/* ============================================================
   OpenClaw Dashboard Architecture Handbook
   Design system: "Control Plane Blueprint"
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg:        #0a0f1c;
  --bg-raise:  #0e1526;
  --panel:     #111a2e;
  --panel-2:   #0d1524;
  --border:    #223050;
  --border-soft: #182338;

  --ink:       #e7ecf5;
  --ink-dim:   #aab6cc;
  --ink-mute:  #7c88a3;

  --teal:      #4fd1c5;
  --teal-dim:  #2b7a71;
  --teal-glow: rgba(79, 209, 197, 0.18);

  --violet:    #a78bfa;
  --violet-dim:#5b4a99;
  --violet-glow: rgba(167, 139, 250, 0.16);

  --amber:     #f0b849;
  --amber-dim: #8a6a26;
  --amber-glow: rgba(240, 184, 73, 0.16);

  --rose:      #fb7185;
  --rose-dim:  #7a2f3a;
  --rose-glow: rgba(251, 113, 133, 0.14);

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --sidebar-w: 300px;
  --content-max: 860px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* faint blueprint dot-grid texture on the whole page */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.045) 1px, transparent 1px);
  background-size: 26px 26px;
  pointer-events: none;
  z-index: 0;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* ============ LAYOUT ============ */

.shell {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}

/* ---------- Sidebar / TOC ---------- */

.sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--bg-raise), var(--bg));
  padding: 28px 0 60px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.sidebar-brand {
  padding: 0 24px 20px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 18px;
}
.sidebar-brand .mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.sidebar-brand .mark svg { flex: none; }
.sidebar-brand .sub {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--ink-mute);
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
}

.toc-group { margin-bottom: 4px; }
.toc-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 9px 24px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--teal);
  opacity: 0.85;
}
.toc-group-title .n {
  color: var(--ink-mute);
  min-width: 18px;
}
.toc-links { list-style: none; margin: 0; padding: 0 0 10px; }
.toc-links li a {
  display: block;
  padding: 6px 24px 6px 52px;
  font-size: 13px;
  color: var(--ink-dim);
  border-left: 2px solid transparent;
  line-height: 1.4;
}
.toc-links li a:hover {
  color: var(--ink);
  text-decoration: none;
  background: rgba(255,255,255,0.02);
}
.toc-links li a.active {
  color: var(--teal);
  border-left-color: var(--teal);
  background: var(--teal-glow);
}

.sidebar-toggle { display: none; }

/* ---------- Main content ---------- */

main {
  position: relative;
  z-index: 1;
  min-width: 0;
  flex: 1 1 auto;
}

.content {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 40px 140px;
}

/* ============ HERO ============ */

.hero {
  padding: 90px 40px 70px;
  border-bottom: 1px solid var(--border-soft);
  position: relative;
  overflow: hidden;
}
.hero-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  position: relative;
  z-index: 2;
}
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal);
  border: 1px solid var(--teal-dim);
  background: var(--teal-glow);
  padding: 6px 12px;
  border-radius: 999px;
  margin-bottom: 28px;
}
.hero-eyebrow .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 8px 1px var(--teal);
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(34px, 4.6vw, 54px);
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin: 0 0 20px;
  color: var(--ink);
}
.hero h1 .accent { color: var(--teal); }
.hero .subtitle {
  font-size: 18px;
  color: var(--ink-dim);
  max-width: 640px;
  margin: 0 0 32px;
  line-height: 1.6;
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-mute);
  padding-top: 24px;
  border-top: 1px dashed var(--border);
}
.hero-meta strong { color: var(--ink-dim); font-weight: 500; }

/* signature schematic in hero */
.hero-schematic {
  margin-top: 48px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: radial-gradient(ellipse at top left, rgba(79,209,197,0.06), transparent 60%), var(--panel-2);
  padding: 28px 20px;
  overflow-x: auto;
}

/* ============ PART / SECTION STRUCTURE ============ */

