:root {
  --bg: #000000;
  --panel: #0e0e0f;
  --panel2: #18181a;
  --line: #27272a;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --accent: #22c55e;
  --accent2: #38bdf8;
  --warn: #f59e0b;
  --danger: #ef4444;
  --gold: #facc15;
  --radius: 14px;
  /* похідні токени — кожна тема перевизначає їх */
  --field: #060607;          /* поля вводу, підкладки картинок */
  --topbar: #000000;
  --text2: #d4d4d8;
  --placeholder: #5c5c63;
  --hover: #232326;
  --accent-hover: #4ade80;
  --on-accent: #052e16;      /* текст на зеленому */
  --on-accent2: #082f49;     /* текст на блакитному */
  --danger-text: #fca5a5;
  --accent2-text: #7dd3fc;
  --baseline: #3f3f46;
  --overlay: rgba(0,0,0,.8);
  --shadow: 0 8px 30px rgba(0,0,0,.7);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
button, input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: var(--topbar);
  border-bottom: 1px solid var(--line);
}
.chrome { position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 800; font-size: 1.2rem; letter-spacing: .3px; }
.level { display: flex; align-items: center; gap: 10px; min-width: 0; }
.level .lvl-badge {
  background: var(--gold); color: #1a1a1a; font-weight: 800; border-radius: 999px;
  padding: 2px 10px; white-space: nowrap;
}
.level .xpbar { width: 120px; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.level .xpbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #fb923c); }
.level small { color: var(--muted); white-space: nowrap; }

.tabs {
  display: flex; gap: 6px; padding: 10px 16px; overflow-x: auto;
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.tabs button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 7px 14px; cursor: pointer; white-space: nowrap;
}
.tabs button.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }

main { max-width: 960px; margin: 0 auto; padding: 18px 16px 60px; }
h2 { margin: 6px 0 14px; font-size: 1.35rem; }
h3 { margin: 0 0 8px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}

.btn {
  border: 1px solid var(--line); background: var(--panel2); border-radius: 10px;
  padding: 8px 14px; cursor: pointer; transition: transform .05s, background .15s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.blue { background: var(--accent2); border-color: var(--accent2); color: var(--on-accent2); font-weight: 700; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger-text); }
.btn.small { padding: 4px 10px; font-size: .85rem; }
.btn.icon { padding: 4px 9px; }

