/* rm-bridge design system: "ink on paper".
   Warm paper surfaces with a dot grid, ink-black primary actions, one ember accent,
   Instrument Serif for display type, Geist for the interface. Light by default. */

@font-face { font-family: "Geist"; src: url("../fonts/Geist-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("../fonts/GeistMono-Variable.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("../fonts/InstrumentSerif-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Instrument Serif"; src: url("../fonts/InstrumentSerif-Italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }

:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f2ec;
  --dot: #d9d5ca;
  --surface: #fdfcf8;
  --surface-2: #efece4;
  --sidebar: #f8f6f1;
  --border: #e3dfd4;
  --border-strong: #cfc9bb;
  --text: #17150f;
  --text-2: #57534a;
  --text-3: #686357;
  --ink: #17150f;
  --ink-hover: #36332b;
  --ink-text: #fdfcf8;
  --accent: #e2491f;
  --accent-hover: #c63c15;
  --accent-soft: #fbe7dd;
  --accent-text: #ffffff;
  --accent-ink: #b83a16;
  --ok: #18794e;
  --ok-soft: #e3f3ea;
  --warn: #9a5b00;
  --warn-soft: #fbefd5;
  --danger: #c42b1c;
  --danger-soft: #fbe5e1;
  --shadow: 0 1px 0 rgb(23 21 15 / 0.04), 0 1px 3px rgb(23 21 15 / 0.06);
  --shadow-lg: 0 1px 0 rgb(23 21 15 / 0.04), 0 12px 32px -12px rgb(23 21 15 / 0.18), 0 4px 10px -6px rgb(23 21 15 / 0.08);
  --glow: radial-gradient(60% 60% at 50% 0%, rgb(226 73 31 / 0.10), transparent 70%);
  --paper: #ffffff;
  --paper-line: #e9e6dd;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0b;
  --dot: #22221e;
  --surface: #151512;
  --surface-2: #1d1d19;
  --sidebar: #11110f;
  --border: #262621;
  --border-strong: #36362f;
  --text: #efede6;
  --text-2: #b3b0a5;
  --text-3: #8e8b82;
  --ink: #efede6;
  --ink-hover: #ffffff;
  --ink-text: #0d0d0b;
  --accent: #ff6b42;
  --accent-hover: #ff8a68;
  --accent-soft: #2e1710;
  --accent-text: #0d0d0b;
  --accent-ink: #ff8a68;
  --ok: #4ccb8a;
  --ok-soft: #0f2a1d;
  --warn: #f0b443;
  --warn-soft: #2c2009;
  --danger: #ff6f61;
  --danger-soft: #331512;
  --shadow: 0 1px 0 rgb(255 255 255 / 0.02), 0 1px 3px rgb(0 0 0 / 0.5);
  --shadow-lg: 0 1px 0 rgb(255 255 255 / 0.03), 0 16px 40px -12px rgb(0 0 0 / 0.7);
  --glow: radial-gradient(60% 60% at 50% 0%, rgb(255 107 66 / 0.12), transparent 70%);
  --paper: #f6f4ee;
  --paper-line: #e4e1d8;
}

:root {
  /* Paper stays light in both themes, so ink on it does too. */
  --paper-ink: #23211b;
  --paper-mute: #686357;
  --paper-dot: #dad7ce;
  --highlighter: rgb(255 107 66 / 0.35);
  --radius: 14px;
  --radius-sm: 8px;
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Instrument Serif", "Iowan Old Style", Charter, Georgia, serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, Consolas, monospace;
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --sidebar-w: 252px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.2px);
  background-size: 22px 22px;
  color: var(--text);
  font: 14.5px/1.55 var(--font);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-ink); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 var(--s3); letter-spacing: -0.015em; font-weight: 600; }
h1 { font-family: var(--serif); font-weight: 400; font-size: 2.7rem; letter-spacing: -0.01em; line-height: 1.05; }
h2 { font-size: 1rem; }
h3 { font-size: 0.92rem; }
p { margin: 0 0 var(--s3); }
em.ink { font-family: var(--serif); font-style: italic; color: var(--accent); font-weight: 400; }
code, pre, .mono { font-family: var(--mono); font-size: 0.85em; }
code { background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; color: var(--text); }
pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--s3) var(--s4);
  overflow-x: auto;
  margin: 0 0 var(--s3);
  line-height: 1.6;
}
pre code { background: none; border: 0; padding: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s5) 0; }
.muted { color: var(--text-3); }
.small { font-size: 0.84rem; }
.inline { display: inline; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::selection { background: var(--accent); color: var(--accent-text); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.ic { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ic-lg { width: 20px; height: 20px; }

/* App shell: slim sidebar + content */
.shell {
  display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh;
  /* Paint the sidebar column the full height of the page, not just the sticky viewport. */
  background:
    linear-gradient(var(--border), var(--border)) no-repeat calc(var(--sidebar-w) - 1px) 0 / 1px 100%,
    linear-gradient(var(--sidebar), var(--sidebar)) no-repeat 0 0 / var(--sidebar-w) 100%;
}
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: var(--s5);
  padding: var(--s5) var(--s4) var(--s4);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); padding: 0 var(--s2); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-mark .sheet { fill: var(--ink); }
.brand-mark .stroke { fill: none; stroke: var(--ink-text); stroke-width: 1.8; stroke-linecap: round; }
.brand-mark .spark { fill: var(--accent); }
.brand-word { font-family: var(--serif); font-size: 1.45rem; letter-spacing: -0.01em; line-height: 1; }
.brand-word i { color: var(--accent); font-style: normal; font-family: var(--font); font-weight: 700; margin: 0 1px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { font: 500 0.68rem/1 var(--mono); text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-3); padding: var(--s4) 10px var(--s2); }
.nav-group:first-child { padding-top: 0; }
.nav-link {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 0.9rem; font-weight: 450;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.nav-link .ic { color: var(--text-3); transition: color 0.15s var(--ease); }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--surface); color: var(--text); font-weight: 550; box-shadow: var(--shadow); }
.nav-link.active .ic { color: var(--accent); }
.nav-link.active::before {
  content: ""; position: absolute; left: -16px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}

.sidebar-foot { margin-top: auto; display: grid; gap: var(--s3); }
.me { display: flex; align-items: center; gap: 10px; padding: var(--s2); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.avatar {
  width: 32px; height: 32px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ink); color: var(--ink-text);
  font: 400 1.05rem/1 var(--serif);
}
.me-name { font-size: 0.85rem; font-weight: 550; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-sub { font-size: 0.74rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me { min-width: 0; }
.me-text { min-width: 0; flex: 1; }

.main { min-width: 0; display: flex; flex-direction: column; }
.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: var(--s7) var(--s6) var(--s7); flex: 1; }

/* Public pages: thin top bar */
.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: saturate(160%) blur(12px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1180px; margin: 0 auto; height: 64px; padding: 0 var(--s6); display: flex; align-items: center; gap: var(--s4); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }
.public-main { max-width: 1180px; margin: 0 auto; padding: 0 var(--s6); width: 100%; }
.footer {
  max-width: 1180px; width: 100%; margin: 0 auto; padding: var(--s5) var(--s6) var(--s6);
  display: flex; justify-content: space-between; gap: var(--s4); flex-wrap: wrap;
  color: var(--text-3); font: 0.78rem/1.4 var(--mono);
  border-top: 1px solid var(--border);
}

.icon-btn {
  width: 34px; height: 34px; flex: none;
  display: inline-grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-2); cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn .ic { width: 16px; height: 16px; }
#theme-toggle .ic { display: none; }
html[data-theme-choice="light"] #theme-toggle .i-light,
html:not([data-theme-choice]) #theme-toggle .i-light,
html[data-theme-choice="dark"] #theme-toggle .i-dark,
html[data-theme-choice="system"] #theme-toggle .i-system { display: block; }

/* Page head */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s5); margin-bottom: var(--s6); flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head p { margin: var(--s3) 0 0; color: var(--text-2); max-width: 62ch; }
.eyebrow {
  display: inline-flex; align-items: center; gap: var(--s2);
  font: 500 0.7rem/1 var(--mono); text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--accent-ink); margin-bottom: var(--s3);
}
.eyebrow::before { content: ""; width: 14px; height: 1.5px; background: currentColor; }
.crumb { display: inline-flex; align-items: center; gap: 6px; font-size: 0.84rem; color: var(--text-3); margin-bottom: var(--s4); }
.crumb:hover { color: var(--text); text-decoration: none; }

