:root {
  /* Dark by default. */
  --bg: #0f1312;
  --surface: #161b19;
  --surface-2: #1d2421;
  --side: #121715;
  --ink: #e8ece9;
  --ink-2: #b4bdb8;
  --ink-3: #87918c;
  --line: #262e2a;
  --line-2: #34403b;
  --accent: #4fb596;
  --accent-ink: #0b1310;
  --accent-soft: #19302a;
  --video: #f0825c;
  --video-soft: #2c1d17;
  --warn: #e8b34f;
  --warn-soft: #2a2416;
  --note-soft: #18212e;
  --note: #8fb2e8;
  --good: #5cc98a;
  --bad: #f07a7a;
  --danger: #c64545;
  --code-bg: #131816;
  --mark: color-mix(in srgb, #ffd84d 30%, transparent);
  --mark-ink: #e0b440;
  --ask-ink: #7fa6e8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 6px 20px rgba(0, 0, 0, .28);
  --radius: 12px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --serif: 'Source Serif 4', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #fbfaf7; --surface: #ffffff; --surface-2: #f3f1ec; --side: #fbfaf7; --ink: #1b2320; --ink-2: #4a544f; --ink-3: #7a837e;
  --line: #e4e0d8; --line-2: #d6d1c6; --accent: #1f6f5c; --accent-ink: #ffffff; --accent-soft: #e3f0eb;
  --video: #b4441f; --video-soft: #fbeee8; --warn: #9a5b00; --warn-soft: #fdf3e1; --note-soft: #eef2f8; --note: #2d5a9a;
  --good: #1f7a3f; --bad: #b42323; --danger: #b42323; --code-bg: #f6f5f1; --mark: color-mix(in srgb, #ffd84d 55%, transparent); --mark-ink: #a67c00; --ask-ink: #3a6cc0;
  --shadow: 0 1px 2px rgba(20, 30, 25, .06), 0 4px 16px rgba(20, 30, 25, .05); color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.65 var(--sans); }
a { color: var(--accent); text-underline-offset: 2px; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; overflow-wrap: anywhere; }
pre code { overflow-wrap: normal; }
pre { margin: 0; overflow-x: auto; }
pre code { background: none; padding: 0; font-size: 13.5px; line-height: 1.6; }
pre code.hljs { background: transparent; padding: 0; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- buttons, chips ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); background: var(--surface); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 500; font-size: 14px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.07); border-color: var(--accent); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.chip-video { background: var(--video-soft); color: var(--video); }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 10px 20px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.topbar .crumbs { color: var(--ink-3); font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .crumbs a { color: var(--ink-2); text-decoration: none; }
.topbar .spacer { flex: 1; }
.xp { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); flex-shrink: 0; white-space: nowrap; }
.xp-level { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink); }
.xp-level b { background: var(--accent); color: var(--accent-ink); border-radius: 6px; padding: 0 6px; font-size: 12px; }
.xp-bar { width: 90px; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.xp-bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.streak { display: inline-flex; align-items: center; gap: 4px; color: var(--warn); font-weight: 600; }
.menu-toggle { display: none; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: calc(100vh - 53px); }
.sidebar { border-right: 1px solid var(--line); padding: 14px 14px 40px; position: sticky; top: 53px; height: calc(100vh - 53px); overflow-y: auto; background: var(--side); }
.main { padding: 36px 40px 100px; min-width: 0; }
.prose { max-width: 740px; margin: 0 auto; }

.side-course { display: block; padding: 4px 8px 14px; text-decoration: none; color: var(--ink); }
.side-course strong { display: block; font-size: 15px; line-height: 1.35; }
.side-course .bar { height: 5px; background: var(--surface-2); border-radius: 9px; margin-top: 10px; overflow: hidden; }
.side-course .bar span { display: block; height: 100%; background: var(--accent); }
.side-section { margin-top: 6px; }
.side-section > button { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; background: none; border: 0; padding: 8px; cursor: pointer; font-weight: 600; font-size: 13.5px; text-align: left; border-radius: 8px; color: var(--ink); }
.side-part { display: flex; align-items: flex-start; gap: 6px; min-width: 0; }
.side-part .chev { display: inline-grid; place-items: center; flex-shrink: 0; color: var(--ink-3); margin-top: 2px; transform: rotate(90deg); transition: transform .15s; }
.side-section.collapsed .side-part .chev { transform: none; }
/* the outline's own tools: rename, fold every part, hide it */
.side-tools { display: flex; align-items: center; gap: 2px; padding: 0 0 6px 8px; }
.side-tools-label { flex: 1; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); }
.side-icon { padding: 5px; color: var(--ink-3); line-height: 0; }
.side-icon:hover, .side-icon:focus-visible { color: var(--ink); }
.side-parts-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 2px 8px; font-size: 12px; color: var(--ink-3); }
.side-fold-all { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; color: var(--ink-3); font-size: 12px; font-weight: 500; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.side-fold-all svg { width: 14px; height: 14px; }
.side-fold-all:hover, .side-fold-all:focus-visible { background: var(--surface-2); color: var(--ink); }
.side-rail { display: none; }
.rail-progress { font: 600 11px var(--mono); color: var(--accent); }
@media (min-width: 901px) {
  .layout { transition: grid-template-columns .2s ease; }
  .layout.side-collapsed { grid-template-columns: 56px minmax(0, 1fr); }
  .layout.side-collapsed .sidebar { padding: 12px 8px; overflow: hidden; }
  .layout.side-collapsed .side-full { display: none; }
  .layout.side-collapsed .side-rail { display: flex; flex-direction: column; align-items: center; gap: 10px; }
}
.side-section > button:hover { background: var(--surface-2); }
.side-section > button .count { font-weight: 500; color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.side-section ol { list-style: none; margin: 0 0 6px; padding: 0; }
.side-section.collapsed ol { display: none; }
.side-lesson { display: grid; grid-template-columns: 22px 1fr auto; align-items: start; gap: 6px; padding: 6px 8px; border-radius: 8px; text-decoration: none; color: var(--ink-2); font-size: 13.5px; line-height: 1.4; }
.side-lesson:hover { background: var(--surface-2); color: var(--ink); }
.side-lesson.active { background: var(--accent-soft); color: var(--ink); font-weight: 500; }
.side-lesson.pending { opacity: .5; pointer-events: none; }
.side-lesson .dot { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line-2); display: grid; place-items: center; font-size: 10px; color: var(--ink-3); margin-top: 1px; }
.side-lesson.done .dot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.side-lesson .mins { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; margin-top: 2px; }
.side-quiz { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 36px; font-size: 13px; color: var(--ink-3); text-decoration: none; border-radius: 8px; }
.side-quiz:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- home ---------- */
.home { max-width: 1080px; margin: 0 auto; padding: 56px 24px 100px; }
.hero h1 { font-family: var(--serif); font-size: clamp(32px, 5vw, 48px); font-weight: 600; letter-spacing: -.02em; max-width: 760px; }
.hero p { color: var(--ink-2); font-size: 18px; max-width: 680px; margin: 14px 0 0; }
.generator { margin-top: 32px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; box-shadow: var(--shadow); }
.generator label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.generator .hint { font-weight: 400; color: var(--ink-3); font-size: 13px; }
.field { margin-bottom: 16px; }
.signin { max-width: 460px; margin: 10vh auto 0; }
.signin h1 { font-family: var(--serif); font-size: 30px; font-weight: 600; margin-bottom: 8px; }
.signin p { margin: 0 0 16px; }
textarea, input[type=text], input[type=password], select { width: 100%; font: inherit; font-size: 15px; color: var(--ink); background: var(--bg); border: 1px solid var(--line-2); border-radius: 9px; padding: 10px 12px; }
textarea:focus, input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; }
.segmented button { border: 0; background: none; padding: 6px 14px; border-radius: 7px; cursor: pointer; font-size: 14px; color: var(--ink-2); }
.segmented button:disabled { opacity: .45; cursor: not-allowed; }
.segmented .seg-hint { display: block; font-size: 11px; color: var(--ink-3); font-weight: 400; line-height: 1.2; }
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 500; }
.checkline { display: flex !important; gap: 10px; align-items: flex-start; font-weight: 500 !important; margin: 4px 0 14px !important; cursor: pointer; }
.checkline input { width: 17px; height: 17px; margin-top: 3px; accent-color: var(--accent); flex-shrink: 0; }
details.advanced { margin: 4px 0 18px; }
details.advanced summary { cursor: pointer; color: var(--ink-2); font-size: 14px; }
details.advanced[open] summary { margin-bottom: 14px; }
.form-error { color: var(--bad); font-size: 14px; margin-top: 10px; }
.pipeline { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; font-size: 13px; color: var(--ink-3); align-items: center; }
.pipeline .chip { font-size: 12px; }

