
/* UI fonts, vendored so the site works offline (SIL OFL): Inter for text, JetBrains Mono for code */
@font-face { font-family: "Inter Variable"; src: url("vendor/fonts/inter-latin-wght-normal.woff2") format("woff2-variations"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Inter Variable"; src: url("vendor/fonts/inter-latin-wght-italic.woff2") format("woff2-variations"); font-weight: 100 900; font-style: italic; font-display: swap; }
@font-face { font-family: "JetBrains Mono Variable"; src: url("vendor/fonts/jetbrains-mono-latin-wght-normal.woff2") format("woff2-variations"); font-weight: 100 800; font-display: swap; }

/* ---------- Theme tokens: white page, one blue family ----------
   Persian blue  = headings, primary actions, "evaluated"
   Cyan (deep)   = sub-headings, "attempted", AI tutor accents
   Pale blue     = surfaces, hover, selection                       */
:root, [data-theme="light"] {
  --font-sans: "Inter Variable", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono Variable", "JetBrains Mono", var(--font-mono);
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --bg-sunk: #f2f6fc;
  --text: #1e293b;
  --text-soft: #5b6b82;
  --border: #dde6f1;
  --accent: #1c39bb;       /* Persian blue */
  --accent-soft: #e9eefc;
  --sub: #0e7490;          /* deep cyan: readable on white */
  --sub-soft: #e4f5f9;
  --ok: #0e7490;
  --ok-soft: #eef3fe;
  --info: #1c39bb;
  --info-soft: #eef2fd;
  --lld: #1c39bb;
  --hld: #1c39bb;
  --ai: #0e7490;
  --dsa: #0e7490;
  --ink: #1e293b;          /* diagram strokes */
  --paper: #ffffff;        /* diagram fill */
  --shadow: 0 1px 2px rgba(15, 35, 95, .05), 0 6px 20px rgba(15, 35, 95, .05);
}
[data-theme="dark"] {
  --bg: #0c1424;
  --bg-elev: #111b30;
  --bg-sunk: #0a1120;
  --text: #e2e8f0;
  --text-soft: #94a3b8;
  --border: #22314d;
  --accent: #8199f5;
  --accent-soft: #1a2552;
  --sub: #5ec8de;
  --sub-soft: #0f2a36;
  --ok: #5ec8de;
  --ok-soft: #121f3d;
  --info: #8199f5;
  --info-soft: #16224a;
  --lld: #8199f5;
  --hld: #8199f5;
  --ai: #5ec8de;
  --dsa: #5ec8de;
  --ink: #cbd5e1;
  --paper: #16213a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15.5px/1.65 var(--font-sans);
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
button { font: inherit; color: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px;
  height: 52px; padding: 0 14px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; font-size: 19px; letter-spacing: .5px; color: var(--text); text-decoration: none; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--text-soft);
}
.icon-btn:hover { background: var(--bg-sunk); color: var(--text); }
[data-theme="light"] .moon, [data-theme="dark"] .sun { display: none; }

.progress { display: flex; align-items: center; gap: 10px; margin-left: auto; min-width: 0; }
.progress-bars { display: grid; gap: 3px; width: clamp(90px, 18vw, 220px); }
.bar { height: 8px; border-radius: 99px; background: var(--bg-sunk); overflow: hidden; }
.bar.thin { height: 4px; }
.fill { display: block; height: 100%; width: 0; border-radius: 99px; transition: width .4s ease; }
.fill.answered { background: var(--sub); }
.fill.evaluated { background: var(--accent); }
.progress-text { font-size: 13px; color: var(--text-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
.practice-toggle { font-size: 13px; color: var(--text-soft); display: flex; gap: 6px; align-items: center; cursor: pointer; white-space: nowrap; }

/* ---------- Layout ---------- */
.layout { display: flex; height: calc(100vh - 52px); }
.sidebar {
  width: 310px; flex: 0 0 310px;
  overflow-y: auto; padding: 12px 10px 40px;
  background: var(--bg-elev); border-right: 1px solid var(--border);
  transition: margin-left .2s ease;
}
body.sidebar-collapsed .sidebar { margin-left: -310px; }
.content { flex: 1; min-width: 0; overflow-y: auto; padding: 28px 36px 80px; } /* full width: no max-width cap */

.filter {
  width: 100%; padding: 7px 10px; margin-bottom: 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 14px;
}

/* ---------- Sidebar groups ---------- */
.track { margin-bottom: 6px; }
.track > summary, .subtrack > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px;
}
.track > summary::-webkit-details-marker, .subtrack > summary::-webkit-details-marker { display: none; }
.track > summary { font-weight: 700; font-size: 13px; letter-spacing: .6px; text-transform: uppercase; }
.track > summary:hover, .subtrack > summary:hover { background: var(--bg-sunk); }
.chev { width: 10px; transition: transform .15s; color: var(--text-soft); flex: none; }
details[open] > summary .chev { transform: rotate(90deg); }
.track-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.count { margin-left: auto; font-size: 12px; font-weight: 500; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.subtrack { margin-left: 10px; }
.subtrack > summary { font-size: 13.5px; font-weight: 600; color: var(--text-soft); }
.items { list-style: none; margin: 2px 0 6px; padding: 0 0 0 14px; }
.items a {
  display: flex; gap: 8px; align-items: baseline;
  padding: 4px 8px; border-radius: 6px;
  color: var(--text); text-decoration: none; font-size: 14px; line-height: 1.35;
}
.items a:hover { background: var(--bg-sunk); }
.items a.active { background: var(--accent-soft); }
.items .num { color: var(--text-soft); font-size: 12px; min-width: 22px; font-variant-numeric: tabular-nums; }
.items .t { flex: 1; }
.status { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--border); flex: none; align-self: center; }
.status.answered { background: var(--sub); border-color: var(--sub); }
.status.evaluated { background: var(--accent); border-color: var(--accent); }
.items .pending { color: var(--text-soft); font-style: italic; }
.empty-note { font-size: 13px; color: var(--text-soft); padding: 2px 8px 8px 28px; }

/* ---------- Content ---------- */
.topic-head { margin-bottom: 20px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--text-soft); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 700; letter-spacing: .4px; color: var(--bg-elev); }
.badge.LLD { background: var(--lld); } .badge.HLD { background: var(--hld); }
.badge.AI { background: var(--ai); } .badge.DSA { background: var(--dsa); }
h1.title { font-size: 30px; line-height: 1.2; margin: 8px 0 6px; }
.concepts { color: var(--text-soft); }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pill { font-size: 12.5px; padding: 2px 9px; border-radius: 99px; background: var(--bg-sunk); color: var(--text-soft); }

.card {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 22px; margin: 18px 0; box-shadow: var(--shadow);
}
.card > h2 { font-size: 15px; margin: 0 0 12px; letter-spacing: .3px; display: flex; align-items: center; gap: 10px; }
.card > h2 .spacer { flex: 1; }
.muted { color: var(--text-soft); }
.small { font-size: 13px; }

.diagram { width: 100%; overflow-x: auto; }
.diagram svg { display: block; width: 100%; height: auto; max-height: 460px; }
.diagram text { font-family: var(--font-sans); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); font-size: 14px;
}
.btn:hover { border-color: var(--text-soft); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg-elev); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: default; }
.save-state { font-size: 13px; color: var(--text-soft); }
.save-state.dirty { color: var(--accent); }
.save-state.ok { color: var(--ok); }
.save-state.err { color: #c0503a; }

.reveal { display: grid; place-items: center; gap: 10px; padding: 24px; border: 1.5px dashed var(--border); border-radius: 10px; color: var(--text-soft); }

.verdict { border-left: 4px solid var(--ok); background: var(--ok-soft); border-radius: 8px; padding: 2px 18px; }
.ask {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--info-soft); border-radius: 8px; padding: 10px 14px; font-size: 14px;
}
.ask code { background: var(--bg-elev); padding: 2px 8px; border-radius: 6px; font-size: 13px; }

