/* THEME LAYER — "Research paper". Restyles components only (no layout changes):
   journal rule lines, booktabs-style tables, serif prose, small-caps labels,
   numbered-figure feel. Pairs with css/tokens/paper.css. */

/* ---------- Global typography ---------- */
body { font-feature-settings: "kern", "liga"; text-rendering: optimizeLegibility; }
h1, h2, h3 { font-variation-settings: "opsz" 60; }
h4 { font-family: var(--font-sans); font-weight: 600; letter-spacing: 0; }
h1 { text-wrap: balance; }
.lead { font-family: var(--font-prose); font-size: 1.22rem; line-height: 1.55; color: var(--text-muted); }
.eyebrow { font-family: var(--font-sans); font-weight: 600; font-size: var(--fs-xs); letter-spacing: 0.16em; color: var(--accent); }
::selection { background: rgba(139, 30, 45, 0.16); }
a:hover { text-decoration-thickness: 1px; text-underline-offset: 3px; }
:not(pre) > code { border: 1px solid var(--border); font-size: 0.86em; }
pre { border-radius: var(--radius); }

/* ---------- Nav: a journal masthead ---------- */
.nav { background: color-mix(in srgb, var(--bg) 92%, transparent); border-top: 3px solid var(--accent); border-bottom: 1px solid var(--border-strong); }
.brand { font-family: var(--font-display); font-weight: 600; font-size: 1.28rem; letter-spacing: -0.01em; }
.brand__name { font-variation-settings: "opsz" 36; }
.brand__mark { stroke-width: 1.4; }
.nav__link { font-weight: 500; font-size: 0.95rem; border-radius: 0; padding: 6px 2px; margin: 0 10px; border-bottom: 1.5px solid transparent; }
.nav__link:hover { background: none; color: var(--text); border-bottom-color: var(--border-strong); }
.nav__link.is-active { background: none; color: var(--text); border-bottom-color: var(--accent); }
.nav__toggle { border-radius: var(--radius); background: transparent; border-color: var(--border-strong); }
.nav__drawer-link { font-family: var(--font-display); font-size: 1.15rem; }
.menu__panel { border-radius: var(--radius); border-color: var(--border-strong); }

/* ---------- Footer: colophon ---------- */
.footer { border-top: 0; background: var(--bg); position: relative; }
.footer::before { content: ""; display: block; max-width: calc(var(--maxw) - 2 * var(--space-4)); margin: 0 auto; height: 4px; border-top: 1px solid var(--text); border-bottom: 1px solid var(--border-strong); width: calc(100% - 2 * var(--space-4)); }
@media (min-width: 720px) { .footer::before { width: calc(100% - 2 * var(--space-5)); max-width: calc(var(--maxw) - 2 * var(--space-5)); } }
.footer__tag { font-family: var(--font-prose); font-style: italic; font-size: 1rem; }
.footer__cols h4 { font-family: var(--font-sans); font-weight: 600; letter-spacing: 0.14em; color: var(--text-faint); }
.footer__cols a:hover { color: var(--accent); }
.footer__legal { font-family: var(--font-mono); }