.library h2 { font-size: 20px; margin: 0; }
.library-head { display: flex; align-items: baseline; gap: 10px; margin: 56px 0 14px; }
.library-head .spacer, .playlist-head .spacer { flex: 1; }
/* playlist folders */
.playlist { margin: 0 0 18px; border: 1px solid var(--line); border-radius: 16px; background: color-mix(in srgb, var(--surface) 55%, transparent); padding: 6px 14px 16px; transition: border-color .15s, background .15s; }
.playlist.loose { border-style: dashed; background: none; }
.playlist.drop { border-color: var(--accent); background: var(--accent-soft); }
.playlist-head { display: flex; align-items: center; gap: 8px; min-height: 46px; flex-wrap: wrap; }
.playlist-head.editing { gap: 8px; padding: 6px 0; }
.playlist-head .btn span { margin-left: 2px; }
.playlist-toggle { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--ink-3); padding: 6px 4px; border-radius: 8px; cursor: pointer; }
.playlist-toggle:hover, .playlist-toggle:focus-visible { color: var(--ink); background: var(--surface-2); }
.playlist-toggle .chev { display: inline-grid; transform: rotate(90deg); transition: transform .15s; }
.playlist.folded .playlist-toggle .chev { transform: none; }
.playlist-icon { display: inline-grid; color: var(--accent); }
.playlist-name { font-size: 16.5px; font-weight: 650; min-width: 0; overflow-wrap: anywhere; }
.playlist-count { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.playlist-input { flex: 1; min-width: 180px; max-width: 420px; font-weight: 600; padding: 7px 10px !important; }
.playlist > .cards { margin-top: 6px; }
.playlist.folded > .cards, .playlist.folded > .playlist-empty { display: none; }
.playlist-empty { padding: 16px; text-align: center; color: var(--ink-3); font-size: 14px; border: 1px dashed var(--line-2); border-radius: 12px; margin-top: 6px; }
.course-card.dragging { opacity: .45; }
.card-playlist { padding: 0 12px 4px; }
.playlist-picker { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.playlist-picker .playlist-icon svg { width: 15px; height: 15px; }
select.playlist-select { width: auto; max-width: 100%; font-size: 13px; padding: 4px 26px 4px 8px; border-radius: 7px; background-color: var(--surface-2); }
.overview-playlist { display: inline-flex; }
@media (max-width: 520px) { .playlist-head .btn span { display: none; } .playlist { padding: 4px 10px 12px; } }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.course-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; text-decoration: none; color: var(--ink); transition: transform .15s, box-shadow .15s; }
.course-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.course-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--surface-2); display: block; }
.course-card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.course-card h3 { font-size: 16px; }
.course-card .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.course-card .card-main { display: flex; flex-direction: column; flex: 1; color: inherit; text-decoration: none; }
.card-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 0 10px 10px; }
.card-actions .spacer { flex: 1; }
.chip-saved { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); border-color: var(--bad); }
.btn-danger-ghost { border-color: transparent; background: transparent; color: var(--bad); }
.btn-danger-ghost:hover { background: color-mix(in srgb, var(--bad) 10%, transparent); border-color: transparent; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.copy-panel { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin: 22px 0 6px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.copy-panel .copy-text { display: grid; gap: 3px; flex: 1; min-width: 240px; }
.copy-panel .copy-text code { overflow-wrap: anywhere; }
.copy-panel .copy-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { padding: 40px; text-align: center; color: var(--ink-3); border: 1px dashed var(--line-2); border-radius: 14px; }

/* ---------- course overview ---------- */
.overview h1 { font-family: var(--serif); font-size: clamp(30px, 4vw, 42px); font-weight: 600; letter-spacing: -.015em; }
.title-row { display: flex; align-items: flex-start; gap: 10px; }
.title-row h1 { flex: 1; min-width: 0; }
.rename-btn { margin-top: 8px; color: var(--ink-3); flex-shrink: 0; }
.rename-btn:hover { color: var(--ink); }
.title-edit { display: grid; gap: 10px; }
.title-edit .title-input { font-family: var(--serif); font-size: clamp(24px, 3.2vw, 34px); font-weight: 600; letter-spacing: -.015em; padding: 8px 12px; }
.title-edit-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 520px) { .rename-btn span { display: none; } }
.stackline { color: var(--ink-3); font-size: 14px; margin: 10px 0 0; }
.overview .tagline { font-size: 19px; color: var(--ink-2); margin: 16px 0 0; }
.overview h2 { font-size: 22px; margin: 44px 0 14px; letter-spacing: -.01em; }
.overview p { margin: 0 0 12px; }
.build-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.build-grid > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.build-grid strong { display: block; margin-bottom: 4px; font-size: 14.5px; }
.build-grid span { color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.path-svg { width: 100%; height: auto; display: block; margin-top: 8px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14.5px; margin: 6px 0 4px; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; background: var(--surface-2); }
table.data td a { text-decoration: none; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.table-wrap table.data { margin: 0; }
.table-wrap table.data tr:last-child td { border-bottom: 0; }
ul.plain { margin: 0; padding-left: 20px; }
ul.plain li { margin: 4px 0; }
.who { display: grid; gap: 10px; }
.who > div { padding-left: 14px; border-left: 3px solid var(--accent); }

/* ---------- generation progress ---------- */
.genpanel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-bottom: 28px; box-shadow: var(--shadow); }
.stepper { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 14px 0; }
.step { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: 13px; color: var(--ink-3); }
.step strong { display: block; color: var(--ink-2); font-size: 13.5px; }
.step.active { background: var(--accent-soft); color: var(--accent); }
.step.active strong { color: var(--ink); }
.step.done strong::after { content: ' ✓'; color: var(--accent); }
.genbar { height: 6px; border-radius: 9px; background: var(--surface-2); overflow: hidden; }
.genbar span { display: block; height: 100%; background: var(--accent); transition: width .5s; }
.download-note { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); }
.download-note-text { font-size: 13.5px; margin-bottom: 8px; color: var(--ink); }
.download-bar { margin: 0; }
.download-bar.indeterminate span { width: 35%; animation: download-slide 1.1s ease-in-out infinite; }
@keyframes download-slide { from { transform: translateX(0); } to { transform: translateX(180%); } }
.log { margin-top: 14px; max-height: 230px; overflow-y: auto; font: 12.5px/1.6 var(--mono); background: var(--code-bg); border-radius: 10px; padding: 10px 12px; color: var(--ink-2); }
.log .warn { color: var(--warn); }
.log .error { color: var(--bad); }
.spinner { width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- lesson ---------- */
.lesson-head .eyebrow { font-size: 13px; color: var(--ink-3); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.lesson-head h1 { font-family: var(--serif); font-size: clamp(30px, 4vw, 40px); font-weight: 600; letter-spacing: -.015em; margin-top: 8px; }
.lesson-head .lead { font-size: 19px; line-height: 1.6; color: var(--ink); margin: 18px 0 0; }
.lesson-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }
.lesson h2 { font-size: 24px; margin: 46px 0 14px; letter-spacing: -.01em; }
.lesson h3 { font-size: 18px; margin: 30px 0 10px; }
.lesson p { margin: 0 0 16px; }
.lesson .block { margin: 18px 0; }
.codeblock { position: relative; background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.codeblock .copy { position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity .15s; }
.codeblock:hover .copy, .codeblock .copy:focus { opacity: 1; }
.caption { font-size: 13px; color: var(--ink-3); margin-top: 8px; }
figure { margin: 24px 0; }
figure.diagram { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
figure.diagram .mermaid { display: flex; justify-content: center; overflow-x: auto; }
figure.diagram svg { max-width: 100%; height: auto; }
figcaption { font-size: 13.5px; color: var(--ink-3); margin-top: 10px; text-align: center; }

/* segments strip */
.segments { margin: 28px 0 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.segments-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.segments-head strong { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.timeline { position: relative; height: 10px; background: var(--surface-2); border-radius: 99px; margin: 12px 0 10px; }
.timeline span { position: absolute; top: 0; bottom: 0; background: var(--video); border-radius: 99px; min-width: 4px; cursor: pointer; }
.segment-list { display: flex; flex-wrap: wrap; gap: 8px; }
.segment-list button { border: 1px solid var(--line); background: var(--bg); border-radius: 9px; padding: 6px 10px; cursor: pointer; font-size: 13px; text-align: left; display: flex; gap: 8px; align-items: center; max-width: 100%; }
.segment-list button:hover { border-color: var(--video); }
.segment-list .time { font-family: var(--mono); color: var(--video); font-size: 12.5px; white-space: nowrap; }

/* screenshots from the video */
.segments { scroll-margin-top: 70px; }
.shot { margin: 22px 0; }
.shot-image { position: relative; display: block; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #000; cursor: zoom-in; cursor: pointer; }
.shot-image img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: contain; }
.shot-time { position: absolute; left: 10px; bottom: 10px; display: inline-flex; align-items: center; gap: 4px; background: rgba(0, 0, 0, .75); color: #fff; font: 600 12.5px var(--mono); padding: 4px 9px 4px 6px; border-radius: 999px; }
.shot-hover { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .45); color: #fff; font-weight: 600; font-size: 15px; opacity: 0; transition: opacity .15s; }
.shot-image:hover .shot-hover, .shot-image:focus-visible .shot-hover { opacity: 1; }
.shot figcaption { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 10px; text-align: left; font-size: 14px; color: var(--ink-2); }
.shot-caption { flex: 1 1 100%; order: 2; }
.shot figcaption .chip { order: 1; }
.shot-source { order: 1; font-size: 12.5px; color: var(--ink-3); font-family: var(--mono); }
.shot-actions { order: 3; display: flex; gap: 6px; }
.frame-status { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); background: rgba(0, 0, 0, .78); color: #fff; font-size: 13px; padding: 6px 12px; border-radius: 999px; pointer-events: none; white-space: nowrap; }
.modal-back.lightbox { background: rgba(8, 10, 9, .9); z-index: 80; }
.lightbox-body { margin: 0; width: min(1280px, 100%); }
.lightbox-body { display: flex; flex-direction: column; align-items: center; }
.lightbox-body img { max-width: 100%; max-height: calc(100vh - 190px); width: auto; height: auto; display: block; border-radius: 10px; }
.lightbox-body figcaption { width: 100%; }
.lightbox-body figcaption { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; color: #eee; text-align: left; margin-top: 12px; font-size: 14px; }

/* narrated lessons */
.part { margin: 34px 0 10px; padding-top: 18px; border-top: 1px solid var(--line); scroll-margin-top: 80px; }
.part-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.part-label { font: 600 12.5px var(--mono); color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 6px; }
.part-time { font-family: var(--mono); color: var(--video); }
.part h3 { font-size: 21px; margin: 10px 0 10px; }
.part-terms { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 14px; }
.term-chip { border: 1px dashed var(--accent); background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 10px; font-size: 12.5px; cursor: pointer; }
.term-chip:hover { border-style: solid; }
.in-short { margin: 20px 0 6px; padding: 12px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.in-short strong { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.in-short ul { margin: 6px 0 0; padding-left: 20px; font-size: 15px; }
.code-notes { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 10px 0 0; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; font-size: 14.5px; }
.code-notes dt { font: 600 12px var(--mono); color: var(--accent); padding-top: 3px; white-space: nowrap; }
.code-notes dd { margin: 0; color: var(--ink-2); }
.term { text-decoration: underline dotted var(--accent); text-decoration-thickness: 1.5px; text-underline-offset: 3px; cursor: help; }
code.term { text-decoration-color: var(--accent); }
.term:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.term-pop { position: absolute; z-index: 90; background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 12px 14px; font-size: 14px; }
.term-pop p { margin: 6px 0; color: var(--ink-2); }
.term-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.term-analogy { font-size: 13.5px; }
.vocab { margin-top: 30px; }
.vocab-list { display: grid; gap: 8px; }
.vocab-card { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); scroll-margin-top: 90px; }
.vocab-card.flash { animation: flash 1.6s ease-out; }
.vocab-card summary { cursor: pointer; padding: 10px 14px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; list-style: none; }
.vocab-card summary::-webkit-details-marker { display: none; }
.vocab-card summary::before { content: '+'; font: 600 14px var(--mono); color: var(--ink-3); width: 12px; }
.vocab-card[open] summary::before { content: '−'; }
.vocab-term { font-weight: 650; }
.vocab-def { flex: 1 1 100%; color: var(--ink-2); font-size: 14.5px; padding-left: 22px; }
.vocab-body { padding: 0 14px 12px 36px; font-size: 14.5px; color: var(--ink-2); }
.vocab-body p { margin: 0 0 8px; }
.vocab-body b { color: var(--ink); }
.vocab-example { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 6px 0 8px; font-size: 13px; }
.prereqs { margin: 0 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--note-soft); padding: 10px 14px; }
.prereqs summary { cursor: pointer; font-weight: 600; color: var(--note); }
.prereq { margin-top: 10px; }
.prereq p { margin: 2px 0 0; font-size: 14.5px; color: var(--ink-2); }
.glossary-letter h2 { font-family: var(--serif); font-size: 26px; margin: 30px 0 10px; color: var(--accent); }
.side-glossary { display: block; padding: 6px 8px; margin: -6px 0 6px; font-size: 13px; color: var(--accent); text-decoration: none; border-radius: 8px; }
.side-glossary:hover { background: var(--surface-2); }

.point { display: grid; grid-template-columns: 62px 1fr; gap: 4px 12px; margin: 14px 0; }
.point-time { justify-self: start; align-self: start; margin-top: 3px; }
.point-body p { margin: 2px 0 0; }
.point-title { display: block; font-size: 16px; }
.part-coverage { font-size: 12.5px; color: var(--ink-3); margin: -4px 0 10px; }
@media (max-width: 520px) { .point { grid-template-columns: 1fr; } }

/* selection tools */
.sel-toolbar { position: absolute; z-index: 85; display: flex; gap: 2px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.sel-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--ink); padding: 7px 10px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.sel-btn:hover, .sel-btn:focus-visible { background: var(--line-2); }
mark.bm { background: none; color: inherit; cursor: pointer; border-radius: 3px; }
mark.bm-highlight { background: var(--mark); }
mark.bm-ask { box-shadow: inset 0 -2px 0 #4a7fd6; background: color-mix(in srgb, #4a7fd6 10%, transparent); }
mark.bm-lookup { box-shadow: inset 0 -2px 0 var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
mark.bm-google { box-shadow: inset 0 -2px 0 var(--ink-3); }
mark.bm-flash { animation: bmflash 1.6s ease-out; }
@keyframes bmflash { 0%, 40% { background: color-mix(in srgb, var(--video) 35%, transparent); } }
.lookup-card { position: absolute; z-index: 88; width: min(400px, calc(100vw - 16px)); max-height: min(70vh, 560px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.2); padding: 12px 14px; font-size: 14.5px; }
.lookup-card.centered { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.lookup-head { display: flex; justify-content: space-between; align-items: center; }
.lookup-head strong { display: inline-flex; gap: 6px; align-items: center; }
.lookup-quote { margin: 8px 0; padding: 6px 10px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 8px 8px 0; color: var(--ink-2); font-size: 13.5px; }
.lookup-card h4 { margin: 12px 0 6px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.lookup-word { font-size: 18px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.lookup-senses { margin: 6px 0; padding-left: 20px; }
.lookup-senses li { margin: 4px 0; }
.lookup-context { background: var(--accent-soft); padding: 8px 10px; border-radius: 8px; }
.lookup-hindi { border-top: 1px solid var(--line); margin-top: 10px; }
.hindi { font-family: 'Noto Sans Devanagari', var(--sans); font-size: 17px; line-height: 1.7; }
.bm-item-sub.hindi { font-size: 13.5px; }
.lookup-terms { padding-left: 18px; margin: 4px 0; }
.saved-note { margin: 8px 0 0; }
.bm-menu { position: absolute; z-index: 87; background: var(--surface); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 4px; min-width: 240px; }
.bm-menu-row { display: flex; align-items: center; }
.bm-menu-open { flex: 1; display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: left; font-size: 14px; }
.bm-menu-open:hover { background: var(--surface-2); }
.bm-panel { position: fixed; top: 53px; right: 0; bottom: 0; width: min(420px, 100vw); z-index: 60; background: var(--surface); border-left: 1px solid var(--line-2); box-shadow: -8px 0 30px rgba(0,0,0,.12); display: flex; flex-direction: column; }
.bm-filters { display: flex; flex-direction: column; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.bm-kinds { flex-wrap: wrap; }
.bm-kinds button { padding: 5px 9px; font-size: 12.5px; }
.bm-list { flex: 1; overflow-y: auto; padding: 10px 12px; display: grid; gap: 8px; align-content: start; }
.bm-item { display: flex; align-items: flex-start; gap: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.bm-item-open { flex: 1; display: grid; gap: 3px; text-align: left; border: 0; background: none; padding: 10px 12px; cursor: pointer; min-width: 0; }
.bm-item-open:hover { background: var(--surface-2); border-radius: 10px; }
.bm-item-kind { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.bm-item-highlight .bm-item-kind { color: var(--mark-ink); }
.bm-item-ask .bm-item-kind { color: var(--ask-ink); }
.bm-item-lookup .bm-item-kind { color: var(--accent); }
.bm-item-text { font-size: 14px; color: var(--ink); overflow-wrap: anywhere; }
.bm-item-sub { font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.bm-item-meta { font-size: 12px; color: var(--ink-3); }
.tutor-quote { display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px 0; border-top: 1px solid var(--line); }
.tutor-quote blockquote { flex: 1; margin: 0; font-size: 13px; color: var(--ink-2); border-left: 3px solid #4a7fd6; padding-left: 8px; max-height: 72px; overflow-y: auto; }
.tutor-quote .small { white-space: nowrap; padding-top: 2px; }
.msg-quote { margin: 0 0 6px; padding-left: 8px; border-left: 3px solid color-mix(in srgb, var(--accent-ink) 60%, transparent); font-size: 13px; opacity: .9; }
@media (max-width: 520px) { .sel-btn span { display: none; } .sel-btn { padding: 9px 12px; } }

/* screens from the video */
.screen { margin: 26px 0; scroll-margin-top: 80px; border-radius: 14px; transition: box-shadow .3s; }
.screen.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 4px var(--video); } 100% { box-shadow: 0 0 0 0 transparent; } }
.screen-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.screen-label { font: 600 12.5px var(--mono); color: var(--video); background: var(--video-soft); padding: 2px 8px; border-radius: 6px; }
.screen-title { font-weight: 600; flex: 1; min-width: 200px; }
.screen figcaption { display: block; margin-top: 10px; text-align: left; }
.screen-explain { margin: 0 0 8px; color: var(--ink-2); font-size: 15px; }
.screen-points { margin: 0 0 10px; padding-left: 20px; font-size: 14px; color: var(--ink-2); }
.on-screen { margin: 6px 0 10px; }
.on-screen summary { cursor: pointer; font-size: 13.5px; color: var(--ink-2); font-weight: 500; }
.on-screen[open] summary { margin-bottom: 8px; }
.visible-text { white-space: pre-wrap; font: 13px/1.55 var(--mono); background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; color: var(--ink-2); }
.screen .shot-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.screen .shot-source { font-size: 12px; color: var(--ink-3); margin-left: auto; }
.screen-ref { border: 0; background: var(--video-soft); color: var(--video); font: 600 .9em var(--sans); padding: 0 6px; border-radius: 5px; cursor: pointer; }
.screen-ref:hover { text-decoration: underline; }
.timeline .tick { position: absolute; top: -3px; width: 2px; height: 16px; background: var(--ink); opacity: .55; border-radius: 1px; pointer-events: auto; }
.filmstrip-wrap { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.filmstrip-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; color: var(--ink-2); }
.filmstrip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x proximity; }
.film { flex: 0 0 auto; width: 136px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; padding: 0; background: #000; cursor: pointer; scroll-snap-align: start; }
.film:hover { border-color: var(--video); }
.film img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.film span { display: block; background: var(--surface); color: var(--ink-2); font: 500 11.5px var(--mono); padding: 3px 6px; text-align: left; }
.slide-text { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 260px; }
.slide-text p { margin: 0; color: #d6dbd8; font-size: 14px; max-width: 900px; }
.slide-counter { font: 12.5px var(--mono); color: #f0a080; }
.slide-nav { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.lightbox-body figcaption { align-items: flex-start; }

/* other video sources */
.video-ref .frame video { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; }
.page-video { position: absolute; inset: 0; display: grid; place-content: center; gap: 10px; text-align: center; color: #eee; padding: 16px; }
.no-thumb { width: 100%; height: 100%; min-height: 112px; background: linear-gradient(135deg, #1d2a26, #2f4a42); }
.card-thumb { aspect-ratio: 16 / 9; height: auto; }

/* video block */
.video-ref { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.video-ref .frame { position: relative; aspect-ratio: 16 / 9; background: #000; }
.video-ref .frame img { width: 100%; height: 100%; object-fit: cover; opacity: .82; display: block; }
.video-ref .frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-ref .play { position: absolute; inset: 0; display: grid; place-items: center; background: none; border: 0; cursor: pointer; }
.video-ref .play span { display: inline-flex; align-items: center; gap: 8px; background: rgba(0, 0, 0, .72); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; }
.video-ref .play:hover span { background: var(--video); }
.video-ref .bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; flex-wrap: wrap; }
.video-ref .bar .cap { flex: 1; min-width: 200px; font-size: 13.5px; color: var(--ink-2); }
.video-ref .bar .cap b { color: var(--video); font-family: var(--mono); font-weight: 500; font-size: 12.5px; }
.video-ref.compact { display: grid; grid-template-columns: 200px 1fr; align-items: center; }
.video-ref.compact .frame { height: 100%; min-height: 112px; aspect-ratio: auto; }
.video-ref.compact .play span { padding: 6px 12px; font-size: 13px; }
.video-ref.compact .transcript { grid-column: 1 / -1; }
.transcript { border-top: 1px solid var(--line); max-height: 280px; overflow-y: auto; padding: 8px 6px; font-size: 14px; }
.transcript button { display: grid; grid-template-columns: 58px 1fr; gap: 8px; width: 100%; text-align: left; border: 0; background: none; padding: 4px 8px; border-radius: 6px; cursor: pointer; color: var(--ink-2); line-height: 1.5; }
.transcript button:hover { background: var(--surface-2); color: var(--ink); }
.transcript button span:first-child { font-family: var(--mono); font-size: 12px; color: var(--video); padding-top: 2px; }

/* sandbox */
.sandbox { border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; background: var(--surface); }
.sandbox-head { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.sandbox-head .tab { border: 0; background: none; padding: 5px 10px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--ink-3); font-weight: 500; }
.sandbox-head .tab.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.sandbox-head .spacer { flex: 1; }
.sandbox-body { position: relative; }
.sandbox pre { padding: 14px 16px; background: var(--code-bg); }
.sandbox textarea.editor { display: block; width: 100%; min-height: 160px; border: 0; border-radius: 0; resize: vertical; font: 13.5px/1.6 var(--mono); background: var(--code-bg); padding: 14px 16px; tab-size: 4; white-space: pre; overflow-x: auto; }
.sandbox .setup { padding: 14px 16px; font-size: 14px; color: var(--ink-2); }
.output { border-top: 1px solid var(--line); }
.output-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 14px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; }
.output pre { padding: 4px 16px 14px; font: 13px/1.55 var(--mono); white-space: pre-wrap; word-break: break-word; color: var(--ink-2); background: none; }
.output pre .err { color: var(--bad); }
.run-note { font-size: 12.5px; color: var(--ink-3); padding: 0 14px 10px; }

/* bullets, callouts, tables, checks */
.bullets h3 { margin-top: 0; }
.bullets ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.bullets li { padding-left: 16px; border-left: 2px solid var(--line-2); }
.bullets li strong { font-family: var(--mono); font-size: 14px; font-weight: 500; }
.callout { border-radius: 12px; padding: 14px 16px; background: var(--note-soft); border-left: 4px solid var(--note); }
.callout strong.title { display: block; margin-bottom: 4px; color: var(--note); }
.callout.tip { background: var(--accent-soft); border-color: var(--accent); }
.callout.tip strong.title { color: var(--accent); }
.callout.watch { background: var(--warn-soft); border-color: var(--warn); }
.callout.watch strong.title { color: var(--warn); }
.callout p:last-child { margin-bottom: 0; }
.check { border: 1px solid var(--line-2); border-radius: 12px; padding: 16px; background: var(--surface); }
.check .q { font-weight: 600; margin-bottom: 10px; display: flex; gap: 8px; align-items: baseline; }
.options { display: grid; gap: 8px; }
.option > span:last-child { min-width: 0; }
.option { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; cursor: pointer; background: var(--bg); text-align: left; width: 100%; }
.option:hover:not(:disabled) { border-color: var(--accent); }
.option .letter { font-weight: 600; color: var(--ink-3); font-size: 13px; padding-top: 1px; }
.option.correct { border-color: var(--good); background: color-mix(in srgb, var(--good) 10%, var(--bg)); }
.option.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--bg)); }
.option:disabled { cursor: default; }
.explain { margin-top: 12px; font-size: 14.5px; color: var(--ink-2); }
.explain b.good { color: var(--good); }
.explain b.bad { color: var(--bad); }
ol.exercises { padding-left: 22px; }
ol.exercises li { margin: 8px 0; }
.related { display: grid; gap: 6px; }
.lesson-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 54px; padding-top: 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.lesson-foot a.prev { text-decoration: none; color: var(--ink-2); font-size: 14px; }
.lesson-foot a.prev b { display: block; color: var(--ink); }
.cheer { text-align: center; color: var(--ink-3); font-size: 14px; margin-top: 28px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-2); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px; z-index: 60; box-shadow: var(--shadow); animation: pop .25s ease-out; display: flex; gap: 8px; align-items: center; }
@keyframes pop { from { transform: translate(-50%, 12px); opacity: 0; } }

/* ---------- quiz ---------- */
.quiz .qcard { margin: 18px 0; }
.quiz .qcard pre { background: var(--code-bg); padding: 12px 14px; border-radius: 9px; margin: 0 0 12px; border: 1px solid var(--line); }
.score { font-family: var(--serif); font-size: 44px; font-weight: 600; }

/* ---------- tutor ---------- */
.tutor-fab { position: fixed; right: 22px; bottom: 22px; z-index: 40; box-shadow: 0 6px 24px rgba(0,0,0,.18); border-radius: 999px; padding: 11px 18px; }
.tutor { position: fixed; right: 22px; bottom: 22px; width: min(420px, calc(100vw - 32px)); height: min(600px, calc(100vh - 100px)); z-index: 50; background: var(--surface); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.2); display: flex; flex-direction: column; overflow: hidden; }
.tutor-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.tutor-head strong { font-size: 14.5px; }
.tutor-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; font-size: 14.5px; }
.msg { padding: 10px 12px; border-radius: 12px; max-width: 92%; }
.msg p { margin: 0 0 8px; } .msg p:last-child { margin: 0; }
.msg pre { background: var(--code-bg); padding: 10px; border-radius: 8px; margin: 8px 0; }
.msg ul, .msg ol { margin: 4px 0 8px; padding-left: 20px; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); }
.msg.tutor-msg { align-self: flex-start; background: var(--surface-2); }
.ts { border: 0; background: var(--video-soft); color: var(--video); font: 500 12px var(--mono); padding: 1px 6px; border-radius: 5px; cursor: pointer; }
.tutor form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.tutor form textarea { resize: none; height: 44px; font-size: 14px; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.suggest button { border: 1px solid var(--line-2); background: var(--bg); border-radius: 999px; padding: 4px 10px; font-size: 12.5px; cursor: pointer; color: var(--ink-2); }

/* ---------- modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 70; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--line-2); border-radius: 16px; padding: 22px; width: min(520px, 100%); max-height: 90vh; overflow-y: auto; }
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 14px; }
.badge { border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; font-size: 13px; color: var(--ink-3); }
.badge .medal { width: 40px; height: 40px; margin: 0 auto 8px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--ink-3); }
.badge.earned { border-color: var(--accent); color: var(--ink-2); }
.badge.earned .medal { background: var(--accent); color: var(--accent-ink); }
.badge strong { display: block; color: var(--ink); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 53px; bottom: 0; width: min(320px, 86vw); z-index: 35; transform: translateX(-102%); transition: transform .2s; box-shadow: var(--shadow); height: auto; }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .main { padding: 24px 16px 100px; }
  .xp-bar, .xp .xp-text { display: none; }
  .xp { gap: 6px; min-width: 0; }
  .brand { flex-shrink: 0; }
  .stepper { grid-template-columns: repeat(2, 1fr) !important; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .video-ref.compact { grid-template-columns: 120px 1fr; }
  .video-ref.compact .bar .cap { min-width: 0; }
  .topbar { padding: 10px 12px; gap: 10px; }
}
@media (max-width: 520px) {
  .home { padding: 32px 16px 80px; }
  .topbar .crumbs { display: none; }
  .xp-level { font-size: 0; gap: 0; }
  .xp-level b { font-size: 12px; }
  .brand-text { display: none; }
  .xp .btn-label { display: none; }
}

/* Settings: accounts and API keys */
.settings h1 { margin: 8px 0 18px; }
.settings-section { margin: 0 0 34px; }
.settings-section > h2 { margin: 0 0 6px; }
.settings-section > p { margin: 0 0 14px; }
.settings-section code { overflow-wrap: anywhere; }
.settings-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin: 0 0 12px; display: grid; gap: 10px; }
.settings-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.settings-card-head h3 { font-size: 17px; margin: 0 0 2px; }
.settings-card p { margin: 0; }
.settings-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.settings-actions select { width: auto; max-width: 100%; }
.key-fields { display: grid; gap: 12px; }
.key-row { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 4px 16px; align-items: start; }
.key-row label { font-weight: 600; font-size: 14px; grid-row: span 2; padding-top: 2px; }
.key-row .key-current { color: var(--ink-2); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.key-row .key-current code { overflow-wrap: anywhere; }
.key-input { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.key-input input, .key-input select, .key-input textarea { flex: 1; min-width: 200px; }
.key-input textarea { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }
.login-panel { border: 1px dashed var(--line-2); border-radius: 10px; padding: 12px 14px; display: grid; gap: 10px; background: var(--surface-2); }
.device-code { display: flex; align-items: center; gap: 10px; }
.device-code code { font-size: 22px; letter-spacing: .12em; padding: 6px 12px; background: var(--surface); border-radius: 8px; }
.code-form { display: grid; gap: 6px; }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; }
.ok-text { color: var(--good); }
.warn-text { color: var(--bad); }
.topbar-settings span { margin-left: 2px; }
@media (max-width: 640px) {
  .key-row { grid-template-columns: 1fr; }
  .key-row label { grid-row: auto; }
  .topbar-settings span { display: none; }
}
