/* Layout and components. Colours, type and shape come from themes.css. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-width: 320px;
  background-color: var(--bg);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.55;
}
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
code, kbd, pre, samp { font-family: var(--font-mono); font-stretch: var(--mono-stretch); }
:not(pre) > code { padding: 0 4px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--panel-2); font-size: 0.86em; overflow-wrap: anywhere; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 16px 0; }
::selection { background: var(--accent-soft); }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; padding: 10px 14px; background: var(--accent-fill); color: var(--on-accent); text-decoration: none; }
.skip-link:focus { top: 12px; }

/* ---------- shell ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0 24px;
  padding: 0 20px; min-height: 60px;
  background: var(--panel); border-bottom: 1px solid var(--panel-border);
}
.brand { display: flex; align-items: center; gap: 10px; min-height: 44px; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand svg { flex: none; }
.brand-word { font-family: var(--font-display); font-stretch: var(--wordmark-stretch); font-weight: 800; font-size: 16px; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; }
:root[data-family="editorial"] .brand-word { font-size: 21px; letter-spacing: -0.02em; text-transform: none; }
:root[data-family="console"] .brand-word { letter-spacing: 0.02em; text-transform: none; font-size: 17px; }
.nav { display: flex; gap: 2px; font-family: var(--label-font); font-size: 12px; letter-spacing: 0.04em; text-transform: var(--label-case); }
:root[data-family="editorial"] .nav { font-size: 15px; letter-spacing: 0; text-transform: none; gap: 4px 14px; }
:root[data-family="console"] .nav { font-size: 13px; }
.nav a { display: flex; align-items: center; min-height: 44px; padding: 0 12px; color: var(--muted); text-decoration: none; white-space: nowrap; }
:root[data-family="editorial"] .nav a { padding: 0 4px; font-weight: 600; }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); box-shadow: var(--nav-on-shadow); }
.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.jump { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px 0 12px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; }
.jump:hover { border-color: var(--strong); color: var(--ink); }
.kbd { display: inline-block; min-width: 20px; padding: 0 5px; border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px; font-family: var(--font-mono); font-size: 11px; line-height: 18px; text-align: center; color: var(--muted); background: var(--panel); }
.page { flex: 1; width: 100%; max-width: 1440px; margin: 0 auto; padding: 20px 24px 36px; }
.page.wide { max-width: none; padding: 12px 12px 0; }
.page:focus { outline: none; }
.footer { padding: 18px 24px 28px; color: var(--muted); font-size: 13px; text-align: center; }
.footer a { color: var(--muted); }

@media (max-width: 960px) {
  .topbar { padding: 0 12px; gap: 0 12px; }
  .nav { order: 3; flex: 1 0 100%; margin: 0 -12px; padding: 0 6px; overflow-x: auto; border-top: 1px solid var(--rule); scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .jump .jump-text { display: none; }
  .page { padding: 14px 12px 28px; }
}

/* ---------- type ---------- */
.display { margin: 0; font-family: var(--font-display); font-stretch: var(--display-stretch); font-weight: var(--display-weight); letter-spacing: var(--display-tracking); line-height: 1.1; }
h1.display { font-size: clamp(26px, 3vw, 34px); }
h2.display { font-size: 22px; }
h3.display { font-size: 18px; }
.hero-title { font-size: clamp(32px, 5.2vw, 60px) !important; line-height: 1.02 !important; max-width: 18ch; }
.label { font-family: var(--label-font); font-size: var(--label-size); font-weight: var(--label-weight); letter-spacing: var(--label-tracking); text-transform: var(--label-case); color: var(--muted); }
.mono { font-family: var(--font-mono); font-stretch: var(--mono-stretch); font-size: var(--fs-mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.lede { font-size: 17px; max-width: 62ch; color: var(--muted); margin: 0; }
.nowrap { white-space: nowrap; }
.tone-pass { color: var(--pass); }
.tone-fail { color: var(--fail); }
.tone-warn { color: var(--warn); }
.tone-info { color: var(--info); }
.tone-muted { color: var(--muted); }
.tone-accent { color: var(--accent); }

/* ---------- layout helpers ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.tight { gap: 8px; }
.stack.loose { gap: 24px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grow { flex: 1 1 auto; min-width: 0; }
.push { margin-left: auto; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 16px; }
.cols-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 20px; align-items: start; }
.browse { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .browse { grid-template-columns: minmax(0, 1fr); } }

/* ---------- panels ---------- */
.panel { min-width: 0; background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); box-shadow: var(--panel-shadow); }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: 44px; padding: 8px 14px; border-bottom: 1px solid var(--rule); }
.panel-head.tall { padding: 18px 22px 14px; }
.panel-body { padding: 16px; }
.panel-body.roomy { padding: 20px 22px 24px; }
.panel-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--rule); }
.panel > :last-child { border-bottom-left-radius: inherit; border-bottom-right-radius: inherit; }
.divide > * + * { border-top: 1px solid var(--rule); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 10px 14px; border-bottom: 1px solid var(--rule); }
.list > li:last-child { border-bottom: 0; }
.list a.strong { color: var(--ink); font-weight: 700; text-decoration: none; }
.list a.strong:hover { color: var(--accent); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.empty .display { color: var(--ink); margin-bottom: 6px; }

/* ---------- tags, badges ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border: 1px solid var(--rule); border-radius: var(--radius-sm); font-family: var(--label-font); font-size: 11px; font-weight: 500; letter-spacing: 0.05em; text-transform: var(--label-case); color: var(--muted); white-space: nowrap; text-decoration: none; }
a.tag:hover { border-color: var(--strong); color: var(--ink); }
.tag { max-width: 100%; }
.facts .tag, a.tag { white-space: normal; overflow-wrap: anywhere; }
.tag.accent { border-color: var(--accent); color: var(--accent); }
.tag.pass { border-color: var(--pass); color: var(--pass); }
.tag.fail { border-color: var(--fail); color: var(--fail); }
.tag.warn { border-color: var(--warn); color: var(--warn); }
.tag.solid { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.diff-easy { color: var(--pass); }
.diff-medium { color: var(--ink); }
.diff-hard { color: var(--accent); }
.tag.diff-easy { border-color: var(--pass); }
.tag.diff-medium { border-color: var(--strong); }
.tag.diff-hard { border-color: var(--accent); }
.status-dot { font-size: 14px; line-height: 1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--strong); border-radius: var(--radius-sm);
  background: transparent; color: var(--ink);
  font-family: var(--label-font); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: var(--label-case);
  text-decoration: none; white-space: nowrap; cursor: pointer;
}
:root[data-family="editorial"] .btn { font-size: 14px; letter-spacing: 0; text-transform: none; }
:root[data-family="console"] .btn { font-size: 13px; }
.btn:hover { background: var(--panel-2); color: var(--ink); }
.btn.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); font-weight: 700; }
.btn.primary:hover { background: var(--accent-fill); filter: brightness(1.08) saturate(1.05); color: var(--on-accent); }
.btn.quiet { border-color: var(--rule); color: var(--muted); }
.btn.quiet:hover { color: var(--ink); border-color: var(--strong); }
.btn.danger { border-color: var(--fail); color: var(--fail); }
.btn.danger:hover { background: var(--fail-soft); color: var(--fail); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 11px; }
:root[data-family="editorial"] .btn.small { font-size: 13px; }
.btn.block { width: 100%; white-space: normal; text-align: center; padding-top: 6px; padding-bottom: 6px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; filter: none; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--strong); border-radius: var(--radius-sm); background: transparent; color: var(--ink); cursor: pointer; }
.icon-btn:hover { background: var(--panel-2); }
.icon-btn.quiet { border-color: var(--rule); color: var(--muted); }
.icon-btn.quiet:hover { color: var(--ink); }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.linklike { padding: 0; border: 0; background: none; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.linklike:hover { color: var(--ink); }

/* ---------- tabs ---------- */
.tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; border-bottom: 1px solid var(--rule); font-family: var(--label-font); font-size: 12px; letter-spacing: 0.04em; text-transform: var(--label-case); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
:root[data-family="editorial"] .tabs { font-size: 14.5px; letter-spacing: 0; text-transform: none; font-weight: 600; gap: 0 4px; padding: 0 6px; }
:root[data-family="console"] .tabs { font-size: 12.5px; }
.tab { flex: none; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border: 0; border-right: 1px solid var(--rule); background: transparent; color: var(--muted); font: inherit; cursor: pointer; white-space: nowrap; }
:root[data-family="editorial"] .tab { border-right: 0; padding: 0 10px; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: var(--tab-on-bg); color: var(--tab-on-ink); box-shadow: var(--tab-on-shadow); }
.tab .count { font-family: var(--font-mono); font-size: 11px; opacity: 0.8; }
.tab:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- forms ---------- */
.input, .select, .textarea {
  min-height: 40px; max-width: 100%;
  padding: 0 10px;
  border: 1px solid var(--rule); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--ink);
  font: inherit; font-size: 14px;
}
.select { padding-right: 28px; cursor: pointer; }
.textarea { display: block; width: 100%; min-height: 72px; padding: 8px 10px; font-family: var(--font-mono); font-stretch: var(--mono-stretch); font-size: 12.5px; line-height: 1.5; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--strong); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--focus); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--fail); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-error { color: var(--fail); font-size: 12.5px; }
.field-hint { color: var(--muted); font-size: 12.5px; }
.search { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 10px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--panel); }
.search:focus-within { border-color: var(--focus); outline: 2px solid var(--focus); outline-offset: -1px; }
.search input { flex: 1; min-width: 0; min-height: 38px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 14px; outline: none; }
.check { display: flex; align-items: center; gap: 10px; min-height: 34px; cursor: pointer; }
.check input { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.check .n { margin-left: auto; font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
fieldset.group { margin: 0; padding: 12px 14px; border: 0; border-bottom: 1px solid var(--rule); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
fieldset.group:last-child { border-bottom: 0; }
fieldset.group > legend { float: left; width: 100%; padding: 0; margin-bottom: 6px; }
fieldset.group > legend + * { clear: both; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg label { position: relative; display: flex; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; min-height: 36px; padding: 0 12px; font-family: var(--label-font); font-size: 12px; letter-spacing: 0.04em; text-transform: var(--label-case); color: var(--muted); border-right: 1px solid var(--rule); }
.seg label:last-child span { border-right: 0; }
.seg input:checked + span { background: var(--ink); color: var(--panel); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -2px; }
.chips-filter { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px; border: 1px solid var(--rule); border-radius: var(--radius-pill); background: transparent; color: var(--ink); font-size: 13px; cursor: pointer; }
.chip:hover { border-color: var(--strong); }
.chip[aria-pressed="true"] { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); }
.chip .n { font-family: var(--font-mono); font-size: 11px; opacity: 0.75; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { padding: 10px 8px; border-bottom: 1px solid var(--rule); font-family: var(--label-font); font-size: 10.5px; font-weight: 500; letter-spacing: 0.08em; text-transform: var(--label-case); color: var(--muted); text-align: left; white-space: nowrap; }
.table td { padding: 9px 8px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table th:first-child, .table td:first-child { padding-left: 16px; }
.table th:last-child, .table td:last-child { padding-right: 16px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--panel-2); }
.table .num { font-family: var(--font-mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.table .title-link { color: var(--ink); font-weight: 600; text-decoration: none; }
.table .title-link:hover { color: var(--accent); text-decoration: underline; }
.table .sub { font-size: 12.5px; color: var(--muted); }
.table .only-narrow { display: none; }
@media (max-width: 640px) {
  .table .opt-col { display: none; }
  .table .only-narrow { display: block; }
}

/* ---------- markdown ---------- */
.md { max-width: 72ch; overflow-wrap: break-word; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md h1, .md h2, .md h3, .md h4 { margin: 22px 0 10px; }
.md h2 { padding-top: 12px; border-top: 1px solid var(--rule); font-family: var(--label-font); font-size: var(--label-size); font-weight: 600; letter-spacing: var(--label-tracking); text-transform: var(--label-case); color: var(--muted); }
.md h3 { font-family: var(--font-display); font-stretch: var(--display-stretch); font-size: 16px; font-weight: 700; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 22px; }
.md li { margin: 4px 0; }
.md li > p { margin: 0; }
.md code { padding: 0 4px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--panel-2); font-size: 0.86em; }
.md pre { margin: 0 0 14px; }
.md pre code { padding: 0; border: 0; background: none; font-size: inherit; }
.md table { display: block; max-width: 100%; overflow-x: auto; margin: 0 0 14px; border-collapse: collapse; font-size: 14px; }
.md th, .md td { padding: 6px 10px; border: 1px solid var(--rule); text-align: left; vertical-align: top; }
.md th { background: var(--panel-2); font-weight: 600; }
.md blockquote { margin: 0 0 12px; padding: 8px 14px; border-left: 3px solid var(--accent); background: var(--panel-2); }
.md blockquote > :last-child { margin-bottom: 0; }
.md hr { margin: 18px 0; }
.md img { border: 1px solid var(--rule); }
.md.wide { max-width: none; }

/* ---------- code blocks + syntax ---------- */
.code {
  margin: 0; padding: 12px 14px;
  background: var(--code-bg); color: var(--code-ink);
  border: 1px solid var(--code-rule); border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-stretch: var(--mono-stretch); font-size: var(--fs-mono); line-height: 1.6;
  white-space: pre; overflow-x: auto; tab-size: 4;
}
.code.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.code.flat { border: 0; border-radius: 0; }
.code-frame { position: relative; }
.code-frame .copy { position: absolute; top: 6px; right: 6px; }
.tok-keyword, .tok-meta, .tok-macroName, .tok-modifier { color: var(--syn-k); }
.tok-typeName, .tok-className, .tok-namespace { color: var(--syn-t); }
.tok-number, .tok-bool, .tok-atom, .tok-literal { color: var(--syn-n); }
.tok-comment { color: var(--syn-c); font-style: italic; }
.tok-string, .tok-string2 { color: var(--syn-s); }
.tok-definition { color: var(--syn-f); font-weight: 700; }
.tok-operator, .tok-punctuation { color: var(--syn-op); }
.tok-invalid { color: var(--fail); }
.tok-heading, .tok-strong { font-weight: 700; }
.tok-emphasis { font-style: italic; }

/* ---------- callouts ---------- */
.callout { padding: 10px 14px; border: 1px dashed var(--strong); border-radius: var(--radius-sm); font-size: 14px; }
.callout > :last-child { margin-bottom: 0; }
.callout.warn { border: 1px solid var(--warn); background: var(--warn-soft); }
.callout.fail { border: 1px solid var(--fail); background: var(--fail-soft); }
.callout.pass { border: 1px solid var(--pass); background: var(--pass-soft); }
.callout.info { border: 1px solid var(--info); background: var(--info-soft); }
.callout .label { display: block; margin-bottom: 4px; color: inherit; }
.callout ul { margin: 4px 0 0; padding-left: 20px; }

/* ---------- progress ---------- */
.bar { position: relative; height: 4px; overflow: hidden; background: var(--rule); border-radius: var(--radius-pill); }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s ease; }
.bar.pass > i { background: var(--pass); }
.bar.indeterminate > i { position: absolute; width: 30%; animation: bar-slide 1.1s linear infinite; }
@keyframes bar-slide { from { left: -30%; } to { left: 100%; } }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--rule); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .bar.indeterminate > i { left: 0; width: 100%; opacity: 0.5; }
}

/* ---------- dialogs, popovers, toasts ---------- */
dialog.dlg {
  width: min(640px, calc(100vw - 24px)); max-height: min(84dvh, 760px);
  padding: 0; border: 1px solid var(--panel-border); border-radius: var(--radius);
  background: var(--panel); color: var(--ink);
  box-shadow: 0 24px 70px rgb(0 0 0 / 0.28);
}
dialog.dlg[open] { display: flex; flex-direction: column; }
dialog.dlg.wide { width: min(980px, calc(100vw - 24px)); }
dialog.dlg::backdrop { background: rgb(8 8 8 / 0.5); }
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--rule); }
.dlg-head .display { font-size: 18px; }
.dlg-body { flex: 1; min-height: 0; overflow: auto; padding: 16px 18px; }
.dlg-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--rule); }
dialog.palette-dlg { margin-top: 10vh; width: min(620px, calc(100vw - 24px)); }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 4px 14px; border-bottom: 1px solid var(--rule); }
.palette-input input { flex: 1; min-width: 0; min-height: 52px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 17px; outline: none; }
.palette-list { list-style: none; margin: 0; padding: 6px; max-height: 52dvh; overflow-y: auto; }
.palette-list li { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 6px 10px; border-radius: var(--radius-sm); cursor: pointer; }
.palette-list li[aria-selected="true"] { background: var(--accent-soft); }
.palette-list .kind { width: 74px; flex: none; }
.palette-list .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-list .meta { flex: none; font-size: 12.5px; color: var(--muted); }
.palette-foot { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 14px; border-top: 1px solid var(--rule); font-size: 12px; color: var(--muted); }

