:root {
  --bg: #0b100e;
  --bg2: #101713;
  --bg3: #1a231e;
  --text: #f0ead8;
  --muted: #93a89a;
  --accent: #d4a94e;
  --accent-soft: rgba(212, 169, 78, .14);
  --rest: #4e9e7a;
  --radius: 14px;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button {
  font: inherit; color: inherit; background: none; border: 0; cursor: pointer;
}

/* ── layout ─────────────────────────────── */
#layout { display: flex; height: 100dvh; }
#sidebar {
  width: 340px; min-width: 340px; height: 100%;
  background: var(--bg2); border-right: 1px solid #223129;
  display: flex; flex-direction: column;
}
#sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(18px + env(safe-area-inset-top)) 20px 18px;
  border-bottom: 1px solid #223129;
}
.logo { font-weight: 800; letter-spacing: .5px; font-size: 18px; }
.logo span { color: var(--accent); }
#burger { display: none; font-size: 20px; padding: 4px 8px; }
#menu-open {
  display: none; position: fixed; z-index: 30;
  top: calc(10px + env(safe-area-inset-top)); left: 12px;
  background: var(--bg2); border: 1px solid #223129; border-radius: 10px;
  font-size: 20px; padding: 8px 12px;
}
#nav { overflow-y: auto; padding: 10px 10px 40px; flex: 1; }