.stack > * + * { margin-top: var(--s5); }
.grid { display: grid; gap: var(--s4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.row { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.spacer { flex: 1; }
.section { margin-top: var(--s7); }
.section-head { display: flex; align-items: baseline; gap: var(--s3); margin-bottom: var(--s4); }
.section-head h2 { margin: 0; font-size: 1.05rem; }
.section-head .count { font: 0.78rem var(--mono); color: var(--text-3); }
.section-head a { margin-left: auto; font-size: 0.84rem; display: inline-flex; align-items: center; gap: 4px; }

/* Cards */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--s5);
}
.card > h2:first-child { margin-bottom: var(--s2); }
.card-sub { color: var(--text-2); font-size: 0.88rem; margin-bottom: var(--s4); }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.card-head h2 { margin: 0; font-size: 0.95rem; }
.card-icon {
  width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border); margin-bottom: var(--s4);
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  height: 36px; padding: 0 16px;
  border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-size: 0.88rem; font-weight: 550; letter-spacing: -0.005em; cursor: pointer; white-space: nowrap;
  background: var(--ink); color: var(--ink-text);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.12), inset 0 1px 0 rgb(255 255 255 / 0.08);
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.15s var(--ease), box-shadow 0.15s;
}
.btn:hover { background: var(--ink-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-accent { background: var(--accent); color: var(--accent-text); }
.btn-accent:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--border-strong); box-shadow: none; }
.btn-danger:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 0.82rem; }
.btn-lg { height: 46px; padding: 0 24px; font-size: 0.98rem; }
.btn .ic { width: 15px; height: 15px; }
.btn-arrow .ic:last-child { transition: transform 0.2s var(--ease); }
.btn-arrow:hover .ic:last-child { transform: translateX(3px); }