.popwrap { position: relative; }
.pop {
  position: absolute; z-index: 45; top: calc(100% + 8px); right: 0;
  width: max-content; min-width: 260px; max-width: min(360px, calc(100vw - 24px));
  padding: 14px; border: 1px solid var(--panel-border); border-radius: var(--radius);
  background: var(--panel); color: var(--ink); box-shadow: 0 14px 40px rgb(0 0 0 / 0.2);
}
.pop.left { right: auto; left: 0; }
.theme-cards { display: grid; gap: 8px; }
.theme-card { display: grid; grid-template-columns: 54px 1fr; align-items: center; gap: 12px; width: 100%; padding: 8px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: transparent; color: var(--ink); text-align: left; cursor: pointer; }
.theme-card:hover { border-color: var(--strong); }
.theme-card[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.theme-card .name { font-weight: 700; }
.theme-card .desc { font-size: 12.5px; color: var(--muted); }
.swatch { display: grid; grid-template-columns: repeat(3, 1fr); width: 54px; height: 36px; border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; }
.swatch i { display: block; }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; max-width: min(440px, calc(100vw - 32px)); padding: 10px 14px; border-radius: var(--radius-sm); background: var(--ink); color: var(--panel); font-size: 14px; box-shadow: 0 10px 30px rgb(0 0 0 / 0.25); pointer-events: auto; }
.toast.pass { background: var(--pass); color: var(--panel); }
.toast.fail { background: var(--fail); color: var(--panel); }