/* ── табы курсов ────────────────────────── */
#course-tabs {
  padding: 12px 10px 4px; display: flex; flex-direction: column; gap: 6px;
  border-bottom: 1px solid #223129;
}
.course-tab {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 12px;
  color: var(--muted); font-size: 14px; font-weight: 600;
  border: 1px solid transparent; text-align: left;
}
.course-tab:hover { background: var(--bg3); }
.course-tab.active {
  background: var(--accent-soft); color: var(--text);
  border-color: rgba(212, 169, 78, .45);
}
.course-tab .ct-cover {
  width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex: none;
  background: var(--bg3);
}
.course-tab .ct-nocover {
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.course-tab .ct-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.course-tab .ct-prog {
  font-size: 12px; font-variant-numeric: tabular-nums;
  background: var(--bg3); border-radius: 999px; padding: 3px 9px; flex: none;
}
.course-tab.active .ct-prog { background: rgba(212, 169, 78, .25); color: var(--text); }
#main { flex: 1; overflow-y: auto; }
#welcome { max-width: 620px; margin: 15vh auto; padding: 0 24px; text-align: center; color: var(--muted); }
#welcome h1 { color: var(--text); margin-bottom: 12px; font-size: 26px; }
.loading { color: var(--muted); padding: 20px; text-align: center; }

/* ── nav tree ───────────────────────────── */
.course-name {
  font-size: 12px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); padding: 16px 12px 8px;
}
summary.course-name {
  cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 8px;
  border-radius: 10px; font-weight: 700;
}
summary.course-name::-webkit-details-marker { display: none; }
summary.course-name::before {
  content: "▸"; color: var(--accent); font-size: 10px; transition: transform .15s;
}
.course[open] > summary.course-name::before { transform: rotate(90deg); }
summary.course-name:hover { background: var(--bg3); }
.nav-section > summary {
  cursor: pointer; list-style: none;
  padding: 10px 12px; border-radius: 10px;
  font-weight: 600; font-size: 14px;
  display: flex; align-items: center; gap: 8px;
}
.nav-section > summary::-webkit-details-marker { display: none; }
.nav-section > summary::before {
  content: "▸"; color: var(--accent); transition: transform .15s;
}
.nav-section[open] > summary::before { transform: rotate(90deg); }
.nav-section > summary:hover { background: var(--bg3); }
.nav-section .sec-name { flex: 1; min-width: 0; }
.nav-section .sec-prog {
  margin-left: auto; font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums;
  background: var(--bg3); border-radius: 999px; padding: 2px 9px; flex: none;
}
.nav-section .sec-prog.all { background: var(--rest); color: #fff; }
.nav-section summary.sec-done { color: var(--rest); }

/* кнопка скачивания дня */
.dl-day {
  flex: none; font-size: 13px; color: var(--muted);
  padding: 3px 8px; border-radius: 8px; margin-left: 6px;
  min-width: 34px; text-align: center;
}
.dl-day:hover { background: var(--bg3); color: var(--text); }
.dl-day.dling { color: var(--accent); font-variant-numeric: tabular-nums; font-size: 11px; }
.dl-day.saved { color: var(--rest); }
.nav-lesson {
  display: flex; align-items: center; gap: 8px; width: 100%;
  text-align: left; padding: 8px 12px 8px 30px;
  color: var(--muted); font-size: 14px; border-radius: 10px;
}
.nav-lesson:hover { background: var(--bg3); color: var(--text); }
.nav-lesson.active { background: var(--accent-soft); color: var(--text); }
.nav-lesson .check {
  width: 16px; flex: none; font-size: 13px; color: var(--rest);
  opacity: 0; transition: opacity .15s;
}
.nav-lesson.done .check { opacity: 1; }
.nav-lesson.done { color: var(--rest); }
.nav-lesson .nl-title { flex: 1; min-width: 0; }

/* ── lesson view ────────────────────────── */
.lesson { max-width: 860px; margin: 0 auto; padding: calc(28px + env(safe-area-inset-top)) 24px calc(80px + env(safe-area-inset-bottom)); }
.lesson-crumb { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.lesson h1 { font-size: 26px; margin-bottom: 14px; }
.lesson-meta { display: flex; gap: 14px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.badge {
  background: var(--bg3); border-radius: 999px; padding: 5px 12px;
  font-size: 13px; color: var(--muted);
}
#start-workout {
  background: var(--accent); color: #fff; font-weight: 700;
  padding: 12px 26px; border-radius: 999px; font-size: 16px;
  box-shadow: 0 6px 24px rgba(212, 169, 78, .35);
  transition: transform .1s;
}
#start-workout:hover { transform: scale(1.03); }
.lesson video, .lesson img {
  width: 100%; border-radius: var(--radius); background: #000; margin: 10px 0;
}
.lesson .md { line-height: 1.65; color: #d9d9de; margin: 14px 0; }
.lesson .md h1, .lesson .md h2, .lesson .md h3 { color: var(--text); margin: 22px 0 8px; }
.lesson .md h1 { font-size: 22px; } .lesson .md h2 { font-size: 19px; } .lesson .md h3 { font-size: 16px; }
.lesson .md p { margin: 8px 0; }
.lesson .md ul, .lesson .md ol { margin: 8px 0 8px 22px; }
.lesson .md hr { border: 0; border-top: 1px solid #2c3a32; margin: 20px 0; }
.lesson .md a { color: var(--accent); }
.lesson .md strong { color: var(--text); }

/* exercise cards */
.ex-card {
  display: flex; gap: 14px; align-items: center;
  background: var(--bg2); border-radius: var(--radius);
  padding: 12px; margin: 10px 0;
}
.ex-card video { width: 128px; height: 72px; object-fit: cover; border-radius: 8px; margin: 0; flex: none; }
.ex-thumb { position: relative; flex: none; cursor: pointer; }
.ex-thumb .ex-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 22px; text-shadow: 0 1px 8px #000;
  background: rgba(0,0,0,.25); border-radius: 8px;
}
.ex-thumb:hover .ex-play { background: rgba(0,0,0,.45); }
.ex-card .ex-info { flex: 1; min-width: 0; }
.ex-card .ex-title { font-weight: 600; font-size: 15px; }
.ex-card .ex-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.ex-card .ex-timer {
  font-variant-numeric: tabular-nums; font-weight: 700;
  color: var(--accent); font-size: 18px; flex: none;
}
.ex-card.rest .ex-timer { color: var(--rest); }

/* ── workout mode ───────────────────────── */
#workout {
  position: fixed; inset: 0; z-index: 50;
  background: #000; display: flex; flex-direction: column;
}
#workout.hidden { display: none; }
#wo-top {
  display: flex; align-items: center; gap: 14px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
#wo-exit { font-size: 20px; color: var(--muted); padding: 6px 10px; }
#wo-sound, #wo-plan, #wo-expand { font-size: 18px; color: var(--muted); padding: 6px 8px; }
#wo-progress { flex: 1; height: 4px; background: #2c3a32; border-radius: 2px; overflow: hidden; }
#wo-progress-fill { height: 100%; background: var(--accent); width: 0; transition: width .3s; }
#wo-counter { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
#wo-stage { position: relative; flex: 1; overflow: hidden; }
#wo-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; background: #000;
}
#wo-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  padding: 30px 20px calc(30px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent 45%, rgba(0,0,0,.82));
  text-align: center;
  pointer-events: none; /* тапы по видео проходят к #wo-video */
}
#wo-overlay > * { pointer-events: auto; }
#wo-label {
  font-size: 12px; letter-spacing: 2px; color: var(--accent); font-weight: 700;
  text-transform: uppercase; margin-bottom: 6px;
}
#workout.rest-mode #wo-label { color: var(--rest); }
#wo-title { font-size: clamp(22px, 4vw, 34px); margin-bottom: 8px; text-shadow: 0 2px 12px #000; }
#wo-timer {
  font-size: clamp(64px, 14vw, 120px); font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums; text-shadow: 0 2px 16px #000;
}
#workout.rest-mode #wo-timer { color: var(--rest); }
#wo-next { color: #cfcfd6; margin-top: 10px; font-size: 15px; text-shadow: 0 1px 8px #000; }
#wo-controls {
  display: flex; justify-content: center; gap: 26px;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
  background: #000;
}
#wo-controls button {
  width: 62px; height: 62px; border-radius: 50%;
  background: var(--bg3); font-size: 24px;
}
#wo-controls #wo-pause { background: var(--accent); width: 74px; height: 74px; margin-top: -6px; }
#wo-manual {
  margin: 14px 0 4px;
  background: var(--accent); padding: 14px 40px; border-radius: 999px;
  font-size: 18px; font-weight: 700; box-shadow: 0 6px 24px rgba(242,24,0,.4);
}
#wo-manual.hidden { display: none; }
#get-ready {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; background: rgba(0,0,0,.9); z-index: 5;
}
#get-ready .count { font-size: 110px; font-weight: 800; }
#get-ready .what { color: var(--muted); font-size: 18px; margin-top: 8px; }

