/* ============================================================
   BELA65 Launch Studio — Design System
   Standalone. No frameworks. Light/Dark. Print-friendly.
   ============================================================ */

:root {
  /* Type */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter",
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  /* Layout */
  --sidebar-w: 288px;
  --toc-w: 240px;
  --content-max: 760px;
  --radius: 12px;
  --radius-sm: 8px;

  /* Light theme */
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --bg-subtle: #f6f7f9;
  --bg-sunken: #f0f2f5;
  --text: #191d24;
  --text-soft: #3d4552;
  --text-muted: #6b7480;
  --border: #e7e9ee;
  --border-strong: #d5d9e0;
  --accent: #4f46e5;
  --accent-soft: #eef0fe;
  --accent-text: #4338ca;
  --shadow: 0 1px 2px rgba(20, 24, 40, .04), 0 8px 24px rgba(20, 24, 40, .06);
  --shadow-sm: 0 1px 2px rgba(20, 24, 40, .06);

  /* Status colors */
  --ok: #0f9d6a; --ok-bg: #e5f6ef;
  --warn: #b7791f; --warn-bg: #fbf3e2;
  --info: #2563eb; --info-bg: #e8f0fe;
  --muted-bg: #eef0f3; --muted-fg: #6b7480;
  --frozen: #4f46e5; --frozen-bg: #eef0fe;
}

[data-theme="dark"] {
  --bg: #0b0d12;
  --bg-elev: #12151d;
  --bg-subtle: #12151d;
  --bg-sunken: #0f1219;
  --text: #e9ebf0;
  --text-soft: #c3c9d4;
  --text-muted: #8b94a3;
  --border: #222732;
  --border-strong: #2c333f;
  --accent: #8b93f8;
  --accent-soft: #1b1f36;
  --accent-text: #b3b9fb;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);

  --ok: #34d399; --ok-bg: #10241d;
  --warn: #eab308; --warn-bg: #2a2410;
  --info: #60a5fa; --info-bg: #0f1d33;
  --muted-bg: #1a1f29; --muted-fg: #8b94a3;
  --frozen: #a5adff; --frozen-bg: #1b1f36;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .25s ease, color .25s ease;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  height: 60px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 640; letter-spacing: -.01em; color: var(--text); white-space: nowrap; }
.brand svg { display: block; }
.brand .brand-sub { color: var(--text-muted); font-weight: 500; }
.topbar-spacer { flex: 1; }

.search { position: relative; width: min(360px, 40vw); }
.search input {
  width: 100%; height: 38px; padding: 0 12px 0 36px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--bg-subtle); color: var(--text); font-size: 14px;
  font-family: inherit; outline: none;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search .search-ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--text-muted); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 6px; background: var(--bg); font-family: var(--font-mono);
}
.search-results {
  position: absolute; top: 46px; left: 0; right: 0; max-height: 60vh; overflow: auto;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; display: none;
}
.search-results.open { display: block; }
.search-results a { display: block; padding: 9px 11px; border-radius: 8px; color: var(--text); }
.search-results a:hover, .search-results a.active { background: var(--accent-soft); text-decoration: none; }
.search-results .sr-title { font-weight: 600; font-size: 14px; }
.search-results .sr-page { font-size: 12px; color: var(--text-muted); }
.search-results .sr-snip { font-size: 12.5px; color: var(--text-soft); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-results .sr-empty { padding: 14px; color: var(--text-muted); font-size: 14px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--bg-subtle); color: var(--text-soft);
}
.icon-btn:hover { color: var(--text); border-color: var(--accent); }
.menu-btn { display: none; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); align-items: start; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: 60px; align-self: start;
  height: calc(100vh - 60px); overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 22px 14px 60px;
}
.nav-group { margin-bottom: 20px; }
.nav-group h4 {
  margin: 0 0 6px; padding: 0 10px;
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 700;
}
.nav-link {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: 8px; color: var(--text-soft);
  font-size: 14.5px; font-weight: 500; line-height: 1.3;
}
.nav-link:hover { background: var(--bg-subtle); text-decoration: none; color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-link .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); flex: none; }
.nav-link.active .dot { background: var(--accent); }
.nav-link .badge { margin-left: auto; }

