/* ============================================================
   Нейрокурс — тренажёр подготовки к экзамену (МДК.02.02)
   Палитра: «палатная бумага» + хирургический зелёный
   ============================================================ */

:root {
  /* поверхности и текст */
  --ground: #EFF2EE;
  --surface: #FFFFFF;
  --surface-2: #F7F9F6;
  --ink: #12201B;
  --ink-2: #41534B;
  --ink-3: #6B7C74;
  --line: #DCE3DD;
  --line-strong: #C3CEC6;

  /* смысловые цвета */
  --accent: #0B6B5B;
  --accent-soft: #E1EFEA;
  --accent-ink: #07463C;
  --on-accent: #FFFFFF;
  --amber: #A8690B;
  --amber-soft: #F7EBD6;
  --crimson: #A33222;
  --crimson-soft: #F7E3DF;
  --plum: #6B4A80;
  --plum-soft: #EDE5F2;

  /* прочее */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(18, 32, 27, .06), 0 8px 24px -14px rgba(18, 32, 27, .28);
  --rail: 232px;
  --read: 68ch;
  --step: 180ms;

  --font-display: "Literata", Georgia, "Times New Roman", serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0E1613;
    --surface: #15201C;
    --surface-2: #1A2723;
    --ink: #E7EEE9;
    --ink-2: #A9BBB2;
    --ink-3: #7D9189;
    --line: #26332E;
    --line-strong: #35453E;
    --accent: #53CDB2;
    --accent-soft: #143029;
    --accent-ink: #9FE6D5;
    --on-accent: #06221C;
    --amber: #E0A852;
    --amber-soft: #2E2515;
    --crimson: #E2836F;
    --crimson-soft: #30201C;
    --plum: #B795CC;
    --plum-soft: #262033;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px -16px rgba(0, 0, 0, .7);
  }
}

:root[data-theme="dark"] {
  --ground: #0E1613;
  --surface: #15201C;
  --surface-2: #1A2723;
  --ink: #E7EEE9;
  --ink-2: #A9BBB2;
  --ink-3: #7D9189;
  --line: #26332E;
  --line-strong: #35453E;
  --accent: #53CDB2;
  --accent-soft: #143029;
  --accent-ink: #9FE6D5;
  --on-accent: #06221C;
  --amber: #E0A852;
  --amber-soft: #2E2515;
  --crimson: #E2836F;
  --crimson-soft: #30201C;
  --plum: #B795CC;
  --plum-soft: #262033;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px -16px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

img, svg { max-width: 100%; }
[hidden] { display: none !important; }

button, input, textarea, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
  margin: 0;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- шапка ---------- */

.top {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 18px;
  white-space: nowrap;
}

.brand svg { width: 26px; height: 26px; flex: none; }

.brand small {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}

.search {
  position: relative;
  flex: 1;
  max-width: 420px;
  margin-left: auto;
}

.search input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 15px;
}

.search input::placeholder { color: var(--ink-3); }

.search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--ink-3);
  pointer-events: none;
}

.top-ready {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
}

.top-ready b {
  font-family: var(--font-mono);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.top-ready span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-3);
  display: block;
  line-height: 1.1;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  flex: none;
}

.icon-btn:hover { border-color: var(--line-strong); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------- каркас ---------- */

.shell {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  gap: 28px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 20px 120px;
}

.rail { position: sticky; top: 84px; align-self: start; display: grid; gap: 22px; }

.rail-group { display: grid; gap: 3px; }

.rail-title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0 10px 6px;
}

.rail a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  text-decoration: none;
  font-size: 15px;
  transition: background var(--step), color var(--step);
}

.rail a:hover { background: var(--surface-2); color: var(--ink); }

.rail a.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 600;
}

.rail a .count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
}

.rail a.active .count { color: var(--accent-ink); }
.rail svg { width: 18px; height: 18px; flex: none; }

.view { min-width: 0; }
.view[hidden] { display: none; }

/* ---------- типовые блоки ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.muted { color: var(--ink-2); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--step), filter var(--step), opacity var(--step);
}

.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }

.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }

.btn.ghost {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 7px 13px; font-size: 14px; }
.btn svg { width: 16px; height: 16px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-ink);
  white-space: nowrap;
}

.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.crimson { background: var(--crimson-soft); color: var(--crimson); }
.chip.plum { background: var(--plum-soft); color: var(--plum); }
.chip.flat { background: var(--surface-2); color: var(--ink-2); }

/* ---------- экран «Сегодня» ---------- */

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px 26px 24px;
  margin-bottom: 18px;
}

.hero h1 {
  font-size: clamp(26px, 3.4vw, 36px);
  letter-spacing: -0.015em;
  margin: 8px 0 6px;
}