/* Forms */
.field { display: grid; gap: 6px; margin-bottom: var(--s4); }
.field label { font-weight: 550; font-size: 0.85rem; }
.field .help { color: var(--text-3); font-size: 0.8rem; }
.input, select.input, textarea.input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea.input { height: auto; padding: 10px 12px; font-family: var(--mono); font-size: 0.85rem; }
.input:hover { border-color: color-mix(in srgb, var(--text) 30%, var(--border-strong)); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.input-code { font: 500 1.2rem/1 var(--mono); letter-spacing: 0.32em; text-transform: uppercase; height: 52px; text-align: center; max-width: 280px; }
.check { display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.86rem; color: var(--text-2); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  width: 34px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; flex: none;
  transition: background 0.2s var(--ease);
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 2px rgb(0 0 0 / 0.25); transition: transform 0.2s var(--ease);
}
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.search {
  display: flex; align-items: center; gap: var(--s2);
  height: 40px; padding: 0 6px 0 14px; min-width: min(360px, 100%);
  border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); box-shadow: var(--shadow);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
.search .ic { color: var(--text-3); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; }

/* Badges, flash, callouts */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 999px; font: 500 0.72rem/1.6 var(--mono); letter-spacing: 0.02em;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.badge-warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.badge-danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.badge-accent { color: var(--accent-ink); background: var(--accent-soft); border-color: transparent; }

.flash {
  display: flex; align-items: flex-start; gap: var(--s3);
  padding: var(--s3) var(--s4); border-radius: var(--radius-sm); margin-bottom: var(--s5);
  border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); font-size: 0.9rem;
  animation: rise 0.35s var(--ease) both;
}
.flash .ic { margin-top: 2px; }
.flash-ok { border-color: color-mix(in srgb, var(--ok) 30%, transparent); background: var(--ok-soft); }
.flash-ok .ic { color: var(--ok); }
.flash-error { border-color: color-mix(in srgb, var(--danger) 30%, transparent); background: var(--danger-soft); }
.flash-error .ic { color: var(--danger); }
.callout {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); border-radius: var(--radius-sm); background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); margin-bottom: var(--s5);
}
.card.callout { display: block; padding: var(--s5); }
.secret { display: flex; gap: var(--s2); align-items: center; }
.secret input { font-family: var(--mono); font-size: 0.85rem; }

