/* CPEN 151 Practice. Colour tokens follow slides_2026/shared/theme.css. */
:root {
  --page-bg: #eef0f5;
  --bg: #ffffff;
  --surface: #f7f8fb;
  --border: #e2e5ec;
  --text: #14161c;
  --text-dim: #5b6472;
  --accent: #4338ca;
  --accent-hover: #3730a3;
  --accent-soft: #eef0ff;
  --on-accent: #ffffff;
  --success: #047857;
  --success-soft: #d1fae5;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --star: #f59e0b;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --none: #d5d9e2;
  --code-bg: #0d1117;
  --code-text: #e6edf3;
  --code-border: #2a3142;
  --code-dim: #6e7681;
  --tok-kw: #ff7b72;
  --tok-str: #a5d6ff;
  --tok-num: #79c0ff;
  --tok-com: #8b949e;
  --tok-fn: #d2a8ff;
  --tok-self: #ffa657;
  --radius-sm: 8px;
  --radius: 14px;
  --shadow-sm: 0 1px 3px rgba(20, 22, 28, 0.08);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page-bg: #0b0d12;
    --bg: #151821;
    --surface: #1b1f2a;
    --border: #2b3140;
    --text: #e8eaf0;
    --text-dim: #a2aaba;
    --accent: #8b93ff;
    --accent-hover: #a5abff;
    --accent-soft: #23264a;
    --on-accent: #0b0d12;
    --success: #34d399;
    --success-soft: #0f2e24;
    --warn: #fbbf24;
    --warn-soft: #33270b;
    --star: #fbbf24;
    --danger: #f87171;
    --danger-soft: #3a1717;
    --none: #3a4152;
    --code-bg: #0b0e14;
    --code-border: #2b3140;
    --shadow-sm: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --page-bg: #0b0d12;
  --bg: #151821;
  --surface: #1b1f2a;
  --border: #2b3140;
  --text: #e8eaf0;
  --text-dim: #a2aaba;
  --accent: #8b93ff;
  --accent-hover: #a5abff;
  --accent-soft: #23264a;
  --on-accent: #0b0d12;
  --success: #34d399;
  --success-soft: #0f2e24;
  --warn: #fbbf24;
  --warn-soft: #33270b;
  --star: #fbbf24;
  --danger: #f87171;
  --danger-soft: #3a1717;
  --none: #3a4152;
  --code-bg: #0b0e14;
  --code-border: #2b3140;
  --shadow-sm: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font: 16px/1.55 var(--font-sans);
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

h1, h2 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.05rem; }
p { margin: 0.5em 0; }
code { font-family: var(--font-mono); font-size: 0.92em; background: var(--surface); border: 1px solid var(--border); border-radius: 5px; padding: 0 0.3em; }
.dim { color: var(--text-dim); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.loading { text-align: center; color: var(--text-dim); margin-top: 30vh; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 8px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); padding: 8px 10px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.45; cursor: default; }
.link { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 6px 4px; }
.link.danger { color: var(--danger); }
.link:disabled { opacity: 0.45; cursor: default; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.actions { display: flex; align-items: center; gap: 8px; margin: 12px 0; flex-wrap: wrap; }

/* ---------------------------------------------------------------- header */
.brand { background: var(--bg); border-bottom: 1px solid var(--border); }
.brand-in {
  max-width: 760px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand-home { display: flex; align-items: center; gap: 12px; flex: 1 1 auto; min-width: 0; color: var(--text); text-decoration: none; }
.logo { display: block; flex: none; width: auto; height: 34px; }
.logo-dark { display: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; padding-left: 12px; border-left: 1px solid var(--border); line-height: 1.25; }
.brand-text b { font-size: 1rem; }
.brand-text span { font-size: 0.8rem; color: var(--text-dim); }
.icon-btn {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.i-sun { display: none; }
/* the player: avatar, name, level and score */
.player {
  display: flex; align-items: center; gap: 10px; min-width: 0; margin-left: auto; padding: 4px 6px 4px 4px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); text-decoration: none;
}
.player[hidden] { display: none; }
.player:hover { border-color: var(--accent); }
.avatar {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff; font-weight: 800; font-size: 0.95rem;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}
.avatar.xl { width: 64px; height: 64px; font-size: 1.5rem; }
.p-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.p-text b { font-size: 0.92rem; max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-text span { font-size: 0.74rem; color: var(--text-dim); white-space: nowrap; }
.p-score {
  flex: none; display: inline-flex; align-items: center; gap: 5px; padding: 5px 12px; border-radius: 999px;
  background: linear-gradient(135deg, #f59e0b, #f97316); color: #fff; font-weight: 800; font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}
.p-score.bump { animation: bump 0.7s ease; }
@keyframes bump { 0% { transform: scale(1); } 30% { transform: scale(1.3); } 100% { transform: scale(1); } }
.brand-in .icon-btn { margin-left: 0; }

/* the page tabs under the header */
.tabs { border-top: 1px solid var(--border); }
.tabs-in { max-width: 760px; margin: 0 auto; padding: 0 16px; display: flex; gap: 6px; }
.tab {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 16px;
  border-bottom: 3px solid transparent; color: var(--text-dim); font-weight: 700; text-decoration: none;
}
.tab:hover { color: var(--text); }
.tab svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

/* phones: the player gets a row of its own, the tabs share the width */
@media (max-width: 639px) {
  .brand-in { flex-wrap: wrap; row-gap: 10px; }
  .brand-home { order: 1; flex: 1 1 0; }
  .brand-in .icon-btn { order: 2; }
  .player { order: 3; flex-basis: 100%; margin-left: 0; border-radius: var(--radius); padding: 6px 8px 6px 6px; }
  .player .p-text { flex: 1; }
  .player .p-text b { max-width: none; }
  .tabs-in { padding: 0; gap: 0; }
  .tab { flex: 1; }
}
@media (max-width: 359px) {
  .logo { height: 26px; }
  .brand-home { gap: 8px; }
  .brand-text { padding-left: 8px; }
  .brand-text span { font-size: 0.72rem; }
}

/* notices: points, a new level, a new badge */
.toasts {
  position: fixed; bottom: 20px; left: 50%; z-index: 50; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; width: max-content; max-width: calc(100% - 32px);
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 999px;
  color: #fff; font-weight: 700; box-shadow: 0 10px 28px rgba(20, 22, 28, 0.25);
  animation: toast-in 0.35s ease, toast-out 0.4s ease 2.4s forwards;
}
.toast .t-icon { font-size: 1.3rem; }
.toast.gain { background: linear-gradient(135deg, #f59e0b, #f97316); }
.toast.level { background: linear-gradient(135deg, #059669, #10b981); }
.toast.award { background: linear-gradient(135deg, #6366f1, #a855f7); }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(0.95); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }

/* the name dialog */
.namedlg {
  width: calc(100% - 32px); max-width: 420px; padding: 24px; border: 0; border-radius: var(--radius);
  background: var(--bg); color: var(--text); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35); text-align: center;
}
.namedlg::backdrop { background: rgba(10, 12, 20, 0.6); }
.namedlg h2 { font-size: 1.3rem; margin: 12px 0 4px; }
.namedlg .label { text-align: left; }
.namedlg input {
  width: 100%; min-height: 48px; padding: 10px 14px; border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 1.05rem;
}
.namedlg input:focus { border-color: var(--accent); outline: none; }
.namedlg .actions { justify-content: center; margin-top: 16px; }
.namedlg .btn { min-width: 120px; }
.namedlg .btn[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .p-score.bump, .toast { animation: none; }
}
:root[data-theme="dark"] .logo-light, :root[data-theme="dark"] .i-moon { display: none; }
:root[data-theme="dark"] .logo-dark, :root[data-theme="dark"] .i-sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light, :root:not([data-theme="light"]) .i-moon { display: none; }
  :root:not([data-theme="light"]) .logo-dark, :root:not([data-theme="light"]) .i-sun { display: block; }
}

/* ---------------------------------------------------------------- home */
.home-head { margin: 4px 0 4px; }
.lead { color: var(--text-dim); margin: 4px 0 12px; }
.message { background: var(--accent-soft); border-radius: var(--radius-sm); padding: 10px 14px; }

.panel {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px 16px; margin: 12px 0; box-shadow: var(--shadow-sm);
}
.panel h2 { margin-bottom: 10px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.panel-head h2 { margin: 0; }
.panel h3 { font-size: 0.88rem; font-weight: 700; color: var(--text-dim); margin: 16px 0 6px; }
.row-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px; }
.row-h h2 { margin: 0; }

/* starting a session */
.step h2 { display: flex; align-items: center; gap: 10px; }
.stepnum {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--on-accent); font-size: 0.85rem; font-weight: 700;
}
.options { display: grid; gap: 8px; }
.option {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 8px 14px;
  border: 2px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
}
.option::before {
  content: ""; flex: none; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--text-dim); background: var(--bg);
}
.option[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.option[aria-checked="true"]::before { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 4px, var(--bg) 5px); }
.o-t { flex: 1; }
.o-c { color: var(--text-dim); font-weight: 400; font-variant-numeric: tabular-nums; }
@media (min-width: 560px) { .options { grid-template-columns: repeat(3, 1fr); } }
.startbar {
  position: sticky; bottom: 12px; z-index: 5; margin: 16px 0 0; padding: 12px 12px 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(20, 22, 28, 0.14);
}
.startbar .match { flex: 1; min-width: 0; color: var(--text-dim); margin: 0; font-size: 0.93rem; }
.startbar .match b { color: var(--text); }
.startbar .btn { flex: none; min-width: 150px; }
.resume { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px 16px; margin: 4px 0 16px; }
.resume h2 { font-size: 1rem; }
.resume p { margin: 4px 0 0; }
.resume .actions { margin: 10px 0 0; }

/* progress */
.counts { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.9rem; margin: 8px 0 0; }
.counts span { display: inline-flex; align-items: center; gap: 6px; }
.levels { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 8px; }
.levels li { display: grid; grid-template-columns: 4.6em 1fr 4.2em; align-items: center; gap: 10px; font-size: 0.9rem; }
.levels .num { text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.stack { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--none); }
.stack.big { height: 14px; border-radius: 7px; }
.s-c { background: var(--success); }
.s-m { background: var(--danger); }
.s-n { background: var(--none); }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }

/* filters */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 0.95rem; cursor: pointer; text-align: left;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 600; }
.chip[aria-pressed="true"]::before { content: "\2713"; color: var(--accent); font-weight: 700; }
.chip:disabled { opacity: 0.5; cursor: default; }
.chip:disabled::before { content: none; }
.chips.lectures { display: grid; grid-template-columns: 1fr; gap: 6px; }
.chip.lec { width: 100%; border-radius: var(--radius-sm); padding: 6px 12px; }
.chip-n { font-weight: 700; min-width: 2.2em; }
.chip-t { flex: 1; }
.soon { font-size: 0.8rem; color: var(--text-dim); }
@media (min-width: 560px) { .chips.lectures { grid-template-columns: 1fr 1fr; } }

/* the progress page */
.profile-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.profile .who { flex: 1; min-width: 0; }
.profile .who h2 { margin: 0; font-size: 1.3rem; overflow-wrap: break-word; }
.profile .who .link { padding: 4px 0 0; font-size: 0.88rem; }
.lvl { margin: 4px 0 0; color: var(--text-dim); font-weight: 600; }
.lvl-badge {
  display: inline-block; padding: 1px 10px; border-radius: 999px; margin-right: 4px;
  background: linear-gradient(135deg, #059669, #10b981); color: #fff; font-size: 0.82rem; font-weight: 800;
}
.xp { margin: 16px 0 4px; }
.xp-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 6px; }
.xp-head b { font-size: 1.6rem; color: var(--text); font-variant-numeric: tabular-nums; }
.xp-head .dim { font-size: 0.88rem; }
.xp-bar { display: block; height: 12px; border-radius: 6px; background: var(--none); overflow: hidden; }
.xp-bar > span { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #f59e0b, #f97316); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.stat {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px;
  border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); text-align: center;
}
.stat .s-ico { font-size: 1.3rem; line-height: 1; }
.stat b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.stat span:last-child { font-size: 0.76rem; color: var(--text-dim); }
.b-group { display: flex; align-items: baseline; gap: 8px; font-size: 0.92rem; color: var(--text); margin: 18px 0 10px; }
.panel-head + .b-group, .fold > summary + .b-group { margin-top: 4px; }
.b-group .dim { font-size: 0.82rem; font-weight: 600; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 14px 8px; }
.badge { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.medal {
  width: 58px; height: 58px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 28px; line-height: 1; border: 3px solid var(--bg);
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.55), transparent 55%), linear-gradient(135deg, var(--c1), var(--c2));
  box-shadow: 0 0 0 2px var(--c2), 0 6px 14px rgba(20, 22, 28, 0.18);
}
.badge.locked .medal { filter: grayscale(1); opacity: 0.35; box-shadow: 0 0 0 2px var(--none); }
.b-name { font-weight: 700; font-size: 0.85rem; line-height: 1.2; }
.b-desc { font-size: 0.74rem; color: var(--text-dim); line-height: 1.3; }
.b-got { font-size: 0.72rem; font-weight: 700; color: var(--success); }
.b-prog { display: block; width: 70%; height: 5px; border-radius: 3px; background: var(--none); overflow: hidden; margin-top: 2px; }
.b-prog > span { display: block; height: 100%; background: var(--accent); }
.b-count { font-size: 0.72rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.score-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 10px; }
.score-big { font-size: 2rem; font-weight: 800; line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; }
.score-of { color: var(--text-dim); }
.stars { color: var(--star); font-size: 1.05rem; letter-spacing: 1px; white-space: nowrap; }
.stars .off { color: var(--none); }
.lec-meta { font-size: 0.88rem; color: var(--text-dim); margin: 2px 0 0; }
.over-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px; padding: 12px 0 0; margin-top: 12px; border-top: 1px solid var(--border); }
.over-text { display: flex; flex-direction: column; gap: 2px; flex: 1 1 220px; min-width: 0; }
.over-row .actions { margin: 0; }
#h-over + .message { margin-top: 10px; }
.over-row .dim { font-size: 0.88rem; }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: var(--on-accent); }
.btn.danger-solid:hover:not(:disabled) { filter: brightness(1.08); border-color: var(--danger); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.85rem; color: var(--text-dim); margin: 0 0 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw.t-solved { background: var(--success-soft); border: 1px solid var(--success); }
.sw.t-wrong { background: var(--danger-soft); border: 1px solid var(--danger); }
.sw.t-new { background: var(--surface); border: 1px solid var(--none); }
.sw.t-last { background: var(--surface); box-shadow: 0 0 0 2px var(--accent); }
.qhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 22px 0 4px; }
.qhead h2 { font-size: 1.15rem; }
.qhead { flex-wrap: wrap; row-gap: 0; }
.fold-all { color: var(--text-dim); font-size: 0.92rem; white-space: nowrap; }
.lecgroup-h { display: flex; align-items: baseline; justify-content: space-between; gap: 4px 10px; flex-wrap: wrap; }
.lecgroup-h h3 { font-size: 1rem; color: var(--text); margin: 0; }
.lecgroup .fold-main > .stack { margin-top: 8px; height: 6px; }
.lecgroup .lec-meta { display: block; }

/* sections that open and close */
.fold > summary { display: flex; align-items: center; gap: 12px; list-style: none; cursor: pointer; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary:hover .chev { border-color: var(--accent); }
.fold-main { display: block; flex: 1; min-width: 0; }
.fold-main > .panel-head { margin-bottom: 0; }
.fold[open] > summary { margin-bottom: 12px; }
.chev {
  flex: none; width: 11px; height: 11px; margin: 0 6px 5px 0;
  border-right: 2.5px solid var(--text-dim); border-bottom: 2.5px solid var(--text-dim); transform: rotate(45deg);
}
.fold[open] > summary .chev { transform: rotate(-135deg); margin-bottom: -5px; }
.fold-peek { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.fold-peek .dim { font-size: 0.88rem; }
.fold[open] .fold-peek { display: none; }
.medal.sm { width: 34px; height: 34px; font-size: 17px; border-width: 2px; box-shadow: 0 0 0 1.5px var(--c2), 0 2px 6px rgba(20, 22, 28, 0.15); }
.lvrow { margin-top: 10px; }
.lv-label { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.lv-E { color: var(--success); }
.lv-M { color: var(--warn); }
.lv-H { color: var(--danger); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 6px; margin-top: 4px; }
.tile {
  position: relative; height: 48px; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer;
}
.tile:hover { border-color: var(--accent); }
.t-n { font-weight: 700; font-size: 0.95rem; }
.t-k { font-size: 0.66rem; color: var(--text-dim); }
.tile.st-solved { background: var(--success-soft); border-color: var(--success); }
.tile.st-wrong { background: var(--danger-soft); border-color: var(--danger); }
.tile.st-solved::after, .tile.st-wrong::after { position: absolute; top: 1px; right: 4px; font-size: 0.68rem; font-weight: 700; }
.tile.st-solved::after { content: "\2713"; color: var(--success); }
.tile.st-wrong::after { content: "\2717"; color: var(--danger); }
.tile.is-last { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }

/* ---------------------------------------------------------------- a question */
.qtop { display: flex; align-items: center; gap: 8px; }
.qcount { font-weight: 600; flex: 1; text-align: center; }
.pystatus { font-size: 0.8rem; color: var(--text-dim); min-width: 5.5em; text-align: right; }
.pystatus[data-status="failed"] { color: var(--danger); }
.progressbar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin: 6px 0 16px; }
.progressbar span { display: block; height: 100%; background: var(--accent); }

.kindhead h1 { font-size: 1.3rem; margin-top: 4px; }
.kindhead p { color: var(--text-dim); font-size: 0.93rem; margin: 4px 0 0; }
.tags { display: flex; gap: 6px; }
.tag { font-size: 0.78rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text-dim); }
.tag.pts { color: var(--accent); }
.points { margin: 14px 0 0; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.points b { font-size: 1.1em; }
.points { display: flex; align-items: center; gap: 10px; }
.pts-big {
  flex: none; padding: 2px 12px; border-radius: 999px; color: #fff; font-weight: 800; font-size: 1.15rem;
  background: linear-gradient(135deg, #f59e0b, #f97316);
}
.points.part .pts-big { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.points.ok { background: var(--success-soft); border-color: var(--success); }
.points.part { background: var(--warn-soft); border-color: var(--warn); }
.tag.st-solved { color: var(--success); border-color: var(--success); }
.tag.st-wrong { color: var(--danger); border-color: var(--danger); }

.question {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin: 14px 0; box-shadow: var(--shadow-sm);
}
.prompt { font-size: 1.05rem; }
.prompt p:first-child { margin-top: 0; }
.prompt pre.code { margin: 10px 0; }
.note { color: var(--text-dim); font-size: 0.93rem; }

.part { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 14px; }
.part h2 { font-size: 1rem; margin-bottom: 6px; }

.label { display: block; font-size: 0.88rem; font-weight: 600; color: var(--text-dim); margin: 10px 0 4px; }
textarea.answer {
  width: 100%; padding: 10px 12px; resize: vertical;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font: 15px/1.5 var(--font-mono);
}
textarea.answer[readonly] { opacity: 0.85; }

.choices { display: grid; gap: 8px; margin: 14px 0 4px; }
.choices.two { grid-template-columns: 1fr 1fr; }
.choice {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 14px;
  border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.choices.two .choice { justify-content: center; font-weight: 700; }
.choice:hover:not(:disabled) { border-color: var(--accent); }
.choice:disabled { cursor: default; }
.choice.is-correct { border-color: var(--success); background: var(--success-soft); }
.choice.is-wrong { border-color: var(--danger); background: var(--danger-soft); }
.choice.is-dim { opacity: 0.55; }
.letter {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg); border: 1px solid var(--border); font-weight: 700; font-size: 0.9rem;
}
.opt-t { min-width: 0; overflow-wrap: anywhere; }

.verdict { display: flex; align-items: flex-start; gap: 8px; font-weight: 700; margin: 12px 0 6px; }
.verdict.ok { color: var(--success); }
.verdict.bad { color: var(--danger); }
.verdict.part { color: var(--warn); }
.v-icon { flex: none; }
.verdict code { font-weight: 400; }

.why { background: var(--surface); border-left: 4px solid var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 8px 12px; margin: 12px 0 0; }
.why p { margin: 4px 0; }
.concept { font-size: 0.8rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; }

.model { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 8px 12px; margin: 10px 0; }
.model-h { font-size: 0.8rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.03em; margin: 6px 0 2px; }
.model p { margin: 4px 0; }
.rubric { margin: 4px 0; padding-left: 20px; }
.selfcheck span { font-weight: 600; margin-right: 4px; }
.hint { font-size: 0.85rem; color: var(--text-dim); margin: 6px 0; }

.results { list-style: none; padding: 0; margin: 8px 0; }
.results li { padding: 6px 10px 6px 34px; margin: 4px 0; border-radius: var(--radius-sm); position: relative; overflow-wrap: anywhere; }
.results li::before { position: absolute; left: 10px; top: 6px; font-weight: 700; }
.results li.ok { background: var(--success-soft); }
.results li.ok::before { content: "\2713"; color: var(--success); }
.results li.bad { background: var(--danger-soft); }
.results li.bad::before { content: "\2717"; color: var(--danger); }
.results .got { display: block; }
.results pre.out { margin: 4px 0; }

.qnav { display: flex; justify-content: space-between; gap: 12px; }
.qnav .btn { min-width: 110px; }

/* ---------------------------------------------------------------- code */
pre.code, pre.out {
  margin: 10px 0; padding: 12px 14px; overflow-x: auto;
  background: var(--code-bg); color: var(--code-text); border: 1px solid var(--code-border); border-radius: var(--radius-sm);
  font: 14px/1.5 var(--font-mono); tab-size: 4;
}
pre.code code { background: none; border: 0; padding: 0; font-size: inherit; color: inherit; }
pre.out { background: var(--surface); color: var(--text); border-color: var(--border); }
.numbered { display: flex; margin: 10px 0; border: 1px solid var(--code-border); border-radius: var(--radius-sm); overflow: hidden; background: var(--code-bg); }
.numbered .gutter { margin: 0; padding: 12px 8px 12px 10px; color: var(--code-dim); background: var(--code-bg); font: 14px/1.5 var(--font-mono); text-align: right; user-select: none; border-right: 1px solid var(--code-border); }
.numbered pre.code { margin: 0; border: 0; border-radius: 0; flex: 1; min-width: 0; }

/* Pygments classes */
.code .k, .code .kn, .code .kd, .code .kr, .code .ow, .code .kc { color: var(--tok-kw); }
.code .s, .code .s1, .code .s2, .code .sd, .code .sa, .code .si, .code .se, .code .sb, .code .sc, .code .dl { color: var(--tok-str); }
.code .m, .code .mi, .code .mf, .code .mh, .code .mo { color: var(--tok-num); }
.code .c, .code .c1, .code .cm { color: var(--tok-com); font-style: italic; }
.code .nf, .code .nb, .code .fm, .code .nc { color: var(--tok-fn); }
.code .bp { color: var(--tok-self); }

/* the editor */
.editor { margin: 10px 0; }
.editor-box { display: flex; border: 1px solid var(--code-border); border-radius: var(--radius-sm); overflow: hidden; background: var(--code-bg); }
.editor-box:focus-within { outline: 3px solid var(--accent); outline-offset: 1px; }
.editor .gutter { margin: 0; padding: 12px 8px 12px 10px; color: var(--code-dim); font: 14px/1.5 var(--font-mono); text-align: right; user-select: none; border-right: 1px solid var(--code-border); }
.code-input {
  flex: 1; min-width: 0; min-height: 10em; margin: 0; padding: 12px 14px;
  border: 0; outline: none; resize: none; overflow-x: auto; overflow-y: hidden;
  background: var(--code-bg); color: var(--code-text); caret-color: #fff;
  font: 14px/1.5 var(--font-mono); white-space: pre; tab-size: 4;
}
.keyrow { display: none; gap: 6px; overflow-x: auto; padding: 6px 0 0; }
.key {
  flex: none; min-width: 40px; height: 40px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: 600 1rem var(--font-mono); cursor: pointer;
}
/* the symbol keys: on touch screens (checked live, so a browser's phone view shows them without
   a reload) and on any narrow screen */
.touch .keyrow { display: flex; }
.touch .editor .hint { display: none; }
@media (pointer: coarse), (max-width: 700px) {
  .keyrow { display: flex; }
  .editor .hint { display: none; }
}

@media (min-width: 700px) {
  body { font-size: 17px; }
  main { padding-top: 24px; }
  .logo { height: 42px; }
  .brand-text b { font-size: 1.1rem; }
  .brand-text span { font-size: 0.88rem; }
}