.part-divider {
  padding: 56px 0 18px;
  margin-top: 30px;
  border-top: 1px solid var(--border-soft);
}
.part-divider:first-of-type { border-top: none; margin-top: 0; }
.part-eyebrow {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--violet);
  margin-bottom: 8px;
}
.part-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  color: var(--ink);
  margin: 0;
}

section.sec {
  padding-top: 52px;
  scroll-margin-top: 24px;
}
.sec-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 18px;
}
.sec-num {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--teal);
  border: 1px solid var(--teal-dim);
  border-radius: 6px;
  padding: 2px 8px;
  background: var(--teal-glow);
  flex: none;
}
.sec-head h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 23px;
  color: var(--ink);
  margin: 0;
  line-height: 1.3;
}

.sec p { color: var(--ink-dim); margin: 0 0 16px; }
.sec ul, .sec ol { color: var(--ink-dim); margin: 0 0 16px; padding-left: 22px; }
.sec li { margin-bottom: 6px; }
.sec strong { color: var(--ink); font-weight: 600; }
.sec h3 {
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 600;
  color: var(--ink);
  margin: 26px 0 12px;
}
.sec h4 {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin: 20px 0 8px;
}

/* ============ CALLOUT / PRINCIPLE ============ */

.callout {
  border-left: 3px solid var(--teal);
  background: linear-gradient(90deg, var(--teal-glow), transparent 70%);
  padding: 14px 18px;
  border-radius: 0 8px 8px 0;
  margin: 18px 0 22px;
}
.callout p {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 500;
  line-height: 1.55;
}
.callout.amber { border-left-color: var(--amber); background: linear-gradient(90deg, var(--amber-glow), transparent 70%); }
.callout.rose  { border-left-color: var(--rose);  background: linear-gradient(90deg, var(--rose-glow), transparent 70%); }
.callout.violet{ border-left-color: var(--violet);background: linear-gradient(90deg, var(--violet-glow), transparent 70%); }

.principle-banner {
  margin: 22px 0 26px;
  padding: 20px 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  position: relative;
}
.principle-banner::before {
  content: "PRINCIPLE";
  position: absolute;
  top: -9px; left: 18px;
  background: var(--bg);
  padding: 0 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .12em;
  color: var(--amber);
}
.principle-banner p {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 500;
  font-family: var(--font-display);
}

/* ============ EXAMPLE WRAPPER ============ */

.example {
  margin: 18px 0 24px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  overflow: hidden;
  background: var(--panel-2);
}
.example-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-mute);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(255,255,255,0.015);
}
.example-body { padding: 18px 18px 20px; }

/* ============ DIAGRAM: FLOW (vertical) ============ */

.flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  margin: 6px 0;
}
.node {
  min-width: 190px;
  max-width: 100%;
  text-align: center;
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
  white-space: pre-line;
}
.node .sub { display:block; font-size: 11px; color: var(--ink-mute); margin-top: 3px; }
.node.accent { border-color: var(--teal-dim); background: var(--teal-glow); color: var(--teal); }
.node.violet { border-color: var(--violet-dim); background: var(--violet-glow); color: var(--violet); }
.node.amber  { border-color: var(--amber-dim); background: var(--amber-glow); color: var(--amber); }
.node.rose   { border-color: var(--rose-dim); background: var(--rose-glow); color: var(--rose); }
.node.ghost  { border-style: dashed; color: var(--ink-mute); background: transparent; }
.flow .arrow {
  width: 1px;
  height: 22px;
  background: var(--border);
  position: relative;
}
.flow .arrow::after {
  content: "";
  position: absolute;
  bottom: -1px; left: 50%;
  transform: translateX(-50%);
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 6px solid var(--border);
}
.flow .arrow .label {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--ink-mute);
  white-space: nowrap;
}

