/* Мини-приложение школы. Цвета задаются переменными — замените --accent на фирменный цвет школы. */
:root {
  --paper: #ffffff;
  --surface: #ffffff;
  --ink: #1c1d1f;
  --muted: #6f737a;
  --line: #ebecef;
  --accent: #1c1d1f;
  --accent-ink: #ffffff;
  --accent-soft: #f2f3f5;
  --link: #266df0;
  --link-soft: #edf3ff;
  --danger: #d93036;
  --danger-soft: #fdecec;
  --radius: 12px;
  --gutter: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 2px 8px rgba(16, 24, 40, 0.04);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111214;
    --surface: #17181b;
    --ink: #f1f2f4;
    --muted: #8d9199;
    --line: #26282c;
    --accent: #f1f2f4;
    --accent-ink: #111214;
    --accent-soft: #222428;
    --link: #5b8ff6;
    --link-soft: #1a2541;
    --danger: #f06a6f;
    --danger-soft: #321a1b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15.5px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'tnum' 0;
  padding-bottom: env(safe-area-inset-bottom);
}
main { max-width: 640px; margin: 0 auto; padding: 8px var(--gutter) 120px; }
a { color: var(--link); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

h1 { font-size: 26px; line-height: 1.2; font-weight: 600; letter-spacing: -0.015em; margin: 16px 0 8px; }
h2 { font-size: 19px; line-height: 1.3; font-weight: 600; margin: 32px 0 12px; }
h3 { font-size: 16px; font-weight: 600; margin: 0; }
p { margin: 0 0 12px; }
.lead { color: var(--muted); font-size: 17px; margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }

/* Шапка экрана */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0 4px; min-height: 44px; }
.top .school { font-weight: 600; font-size: 15px; }
.top .school { min-width: 0; overflow-wrap: anywhere; line-height: 1.25; }
.tabs { display: flex; flex-shrink: 0; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.tabs a { text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 500; line-height: 20px; padding: 6px 12px; border-radius: 999px; white-space: nowrap; }
@media (max-width: 380px) { .tabs a { padding: 6px 10px; font-size: 13px; } }
.tabs a[aria-current='page'] { background: var(--ink); color: var(--paper); }
.back { background: none; border: 0; padding: 8px 0; color: var(--link); font-weight: 500; cursor: pointer; }

/* Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 20px; border-radius: 10px; border: 0; box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 1px 2px rgba(16,24,40,.2);
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 16px;
  text-decoration: none; cursor: pointer; width: 100%;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.secondary { background: var(--accent-soft); color: var(--ink); box-shadow: none; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(16,24,40,.05); }
.btn.inline { width: auto; min-height: 40px; padding: 8px 16px; font-size: 15px; }
.stack > * + * { margin-top: 10px; }

/* Каталог: строки, а не карточки */
.catalog { list-style: none; margin: 8px 0 0; padding: 0; border-top: 1px solid var(--line); }
.catalog li { border-bottom: 1px solid var(--line); }
.catalog a { display: grid; grid-template-columns: 64px 1fr; gap: 14px; padding: 16px 0; text-decoration: none; color: inherit; }
.catalog .cover { width: 64px; height: 64px; border-radius: 12px; background: var(--accent-soft) center/cover no-repeat; display: grid; place-items: center; color: var(--accent); font-weight: 600; font-size: 22px; }
.catalog .meta { color: var(--muted); font-size: 14px; margin-top: 2px; }
.catalog .price { margin-top: 6px; font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.nowrap { white-space: nowrap; }
.pill { display: inline-block; font-size: 12.5px; font-weight: 500; padding: 1px 7px; border-radius: 6px; background: var(--link-soft); color: var(--link); margin-right: 6px; }

/* Обложка курса */
.hero-cover { margin: 8px calc(-1 * var(--gutter)) 0; height: 180px; background: var(--accent-soft) center/cover no-repeat; }
@media (min-width: 640px) { .hero-cover { margin: 8px 0 0; border-radius: var(--radius); } }
.facts { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: 14px; margin: 4px 0 16px; padding: 0; list-style: none; }

/* Программа курса — главный элемент: рельс с состоянием каждого урока */
.program { list-style: none; margin: 0; padding: 0; }
.module-title { font-size: 14px; font-weight: 600; color: var(--muted); margin: 20px 0 6px 40px; }
.rail { list-style: none; margin: 0; padding: 0; position: relative; }
.rail::before { content: ''; position: absolute; left: 13px; top: 18px; bottom: 18px; width: 2px; background: var(--line); }
.rail li { position: relative; }
.rail a, .rail .row { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; text-decoration: none; color: inherit; }
.node { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 600; position: relative; z-index: 1; font-variant-numeric: tabular-nums; }
.node.done { background: var(--accent); color: var(--accent-ink); }
.node.open { background: var(--surface); border: 2px solid var(--accent); color: var(--accent); }
.node.locked { background: var(--paper); border: 2px dashed var(--line); color: var(--muted); }
.rail .title { font-weight: 500; }
.rail .sub { display: block; font-size: 13px; color: var(--muted); font-weight: 400; }
.rail .locked-row .title { color: var(--muted); }
.rail .tag { font-size: 13px; color: var(--link); font-weight: 500; white-space: nowrap; }

.progress { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* Тарифы: выбор как в списке, а не витрина карточек */
.tariffs { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.tariff { display: grid; grid-template-columns: 22px 1fr auto; gap: 12px; padding: 16px; cursor: pointer; border-top: 1px solid var(--line); }
.tariff:first-child { border-top: 0; }
.tariff input { margin: 3px 0 0; width: 18px; height: 18px; accent-color: var(--link); }
.tariff .price { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tariff ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); font-size: 14px; }
.tariff:has(input:checked) { background: var(--link-soft); box-shadow: inset 0 0 0 1.5px var(--link); }

.teacher { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.teacher .ph { width: 44px; height: 44px; border-radius: 50%; background: var(--accent-soft) center/cover; flex: none; }
details { border-top: 1px solid var(--line); padding: 12px 0; }
details:last-of-type { border-bottom: 1px solid var(--line); }
summary { cursor: pointer; font-weight: 500; list-style-position: inside; }
details p { margin: 8px 0 0; color: var(--muted); }

/* Нижняя панель действия (в MAX нет системной главной кнопки) */
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
}
.bar-inner { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.bar-inner .btn { flex: 1; }
.bar-price { font-weight: 600; font-size: 18px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar-price s { color: var(--muted); font-weight: 400; font-size: 14px; display: block; }

/* Формы */
.field { display: block; margin: 0 0 14px; }
.field span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
input[type='text'], input[type='email'], textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 48px;
}
textarea { min-height: 110px; resize: vertical; }
.inline-field { display: flex; gap: 8px; }
.inline-field input { flex: 1; }
.check { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; font-size: 15px; margin: 12px 0; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--link); }

.summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0 20px; }
.summary .line { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-variant-numeric: tabular-nums; }
.summary .total { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 12px; font-weight: 600; font-size: 18px; }

.note { padding: 14px 16px; border-radius: 12px; background: var(--accent-soft); margin: 12px 0; }
.note.error { background: var(--danger-soft); color: var(--danger); }
.status-mark { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; margin: 32px 0 8px; font-size: 26px; font-weight: 600; }
.status-mark.ok { background: var(--accent); color: var(--accent-ink); }
.status-mark.wait { border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
.status-mark.fail { background: var(--danger-soft); color: var(--danger); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Урок */
.video { position: relative; margin: 12px calc(-1 * var(--gutter)); aspect-ratio: 16/9; background: #000; }
.video iframe, .video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
@media (min-width: 640px) { .video { margin: 12px 0; border-radius: var(--radius); overflow: hidden; } }
.lesson-body { font-size: 17px; line-height: 1.6; }
.lesson-body img { max-width: 100%; height: auto; border-radius: 10px; }
.lesson-body h2, .lesson-body h3 { margin-top: 24px; }
.files { list-style: none; padding: 0; margin: 8px 0 0; }
.files button { width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px; }
.files button span:last-child { color: var(--accent); font-weight: 500; }
.lesson-nav { display: flex; gap: 10px; margin-top: 24px; }
.lesson-nav .btn { flex: 1; }

.quiz { margin-top: 28px; }
.quiz fieldset { border: 0; padding: 0; margin: 0 0 20px; }
.quiz legend { font-weight: 600; margin-bottom: 8px; }
.quiz label { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; background: var(--surface); cursor: pointer; }
.quiz label:has(input:checked) { border-color: var(--link); background: var(--link-soft); }
.quiz input { margin: 3px 0 0; accent-color: var(--link); width: 18px; height: 18px; }

.empty { text-align: left; padding: 32px 0; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 12px; font-size: 15px; z-index: 20; max-width: calc(100% - 32px); }
.skeleton { height: 18px; border-radius: 6px; background: var(--line); margin: 14px 0; opacity: 0.6; }
.skeleton.big { height: 30px; width: 70%; }
.date-cover { flex-direction: column; gap: 0; line-height: 1; }
.date-cover .d { font-size: 22px; font-weight: 600; }
.date-cover .m { font-size: 12px; font-weight: 500; margin-top: 2px; }

/* Открыто в браузере вне MAX */
.outside-card { max-width: 440px; margin: 12vh auto 0; text-align: center; }
.outside-card h1 { margin-bottom: 8px; }
.outside-card .btn { margin: 20px 0 8px; text-decoration: none; }
.outside-links { display: flex; justify-content: center; gap: 24px; margin-top: 28px; }
.outside-links a { color: var(--muted); font-size: 15px; }
.outside-links a:hover { color: var(--ink); }
