:root {
  --bg: #0c0c0d;
  --bg-2: #111113;
  --surface: #0a0a0b;
  --card: #161618;
  --card-alt: #1c1c1f;
  --border: #2a2a2e;
  --border-strong: rgba(224, 182, 58, 0.35);
  --line: rgba(224, 182, 58, 0.18);
  --text: #f4f1ea;
  --muted: #8d887b;
  --dim: #5c584f;
  --accent: #e0b63a;
  --accent-dark: #8f6d2c;
  --accent-soft: #e0b63a18;
  --gold: #f3e0a0;
  --ok: #8fbf6e;
  --warn: #d4a24a;
  --danger: #c45c4a;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem clamp(1rem, 3vw, 2.5rem);
  border-bottom: 1px solid var(--border-strong);
  background: rgba(10, 10, 11, 0.98);
  position: sticky;
  top: 0;
  z-index: 10;
}

body.is-authenticated .topbar { display: none; }

.topbar h1 {
  font-size: 1.08rem;
  margin: 0;
  font-weight: 850;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.topbar-brand img { display: none; }

.language-switch {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.lang-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  background: var(--card-alt);
  border: 1px solid var(--border);
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 17px;
  line-height: 1;
}

.lang-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(224, 182, 58, 0.18);
}

main { max-width: 1060px; margin: 0 auto; padding: 1.5rem; }

#auth-view {
  min-height: calc(100vh - 74px);
  max-width: 1040px;
  padding-top: 2rem;
  padding-bottom: 2rem;
}

.auth-shell {
  min-height: calc(100vh - 138px);
  display: grid;
  grid-template-columns: minmax(280px, 440px) minmax(300px, 400px);
  align-items: center;
  justify-content: center;
  gap: clamp(1.5rem, 5vw, 5rem);
}

.auth-brand { display: flex; justify-content: center; }
.auth-brand img {
  width: clamp(260px, 36vw, 430px);
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 38px;
  border: 1px solid var(--border);
}

.auth-panel { width: 100%; }