/* done screen */
#wo-done {
  position: absolute; inset: 0; z-index: 6;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #000; text-align: center; padding: 20px;
}
#wo-done .big { font-size: 64px; margin-bottom: 10px; }
#wo-done h2 { font-size: 28px; margin-bottom: 8px; }
#wo-done p { color: var(--muted); margin-bottom: 26px; }
#wo-done button { background: var(--accent); padding: 13px 34px; border-radius: 999px; font-weight: 700; }
#wo-done .wo-stats {
  width: 100%; max-width: 340px; max-height: 38vh; overflow-y: auto;
  margin: 0 0 26px;
}
#wo-done .wo-stat {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 7px 2px; font-size: 14px; color: var(--muted);
  border-bottom: 1px solid #222;
}
#wo-done .wo-stat b { color: var(--text); font-variant-numeric: tabular-nums; flex: none; }

/* ── полноэкранный просмотрщик ──────────── */
#viewer {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,.97);
  display: flex; flex-direction: column;
}
#viewer.hidden { display: none; }
#viewer-head {
  display: flex; align-items: center; gap: 14px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
}
#viewer-title {
  flex: 1; min-width: 0; font-weight: 700; font-size: 16px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#viewer-close { font-size: 22px; color: var(--muted); padding: 6px 10px; }
#viewer-video {
  flex: 1; width: 100%; min-height: 0;
  object-fit: contain; background: #000;
}
#viewer-variants {
  display: flex; justify-content: center; gap: 10px;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
}
#viewer-variants.hidden { display: none; }
#viewer-variants button {
  padding: 9px 22px; border-radius: 999px;
  background: var(--bg3); color: var(--muted); font-weight: 600;
}
#viewer-variants button.active { background: var(--accent); color: #fff; }

/* ── PIN-экран ──────────────────────────── */
#pin-gate {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
#pin-gate .pin-box {
  display: flex; flex-direction: column; gap: 14px; align-items: center;
  width: min(320px, 86vw);
}
#pin-gate .logo { font-size: 22px; margin-bottom: 8px; }
#pin-gate input {
  width: 100%; padding: 14px 16px; font-size: 20px; text-align: center;
  background: var(--bg2); color: var(--text);
  border: 1px solid #223129; border-radius: 12px; outline: none;
  letter-spacing: 4px;
}
#pin-gate input:focus { border-color: var(--accent); }
#pin-gate button {
  width: 100%; padding: 13px; border-radius: 12px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 16px;
}
#pin-gate .pin-err { color: var(--accent); font-size: 14px; }
#pin-gate .pin-err.hidden { display: none; }

