/* Зачёт: синие чернила, жёлтый маркер, тетрадная клетка. Сначала телефон: ученики делают задания с телефона. */
:root {
  --bg: #f5f6fb; --surface: #ffffff; --surface-2: #eceff9; --line: #d8ddef; --grid: #e7eaf6;
  --ink: #1c2541; --muted: #5d6585; --accent: #2340a8; --accent-ink: #ffffff; --accent-soft: #e2e7fa;
  --marker: #ffe066; --marker-ink: #3d3200;
  --danger: #c0392b; --danger-soft: #fbe3df; --warn: #946200; --warn-soft: #fff1c7; --ok: #1d7a4a; --ok-soft: #dcf3e6;
  --radius: 12px; --shadow: 0 1px 2px rgb(28 37 65 / 6%), 0 6px 18px rgb(28 37 65 / 7%);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12162a; --surface: #1b2038; --surface-2: #252b47; --line: #333a5c; --grid: #1a1f37;
    --ink: #e8ebf7; --muted: #a0a7c6; --accent: #8fa5ff; --accent-ink: #0f1430; --accent-soft: #283265;
    --marker: #e6c44a; --marker-ink: #2a2200;
    --danger: #f08a7d; --danger-soft: #45221e; --warn: #e6b456; --warn-soft: #3b3014; --ok: #6fd3a0; --ok-soft: #173a29;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 6px 18px rgb(0 0 0 / 30%);
  }
}

body {
  font-size: 15.5px;
  background-color: var(--bg);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
}
.small { font-size: 13.5px; }
.wide { width: 100%; }
.btn { min-height: 44px; border-radius: 10px; white-space: normal; text-align: center; line-height: 1.25; }
input:not([type=checkbox]):not([type=radio]), select, textarea { min-height: 44px; font-size: 16px; }
h1 { overflow-wrap: break-word; }
h3 { margin: 0; font-size: 16px; font-weight: 800; }
.marker { background: linear-gradient(transparent 58%, var(--marker) 58%); padding: 0 2px; color: inherit; }

.shell { max-width: 820px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.top { position: sticky; top: 0; z-index: 30; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 19px; text-decoration: none; color: var(--accent); }
.brand.big { font-size: 26px; }
.top-actions { display: flex; align-items: center; gap: 12px; min-width: 0; }
.top-actions .avatar { width: 32px; height: 32px; text-decoration: none; }
.top-actions select { min-height: 36px; width: auto; max-width: 150px; padding: 4px 8px; font-size: 14px; }
.bell { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; font-weight: 700; font-size: 14px; text-decoration: none; color: var(--muted); }
.badge { min-width: 22px; height: 22px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 11px; background: var(--danger); color: #fff; font-size: 12.5px; font-weight: 800; }
.page-in { display: grid; gap: 16px; padding: 14px 16px 28px; min-width: 0; }
.page-in > * { min-width: 0; }

.tabs {
  position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(var(--tabs, 5), 1fr); gap: 2px;
  max-width: 820px; margin: 0 auto; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line);
}
.tab { display: grid; justify-items: center; gap: 2px; min-height: 52px; padding: 5px 1px 4px; border-radius: 10px; font-size: 11.5px; letter-spacing: -0.01em; font-weight: 800; color: var(--muted); text-decoration: none; text-align: center; }
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--accent); background: var(--accent-soft); }

