:root {
  --bg: #f4f3ee;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --ink: #1b1a16;
  --muted: #6d6a61;
  --line: #e3e0d6;
  --accent: #1f6f5c;
  --accent-2: #2d8a72;
  --accent-soft: #e6f1ec;
  --ok: #1f7a4d;
  --warn: #9a5b00;
  --warn-soft: #fdf3e2;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 18, 12, .04), 0 6px 20px rgba(20, 18, 12, .04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15140f;
    --surface: #1e1d18;
    --surface-2: #23221c;
    --ink: #f2f0e8;
    --muted: #a6a298;
    --line: #32302a;
    --accent: #4fb393;
    --accent-2: #6dc9ab;
    --accent-soft: #1d3a32;
    --ok: #5fcf9a;
    --warn: #e0a458;
    --warn-soft: #3a2c15;
    --danger: #f27c72;
    --danger-soft: #3b1d1a;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  padding-bottom: 84px;
}
@media (min-width: 900px) { body { padding-bottom: 24px; } }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; margin-top: 1.4em; }
h3 { font-size: 1.02rem; }
p { margin: .5em 0; }
small, .small { font-size: .84rem; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 18px; padding-bottom: 28px; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 14px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo {
  width: 28px; height: 28px; border-radius: 8px; flex: 0 0 auto;
  background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 15px;
}
.nav { display: none; gap: 4px; margin-left: 8px; }
.nav a { color: var(--muted); padding: 8px 10px; border-radius: 9px; font-size: .94rem; }
.nav a.active, .nav a:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.topbar .spacer { flex: 1; }
.who { display: none; color: var(--muted); font-size: .88rem; }
@media (min-width: 860px) { .nav, .who { display: flex; } }
@media (max-width: 859px) { .topbar .logout-top { display: none; } }

/* ---------- bottom nav ---------- */
.bottom {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(5, 1fr);
}
@media (min-width: 900px) { .bottom { display: none; } }
.bottom a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 2px 5px; border-radius: 10px; color: var(--muted); font-size: .68rem;
}
.bottom a.active { color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.bottom svg { width: 22px; height: 22px; }

/* ---------- cards & grids ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.card-tight { padding: 14px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: 1fr; }
.grid.three { grid-template-columns: 1fr; }
.grid.stats { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 720px) {
  .grid.two { grid-template-columns: 1fr 1fr; }
  .grid.three { grid-template-columns: repeat(3, 1fr); }
  .grid.stats { grid-template-columns: repeat(4, 1fr); }
}

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; }
.stat b { display: block; font-size: 1.5rem; line-height: 1.15; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: .8rem; }

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.stack > * + * { margin-top: 10px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px; border-radius: 11px;
  border: 1px solid transparent; background: var(--accent); color: #fff;
  font: inherit; font-weight: 600; font-size: .96rem; cursor: pointer; text-align: center;
}
.btn:hover { background: var(--accent-2); text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--accent); border-color: transparent; min-height: 36px; padding: 6px 10px; }
.btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .86rem; border-radius: 9px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .86rem; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number],
textarea, select {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
}
textarea { min-height: 100px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.check { display: flex; align-items: flex-start; gap: 10px; font-size: .92rem; margin: 8px 0; }
.check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); }
.form-inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-inline .field { flex: 1 1 180px; margin-bottom: 0; }

/* ---------- misc ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.badge.ok { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.type { background: var(--surface-2); }

.divider { height: 1px; background: var(--line); margin: 16px 0; border: 0; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty b { display: block; color: var(--ink); margin-bottom: 6px; font-size: 1.05rem; }

.hero { padding: 8px 0 4px; }
.hero h1 { font-size: 1.75rem; }
.hero p { color: var(--muted); max-width: 62ch; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .grow b { display: block; font-weight: 600; }
.list .grow small { color: var(--muted); }

.progress { height: 7px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.q-text { font-size: 1.12rem; line-height: 1.5; }
.q-meta { color: var(--muted); font-size: .8rem; }
.quote { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 10px 14px; border-radius: 0 10px 10px 0; font-size: .9rem; }
.answer-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; }

.verdict { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border-radius: 12px; margin-bottom: 12px; }
.verdict.ok { background: var(--accent-soft); color: var(--accent); }
.verdict.warn { background: var(--warn-soft); color: var(--warn); }
.verdict.bad { background: var(--danger-soft); color: var(--danger); }
.verdict b { font-size: 1rem; }
.verdict .score { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; flex: 0 0 auto; }

.options { display: grid; gap: 10px; padding: 0; margin: 0; list-style: none; }
.opt {
  display: flex; gap: 11px; align-items: flex-start; padding: 13px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer;
}
.opt:hover { border-color: var(--accent); }
.opt input { margin-top: 3px; width: 20px; height: 20px; accent-color: var(--accent); }
.opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
.table-wrap { overflow-x: auto; }

details.edit { border: 1px solid var(--line); border-radius: 12px; padding: 0; background: var(--surface); }
details.edit > summary {
  cursor: pointer; padding: 11px 14px; font-size: .86rem; font-weight: 600; color: var(--muted);
  list-style: none;
}
details.edit > summary::-webkit-details-marker { display: none; }
details.edit[open] > summary { border-bottom: 1px solid var(--line); }
details.edit .body { padding: 14px; }

.auth { max-width: 420px; margin: 6vh auto 0; }
.auth .brand { justify-content: center; margin-bottom: 18px; }
.auth .card { padding: 24px; }

.pill-nav { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; }
.pill-nav a { flex: 0 0 auto; padding: 7px 13px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: .86rem; }
.pill-nav a.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.flash { background: var(--accent-soft); color: var(--accent); border-radius: 11px; padding: 10px 14px; margin-bottom: 14px; font-size: .9rem; }
.error { background: var(--danger-soft); color: var(--danger); border-radius: 11px; padding: 10px 14px; margin-bottom: 14px; font-size: .9rem; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 96px; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: .88rem; z-index: 60; }

details.acc { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
details.acc + details.acc { margin-top: 10px; }
details.acc > summary { padding: 14px 16px; cursor: pointer; list-style: none; }
details.acc > summary::-webkit-details-marker { display: none; }
details.acc .body { padding: 0 16px 16px; }

/* ---------- вопросы преподавателя ---------- */
.set-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.set-head-main { min-width: 0; }
.set-head h1 { margin: 0 0 2px; }
.set-head p { margin: 0; }
.set-stats { margin: 14px 0 16px; }
.set-layout { display: grid; gap: 16px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 900px) {
  .set-layout { grid-template-columns: 38% minmax(0, 1fr); }
  .set-source { position: sticky; top: 72px; }
}
.set-source, .set-tasks { min-width: 0; }
.set-tasks-head { margin-bottom: 10px; }
.set-tasks-head h2 { margin: 0; }
.raw {
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
  margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem; line-height: 1.55; max-height: 72vh; overflow: auto;
}
.notice { border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; margin-bottom: 12px; font-size: .88rem; }
.notice.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.notice b { display: block; margin-bottom: 2px; }
.task-card { padding: 0; overflow: hidden; }
.task-card + .task-card { margin-top: 12px; }
.task-summary {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 14px; cursor: pointer; list-style: none;
}
.task-summary::-webkit-details-marker { display: none; }
.task-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.task-card[open] .task-summary { background: var(--surface-2); border-bottom: 1px solid var(--line); }
.task-preview {
  flex: 1 1 220px; min-width: 0; color: var(--muted); font-size: .88rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.task-edit { flex: 0 0 auto; pointer-events: none; }
.task-body { padding: 14px; }
.task-note-box {
  background: var(--warn-soft); color: var(--warn); border-radius: 10px;
  padding: 9px 12px; font-size: .86rem; margin-bottom: 12px;
}
.task-card textarea { min-height: 96px; }
.tab-pane[hidden] { display: none; }

/* ---------- фото и проверка OCR ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .photo-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.photo-grid a { display: block; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.photo-grid img { display: block; width: 100%; height: 150px; object-fit: cover; }
.page-check-list { display: grid; gap: 14px; }
.page-check {
  display: grid; gap: 12px; grid-template-columns: 1fr;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
@media (min-width: 760px) {
  .page-check { grid-template-columns: 240px minmax(0, 1fr); align-items: start; }
}
.page-check-thumb { min-width: 0; }
.page-check-thumb img {
  display: block; width: 100%; max-width: 240px; height: auto;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2);
}
.page-check-form { min-width: 0; }
.page-check-form textarea { min-height: 180px; font-size: .9rem; }
@media (max-width: 480px) {
  .field > span { font-size: .82rem; }
  .pill-nav { margin: 0 -2px; }
}

@media print {
  .topbar, .bottom, .btn, details.edit { display: none !important; }
  body { padding: 0; background: #fff; }
}