/* ── офлайн-индикатор + баннер установки ── */
#sidebar-head::after {
  content: "офлайн"; display: none;
  font-size: 11px; color: #f2a900; border: 1px solid #f2a900;
  padding: 2px 8px; border-radius: 999px;
}
body.offline #sidebar-head::after { display: block; }
#install-banner {
  position: fixed; z-index: 40; /* ниже #workout (50) и #viewer (70) — не перекрывает их */
  left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px;
  background: var(--bg2); border: 1px solid #223129; border-radius: 14px;
  padding: 12px 14px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
#install-banner span { flex: 1; }
#install-banner button { color: var(--muted); font-size: 16px; padding: 4px 8px; }
/* пока баннер виден — контент не прячется под ним */
body.has-banner .lesson { padding-bottom: 150px; }
body.has-banner #nav { padding-bottom: 110px; }

/* ── экран входа (аккаунт) ──────────────── */
#auth-gate {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
#auth-gate .pin-box {
  display: flex; flex-direction: column; gap: 12px; align-items: center;
  width: min(320px, 86vw);
}
#auth-gate .logo { font-size: 22px; margin-bottom: 8px; }
#auth-gate input {
  width: 100%; padding: 14px 16px; font-size: 16px;
  background: var(--bg2); color: var(--text);
  border: 1px solid #223129; border-radius: 12px; outline: none;
}
#auth-gate input:focus { border-color: var(--accent); }
#auth-gate button:not(.link) {
  width: 100%; padding: 13px; border-radius: 12px;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 16px;
}
#auth-gate button:disabled { opacity: .6; }
#auth-gate .link { color: var(--muted); font-size: 14px; text-decoration: underline; }
#auth-gate .pin-err { color: var(--accent); font-size: 14px; }
#auth-gate .pin-err.hidden { display: none; }

/* ── футер сайдбара (аккаунт/синк) ──────── */
#side-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid #223129;
  font-size: 12px; color: var(--muted);
}
#side-foot.hidden { display: none; }
#foot-email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#foot-sync { font-size: 10px; }
#foot-logout { color: var(--muted); padding: 4px 8px; font-size: 15px; }
#foot-logout:hover { color: var(--text); }

/* ── mobile ─────────────────────────────── */
#backdrop { display: none; }
@media (max-width: 800px) {
  #backdrop {
    position: fixed; inset: 0; z-index: 35;
    background: rgba(0,0,0,.55);
  }
  body.sb-open #backdrop { display: block; }
  body.has-banner #sidebar { padding-bottom: 90px; }
  #sidebar {
    position: fixed; z-index: 40; height: 100dvh;
    transform: translateX(-100%); transition: transform .2s;
    width: min(86vw, 340px); min-width: 0;
  }
  #sidebar.open { transform: none; box-shadow: 0 0 60px #000; }
  #burger { display: block; }
  #menu-open { display: block; }
  #main { width: 100%; }
  /* запас сверху — контент не попадает под плавающую кнопку ☰ */
  .lesson { padding: calc(64px + env(safe-area-inset-top)) 16px calc(60px + env(safe-area-inset-bottom)); }
}