/* ---------- Main + content ---------- */
.main { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) var(--toc-w); }
.content-wrap { min-width: 0; padding: 44px 48px 80px; }
.content { max-width: var(--content-max); margin: 0 auto; }

.crumbs { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; display: flex; gap: 8px; align-items: center; }
.crumbs .sep { opacity: .5; }

/* Typography */
.content h1 { font-size: 34px; line-height: 1.18; letter-spacing: -.02em; font-weight: 720; margin: 8px 0 10px; }
.content h2 { font-size: 23px; line-height: 1.28; letter-spacing: -.01em; font-weight: 680; margin: 44px 0 12px; padding-top: 6px; }
.content h3 { font-size: 18px; font-weight: 660; margin: 30px 0 8px; }
.content h4 { font-size: 15px; font-weight: 680; margin: 22px 0 6px; color: var(--text-soft); }
.content p { margin: 0 0 16px; color: var(--text-soft); }
.content strong { color: var(--text); font-weight: 660; }
.content em { font-style: italic; }
.content ul, .content ol { margin: 0 0 18px; padding-left: 24px; color: var(--text-soft); }
.content li { margin: 6px 0; }
.content li::marker { color: var(--text-muted); }
.content li.task { list-style: none; margin-left: -22px; display: flex; gap: 9px; align-items: flex-start; }
.content li.task input { margin-top: 5px; accent-color: var(--accent); }
.content hr { border: none; border-top: 1px solid var(--border); margin: 34px 0; }
.content a { color: var(--accent-text); font-weight: 500; }

/* Section anchors */
.content h1[id], .content h2[id], .content h3[id] { scroll-margin-top: 78px; position: relative; }

/* Blockquote → callout (the "wow" lines shine here) */
.content blockquote {
  margin: 22px 0; padding: 16px 20px;
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  background: var(--bg-subtle); border-radius: var(--radius);
  color: var(--text); font-size: 17px; line-height: 1.55;
}
.content blockquote p { color: var(--text); margin: 0 0 10px; }
.content blockquote p:last-child { margin-bottom: 0; }
.content blockquote strong { color: var(--text); }

/* Inline code + code blocks */
.content code {
  font-family: var(--font-mono); font-size: .88em;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: 6px; padding: .12em .4em; color: var(--accent-text);
}
.content pre {
  margin: 20px 0; padding: 18px 20px; overflow-x: auto;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.content pre code {
  background: none; border: none; padding: 0; color: var(--text-soft);
  font-size: 13px; line-height: 1.55; white-space: pre;
}

/* Tables */
.table-scroll { overflow-x: auto; margin: 20px 0; border: 1px solid var(--border); border-radius: var(--radius); }
.content table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.content thead th {
  text-align: left; font-weight: 640; color: var(--text);
  background: var(--bg-subtle); padding: 11px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.content tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text-soft); vertical-align: top; }
.content tbody tr:last-child td { border-bottom: none; }
.content tbody tr:nth-child(even) { background: color-mix(in srgb, var(--bg-subtle) 55%, transparent); }

/* Doc separators (multi-doc pages) */
.doc-sep { height: 1px; background: var(--border); margin: 60px 0; border: none; }

/* ---------- Right TOC ---------- */
.toc { position: sticky; top: 60px; align-self: start; height: calc(100vh - 60px); overflow-y: auto; padding: 46px 20px 60px 8px; }
.toc h5 { margin: 0 0 10px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); font-weight: 700; }
.toc a { display: block; padding: 4px 10px; border-left: 2px solid var(--border); color: var(--text-muted); font-size: 13px; line-height: 1.4; }
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.l3 { padding-left: 22px; font-size: 12.5px; }
.toc a.active { color: var(--accent-text); border-left-color: var(--accent); font-weight: 600; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 640; padding: 2px 9px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap; line-height: 1.6;
}
.badge.frozen { background: var(--frozen-bg); color: var(--frozen); }
.badge.review { background: var(--info-bg); color: var(--info); }
.badge.progress { background: var(--warn-bg); color: var(--warn); }
.badge.planned { background: var(--muted-bg); color: var(--muted-fg); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }

