:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #5b6673;
  --line: #dde3ea;
  --accent: #1f5f8b;
  --accent-text: #ffffff;
  --ok: #2f8f5b;
  --warn: #c77d12;
  --radius: 14px;
  --topbar: 52px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171d;
    --card: #1b232c;
    --text: #e8edf2;
    --muted: #9aa7b4;
    --line: #2b3641;
    --accent: #5aa5d8;
    --accent-text: #0e1620;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  height: calc(var(--topbar) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); font-size: 18px; }
.net { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.net.offline { background: var(--warn); }
.net.nosync { background: #c9a227; }
.view { max-width: 760px; margin: 0 auto; padding: 16px; }
h1 { font-size: 24px; margin: 8px 0 12px; }
h2 { font-size: 18px; margin: 20px 0 8px; }
.muted { color: var(--muted); }
.card {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin: 10px 0;
  color: inherit; text-decoration: none;
}
a.card:active { opacity: .85; }
.card h3 { margin: 0 0 4px; font-size: 17px; }
.card p { margin: 4px 0; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.badge { font-size: 13px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--accent); background: var(--accent);
  color: var(--accent-text); border-radius: 10px; padding: 8px 14px; min-height: 40px;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button.secondary, .btn.secondary { background: transparent; color: var(--accent); }
button[disabled] { opacity: .5; cursor: default; }
.tabs { display: flex; gap: 6px; margin: 12px 0; }
.tabs a { flex: 1; text-align: center; padding: 8px; border-radius: 10px; border: 1px solid var(--line); text-decoration: none; color: var(--muted); }
.tabs a.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.lesson { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: start; }
.lesson .num {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: var(--bg); border: 1px solid var(--line); font-weight: 600; color: var(--muted);
}
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 8px 0; }
.progress > span { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.notice { border-left: 3px solid var(--warn); padding: 8px 12px; background: var(--card); border-radius: 8px; margin: 12px 0; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 10; max-width: 90vw;
}
details summary { cursor: pointer; color: var(--accent); }

.chip {
  font-size: 14px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--text); text-decoration: none; background: var(--bg); max-width: 40vw;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip.empty { border-color: var(--warn); color: var(--warn); }
.lesson .bar { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; margin: 6px 0 4px; }
.lesson .bar > span { display: block; height: 100%; background: var(--ok); }
.lesson.pending .bar > span { background: var(--accent); }
.grade { font-weight: 600; }
.grade.ok { color: var(--ok); }
.grade.low { color: var(--warn); }
.stat { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 8px 0; }
.stat div { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.stat b { display: block; font-size: 20px; }
.stat small { color: var(--muted); }
.profile { display: flex; align-items: center; gap: 10px; }
.profile .avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 18px;
}
.profile.active { border-color: var(--accent); }
form.inline { display: flex; gap: 8px; margin: 12px 0; }
form.inline input { flex: 1; font: inherit; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); min-width: 0; }
.review-item .q { margin: 4px 0 8px; }
.linkrow { display: flex; gap: 14px; flex-wrap: wrap; margin: 16px 0; }
code { font-size: 13px; background: var(--bg); padding: 1px 5px; border-radius: 4px; }

/* роли и страницы учителя */
.banner { padding: 8px 12px; border-radius: 10px; margin: 10px 0; font-size: 14px; border: 1px solid; }
.banner.preview { background: #fff4e0; color: #7a4d00; border-color: #f0c98a; }
.banner.actas { background: #e3f3ea; color: #1c5a37; border-color: #9fd3b5; }
.banner a { color: inherit; font-weight: 600; }
@media (prefers-color-scheme: dark) {
  .banner.preview { background: #3a2a10; color: #f3c987; border-color: #6a4a1a; }
  .banner.actas { background: #10301e; color: #9fd3b5; border-color: #2c6a44; }
}
select {
  font: inherit; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); min-height: 40px; max-width: 100%;
}
.invite { margin-top: 10px; }
.invite code { display: block; word-break: break-all; white-space: normal; padding: 8px 10px; margin: 8px 0; font-size: 13px; }
.invite .row { margin: 8px 0; }
.qlist { list-style: none; padding: 0; margin: 6px 0 0; }
.qlist li { padding: 6px 0; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: baseline; font-size: 15px; }
.qlist .mark { flex: none; min-width: 2.4em; font-weight: 700; color: var(--muted); }
.qlist .ok .mark { color: var(--ok); }
.qlist .bad .mark { color: #c0392b; }
.qlist .fixed .mark { color: var(--warn); }
.log { list-style: none; padding: 0; margin: 0; }
.log li { padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.log li:first-child { border-top: 0; }
details > summary { cursor: pointer; padding: 6px 0; }
