/* Nucleus – UI modelled on VS Code "Light Modern" / "Dark Modern". Flat, dense, no decoration. */
:root {
  --bg: #ffffff;            /* editor */
  --bg-side: #f8f8f8;       /* sidebar, title bar, status bar */
  --panel: #f8f8f8;         /* cards / widgets */
  --input: #ffffff;
  --hover: #f2f2f2;
  --active: #e4e6f1;
  --border: #e5e5e5;
  --border-strong: #cecece;
  --text: #3b3b3b;
  --text-strong: #1f1f1f;
  --muted: #6e6e6e;
  --accent: #005fb8;
  --accent-hover: #0258a8;
  --accent-soft: rgba(0, 95, 184, .08);
  --link: #005fb8;
  --ok: #1a7f37;
  --warn: #9a6700;
  --bad: #c4314b;
  --info: #005fb8;
  --focus: #005fb8;
  --code-bg: #f3f3f3;
  --shadow: 0 2px 8px rgba(0, 0, 0, .12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI", system-ui, Ubuntu, "Droid Sans", sans-serif;
  --mono: "Cascadia Code", Consolas, "SF Mono", Menlo, "Ubuntu Mono", "DejaVu Sans Mono", monospace;
  --r: 4px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1f1f1f; --bg-side: #181818; --panel: #181818; --input: #313131; --hover: #2a2d2e; --active: #37373d;
    --border: #2b2b2b; --border-strong: #3c3c3c; --text: #cccccc; --text-strong: #e7e7e7; --muted: #9d9d9d;
    --accent: #0078d4; --accent-hover: #026ec1; --accent-soft: rgba(0, 120, 212, .14); --link: #4daafc;
    --ok: #2ea043; --warn: #d29922; --bad: #f85149; --info: #3794ff; --focus: #0078d4; --code-bg: #2b2b2b;
    --shadow: 0 2px 8px rgba(0, 0, 0, .36);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1f1f1f; --bg-side: #181818; --panel: #181818; --input: #313131; --hover: #2a2d2e; --active: #37373d;
  --border: #2b2b2b; --border-strong: #3c3c3c; --text: #cccccc; --text-strong: #e7e7e7; --muted: #9d9d9d;
  --accent: #0078d4; --accent-hover: #026ec1; --accent-soft: rgba(0, 120, 212, .14); --link: #4daafc;
  --ok: #2ea043; --warn: #d29922; --bad: #f85149; --info: #3794ff; --focus: #0078d4; --code-bg: #2b2b2b;
  --shadow: 0 2px 8px rgba(0, 0, 0, .36);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font);
  display: flex; flex-direction: column; overflow-x: hidden; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--text-strong); font-weight: 600; line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 .9em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
code, kbd, .mono { font-family: var(--mono); font-size: 13px; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 3px; }
:focus-visible { outline: 1px solid var(--focus); outline-offset: 1px; }
::selection { background: var(--accent-soft); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
@media (max-width: 1000px) { .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .split { grid-template-columns: 1fr; } }
@media (max-width: 680px) { .cols-2, .cols-3 { grid-template-columns: 1fr; } }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* Title bar ---------------------------------------------------------------- */
.titlebar { height: 44px; display: flex; align-items: center; gap: 16px; padding: 0 16px; background: var(--bg-side);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text-strong); font-weight: 600; font-size: 14px; }
.brand:hover { text-decoration: none; }
.brand svg { width: 20px; height: 20px; color: var(--accent); }
.topnav { display: flex; gap: 2px; margin-left: 8px; }
.topnav a { color: var(--text); padding: 4px 10px; border-radius: var(--r); font-size: 13px; }
.topnav a:hover, .topnav a.active { background: var(--hover); text-decoration: none; }
.titlebar .spacer { flex: 1; }
.titlebar .menu-toggle { display: none; }
@media (max-width: 800px) {
  .topnav { display: none; }
  .titlebar .menu-toggle { display: inline-flex; }
}