.hero p { margin: 0 0 18px; color: var(--ink-2); max-width: 46ch; }

.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.axon { width: 100%; height: auto; }

.axon .pulse {
  stroke-dasharray: 26 260;
  animation: travel 3.4s linear infinite;
}

@keyframes travel { to { stroke-dashoffset: -286; } }

.plan-strip {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 5px;
  margin-top: 16px;
}

.plan-day {
  aspect-ratio: 1;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

.plan-day.done { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.plan-day.today { border-color: var(--accent); color: var(--accent); font-weight: 700; }

.queue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.queue-card {
  display: grid;
  gap: 6px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  transition: transform var(--step), border-color var(--step);
}

.queue-card:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.queue-card.amber { border-left-color: var(--amber); }
.queue-card.crimson { border-left-color: var(--crimson); }
.queue-card b { font-family: var(--font-mono); font-size: 27px; line-height: 1; }
.queue-card span { font-size: 14px; color: var(--ink-2); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 26px 0 12px;
}

.section-head h2 { font-size: 20px; }

/* ---------- модули ---------- */

.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 14px; }

.module {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--step), transform var(--step);
}

.module:hover { border-color: var(--accent); transform: translateY(-2px); }
.module svg { width: 44px; height: 44px; }
.module h3 { font-size: 16px; margin-bottom: 3px; }
.module p { margin: 0 0 9px; font-size: 13.5px; color: var(--ink-3); line-height: 1.45; }

.bar { height: 5px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 400ms ease-out; }
.module footer { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); margin-top: 5px; }

/* ---------- карточка изучения ---------- */

.study { max-width: var(--read); margin: 0 auto; }

.study-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.progress-line { flex: 1; height: 4px; background: var(--surface-2); border-radius: 999px; overflow: hidden; min-width: 90px; }
.progress-line i { display: block; height: 100%; background: var(--accent); transition: width var(--step) ease-out; }

.prompt {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.prompt .q {
  font-family: var(--font-display);
  font-size: clamp(20px, 2.6vw, 26px);
  line-height: 1.32;
  margin: 10px 0 4px;
}

.case-text p { margin: 0 0 10px; }
.case-text p:last-child { margin-bottom: 0; }

.tasks { margin: 16px 0 0; padding: 14px 16px; background: var(--surface-2); border-radius: var(--radius); }
.tasks ol { margin: 6px 0 0; padding-left: 20px; }
.tasks li { margin-bottom: 4px; }
.tasks li:last-child { margin-bottom: 0; }

.recall-zone { margin-top: 18px; display: grid; gap: 12px; }

.recall-zone textarea {
  width: 100%;
  min-height: 108px;
  padding: 13px 15px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  resize: vertical;
  line-height: 1.55;
}

.recall-hint {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  color: var(--ink-2);
  background: var(--amber-soft);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.recall-hint svg { width: 17px; height: 17px; flex: none; color: var(--amber); }

.answer { animation: rise var(--step) ease-out both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.answer h3 { font-size: 15px; margin-bottom: 8px; }
.answer .body { font-size: 16.5px; }
.answer .body p { margin: 0 0 9px; }
.answer .body p.lead { font-weight: 600; }

.checklist { display: grid; gap: 7px; margin: 16px 0 4px; }

.checklist label {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 15px;
  line-height: 1.4;
}

.checklist input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--accent); }
.checklist label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }

.grades { display: grid; grid-template-columns: repeat(auto-fit, minmax(146px, 1fr)); gap: 9px; margin-top: 16px; }

.grade {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--step), background var(--step);
}

.grade:hover { border-color: var(--accent); background: var(--accent-soft); }
.grade b { font-size: 14.5px; }
.grade span { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); }

/* ---------- тест ---------- */

.options { display: grid; gap: 9px; margin-top: 16px; }

.option {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 11px;
  align-items: start;
  padding: 13px 15px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  font-size: 15.5px;
  line-height: 1.45;
}

.option:hover { border-color: var(--accent); }
.option i { font-family: var(--font-mono); font-style: normal; color: var(--ink-3); }
.option.correct { border-color: var(--accent); background: var(--accent-soft); }
.option.wrong { border-color: var(--crimson); background: var(--crimson-soft); }
.option .mark { font-weight: 600; }

/* ---------- карта материала ---------- */

.heat { display: grid; grid-template-columns: repeat(auto-fill, minmax(24px, 1fr)); gap: 5px; margin-top: 14px; }

.heat button {
  aspect-ratio: 1;
  border-radius: 3px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
  padding: 0;
}