/* ---------- home ---------- */
.hero { position: relative; overflow: hidden; }
.hero .panel-body { padding: 32px 28px 28px; }
.hero-mark { position: absolute; right: 28px; top: 28px; width: 132px; height: 132px; color: var(--accent); opacity: 0.16; pointer-events: none; }
@media (max-width: 760px) { .hero-mark { display: none; } }
.stats { display: flex; flex-wrap: wrap; gap: 0; border-top: 1px solid var(--rule); }
.stat { flex: 1 1 140px; padding: 14px 20px; border-right: 1px solid var(--rule); }
.stat:last-child { border-right: 0; }
.stat .value { font-family: var(--font-display); font-stretch: var(--display-stretch); font-weight: var(--display-weight); font-size: 28px; line-height: 1.1; }
.home-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; align-items: start; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
@media (max-width: 1100px) { .span-4, .span-5, .span-7, .span-8 { grid-column: span 6; } }
@media (max-width: 760px) { .home-grid > * { grid-column: span 12 !important; } }

/* ---------- problem workspace ---------- */
.ws { display: grid; grid-template-columns: minmax(300px, var(--ws-left, 42%)) 10px minmax(360px, 1fr); height: calc(100dvh - var(--topbar-h, 61px) - 12px); padding-bottom: 12px; }
.ws-pane { min-width: 0; min-height: 0; }
.ws-left { display: flex; flex-direction: column; overflow: hidden; }
.ws-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.ws-right { display: grid; grid-template-rows: minmax(140px, 1fr) 10px minmax(110px, var(--ws-bottom, 40%)); min-height: 0; }
.ws-right.collapsed { grid-template-rows: minmax(140px, 1fr) 10px 46px; }
.editor-panel, .console-panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 7px 8px 7px 10px; border-bottom: 1px solid var(--rule); }
.toolbar .file { font-family: var(--font-mono); font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toolbar .actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px; }
.editor-host { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--code-bg); }
.editor-host > .cm-editor { height: 100%; }
.engine-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 6px 12px; border-top: 1px solid var(--rule); font-size: 12.5px; color: var(--muted); }
.engine-strip .bar { flex: 1; max-width: 220px; }
.console-body { flex: 1; min-height: 0; overflow: auto; }
.splitter { display: grid; place-items: center; touch-action: none; user-select: none; cursor: col-resize; background: transparent; border: 0; padding: 0; }
.splitter::before { content: ''; display: block; width: 2px; height: 36px; border-radius: 2px; background: var(--rule); }
.splitter.rows { cursor: row-resize; }
.splitter.rows::before { width: 36px; height: 2px; }
.splitter:hover::before, .splitter:focus-visible::before, .splitter.dragging::before { background: var(--accent); }
.splitter:focus-visible { outline: none; }
.ws-switch { display: none; }
.problem-head { padding: 16px 20px 14px; border-bottom: 1px solid var(--rule); }
.problem-head h1 { margin: 6px 0 10px; }
.problem-body { padding: 18px 20px 28px; }
.sig { padding: 10px 14px; border: 1px dashed var(--strong); border-radius: var(--radius-sm); font-family: var(--font-mono); font-stretch: var(--mono-stretch); font-size: var(--fs-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: 104px minmax(0, 1fr); margin: 0; border-top: 1px solid var(--rule); }
.facts dt { padding: 9px 0; border-bottom: 1px solid var(--rule); }
.facts dd { margin: 0; padding: 9px 0 9px 8px; border-bottom: 1px solid var(--rule); min-width: 0; }
.example { border: 1px solid var(--rule); border-radius: var(--radius-sm); }
.example-head { display: flex; justify-content: space-between; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--rule); }
.example-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.example-grid > div { min-width: 0; padding: 10px 12px; }
.example-grid > div + div { border-left: 1px solid var(--rule); }
@media (max-width: 520px) { .example-grid > div + div { border-left: 0; border-top: 1px solid var(--rule); } }
.example .io { font-family: var(--font-mono); font-stretch: var(--mono-stretch); font-size: var(--fs-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.example .io .k { color: var(--muted); }
.example-note { padding: 8px 12px; border-top: 1px dashed var(--rule); color: var(--muted); font-size: 14px; }
.sql-table { border-collapse: collapse; font-family: var(--font-mono); font-size: 12px; }
.sql-table th, .sql-table td { padding: 3px 10px; border: 1px solid var(--rule); text-align: left; white-space: nowrap; }
.sql-table th { background: var(--panel-2); font-weight: 600; }
.sql-wrap { max-width: 100%; overflow-x: auto; }
.hint { border: 1px solid var(--rule); border-radius: var(--radius-sm); }
.hint-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--rule); }
.hint-body { padding: 10px 12px; }
.spoiler { display: grid; place-items: center; gap: 12px; padding: 36px 20px; border: 1px dashed var(--strong); border-radius: var(--radius-sm); text-align: center; }
.verdict { display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px; border: 2px solid currentColor; border-radius: var(--radius-sm); font-family: var(--font-mono); font-stretch: var(--mono-stretch); font-size: 13px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap; }
.verdict.small { padding: 1px 6px; border-width: 1px; font-size: 11px; letter-spacing: 0.06em; }
.result-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 14px; border-bottom: 1px solid var(--rule); }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(128px, 100%), 1fr)); gap: 14px; }
.metric .value { font-family: var(--font-display); font-stretch: var(--display-stretch); font-weight: var(--display-weight); font-size: 24px; line-height: 1.2; }
.metric .sub { font-size: 12.5px; color: var(--muted); }
.tchips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tchip { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 3px 8px; border: 1px solid transparent; border-radius: var(--radius-sm); background: var(--panel-2); color: var(--muted); font-family: var(--font-mono); font-stretch: var(--mono-stretch); font-size: 11.5px; cursor: pointer; }
.tchip.pass { background: var(--pass-soft); color: var(--pass); }
.tchip.fail { background: var(--fail-soft); color: var(--fail); }
.tchip.warn { background: var(--warn-soft); color: var(--warn); }
.tchip.running { border-color: var(--accent); border-style: dashed; color: var(--ink); }
.tchip[aria-pressed="true"] { border-color: currentColor; border-style: solid; }
.tchip .t { opacity: 0.8; }
.detail { border: 1px solid var(--rule); border-radius: var(--radius-sm); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.detail-grid > section { min-width: 0; padding: 10px 12px; border-top: 1px solid var(--rule); }
.detail-grid pre { margin: 4px 0 0; font-family: var(--font-mono); font-stretch: var(--mono-stretch); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 240px; overflow: auto; }
.diag { margin: 0; padding: 12px 14px; max-height: 340px; overflow: auto; background: var(--code-bg); color: var(--code-ink); font-family: var(--font-mono); font-stretch: var(--mono-stretch); font-size: 12px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--code-rule); border-radius: var(--radius-sm); }
.case-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.case-view { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); border: 1px solid var(--rule); border-radius: var(--radius-sm); }
.case-view > div { min-width: 0; padding: 10px 12px; }
.case-view > div + div { border-left: 1px solid var(--rule); }
@media (max-width: 520px) { .case-view > div + div { border-left: 0; border-top: 1px solid var(--rule); } }
.case-view .io { font-family: var(--font-mono); font-stretch: var(--mono-stretch); font-size: var(--fs-mono); white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.case-view .io .k { color: var(--muted); }
.case-tab { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: transparent; color: var(--muted); font-family: var(--font-mono); font-size: 12px; cursor: pointer; }
.case-tab[aria-selected="true"] { border-color: var(--strong); color: var(--ink); background: var(--panel-2); }
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--font-mono); font-stretch: var(--mono-stretch); font-size: 9px; fill: var(--muted); }
.probe-grid { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1280px) { .probe-grid { grid-template-columns: minmax(0, 1fr); } .probe-chart { max-width: 460px; } }
.probe-chart { margin: 0; padding: 8px 10px 6px; border: 1px solid var(--rule); border-radius: var(--radius-sm); }
.probe-chart figcaption { margin-top: 4px; }
@media (max-width: 1023px) {
  .ws { display: block; height: auto; padding-bottom: 0; }
  .ws > .splitter, .ws-right > .splitter { display: none; }
  .ws-switch { display: flex; position: sticky; top: var(--topbar-h, 61px); z-index: 20; margin-bottom: 10px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); }
  .ws-switch .tab { flex: 1; justify-content: center; }
  .ws-switch .tab:last-child { border-right: 0; }
  .ws-pane.off { display: none; }
  .ws-left { overflow: visible; }
  .ws-scroll { overflow: visible; }
  .ws-right { display: flex; flex-direction: column; gap: 12px; }
  .editor-host { flex: none; height: max(360px, 64dvh); }
  .console-panel { min-height: 260px; }
}

