/* Exam Ready — light, fast, works on low-cost phones. System fonts only (no font downloads). */
:root {
  --ink: #17201b;
  --ink-2: #4b564f;
  --ink-3: #7a847e;
  --paper: #fbfaf6;
  --card: #ffffff;
  --line: #e4e1d6;
  --brand: #0f6b45;       /* deep green */
  --brand-ink: #ffffff;
  --brand-soft: #e3f1e9;
  --accent: #f2b705;      /* warm yellow */
  --accent-soft: #fff4cc;
  --bad: #b42318;
  --bad-soft: #fde8e6;
  --good: #137a3e;
  --good-soft: #e2f4e8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(23, 32, 27, 0.06), 0 2px 8px rgba(23, 32, 27, 0.05);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75rem; }
small, .muted { color: var(--ink-2); }
.tiny { font-size: 0.8rem; color: var(--ink-3); }

/* Layout */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1rem; background: var(--brand); color: var(--brand-ink);
}
.topbar .brand { font-weight: 700; font-size: 1.05rem; color: inherit; text-decoration: none; display: flex; align-items: center; gap: 0.5rem; }
.topbar .spacer { flex: 1; }
.topbar a, .topbar button.link { color: var(--brand-ink); }
.wrap { max-width: 720px; margin: 0 auto; padding: 1rem; }
.wrap.wide { max-width: 1100px; }
.stack > * + * { margin-top: 0.75rem; }
.row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* Admin nav */
.tabs { display: flex; gap: 0.25rem; overflow-x: auto; padding: 0.5rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); }
.tabs a { padding: 0.4rem 0.75rem; border-radius: 999px; text-decoration: none; color: var(--ink-2); white-space: nowrap; font-size: 0.92rem; }
.tabs a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card.tap { cursor: pointer; transition: border-color 0.15s; }
.card.tap:hover, .card.tap:focus-visible { border-color: var(--brand); }
.stat { font-size: 1.6rem; font-weight: 700; }
.badge { display: inline-block; font-size: 0.75rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--line); color: var(--ink-2); font-weight: 600; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--accent-soft); color: #7a5b00; }
.badge.brand { background: var(--brand-soft); color: var(--brand); }

/* Forms */
label { display: block; font-weight: 600; font-size: 0.92rem; margin-bottom: 0.25rem; }
.field { margin-bottom: 0.85rem; }
.hint { font-size: 0.82rem; color: var(--ink-3); font-weight: 400; margin-top: 0.2rem; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 1rem; padding: 0.65rem 0.75rem;
  border: 1px solid #cfcabb; border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { min-height: 6rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
input[type='checkbox'], input[type='radio'] { width: auto; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: inherit; font-weight: 600; font-size: 1rem; padding: 0.65rem 1.1rem; min-height: 44px;
  border-radius: 10px; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink);
  cursor: pointer; text-decoration: none;
}
button:disabled { opacity: 0.55; cursor: default; }
button.secondary, .btn.secondary { background: #fff; color: var(--brand); }
button.ghost { background: transparent; border-color: transparent; color: var(--brand); padding-left: 0.5rem; padding-right: 0.5rem; }
button.danger { background: #fff; border-color: var(--bad); color: var(--bad); }
button.small, .btn.small { font-size: 0.85rem; padding: 0.35rem 0.7rem; min-height: 34px; }
button.block, .btn.block { width: 100%; }
button.link { background: none; border: none; padding: 0; min-height: 0; color: var(--brand); text-decoration: underline; font-weight: 500; }

/* Practice */
.progress { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); transition: width 0.3s; }
.question { font-size: 1.1rem; white-space: pre-wrap; }
.options { display: grid; gap: 0.5rem; }
.option {
  display: flex; gap: 0.6rem; align-items: flex-start; text-align: left; justify-content: flex-start;
  background: #fff; color: var(--ink); border: 1.5px solid var(--line); font-weight: 500;
}
.option .letter { flex: none; width: 1.6rem; height: 1.6rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--paper); font-weight: 700; font-size: 0.85rem; }
.option.chosen { border-color: var(--brand); background: var(--brand-soft); }
.option.right { border-color: var(--good); background: var(--good-soft); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.feedback { border-radius: var(--radius); padding: 0.85rem 1rem; }
.feedback.good { background: var(--good-soft); border: 1px solid #b8e0c6; }
.feedback.bad { background: var(--bad-soft); border: 1px solid #f5c2bd; }
.feedback.part { background: var(--accent-soft); border: 1px solid #f2dc8a; }
.model { white-space: pre-wrap; background: var(--paper); border-left: 3px solid var(--brand); padding: 0.6rem 0.8rem; border-radius: 6px; font-size: 0.95rem; }
.bar { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }
.bar .track { flex: 1; height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar .track span { display: block; height: 100%; background: var(--brand); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; color: var(--ink-3); }

/* Messages */
.notice { padding: 0.75rem 1rem; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid #f2dc8a; }
.notice.brand { background: var(--brand-soft); border-color: #bfe0cd; }
.error { color: var(--bad); font-size: 0.92rem; }
#toast {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%) translateY(150%);
  background: var(--ink); color: #fff; padding: 0.7rem 1rem; border-radius: 10px; max-width: 90vw;
  transition: transform 0.25s, opacity 0.25s; z-index: 50; font-size: 0.95rem;
  opacity: 0; pointer-events: none;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.bad { background: var(--bad); }
.empty { text-align: center; padding: 2rem 1rem; color: var(--ink-2); }
.loading { padding: 2rem; text-align: center; color: var(--ink-3); }
pre.copy { white-space: pre-wrap; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem; font-family: inherit; font-size: 0.92rem; margin: 0; }
details summary { cursor: pointer; font-weight: 600; }
dialog { border: none; border-radius: var(--radius); padding: 0; width: min(680px, 94vw); box-shadow: 0 10px 40px rgba(0,0,0,0.25); }
dialog::backdrop { background: rgba(23, 32, 27, 0.45); }
dialog .dlg-body { padding: 1rem; max-height: 80vh; overflow-y: auto; }

@media (max-width: 480px) {
  h1 { font-size: 1.4rem; }
  .wrap { padding: 0.75rem; }
}