textarea.notes {
  width: 100%; min-height: 140px; resize: vertical;
  padding: 12px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
  font: 14px/1.55 var(--font-mono);
}
.doubts { margin-top: 14px; display: grid; gap: 10px; }
.doubt { border-radius: 8px; border: 1px solid var(--border); overflow: hidden; }
.doubt .q { padding: 8px 14px; background: var(--bg-sunk); font-weight: 600; }
.doubt .a { padding: 2px 14px; }
.doubt .a.open { padding: 8px 14px; color: var(--text-soft); font-style: italic; }

.row { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }

/* Toast UI theme blending */
.toastui-editor-defaultUI { border-color: var(--border) !important; border-radius: 8px; }
.toastui-editor-contents { font-size: 15px !important; font-family: inherit !important; }
[data-theme="light"] .toastui-editor-defaultUI .toastui-editor-ww-container,
[data-theme="light"] .toastui-editor-defaultUI-toolbar { background: var(--bg) !important; }
[data-theme="dark"] .toastui-editor-dark.toastui-editor-defaultUI .toastui-editor-ww-container,
[data-theme="dark"] .toastui-editor-dark .toastui-editor-defaultUI-toolbar { background: var(--bg-sunk) !important; }
.toastui-editor-contents p, .toastui-editor-contents li { color: var(--text) !important; }
.toastui-editor-contents h1, .toastui-editor-contents h2, .toastui-editor-contents h3 { color: var(--text) !important; border-bottom-color: var(--border) !important; }
.toastui-editor-contents pre, .toastui-editor-contents code { background: var(--bg-sunk) !important; }
.toastui-editor-contents table th { background: var(--bg-sunk) !important; color: var(--text) !important; }
.toastui-editor-contents table td, .toastui-editor-contents table th { border-color: var(--border) !important; }
.toastui-editor-contents blockquote { border-left-color: var(--accent) !important; }
.toastui-editor-contents blockquote p { color: var(--text-soft) !important; }