/* Buttons & inputs ----------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 28px; padding: 0 12px;
  border-radius: var(--r); border: 1px solid var(--border-strong); background: var(--input); color: var(--text);
  font: 13px/1 var(--font); cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: var(--hover); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--hover); }
.btn-lg { height: 34px; padding: 0 16px; font-size: 14px; }
.btn-block { width: 100%; }
.icon-btn { width: 28px; padding: 0; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field > label, .field > .label-text { font-size: 13px; color: var(--text-strong); }
.hint { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; min-height: 28px; padding: 4px 8px; border-radius: var(--r);
  border: 1px solid var(--border-strong); background: var(--input); color: var(--text); font: 13px/1.4 var(--font); }
.input:focus { outline: 1px solid var(--focus); outline-offset: -1px; border-color: var(--focus); }
textarea.input { resize: vertical; min-height: 100px; line-height: 1.6; padding: 8px 10px; }
.check { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; font-size: 13px; line-height: 1.5; }
.check input { margin: 2px 0 0; accent-color: var(--accent); width: 15px; height: 15px; flex: none; }
.form-error { display: none; border: 1px solid var(--bad); color: var(--bad); background: transparent; border-radius: var(--r);
  padding: 6px 10px; font-size: 13px; margin-bottom: 12px; }
.form-error.show { display: block; }
.notice { border: 1px solid var(--border); border-left: 3px solid var(--info); background: var(--panel); padding: 8px 12px;
  border-radius: var(--r); font-size: 13px; }
.notice.ok { border-left-color: var(--ok); }
.notice.warn { border-left-color: var(--warn); }
.notice.bad { border-left-color: var(--bad); }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r); overflow: hidden; }
.segmented a, .segmented label span { display: block; padding: 3px 12px; font-size: 13px; color: var(--text); cursor: pointer; }
.segmented a + a, .segmented label + label span { border-left: 1px solid var(--border-strong); }
.segmented a:hover, .segmented label span:hover { background: var(--hover); text-decoration: none; }
.segmented .active, .segmented input:checked + span { background: var(--accent); color: #fff; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; display: inline-block; width: 34px; height: 18px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--border-strong); border-radius: 9px; cursor: pointer; transition: .15s; }
.switch .slider::before { content: ""; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(16px); }
.switch input:focus-visible + .slider { outline: 1px solid var(--focus); outline-offset: 2px; }
.setting { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: 0; }
.setting .desc { font-size: 12px; color: var(--muted); }
.code-input { display: flex; gap: 6px; }
.code-input input { width: 38px; height: 44px; text-align: center; font: 600 20px var(--mono); border-radius: var(--r);
  border: 1px solid var(--border-strong); background: var(--input); color: var(--text-strong); }
.code-input input:focus { outline: 1px solid var(--focus); outline-offset: -1px; border-color: var(--focus); }

/* Panels, tables, badges ------------------------------------------------------ */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 16px; min-width: 0; }
.panel.flush { padding: 0; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--border); }
.panel-head h2, .panel-head h3 { margin: 0; font-size: 13px; }
.panel-body { padding: 16px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.stat .value { font-size: 22px; font-weight: 600; color: var(--text-strong); font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .sub { font-size: 12px; color: var(--muted); }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 6px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 7px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--hover); }
.table tr.me td { background: var(--accent-soft); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; }
.badge { display: inline-block; padding: 0 6px; border-radius: 3px; font-size: 11px; line-height: 18px; font-weight: 600;
  border: 1px solid var(--border-strong); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: currentColor; }
.badge.warn { color: var(--warn); border-color: currentColor; }
.badge.bad { color: var(--bad); border-color: currentColor; }
.badge.info { color: var(--info); border-color: currentColor; }
.badge.solid { background: var(--accent); border-color: var(--accent); color: #fff; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); vertical-align: 0; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }
.bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff;
  font-size: 11px; line-height: 18px; text-align: center; font-weight: 600; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.prompt { border-left: 3px solid var(--accent); background: var(--panel); padding: 10px 14px; border-radius: 0 var(--r) var(--r) 0; }
.list-item { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 8px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--hover); text-decoration: none; }
.topic-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--c, var(--accent)); vertical-align: 0; margin-right: 6px; }

/* App layout: sidebar + content + status bar --------------------------------- */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); flex: 1; min-height: 0; }
.sidebar { background: var(--bg-side); border-right: 1px solid var(--border); padding: 8px 0 16px; position: sticky; top: 44px;
  height: calc(100vh - 44px - 22px); overflow-y: auto; }