/* Tables & lists */
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th { text-align: left; font: 500 0.68rem/1 var(--mono); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.1em; background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.table th, .table td { padding: 12px var(--s5); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table a { color: var(--text); font-weight: 550; }
.table td.actions { text-align: right; width: 1%; white-space: nowrap; }
.table .empty-row td { text-align: center; color: var(--text-3); padding: var(--s6); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: var(--s3); align-items: baseline; padding: 11px 0; border-bottom: 1px dashed var(--border); }
.list li:last-child { border-bottom: 0; }
.empty { text-align: center; padding: var(--s7) var(--s5); color: var(--text-2); }
.empty h2 { color: var(--text); font: 400 1.9rem/1.15 var(--serif); letter-spacing: -0.01em; margin-bottom: var(--s2); }
.empty p { max-width: 52ch; margin-left: auto; margin-right: auto; }
.empty .btn { margin-top: var(--s3); }
.empty-art { width: 92px; height: 92px; margin: 0 auto var(--s5); display: block; }
.empty-art .sheet { fill: var(--paper); stroke: var(--border-strong); }
.empty-art .line { stroke: var(--border-strong); stroke-width: 2; stroke-linecap: round; fill: none; }
.empty-art .scribble { stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; fill: none; }

/* Dashboard: status panel */
.status-panel { display: grid; grid-template-columns: minmax(240px, 1.1fr) 2.4fr; padding: 0; overflow: hidden; }
.status-main { padding: var(--s5); border-right: 1px solid var(--border); background: var(--glow), var(--surface); display: flex; flex-direction: column; gap: var(--s2); }
.status-label { font: 500 0.68rem/1 var(--mono); text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-3); }
.status-value { font: 400 2.5rem/1 var(--serif); letter-spacing: -0.01em; margin-top: var(--s2); }
.pulse { position: relative; width: 10px; height: 10px; border-radius: 50%; background: var(--ok); flex: none; }
.pulse::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--ok); opacity: 0; animation: ping 2.4s var(--ease) infinite; }
.pulse.is-busy { background: var(--accent); }
.pulse.is-busy::after { border-color: var(--accent); animation-duration: 1.2s; }
.pulse.is-warn { background: var(--warn); }
.pulse.is-warn::after { border-color: var(--warn); }
.pulse.is-danger { background: var(--danger); }
.pulse.is-danger::after { border-color: var(--danger); }
.pulse.is-idle { background: var(--text-3); }
.pulse.is-idle::after { display: none; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric { padding: var(--s5); border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.metric:first-child { border-left: 0; }
.metric .value { font: 400 2.5rem/1 var(--serif); letter-spacing: -0.01em; margin-top: var(--s2); font-variant-numeric: tabular-nums; }
.metric .hint { color: var(--text-3); font-size: 0.8rem; }
.metric.is-alert .value { color: var(--danger); }
.meter { appearance: none; display: block; width: 100%; height: 4px; border: 0; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: auto; }
.meter::-webkit-progress-bar { background: var(--surface-2); border-radius: 999px; }
.meter::-webkit-progress-value { background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--warn))); border-radius: 999px; }
.meter::-moz-progress-bar { background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--warn))); border-radius: 999px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* Notebook covers */
.covers { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: var(--s5) var(--s4); }
.cover { position: relative; display: flex; flex-direction: column; gap: var(--s3); }
.cover-sheet {
  position: relative; aspect-ratio: 1404 / 1500; border-radius: 10px; overflow: hidden;
  background: var(--paper); border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
.cover-sheet img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.cover-blank { position: absolute; inset: 0; display: grid; place-items: center; background-image: radial-gradient(var(--paper-dot) 1px, transparent 1.2px); background-size: 14px 14px; }
.cover-blank span { font: 400 2.6rem/1 var(--serif); color: var(--paper-mute); font-style: italic; }
.cover-badge { position: absolute; top: 10px; left: 10px; }
.cover-badge .badge { box-shadow: var(--shadow); }
.cover-badge .badge-ok, .cover-badge .badge { background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(6px); border-color: var(--border); }
.cover:hover .cover-sheet { transform: translateY(-4px) rotate(-0.4deg); box-shadow: var(--shadow-lg); }
.cover-title { font-weight: 550; font-size: 0.92rem; color: var(--text); line-height: 1.3; }
.cover-title:hover { text-decoration: none; }
.cover-title::after { content: ""; position: absolute; inset: 0; border-radius: 10px; }
.cover-meta { display: flex; gap: var(--s2); font: 0.74rem/1.3 var(--mono); color: var(--text-3); margin-top: 2px; flex-wrap: wrap; }
.cover-meta span + span::before { content: "·"; margin-right: var(--s2); }

/* Activity timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 10px; bottom: 10px; width: 1px; background: var(--border-strong); }
.timeline li { position: relative; display: grid; grid-template-columns: 16px 1fr auto; gap: var(--s4); padding: 10px 0; align-items: baseline; }
.timeline .node { width: 15px; height: 15px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); position: relative; top: 2px; align-self: start; }
.timeline .lvl-info .node { border-color: var(--text-3); }
.timeline .lvl-warn .node { border-color: var(--warn); background: var(--warn-soft); }
.timeline .lvl-error .node { border-color: var(--danger); background: var(--danger-soft); }
.timeline .msg { font-size: 0.9rem; overflow-wrap: anywhere; }
.timeline .when { font: 0.74rem/1.4 var(--mono); color: var(--text-3); white-space: nowrap; }
.timeline .lvl-error .msg { color: var(--danger); }
.timeline-day { font: 500 0.68rem/1 var(--mono); text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-3); padding: var(--s5) 0 var(--s2) 32px; }
.timeline-day:first-child { padding-top: 0; }

/* Steps (Connect) */
.steps-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--s4); counter-reset: step; }
.step { padding: var(--s5); }
.step-num {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; margin-bottom: var(--s4);
  font: 400 1.25rem/1 var(--serif); background: var(--ink); color: var(--ink-text);
}
.steps { margin: 0; padding-left: 1.2em; color: var(--text-2); }
.steps li { margin-bottom: var(--s2); }
.steps li::marker { color: var(--text-3); font-family: var(--mono); font-size: 0.8em; }
.paired { display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; padding: var(--s6); background: var(--glow), var(--surface); }
.link-art { display: flex; align-items: center; gap: var(--s3); }
.link-art .node { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); }
.link-art .node.is-ink { background: var(--ink); color: var(--ink-text); border-color: transparent; }
.link-art .wire { width: 56px; height: 2px; background: repeating-linear-gradient(90deg, var(--accent) 0 6px, transparent 6px 11px); animation: flow 1s linear infinite; background-size: 22px 2px; }
.paired h2 { font: 400 1.9rem/1.1 var(--serif); margin: 0 0 var(--s1); letter-spacing: -0.01em; }
.tag-demo { display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; }
.tag-demo .tablet {
  width: 120px; aspect-ratio: 3 / 4; border-radius: 12px; background: var(--paper); border: 6px solid var(--ink);
  position: relative; box-shadow: var(--shadow-lg); flex: none;
}
.tag-demo .tablet svg { position: absolute; inset: 12px; width: calc(100% - 24px); height: calc(100% - 24px); }
.tag-demo .tablet .scribble { fill: none; stroke: var(--paper-ink); stroke-width: 2; stroke-linecap: round; }
.tag-demo .tablet .chip { position: absolute; right: -24px; bottom: 16px; background: var(--accent); color: var(--accent-text); border-radius: 999px; padding: 2px 10px; font: 500 0.72rem/1.6 var(--mono); box-shadow: var(--shadow-lg); }
.tag-demo .copy { flex: 1; min-width: 240px; }

