/* ====== Tokens (shared design language with ane-comware.pages.dev) ====== */
:root {
  --d-bg: #0b0f17; --d-surface: #131a26; --d-border: #283449;
  --d-text: #e9eef6; --d-muted: #94a3b8; --d-dim: #64748b;
  --accent: #2dd4bf; --accent-deep: #0f766e; --amber: #f5b94a;
  --l-bg: #faf8f4; --l-surface: #ffffff; --l-border: #e7e2d8;
  --l-text: #1a1f29; --l-muted: #4b5563; --l-dim: #6b7280;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { background: var(--l-bg); color: var(--l-text); font-family: var(--serif); line-height: 1.7; -webkit-font-smoothing: antialiased; }

/* ====== Topbar ====== */
.topbar { background: var(--d-bg); font-family: var(--sans); padding: 14px 24px; }
.topbar .wrap { max-width: 1240px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; }
.topbar .brand { color: var(--d-text); font-weight: 700; letter-spacing: .14em; text-transform: uppercase; font-size: 13px; text-decoration: none; }
.topbar .brand b { color: var(--accent); }
.topbar nav a { color: var(--d-muted); text-decoration: none; font-size: 14px; margin-left: 22px; }
.topbar nav a:hover { color: var(--accent); }

/* ====== Paper layout (sticky TOC + content) ====== */
.bp-layout { display: grid; grid-template-columns: 280px 1fr; max-width: 1240px; margin: 0 auto; gap: 40px; padding: 0 24px; }
.bp-toc { position: sticky; top: 0; align-self: start; max-height: 100vh; overflow-y: auto; padding: 32px 0; font-family: var(--sans); }
.bp-toc .toc-title { font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--l-dim); font-weight: 700; margin-bottom: 12px; }
.bp-toc a { display: block; font-size: 13.5px; color: var(--l-muted); text-decoration: none; padding: 5px 0; border-left: 2px solid transparent; padding-left: 10px; line-height: 1.35; }
.bp-toc a:hover { color: var(--accent-deep); border-left-color: var(--accent-deep); }
.bp-content { padding: 32px 0 80px; min-width: 0; }
.bp-content h1 { font-size: clamp(30px, 4vw, 44px); line-height: 1.15; margin-bottom: 8px; }
.bp-content h2 { font-size: clamp(24px, 3vw, 32px); margin: 52px 0 16px; scroll-margin-top: 24px; }
.bp-content h3 { font-family: var(--sans); font-size: 18px; font-weight: 700; margin: 32px 0 10px; scroll-margin-top: 24px; }
.bp-content h4 { font-family: var(--sans); font-size: 15.5px; font-weight: 700; margin: 26px 0 8px; scroll-margin-top: 24px; }
.bp-content p, .bp-content li { font-size: 16.5px; }
.bp-content ul, .bp-content ol { margin: 0 0 16px 22px; }
.bp-content li { margin-bottom: 6px; }
.bp-content p { margin-bottom: 16px; }
.bp-content a { color: var(--accent-deep); text-underline-offset: 3px; }
.bp-content blockquote { border-left: 3px solid var(--accent-deep); padding-left: 16px; color: var(--l-muted); margin-bottom: 16px; font-size: 15px; font-family: var(--sans); }
.bp-content hr { border: none; border-top: 1px solid var(--l-border); margin: 40px 0; }
.bp-content code { font-family: ui-monospace, Menlo, monospace; font-size: .85em; background: #efece4; padding: 2px 6px; border-radius: 5px; }
.bp-content strong { font-weight: 700; }
@media (max-width: 900px) { .bp-layout { grid-template-columns: 1fr; } .bp-toc { position: static; max-height: none; padding-bottom: 0; } }

/* Cross-doc references to unpublished repo files: plain styled text, not links */
.xref { color: var(--l-muted); }
.xref code { background: #efece4; }

/* ====== Tables ====== */
.tablewrap { overflow-x: auto; margin: 0 0 22px; border: 1px solid var(--l-border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: 14.5px; background: var(--l-surface); }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--l-border); vertical-align: top; }
th { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--l-dim); background: #f4f1ea; }
tr:last-child td { border-bottom: none; }

/* ====== Diagrams (hand-crafted partials + ascii fallback) ====== */
.ascii-panel { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; line-height: 1.5; background: #10151f; color: #cdd6e4; border-radius: 12px; padding: 18px 20px; overflow-x: auto; margin: 0 0 22px; }
.diagram { font-family: var(--sans); background: var(--l-surface); border: 1px solid var(--l-border); border-radius: 14px; padding: 24px 22px; margin: 0 0 26px; }
.diagram .dg-title { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--l-dim); font-weight: 700; margin-bottom: 16px; }
/* vertical flow of steps */
.flow { display: flex; flex-direction: column; align-items: stretch; gap: 0; }
.fnode { background: #f6f4ee; border: 1px solid var(--l-border); border-radius: 10px; padding: 12px 16px; text-align: center; position: relative; }
.fnode .t { font-weight: 700; font-size: 14.5px; }
.fnode .d { font-size: 13px; color: var(--l-muted); margin-top: 3px; }
.fnode .agent { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--accent-deep); }
.fnode + .fnode, .lanes + .fnode, .fnode + .lanes { margin-top: 28px; }
.fnode + .fnode::before, .lanes + .fnode::before { content: ""; position: absolute; top: -22px; left: 50%; width: 2px; height: 16px; background: var(--accent-deep); }
.fnode + .fnode::after, .lanes + .fnode::after { content: ""; position: absolute; top: -8px; left: 50%; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--accent-deep); }
/* parallel lanes */
.lanes { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.lane { display: flex; flex-direction: column; gap: 8px; }
.lane .fnode { flex: none; }
/* badges */
.b-human, .b-out, .b-gap { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .05em; padding: 2px 8px; border-radius: 999px; vertical-align: 2px; margin-left: 6px; }
.b-human { background: var(--amber); color: #1a1206; }
.b-out { background: var(--accent-deep); color: #fff; }
.b-gap { background: #e2e8f0; color: #475569; }
/* layered architecture */
.layer { border: 1px solid var(--l-border); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.layer:last-child { margin-bottom: 0; }
.layer .l-name { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent-deep); font-weight: 700; margin-bottom: 10px; }
.layer .l-note { font-size: 12.5px; color: var(--l-dim); float: right; font-weight: 400; text-transform: none; letter-spacing: 0; }
.layer .nodes { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: #f6f4ee; border: 1px solid var(--l-border); border-radius: 8px; padding: 6px 11px; font-size: 12.5px; font-weight: 600; }
.chip .c-d { display: block; font-size: 11px; color: var(--l-muted); font-weight: 400; margin-top: 1px; }
.chip.mono { font-family: ui-monospace, Menlo, monospace; font-weight: 500; color: var(--accent-deep); }
/* key-value definition panel */
.kv { display: grid; grid-template-columns: 190px 1fr; gap: 10px 16px; font-size: 14.5px; margin: 0; }
.kv dt { font-weight: 700; color: var(--accent-deep); font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.kv dd { margin: 0; color: var(--l-muted); }
@media (max-width: 640px) { .kv { grid-template-columns: 1fr; gap: 2px 0; } .kv dd { margin-bottom: 10px; } }
/* function-signature header inside a diagram */
.fn-sig { font-family: ui-monospace, Menlo, monospace; font-size: 13.5px; color: var(--l-text); background: #f6f4ee; border: 1px solid var(--l-border); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.fn-sig b { color: var(--accent-deep); }

/* ====== Footer ====== */
footer { font-family: var(--sans); text-align: center; font-size: 13px; color: var(--l-dim); padding: 28px 24px 40px; background: var(--l-bg); }
footer a { color: var(--accent-deep); }
footer code { font-family: ui-monospace, Menlo, monospace; font-size: .9em; background: #efece4; padding: 1px 5px; border-radius: 4px; }