/* Home */
.home h1 { font-size: 32px; margin: 0 0 4px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-top: 18px; }
.stat { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.stat .k { font-size: 12px; letter-spacing: .6px; text-transform: uppercase; color: var(--text-soft); font-weight: 700; }
.stat .v { font-size: 28px; font-weight: 750; font-variant-numeric: tabular-nums; }
.stat .bar { margin-top: 8px; }

.dsa-link { font-size: 15px; }

@media (max-width: 780px) {
  .sidebar { position: fixed; top: 52px; bottom: 0; left: 0; z-index: 5; box-shadow: var(--shadow); }
  .content { padding: 20px 16px 60px; }
  .practice-toggle { display: none; }
  .progress-text { display: none; }
}
@media (max-width: 780px) { .diagram svg { min-width: 620px; } }

/* ---------- AI: top-bar chip, settings dialog, tutor chat ---------- */
.btn.small { padding: 3px 10px; font-size: 13px; }
.err { color: #c0503a; }
code { font-family: var(--font-mono); font-size: .92em; }

.ai-chip {
  display: inline-flex; align-items: center; gap: 7px; max-width: 260px;
  height: 30px; padding: 0 12px; border-radius: 99px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); color: var(--text-soft); font-size: 13px;
}
.ai-chip:hover { color: var(--text); border-color: var(--text-soft); }
.ai-chip #aiLabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-soft); flex: none; }
.ai-chip[data-state="on"] .ai-dot { background: var(--ok); }
.ai-chip[data-state="off"] { color: var(--accent); border-color: var(--accent-soft); }
.ai-chip[data-state="off"] .ai-dot { background: var(--accent); }

.ai-dialog {
  width: min(520px, calc(100vw - 32px)); padding: 22px 24px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow);
}
.ai-dialog::backdrop { background: rgba(30, 25, 18, .35); }
.ai-dialog h2 { margin: 0 0 6px; font-size: 18px; }
.field { display: grid; gap: 5px; margin: 14px 0; }
.field .lbl { font-size: 13px; font-weight: 650; display: flex; justify-content: space-between; }
.field .lbl a { font-weight: 400; }
.field input {
  width: 100%; padding: 8px 11px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: 14px var(--font-mono);
}
.field input:focus, .chat-input textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.hint { font-size: 12.5px; color: var(--text-soft); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); font-size: 13.5px;
}
.seg-btn.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.ok-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.dlg-actions { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.dlg-actions .spacer { flex: 1; }
.dlg-actions .save-state { max-width: 60%; }

.chat { display: grid; gap: 12px; max-height: 560px; overflow-y: auto; padding: 2px 2px 4px; }
.chat-empty { color: var(--text-soft); background: var(--bg-sunk); border-radius: 10px; padding: 12px 16px; font-size: 14px; }
.msg { display: grid; gap: 3px; }
.msg .who { font-size: 11.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: var(--text-soft); }
.msg.user { justify-items: end; }
.msg.user .body {
  max-width: 85%; padding: 8px 13px; border-radius: 12px 12px 3px 12px;
  background: var(--accent-soft); white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.assistant .body { border-left: 3px solid var(--ai); padding: 0 0 0 14px; min-height: 22px; }
.msg.assistant .body.streaming { white-space: pre-wrap; padding-top: 4px; padding-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 8px; }
.chip {
  font-size: 12.5px; padding: 4px 11px; border-radius: 99px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); color: var(--text-soft);
}
.chip:hover { color: var(--text); border-color: var(--accent); }
.chat-input { display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea {
  flex: 1; min-height: 44px; max-height: 200px; resize: vertical; padding: 10px 12px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit;
}
.chat-input .btn { height: 44px; }
.cli-hint { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.cli-hint code, .doubts code, .hint code { background: var(--bg-sunk); padding: 1px 6px; border-radius: 5px; }

.thinking { display: flex; align-items: center; gap: 5px; color: var(--text-soft); font-size: 14px; padding: 6px 0; }
.thinking i { width: 7px; height: 7px; border-radius: 50%; background: var(--ai); opacity: .35; animation: kb-blink 1.2s infinite; }
.thinking i:nth-child(2) { animation-delay: .2s; } .thinking i:nth-child(3) { animation-delay: .4s; }
.thinking span { margin-left: 6px; }
@keyframes kb-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .thinking i { animation: none; opacity: .7; } }
@media (max-width: 780px) {
  .ai-chip #aiLabel { display: none; }
  .ai-chip { padding: 0 10px; }
  .msg.user .body { max-width: 100%; }
}
.card > h2 { flex-wrap: wrap; row-gap: 6px; }
.no-server-msg { display: none; background: var(--accent-soft); border-radius: 10px; padding: 4px 16px; margin: 10px 0; }
.ai-dialog.no-server .no-server-msg { display: block; }
.ai-dialog.no-server .field, .ai-dialog.no-server #aiSave, .ai-dialog.no-server #aiOllamaHelp, .ai-dialog.no-server > p.muted { display: none; }

/* Markdown-mode answer editor: themed code blocks, comfortable monospace */
.toastui-editor-md-container .toastui-editor-md-code-block-line-background,
.toastui-editor-md-container .toastui-editor-md-code-block-line-background.start,
.toastui-editor-md-container .toastui-editor-md-code-block-line-background.end { background: var(--bg-sunk) !important; }
.toastui-editor-md-container .toastui-editor-md-code-block,
.toastui-editor-md-container .toastui-editor-md-code { font-family: var(--font-mono) !important; font-size: 13.5px !important; color: var(--text) !important; }
.toastui-editor-md-container .toastui-editor-md-delimiter,
.toastui-editor-md-container .toastui-editor-md-code-block .toastui-editor-md-meta { color: var(--text-soft) !important; }
[data-theme="light"] .toastui-editor-defaultUI .toastui-editor-md-container,
[data-theme="light"] .toastui-editor-defaultUI .toastui-editor-md-preview { background: var(--bg) !important; }
[data-theme="dark"] .toastui-editor-dark.toastui-editor-defaultUI .toastui-editor-md-container,
[data-theme="dark"] .toastui-editor-dark .toastui-editor-md-preview { background: var(--bg-sunk) !important; }
.toastui-editor-defaultUI .toastui-editor-mode-switch { background: transparent !important; border-top-color: var(--border) !important; }
[data-theme="dark"] .toastui-editor-md-container .toastui-editor-md-code-block-line-background,
[data-theme="dark"] .toastui-editor-md-container .toastui-editor-md-code-block-line-background.start,
[data-theme="dark"] .toastui-editor-md-container .toastui-editor-md-code-block-line-background.end { background: var(--paper) !important; }
#aiModelHint .chip { margin: 2px 2px 0 0; font-family: var(--font-mono); }
[hidden] { display: none !important; }

/* =====================================================================
   Blue theme: white page, Persian-blue headings, cyan sub-headings.
   Everything below only restyles. Layout and behaviour are unchanged.
   ===================================================================== */
:root, [data-theme="light"] { --surface: #f7f9fd; }
[data-theme="dark"] { --surface: #0e1729; }

a { color: var(--accent); text-underline-offset: 2px; }
::selection { background: var(--accent-soft); }

/* Top bar */
.topbar { background: var(--bg-elev); border-bottom: 1px solid var(--border); box-shadow: 0 1px 0 rgba(15,35,95,.02); }
.brand { color: var(--accent); font-weight: 800; font-size: 20px; letter-spacing: -.01em; }
.brand::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 3px; border-radius: 50%; background: var(--sub); vertical-align: 2px; }
.practice-toggle input { accent-color: var(--accent); }

/* Sidebar */
.sidebar { background: var(--surface); border-right: 1px solid var(--border); }
.filter { background: var(--bg-elev); border-radius: 10px; padding: 8px 12px; }
.filter:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.track > summary { color: var(--accent); font-size: 12px; letter-spacing: .08em; font-weight: 750; }
.track-dot { background: var(--accent) !important; }
.subtrack > summary { color: var(--sub); font-weight: 650; }
.track > summary:hover, .subtrack > summary:hover, .items a:hover { background: var(--accent-soft); }
.items a { border-radius: 8px; }
.items a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.items a.active .num { color: var(--accent); }

/* Topic header */
.badge { background: var(--accent) !important; color: #fff; letter-spacing: .06em; padding: 2px 10px; }
[data-theme="dark"] .badge { color: var(--bg); }
h1.title { color: var(--accent); font-size: 34px; font-weight: 800; letter-spacing: -.022em; line-height: 1.15; margin: 10px 0 8px; }
.pill { background: var(--sub-soft); color: var(--sub); font-weight: 550; padding: 3px 11px; }
.home h1 { color: var(--accent); font-weight: 800; letter-spacing: -.02em; }

/* Cards */
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 20px 24px; }
.card > h2 { color: var(--accent); font-size: 17px; font-weight: 750; letter-spacing: -.005em; }
.stat { border-radius: 14px; box-shadow: var(--shadow); }
.stat .k { color: var(--sub); }
.stat .v { color: var(--accent); font-weight: 800; }

/* Buttons and inputs */
.btn { background: var(--bg-elev); border-radius: 9px; font-weight: 550; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { color: #fff; filter: brightness(1.08); }
[data-theme="dark"] .btn.primary, [data-theme="dark"] .btn.primary:hover { color: var(--bg); }
textarea.notes:focus, .chat-input textarea:focus, .field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.seg-btn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.ai-chip[data-state="off"] { color: var(--accent); border-color: var(--accent-soft); }
.ai-chip[data-state="off"] .ai-dot { background: var(--accent); }
.ai-chip[data-state="on"] .ai-dot { background: var(--sub); }
.save-state.dirty { color: var(--sub); }
.save-state.ok { color: var(--accent); }

/* Verdict, hints, chat, doubts */
.verdict { background: var(--ok-soft); border-left: 4px solid var(--accent); border-radius: 10px; }
.ask { background: var(--info-soft); border-radius: 10px; }
.msg .who { color: var(--sub); }
.msg.user .body { background: var(--accent-soft); color: var(--text); }
.msg.assistant .body { border-left-color: var(--sub); }
.thinking i { background: var(--sub); }
.doubt { border-radius: 10px; }
.doubt .q { background: var(--sub-soft); color: var(--sub); }
.reveal { border-color: var(--accent-soft); }

/* Rendered Markdown (write-ups, verdicts, chat) */
.toastui-editor-contents { font-family: var(--font-sans) !important; font-size: 15.5px !important; line-height: 1.7 !important; }
.toastui-editor-contents h1, .toastui-editor-contents h2 { color: var(--accent) !important; font-weight: 750 !important; letter-spacing: -.01em; border-bottom: 1px solid var(--border) !important; padding-bottom: 6px !important; }
.toastui-editor-contents h2 { font-size: 21px !important; margin-top: 28px !important; }
.toastui-editor-contents h3, .toastui-editor-contents h4 { color: var(--sub) !important; font-weight: 700 !important; border: 0 !important; }
.toastui-editor-contents h3 { font-size: 17px !important; }
.toastui-editor-contents strong { color: var(--text) !important; font-weight: 650; }
.toastui-editor-contents a { color: var(--accent) !important; }
.toastui-editor-contents code { font-family: var(--font-mono) !important; color: var(--accent) !important; background: var(--accent-soft) !important; border-radius: 5px; padding: 1px 5px !important; font-size: .88em !important; }
.toastui-editor-contents pre { background: var(--surface) !important; border: 1px solid var(--border); border-radius: 10px; }
.toastui-editor-contents pre code { color: var(--text) !important; background: transparent !important; padding: 0 !important; font-size: 13.5px !important; }
.toastui-editor-contents table th { background: var(--accent-soft) !important; color: var(--accent) !important; }
.toastui-editor-contents blockquote { border-left-color: var(--sub) !important; }
.toastui-editor-contents ul > li::before { background-color: var(--sub) !important; }
.toastui-editor-contents ol > li::before { color: var(--sub) !important; }
.toastui-editor-defaultUI { border-radius: 12px !important; }
.toastui-editor-md-tab-container .tab-item.active { color: var(--accent) !important; }

/* DSA patterns: difficulty chips, pattern pages */
.diff { flex: none; align-self: center; font-size: 10.5px; font-weight: 700; line-height: 1; padding: 3px 6px; border-radius: 5px; letter-spacing: .02em; }
.diff.E { background: var(--sub-soft); color: var(--sub); }
.diff.M { background: var(--accent-soft); color: var(--accent); }
.diff.H { background: var(--accent); color: #fff; }
[data-theme="dark"] .diff.H { color: var(--bg); }
.crumbs .diff { font-size: 11.5px; padding: 3px 8px; }
.crumbs a { color: var(--accent); font-weight: 600; text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.subtrack .pnum { font-size: 11px; color: var(--text-soft); min-width: 18px; font-variant-numeric: tabular-nums; }
.items a.guide-link { color: var(--accent); font-weight: 600; }
.items a.guide-link .num { color: var(--sub); }
.lede { font-size: 17px; color: var(--text-soft); max-width: 75ch; margin: 6px 0 0; line-height: 1.55; }
.guide-card > summary { list-style: none; cursor: pointer; display: grid; gap: 2px; }
.guide-card > summary::-webkit-details-marker { display: none; }
.guide-card > summary h2 { margin: 0; color: var(--accent); font-size: 17px; font-weight: 750; }
.guide-card > summary h2::after { content: " ▸"; color: var(--sub); font-size: 14px; }
.guide-card[open] > summary h2::after { content: " ▾"; }
.guide-card[open] > summary { margin-bottom: 10px; }
.ptable { width: 100%; border-collapse: collapse; }
.ptable tr { border-top: 1px solid var(--border); cursor: pointer; }
.ptable tr:first-child { border-top: 0; }
.ptable tr:hover { background: var(--accent-soft); }
.ptable td { padding: 9px 8px; vertical-align: middle; }
.ptable td.n { width: 44px; color: var(--text-soft); font-size: 13px; font-variant-numeric: tabular-nums; }
.ptable td.t a { color: var(--text); text-decoration: none; font-weight: 550; }
.ptable td.st { width: 24px; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin: 8px 0 30px; }
.pager .btn { text-decoration: none; }

/* Read-first fundamentals and the reference-design gate */
.readfirst .rf-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.readfirst .rf-list li { display: grid; grid-template-columns: minmax(220px, max-content) 1fr; gap: 4px 16px; align-items: baseline; padding: 7px 4px; border-top: 1px solid var(--border); }
.readfirst .rf-list li:first-child { border-top: 0; }
.readfirst .rf-list a { display: inline-flex; gap: 9px; align-items: center; color: var(--accent); font-weight: 600; text-decoration: none; }
.readfirst .rf-list a:hover .rf-t { text-decoration: underline; }
.readfirst .rf-s { color: var(--text-soft); font-size: 13.5px; line-height: 1.45; }
@media (max-width: 780px) { .readfirst .rf-list li { grid-template-columns: 1fr; } }
.gate { border-style: dashed; background: var(--surface); }
.gate .confirm { background: var(--bg-elev); border: 1px solid var(--border); border-left: 4px solid var(--sub); border-radius: 10px; padding: 4px 16px 14px; }
.pill.link { text-decoration: none; background: var(--accent-soft); color: var(--accent); }
.pill.link:hover { text-decoration: underline; }
.track > summary { line-height: 1.3; }
#briefCard .toastui-editor-contents > h2:first-child { margin-top: 0 !important; }

/* Article contents list */
.toc { padding: 14px 18px; }
.toc-title { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--sub); margin-bottom: 6px; }
.toc ol { margin: 0; padding-left: 20px; columns: 2; column-gap: 28px; }
.toc li { break-inside: avoid; margin: 2px 0; }
.toc button { background: none; border: 0; padding: 2px 0; font: inherit; font-size: 14px; color: var(--accent); cursor: pointer; text-align: left; }
.toc button:hover { text-decoration: underline; }
.toastui-editor-contents h2 { scroll-margin-top: 16px; }
@media (max-width: 700px) { .toc ol { columns: 1; } }
.ptable .status { display: inline-block; vertical-align: middle; }

/* ---------- voice ---------- */
.voice-tools { display: inline-flex; gap: 6px; align-items: center; margin-right: 6px; }
.vbtn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border);
  background: transparent; color: var(--text-soft); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; letter-spacing: 0; text-transform: none; }
.vbtn.icon { width: 30px; padding: 0; justify-content: center; }
.vbtn svg, .mic svg, .listen svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.vbtn:hover { border-color: var(--accent); color: var(--accent); }
.vbtn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.vbtn:disabled { opacity: .5; cursor: default; }
.vbtn.dictate { margin-right: 8px; }
.vbtn.on, .mic.on { background: #dc2626; border-color: #dc2626; color: #fff; animation: kbPulse 1.4s ease-in-out infinite; }
.vbtn.busy, .mic.busy { opacity: .7; cursor: progress; }
.mic { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-card, transparent); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.mic svg { width: 20px; height: 20px; }
.mic:hover { border-color: var(--accent); background: var(--accent-soft); }
@keyframes kbPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .45); } 50% { box-shadow: 0 0 0 7px rgba(220, 38, 38, 0); } }
.voice-status { margin-top: 8px; font-size: 13px; color: var(--text-soft); display: flex; align-items: center; gap: 8px; }
.voice-status.live { color: #dc2626; font-weight: 600; }
.voice-status.err { color: var(--danger, #dc2626); }
.voice-status.warn { color: var(--sub); }
.voice-status .dot { width: 8px; height: 8px; border-radius: 50%; background: #dc2626; animation: kbPulse 1.4s ease-in-out infinite; }
.msg .listen { border: 0; background: none; padding: 0 2px; margin-left: 4px; color: var(--text-soft); cursor: pointer; vertical-align: middle; opacity: .55; }
.msg .listen:hover, .msg .listen.on { opacity: 1; color: var(--accent); }
.msg .listen svg { width: 14px; height: 14px; }
.voice-dialog select, .voice-dialog input[type=range] { width: 100%; }
.voice-dialog select { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; }
.voice-dialog .check { display: flex; gap: 8px; align-items: center; margin: 4px 0 8px; font-size: 14px; }
@media (max-width: 700px) { .vbtn span { display: none; } .vbtn { width: 30px; padding: 0; justify-content: center; } }
.voice-dialog .vrow { display: flex; gap: 8px; align-items: center; }
.voice-dialog .vrow select { flex: 1; min-width: 0; }
.voice-dialog .vrow .btn { flex: none; height: 38px; }
.voice-dialog { max-height: 92vh; overflow-y: auto; }
.toc ol.plain { list-style: none; padding-left: 0; }
.badge.LIB { background: var(--sub); color: #fff; }

/* ---------- read-only demo (GitHub Pages) ---------- */
body.demo #aiButton, body.demo #progress { display: none !important; }
.demo-banner { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-soft); min-width: 0; }
.demo-banner a { font-weight: 600; }
.demo-banner .muted-txt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.demo-banner .small-btn { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; font-size: 13px; white-space: nowrap; }
.folder-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border, rgba(127,127,127,.3));
  background: transparent; color: inherit; font: inherit; font-size: 13px; cursor: pointer; max-width: 220px; }
.folder-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-chip:hover { border-color: var(--accent, #1c39bb); }
.folder-dialog pre { background: var(--bg-sunk, rgba(127,127,127,.08)); padding: 10px 12px; border-radius: 8px; overflow-x: auto; font-size: 13px; }
.folder-dialog h3 { margin: 16px 0 4px; font-size: 15px; }
.check-row { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; margin: -4px 0 12px; color: var(--text-soft); }
.check-row input { margin-top: 2px; }
.check-row[hidden] { display: none; }
.web-only { display: none; }
body.web .web-only { display: revert; }
body.web .server-only, body.web .ask, body.web .cli-hint { display: none; }
.demo-card { border-left: 3px solid var(--sub); }
.demo-card pre { background: var(--bg-sunk, rgba(127,127,127,.08)); padding: 12px 14px; border-radius: 8px; overflow-x: auto; font-size: 13px; }
@media (max-width: 700px) { .demo-banner .muted-txt, .demo-banner .gh-link, .folder-chip span { display: none; } .folder-chip { padding: 6px; } }

/* ---------- Google sign-in, sync and KB Pro (website + Android app) ---------- */
.drive-only { display: none; }
.ai-dialog.drive .drive-only { display: block; }
.ai-dialog.drive .folder-only { display: none !important; }
.g-btn svg { background: #fff; border-radius: 50%; padding: 1px; }
.link-btn { display: inline-flex; align-items: center; gap: 5px; background: none; border: 0; padding: 4px 2px; color: var(--text-soft); font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.link-btn:hover { color: var(--accent); }
.acct-chip { padding: 3px 10px 3px 3px; }
.acct-pic { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; }
.acct-pic.sm { width: 24px; height: 24px; }
.acct-initial { display: inline-grid; place-items: center; background: var(--accent); color: #fff; font-weight: 700; font-size: 13px; }
.acct-row { display: flex; align-items: center; gap: 12px; margin: 4px 0 8px; }
.acct-chip .sync-txt::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; background: var(--sub); }
.acct-chip[data-sync="syncing"] .sync-txt::before { background: var(--accent); animation: kbpulse 1s ease-in-out infinite; }
.acct-chip[data-sync="paused"], .acct-chip[data-sync="error"] { border-color: var(--accent); color: var(--accent); }
.acct-chip[data-sync="paused"] .sync-txt::before, .acct-chip[data-sync="error"] .sync-txt::before { background: #d97706; }
.acct-chip[data-sync="offline"] .sync-txt::before { background: var(--text-soft); }
@keyframes kbpulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .acct-chip .sync-txt::before { animation: none !important; } }
.err-txt { color: #b42318; }
.pro-list { padding-left: 20px; margin: 8px 0 14px; }
.pro-list li { margin: 4px 0; }
.pro-dialog a.btn { display: inline-block; text-decoration: none; }
@media (max-width: 700px) {
  .demo-banner { gap: 6px; }
  .demo-banner .link-btn span, .acct-chip .sync-txt { display: none; }
  .acct-chip[data-sync="paused"] .sync-txt, .acct-chip[data-sync="error"] .sync-txt { display: inline; }
  .acct-chip { padding: 3px; }
  .acct-chip .acct-pic.acct-initial { display: inline-grid; }
  .g-btn span { font-size: 12px; }
  .ai-dialog { width: calc(100vw - 24px); max-width: none; }
}
/* Installed app (home screen / Android): room for the status bar */
@media (display-mode: standalone) { .topbar { padding-top: env(safe-area-inset-top); } }

/* ---------- Launch page (signed-out home on the website and Android app) ----------
   One idea: you design it on a whiteboard, KB grades it. The board (graph paper, handwriting, a grader's slip)
   is the only decorated thing; everything else is plain type on white. */
@font-face { font-family: "Kalam"; src: url("vendor/fonts/kalam-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Kalam"; src: url("vendor/fonts/kalam-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
body.landing .sidebar, body.landing #sidebarToggle { display: none; }
body.landing .content { padding: 0; }
.lp { max-width: 1160px; margin: 0 auto; padding: 0 32px 72px; color: var(--text); }
.lp h2 { font-size: 28px; font-weight: 750; letter-spacing: -.015em; color: var(--accent); margin: 0 0 22px; }
.lp a { color: var(--accent); }

.lp-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 56px; align-items: center;
  min-height: calc(100vh - 52px); min-height: calc(100svh - 52px); padding: 40px 0 56px; }
.lp-title { margin: 0; font-size: clamp(46px, 6vw, 82px); line-height: .98; font-weight: 820; letter-spacing: -.04em; color: var(--accent); }
.lp-title span { display: block; }
.lp-title span:nth-child(2) { padding-left: .55em; }
.lp-title span:nth-child(3) { padding-left: 1.1em; }
.lp-sub { font-size: 19px; line-height: 1.55; max-width: 34em; margin: 26px 0 0; color: var(--text); }
.lp-cta { display: flex; align-items: center; flex-wrap: wrap; gap: 14px 22px; margin-top: 30px; }
.lp-go { font-size: 17px; padding: 13px 24px; border-radius: 10px; }
.lp-browse { font-weight: 600; font-size: 16px; }
.lp-trust { margin: 18px 0 0; font-size: 14px; line-height: 1.5; color: var(--text-soft); max-width: 36em; }

.lp-board { position: relative; margin: 0 22px 40px 0; padding: 18px 18px 22px; border: 1px solid var(--border); border-radius: 16px;
  background-color: var(--bg-elev);
  background-image: linear-gradient(var(--board-line) 1px, transparent 1px), linear-gradient(90deg, var(--board-line) 1px, transparent 1px);
  background-size: 22px 22px; --board-line: rgba(28, 57, 187, .06); }
[data-theme="dark"] .lp-board { --board-line: rgba(142, 162, 255, .07); }
.lp-board-head { display: flex; align-items: baseline; gap: 10px; font-size: 15px; }
.lp-board-head b { color: var(--accent); font-size: 17px; }
.lp-board-head span { color: var(--sub); font-weight: 600; font-size: 13px; }
.lp-diagram { margin: 10px 0 4px; min-height: 180px; }
.lp-diagram svg { width: 100%; height: auto; min-width: 0 !important; }
.lp-hand { font-family: "Kalam", "Segoe Print", cursive; font-size: 19px; line-height: 1.35; color: var(--text); transform: rotate(-1.2deg); margin: 4px 6px 0; max-width: 44%; }
.lp-hand p { margin: 0 0 4px; }
.lp-verdict { position: absolute; right: -22px; bottom: -40px; width: min(320px, 56%); background: var(--bg-elev); border: 1px solid var(--border);
  border-left: 4px solid var(--sub); border-radius: 10px; padding: 12px 14px 10px; box-shadow: 0 2px 4px rgba(15, 35, 95, .06), 0 14px 34px rgba(15, 35, 95, .12); font-size: 14px; line-height: 1.45; }
.lp-verdict p { margin: 0 0 7px; }
.lp-v-head { font-size: 15px; color: var(--text-soft); }
.lp-v-head b { color: var(--sub); font-size: 17px; }
.lp-v-line { padding-left: 22px; position: relative; }
.lp-v-line::before { position: absolute; left: 0; top: 0; width: 16px; text-align: center; font-weight: 800; }
.lp-v-line.lp-ok::before { content: "✓"; color: var(--sub); }
.lp-v-line.lp-gap::before { content: "!"; color: var(--accent); }
.lp-v-line.lp-q::before { content: "?"; color: var(--accent); }
/* The one moment of motion: the grader's slip arrives and its lines are written in, once. */
@media (prefers-reduced-motion: no-preference) {
  .lp-verdict { animation: lp-slip .5s cubic-bezier(.2, .8, .2, 1) .5s both; }
  .lp-verdict p { animation: lp-line .35s ease-out both; }
  .lp-verdict p:nth-child(1) { animation-delay: .8s; }
  .lp-verdict p:nth-child(2) { animation-delay: 1.15s; }
  .lp-verdict p:nth-child(3) { animation-delay: 1.5s; }
  .lp-verdict p:nth-child(4) { animation-delay: 1.85s; }
}
@keyframes lp-slip { from { opacity: 0; transform: translateY(18px) rotate(1.5deg); } to { opacity: 1; transform: none; } }
@keyframes lp-line { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

.lp-steps { padding: 56px 0 8px; }
.lp-steps ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0 22px; counter-reset: lp; }
.lp-steps li { counter-increment: lp; border-top: 2px solid var(--border); padding-top: 14px; position: relative; }
.lp-steps li::before { content: counter(lp); position: absolute; top: -15px; left: 0; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 750; font-size: 14px; }
.lp-steps li b { display: block; margin-top: 12px; font-size: 17px; color: var(--text); }
.lp-steps li span { display: block; margin-top: 4px; color: var(--text-soft); line-height: 1.5; font-size: 15px; }

.lp-inside { padding: 64px 0 8px; }
.lp-inside dl { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 30px 48px; }
.lp-inside dt { font-size: 18px; font-weight: 650; color: var(--sub); display: flex; align-items: baseline; gap: 10px; }
.lp-n { font-size: 44px; font-weight: 820; letter-spacing: -.03em; color: var(--accent); font-variant-numeric: tabular-nums; }
.lp-inside dd { margin: 4px 0 0; line-height: 1.6; max-width: 34em; }

.lp-price { padding: 64px 0 8px; }
.lp-plans { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.lp-plan { border: 1px solid var(--border); border-radius: 14px; padding: 20px 22px; }
.lp-plan.pro { border: 2px solid var(--accent); }
.lp-plan h3 { margin: 0 0 8px; font-size: 20px; color: var(--accent); }
.lp-plan h3 span { font-size: 15px; font-weight: 600; color: var(--text-soft); margin-left: 6px; }
.lp-plan p { margin: 0; line-height: 1.6; }

.lp-faq { padding: 64px 0 8px; max-width: 760px; }
.lp-faq details { border-bottom: 1px solid var(--border); padding: 14px 0; }
.lp-faq summary { cursor: pointer; font-weight: 650; font-size: 17px; }
.lp-faq p { margin: 10px 0 2px; line-height: 1.6; color: var(--text); }

.lp-end { padding: 72px 0 0; display: flex; align-items: center; flex-wrap: wrap; gap: 18px 28px; }
.lp-end p { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.01em; color: var(--accent); max-width: 26em; }

@media (max-width: 920px) {
  .lp { padding: 0 18px 56px; }
  .lp-hero { grid-template-columns: 1fr; gap: 28px; min-height: 0; padding: 26px 0 64px; }
  .lp-title { font-size: clamp(40px, 12vw, 64px); }
  .lp-sub { font-size: 17px; margin-top: 18px; }
  .lp-cta { margin-top: 22px; }
  .lp-board { margin: 0; }
  .lp-verdict { position: relative; right: auto; bottom: auto; width: auto; margin: 14px -4px 0; }
  .lp-hand { max-width: 100%; font-size: 17px; }
  .lp-hero { padding-bottom: 24px; }
  .lp-steps ol { grid-template-columns: 1fr; gap: 22px; padding-left: 15px; }
  .lp-steps li { border-top: 0; border-left: 2px solid var(--border); padding: 0 0 0 26px; }
  .lp-steps li::before { top: -2px; left: -15px; }
  .lp-steps li b { margin-top: 0; }
  .lp-inside dl, .lp-plans { grid-template-columns: 1fr; }
  .lp-steps, .lp-inside, .lp-price, .lp-faq { padding-top: 48px; }
}
.linklike { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }
.linklike.small { font-size: .9em; }
.pro-dialog code { user-select: all; }

/* Lesson figures use a narrow viewBox so labels remain legible on phones. */
#writeup img[src*="lessons/"] {
  display: block;
  width: 440px;
  max-width: 100%;
  height: auto;
  margin: 24px auto 12px;
  border-radius: 12px;
}
#writeup img[src$="hld-1-architecture.svg"] { width: 760px; }
#writeup img[src*="designs/"] { display: block; width: 780px; max-width: 100%; height: auto; margin: 20px auto; border-radius: 12px; }