/* Settings rows */
.settings { display: grid; gap: 0; }
.setting { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(0, 2fr); gap: var(--s6); padding: var(--s6) 0; border-top: 1px solid var(--border); }
.setting:first-child { border-top: 0; padding-top: 0; }
.setting-info h2 { font-size: 1rem; margin-bottom: var(--s2); }
.setting-info p { color: var(--text-2); font-size: 0.88rem; }
.kv { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.kv li { background: var(--surface); padding: var(--s4); display: grid; gap: 4px; }
.kv .k { font: 500 0.68rem/1 var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-3); }
.kv .v { font-weight: 550; overflow-wrap: anywhere; }

/* Code windows */
.code-window { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); margin-bottom: var(--s4); }
.code-window:last-child { margin-bottom: 0; }
.code-bar { display: flex; align-items: center; gap: var(--s2); padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); font-size: 0.8rem; color: var(--text-2); }
.code-bar .dots { display: inline-flex; gap: 5px; margin-right: var(--s2); }
.code-bar .dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); }
.code-bar code { background: transparent; border: 0; padding: 0; color: var(--text); }
.code-window pre { margin: 0; border: 0; border-radius: 0; background: transparent; padding: var(--s4); font-size: 0.82rem; }
.endpoint { display: flex; align-items: center; gap: var(--s2); padding: 6px 6px 6px 14px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface-2); font: 0.82rem var(--mono); overflow: hidden; }
.endpoint span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