.off { opacity: .6; }
.card { display: grid; gap: 10px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.list { display: grid; gap: 10px; }
.plain { text-decoration: none; color: inherit; }
a.card:hover { border-color: var(--accent); }
.top-row { align-items: flex-start; flex-wrap: nowrap; }
.top-row > :first-child { min-width: 0; overflow-wrap: break-word; }
.chips { gap: 6px; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 800; background: var(--surface-2); overflow-wrap: break-word; max-width: 100%; flex: none; }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-bad { background: var(--danger-soft); color: var(--danger); }
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.chip-marker { background: var(--marker); color: var(--marker-ink); }
.note { padding: 11px 14px; border-radius: 10px; background: var(--warn-soft); font-size: 14px; }
.note-calm { background: var(--accent-soft); }
.back { font-weight: 700; color: var(--muted); text-decoration: none; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pre { white-space: pre-wrap; overflow-wrap: break-word; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.section-title { margin-top: 6px; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tile { display: grid; gap: 2px; align-content: start; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.tile > span { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.tile b { font-size: 24px; font-weight: 800; line-height: 1.15; }
.tile small { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.tile.bad b { color: var(--danger); }

/* Статусы */
.st-issued { background: var(--accent-soft); color: var(--accent); }
.st-draft { background: var(--surface-2); color: var(--ink); }
.st-overdue { background: var(--danger-soft); color: var(--danger); }
.st-submitted { background: var(--warn-soft); color: var(--warn); }
.st-checked { background: var(--ok-soft); color: var(--ok); }
.pct { font-weight: 800; }
.pct-hi { color: var(--ok); } .pct-mid { color: var(--warn); } .pct-lo { color: var(--danger); }

/* Выполнение задания */
.question { display: grid; gap: 10px; }
.q-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.q-num { font-weight: 800; color: var(--accent); }
.q-text { font-size: 16.5px; font-weight: 600; line-height: 1.45; overflow-wrap: break-word; }
.img-btn { padding: 0; border: 0; background: none; cursor: zoom-in; justify-self: start; max-width: 100%; }
.q-img { display: block; max-width: 100%; max-height: 320px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.options { display: grid; gap: 8px; }
.option { display: flex; gap: 10px; align-items: center; min-height: 48px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; overflow-wrap: anywhere; }
.option input { width: 20px; height: 20px; flex: none; accent-color: var(--accent); }
.option.right { border-color: var(--ok); background: var(--ok-soft); }
.option.wrong { border-color: var(--danger); background: var(--danger-soft); }
.result { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 14px; }
.answer-box { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); white-space: pre-wrap; overflow-wrap: break-word; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.thumb { position: relative; width: 84px; height: 84px; padding: 0; border: 0; border-radius: 8px; overflow: hidden; background: var(--surface-2); cursor: pointer; }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo-full { display: block; width: 100%; max-height: calc(100dvh - 110px); object-fit: contain; border-radius: 8px; background: #fff; }
.dialog-photo { width: min(900px, calc(100vw - 16px)); padding: 10px; }
.score-big { font-size: 34px; font-weight: 800; color: var(--accent); }
.sticky-actions { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 20; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* Конструктор */
.q-edit { display: grid; gap: 10px; border-left: 4px solid var(--accent); }
.opt-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.opt-row input[type=radio], .opt-row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--ok); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { width: 20px; height: 20px; margin-top: 1px; flex: none; accent-color: var(--accent); }
.pick-list { display: grid; gap: 6px; max-height: 240px; overflow-y: auto; padding: 4px; border: 1px solid var(--line); border-radius: 10px; }

/* Журнал */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.journal { border-collapse: collapse; min-width: 100%; font-size: 14px; }
.journal th, .journal td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.journal th:first-child, .journal td:first-child { position: sticky; left: 0; background: var(--surface); text-align: left; z-index: 1; }
.journal thead th { font-size: 12px; color: var(--muted); font-weight: 800; vertical-align: bottom; }
.journal thead th span { display: block; max-width: 92px; white-space: normal; line-height: 1.2; }
.journal td a { text-decoration: none; font-weight: 800; }
.cell-overdue { color: var(--danger); font-weight: 800; }
.cell-wait { color: var(--warn); font-weight: 800; }
.cell-none { color: var(--muted); }

/* Прогресс */
.chart { display: block; width: 100%; height: auto; }
.chart text { fill: var(--muted); font-size: 10px; font-family: inherit; font-weight: 600; }
.chart .grid { stroke: var(--line); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linejoin: round; }
.chart .dot { fill: var(--accent); stroke: var(--surface); stroke-width: 1.5; }
.chart .ref { stroke: var(--danger); stroke-dasharray: 4 4; opacity: .5; }
.topic { display: grid; gap: 4px; }
.bar { height: 10px; border-radius: 10px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: calc(var(--p, 0) * 1%); background: var(--ok); border-radius: 10px; }
.topic.weak .bar i { background: var(--danger); }

/* Расписание */
.week-nav { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; text-align: center; font-weight: 800; }
.day-head { margin-top: 4px; font-size: 14px; font-weight: 800; color: var(--muted); }
.day-head.today { color: var(--accent); }
.lesson { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px; align-items: start; }
.lesson-time { font-size: 18px; font-weight: 800; }
.lesson-body { display: grid; gap: 6px; min-width: 0; }
.lesson.cancelled .lesson-time, .lesson.cancelled strong { text-decoration: line-through; color: var(--muted); }

/* Материалы */
.doc { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; align-items: center; }
.doc-icon { display: grid; place-items: center; width: 44px; height: 52px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 800; }
.doc-body { display: grid; gap: 4px; min-width: 0; }
.doc-body strong { overflow-wrap: break-word; }

.menu-list { display: grid; }
.menu-list a { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 52px; padding: 10px 2px; border-top: 1px solid var(--line); font-weight: 700; text-decoration: none; color: inherit; }
.menu-list > :first-child { border-top: 0; }
.menu-list a::after { content: '›'; color: var(--muted); font-size: 20px; }
.person { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.notice.unread { border-color: var(--accent); }

/* Главная репетитора */
.landing { max-width: 820px; margin: 0 auto; padding: 0 16px 40px; display: grid; gap: 18px; }
.landing-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; }
.hero { display: grid; gap: 0; overflow: hidden; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.hero img { display: block; width: 100%; aspect-ratio: 800 / 520; object-fit: cover; max-height: 320px; }
.hero-body { display: grid; gap: 12px; padding: 18px; }
.hero h1 { font-size: 27px; }
.block { display: grid; gap: 10px; }
.block-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.rich { display: grid; gap: 10px; }
.rich p, .rich li { line-height: 1.6; }
.rich ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.roles { display: grid; gap: 8px; }
.role-btn { display: grid; gap: 2px; justify-content: stretch; justify-items: start; text-align: left; padding: 12px 14px; min-height: 0; }
.role-btn small { font-weight: 600; color: var(--muted); }
.auth { display: grid; place-items: center; min-height: 100dvh; padding: 16px; }
.auth-card { width: min(440px, 100%); }
.footer { color: var(--muted); font-size: 13px; text-align: center; }

@media (min-width: 640px) {
  .page-in { padding: 18px 20px 32px; }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .hero { grid-template-columns: 1fr 1fr; }
  .hero img { height: 100%; max-height: none; }
}
