/* Layout follows the Rad Ninja lesson page, in black and neutral grays with the deck's yellow as the accent. */
:root {
  --bg: #0a0a0a;
  --bg-2: #111111;
  --card: #151515;
  --card-2: #1c1c1c;
  --hover: #242424;
  --line: #262626;
  --line-2: #333333;
  --text: #f0f0f0;
  --text-2: #c8c8c8;
  --muted: #9a9a9a;
  --dim: #6b6b6b;
  --accent: #ffd23f;
  --accent-ink: #111;
  --ok: #4ade80;
  --no: #f87171;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; color: var(--text); }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ico { width: 16px; height: 16px; flex-shrink: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px;
  padding: 11px 20px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .4; cursor: default; filter: none; }
.btn.ghost { background: transparent; color: var(--text-2); border: 1px solid var(--line-2); }
.btn.ghost:hover { background: var(--hover); }
.btn.small { padding: 8px 16px; font-size: 14px; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }

/* ---------- top bar ---------- */
.topbar {
  height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 24px; border-bottom: 1px solid var(--line); background: var(--bg-2);
  position: sticky; top: 0; z-index: 5;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ghost-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 14px; padding: 6px 8px; border-radius: 8px; white-space: nowrap; }
.ghost-link:hover { color: var(--text); background: var(--hover); }
.sep { width: 1px; height: 22px; background: var(--line-2); }
.badge { font-size: 12px; color: var(--text-2); background: var(--card-2); border: 1px solid var(--line-2); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.topbar-right { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; white-space: nowrap; }

.page { max-width: 1320px; margin: 0 auto; padding: 24px; }

/* ---------- lesson page ---------- */
.lesson-top { display: flex; gap: 24px; align-items: flex-start; }
.lesson-main { flex: 1; min-width: 0; }
.lesson-main h1 { font-size: 28px; font-weight: 700; margin-top: 24px; }
.lede { color: var(--muted); }
.video-frame { position: relative; aspect-ratio: 16 / 9; background: #000; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-missing { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); background: radial-gradient(circle at 50% 45%, #1d1d1d, #050505 70%); }
.play-disc { width: 76px; height: 76px; border-radius: 50%; background: var(--card-2); border: 1px solid var(--line-2); display: grid; place-items: center; }
.play-disc .ico { width: 30px; height: 30px; margin-left: 4px; color: var(--text-2); }

.chapters { width: 320px; flex-shrink: 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--bg-2); }
.chapters-head { padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--card); font-size: 14px; font-weight: 500; color: var(--text-2); }
.chapters-list { max-height: 460px; overflow-y: auto; }
.chapter {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 16px; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; color: var(--muted);
}
.chapter:last-child { border-bottom: 0; }
.chapter:hover { background: var(--card); }
.chapter-dot { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line-2); display: grid; place-items: center; flex-shrink: 0; }
.chapter-dot .ico { width: 11px; height: 11px; margin-left: 2px; }
.chapter-title { flex: 1; min-width: 0; font-size: 14px; font-weight: 500; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chapter-time { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.chapter[aria-current="true"] { background: var(--card-2); }
.chapter[aria-current="true"] .chapter-title { color: var(--accent); }
.chapter[aria-current="true"] .chapter-dot { border-color: var(--accent); color: var(--accent); }

.pills { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.pill-btn {
  padding: 9px 22px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent;
  color: var(--text-2); font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; cursor: pointer;
}
.pill-btn:hover { border-color: #555; color: var(--text); }
.pill-btn[aria-pressed="true"] { background: var(--text); color: #0a0a0a; border-color: var(--text); }
.section-slot { margin-top: 24px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.card h3 { font-size: 22px; font-weight: 700; margin-bottom: 14px; }
.card p { color: var(--muted); }
.about-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.points { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.points li { display: flex; gap: 12px; color: var(--muted); }
.points .ico { width: 20px; height: 20px; margin-top: 2px; }
.ico.ok { color: var(--accent); }

.transcript section + section { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line); }
.transcript-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.transcript h3 { font-size: 17px; margin-bottom: 10px; }
.transcript p { line-height: 1.7; }
.time-link { background: var(--card-2); border: 1px solid var(--line-2); color: var(--text-2); border-radius: 999px; padding: 2px 10px; font-size: 12px; cursor: pointer; font-variant-numeric: tabular-nums; }
.time-link:hover { color: var(--accent); border-color: var(--accent); }

.refs { display: grid; gap: 12px; }
.ref { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--card-2); text-decoration: none; color: var(--text-2); }
.ref:hover { border-color: #555; }
.ref-title { font-weight: 500; color: var(--text); }
.ref-cite { font-size: 13px; color: var(--muted); font-style: italic; margin-top: 2px; }
.ref .ico { color: var(--dim); margin-top: 3px; }

.test-block {
  margin-top: 48px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); min-height: 380px;
  border: 1px solid var(--line); border-radius: 18px; overflow: hidden;
  background: linear-gradient(135deg, #161616, #0a0a0a 60%);
}
.test-copy { padding: 40px; display: flex; flex-direction: column; justify-content: center; border-right: 1px solid var(--line); }
.test-copy h2 { font-size: 40px; font-weight: 800; margin-bottom: 12px; }
.accent { color: var(--accent); }
.test-copy p { color: var(--muted); max-width: 440px; }
.name-label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); margin: 8px 0 18px; max-width: 320px; }
.name-input { background: var(--card-2); border: 1px solid var(--line-2); color: var(--text); border-radius: 10px; padding: 10px 12px; font: inherit; }
.name-input:focus { border-color: var(--accent); outline: none; }
.test-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.test-art { display: grid; grid-template-columns: 1.2fr 1fr; grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 2px; background: #000; height: 420px; }
.art-tile { overflow: hidden; background: #000; min-height: 0; }
.art-tile:first-child { grid-row: span 2; }
.art-tile img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1) brightness(.8); }

/* ---------- case screen ---------- */
.case-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; max-width: 1500px; padding-top: 16px; }
.viewer-col { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.viewer-host { position: relative; height: calc(100vh - 150px); min-height: 360px; background: #000; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; touch-action: none; }
.viewer-canvas { display: block; cursor: grab; outline: none; }
.viewer-canvas:active { cursor: grabbing; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.tb-group { display: flex; flex-wrap: wrap; gap: 4px; }
.tb { background: var(--card-2); border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 11px; font-size: 14px; cursor: pointer; min-height: 36px; color: var(--text-2); }
.tb:hover { background: var(--hover); color: var(--text); }
.tb[aria-pressed="true"] { background: var(--text); color: #0a0a0a; border-color: var(--text); }
.views { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 6px; }
.view-btn { background: rgba(21, 21, 21, .9); border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 12px; cursor: pointer; color: var(--text-2); }
.view-btn[aria-pressed="true"] { border-color: var(--text); color: var(--text); }

.panel { display: flex; flex-direction: column; gap: 14px; }
.questions { display: flex; flex-direction: column; gap: 14px; }
.q { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.q h2 { font-size: 18px; font-weight: 600; }
.q-compact { padding: 12px 18px; }
.q-compact .verdict { margin: 0; }
.opts { display: grid; gap: 8px; }
.opt { text-align: left; background: var(--card-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 14px; cursor: pointer; color: var(--text-2); }
.opt:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.opt[aria-pressed="true"] { border-color: var(--text); color: var(--text); background: var(--hover); }
.opt:disabled { cursor: default; opacity: .6; }
.opt.right { border-color: var(--ok); background: rgba(74, 222, 128, .1); color: var(--text); opacity: 1; }
.opt.wrong { border-color: var(--no); background: rgba(248, 113, 113, .1); color: var(--text); opacity: 1; }
.submit-row { display: flex; justify-content: flex-end; margin-top: 12px; }
.verdict { margin: 14px 0 0; font-weight: 600; }
.verdict.ok { color: var(--ok); }
.verdict.no { color: var(--no); }
.explain { margin-top: 12px; padding: 12px 14px; border-left: 3px solid var(--accent); background: var(--card-2); border-radius: 0 10px 10px 0; color: var(--text-2); }
.lecture-link { margin-top: 12px; font-size: 14px; }
.lecture-link .ico { width: 12px; height: 12px; }
textarea { width: 100%; background: var(--card-2); color: var(--text); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; font: inherit; resize: vertical; }
textarea:focus { border-color: var(--accent); outline: none; }

.template { margin: 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.template h3 { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.template-img { display: block; width: 100%; padding: 0; border: 0; background: #fff; border-radius: 8px; overflow: hidden; cursor: zoom-in; }
.template-img img { display: block; width: 100%; height: auto; max-height: 50vh; object-fit: contain; background: #fff; }
.template figcaption { font-size: 12px; color: var(--dim); margin-top: 8px; line-height: 1.4; }
.case-nav { display: flex; justify-content: space-between; gap: 8px; }

/* ---------- results ---------- */
.results { max-width: 820px; }
.results h1 { font-size: 44px; font-weight: 800; margin-top: 8px; }
.results-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 24px; }
.results-bar .name-label { margin: 0; flex: 1 1 220px; }
.result-list { padding: 0; list-style: none; display: grid; gap: 10px; }
.result-list li { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.result-list p { margin: 8px 0 0; }
.result-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tick { font-weight: 700; }
.tick.ok { color: var(--ok); }
.tick.no { color: var(--no); }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .88); display: grid; place-items: center; padding: 16px; z-index: 20; }
.overlay-box { position: relative; width: min(1100px, 100%); margin: 0; }
.overlay-close { position: absolute; top: -42px; right: 0; background: none; border: 0; font-size: 32px; line-height: 1; cursor: pointer; color: var(--text); }
.image-box img { display: block; max-width: 100%; max-height: 80vh; margin: 0 auto; background: #fff; border-radius: 8px; }
.image-box figcaption { color: var(--muted); font-size: 13px; margin-top: 8px; text-align: center; }

/* ---------- narrow screens ---------- */
@media (max-width: 1000px) {
  .lesson-top { flex-direction: column; }
  .chapters { width: 100%; }
  .chapters-list { max-height: 300px; }
  .about-grid { grid-template-columns: minmax(0, 1fr); }
  .test-block { grid-template-columns: minmax(0, 1fr); }
  .test-copy { border-right: 0; border-bottom: 1px solid var(--line); padding: 28px 24px; }
  .test-art { height: 220px; }
}
@media (max-width: 900px) {
  .case-grid { grid-template-columns: minmax(0, 1fr); padding-top: 0; }
  .case-grid > * { min-width: 0; }
  /* Keep the image pinned under the top bar while the template and questions scroll beneath it. */
  .viewer-col { top: 52px; z-index: 2; background: var(--bg); margin: 0 -16px; padding: 8px 16px; }
  .viewer-host { height: 40vh; height: 40svh; min-height: 230px; }
  .toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .toolbar::-webkit-scrollbar { display: none; }
  .tb-group { flex-wrap: nowrap; }
  .tb { padding: 6px 9px; font-size: 13px; white-space: nowrap; min-height: 34px; }
  .template-img img { max-height: 36vh; }
}
@media (max-width: 640px) {
  .page { padding: 16px; }
  .topbar { height: 52px; padding: 0 12px; }
  .topbar .badge { display: none; }
  .topbar .sep { display: none; }
  .lesson-main h1 { font-size: 24px; margin-top: 18px; }
  .card { padding: 18px; }
  .test-copy h2 { font-size: 32px; }
  .pill-btn { padding: 8px 16px; }
}
@media print {
  .topbar, .results-bar, .test-block { display: none; }
  body { background: #fff; color: #000; }
}