/* Notebook detail */
.chips { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s4); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font: 0.76rem/1.4 var(--mono); color: var(--text-2); }
.chip .ic { width: 13px; height: 13px; color: var(--text-3); }
.paths { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--s3); margin-bottom: var(--s6); }
.path { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.path .k { font: 500 0.66rem/1 var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-3); margin-bottom: 4px; }
.path .v { font: 0.8rem/1.4 var(--mono); overflow-wrap: anywhere; }
.reader { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: var(--s5); align-items: start; }
.pager { position: sticky; top: var(--s5); display: flex; flex-direction: column; gap: 6px; }
.pager a {
  height: 36px; border-radius: 10px; display: grid; place-items: center;
  font: 0.8rem var(--mono); color: var(--text-2); border: 1px solid var(--border); background: var(--surface);
}
.pager a:hover { color: var(--text); border-color: var(--border-strong); text-decoration: none; }
.pager .is-failed { color: var(--danger); }
.pages { display: grid; gap: var(--s6); }
.page-item {
  display: grid;
  grid-template-columns: minmax(260px, 5fr) 6fr;
  gap: var(--s6);
  padding: var(--s5);
  scroll-margin-top: var(--s5);
}
.page-image {
  background: var(--paper);
  border-radius: 6px;
  overflow: hidden;
  align-self: start;
  box-shadow: 0 0 0 1px var(--border), var(--shadow-lg);
  position: relative;
}
.page-image img { display: block; width: 100%; height: auto; }
.page-image .placeholder {
  aspect-ratio: 1404 / 1872; display: grid; place-items: center; color: var(--paper-mute); font: italic 400 1.4rem var(--serif);
  background-image: radial-gradient(var(--paper-dot) 1px, transparent 1.2px); background-size: 18px 18px;
}
.page-meta { display: flex; gap: var(--s3); align-items: center; margin-bottom: var(--s4); padding-bottom: var(--s3); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.page-no { font: 400 1.6rem/1 var(--serif); margin: 0; }
.page-no small { font: 0.72rem var(--mono); color: var(--text-3); margin-left: 4px; letter-spacing: 0.06em; }
.prose { font-size: 0.97rem; line-height: 1.7; overflow-wrap: anywhere; }
.prose > :last-child { margin-bottom: 0; }
.prose h1 { font-size: 1.7rem; margin-top: var(--s4); }
.prose h2 { font-size: 1.15rem; margin-top: var(--s5); }
.prose h3 { font-size: 1rem; margin-top: var(--s4); }
.prose p { margin-bottom: var(--s4); }
.diagram {
  margin: 0 0 var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.diagram-canvas { padding: var(--s4); display: flex; justify-content: center; min-height: 48px; }
.diagram-canvas svg { max-width: 100%; height: auto; }
.diagram-error .diagram-canvas { color: var(--text-3); font-size: 0.85rem; justify-content: flex-start; }
.diagram-source { border-top: 1px solid var(--border); padding: var(--s2) var(--s4); }
.diagram-source summary { cursor: pointer; color: var(--text-3); font-size: 0.8rem; }
.diagram-source pre { margin: var(--s2) 0 0; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 var(--s4); }
.prose li { margin-bottom: 4px; }
.prose li::marker { color: var(--accent); }
.prose table { border-collapse: collapse; margin-bottom: var(--s4); font-size: 0.9rem; }
.prose th, .prose td { border: 1px solid var(--border); padding: 6px 10px; }
.prose th { background: var(--surface-2); }
.prose em { color: var(--text-2); }
.prose blockquote { margin: 0 0 var(--s4); padding-left: var(--s4); border-left: 2px solid var(--accent); color: var(--text-2); }
.prose input[type="checkbox"] { margin-right: 6px; accent-color: var(--accent); }

/* Landing */
.hero-wrap { position: relative; padding: var(--s7) 0 var(--s6); overflow-x: clip; }
.hero { display: grid; grid-template-columns: 1.05fr 1fr; gap: var(--s7); align-items: center; min-height: 560px; }
.hero h1 { font-size: clamp(2.8rem, 5.4vw, 4.6rem); line-height: 0.98; letter-spacing: -0.02em; margin-bottom: var(--s5); }
.hero h1 em { font-style: italic; color: var(--accent); }
.hero .lead { color: var(--text-2); font-size: 1.08rem; max-width: 48ch; margin-bottom: var(--s6); }
.hero-cta { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: center; }
.hero-note { margin-top: var(--s4); }
.pill {
  display: inline-flex; align-items: center; gap: var(--s2); padding: 4px 12px 4px 4px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 0.8rem; color: var(--text-2); margin-bottom: var(--s5);
}
.pill b { background: var(--ink); color: var(--ink-text); border-radius: 999px; padding: 2px 9px; font: 500 0.7rem/1.6 var(--mono); letter-spacing: 0.04em; }

.showcase { position: relative; height: 480px; }
.showcase::before { content: ""; position: absolute; inset: -10% -10% 0; background: var(--glow); filter: blur(10px); }
.sheet {
  position: absolute; background: var(--paper); border-radius: 14px; box-shadow: 0 0 0 1px var(--border), var(--shadow-lg);
}
.sheet-hand { left: 0; top: 24px; width: 54%; height: 400px; transform: rotate(-4deg); padding: 26px 22px; background-image: linear-gradient(var(--paper-line) 1px, transparent 1px); background-size: 100% 28px; background-position: 0 50px; background-color: var(--paper); }
.sheet-hand svg { width: 100%; height: 100%; overflow: visible; }
.sheet-hand .hw { fill: none; stroke: var(--paper-ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 600; stroke-dashoffset: 600; animation: write 2.2s var(--ease) forwards; }
.sheet-hand .hw:nth-of-type(2) { animation-delay: 0.3s; }
.sheet-hand .hw:nth-of-type(3) { animation-delay: 0.6s; }
.sheet-hand .hw:nth-of-type(4) { animation-delay: 0.9s; }
.sheet-hand .hw:nth-of-type(5) { animation-delay: 1.2s; }
.sheet-hand .hw:nth-of-type(6) { animation-delay: 1.5s; }
.sheet-hand .hl { fill: none; stroke: var(--highlighter); stroke-width: 12; stroke-linecap: round; }
.sheet-md {
  right: 0; top: 70px; width: 56%; padding: 0; overflow: hidden; transform: rotate(2.5deg);
  background: var(--surface); box-shadow: 0 0 0 1px var(--border), var(--shadow-lg);
}
.sheet-md .code-bar { border-radius: 0; }
.sheet-md pre { margin: 0; border: 0; background: transparent; padding: var(--s4); font-size: 0.78rem; line-height: 1.75; color: var(--text-2); white-space: pre-wrap; }
.sheet-md .t-h { color: var(--text); font-weight: 600; }
.sheet-md .t-k { color: var(--accent-ink); }
.sheet-md .t-c { color: var(--ok); }
.bridge-arc { position: absolute; left: 40%; top: 6px; width: 30%; height: 90px; z-index: 2; overflow: visible; }
.bridge-arc path { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 5 6; animation: flow-dash 1.2s linear infinite; }
.bridge-arc circle { fill: var(--accent); }
.agent-chip {
  position: absolute; right: 8%; bottom: 0; z-index: 3; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px 10px 10px; border-radius: 14px; background: var(--ink); color: var(--ink-text);
  box-shadow: var(--shadow-lg); font-size: 0.82rem;
}
.agent-chip .dot { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--accent); color: var(--accent-text); }
.agent-chip small { display: block; opacity: 0.6; font: 0.68rem var(--mono); }

.flow { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; margin: var(--s6) 0 var(--s7); }
.flow-step { padding: var(--s5); border-left: 1px solid var(--border); position: relative; }
.flow-step:first-child { border-left: 0; }
.flow-step .n { font: 500 0.68rem/1 var(--mono); color: var(--accent-ink); letter-spacing: 0.12em; }
.flow-step h3 { margin: var(--s3) 0 var(--s1); font-size: 0.95rem; }
.flow-step p { margin: 0; color: var(--text-2); font-size: 0.84rem; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s6) var(--s5); margin: var(--s7) 0; }
.feature h3 { font: 400 1.5rem/1.15 var(--serif); letter-spacing: -0.01em; margin: var(--s3) 0 var(--s2); }
.feature p { color: var(--text-2); margin: 0; font-size: 0.9rem; }
.feature .card-icon { margin-bottom: 0; }
.section-title { font: 400 clamp(2rem, 3.6vw, 2.8rem)/1.05 var(--serif); letter-spacing: -0.015em; max-width: 20ch; margin: 0 0 var(--s3); }

/* Centered states (error, denied, consent) */
.state { max-width: 560px; margin: var(--s7) auto; text-align: center; padding: var(--s6) 0; }
.state h1 { font-size: 3rem; margin-bottom: var(--s4); }
.state p { color: var(--text-2); font-size: 1rem; }
.state .row { justify-content: center; margin-top: var(--s5); }
.state-code { font: 400 7rem/1 var(--serif); font-style: italic; color: var(--accent); opacity: 0.9; margin-bottom: var(--s2); }
.consent { max-width: 480px; margin: var(--s7) auto; padding: var(--s6); text-align: center; box-shadow: var(--shadow-lg); }
.consent .link-art { justify-content: center; margin-bottom: var(--s5); }
.consent h1 { font-size: 2.2rem; margin-bottom: var(--s3); }
.consent form { justify-content: center; margin-top: var(--s5); }
.consent .btn { min-width: 120px; }

@keyframes ping { 0% { transform: scale(0.6); opacity: 0.7; } 80%, 100% { transform: scale(2); opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes write { to { stroke-dashoffset: 0; } }
@keyframes flow { to { background-position: 22px 0; } }
@keyframes flow-dash { to { stroke-dashoffset: -22; } }
.container > * { animation: rise 0.45s var(--ease) both; }
.container > *:nth-child(2) { animation-delay: 0.04s; }
.container > *:nth-child(3) { animation-delay: 0.08s; }
.container > *:nth-child(4) { animation-delay: 0.12s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .sheet-hand .hw { stroke-dashoffset: 0; }
}

@media (max-width: 1080px) {
  .hero { grid-template-columns: minmax(0, 1fr); min-height: 0; gap: var(--s6); }
  .showcase { max-width: 620px; width: 100%; margin: 0 auto; }
  .flow { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .flow-step { border-left: 0; border-top: 1px solid var(--border); }
  .status-panel { grid-template-columns: minmax(0, 1fr); }
  .status-main { border-right: 0; border-bottom: 1px solid var(--border); }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: none; }
  .sidebar {
    position: sticky; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: var(--s3);
    padding: var(--s2) var(--s4); border-right: 0; border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--sidebar) 88%, transparent); backdrop-filter: blur(12px);
  }
  .brand-word { display: none; }
  .sidebar { min-width: 0; }
  .nav { flex-direction: row; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
  .nav-group { display: none; }
  .nav-link { white-space: nowrap; padding: 6px 10px; }
  .nav-link.active::before { display: none; }
  .sidebar-foot { margin: 0; display: flex; }
  .me { border: 0; padding: 0; background: transparent; }
  .me-text { display: none; }
  .container { padding: var(--s6) var(--s4) var(--s7); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(3) { border-left: 0; }
  .metric:nth-child(n+3) { border-top: 1px solid var(--border); }
  .page-item { grid-template-columns: minmax(0, 1fr); padding: var(--s4); }
  .reader { grid-template-columns: minmax(0, 1fr); }
  .pager { position: static; flex-direction: row; flex-wrap: wrap; }
  .pager a { width: 36px; }
  .setting { grid-template-columns: minmax(0, 1fr); gap: var(--s4); }
  .table .hide-sm { display: none; }
  .table th, .table td { padding: 10px var(--s4); }
  h1 { font-size: 2.2rem; }
  .topbar-inner, .public-main, .footer { padding-left: var(--s4); padding-right: var(--s4); }
}

@media (max-width: 560px) {
  .sheet-hand { width: 62%; height: 330px; }
  .sheet-md { width: 64%; }
  .showcase { height: 420px; }
  .covers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.unit { font-size: 0.45em; color: var(--text-3); margin-left: 2px; }
.flush { margin: 0; }
.mt { margin-top: var(--s4); }
.consent-actions { display: flex; gap: var(--s2); justify-content: flex-end; margin: var(--s5) 0 var(--s3); }
.consent-actions .btn { flex: 1; justify-content: center; }