.heat button[data-level="1"] { background: var(--accent-soft); background: color-mix(in srgb, var(--accent) 22%, var(--surface-2)); border-color: transparent; }
.heat button[data-level="2"] { background: var(--accent-soft); background: color-mix(in srgb, var(--accent) 48%, var(--surface-2)); border-color: transparent; }
.heat button[data-level="3"] { background: var(--accent); border-color: transparent; }
.heat button[data-weak="1"] { border-color: var(--crimson); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ink-3); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ---------- списки материала ---------- */

.list { display: grid; gap: 8px; }

.list-item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
}

.list-item:hover { border-color: var(--accent); }
.list-item .num { font-family: var(--font-mono); color: var(--ink-3); font-size: 14px; }
.list-item .t { font-size: 15.5px; line-height: 1.4; }
.list-item .t em { display: block; font-style: normal; font-size: 13px; color: var(--ink-3); margin-top: 2px; }

/* ---------- результат / пусто ---------- */

.empty { text-align: center; padding: 46px 20px; color: var(--ink-2); }
.empty svg { width: 76px; height: 76px; margin-bottom: 12px; }

.score-ring { display: grid; place-items: center; gap: 4px; }
.score-ring svg { width: 148px; height: 148px; }
.ring-track { stroke: var(--line); }
.ring-value { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset 700ms ease-out; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 12px; margin-top: 18px; }
.stat { padding: 14px 16px; background: var(--surface-2); border-radius: var(--radius); }
.stat b { display: block; font-family: var(--font-mono); font-size: 23px; line-height: 1.2; }
.stat span { font-size: 13px; color: var(--ink-3); }

/* ---------- нижняя навигация (телефон) ---------- */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: none;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.tabbar a {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 9px 4px 7px;
  color: var(--ink-3);
  text-decoration: none;
  font-size: 11px;
  min-height: 52px;
}

.tabbar a.active { color: var(--accent); }
.tabbar svg { width: 21px; height: 21px; }

/* ---------- всплывающее сообщение ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 14px);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  background: var(--ink);
  color: var(--ground);
  border-radius: 999px;
  font-size: 14.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--step), transform var(--step);
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast button { background: none; border: none; color: var(--accent); font-weight: 600; cursor: pointer; padding: 0; }

/* ---------- адаптив ---------- */

@media (max-width: 1000px) {
  .shell { grid-template-columns: minmax(0, 1fr); padding-bottom: 96px; }
  .rail { display: none; }
  .tabbar { display: grid; }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero figure { display: none; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  .top { padding: 9px 14px; gap: 10px; }
  .brand span.full { display: none; }
  .search { max-width: none; }
  .shell { padding: 16px 14px 96px; }
  .card, .prompt, .hero { padding: 17px; border-radius: 14px; }
  .grades { grid-template-columns: 1fr 1fr; }
  .plan-strip { grid-template-columns: repeat(7, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- поиск и шапка на телефоне --- */
.search-toggle { display: none; }

@media (max-width: 720px) {
  .search { position: fixed; left: 0; right: 0; top: calc(56px + env(safe-area-inset-top, 0px)); z-index: 45; max-width: none; margin: 0; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
  .search[hidden] { display: none; }
  .search-toggle { display: grid; }
  .top-ready .txt span { display: none; }
  .top-ready { padding: 4px 8px 4px 4px; }
}

/* --- длинный эталон --- */
.answer .body.clipped { max-height: 380px; overflow: hidden; -webkit-mask-image: linear-gradient(to bottom, #000 72%, transparent); mask-image: linear-gradient(to bottom, #000 72%, transparent); }
.expand { margin: 12px 0 18px; }

/* --- поведение на iOS --- */
html { -webkit-text-size-adjust: 100%; }
body { overscroll-behavior-y: none; }
button, a, input, textarea, label { -webkit-tap-highlight-color: rgba(11, 107, 91, .14); }
input, textarea { font-size: 16px; }  /* иначе Safari зумит форму при фокусе */
.recall-zone textarea { font-size: 16px; }

/* --- касание на телефоне: цели не меньше 44 px --- */
@media (max-width: 720px) {
  .icon-btn { width: 44px; height: 44px; }
  .checklist input { width: 22px; height: 22px; }
  .checklist label { padding: 12px 14px; }
  .grade { padding: 14px; }
}

/* --- узкий экран (iPhone SE и подобные) --- */
@media (max-width: 420px) {
  .top { gap: 8px; padding: 8px 12px; }
  .brand { font-size: 16px; }
  .brand small { display: none; }
  .brand svg { width: 22px; height: 22px; }
  .top-ready { padding: 3px 8px 3px 3px; gap: 6px; }
  .top-ready b { font-size: 14px; }
  .icon-btn { width: 40px; height: 40px; }
  .tabbar a { font-size: 10.5px; padding: 8px 2px 6px; }
  .tabbar svg { width: 20px; height: 20px; }
}