.grid { display: grid; grid-template-columns: 1.45fr 0.9fr; gap: 1rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  margin-bottom: 1rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

#auth-view .card { background: var(--surface); border-color: var(--border); }

.card h2 {
  margin-top: 0;
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

form { display: flex; flex-direction: column; gap: 0.5rem; }
.inline-form { flex-direction: row; flex-wrap: wrap; margin-bottom: 0.75rem; }

input, select {
  background: #101012;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

button {
  background: var(--accent);
  color: #1a1404;
  border: 0;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
button:hover { filter: brightness(1.08); }

.btn-gold { background: var(--accent); color: #1a1404; }

.secondary-btn,
.danger-btn {
  background: var(--card-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
}
.secondary-btn:hover { background: #201f1c; border-color: var(--accent-dark); }

.hidden { display: none !important; }

.msg { color: var(--danger); min-height: 1.2em; font-size: 0.9rem; }
.msg.ok { color: var(--accent); }

a { color: var(--accent); text-decoration: none; }

/* --- Rail nav --- */

.app { min-height: 100vh; display: grid; grid-template-columns: 108px 1fr; }
.app.hidden { display: none; }

nav.rail {
  position: sticky; top: 0; height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center;
  padding: 18px 8px 18px; gap: 7px;
  z-index: 10;
}
.mark { width: 68px; height: 68px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 4px; }
.mark img { width: 100%; height: 100%; object-fit: cover; display: block; }

.rail-info {
  width: 100%;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: 2px 4px 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.rail-day { font-size: 32px; font-weight: 900; line-height: 1; color: var(--gold); letter-spacing: -0.01em; }
.rail-monthyear { margin-top: 3px; font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.rail-weekday { margin-top: 5px; font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.rail-user {
  margin-top: 10px; width: 100%; font-size: 10.5px; font-weight: 700; color: var(--text);
  background: var(--accent-soft); border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 5px 6px; word-break: break-word; line-height: 1.3;
}

.rail-language {
  justify-content: center;
  margin-top: 8px;
}

.rail-language .lang-btn {
  width: 28px;
  height: 28px;
  font-size: 14px;
}

.rail button.nav {
  width: 88px; border: 0; background: transparent; color: var(--muted);
  display: grid; place-items: center; gap: 4px; padding: 10px 4px; border-radius: 12px;
  font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 700;
}
.rail button.nav.active { background: #24200f; color: var(--gold); }
.rail button.nav:hover { color: var(--gold); }
.rail .spacer { flex: 1; }

#app-view { padding: 18px 22px 40px; max-width: none; }

.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.eyebrow { color: var(--accent); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; margin: 0 0 4px; }
.top h1 { margin: 0; font-size: 26px; letter-spacing: 0.02em; font-weight: 700; text-transform: capitalize; }
.who {
  color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 0.5rem;
  background: var(--card-alt); border: 1px solid var(--border); border-radius: 999px;
  padding: 0.4rem 0.9rem;
}
.who b { color: var(--gold); font-weight: 800; font-size: 0.95rem; letter-spacing: 0.01em; }

.view-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }

/* --- Week strip --- */

.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-bottom: 16px; }
.day {
  background: var(--card-alt); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 10px 12px; min-height: 132px; text-align: left; color: inherit;
  overflow: hidden;
}
.day { font-weight: 400; }
.day .d { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.day .name { font-weight: 700; color: var(--text); letter-spacing: 0.04em; }
.day .plan { margin-top: 8px; font-size: 13px; line-height: 1.25; font-weight: 700; }
.day .meta { margin-top: 6px; font-size: 11px; color: var(--dim); font-weight: 400; }
.week-plan-list { list-style: none; padding: 0; margin: 7px 0 0; display: grid; gap: 5px; }
.week-plan-list li { display: grid; gap: 1px; min-width: 0; }
.week-plan-list b { color: var(--text); font-size: 11px; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.week-plan-list span { color: var(--muted); font-size: 10px; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.week-plan-list .more-items { color: var(--gold); font-size: 10px; font-weight: 800; }
.day.trained { border-color: rgba(143, 191, 110, 0.35); background: #16210f; }
.day.today { outline: 1px solid var(--accent); }
.day.rest { opacity: 0.78; }

/* --- Hero / lifts / stats --- */

.hero-kicker { color: var(--muted); font-size: 13px; margin: 0 0 6px; }
.hero-title { font-size: 26px; margin: 0 0 8px; letter-spacing: 0.02em; }
.hero-sub { color: var(--muted); margin: 0 0 16px; font-size: 14px; max-width: 60ch; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

.lifts { display: grid; gap: 6px; margin-top: 0.5rem; }
.lift {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center;
  background: var(--card-alt); border-radius: 10px; padding: 9px 11px; border: 1px solid var(--border);
}
.lift b { font-size: 14px; }
.lift .last { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.lift .next { color: var(--gold); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 0; }
.stat { background: #121214; border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.stat strong { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 11px; letter-spacing: 0.04em; }

.side { display: grid; gap: 12px; align-content: start; }
.waga-row { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.waga-row strong { font-size: 30px; font-variant-numeric: tabular-nums; }
.note { color: var(--muted); font-size: 12px; margin: 0; }
.note.down, .note.trend-good { color: var(--accent); }
.note.trend-bad { color: var(--warn); }

.log { display: flex; gap: 8px; margin-top: 10px; flex-direction: row; }
.log input { flex: 1; min-width: 0; }

.dashboard-list, .recommendation-list { display: grid; gap: 0.55rem; }
.dashboard-list p, .recommendation-list p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.dashboard-list-item, .recommendation-item {
  background: var(--card-alt); border: 1px solid var(--border); border-radius: var(--radius);
  display: grid; gap: 0.2rem; padding: 0.7rem 0.8rem;
}
.dashboard-list-item strong, .recommendation-item strong { font-size: 0.92rem; }
.dashboard-list-item span, .recommendation-item small, .trend-note { color: var(--muted); font-size: 0.82rem; }
.recommendation-item span { color: var(--accent); font-size: 0.84rem; font-weight: 700; }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  border: 1px solid var(--border); background: #121214; border-radius: 999px;
  padding: 5px 9px; font-size: 12px; color: var(--muted);
}
.pill.on { color: #1a1404; background: var(--accent); border-color: transparent; font-weight: 700; }
.pill.rec { color: var(--ok); border-color: rgba(143, 191, 110, 0.3); }
.pill.sore { color: var(--warn); border-color: rgba(212, 162, 74, 0.3); }

/* --- Mapa mięśni --- */

.seg-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.7rem; }
.seg-btn {
  background: var(--card-alt); border: 1px solid var(--border); color: var(--muted);
  border-radius: 999px; padding: 0.4rem 0.9rem; font-size: 0.82rem; font-weight: 700;
}
.seg-btn.active { background: var(--accent); color: #120d04; border-color: var(--accent); }

.muscle-picker-row { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.6rem; flex-wrap: wrap; }
.muscle-picker-row label { color: var(--muted); font-size: 0.82rem; }
.muscle-picker-row select { flex: 1; min-width: 180px; }
.muscle-map { display: flex; justify-content: center; gap: 1rem; padding: 0.25rem 0 0.5rem; }
.bm-col { display: flex; flex-direction: column; align-items: center; flex: 1; min-width: 0; max-width: 190px; }
.bm-v { width: 100%; height: auto; }
.bm-label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 0.3rem; }
.muscle-region, .muscle-inert { stroke: var(--bg); stroke-width: 1.5; stroke-linejoin: round; transition: fill 0.2s, fill-opacity 0.2s; cursor: pointer; }
.muscle-inert { fill: #1c1c1f; cursor: default; }
.muscle-region { fill: #1c1c1f; }
.muscle-region.sel { stroke: var(--accent); stroke-width: 2; }

/* Bilans: poziomy 0-4 tej samej palety co roczna/miesięczna heatmapa. */
.muscle-region.lvl-0 { fill: #1c1c1f; }
.muscle-region.lvl-1 { fill: #3a3418; }
.muscle-region.lvl-2 { fill: #6d5a1c; }
.muscle-region.lvl-3 { fill: #b8891d; }
.muscle-region.lvl-4 { fill: var(--accent); }

/* Zmęczenie: gotowe / regeneruje się / zmęczone. */
.muscle-region.state-ready { fill: var(--ok); fill-opacity: 0.35; }
.muscle-region.state-recovering { fill: var(--warn); fill-opacity: 0.6; }
.muscle-region.state-fatigued { fill: var(--danger); fill-opacity: 0.85; }

/* Siła: intensywność wypełnienia = zachowana siła (0.5 podłoga .. 1 pełnia). */
.muscle-region.strength-fill { fill: var(--accent); }

.heat-rec { background: var(--ok); }
.heat-sore { background: var(--warn); }
.heat-fatigued { background: var(--danger); }
.heat-none { background: #1c1c1f; }

.mrow { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0; border-top: 1px solid var(--border); font-size: 0.85rem; }
.mrow:first-child { border-top: 0; }
.mrow .nm { flex: 1; min-width: 0; }
.mrow .nm small { display: block; color: var(--muted); font-weight: 400; font-size: 0.75rem; }
.mrow .bar { flex: 1.4; height: 8px; background: #121214; border-radius: 999px; overflow: hidden; }
.mrow .bar i { display: block; height: 100%; background: var(--accent); }
.mrow .v { color: var(--muted); font-size: 0.8rem; white-space: nowrap; text-align: right; }
.mchips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem; }
.mchip { background: var(--card-alt); border: 1px solid var(--border); color: var(--muted); border-radius: 999px; padding: 0.3rem 0.7rem; font-size: 0.78rem; }
.sec { margin: 0.8rem 0 0.3rem; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 800; }

/* --- RIR (ile zostało w zapasie) --- */

.rir-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.6rem; }
.rir-label { color: var(--muted); font-size: 0.78rem; width: 100%; }
.rir-btn { background: var(--card-alt); border: 1px solid var(--border); color: var(--muted); padding: 0.35rem 0.7rem; font-size: 0.78rem; border-radius: 999px; }
.rir-btn.active { background: var(--warn); color: #1a1404; border-color: var(--warn); }
.row-rir { font-size: 0.72rem; padding: 0.3rem; }

/* --- Workout mode --- */

table.sets { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.sets th { text-align: left; color: var(--dim); font-size: 11px; letter-spacing: 0.08em; font-weight: 600; padding: 6px 8px; }
table.sets td { padding: 8px; border-top: 1px solid var(--border); font-size: 13px; }
table.sets tr.current { background: #24200f; }
table.sets input, table.sets select { padding: 0.4rem 0.5rem; font-size: 0.85rem; width: 100%; }
table.sets .row-actions { display: flex; gap: 0.3rem; }

.timer {
  width: 84px; height: 84px; border-radius: 50%; border: 6px solid #2a2410;
  border-top-color: var(--accent); display: grid; place-items: center; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.board { margin-top: 12px; display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 12px; }
.numbers-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.numbers-grid .card { padding: 1rem; }
.numbers-grid canvas { max-height: 150px; }
.numbers-grid .recommendation-list { max-height: 210px; overflow-y: auto; padding-right: 0.2rem; }
.numbers-history-grid { display: grid; grid-template-columns: minmax(280px, 0.9fr) minmax(340px, 1.1fr); gap: 1rem; align-items: start; }

.summary { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.summary .stat { text-align: center; }
.summary .stat .num { font-size: 2.1rem; font-weight: 800; letter-spacing: -0.02em; }
.summary .stat .label { color: var(--muted); font-size: 0.82rem; }

.card-heading-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.card-meta { color: var(--muted); font-size: 0.82rem; font-weight: 700; text-transform: lowercase; }

.month-heatmap { display: grid; gap: 0.4rem; }

.year-heatmap { overflow-x: auto; overflow-y: visible; padding: 1.7rem 0 0.35rem; margin-top: -1.35rem; position: relative; z-index: 2; }
.year-months { display: grid; min-width: 820px; padding-left: 44px; margin-bottom: 0.35rem; }
.year-months span { color: var(--muted); font-size: 0.74rem; text-transform: capitalize; }
.year-body { align-items: start; display: flex; gap: 0.45rem; min-width: 860px; }
.year-days { color: var(--muted); display: grid; font-size: 0.72rem; gap: 3px; grid-template-rows: repeat(7, 12px); line-height: 12px; width: 40px; }
.year-weeks { display: flex; gap: 3px; }
.year-week { display: grid; gap: 3px; grid-template-rows: repeat(7, 12px); }
.year-cell {
  border: 1px solid rgba(244, 241, 234, 0.14); border-radius: 3px; display: block; height: 12px; width: 12px;
  position: relative; cursor: default; transition: transform 0.12s, border-color 0.12s;
  padding: 0; min-width: 0;
}
.year-cell:disabled { cursor: default; }
.year-cell.has-session { cursor: pointer; }
.year-cell.out { opacity: 0.35; }
.year-cell:hover {
  border-color: var(--accent); transform: scale(1.35); z-index: 30; box-shadow: 0 0 0 1px var(--accent);
}
.year-cell[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  margin-bottom: 8px; background: #000; color: var(--text);
  border: 1px solid var(--border-strong); padding: 4px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600; white-space: nowrap; pointer-events: none; z-index: 60;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
}

.month-weekdays, .month-grid { display: grid; grid-template-columns: repeat(7, 44px); gap: 0.35rem; }
.month-weekdays span { color: var(--muted); font-size: 0.62rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; text-align: center; }
.month-cell {
  aspect-ratio: 1; border: 1px solid rgba(244, 241, 234, 0.14); border-radius: 6px;
  display: flex; flex-direction: column; justify-content: flex-start; width: 44px; padding: 0.35rem 0.4rem;
  position: relative; cursor: default; transition: border-color 0.12s, transform 0.12s;
  color: var(--text); text-align: left; min-width: 0;
}
.month-cell:disabled { cursor: default; }
.month-cell.has-session { cursor: pointer; }
.month-cell.empty { border-color: transparent; background: transparent; }
.month-cell span { font-size: 0.7rem; font-weight: 800; }
.month-cell.today { border-color: var(--accent); border-width: 2px; }
.month-cell:not(.empty):hover {
  border-color: var(--accent); transform: scale(1.06); z-index: 3; box-shadow: 0 0 0 1px var(--accent);
}
.month-cell[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  margin-bottom: 8px; background: #000; color: var(--text);
  border: 1px solid var(--border-strong); padding: 4px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600; white-space: nowrap; pointer-events: none; z-index: 20;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
}

.heat-0 { background: #121212; }
.heat-1 { background: #3a3418; }
.heat-2 { background: #6d5a1c; }
.heat-3 { background: #b8891d; }
.heat-4 { background: #e0b63a; color: #120d04; }
.month-cell.heat-0 { background: #141416; }
.month-cell.heat-1 { background: #272516; }
.month-cell.heat-2 { background: #4d421e; }
.month-cell.heat-3 { background: #806a27; }
.month-cell.heat-4 { background: #b99332; color: #120d04; }

.heatmap-legend { align-items: center; color: var(--muted); display: flex; gap: 0.35rem; justify-content: flex-end; margin-top: 0.65rem; font-size: 0.75rem; }
.heatmap-legend i { border: 1px solid var(--border); border-radius: 3px; display: block; height: 13px; width: 13px; }

.recommendation { background: var(--accent-soft); border: 1px solid var(--accent-dark); border-radius: 12px; padding: 0.8rem 0.9rem; margin: 0.5rem 0; font-size: 0.9rem; }

canvas { width: 100%; max-width: 480px; margin-top: 0.5rem; }

.stack-form { gap: 0.6rem; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 120px; }

.routine-grid { display: flex; flex-direction: column; gap: 1rem; }
.routine-day {
  background: linear-gradient(180deg, #202023 0%, var(--card-alt) 100%);
  border: 1px solid rgba(244, 241, 234, 0.12);
  border-radius: 10px;
  padding: 0.85rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}
.routine-day.has-items { border-color: rgba(224, 182, 58, 0.28); }
.routine-day.focus-ring { box-shadow: 0 0 0 2px var(--accent), 0 14px 38px rgba(0, 0, 0, 0.45); }
.routine-day-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.65rem; }
.routine-day-head h3 { margin: 0; font-size: 0.95rem; color: var(--gold); font-weight: 800; }
.routine-day-head span {
  min-width: 26px;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--gold);
  border: 1px solid var(--border-strong);
  text-align: center;
  font-size: 0.74rem;
  font-weight: 800;
}
.routine-day-label-field { margin-bottom: 0.7rem; }
.routine-day-label { width: 100%; font-size: 0.82rem; padding: 0.48rem 0.6rem; }
.routine-items { display: grid; gap: 0.5rem; min-height: 38px; }
.routine-item, .routine-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 140px) 32px;
  gap: 0.6rem;
  align-items: end;
}
.routine-item {
  background: rgba(10, 10, 11, 0.48);
  border: 1px solid rgba(244, 241, 234, 0.08);
  border-radius: 8px;
  padding: 0.55rem;
}
.routine-item .danger-btn { align-self: center; }
.routine-add-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 140px);
  margin-top: 0.7rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(244, 241, 234, 0.1);
}
.routine-item select, .routine-add-row select, .routine-item input, .routine-add-row input { margin-top: 0; min-width: 0; width: 100%; font-size: 0.78rem; padding: 0.45rem 0.52rem; }
.routine-empty { color: var(--muted); font-size: 0.82rem; margin: 0; padding: 0.45rem 0.1rem; }

.field { display: flex; flex-direction: column; gap: 0.28rem; min-width: 0; }
.field-label { font-size: 0.7rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.danger-btn { color: var(--danger); padding: 0.45rem 0; }
.danger-btn:hover { background: #2a1111; }

.history-controls { display: grid; gap: 0.65rem; margin-bottom: 0.8rem; }
.date-range { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.55rem; }
.date-range label { display: grid; gap: 0.25rem; color: var(--muted); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; }
.date-range input { width: 100%; font-size: 0.82rem; padding: 0.45rem 0.55rem; }
.quick-filters { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.quick-filters button { padding: 0.42rem 0.62rem; font-size: 0.74rem; }
#session-history { display: grid; gap: 0.35rem; max-height: 430px; overflow-y: auto; padding-right: 0.2rem; }
.session-item {
  width: 100%; display: grid; gap: 0.18rem; padding: 0.62rem 0.7rem; border: 1px solid transparent;
  border-bottom-color: var(--border); cursor: pointer; border-radius: 8px; background: transparent; color: var(--text);
  text-align: left; line-height: 1.25;
}
.session-item span { color: var(--muted); font-size: 0.76rem; }
.session-item strong { font-size: 0.88rem; }
.session-item small { color: var(--muted); font-size: 0.76rem; }
.session-item:hover, .session-item.active { background: var(--card-alt); border-color: var(--border-strong); }

.exercise-description { font-size: 0.82rem; color: var(--muted); background: var(--card-alt); border-radius: 10px; padding: 0.6rem 0.75rem; margin: 0; }

.exercise-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.75rem; }
.exercise-card { background: var(--card-alt); border: 1px solid var(--border); border-radius: 14px; padding: 0.8rem; }
.exercise-card h4 { margin: 0 0 0.4rem; font-size: 0.95rem; font-weight: 700; }
.exercise-card p { margin: 0.3rem 0 0; font-size: 0.8rem; color: var(--muted); }
.exercise-edit-form { margin-top: 0.75rem; gap: 0.6rem; }
.mini-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.45rem; }
.exercise-edit-form input, .exercise-edit-form select, .exercise-edit-form button { width: 100%; min-width: 0; font-size: 0.82rem; padding: 0.48rem 0.6rem; }
.exercise-muscles { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.45rem; }
.muscle-check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 0.35rem; max-height: 150px; overflow-y: auto; padding: 0.2rem; border: 1px solid var(--border); border-radius: 8px; background: rgba(10, 10, 11, 0.32); }
.muscle-check { display: flex; align-items: center; gap: 0.4rem; min-width: 0; color: var(--muted); font-size: 0.76rem; line-height: 1.2; }
.muscle-check input { width: 15px; height: 15px; min-width: 15px; accent-color: var(--accent); padding: 0; }
.muscle-check span { min-width: 0; overflow-wrap: anywhere; }

.weight-entry-list { display: grid; gap: 0.4rem; margin: 0.65rem 0; }
.weight-entry { display: grid; grid-template-columns: minmax(82px, 1fr) 82px auto; gap: 0.4rem; align-items: center; font-size: 0.78rem; color: var(--muted); }
.weight-entry input, .weight-entry button { font-size: 0.78rem; padding: 0.42rem 0.55rem; }

.editable-set-list { display: grid; gap: 0.5rem; }
.editable-set { display: grid; grid-template-columns: minmax(150px, 1.4fr) 86px 72px 82px auto; gap: 0.45rem; align-items: center; }
.editable-set input, .editable-set select, .editable-set button { min-width: 0; font-size: 0.82rem; padding: 0.45rem 0.55rem; }

.badge { display: inline-block; font-size: 0.68rem; font-weight: 700; padding: 0.2rem 0.55rem; border-radius: 999px; color: #120d04; }
.badge-nogi { background: var(--accent); }
.badge-plecy { background: #a78bfa; }
.badge-klatka { background: #f472b6; }
.badge-barki { background: var(--gold); }
.badge-ramiona { background: #60d6ff; }
.badge-brzuch { background: #fb923c; }
.badge-default { background: var(--muted); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; max-width: 360px; }
.switch-row input[type="checkbox"] {
  width: 46px; height: 26px; appearance: none; background: var(--border); border-radius: 999px;
  position: relative; cursor: pointer; outline: none;
}
.switch-row input[type="checkbox"]::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px;
  border-radius: 50%; background: white; transition: transform 0.15s;
}
.switch-row input[type="checkbox"]:checked { background: var(--danger); }
.switch-row input[type="checkbox"]:checked::before { transform: translateX(20px); }

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.admin-table th, .admin-table td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); }
.admin-table th { color: var(--muted); font-weight: 600; }
.admin-table select { font-size: 0.8rem; }
.admin-table button { font-size: 0.78rem; padding: 0.35rem 0.7rem; }

.muted-count { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.library-search { width: 100%; margin-bottom: 0.7rem; }

.chip-row { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip { background: var(--card-alt); border: 1px solid var(--border); color: var(--muted); padding: 0.35rem 0.8rem; border-radius: 999px; font-size: 0.8rem; cursor: pointer; font-weight: 600; }
.chip.active { background: var(--accent); color: #120d04; border-color: var(--accent); }

.library-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0.75rem; max-height: 640px; overflow-y: auto; padding-right: 0.2rem; }
.library-card { background: var(--card-alt); border: 1px solid var(--border); border-radius: 14px; padding: 0.8rem; display: flex; flex-direction: column; gap: 0.4rem; }
.library-card .icon-row { display: flex; align-items: center; gap: 0.6rem; }
.library-card .icon-row .icon-box { background: var(--accent-soft); color: var(--accent); border-radius: 10px; padding: 0.4rem; display: flex; }
.library-card h4 { margin: 0; font-size: 0.92rem; font-weight: 700; }
.library-card p { margin: 0; font-size: 0.78rem; color: var(--muted); }
.library-card .meta { font-size: 0.72rem; color: var(--muted); }
.library-card button { align-self: flex-start; font-size: 0.78rem; padding: 0.35rem 0.8rem; }
.library-card button:disabled { background: var(--border); color: var(--muted); cursor: default; }

.banner { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-dark); border-radius: 12px; padding: 0.7rem 1rem; margin-bottom: 1rem; font-weight: 600; }

@media (max-width: 1080px) {
  .app { grid-template-columns: 1fr; }
  nav.rail {
    position: sticky; top: auto; bottom: 0; height: auto; width: 100%;
    flex-direction: row; justify-content: space-around; border-right: 0;
    border-top: 1px solid var(--line); z-index: 15;
  }
  .mark { display: none; }
  .rail-info { display: none; }
  .rail .spacer { display: none; }
  #app-view { padding-bottom: 88px; }
  .grid, .board, .week, .numbers-grid, .numbers-history-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .numbers-grid .recommendation-list { max-height: none; }
}

@media (max-width: 520px) {
  main { padding: 1rem; }
  #app-view { padding: 1rem 1rem 88px; }
  .topbar { padding: 0.85rem 1rem; }
  .topbar h1 { font-size: 0.95rem; }
  .auth-brand img { width: min(84vw, 300px); }
  .inline-form { flex-direction: column; }
  .month-weekdays, .month-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.25rem;
  }
  .month-cell { width: auto; padding: 0.3rem; }
  .month-cell span { font-size: 0.66rem; }
  .date-range { grid-template-columns: 1fr; }
  #session-history { max-height: 360px; }
  .routine-item, .routine-add-row, .editable-set, .weight-entry { grid-template-columns: 1fr; }
}