/* ---------- MCQ ---------- */
.quiz { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .quiz { grid-template-columns: minmax(0, 1fr); } }
@media (hover: none) { .keys-hint { display: none !important; } }
.quiz-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 14px; border-bottom: 1px solid var(--rule); }
.timer { font-family: var(--font-mono); font-stretch: var(--mono-stretch); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer.low { color: var(--fail); }
.q-prompt { font-size: 17px; font-weight: 600; line-height: 1.5; }
.q-prompt.md { max-width: none; }
.q-prompt.md p:last-child { margin-bottom: 0; }
.opts { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.opt { position: relative; display: flex; align-items: flex-start; gap: 12px; min-height: 48px; padding: 11px 12px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--panel); color: var(--ink); cursor: pointer; }
.opt:hover { border-color: var(--strong); }
.opt input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.opt:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.opt .key { flex: none; min-width: 22px; font-family: var(--font-mono); font-size: 12px; line-height: 1.9; color: var(--muted); }
.opt .txt { flex: 1; min-width: 0; }
.opt .txt p { margin: 0; }
.opt .mark { flex: none; font-family: var(--font-mono); font-size: 12px; line-height: 1.9; }
.opt.selected { border-color: var(--accent); background: var(--accent-soft); }
.opt.selected .key { color: var(--accent); }
.opt.right { border-color: var(--pass); background: var(--pass-soft); color: var(--pass); }
.opt.wrong { border-color: var(--fail); background: var(--fail-soft); color: var(--fail); }
.opt.right .key, .opt.wrong .key { color: inherit; }
.opt.dim { opacity: 0.62; }
.opt.locked { cursor: default; }
.explain { padding-top: 12px; border-top: 1px dashed var(--rule); }
.qpal { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
.qpal button { position: relative; height: 38px; padding: 0; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: transparent; color: var(--ink); font-family: var(--font-mono); font-size: 12px; cursor: pointer; }
.qpal button:hover { border-color: var(--strong); }
.qpal .answered { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.qpal .right { background: var(--pass-soft); border-color: var(--pass); color: var(--pass); }
.qpal .wrong { background: var(--fail-soft); border-color: var(--fail); color: var(--fail); }
.qpal .current { outline: 2px solid var(--accent); outline-offset: 1px; }
.qpal .flagged::after { content: ''; position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; border: 1px solid var(--rule); vertical-align: -1px; }
.score-big { font-family: var(--font-display); font-stretch: var(--display-stretch); font-weight: var(--display-weight); font-size: clamp(40px, 6vw, 64px); line-height: 1; }
.topic-bars { display: grid; gap: 8px; }
.topic-bars .row { flex-wrap: nowrap; }
.topic-bars .bar { flex: 1; height: 6px; }

/* ---------- mock OA ---------- */
.mock-bar { position: sticky; top: var(--topbar-h, 61px); z-index: 25; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 12px; margin-bottom: 10px; background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); }
.mock-items { display: flex; flex-wrap: wrap; gap: 6px; }
.mock-item { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 10px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: transparent; color: var(--muted); font-family: var(--font-mono); font-size: 12px; cursor: pointer; }
.mock-item[aria-current="true"] { border-color: var(--strong); color: var(--ink); background: var(--panel-2); }
.mock-item.done { color: var(--pass); border-color: var(--pass); }
.mock-item.tried { color: var(--warn); }
.page.wide .ws { height: calc(100dvh - var(--topbar-h, 61px) - var(--mockbar-h, 0px) - 12px); }

.how-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 8px 24px; }
.how-cols > p { margin: 0; }

/* ---------- sheets ---------- */
.sheet-section > summary { list-style: none; cursor: pointer; }
.sheet-section > summary::-webkit-details-marker { display: none; }
.sheet-section:not([open]) > summary { border-bottom: 0; }
.sheet-caret { display: inline-grid; place-items: center; width: 18px; color: var(--muted); }
.sheet-caret svg { transition: transform 0.15s ease; }
.sheet-section[open] .sheet-caret svg { transform: rotate(90deg); }
.sheet-bar { width: 140px; flex: none; }
.sheet-table td { vertical-align: middle; }
.ext-link { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; font-family: var(--font-mono); font-stretch: var(--mono-stretch); font-size: 12px; }
@media (max-width: 640px) { .sheet-bar { display: none; } }

/* ---------- add content ---------- */
.prompt-box { position: relative; }
.prompt-box .code { max-height: 520px; white-space: pre-wrap; font-size: 12.5px; }
.steps { counter-reset: step; list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.steps > li { position: relative; padding-left: 44px; min-height: 32px; }
.steps > li::before { counter-increment: step; content: counter(step, decimal-leading-zero); position: absolute; left: 0; top: 0; width: 32px; height: 28px; display: grid; place-items: center; border: 1px solid var(--strong); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: 11.5px; }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
details.disclosure > summary { cursor: pointer; list-style: none; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::before { content: '+'; display: inline-block; width: 1.2em; font-family: var(--font-mono); color: var(--muted); }
details.disclosure[open] > summary::before { content: '–'; }
.filters-toggle { display: none; }
@media (max-width: 860px) {
  .filters-toggle { display: inline-flex; }
  .filters:not(.open) .filters-body { display: none; }
}
.notice-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--warn); background: var(--warn-soft); border-radius: var(--radius-sm); }
.blank-gap { height: 1px; }