/* ---------- Buttons ---------- */
.btn { border-radius: var(--radius); font-weight: 600; letter-spacing: 0.005em; }
.btn--primary { box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.18); }
.btn--secondary { background: transparent; border-color: var(--text); color: var(--text); }
.btn--secondary:hover { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn--ghost:hover { background: var(--bg-sunken); }
.btn--lg { padding: 14px 24px; font-size: 1.02rem; }
.btn[disabled], .btn.is-disabled, .btn[disabled]:hover, .btn.is-disabled:hover { opacity: 1; background: var(--bg-sunken); color: var(--text-muted); border: 1px dashed var(--border-strong); box-shadow: none; transform: none; }

/* ---------- Chips, tags, difficulty ---------- */
.chip { border-radius: var(--radius-sm); font-weight: 600; letter-spacing: 0.02em; padding: 2px 7px; }
.chip--pro { background: var(--accent); color: var(--accent-contrast); }
.chip--free { background: transparent; border: 1px solid color-mix(in srgb, var(--ok) 45%, transparent); }
.chip--company { background: transparent; border: 1px solid color-mix(in srgb, var(--accent-2) 40%, transparent); }
.chip--filter { border-radius: var(--radius-sm); }
.diff { font-family: var(--font-sans); font-weight: 600; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.1em; }
.tag { background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.tag:hover { border-color: var(--accent); }

/* ---------- Cards ---------- */
.card { border-radius: var(--radius-lg); box-shadow: none; border-color: var(--border); }
.card__title { font-family: var(--font-display); }

/* ---------- Forms ---------- */
.input, .select, .search__input { border-radius: var(--radius); background: var(--bg-elev); }
.field label { font-weight: 600; }

/* ---------- Bank: booktabs table ---------- */
.bank__title { font-size: var(--fs-3xl); font-weight: 500; }
.bank__sub { font-family: var(--font-prose); font-style: italic; font-size: 1.05rem; }
.rail__h { font-family: var(--font-sans); font-weight: 600; letter-spacing: 0.14em; color: var(--text-faint); border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.facet { border-radius: var(--radius-sm); }
.facet.is-on { background: var(--accent-soft); color: var(--accent); box-shadow: inset 2px 0 0 var(--accent); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.toolbar__count { font-family: var(--font-prose); font-style: italic; font-weight: 400; font-size: 1rem; }
.plist { border: 0; border-top: 2px solid var(--text); border-bottom: 2px solid var(--text); border-radius: 0; background: transparent; }
.prow { border-bottom-color: var(--border); padding: 8px var(--space-2); }
.prow:hover { background: color-mix(in srgb, var(--bg-elev) 70%, var(--accent-soft)); }
.prow__title { font-family: var(--font-prose); font-size: 1.04rem; font-weight: 400; line-height: 1.45; font-variation-settings: "opsz" 16; }
.prow__title:hover { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.prow__id { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.prow__cat { font-style: italic; font-family: var(--font-prose); font-size: 0.8rem; color: var(--text-muted); }
.plist__more { border-top: 1px solid var(--border); }

/* ---------- Detail: the problem as a paper excerpt ---------- */
.dnav__back { font-family: var(--font-sans); }
.iconbtn { border-radius: var(--radius); background: transparent; }
.problem__id { font-family: var(--font-mono); letter-spacing: 0.04em; }
.problem__title { font-size: clamp(1.9rem, 4vw, 2.5rem); font-weight: 500; line-height: 1.12; }
.pmeta__cat { font-family: var(--font-sans); color: var(--accent); }
.statement { position: relative; background: var(--bg-elev); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 0 var(--radius-lg) var(--radius-lg) 0; box-shadow: none; padding: var(--space-5) var(--space-5) var(--space-5) calc(var(--space-5) + 2px); }
.statement::before { content: "Problem"; display: block; font-family: var(--font-sans); font-weight: 700; font-size: var(--fs-xs); letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); margin-bottom: var(--space-2); }
.prose { font-size: 1.1rem; line-height: 1.68; font-variation-settings: "opsz" 16; }
.prose strong { font-weight: 600; }
.prose .katex { font-size: 1.08em; }
.prose th { font-family: var(--font-sans); }
.prose table { border-top: 2px solid var(--text); border-bottom: 2px solid var(--text); }
.prose th, .prose td { border: 0; border-bottom: 1px solid var(--border); }
.prose th { background: transparent; border-bottom: 1px solid var(--text); }
.prose blockquote { border-left-color: var(--accent-2); background: transparent; font-style: italic; }
.reports { border-radius: 0 var(--radius) var(--radius) 0; background: transparent; }
.reports__h { font-family: var(--font-sans); font-weight: 600; }

/* ---------- Solve card ---------- */
.solve__card { border-radius: var(--radius-lg); box-shadow: none; border-color: var(--border-strong); background: var(--bg-elev); }
.solve__label { font-family: var(--font-sans); font-weight: 700; letter-spacing: 0.16em; }
.part { border-top: 1px solid var(--border); }
.part__n { font-family: var(--font-sans); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.part__title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 500; }
.answer__input { font-size: 1rem; }
.option { background: var(--bg); border-radius: var(--radius); padding: 12px 14px; }
.option:hover { border-color: var(--text-faint); background: var(--bg-elev); }
.option__key { border: 0; width: auto; min-width: 26px; height: 26px; border-radius: var(--radius-sm); font-family: var(--font-prose); font-style: italic; font-size: 1.05rem; font-weight: 500; text-transform: lowercase; color: var(--text-muted); }
.option__key::before { content: "("; } .option__key::after { content: ")"; }
.option__text { font-size: 1.04rem; }
.option:has(input:checked) { border-color: var(--text); background: var(--bg-elev); box-shadow: inset 3px 0 0 var(--text); }
.option:has(input:checked) .option__key { background: transparent; color: var(--text); font-weight: 600; }
.option.is-right, .option.is-right:has(input:checked) { border-color: var(--ok); background: var(--ok-soft); box-shadow: inset 3px 0 0 var(--ok); }
.option.is-right .option__key { background: transparent; color: var(--ok); }
.option.is-wrong, .option.is-wrong:has(input:checked) { border-color: var(--bad); background: var(--bad-soft); box-shadow: inset 3px 0 0 var(--bad); }
.option.is-wrong .option__key { background: transparent; color: var(--bad); }
.verdict { font-family: var(--font-sans); }
.solve__done { border-radius: var(--radius); border: 1px solid currentColor; }
.model-answer, .intuition { border-radius: 0 var(--radius) var(--radius) 0; }
.model-answer__label, .intuition__label { font-family: var(--font-sans); font-weight: 700; letter-spacing: 0.14em; }
.intuition { background: transparent; border-left: 3px solid var(--accent-2); }
.reveal-block { border-top: 1px solid var(--border-strong); }
.reveal-block__head h3 { font-size: var(--fs-xl); }
.hints li::marker { color: var(--accent); font-family: var(--font-sans); font-weight: 600; }

/* ---------- Dashboard: Up next / Skill by topic as booktabs tables ---------- */
.dash__grid .card { background: transparent; border: 0; border-radius: 0; box-shadow: none; padding: 0; }
.dash__grid .card__head { margin-bottom: var(--space-2); }
.dash__grid .card__title { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 500; }
.dash__grid .card__head .small { font-family: var(--font-prose); font-style: italic; font-size: 0.95rem; color: var(--text-muted); }
.recs, .skills { gap: 0; border-top: 2px solid var(--text); border-bottom: 2px solid var(--text); }
.rec + .rec, .skill + .skill { border-top: 1px solid var(--border); }
.mini { gap: 0; border-top: 2px solid var(--text); border-bottom: 2px solid var(--text); }
.mini li { padding: 8px var(--space-2); }
.mini li + li { border-top: 1px solid var(--border); }
.mini a { font-family: var(--font-prose); font-size: 1rem; }
.dash__grid .card > p { border-top: 2px solid var(--text); border-bottom: 2px solid var(--text); padding: var(--space-3) var(--space-2); margin: 0; font-family: var(--font-prose); font-style: italic; }
.dash__grid { row-gap: var(--space-6); margin-bottom: var(--space-6); }
@media (min-width: 900px) { .dash__grid { column-gap: var(--space-7); } }
.rec__link { border: 0; border-radius: 0; padding: 9px var(--space-2); }
.rec__link:hover { background: var(--bg-elev); border-color: transparent; }
.rec__link:hover .rec__title { color: var(--accent); }
.rec__title { font-family: var(--font-prose); font-size: 1.04rem; font-weight: 400; line-height: 1.4; }
.rec__cat { font-family: var(--font-prose); font-style: italic; font-size: 0.8rem; color: var(--text-muted); }
.skill { padding: 9px var(--space-2); }
.skill__label { font-family: var(--font-prose); font-size: 1rem; }
.skill__bar { height: 4px; border-radius: 2px; }
.skill__bar span { background: var(--accent); opacity: 0.8; border-radius: 2px; }
.skill__val, .skill__n { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.stat { box-shadow: none; border-radius: var(--radius-lg); }
.stat__num { font-weight: 500; font-variation-settings: "opsz" 72; }

/* ---------- Paywall ---------- */
.paywall { border-radius: var(--radius-lg); border-color: var(--border-strong); }
.paywall__card h3 { font-size: var(--fs-xl); }

/* ---------- Auth ---------- */
.auth__card { border-top: 3px solid var(--accent); border-radius: 0 0 var(--radius-lg) var(--radius-lg); background: var(--bg-elev); box-shadow: var(--shadow); }
.auth__title { font-size: 2.1rem; font-weight: 500; }
.auth__sub { font-family: var(--font-prose); font-style: italic; font-size: 1.05rem; }
.auth__or { font-family: var(--font-prose); font-style: italic; font-size: 0.95rem; }
.auth__providers .btn--secondary { border-color: var(--border-strong); background: var(--bg-elev); }
.auth__providers .btn--secondary:hover { background: var(--bg-sunken); color: var(--text); border-color: var(--text-faint); }

/* ---------- Coding IDE (scoped to .cs-root) ---------- */
.cs-root { --cs-radius: var(--radius-lg); --cs-radius-sm: var(--radius); }
.cs-root .cs-pane { border-color: var(--border-strong); }
.cs-root .cs-title { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; font-variation-settings: "opsz" 48; }
.cs-root .cs-statement { font-family: var(--font-prose); font-size: 16.5px; line-height: 1.68; }
.cs-root .cs-statement .katex { font-size: 1.06em; }
.cs-root .cs-sec-h { font-family: var(--font-sans); letter-spacing: 0.14em; }
.cs-root .cs-tab.is-active { color: var(--accent); }
.cs-root .cs-pill { border-radius: var(--radius-sm); font-family: var(--font-sans); }
.cs-root .cs-pill--diff.cs-pill--easy { background: var(--ok-soft); }
.cs-root .cs-pill--diff.cs-pill--medium { background: var(--warn-soft); }
.cs-root .cs-pill--diff.cs-pill--hard { background: var(--bad-soft); }
.cs-root .cs-pill--hint { background: var(--accent-2-soft); }
.cs-root .cs-edhead { background: var(--bg-sunken); }
.cs-root .cs-langchip { font-family: var(--font-mono); }
.cs-root .cs-btn { font-family: var(--font-sans); border-radius: var(--radius); }
.cs-root .cs-modebtn { font-family: var(--font-sans); }
.cs-editor .CodeMirror { font-family: var(--font-mono); font-size: 13px; line-height: 1.6; }
.cs-editor .CodeMirror-activeline-background { background: rgba(139, 30, 45, 0.045); }
.cs-editor .CodeMirror-selected { background: rgba(139, 30, 45, 0.12) !important; }
.cs-editor .CodeMirror-focused .CodeMirror-selected { background: rgba(139, 30, 45, 0.17) !important; }
.cs-editor .CodeMirror-matchingbracket { background: rgba(139, 30, 45, 0.10); }
.cs-editor .cm-matchhighlight { background: rgba(42, 102, 112, 0.14); box-shadow: inset 0 0 0 1px rgba(42, 102, 112, 0.3); }
.cs-editor .CodeMirror-selection-highlight-scrollbar { background: rgba(139, 30, 45, 0.5); }
.cs-root .cm-s-default .cm-keyword { color: var(--accent); font-weight: 600; }
.cs-root .cm-s-default .cm-def { color: var(--accent-2); font-weight: 600; }
.cs-root .cm-s-default .cm-variable { color: var(--code-text); }
.cs-root .cm-s-default .cm-variable-2 { color: #3d4f6b; }
.cs-root .cm-s-default .cm-variable-3, .cs-root .cm-s-default .cm-type { color: var(--accent-2); }
.cs-root .cm-s-default .cm-property { color: var(--accent-2); }
.cs-root .cm-s-default .cm-builtin { color: var(--warn); }
.cs-root .cm-s-default .cm-string, .cs-root .cm-s-default .cm-string-2 { color: #3f6b1f; }
.cs-root .cm-s-default .cm-number, .cs-root .cm-s-default .cm-atom { color: #a3470b; }
.cs-root .cm-s-default .cm-comment { color: #6b6153; font-style: italic; }
.cs-root .cm-s-default .cm-operator { color: var(--text-muted); }
.cs-root .cm-s-default .cm-meta { color: var(--warn); }
.cs-root .cm-s-default .cm-bracket { color: var(--text-muted); }
.cs-root .cm-s-default .cm-error { color: var(--bad); }
/* Description-pane code blocks wrap instead of clipping (all widths). */
body .cs-root .cs-statement pre, body.coding-ide .cs-root .cs-statement pre code { white-space: pre-wrap; overflow-wrap: anywhere; }
/* Desktop IDE: the editor takes a bounded share; the Test panel absorbs the rest
   (a drag on the divider still sets an inline height, which wins). */
@media (min-width: 901px) {
  body.coding-ide .cs-root .cs-editor { flex: 0 1 auto; height: clamp(260px, 46vh, 540px); }
}
/* Stacked IDE (<=900px): description at full height, then the editor; no nested
   scroll box. Code keeps its lines and scrolls sideways instead of soft-wrapping. */
@media (max-width: 900px) {
  body.coding-ide .cs-root .cs-pane--statement, .cs-root .cs-pane--statement { max-height: none; }
  body.coding-ide .cs-root .cs-leftbody, .cs-root .cs-leftbody { overflow: visible; }
  .cs-editor .CodeMirror-wrap pre.CodeMirror-line,
  .cs-editor .CodeMirror-wrap pre.CodeMirror-line-like { white-space: pre; word-wrap: normal; overflow-wrap: normal; word-break: normal; }
  .cs-editor .CodeMirror { font-size: 14px; }
}

/* ---------- Small screens: give prose the width ---------- */
@media (max-width: 520px) {
  .statement { padding: var(--space-4) var(--space-4) var(--space-4) calc(var(--space-4) + 2px); }
  .solve__card { padding: var(--space-4); }
  .option { padding: 10px 12px; gap: var(--space-2); }
  .prose { font-size: 1.06rem; }
}

/* Final-answer paragraph (tagged by markdown-render.js) */
.prose .md-answer { border-top: 1px solid var(--text); border-bottom: 1px solid var(--text); padding: var(--space-3) 0; margin: var(--space-5) 0; }
.prose .md-answer strong:first-child { font-family: var(--font-sans); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.12em; color: var(--accent); margin-right: var(--space-2); }