/* ---------- Week ---------- */
.week-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.ring { width: 96px; height: 96px; flex: none; }
.ring circle { fill: none; stroke-width: 10; }
.ring .bg { stroke: var(--line); }
.ring .fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .5s; transform: rotate(-90deg); transform-origin: 50% 50%; }
.ring text { fill: var(--text); font-weight: 800; font-size: 20px; }
.week-title { font-size: 1.5rem; font-weight: 800; }
.rank-pill { display: inline-block; padding: 3px 12px; border-radius: 999px; font-weight: 700; font-size: .9rem; margin-top: 4px; }
.rank-0 { background: var(--line); }
.rank-1 { background: #1e3a8a; color: #bfdbfe; }
.rank-2 { background: #78350f; color: #fde68a; }
.rank-3 { background: linear-gradient(90deg, #facc15, #f97316); color: #1a1a1a; }

.champion {
  background: linear-gradient(120deg, #422006, #713f12 40%, #a16207);
  border: 1px solid var(--gold); text-align: center; color: #fef3c7;
}
.champion .big { font-size: 2.4rem; }

.habit-table-wrap { overflow-x: auto; }
.habit-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.habit-table th, .habit-table td { padding: 8px 4px; text-align: center; border-bottom: 1px solid var(--line); }
.habit-table th:first-child, .habit-table td:first-child { text-align: left; padding-left: 0; }
.habit-table th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.habit-table th.today { color: var(--accent); }
.habit-name { font-weight: 600; }
.habit-name small { display: block; color: var(--muted); font-weight: 400; }
.habit-done .habit-name { color: var(--accent); }
.day {
  width: 34px; height: 34px; border-radius: 10px; border: 2px solid var(--line);
  background: transparent; cursor: pointer; font-weight: 800; transition: all .15s;
}
.day:hover { border-color: var(--accent); }
.day.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.day.today { box-shadow: 0 0 0 2px var(--accent2); }
.day.future { opacity: .35; }
.count-pill { display: inline-block; min-width: 46px; padding: 2px 8px; border-radius: 999px; background: var(--panel2); font-weight: 700; font-size: .85rem; }
.count-pill.ok { background: var(--accent); color: var(--on-accent); }

.history { display: flex; gap: 6px; align-items: flex-end; height: 90px; margin-top: 8px; }
.history .bar { flex: 1; background: var(--panel2); border-radius: 6px 6px 2px 2px; position: relative; min-height: 4px; }
.history .bar.full { background: linear-gradient(180deg, var(--gold), var(--accent)); }
.history .bar span { position: absolute; bottom: -20px; left: 0; right: 0; text-align: center; font-size: .7rem; color: var(--muted); }
.history-wrap { padding-bottom: 22px; }

.quote { font-style: italic; color: var(--muted); border-left: 3px solid var(--accent2); padding-left: 10px; }

/* ---------- Programs ---------- */
.group-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.group-head h3 { margin: 0; font-size: 1.2rem; }
.group-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.ex {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  display: flex; flex-direction: column;
}
.ex-img { aspect-ratio: 16/10; background: var(--field); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ex-img img { width: 100%; height: 100%; object-fit: cover; }
.ex-img .ph { font-size: 3rem; opacity: .9; }
.ex-body { padding: 12px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.ex-title { font-weight: 800; font-size: 1.05rem; }
.ex-dose { display: inline-block; background: var(--field); color: var(--accent2); border-radius: 8px; padding: 2px 8px; font-weight: 700; font-size: .9rem; align-self: flex-start; }
.ex ul { margin: 0; padding-left: 18px; color: var(--text2); font-size: .92rem; }
.ex-muscles { margin-top: auto; font-size: .88rem; background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.3); border-radius: 8px; padding: 6px 8px; }
.ex-muscles b { color: var(--accent); }
.ex-actions { display: flex; gap: 6px; padding: 0 12px 12px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 24px; border: 2px dashed var(--line); border-radius: 12px; }

/* ---------- Session ---------- */
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.pick { cursor: pointer; text-align: left; }
.pick:hover { border-color: var(--accent); }
.sess-ex { display: flex; gap: 14px; align-items: flex-start; }
.sess-ex .thumb { width: 92px; height: 70px; border-radius: 10px; overflow: hidden; background: var(--field); flex: none; display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.sess-ex .thumb img { width: 100%; height: 100%; object-fit: cover; }
.sess-ex.done { opacity: .6; }
.sets { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.set {
  width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--line); background: transparent;
  cursor: pointer; font-weight: 800;
}
.set.on { background: var(--accent2); border-color: var(--accent2); color: var(--on-accent2); }
.progress { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width .3s; }
.timer { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
details summary { cursor: pointer; color: var(--muted); }

/* ---------- Rewards ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { background: var(--panel2); border-radius: 12px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 1.6rem; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.badge { background: var(--panel2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-align: center; }
.badge .ic { font-size: 2.4rem; }
.badge.locked { filter: grayscale(1); opacity: .4; }
.badge.got { border-color: var(--gold); box-shadow: 0 0 18px rgba(250,204,21,.15); }
.badge b { display: block; margin-top: 4px; }
.badge small { color: var(--muted); }

/* ---------- Forms / modal ---------- */
label { display: block; font-size: .88rem; color: var(--muted); margin: 10px 0 4px; }
input[type=text], input[type=number], input[type=time], input[type=url], textarea, select {
  width: 100%; background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent2); border-color: transparent; }
[hidden] { display: none !important; }
.modal { position: fixed; inset: 0; background: var(--overlay); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 30px 16px; overflow-y: auto; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; width: 100%; max-width: 560px; }
.modal-card h3 { font-size: 1.2rem; }
.img-preview { margin-top: 8px; max-height: 180px; border-radius: 10px; }
.habit-edit-row { display: grid; grid-template-columns: 1fr 70px 120px auto; gap: 8px; align-items: center; margin-bottom: 8px; }
@media (max-width: 520px) { .habit-edit-row { grid-template-columns: 1fr 60px; } }

.toasts { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: calc(100% - 32px); }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow); animation: pop .3s ease; }
.toast.gold { border-left-color: var(--gold); }
@keyframes pop { from { transform: translateY(20px); opacity: 0; } }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; width: 100%; height: 100%; }

/* ---------- v2: auth, sync, sets log, progress charts ---------- */
.topbar { flex-wrap: wrap; }
.level { margin-left: auto; }
.userbox { display: flex; align-items: center; gap: 8px; }
#sync { font-size: 1rem; cursor: help; }
body.auth .tabs, body.auth .level, body.auth .userbox { display: none; }
.auth-card { max-width: 420px; margin: 40px auto; }
.auth-hero { text-align: center; font-size: 3rem; }
.auth-err { color: var(--danger-text); min-height: 1.2em; margin-top: 8px; font-size: .9rem; }
.link { background: none; border: 0; color: var(--accent2); cursor: pointer; text-decoration: underline; padding: 0; }
input[type=email], input[type=password], input[type=date] {
  width: 100%; background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
}
code { background: var(--field); padding: 1px 6px; border-radius: 6px; }
.small { font-size: .85rem; }
.ex-pr { display: inline-block; background: rgba(250,204,21,.12); color: var(--gold); border: 1px solid rgba(250,204,21,.35); border-radius: 8px; padding: 1px 8px; font-weight: 700; font-size: .85rem; }

.set-table { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; max-width: 340px; }
.set-row { display: grid; grid-template-columns: 26px 1fr 1fr 44px; gap: 8px; align-items: center; }
.set-row.head { color: var(--muted); font-size: .8rem; }
.set-row.head span:nth-child(2), .set-row.head span:nth-child(3) { padding-left: 4px; }
.set-no { color: var(--muted); font-weight: 700; text-align: center; }
.set-in { width: 100%; background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-variant-numeric: tabular-nums; min-width: 0; }
.set-in::placeholder { color: var(--placeholder); }
.set-row.done .set-in { border-color: rgba(56,189,248,.5); }
.set-row .set { width: 44px; height: 40px; border-radius: 10px; }
.sess-ex.done { opacity: .75; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--panel2); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: .9rem; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 700; }
.up { color: var(--accent); }
.down { color: var(--danger-text); }

.chart { position: relative; width: 100%; min-height: 220px; touch-action: pan-y; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; opacity: .6; }
.chart .baseline { stroke: var(--baseline); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); opacity: .08; }
.chart .pt { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }
.chart .pt.hot { r: 6; }
.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .last-label { fill: var(--text); font-size: 12px; font-weight: 700; }
.chart .tip { position: absolute; pointer-events: none; background: var(--field); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: .85rem; white-space: nowrap; box-shadow: 0 6px 20px rgba(0,0,0,.4); }

.table-wrap { overflow-x: auto; }
.hist-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.hist-table th, .hist-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.hist-table th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.hist-table td:first-child { white-space: nowrap; }
.body-list { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
@media (max-width: 520px) {
  .level .xpbar { width: 80px; }
  .xpwrap small { display: none; }
}

@media (max-width: 520px) {
  .topbar { flex-wrap: nowrap; padding-left: 12px; padding-right: 12px; }
  .level .xpbar { display: none; }
  .userbox .btn { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
.notice { background: rgba(56,189,248,.08); border: 1px solid rgba(56,189,248,.3); border-radius: 10px; padding: 4px 14px; }

/* ---------- admin ---------- */
input[type=search] { width: 100%; background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
.tag { display: inline-block; font-size: .75rem; padding: 1px 7px; border-radius: 999px; background: var(--panel2); color: var(--muted); vertical-align: middle; font-weight: 600; }
.tag.admin { background: rgba(56,189,248,.15); color: var(--accent2-text); }
.tag.blocked { background: rgba(239,68,68,.15); color: var(--danger-text); }
.nowrap { white-space: nowrap; }
.admin-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.admin-table th, .admin-table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table th { color: var(--muted); font-weight: 600; font-size: .85rem; }
.admin-table tr.blocked td { opacity: .6; }
.adm-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.adm-actions .btn:disabled { opacity: .35; cursor: not-allowed; }
.audit { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; font-size: .9rem; }

/* запрошення */
.inv-form { display: flex; gap: 8px; flex-wrap: wrap; }
.inv-form input { flex: 1 1 220px; min-width: 0; }
.inv-form select { flex: 0 0 auto; width: auto; }
.auth-card .notice { margin-bottom: 12px; }

/* ==========================================================================
   Дизайн-система v3: шрифт Inter, лінійні SVG-іконки, плоска навігація,
   стримані радіуси. Кольори беруться з токенів — теми нижче їх перевизначають.
   ========================================================================== */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap; src: url(fonts/inter-cyrillic-ext.woff2) format("woff2"); unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap; src: url(fonts/inter-cyrillic.woff2) format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap; src: url(fonts/inter-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400 700; font-display: swap; src: url(fonts/inter-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 10px;
  --r-sm: 6px;
}
body {
  font-family: var(--font); font-size: 14.5px; line-height: 1.5;
  font-feature-settings: "cv05", "cv08", "ss03"; /* чіткіші l, 0 та круглі розділові знаки */
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  letter-spacing: -.003em;
}
h2 { font-size: 1.375rem; font-weight: 650; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; }
h3 { font-size: 1rem; font-weight: 600; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
h2 > .i, h3 > .i { color: var(--muted); }
b, strong { font-weight: 600; }
.stat b, .timer, .week-title, .count-pill, .set-in, .chart .axis, .admin-table td { font-variant-numeric: tabular-nums; }

/* іконки */
.i { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; }
.i.ok { color: var(--accent); margin-right: 6px; }
.i.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* шапка */
.topbar { padding-top: calc(10px + env(safe-area-inset-top, 0px)); padding-bottom: 10px; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; font-weight: 700; letter-spacing: -.02em; }
.logo { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: var(--on-accent); display: inline-grid; place-items: center; flex: none; }
.logo .i { width: 16px; height: 16px; stroke-width: 2.25; vertical-align: 0; }
.logo.lg { width: 56px; height: 56px; border-radius: 14px; }
.logo.lg .i { width: 28px; height: 28px; }
img.logo { display: block; background: none; border-radius: 22%; box-shadow: 0 0 0 1px rgba(255,255,255,.08); }
.logo.lg { width: 64px; height: 64px; }
.auth-hero { display: flex; justify-content: center; margin-bottom: 6px; }
.auth-card h2 { justify-content: center; }
.level .lvl-badge { background: transparent; color: var(--gold); border: 1px solid currentColor; border-radius: 4px; padding: 1px 7px; font-size: .78rem; font-weight: 650; letter-spacing: .02em; }
.level .xpbar { height: 6px; border-radius: 3px; }
.level small { font-size: .76rem; }
.level .streak { display: inline-flex; align-items: center; gap: 4px; color: var(--warn); font-weight: 600; font-size: .85rem; }
.userbox .btn { gap: 6px; }
#sync { display: inline-flex; color: var(--muted); }
#sync .i { width: 17px; height: 17px; }
#sync.sync-offline { color: var(--warn); }

/* навігація — плоскі вкладки з підкресленням активної */
.tabs { gap: 2px; padding: 0 12px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  display: inline-flex; align-items: center; gap: 8px; position: relative;
  border: 0; border-radius: 0; background: transparent; color: var(--muted);
  padding: 13px 12px 12px; font-size: .9rem; font-weight: 500; transition: color .15s;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { background: transparent; color: var(--text); border: 0; font-weight: 600; }
.tabs button.active::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--accent); }
.tabs button .i { width: 17px; height: 17px; }
.tabs button.active .i { color: var(--accent); }

/* кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: var(--r-sm); padding: 8px 14px; font-size: .9rem; font-weight: 500; line-height: 1.25; }
.btn .i { width: 1.05em; height: 1.05em; }
.btn.small { padding: 5px 10px; font-size: .83rem; gap: 6px; }
.btn.icon, .btn.small.icon { padding: 6px; }
.btn.primary, .btn.blue { font-weight: 600; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.link { text-underline-offset: 3px; }

/* поверхні */
.card { border-radius: var(--radius); padding: 18px; }
.modal-card { border-radius: 12px; }
input[type=text], input[type=number], input[type=time], input[type=url], input[type=email], input[type=password], input[type=date], input[type=search], textarea, select, .set-in { border-radius: var(--r-sm); }
label { font-weight: 500; font-size: .82rem; }

/* статуси, мітки */
.rank-pill { display: inline-flex; align-items: center; gap: 6px; border-radius: var(--r-sm); padding: 3px 10px; font-size: .8rem; font-weight: 600; }
.count-pill { border-radius: 4px; font-size: .8rem; }
.tag { display: inline-flex; align-items: center; gap: 4px; border-radius: 4px; font-size: .72rem; letter-spacing: .01em; }
.tag .i { width: 12px; height: 12px; }
.chip { border-radius: var(--r-sm); font-size: .85rem; font-weight: 500; }
.ex-dose { border-radius: 4px; }
.ex-pr { display: inline-flex; align-items: center; gap: 4px; border-radius: 4px; }
.ex-pr .i { width: 13px; height: 13px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot.ok { background: var(--accent); } .dot.used { background: var(--accent2); } .dot.off { background: var(--muted); opacity: .6; } .dot.bad { background: var(--danger); }
.notice { display: block; }
.notice > .i, .muted > .i { color: var(--accent2); }

/* таблиці */
.habit-table th, .admin-table th { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.habit-name { font-weight: 550; }
.habit-name .i.ok { margin-right: 5px; vertical-align: -.22em; }
.day { border-radius: var(--r-sm); border-width: 1.5px; display: inline-grid; place-items: center; }
.day .i { width: 18px; height: 18px; stroke-width: 2.5; }
.set { display: inline-grid; place-items: center; }
.set-row .set { border-radius: var(--r-sm); }
.set .i { width: 18px; height: 18px; stroke-width: 2.5; }
.log-row { display: flex; align-items: center; }

/* вправи: заглушка замість emoji */
.ex-img, .sess-ex .thumb { background: repeating-linear-gradient(135deg, transparent 0 11px, rgba(127,127,127,.07) 11px 12px), var(--field); }
.ex-img .ph, .sess-ex .thumb { color: var(--muted); }
.ex-img .ph { opacity: .45; font-size: 1rem; }
.ex-img .ph .i { width: 44px; height: 44px; stroke-width: 1.25; }
.sess-ex .thumb .ph .i { width: 26px; height: 26px; stroke-width: 1.5; }
.ex { border-radius: var(--radius); }
.ex-title { font-weight: 650; letter-spacing: -.01em; }

/* ачівки — медалі з іконками */
.badge { border-radius: var(--radius); }
.badge .ic { width: 56px; height: 56px; margin: 2px auto 10px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--line); color: var(--muted); background: var(--panel); font-size: 1rem; }
.badge .ic .i { width: 26px; height: 26px; stroke-width: 1.6; }
.badge.got .ic { border-color: var(--gold); color: var(--gold); background: radial-gradient(circle at 30% 25%, rgba(250,204,21,.16), transparent 70%), var(--panel); box-shadow: 0 0 0 4px rgba(250,204,21,.06); }
.badge b { font-weight: 600; }
.champion .big .i { width: 44px; height: 44px; stroke-width: 1.5; color: var(--gold); }

/* тости */
.toast { display: flex; align-items: flex-start; gap: 10px; border-radius: 8px; border-left-width: 3px; font-size: .9rem; }
.toast-ic { color: var(--accent); display: inline-flex; padding-top: 1px; }
.toast.gold .toast-ic { color: var(--gold); }

/* вибір теми */
.theme-opt { border-radius: 8px; border-width: 1.5px; }
.theme-prev { border-radius: 5px; }
.stat { border-radius: 8px; }
.stat b { font-weight: 650; letter-spacing: -.02em; }


/* ==========================================================================
   Теми. Базові токени (= «Темна») — у :root вище; інші перевизначають їх.
   Вмикаються атрибутом data-theme на <html>.
   ========================================================================== */
:root[data-theme="dark"] {
  --bg: #000000; --panel: #0e0e0f; --panel2: #18181a; --line: #27272a;
  --text: #f4f4f5; --muted: #a1a1aa; --text2: #d4d4d8; --placeholder: #5c5c63;
  --field: #060607; --topbar: #000000; --hover: #232326; --baseline: #3f3f46;
  --overlay: rgba(0,0,0,.8); --shadow: 0 8px 30px rgba(0,0,0,.7);
}
:root[data-theme="graphite"] {
  --bg: #111214; --panel: #1b1c1f; --panel2: #242529; --line: #313237;
  --text: #e9e9eb; --muted: #9c9ea5; --text2: #c8c9cd; --placeholder: #6b6d74;
  --field: #151619; --topbar: linear-gradient(90deg, #141518, #1e1f23); --hover: #2e3035; --baseline: #4b4d54;
  --overlay: rgba(5,5,6,.75);
}
/* Glass Black — напівпрозоре «рідке скло» на чорному з кольоровим світлом позаду */
:root[data-theme="glass"] {
  --bg: #000000; --panel: rgba(255,255,255,.07); --panel2: rgba(255,255,255,.08); --line: rgba(255,255,255,.13);
  --text: #f5f5f7; --muted: rgba(235,235,245,.6); --text2: rgba(235,235,245,.82); --placeholder: rgba(235,235,245,.32);
  --accent: #30d158; --accent-hover: #4be06f; --accent2: #0a84ff; --accent2-text: #64d2ff;
  --gold: #ffd60a; --danger: #ff453a; --danger-text: #ff6961;
  --on-accent: #002810; --on-accent2: #ffffff;
  --field: rgba(255,255,255,.06); --topbar: transparent; --hover: rgba(255,255,255,.15); --baseline: rgba(255,255,255,.3);
  --overlay: rgba(0,0,0,.5); --shadow: 0 12px 40px rgba(0,0,0,.6);
  --radius: 14px;
}
/* спільна «скляна» поведінка для Glass Black і Glass White; кольори — у токенах --g-* */
:root[data-theme="glass"] {
  --g-page: radial-gradient(55% 45% at 12% 8%, rgba(48,209,88,.20), transparent 70%),
            radial-gradient(50% 42% at 92% 28%, rgba(10,132,255,.24), transparent 70%),
            radial-gradient(60% 50% at 45% 105%, rgba(191,90,242,.20), transparent 70%), #000;
  --g-chrome: rgba(0,0,0,.42);
  --g-hi: inset 0 1px 0 rgba(255,255,255,.14), 0 10px 30px rgba(0,0,0,.35);
  --g-btn: rgba(255,255,255,.1);
  --g-active-bg: rgba(255,255,255,.92); --g-active-fg: #000;
  --g-modal: rgba(28,28,30,.72);
  --g-option: #1c1c1e;
}
:root:is([data-theme="glass"], [data-theme="glass-white"]) body { background: var(--g-page); background-attachment: fixed; }
:root:is([data-theme="glass"], [data-theme="glass-white"]) .chrome {
  background: var(--g-chrome);
  -webkit-backdrop-filter: blur(28px) saturate(180%); backdrop-filter: blur(28px) saturate(180%);
}
:root:is([data-theme="glass"], [data-theme="glass-white"]) .tabs { background: transparent; }
:root:is([data-theme="glass"], [data-theme="glass-white"]) :is(.card, .modal-card, .toast, .chart .tip) {
  -webkit-backdrop-filter: blur(24px) saturate(180%); backdrop-filter: blur(24px) saturate(180%);
  box-shadow: var(--g-hi);
}
:root:is([data-theme="glass"], [data-theme="glass-white"]) .btn:not(.primary):not(.blue):not(.danger) { background: var(--g-btn); }
:root:is([data-theme="glass"], [data-theme="glass-white"]) .modal-card { background: var(--g-modal); }
:root:is([data-theme="glass"], [data-theme="glass-white"]) select option { background: var(--g-option); }

/* Glass White — матове біле скло на світлому пастельному фоні */
:root[data-theme="glass-white"] {
  --bg: #f2f2f7; --panel: rgba(255,255,255,.55); --panel2: rgba(255,255,255,.5); --line: rgba(255,255,255,.75);
  --text: #1c1c1e; --muted: rgba(60,60,67,.62); --text2: rgba(28,28,30,.82); --placeholder: rgba(60,60,67,.4);
  --accent: #28a745; --accent-hover: #218838; --accent2: #007aff; --accent2-text: #0062cc;
  --gold: #ff9f0a; --danger: #ff3b30; --danger-text: #d70015;
  --on-accent: #ffffff; --on-accent2: #ffffff;
  --field: rgba(255,255,255,.65); --topbar: transparent; --hover: rgba(255,255,255,.85); --baseline: rgba(60,60,67,.3);
  --overlay: rgba(242,242,247,.45); --shadow: 0 12px 40px rgba(31,38,135,.15);
  --radius: 14px;
  --g-page: radial-gradient(55% 45% at 10% 5%, rgba(52,199,89,.28), transparent 70%),
            radial-gradient(50% 42% at 95% 25%, rgba(0,122,255,.26), transparent 70%),
            radial-gradient(60% 50% at 40% 105%, rgba(255,45,85,.18), transparent 70%), #eef0f6;
  --g-chrome: rgba(255,255,255,.5);
  --g-hi: inset 0 1px 0 rgba(255,255,255,.9), 0 8px 28px rgba(31,38,135,.10);
  --g-btn: rgba(255,255,255,.6);
  --g-active-bg: #1c1c1e; --g-active-fg: #fff;
  --g-modal: rgba(255,255,255,.8);
  --g-option: #ffffff;
  color-scheme: light;
}
:root[data-theme="glass-white"] .ex-pr { color: #b45309; }
:root[data-theme="glass-white"] .card { border-color: rgba(255,255,255,.8); }
:root[data-theme="glass-white"] :is(.ex, .badge, .stat, .day, .set, .btn, input, select, textarea) { border-color: rgba(60,60,67,.14); }
:root[data-theme="glass-white"] .ex-img, :root[data-theme="glass-white"] .sess-ex .thumb { background: rgba(255,255,255,.45); }

/* вибір теми в налаштуваннях */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.theme-opt { border: 1.5px solid var(--line); background: var(--panel2); border-radius: 8px; padding: 8px; cursor: pointer; text-align: left; }
.theme-opt.on { border-color: var(--accent); }
.theme-opt b { display: block; margin-top: 6px; font-size: .9rem; }
.theme-prev { height: 58px; border-radius: 9px; padding: 8px; display: flex; flex-direction: column; gap: 5px; border: 1px solid rgba(127,127,127,.25); }
.theme-prev i { display: block; height: 10px; border-radius: 5px; }
.theme-prev i:last-child { width: 40%; }
:root[data-theme="glass-white"] .ring .bg { stroke: rgba(60,60,67,.12); }
:root[data-theme="glass-white"] :is(.progress, .level .xpbar, .history .bar:not(.full), .count-pill:not(.ok)) { background: rgba(60,60,67,.1); }

/* ==========================================================================
   Художні теми — фоном сама картина (public/art/), форма завжди посередині.
   data-art="full"  — картина на все тло (Ван Гог «Зоряна ніч»).
   data-art="focus" — головна композиція картини справа, у вільному від форми
     місці; ліворуч, під формами, тло продовжується фоном самої картини
     (плиткою з її ж тла). На телефоні — картина на все тло.
   Панелі напівпрозорі з розмиттям — крізь них видно мазки.
   ========================================================================== */
.art-panel { display: none; }
:root[data-art] select option { background: var(--art-option); color: var(--text); }

/* картина на все тло */
:root[data-art="full"] body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: var(--art-scrim), var(--art) var(--art-pos) / cover no-repeat;
}

/* композиція справа + продовження тла картини */
:root[data-art="focus"] body::before {
  content: ""; position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background: var(--art-fill);
}
:root[data-art="focus"] .art-panel {
  display: block; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: var(--art) var(--art-pos-m) / cover no-repeat;
}
@media (min-width: 1000px) {
  /* висота картини = висота екрана під шапкою; --art-fr — частка ширини картини, де закінчується головна композиція,
     вона стає біля правого краю екрана (з відступом --art-r) */
  /* картина починається під шапкою, щоб її не закривало меню (висоту шапки ставить app.js) */
  :root[data-art="focus"] .art-panel {
    --art-h: calc(100vh - var(--chrome-h, 96px));
    inset: auto; top: var(--chrome-h, 96px); height: var(--art-h); width: calc(var(--art-ar) * var(--art-h));
    left: calc(100vw - var(--art-r, 0px) - var(--art-fr) * var(--art-ar) * var(--art-h));
    background-size: 100% 100%;
    -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--art-feather, 20%));
    mask-image: linear-gradient(to right, transparent, #000 var(--art-feather, 20%));
  }
}
/* підпис картини */
:root[data-art="focus"] body::after {
  content: var(--art-caption); position: fixed; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); z-index: 5; pointer-events: none;
  font-size: .72rem; font-weight: 500; letter-spacing: .02em; padding: 4px 9px; border-radius: 4px; background: rgba(0,0,0,.55); color: #fff;
}
@media (max-width: 999px) { :root[data-art="focus"] body::after { display: none; } }

/* спільне скло для всіх художніх тем */
:root[data-art] .chrome {
  background: var(--art-chrome);
  -webkit-backdrop-filter: blur(18px) saturate(160%); backdrop-filter: blur(18px) saturate(160%);
}
:root[data-art] :is(.topbar, .tabs) { background: transparent; }
:root[data-art] :is(.card, .modal-card, .toast, .chart .tip) {
  -webkit-backdrop-filter: blur(14px) saturate(160%); backdrop-filter: blur(14px) saturate(160%);
}
:root[data-art] .modal-card { background: var(--art-modal); }
:root[data-art] main > h2, :root[data-art] main > .row h2 { text-shadow: var(--title-shadow, 0 1px 2px rgba(0,0,0,.85), 0 0 16px rgba(0,0,0,.6)); }

/* ---- Ван Гог «Зоряна ніч» — насичений кобальт і хромово-жовтий ---- */
:root[data-theme="vangogh"] {
  --art: url("art/starry-night.webp"); --art-pos: 58% 30%;
  --art-scrim: linear-gradient(180deg, rgba(6,20,70,0), rgba(6,20,70,.12) 55%, rgba(6,20,70,.28));
  --art-chrome: rgba(14,44,140,.5); --art-option: #163c9e; --art-modal: rgba(16,46,140,.92);
  --bg: #123a9c; --panel: rgba(16,50,160,.56); --panel2: rgba(40,92,200,.5); --line: rgba(160,205,255,.38);
  --text: #fffbea; --muted: #d8e3ff; --text2: #fff3c8; --placeholder: #9fb3e6;
  --accent: #ffd21f; --accent-hover: #ffe066; --accent2: #5fd3ff; --accent2-text: #9fe6ff;
  --gold: #ffd21f; --warn: #ffb020; --danger: #ff6a3d; --danger-text: #ffb199;
  --on-accent: #241900; --on-accent2: #04263a;
  --field: rgba(8,28,96,.55); --topbar: transparent; --hover: rgba(70,124,230,.7); --baseline: rgba(180,215,255,.45);
  --overlay: rgba(4,14,52,.55); --shadow: 0 10px 30px rgba(0,10,50,.45);
  --radius: 12px;
}
:root[data-theme="vangogh"] .brand { color: var(--accent); text-shadow: 0 0 16px rgba(255,210,31,.75); }
:root[data-theme="vangogh"] .card { border-color: rgba(255,214,60,.3); }
:root[data-theme="vangogh"] .btn.primary { box-shadow: 0 0 18px rgba(255,210,31,.35); }

/* ---- Клімт «Поцілунок» — пара справа, під формами — золоте тло картини ---- */
:root[data-theme="klimt"] {
  --art: url("art/the-kiss.webp"); --art-ar: .996; --art-fr: .72; --art-r: 12px; --art-feather: 26%; --art-pos-m: 50% 22%;
  --art-fill: url("art/kiss-tile.webp") 0 0 / 45.7vh 66.4vh repeat, #a98c39;
  --art-caption: "Густав Клімт · «Поцілунок», 1907–1908";
  --art-chrome: rgba(42,29,4,.55); --art-option: #3a2a08; --art-modal: rgba(56,39,7,.93);
  --bg: #a98c39; --panel: rgba(58,40,6,.5); --panel2: rgba(96,70,16,.5); --line: rgba(240,205,110,.38);
  --text: #fff7df; --muted: #f0dfae; --text2: #fbedc4; --placeholder: #c4ab70;
  --accent: #f2c94c; --accent-hover: #ffd966; --accent2: #6fd8c6; --accent2-text: #a3eadd;
  --gold: #ffd75e; --warn: #ffb347; --danger: #ff7a5c; --danger-text: #ffb3a0;
  --on-accent: #2a1c00; --on-accent2: #052a24;
  --field: rgba(40,28,4,.5); --topbar: transparent; --hover: rgba(140,104,30,.65); --baseline: rgba(240,210,130,.45);
  --overlay: rgba(30,20,2,.5); --shadow: 0 10px 30px rgba(40,26,0,.45);
  --radius: 8px;
}
:root[data-theme="klimt"] :is(h2, h3, .brand, .week-title, .ex-title) { font-family: "Didot", "Bodoni MT", Georgia, "Times New Roman", serif; letter-spacing: .3px; }
:root[data-theme="klimt"] .brand { color: var(--accent); text-shadow: 0 0 14px rgba(242,201,76,.55); }
:root[data-theme="klimt"] .card { border-color: rgba(240,205,110,.5); }
/* сусальне золото на головних кнопках */
:root[data-theme="klimt"] :is(.btn.primary, .day.on, .count-pill.ok) {
  background: linear-gradient(135deg, #a07a1e, #d4af37 30%, #f9e49a 50%, #d4af37 70%, #a07a1e);
  border-color: #c9a227; color: #241800;
}

/* ---- Марія Приймаченко — звір справа, під формами — червоне тло картини ---- */
:root[data-theme="prymachenko"] {
  --art: url("art/prymachenko.webp"); --art-ar: 1.407; --art-fr: .97; --art-r: 0px; --art-feather: 16%; --art-pos-m: 78% 50%;
  --art-fill: radial-gradient(55% 40% at 18% 25%, rgba(255,80,60,.45), transparent 70%),
              radial-gradient(45% 45% at 62% 78%, rgba(190,20,12,.35), transparent 70%),
              radial-gradient(40% 30% at 35% 65%, rgba(255,70,45,.3), transparent 70%), #e6241c;
  --art-caption: "Марія Приймаченко";
  --art-chrome: rgba(24,6,4,.6); --art-option: #3a0f0a; --art-modal: rgba(32,9,6,.94);
  --bg: #e6241c; --panel: rgba(26,8,6,.56); --panel2: rgba(70,18,12,.55); --line: rgba(255,195,160,.32);
  --text: #fff5ec; --muted: #f6cfbf; --text2: #ffe7d9; --placeholder: #c99383;
  --accent: #ffb326; --accent-hover: #ffc757; --accent2: #d991f4; --accent2-text: #ebbdfa;
  --gold: #ffc94a; --warn: #ffa043; --danger: #ff6b5b; --danger-text: #ffb5aa;
  --on-accent: #2a1500; --on-accent2: #2a0838;
  --field: rgba(22,6,4,.5); --topbar: transparent; --hover: rgba(120,32,22,.7); --baseline: rgba(255,200,170,.4);
  --overlay: rgba(30,6,4,.5); --shadow: 0 10px 30px rgba(40,0,0,.45);
  --radius: 10px;
}
:root[data-theme="prymachenko"] .brand { color: var(--accent); }
:root[data-theme="prymachenko"] .card { border-color: rgba(255,179,38,.35); }

/* ---- Приймаченко: звір з рибками — синє тло, рудий звір, жовті рибки ---- */
:root[data-theme="pr-fish"] {
  --art: url("art/pr-fish-beast.webp"); --art-ar: 1.384; --art-fr: .97; --art-r: 0px; --art-feather: 16%; --art-pos-m: 72% 50%;
  --art-fill: radial-gradient(55% 40% at 20% 25%, rgba(40,120,255,.45), transparent 70%),
              radial-gradient(45% 45% at 60% 80%, rgba(0,30,140,.35), transparent 70%), #0352cc;
  --art-caption: "Марія Приймаченко";
  --art-chrome: rgba(4,20,96,.55); --art-option: #0b2a8a; --art-modal: rgba(8,28,112,.93);
  --bg: #0352cc; --panel: rgba(6,24,100,.52); --panel2: rgba(24,70,190,.5); --line: rgba(150,195,255,.38);
  --text: #fffbe8; --muted: #d8e4ff; --text2: #fff2c4; --placeholder: #98aee6;
  --accent: #ffd33d; --accent-hover: #ffe070; --accent2: #ff6b3d; --accent2-text: #ffae92;
  --gold: #ffd33d; --warn: #ffa63d; --danger: #ff5a4a; --danger-text: #ffb3a8;
  --on-accent: #2a1d00; --on-accent2: #2a0a00;
  --field: rgba(4,16,72,.5); --topbar: transparent; --hover: rgba(40,96,220,.7); --baseline: rgba(170,205,255,.45);
  --overlay: rgba(2,10,52,.5); --shadow: 0 10px 30px rgba(0,8,60,.45);
  --radius: 10px;
}
:root[data-theme="pr-fish"] .brand { color: var(--accent); }
:root[data-theme="pr-fish"] .card { border-color: rgba(255,211,61,.35); }

/* ---- Приймаченко: яблуня — іржаво-червоне тло, лимонні яблука ---- */
:root[data-theme="pr-apple"] {
  --art: url("art/pr-apple-tree.webp"); --art-ar: 1.398; --art-fr: .98; --art-r: 0px; --art-feather: 16%; --art-pos-m: 68% 60%;
  --art-fill: radial-gradient(55% 40% at 20% 25%, rgba(220,90,20,.45), transparent 70%),
              radial-gradient(45% 45% at 60% 80%, rgba(110,30,0,.35), transparent 70%), #a8480e;
  --art-caption: "Марія Приймаченко";
  --art-chrome: rgba(64,20,2,.58); --art-option: #4a1a05; --art-modal: rgba(70,24,4,.94);
  --bg: #a8480e; --panel: rgba(62,20,4,.52); --panel2: rgba(120,46,10,.5); --line: rgba(255,225,150,.36);
  --text: #fffbea; --muted: #fde3c2; --text2: #fff3c6; --placeholder: #d3a47e;
  --accent: #fff06a; --accent-hover: #fff59a; --accent2: #8fb2ff; --accent2-text: #bcd0ff;
  --gold: #ffe14d; --warn: #ffb347; --danger: #ff6b5b; --danger-text: #ffb5aa;
  --on-accent: #2a2000; --on-accent2: #0a1640;
  --field: rgba(50,16,2,.5); --topbar: transparent; --hover: rgba(160,66,18,.7); --baseline: rgba(255,220,160,.45);
  --overlay: rgba(40,12,0,.5); --shadow: 0 10px 30px rgba(50,14,0,.45);
  --radius: 10px;
}
:root[data-theme="pr-apple"] .brand { color: var(--accent); }
:root[data-theme="pr-apple"] .card { border-color: rgba(255,240,106,.35); }

/* ---- Приймаченко: синій звір у ковпаку — рожево-бузкове тло ---- */
:root[data-theme="pr-blue"] {
  --art: url("art/pr-blue-beast.webp"); --art-ar: 1.18; --art-fr: .99; --art-r: 0px; --art-feather: 18%; --art-pos-m: 74% 40%;
  --art-fill: radial-gradient(55% 40% at 20% 25%, rgba(255,140,200,.45), transparent 70%),
              radial-gradient(45% 45% at 60% 80%, rgba(150,50,120,.3), transparent 70%), #cc6298;
  --art-caption: "Марія Приймаченко";
  --art-chrome: rgba(8,52,84,.58); --art-option: #0a3a5c; --art-modal: rgba(8,54,86,.94);
  --bg: #cc6298; --panel: rgba(8,50,82,.55); --panel2: rgba(18,92,130,.5); --line: rgba(160,235,240,.36);
  --text: #ffffff; --muted: #d6f1f4; --text2: #fff3dc; --placeholder: #93c3cc;
  --accent: #ffa62e; --accent-hover: #ffbd5e; --accent2: #5fe3d3; --accent2-text: #a2f0e7;
  --gold: #ffc23d; --warn: #ffa62e; --danger: #ff5d6e; --danger-text: #ffb3bd;
  --on-accent: #2a1600; --on-accent2: #032a26;
  --field: rgba(4,36,60,.5); --topbar: transparent; --hover: rgba(24,110,150,.7); --baseline: rgba(170,235,240,.45);
  --overlay: rgba(40,10,40,.45); --shadow: 0 10px 30px rgba(30,0,40,.4);
  --radius: 10px;
}
:root[data-theme="pr-blue"] .brand { color: var(--accent); }
:root[data-theme="pr-blue"] .card { border-color: rgba(255,166,46,.4); }

/* ---- Приймаченко: соняшники — червоне тло, жовто-помаранчеві квіти, синя облямівка ---- */
:root[data-theme="pr-sunflowers"] {
  --art: url("art/pr-sunflowers.webp"); --art-ar: .681; --art-fr: 1; --art-r: 0px; --art-feather: 18%; --art-pos-m: 50% 40%;
  --art-fill: radial-gradient(55% 40% at 20% 25%, rgba(255,70,70,.4), transparent 70%),
              radial-gradient(45% 45% at 60% 80%, rgba(150,0,10,.3), transparent 70%), #e1161f;
  --art-caption: "Марія Приймаченко";
  --art-chrome: rgba(70,6,8,.55); --art-option: #5a0a0e; --art-modal: rgba(74,8,10,.94);
  --bg: #e1161f; --panel: rgba(70,6,10,.5); --panel2: rgba(130,14,20,.5); --line: rgba(255,220,120,.38);
  --text: #fffbea; --muted: #ffe0c8; --text2: #fff3c2; --placeholder: #dc9f92;
  --accent: #ffd21a; --accent-hover: #ffe066; --accent2: #5b8bff; --accent2-text: #a9c2ff;
  --gold: #ffd21a; --warn: #ffa31a; --danger: #ff8a7a; --danger-text: #ffc2b8;
  --on-accent: #2a1d00; --on-accent2: #06143a;
  --field: rgba(56,4,8,.5); --topbar: transparent; --hover: rgba(170,24,30,.7); --baseline: rgba(255,220,150,.45);
  --overlay: rgba(40,2,4,.5); --shadow: 0 10px 30px rgba(50,0,0,.45);
  --radius: 10px;
}
:root[data-theme="pr-sunflowers"] .brand { color: var(--accent); }
:root[data-theme="pr-sunflowers"] .card { border-color: rgba(255,210,26,.4); }

/* ---- Едвард Мунк «Крик» — фігура справа, під формами — вогняне небо картини ---- */
:root[data-theme="scream"] {
  --art: url("art/scream.webp"); --art-ar: .8055; --art-fr: .66; --art-r: 16px; --art-feather: 24%; --art-pos-m: 42% 60%;
  --art-fill: url("art/scream-tile.webp") 0 0 / 253vh 200vh repeat-x, #d0571e;
  --art-caption: "Едвард Мунк · «Крик», 1893";
  --art-chrome: rgba(30,22,60,.55); --art-option: #2a2050; --art-modal: rgba(32,24,66,.94);
  --bg: #d0571e; --panel: rgba(28,22,62,.52); --panel2: rgba(60,46,110,.5); --line: rgba(255,200,150,.36);
  --text: #fff6ea; --muted: #f5d9c4; --text2: #ffe9cf; --placeholder: #c8a48c;
  --accent: #ff8a1f; --accent-hover: #ffa64f; --accent2: #59b8ff; --accent2-text: #9dd4ff;
  --gold: #ffc23d; --warn: #ffa63d; --danger: #ff5a4a; --danger-text: #ffb3a8;
  --on-accent: #2a1200; --on-accent2: #04203a;
  --field: rgba(20,16,48,.5); --topbar: transparent; --hover: rgba(80,62,140,.7); --baseline: rgba(255,210,170,.45);
  --overlay: rgba(20,10,30,.5); --shadow: 0 10px 30px rgba(20,0,20,.45);
  --radius: 10px;
}
:root[data-theme="scream"] .brand { color: var(--accent); text-shadow: 0 0 14px rgba(255,138,31,.6); }
:root[data-theme="scream"] .card { border-color: rgba(255,138,31,.38); }

/* ---------- картинки вправ: мініатюра цілком + переглядач ---------- */
.img-btn { all: unset; display: block; width: 100%; height: 100%; cursor: zoom-in; }
.img-btn:focus-visible { outline: 2px solid var(--accent2); outline-offset: -2px; }
.ex-img img, .sess-ex .thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.ex-img .img-btn:hover img { transform: scale(1.02); }
.ex-img img { transition: transform .2s; }

body.no-scroll { overflow: hidden; }
.lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.88); display: flex; flex-direction: column; animation: lbIn .15s ease; }
@keyframes lbIn { from { opacity: 0; } }
.lb-stage { flex: 1; min-height: 0; overflow: auto; display: grid; place-items: center; padding: calc(16px + env(safe-area-inset-top, 0px)) 16px 8px; }
.lb-img { max-width: 94vw; max-height: calc(100vh - 90px); object-fit: contain; border-radius: 4px; box-shadow: 0 20px 60px rgba(0,0,0,.6); cursor: zoom-in; background: #fff1; }
.lightbox.zoom .lb-stage { place-items: start; }
.lightbox.zoom .lb-img { max-width: none; max-height: none; cursor: zoom-out; border-radius: 0; }
.lightbox.fits .lb-img { cursor: default; }
.lightbox.fits .lb-hint { visibility: hidden; }
.lb-close { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; z-index: 1; width: 40px; height: 40px; border-radius: 8px; border: 1px solid rgba(255,255,255,.2); background: rgba(20,20,20,.7); color: #fff; display: grid; place-items: center; cursor: pointer; }
.lb-close:hover { background: rgba(60,60,60,.8); }
.lb-close .i { width: 20px; height: 20px; }
.lb-hint { text-align: center; color: rgba(255,255,255,.6); font-size: .8rem; padding: 6px 16px calc(12px + env(safe-area-inset-bottom, 0px)); }

/* ---------- бібліотека програм ---------- */
main.wide { max-width: 1240px; }
.prog-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.prog-main { min-width: 0; }
.lib-panel { position: sticky; top: 112px; max-height: calc(100vh - 130px); overflow-y: auto; padding: 16px; }
.lib-head h3 { margin-bottom: 4px; }
.lib-head p { margin: 0 0 12px; }
.lib-empty { padding: 8px 0; }
.lib-cat + .lib-cat { margin-top: 14px; }
.lib-cat-name { display: flex; align-items: center; justify-content: space-between; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 2px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.lib-cat-name span { font-variant-numeric: tabular-nums; }
.lib-row { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 8px; border-radius: var(--r-sm); cursor: pointer; color: var(--text); }
.lib-row:hover { background: var(--panel2); }
.lib-row:focus-visible { outline: 2px solid var(--accent2); outline-offset: -2px; }
.lib-row > .i { color: var(--muted); margin-left: auto; }
.lib-row-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.lib-row-text b { font-weight: 600; font-size: .92rem; }
.lib-row-text small { color: var(--muted); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 900px) {
  .prog-layout { grid-template-columns: 1fr; }
  .lib-panel { position: static; max-height: none; order: -1; }
}

/* навігація «назад» */
.crumbs { display: flex; align-items: center; gap: 8px; margin: 2px 0 12px; font-size: .9rem; flex-wrap: wrap; }
.crumb { all: unset; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; color: var(--accent2); font-weight: 500; }
.crumb:hover { text-decoration: underline; text-underline-offset: 3px; }
.crumb:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; border-radius: 4px; }
.crumb-sep { color: var(--muted); }

/* детальний перегляд програми */
.lib-hero { display: flex; gap: 18px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.lib-hero-text { flex: 1 1 360px; min-width: 0; }
.lib-hero-text h2 { margin: 8px 0 6px; }
.lib-desc { margin: 0 0 6px; color: var(--text2); max-width: 70ch; }
.lib-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lib-ex.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.ex-check { display: inline-flex; align-items: center; gap: 6px; margin: 0; cursor: pointer; color: var(--text); font-size: .85rem; }
.ex-check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* куди додати */
.dest { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.dest-opt { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); cursor: pointer; color: var(--text); font-size: .92rem; }
.dest-opt:has(input:checked) { border-color: var(--accent); background: var(--panel2); }
.dest-opt.disabled { opacity: .5; cursor: not-allowed; }
.dest-opt input { margin-top: 3px; accent-color: var(--accent); }
.dest-opt span { display: flex; flex-direction: column; }
.dest-opt small { color: var(--muted); font-size: .8rem; }
.dest-field { padding: 0 2px 4px 34px; }
.dest-field label { margin-top: 0; }

/* сегментований перемикач розділів адмінки */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; margin-bottom: 14px; background: var(--panel); }
.seg button { all: unset; display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; cursor: pointer; color: var(--muted); font-size: .88rem; font-weight: 500; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--panel2); color: var(--text); font-weight: 600; box-shadow: inset 0 -2px 0 var(--accent); }
.seg button:focus-visible { outline: 2px solid var(--accent2); outline-offset: -2px; }

/* адмінка: бібліотека */
.lib-table td { vertical-align: middle; }
.lib-admin-cat + .lib-admin-cat { margin-top: 16px; }
.lib-admin-row { display: flex; align-items: center; gap: 12px; padding: 9px 2px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.lib-admin-row:last-child { border-bottom: 0; }
.lib-none { padding: 8px 2px; }
.lib-ed-list { display: flex; flex-direction: column; }
.lib-ed-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.lib-ed-row:last-child { border-bottom: 0; }
.lib-ed-thumb { width: 56px; height: 42px; flex: none; border-radius: 4px; overflow: hidden; display: grid; place-items: center; color: var(--muted); background: var(--field); }
.lib-ed-thumb img { width: 100%; height: 100%; object-fit: contain; }

/* ---------- «Мої програми»: групи → тренування ---------- */
.prog-head { margin-bottom: 4px; }
.folder { padding: 0; overflow: hidden; }
.folder-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 12px 8px; flex-wrap: wrap; }
.folder.open .folder-head { border-bottom: 1px solid var(--line); }
.folder-toggle, .w-toggle { all: unset; box-sizing: border-box; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-width: 0; border-radius: var(--r-sm); }
.folder-toggle { padding: 4px 8px; flex: 1 1 260px; flex-wrap: wrap; }
.folder-toggle:hover .folder-name { color: var(--accent); }
.folder-toggle:focus-visible, .w-toggle:focus-visible { outline: 2px solid var(--accent2); outline-offset: 2px; }
.folder-toggle > .i, .w-toggle > .i { color: var(--muted); width: 18px; height: 18px; }
.folder-name { font-size: 1.08rem; font-weight: 650; letter-spacing: -.01em; }
.folder-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.folder-body { padding: 6px 14px 14px; display: flex; flex-direction: column; gap: 2px; }
.folder-empty { padding: 10px 6px; }

/* згорнуте тренування — рядок з відступом */
.w-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px 24px; border-radius: var(--r-sm); }
.w-row:hover { background: var(--panel2); }
.w-row .w-toggle { flex: 1; }
.w-text { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; min-width: 0; }
.w-text b { font-weight: 600; white-space: nowrap; }
.w-list { color: var(--muted); font-size: .86rem; }
.w-count { font-size: .8rem; font-variant-numeric: tabular-nums; min-width: 1.5em; text-align: right; }
.w-row .btn.icon { flex: none; }

/* розгорнуте тренування — детальна картка з відступом */
.w-card { margin: 6px 0 10px 24px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel2); }
.w-card .ex { background: var(--panel); }
.w-card .group-head .w-toggle { gap: 8px; }
.w-card .group-head h3 { margin: 0; font-size: 1.05rem; }
.w-card .group-head .w-toggle:hover h3 { color: var(--accent); }
@media (max-width: 600px) {
  .w-row { padding-left: 10px; }
  .w-card { margin-left: 0; padding: 10px; }
  .folder-body { padding: 4px 8px 10px; }
}
@media (max-width: 600px) {
  .prog-head h2 { flex-basis: 100%; margin-bottom: 4px; }
  .prog-head .spacer { display: none; }
  .prog-head .btn.primary { margin-left: auto; }
}