.sidebar .section { padding: 12px 16px 4px; }
.sidebar a { display: flex; align-items: center; gap: 8px; padding: 4px 16px 4px 20px; color: var(--text); font-size: 13px; line-height: 20px; }
.sidebar a:hover { background: var(--hover); text-decoration: none; }
.sidebar a.active { background: var(--active); color: var(--text-strong); box-shadow: inset 2px 0 0 var(--accent); }
.sidebar a .count { margin-left: auto; }
.content { padding: 24px 32px 48px; min-width: 0; }
.content.narrow { max-width: 780px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.statusbar { height: 22px; background: var(--bg-side); border-top: 1px solid var(--border); display: flex; align-items: center;
  gap: 16px; padding: 0 12px; font-size: 12px; color: var(--muted); position: sticky; bottom: 0; z-index: 30; }
.statusbar .spacer { flex: 1; }
.statusbar a { color: var(--muted); }
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 44px; bottom: 0; width: 240px; height: auto; z-index: 50; transform: translateX(-100%);
    transition: transform .15s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .content { padding: 16px; }
  .statusbar .hide-sm { display: none; }
}

/* Workspace navigation position (Settings → Workspace layout) -------------------- */
.shell.nav-right { grid-template-columns: minmax(0, 1fr) 220px; }
.shell.nav-right .sidebar { order: 2; border-right: 0; border-left: 1px solid var(--border); }
.shell.nav-right .sidebar a.active { box-shadow: inset -2px 0 0 var(--accent); }
.shell.nav-top, .shell.nav-bottom { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
.shell.nav-bottom { grid-template-rows: minmax(0, 1fr) auto; }
.shell.nav-top .sidebar, .shell.nav-bottom .sidebar {
  position: sticky; display: flex; align-items: center; gap: 2px; height: auto; width: auto; padding: 4px 12px;
  overflow-x: auto; overflow-y: hidden; white-space: nowrap; border-right: 0; transform: none; left: auto; right: auto;
  box-shadow: none; z-index: 20; scrollbar-width: thin; }
.shell.nav-top .sidebar { top: 44px; bottom: auto; border-bottom: 1px solid var(--border); }
.shell.nav-bottom .sidebar { order: 2; top: auto; bottom: 22px; border-top: 1px solid var(--border); }
.shell.nav-top .sidebar .section, .shell.nav-bottom .sidebar .section { width: 1px; height: 18px; padding: 0; margin: 0 6px;
  background: var(--border); font-size: 0; flex: none; }
.shell.nav-top .sidebar .section:first-child, .shell.nav-bottom .sidebar .section:first-child { display: none; }
.shell.nav-top .sidebar a, .shell.nav-bottom .sidebar a { flex: none; padding: 4px 10px; border-radius: 4px; }
.shell.nav-top .sidebar a.active { box-shadow: inset 0 -2px 0 var(--accent); }
.shell.nav-bottom .sidebar a.active { box-shadow: inset 0 2px 0 var(--accent); }
body.nav-top .titlebar .menu-toggle, body.nav-bottom .titlebar .menu-toggle { display: none; }
@media (min-width: 801px) {  /* wide screens: wrap onto a second line instead of hiding entries */
  .shell.nav-top .sidebar, .shell.nav-bottom .sidebar { flex-wrap: wrap; row-gap: 2px; overflow: visible; }
}
@media (max-width: 800px) {
  .shell.nav-right .sidebar { left: auto; right: 0; transform: translateX(100%); }
  .shell.nav-right .sidebar.open { transform: none; }
}
/* Hidden navigation bar (per-user preference). The sidebar slides in on demand via the header menu button. */
.shell.nav-hidden { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.shell.nav-hidden > .sidebar { position: fixed; left: 0; top: 44px; bottom: 0; width: 240px; height: auto; z-index: 60;
  transform: translateX(-100%); transition: transform .15s ease; border-right: 1px solid var(--border); overflow-y: auto; }
.shell.nav-hidden > .sidebar.open { transform: none; box-shadow: 2px 0 18px rgba(0, 0, 0, .3); }
body.nav-hidden .titlebar .menu-toggle { display: inline-flex; }
.nav-order { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 4px; }
.nav-order li { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.nav-order li:last-child { border-bottom: 0; }
.nav-order li .grow { flex: 1; }
.nav-order .icon-btn { padding: 2px 6px; min-width: 0; }
.tool-note { margin-bottom: 4px; }
pre.code { margin: 4px 0 12px; padding: 8px 10px; background: var(--bg-side); border: 1px solid var(--border); border-radius: 4px;
  font: 12px/1.5 var(--mono); overflow-x: auto; white-space: pre; }
.keybox { display: flex; gap: 8px; align-items: center; }
.keybox code { flex: 1; word-break: break-all; padding: 6px 8px; background: var(--bg-side); border: 1px solid var(--border); border-radius: 4px; }

/* Public pages ----------------------------------------------------------------- */
.page { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.page.narrow { max-width: 760px; }
.page.tiny { max-width: 400px; }
main.public { flex: 1; padding: 40px 0 64px; }
.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 40px; align-items: center; padding: 24px 0 48px; }
.hero h1 { font-size: 34px; line-height: 1.2; letter-spacing: -.01em; margin-bottom: 14px; }
.hero .lead { font-size: 16px; color: var(--text); max-width: 560px; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; gap: 24px; } .hero h1 { font-size: 28px; } }
.terminal { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; font: 13px/1.7 var(--mono); }
.terminal .tabs { display: flex; border-bottom: 1px solid var(--border); background: var(--bg-side); font: 12px var(--font); }
.terminal .tabs span { padding: 6px 14px; border-right: 1px solid var(--border); color: var(--muted); }
.terminal .tabs span.on { color: var(--text-strong); background: var(--panel); box-shadow: inset 0 1px 0 var(--accent); }
.terminal pre { margin: 0; padding: 14px 16px; overflow-x: auto; color: var(--text); }
.terminal .k { color: var(--muted); }
.terminal .v { color: var(--text-strong); }
.terminal .g { color: var(--ok); }
.section-title { font-size: 18px; margin: 48px 0 6px; }
.section-intro { color: var(--muted); margin: 0 0 18px; max-width: 640px; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 32px; }
.steps li { counter-increment: s; padding-left: 36px; position: relative; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 1px; width: 22px; height: 22px; border: 1px solid var(--border-strong);
  border-radius: 50%; font-size: 12px; display: grid; place-items: center; color: var(--muted); }
.steps strong { color: var(--text-strong); display: block; }
@media (max-width: 680px) { .steps { grid-template-columns: 1fr; } }
details.faq { border-bottom: 1px solid var(--border); padding: 10px 0; }
details.faq summary { cursor: pointer; color: var(--text-strong); }
details.faq p { margin: 8px 0 0; color: var(--muted); }
footer.site { border-top: 1px solid var(--border); background: var(--bg-side); padding: 16px 0; font-size: 12px; color: var(--muted); }
footer.site .page { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
footer.site a { color: var(--muted); margin-left: 14px; }
.auth-card { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 24px; }
.auth-card h1 { font-size: 20px; }
.prose { max-width: 760px; }
.prose h2 { margin-top: 1.6em; font-size: 16px; }
.prose h3 { margin-top: 1.2em; font-size: 14px; }
.prose p, .prose li { color: var(--text); }
.banner { background: var(--accent); color: #fff; font-size: 13px; text-align: center; padding: 4px 12px; }

/* Tasks, editor, review ---------------------------------------------------- */
.tasklist .list-item { align-items: flex-start; }
.tasklist .title { color: var(--text-strong); }
.tasklist .desc { font-size: 12px; color: var(--muted); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.editor { min-height: 300px; font: 14px/1.7 var(--font); }
.editor-bar { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.steps-v { list-style: none; margin: 0; padding: 0; }
.steps-v li { display: flex; gap: 10px; align-items: center; padding: 6px 0; font-size: 13px; }
.steps-v .st { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--border-strong); flex: none; }
.steps-v li.run .st { border-color: var(--accent); border-right-color: transparent; animation: spin .8s linear infinite; }
.steps-v li.done .st { background: var(--ok); border-color: var(--ok); }
.steps-v li.fail .st { background: var(--bad); border-color: var(--bad); }
.marked { white-space: pre-wrap; line-height: 1.8; font-size: 14px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; }
mark.err { background: transparent; color: inherit; text-decoration: underline wavy var(--bad); text-underline-offset: 3px; cursor: pointer; }
mark.err.grammar { text-decoration-color: var(--warn); }
mark.err.fixed { text-decoration: underline solid var(--ok); }
.issue { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.issue:last-child { border-bottom: 0; }
.issue .fix { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.check-row { border-left: 3px solid var(--border-strong); padding: 8px 12px; background: var(--panel); border-radius: 0 var(--r) var(--r) 0; }
.check-row.pass { border-left-color: var(--ok); }
.check-row.flag { border-left-color: var(--warn); }
.check-row.reject, .check-row.error { border-left-color: var(--bad); }
.check-row + .check-row { margin-top: 8px; }

/* Chat ------------------------------------------------------------------------ */
.chat { display: grid; grid-template-columns: 220px minmax(0, 1fr); border: 1px solid var(--border); border-radius: 6px;
  height: calc(100vh - 44px - 22px - 150px); min-height: 460px; overflow: hidden; background: var(--panel); }
.chat-side { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.chat-side .list { overflow-y: auto; flex: 1; }
.chat-side a { display: block; padding: 5px 12px; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-side a:hover { background: var(--hover); text-decoration: none; }
.chat-side a.active { background: var(--active); color: var(--text-strong); }
.chat-main { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.chat-log { flex: 1; overflow-y: auto; padding: 16px 20px; }
.msg { padding: 10px 0; border-bottom: 1px solid var(--border); white-space: pre-wrap; word-wrap: break-word; font-size: 14px; }
.msg:last-child { border-bottom: 0; }
.msg .who { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 2px; white-space: normal; }
.msg.typing .body::after { content: "▍"; color: var(--accent); animation: blink 1s steps(2) infinite; }
.chat-input { border-top: 1px solid var(--border); padding: 10px; display: flex; gap: 8px; align-items: flex-end; }
.chat-input textarea { min-height: 34px; max-height: 160px; resize: none; }
@media (max-width: 800px) { .chat { grid-template-columns: 1fr; height: auto; } .chat-side { border-right: 0; border-bottom: 1px solid var(--border); max-height: 160px; } .chat-main { height: 60vh; } }
.chat.fullscreen { position: fixed; inset: 0; z-index: 80; height: 100vh; min-height: 0; border: 0; border-radius: 0; }
body.chat-fs { overflow: hidden; }
@media (max-width: 800px) { .chat.fullscreen { grid-template-columns: 1fr; } .chat.fullscreen .chat-main { height: auto; flex: 1; } }

/* Charts ------------------------------------------------------------------------ */
.chart { width: 100%; height: 200px; display: block; }
.chart .axis { stroke: var(--border); }
.chart text { fill: var(--muted); font: 11px var(--font); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 1.8; }
.chart .line.alt { stroke: var(--ok); }
.chart .area { fill: var(--accent-soft); }
.chart .bar { fill: var(--accent); }
.chart .bar.alt { fill: var(--ok); }
.chart .dot { fill: var(--bg); stroke: var(--accent); stroke-width: 1.5; }
.chart-tip { position: fixed; pointer-events: none; background: var(--panel); border: 1px solid var(--border-strong); border-radius: var(--r);
  padding: 3px 8px; font-size: 12px; box-shadow: var(--shadow); z-index: 100; display: none; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 2px; margin-right: 5px; vertical-align: 3px; background: var(--accent); }
.legend i.alt { background: var(--ok); }

/* Overlays -------------------------------------------------------------------- */
.dropdown-wrap { position: relative; }
.dropdown { position: absolute; right: 0; top: calc(100% + 4px); min-width: 200px; background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: var(--r); box-shadow: var(--shadow); padding: 4px 0; display: none; z-index: 60; }
.dropdown.open { display: block; }
.dropdown a, .dropdown button { display: block; width: 100%; text-align: left; padding: 5px 14px; font: 13px var(--font); color: var(--text);
  background: none; border: 0; cursor: pointer; }
.dropdown a:hover, .dropdown button:hover { background: var(--accent); color: #fff; text-decoration: none; }
.dropdown .head { padding: 6px 14px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; font-size: 12px; color: var(--muted); }
.dropdown .head strong { color: var(--text-strong); font-size: 13px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--input); color: var(--text-strong);
  font: 600 11px var(--font); cursor: pointer; display: grid; place-items: center; }
.toasts { position: fixed; bottom: 32px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: calc(100vw - 32px); }
.toast { background: var(--panel); border: 1px solid var(--border-strong); border-left: 3px solid var(--info); border-radius: var(--r);
  padding: 8px 12px; font-size: 13px; box-shadow: var(--shadow); max-width: 380px; }
.toast.ok { border-left-color: var(--ok); }
.toast.bad { border-left-color: var(--bad); }
dialog.modal { border: 1px solid var(--border-strong); border-radius: 6px; background: var(--panel); color: var(--text); padding: 0;
  width: min(480px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog.modal::backdrop { background: rgba(0, 0, 0, .4); }
dialog.modal .body { padding: 18px 20px; }
dialog.modal h2 { font-size: 15px; }
dialog.modal .foot { padding: 10px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

.spinner { width: 12px; height: 12px; border: 1.5px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: 0; } }
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }
.compact .content { padding: 16px 20px 32px; }
.compact .panel { padding: 12px; }
.compact .table td { padding: 4px 10px; }
.issue .badge { align-self: flex-start; }
.chip-btn { height: auto; min-height: 22px; padding: 2px 8px; font-size: 12px; line-height: 1.35; white-space: normal; text-align: left; }

/* --- Community: pictures, profiles, friends, support ------------------------------------ */
.avatar { overflow: hidden; padding: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-img { border-radius: 50%; flex: none; object-fit: cover; display: inline-block; vertical-align: middle; background: var(--input); }
.avatar-img.initials { display: inline-grid; place-items: center; font-weight: 600; color: #fff; line-height: 1;
  background: hsl(var(--hue) 42% 40%); user-select: none; }
.who { display: inline-flex; align-items: center; gap: 8px; min-width: 0; color: inherit; }
.who span, .who a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.who:hover span { text-decoration: underline; }
.profile-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.profile-head h1 { margin: 0 0 4px; font-size: 22px; word-break: break-word; }
.profile-actions { display: flex; gap: 8px; }
.rel-badges { margin-top: 6px; }
.profile .bio { margin: 14px 0 0; word-break: break-word; }
.profile-stats { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.profile-stats div { display: flex; flex-direction: column; }
.profile-stats strong { font-size: 18px; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.profile-stats span { font-size: 12px; color: var(--muted); }
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 12px; }
.person { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--text); min-width: 0; text-align: center; }
.person span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person:hover { text-decoration: none; color: var(--text-strong); }
.people-list { display: flex; flex-direction: column; }
.person-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.person-row:last-child { border-bottom: 0; }
#search-results:not(:empty) { margin-top: 8px; }
.big-num { font-size: 20px; color: var(--text-strong); }
.plain-list { margin: 0; padding-left: 18px; }
.plain-list li { margin: 4px 0; }
.goal { margin: 12px 0 4px; }
.goal-bar { height: 10px; border-radius: 5px; background: var(--input); border: 1px solid var(--border); overflow: hidden; margin-bottom: 6px; }
.goal-bar span { display: block; height: 100%; background: var(--accent); }
.avatar-editor { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.crop { display: grid; gap: 10px; justify-items: center; }
.crop canvas { width: 240px; height: 240px; max-width: 100%; border-radius: 50%; cursor: grab; touch-action: none;
  background: repeating-conic-gradient(var(--input) 0 25%, var(--panel) 0 50%) 50% / 16px 16px; }
.crop canvas:active { cursor: grabbing; }
.crop input[type="range"] { width: 100%; accent-color: var(--accent); }
.bio-count { font-size: 12px; color: var(--muted); }
@media (max-width: 600px) { .profile-actions { width: 100%; } .profile-actions .btn { flex: 1; } }

/* --- Chat: Markdown answers, thoughts, actions, comparisons ------------------------------------------------- */
.msg.assistant .body { white-space: normal; line-height: 1.6; }
.msg.assistant .body > :first-child { margin-top: 0; }
.msg.assistant .body > :last-child { margin-bottom: 0; }
.msg.assistant .body p { margin: 0 0 8px; }
.msg.assistant .body ul, .msg.assistant .body ol { margin: 0 0 8px; padding-left: 22px; }
.msg.assistant .body li { margin: 2px 0; }
.msg.assistant .body blockquote { margin: 0 0 8px; padding: 2px 12px; border-left: 3px solid var(--border-strong); color: var(--muted); }
.msg.assistant .body hr { border: 0; border-top: 1px solid var(--border); margin: 10px 0; }
.msg.assistant .body .md-h { margin: 12px 0 6px; font-size: 14px; color: var(--text-strong); }
.msg.assistant .body h3.md-h { font-size: 16px; }
.msg.assistant .body a { word-break: break-word; }
.codeblock { margin: 0 0 8px; border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; background: var(--code-bg); }
.codeblock-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 2px 10px;
  font: 11px var(--mono); color: var(--muted); border-bottom: 1px solid var(--border); }
.codeblock pre { margin: 0; padding: 10px 12px; overflow-x: auto; white-space: pre; font: 13px/1.5 var(--mono); }
.codeblock code { background: none; padding: 0; }
.md-table-wrap { overflow-x: auto; margin: 0 0 8px; }
.md-table { border-collapse: collapse; font-size: 13px; }
.md-table th, .md-table td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; vertical-align: top; }
.md-table th { background: var(--panel); color: var(--text-strong); }
.btn-xs { height: 24px; padding: 0 8px; font-size: 12px; }
.btn-xs .icon { width: 14px; height: 14px; }
.msg-actions { display: flex; gap: 2px; margin-top: 4px; white-space: normal; opacity: .75; }
.msg:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
.msg-actions .btn.active { color: var(--accent); background: var(--accent-soft); }
.msg-actions .thumb-down .icon { transform: rotate(180deg); }
.thoughts { margin: 2px 0 6px; font-size: 13px; white-space: normal; }
.thoughts summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.thoughts-body { white-space: pre-wrap; color: var(--muted); border-left: 2px solid var(--border-strong); padding: 4px 10px; margin-top: 4px; }
.compare-bar, .reason-form, .edit-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--r); background: var(--panel); white-space: normal; }
.reason-form, .edit-form { flex-direction: column; align-items: stretch; }
.compare-bar .small { margin-right: 4px; color: var(--text-strong); }
.msg.filtered .body { color: var(--muted); font-style: italic; }
.msg.error .body { opacity: .7; }

/* --- Tasks: conversations, answers to improve, code ------------------------------------------------------- */
.turn { white-space: pre-wrap; word-wrap: break-word; font-size: 14px; padding: 8px 12px; border-radius: var(--r); border: 1px solid var(--border);
  background: var(--bg); margin-bottom: 6px; }
.turn .who { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 2px; text-transform: uppercase; letter-spacing: .03em; }
.turn.user { background: var(--panel); }
.turn.assistant { border-left: 3px solid var(--accent); }
.turn.lose { border-left-color: var(--warn); }
.turn.win { border-left-color: var(--ok); }
.editor.code, .marked.code-answer { font: 13px/1.6 var(--mono); tab-size: 4; }
.eval-result { padding: 6px 0; border-bottom: 1px solid var(--border); }
.eval-result:last-child { border-bottom: 0; }
.feedback-item .grid { margin-top: 0; }

/* --- API documentation ------------------------------------------------------------------------------------- */
.docs h3 { font-size: 13px; margin: 12px 0 6px; color: var(--text-strong); }
.docs ol, .docs ul { padding-left: 20px; margin: 0 0 8px; }
.docs li { margin: 3px 0; }
.code-sample { margin: 0 0 8px; padding: 10px 12px; background: var(--code-bg); border: 1px solid var(--border);
  border-radius: var(--r); overflow-x: auto; white-space: pre; font: 12.5px/1.55 var(--mono); }
