:root {
  --red: #c8102e;
  --red-ink: #a00d24;
  --blue: #0b3d91;
  --blue-ink: #082d6b;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #16202e;
  --muted: #5b6676;
  --line: #dde2ea;
  --ok: #157347;
  --ok-bg: #e6f4ec;
  --bad: #b02a37;
  --bad-bg: #fbe9eb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b; --surface: #171e28; --ink: #e8edf4; --muted: #9aa6b6; --line: #2a3442;
    --blue: #6f9cf0; --blue-ink: #9bbaf5; --red: #ef5a6f; --red-ink: #f47b8c;
    --ok: #4cc38a; --ok-bg: #12301f; --bad: #ef6b78; --bad-bg: #3a1a1f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--blue); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 16px; }
.wrap.narrow { max-width: 560px; padding-top: 48px; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 3px solid var(--red); }
.topbar .wrap { display: flex; align-items: center; gap: 12px; min-height: 64px; flex-wrap: wrap; padding-block: 8px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; }
.brand img { width: 40px; height: 40px; }
.brand span small { display: block; font-weight: 500; color: var(--muted); font-size: .8rem; }
.topbar .who { margin-left: auto; font-size: .875rem; color: var(--muted); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* Class header */
.hero { background: linear-gradient(135deg, var(--blue-ink), var(--blue)); color: #fff; }
.hero .wrap { padding-block: 28px; }
.hero h1 { color: #fff; }
.hero p { color: rgba(255,255,255,.85); margin: 0; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 20px 0; overflow-x: auto; }
.tabs button {
  background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 14px;
  font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--red); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }
.card.center { text-align: center; }
.msg-logo { width: 64px; height: 64px; margin-bottom: 8px; }

.grid2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1 1 200px; min-width: 0; }
.list .title { font-weight: 600; overflow-wrap: anywhere; }

.tag { display: inline-block; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.tag.quiz { color: var(--blue); }
.tag.lab { color: var(--red); }
.tag.handson { color: var(--ok); }
.gradebook td.cat, .gradebook th.cat { background: var(--bg); font-weight: 600; }
.tag.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--blue); color: #fff; border: 0; border-radius: 8px; padding: 10px 16px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; min-height: 44px;
}
.btn:hover { background: var(--blue-ink); }
.btn.red { background: var(--red); }
.btn.red:hover { background: var(--red-ink); }
.btn.ghost { background: transparent; color: var(--blue); border: 1px solid var(--line); }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: .875rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.linkbtn { background: none; border: 0; color: var(--blue); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
.linkbtn.danger { color: var(--bad); }

label { display: block; font-weight: 600; margin-bottom: 4px; font-size: .9rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 160px; }

/* Quiz */
.question { padding: 16px 0; border-top: 1px solid var(--line); }
.question:first-of-type { border-top: 0; }
.question .qtext { font-weight: 600; margin-bottom: 10px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; cursor: pointer; font-weight: 400; }
.choice input { margin-top: 4px; }
.choice.right { border-color: var(--ok); background: var(--ok-bg); }
.choice.wrong { border-color: var(--bad); background: var(--bad-bg); }

.score-big { font-size: 2.4rem; font-weight: 800; color: var(--blue); }

.notice { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
td.num, th.num { text-align: right; }
.gradebook input { width: 72px; padding: 6px; text-align: right; }
.gradebook th.sticky, .gradebook td.sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.saved { outline: 2px solid var(--ok) !important; }
.err { outline: 2px solid var(--bad) !important; }

.empty { color: var(--muted); padding: 12px 0; }
.qbuilder .qcard { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.qbuilder .copt { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.qbuilder .copt input[type=text] { flex: 1; }
.qbuilder .copt label { margin: 0; font-weight: 400; display: flex; gap: 4px; align-items: center; white-space: nowrap; }

footer { color: var(--muted); font-size: .8rem; padding: 32px 0; text-align: center; }
[hidden] { display: none !important; }