/* ---------- Cards (home) ---------- */
.hero { padding: 40px 0 8px; }
.hero .eyebrow { color: var(--accent-text); font-weight: 640; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }
.hero h1 { font-size: 44px; line-height: 1.1; letter-spacing: -.025em; font-weight: 740; margin: 12px 0 14px; }
.hero p.lede { font-size: 19px; color: var(--text-soft); max-width: 640px; }
.hero .signature { margin-top: 18px; font-size: 20px; font-weight: 640; color: var(--text); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; margin: 26px 0; }
.card {
  display: block; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); }
.card .card-ico { width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); display: flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.card h3 { margin: 0 0 4px; font-size: 16px; font-weight: 660; }
.card p { margin: 0; color: var(--text-muted); font-size: 14px; }
.card .card-meta { margin-top: 12px; display: flex; align-items: center; gap: 8px; }

.section-title { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); font-weight: 700; margin: 40px 0 4px; }

/* ---------- Timeline ---------- */
.timeline { position: relative; margin: 24px 0; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding: 0 0 22px 8px; }
.timeline-item::before {
  content: ""; position: absolute; left: -26px; top: 4px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--bg); border: 3px solid var(--border-strong);
}
.timeline-item.done::before { border-color: var(--accent); background: var(--accent); }
.timeline-item.active::before { border-color: var(--accent); background: var(--bg); box-shadow: 0 0 0 4px var(--accent-soft); }
.timeline-item h4 { margin: 0 0 2px; font-size: 15px; font-weight: 640; }
.timeline-item p { margin: 0; color: var(--text-muted); font-size: 13.5px; }
.timeline-item .ti-head { display: flex; align-items: center; gap: 10px; }

/* ---------- Placeholder (upcoming phases) ---------- */
.placeholder { text-align: center; padding: 70px 20px; }
.placeholder .ph-ico { width: 64px; height: 64px; border-radius: 16px; background: var(--accent-soft); color: var(--accent-text); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 18px; }
.placeholder h1 { font-size: 30px; margin: 0 0 8px; }
.placeholder p { color: var(--text-muted); max-width: 460px; margin: 0 auto 8px; }

/* ---------- Prev / Next ---------- */
.prevnext { display: flex; gap: 16px; margin: 56px auto 0; max-width: var(--content-max); }
.prevnext a {
  flex: 1; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, transform .15s ease;
}
.prevnext a:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.prevnext a.next { text-align: right; }
.prevnext .pn-label { font-size: 12px; color: var(--text-muted); }
.prevnext .pn-title { font-weight: 620; margin-top: 3px; }
.prevnext a.disabled { opacity: .4; pointer-events: none; }

.page-foot { max-width: var(--content-max); margin: 40px auto 0; padding-top: 20px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* ---------- Responsive ---------- */
.scrim { display: none; }
@media (max-width: 1100px) {
  .main { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-flex; }
  .search { width: auto; flex: 1; }
  .search kbd { display: none; }
  .sidebar {
    position: fixed; top: 60px; left: 0; z-index: 45; width: 300px;
    background: var(--bg-elev); transform: translateX(-104%);
    transition: transform .25s ease; box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim { display: block; position: fixed; inset: 60px 0 0 0; background: rgba(0,0,0,.4); z-index: 44; }
  .content-wrap { padding: 30px 22px 60px; }
  .hero h1 { font-size: 34px; }
}

/* ---------- Print ---------- */
@media print {
  .topbar, .sidebar, .toc, .prevnext, .menu-btn, .search, .icon-btn, .scrim { display: none !important; }
  .shell, .main { display: block; }
  .content-wrap { padding: 0; }
  .content { max-width: none; }
  body { font-size: 12pt; color: #000; background: #fff; }
  .content blockquote { break-inside: avoid; }
  .content pre, .table-scroll { break-inside: avoid; }
  a { color: #000; text-decoration: underline; }
}