/* horizontal flow (compact inline chains) */
.flow-h {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 0;
  margin: 6px 0 18px;
}
.flow-h .node { min-width: unset; }
.flow-h .arrow-h {
  width: 26px; height: 1px;
  background: var(--border);
  position: relative;
  flex: none;
  margin: 0 2px;
}
.flow-h .arrow-h::after {
  content: "";
  position: absolute;
  right: -1px; top: 50%;
  transform: translateY(-50%);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid var(--border);
}

/* ============ DIAGRAM: TREE (one to many) ============ */

.tree { margin: 6px 0 18px; }
.tree .root {
  display: flex; justify-content: center; margin-bottom: 0;
}
.tree .stem {
  width: 1px; height: 20px; background: var(--border); margin: 0 auto;
}
.tree .branch-line {
  height: 1px; background: var(--border); margin: 0 auto; position: relative;
}
.tree .children {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 26px;
  position: relative;
}
.tree .children::before {
  /* vertical stem from parent */
  content: "";
  position: absolute;
  top: 0; left: 50%;
  width: 1px; height: 14px;
  background: var(--border);
  transform: translateX(-50%);
}
.tree .children::after {
  /* horizontal branch bar */
  content: "";
  position: absolute;
  top: 14px; left: 8%;
  width: 84%; height: 1px;
  background: var(--border);
}
.tree .children .node { flex: 1 1 150px; max-width: 220px; min-width: 140px; position: relative; margin-top: 12px; }
.tree .children .node::before {
  content: "";
  position: absolute;
  top: -12px; left: 50%;
  width: 1px; height: 12px;
  background: var(--border);
  transform: translateX(-50%);
}
.tree .children .drop {
  width: 1px; height: 14px; background: var(--border); margin: 0 auto;
}

/* ============ DIAGRAM: STACK (numbered layers) ============ */

.stack { display: flex; flex-direction: column; gap: 7px; margin: 6px 0 20px; }
.stack .layer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}
.stack .layer .idx {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--bg);
  background: var(--teal);
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex: none;
  font-weight: 700;
}
.stack .layer .txt { font-size: 13.5px; color: var(--ink); font-family: var(--font-mono); }
.stack .layer.emphasis { border-color: var(--amber-dim); background: var(--amber-glow); }
.stack .layer.emphasis .idx { background: var(--amber); }

/* ============ DIAGRAM: DEFS (term = definition stacked) ============ */

.defs {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  overflow: hidden;
  margin: 6px 0 20px;
}
.defs .row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--panel-2);
}
.defs .row:last-child { border-bottom: none; }
.defs .term {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--teal);
  flex: 0 0 auto;
  min-width: 150px;
}
.defs .def { font-size: 13.5px; color: var(--ink-dim); flex: 1 1 260px; }

/* ============ DIAGRAM: COMPARE (2-3 column) ============ */

.compare {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 6px 0 20px;
}
.compare.cols-2 .col { flex: 1 1 calc(50% - 7px); min-width: 220px; }
.compare.cols-3 .col { flex: 1 1 calc(33.333% - 10px); min-width: 200px; }
.compare .col {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  background: var(--panel);
  box-sizing: border-box;
}
.compare .col.a { border-color: var(--teal-dim); }
.compare .col.b { border-color: var(--rose-dim); }
.compare .col.c { border-color: var(--violet-dim); }
.compare .col h5 {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: .04em;
  color: var(--ink);
  text-transform: uppercase;
}
.compare .col.a h5 { color: var(--teal); }
.compare .col.b h5 { color: var(--rose); }
.compare .col.c h5 { color: var(--violet); }
.compare .col ul { margin: 0; padding-left: 18px; }
.compare .col li { font-size: 13px; color: var(--ink-dim); margin-bottom: 5px; }

@media (max-width: 640px) {
  .compare.cols-2 .col, .compare.cols-3 .col { flex: 1 1 100%; }
}

/* ============ CODE BLOCK ============ */

pre.code {
  margin: 6px 0 20px;
  padding: 14px 18px;
  background: #0a1120;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.8px;
  line-height: 1.6;
  color: #cfe8e4;
}
pre.code .k { color: var(--teal); }
pre.code .m { color: var(--violet); }
pre.code .c { color: var(--ink-mute); }