/* ── карточки курсов на стартовом экране ── */
#course-cards {
  display: grid; gap: 14px; margin: 28px 0;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.course-card {
  background: var(--bg2); border: 1px solid #223129; border-radius: var(--radius);
  overflow: hidden; text-align: left; transition: transform .1s;
  display: flex; flex-direction: column;
}
.course-card:hover { background: var(--bg3); transform: translateY(-2px); }
.cc-cover {
  width: 100%; aspect-ratio: 16/9; object-fit: cover;
  background: var(--bg3); display: block;
}
.cc-nocover {
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; color: var(--muted);
}
.cc-body { padding: 16px 18px 18px; }
.course-card .cc-name { font-weight: 800; font-size: 18px; margin-bottom: 6px; color: var(--text); }
.course-card .cc-meta { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.course-card .cc-bar { height: 4px; background: #2c3a32; border-radius: 2px; overflow: hidden; }
.course-card .cc-bar > div { height: 100%; background: var(--accent); transition: width .3s; }

/* ── низ урока: пройдено / следующий урок ── */
.lesson-bottom { margin-top: 24px; }
.lesson-nav { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.lesson-nav .done-btn { cursor: pointer; padding: 8px 16px; font-size: 14px; }
.next-btn {
  background: var(--accent); color: #fff; font-weight: 700;
  padding: 8px 18px; border-radius: 999px; font-size: 14px;
}
.next-btn:disabled { background: var(--bg3); color: var(--muted); cursor: default; }
.next-prompt {
  margin-top: 14px; background: var(--bg2); border: 1px solid #223129;
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  flex-wrap: wrap; color: var(--muted);
}
.next-prompt.hidden { display: none; }
.next-go {
  background: var(--accent); color: #fff; font-weight: 700;
  padding: 10px 20px; border-radius: 999px;
}
.next-go:disabled { background: var(--bg3); color: var(--muted); cursor: default; }

/* ── план тренировки (bottom sheet) ─────── */
#wo-plan-sheet {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; justify-content: flex-end;
  background: rgba(0,0,0,.7);
  transform: translateY(100%); transition: transform .3s ease;
}
#wo-plan-sheet.open { transform: translateY(0); }
#wo-plan-content {
  background: var(--bg2); border-radius: 20px 20px 0 0;
  max-height: 65vh; display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
#wo-plan-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid #223129;
}
#wo-plan-header h3 { font-size: 16px; font-weight: 700; }
#wo-plan-close { font-size: 20px; color: var(--muted); padding: 4px 8px; }
#wo-plan-list {
  overflow-y: auto; padding: 10px 14px;
}
.plan-step {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px; border-radius: 10px;
}
.plan-step.current { background: var(--accent-soft); }
.plan-step.done { opacity: .4; }
.plan-step.rest { border-left: 3px solid var(--rest); padding-left: 9px; }
.plan-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg3); display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex: none;
}
.plan-step.current .plan-num { background: var(--accent); color: #fff; }
.plan-thumb {
  width: 56px; height: 32px; border-radius: 6px; overflow: hidden;
  background: #000; flex: none; cursor: pointer; position: relative;
}
.plan-thumb video {
  width: 100%; height: 100%; object-fit: cover;
}
.plan-thumb-play {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.4); color: #fff; font-size: 12px;
}
.plan-info { flex: 1; min-width: 0; }
.plan-title {
  font-size: 14px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.plan-timer { font-size: 12px; color: var(--muted); margin-top: 2px; }
.plan-step.rest .plan-timer { color: var(--rest); }

/* ── достижения ─────────────────────────── */
#foot-achievements {
  color: var(--muted); padding: 4px 8px; font-size: 15px;
}
#foot-achievements:hover { color: var(--text); }

#achievements-modal {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
#achievements-modal.hidden { display: none; }
#achievements-content {
  background: var(--bg2); border-radius: var(--radius);
  width: 100%; max-width: 600px; max-height: 85vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
#achievements-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid #223129;
}
#achievements-header h2 { font-size: 20px; font-weight: 700; }
#achievements-close { font-size: 22px; color: var(--muted); padding: 6px 10px; }

#achievements-tabs {
  display: flex; border-bottom: 1px solid #223129;
}
.ach-tab {
  flex: 1; padding: 14px; font-size: 14px; font-weight: 600;
  color: var(--muted); border-bottom: 2px solid transparent;
}
.ach-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

#achievements-body {
  flex: 1; overflow-y: auto; padding: 20px 24px;
}
.ach-tab-content { display: none; }
.ach-tab-content.active { display: block; }

/* ачивки */
#badges-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}
.badge-card {
  background: var(--bg3); border-radius: 12px; padding: 16px 12px;
  text-align: center; position: relative;
  border: 2px solid transparent;
}
.badge-card.unlocked {
  background: var(--accent-soft); border-color: var(--accent);
}
.badge-card.locked { opacity: .5; filter: grayscale(1); }
.badge-icon { font-size: 36px; margin-bottom: 8px; }
.badge-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.badge-desc { font-size: 11px; color: var(--muted); line-height: 1.3; }
.badge-progress {
  margin-top: 8px; height: 4px; background: #2c3a32; border-radius: 2px;
  overflow: hidden;
}
.badge-progress-fill {
  height: 100%; background: var(--accent); transition: width .3s;
}

/* календарь */
#calendar-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
#cal-month { font-size: 16px; font-weight: 600; }
#cal-prev, #cal-next {
  font-size: 20px; color: var(--muted); padding: 6px 12px;
  background: var(--bg3); border-radius: 8px;
}
#cal-prev:hover, #cal-next:hover { color: var(--text); }

#calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.cal-day-name {
  text-align: center; font-size: 11px; color: var(--muted);
  padding: 4px; font-weight: 600;
}
.cal-day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: var(--bg3); border-radius: 8px; font-size: 13px;
  position: relative; cursor: default;
}
.cal-day.empty { background: transparent; }
.cal-day.has-workout {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
  cursor: pointer;
}
.cal-day.has-workout::after {
  content: ''; position: absolute; bottom: 4px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}
.cal-day.has-workout:hover {
  background: var(--accent); color: #fff;
}
.cal-day.today { border: 2px solid var(--accent); }

/* модальное окно дня */
.day-modal {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.day-modal-content {
  background: var(--bg2); border-radius: var(--radius);
  width: 100%; max-width: 400px; max-height: 80vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.day-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid #223129;
}
.day-modal-header h3 { font-size: 16px; font-weight: 600; }
.day-modal-close { font-size: 20px; color: var(--muted); padding: 4px 8px; }
.day-modal-body {
  overflow-y: auto; padding: 16px 20px;
}
.day-workout-item {
  padding: 12px; background: var(--bg3); border-radius: 10px;
  margin-bottom: 10px;
}
.day-workout-item:last-child { margin-bottom: 0; }
.day-workout-name { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.day-workout-meta { font-size: 12px; color: var(--muted); }

/* toast уведомление */
.ach-toast {
  position: fixed; top: 20px; right: 20px; z-index: 90;
  background: var(--bg2); border: 2px solid var(--accent);
  border-radius: 12px; padding: 16px 20px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: 0 8px 32px rgba(242, 24, 0, .3);
  transform: translateX(120%); transition: transform .3s ease;
}
.ach-toast.show { transform: translateX(0); }
.ach-toast-icon { font-size: 32px; }
.ach-toast-title { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.ach-toast-name { font-size: 14px; font-weight: 600; }

/* ── нефритовая тема: заголовки serif ── */
#welcome h1, .lesson h1, .hero-title { font-family: var(--serif); letter-spacing: .3px; }
.logo { font-family: var(--serif); }

/* ── главный экран: продолжить + сетка ── */
#home { max-width: 760px; margin: 0 auto; padding: 26px 20px 60px; }
.hero {
  background: linear-gradient(135deg, #14201a 0%, #1d2b22 60%, #24382b 100%);
  border: 1px solid rgba(212, 169, 78, .35);
  border-radius: 20px; padding: 26px 24px; text-align: center;
  box-shadow: 0 10px 40px rgba(0,0,0,.45);
}
.hero-symbol { font-size: 40px; }
.hero-title { font-size: 26px; margin: 8px 0 4px; color: var(--text); }
.hero-sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.hero-bar { height: 6px; background: #2c3a32; border-radius: 3px; overflow: hidden; margin-bottom: 16px; }
.hero-bar > div { height: 100%; background: linear-gradient(90deg, var(--rest), var(--accent)); transition: width .3s; }
.hero-continue {
  display: inline-block; background: linear-gradient(135deg, #d4a94e, #b8863a);
  color: #1a1408; font-weight: 800; font-size: 16px;
  padding: 13px 30px; border-radius: 999px; width: 100%;
  box-shadow: 0 6px 24px rgba(212, 169, 78, .35);
}
.hero-continue:active { transform: scale(.98); }
.hero-continue.done { background: var(--bg3); color: var(--muted); box-shadow: none; }
.home-sec { margin-top: 28px; }
.home-sec-title {
  font-family: var(--serif); font-size: 19px; color: var(--accent);
  margin-bottom: 12px; padding-left: 4px;
}
.home-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.lesson-card {
  background: var(--bg2); border: 1px solid #223129; border-radius: var(--radius);
  padding: 14px 12px; text-align: left; display: flex; flex-direction: column; gap: 8px;
  min-height: 108px;
}
.lesson-card:active { transform: scale(.97); }
.lesson-card.is-done { border-color: rgba(78, 158, 122, .6); opacity: .75; }
.lc-num {
  font-family: var(--serif); font-size: 12px; color: var(--accent);
  border: 1px solid rgba(212,169,78,.4); border-radius: 999px;
  width: fit-content; padding: 2px 10px;
}
.lesson-card.is-done .lc-num { color: var(--rest); border-color: rgba(78,158,122,.5); }
.lc-title { font-size: 13.5px; line-height: 1.35; color: var(--text); }
.lc-check { font-size: 12px; color: var(--rest); }
.lc-novideo { font-size: 11px; color: var(--muted); }
@media (max-width: 480px) { .home-grid { grid-template-columns: repeat(2, 1fr); } }