code.inline {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: rgba(255,255,255,0.06);
  padding: 1px 6px;
  border-radius: 4px;
  color: #cfe8e4;
}

/* ============ TABLE ============ */

.tbl-wrap { overflow-x: auto; margin: 6px 0 22px; border: 1px solid var(--border-soft); border-radius: 10px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--teal);
  background: var(--panel-2);
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-soft);
}
table.tbl td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--ink-dim);
  vertical-align: top;
}
table.tbl tr:last-child td { border-bottom: none; }
table.tbl td:first-child { color: var(--ink); font-weight: 600; white-space: nowrap; }

/* ============ RULE GRID (Ten Rules) ============ */

.rule-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 10px 0 20px;
}
.rule-card {
  display: flex;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  flex: 1 1 calc(50% - 6px);
  min-width: 260px;
  box-sizing: border-box;
}
.rule-card .num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--border);
  line-height: 1;
  flex: none;
}
.rule-card p { margin: 0; font-size: 13.5px; color: var(--ink-dim); }
.rule-card strong { color: var(--ink); }
@media (max-width: 640px) { .rule-card { flex: 1 1 100%; } }

/* ============ QUESTION LIST (final mental model) ============ */

.qlist { list-style: none; margin: 0 0 20px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.qlist li {
  padding: 10px 16px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--panel-2);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-dim);
}
.qlist li::before { content: "→ "; color: var(--teal); }

/* ============ REFERENCE LIST ============ */

.ref-list { list-style: none; margin: 0; padding: 0; }
.ref-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13.5px;
}
.ref-list li span.label { color: var(--ink); font-weight: 500; }
.ref-list li a { color: var(--teal); font-family: var(--font-mono); font-size: 12.5px; }

/* ============ FINAL SUMMARY BANNER ============ */

.final-banner {
  margin-top: 60px;
  padding: 36px 34px;
  border-radius: 16px;
  border: 1px solid var(--teal-dim);
  background: radial-gradient(circle at top right, var(--teal-glow), transparent 60%), var(--panel);
  position: relative;
}
.final-banner .tag {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 14px;
  display: block;
}
.final-banner p {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.6;
}

/* ============ FOOTER ============ */

.doc-footer {
  margin-top: 70px;
  padding-top: 24px;
  border-top: 1px solid var(--border-soft);
  color: var(--ink-mute);
  font-size: 12.5px;
  font-family: var(--font-mono);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

/* ============ PROGRESS BAR ============ */

.progress-bar {
  position: fixed;
  top: 0; left: var(--sidebar-w); right: 0;
  height: 2px;
  background: transparent;
  z-index: 50;
}
.progress-bar .fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--teal), var(--violet));
}

/* ============ MOBILE ============ */

.mobile-topbar { display: none; }

@media (max-width: 980px) {
  .shell { display: block; }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    width: 84vw;
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 60;
    box-shadow: 20px 0 40px rgba(0,0,0,0.5);
  }
  .sidebar.open { transform: translateX(0); }
  .progress-bar { left: 0; }
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--bg-raise);
    border-bottom: 1px solid var(--border-soft);
    padding: 14px 16px;
  }
  .mobile-topbar button {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--ink);
    border-radius: 8px;
    padding: 7px 10px;
    font-family: var(--font-mono);
    font-size: 12px;
  }
  .mobile-topbar .mt-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
  }
  .scrim {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 55;
  }
  .scrim.show { display: block; }
  .hero { padding: 40px 22px 44px; }
  .content { padding: 0 20px 100px; }
  .rule-card { flex: 1 1 100%; }
}

/* print */
@media print {
  .sidebar, .mobile-topbar, .progress-bar, .scrim { display: none !important; }
  .shell { display: block; }
  body { background: white; color: #111; }
  .content { max-width: 100%; }
}
