/* Spitt app styles — ports prototype styles.css (lines 110+) + settings
   styles from marketing-styles.css. Tokens live in /spitt/tokens.css. */

/* -------- Reset / globals (tokens already set <html>) -------- */

* { box-sizing: border-box; }
html, body, #root { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  background: var(--void);
  color: var(--ink-1);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.mono { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.02em; }
.muted { color: var(--ink-3); }
.display { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.02em; }

/* -------- APP SHELL -------- */

.app-shell {
  min-height: 100%;
  display: flex; flex-direction: column;
}

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--edge);
  background: var(--void);
  position: sticky; top: 0; z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-tag {
  font-family: var(--font-mono); font-size: 10px;
  padding: 2px 8px; border: 1px solid var(--edge);
  border-radius: 999px; color: var(--ink-3);
}

.nav { display: flex; gap: 4px; margin-left: 20px; }
.nav a, .nav button {
  padding: 6px 14px; border-radius: 6px;
  color: var(--ink-2); font-size: 13px;
  font-family: var(--font-sans);
  text-decoration: none;
}
.nav a:hover, .nav button:hover { color: var(--ink-1); }
.nav a.on, .nav button.on { background: var(--surface); color: var(--ink-1); }

.topbar .spacer { flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  color: var(--ink-3);
  border: 1px solid transparent;
}
.icon-btn:hover { color: var(--ink-1); border-color: var(--edge); }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--sage);
  display: grid; place-items: center;
  color: #1d2420; font-size: 11px; font-family: var(--font-mono);
}

/* app-mode switch — simple "app ↔ marketing" toggle */
.app-mode-switch {
  display: inline-flex; background: var(--void); border: 1px solid var(--edge);
  border-radius: 999px; overflow: hidden; margin-right: 8px;
}
.app-mode-switch a, .app-mode-switch button {
  padding: 5px 12px; font-size: 11px; color: var(--ink-2);
  display: inline-flex; gap: 6px; align-items: center;
  text-decoration: none;
}
.app-mode-switch a.on, .app-mode-switch button.on { background: var(--ink-1); color: var(--void); }

/* -------- PAGE -------- */

.page {
  flex: 1;
  display: flex;
  overflow: hidden;
}
.page-main {
  flex: 1; overflow: auto;
  padding: 0;
}

/* -------- DASHBOARD -------- */

.dash-wrap {
  padding: 32px 48px 80px;
  max-width: 1400px;
  margin: 0 auto;
}

.welcome-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  border: 1px solid var(--edge);
  border-radius: 10px;
  background: var(--surface);
  margin-bottom: 40px;
}
.welcome-mascot-slot {
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-1);
  flex-shrink: 0;
  margin: -6px 0;
}
.noticed-panel .panel-head { position: relative; }
.noticed-mascot {
  position: absolute;
  right: -6px; top: -18px;
  color: var(--ink-2);
  opacity: 0.9;
  pointer-events: none;
}
.welcome-text { flex: 1; font-size: 14px; color: var(--ink-2); }
.welcome-text strong { color: var(--ink-1); font-weight: 500; margin-right: 4px; }
.welcome-link { color: var(--accent); text-decoration: none; margin-left: 10px; font-family: var(--font-mono); font-size: 11px; }

.dash-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  margin-bottom: 36px;
}
.dash-head h1 {
  font-family: var(--font-display);
  font-size: 52px; font-weight: 400;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  line-height: 1;
}
.dash-head p { margin: 0; color: var(--ink-3); font-size: 14px; }
.dash-head-meta { text-align: right; line-height: 1.6; }

.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px; background: var(--edge);
  border: 1px solid var(--edge); border-radius: 10px; overflow: hidden;
  margin-bottom: 32px;
}
.stat-card { background: var(--surface); padding: 20px 22px; }
.stat-label { color: var(--ink-3); font-size: 10px; text-transform: uppercase; margin-bottom: 14px; }
.stat-value { font-family: var(--font-mono); font-size: 40px; font-weight: 500; color: var(--ink-1); line-height: 1; letter-spacing: -0.02em; }
.stat-trend { margin-top: 12px; font-size: 11px; }

.dash-main {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 24px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 24px;
}
.panel.compact { padding: 20px 24px; }
.panel-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 18px;
}
.panel h2 {
  font-family: var(--font-display);
  font-weight: 400; font-size: 22px;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}
.small { font-size: 12px; }

/* Mini constellation */
.mini-const {
  height: 280px;
  position: relative;
  cursor: pointer;
  margin: 0 -4px;
}
.mini-const svg { width: 100%; height: 100%; }
.mini-hint {
  position: absolute; bottom: 4px; right: 8px;
  color: var(--ink-3); font-size: 10px; opacity: 0.6;
}
.mini-const:hover .mini-hint { opacity: 1; color: var(--accent); }

/* Activity feed */
.feed { list-style: none; padding: 0; margin: 0; }
.feed li {
  display: grid;
  grid-template-columns: 60px 100px 1fr auto;
  gap: 12px; align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--edge);
  font-size: 13px;
}
.feed li:last-child { border-bottom: 0; }
.feed-what { color: var(--ink-2); font-size: 12px; text-transform: lowercase; }
.feed-target { color: var(--ink-1); }
.feed-src { text-align: right; }

/* Recent list */
.recent-list { list-style: none; padding: 0; margin: 0; }
.recent-list li {
  display: grid;
  grid-template-columns: 8px 1fr auto auto auto;
  gap: 12px; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--edge);
  font-size: 13px;
}
.recent-list li:last-child { border-bottom: 0; }
.cat-dot { width: 8px; height: 8px; border-radius: 50%; }
.cat-engineering { background: var(--sage); }
.cat-product { background: var(--bone-node); }
.cat-reference { background: var(--muted-node); }
.cat-career { background: var(--muted-node); }
.cat-personal { background: var(--dim-node); }
.cat-academics { background: var(--sage); }
.cat-other { background: var(--muted-node); }
.rec-title { color: var(--ink-1); }
.rec-seg, .rec-up { font-size: 11px; }

/* Notice list */
.notice-list { list-style: none; padding: 0; margin: 0; }
.notice-list li {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 14px; align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--edge);
  font-size: 13px;
  color: var(--ink-2);
}
.notice-list li:last-child { border-bottom: 0; }
.notice-list em { color: var(--accent); font-style: normal; }

/* Status chip */
.status-chip {
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.status-chip.active { background: rgba(135,160,140,0.18); color: var(--sage); }
.status-chip.dormant { background: transparent; color: var(--ink-3); border: 1px solid var(--edge); }
.status-chip.flag { background: rgba(183,87,44,0.18); color: var(--rust); }
.status-chip.success { background: rgba(135,160,140,0.18); color: var(--sage); }

/* Buttons (used in welcome bar, panels, settings) */
.btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink-2);
  border: 1px solid var(--edge);
  white-space: nowrap;
}
.btn:hover { color: var(--ink-1); border-color: var(--ink-3); }
.btn.ghost { background: transparent; }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; border-color: transparent; }
.btn.small { padding: 4px 10px; font-size: 11px; }
.btn.danger { color: var(--rust); }
.btn.ghost.danger { background: transparent; color: var(--rust); }

.x {
  width: 28px; height: 28px; border-radius: 6px;
  color: var(--ink-3); font-size: 20px; line-height: 1;
}
.x:hover { color: var(--ink-1); background: var(--surface-2); }
.x.small { width: 20px; height: 20px; font-size: 14px; }

/* =============================================================
   SETTINGS PAGE (sidebar hub)
   ============================================================= */
.settings-page {
  display: grid; grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 62px);
  background: var(--void);
}
.settings-nav {
  border-right: 1px solid var(--edge);
  background: color-mix(in oklab, var(--surface) 50%, transparent);
}
.settings-nav-inner { padding: 24px 16px; display: flex; flex-direction: column; gap: 20px; position: sticky; top: 62px; }
.settings-nav-head { display: flex; flex-direction: column; gap: 12px; }
.settings-nav-search {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border: 1px solid var(--edge); border-radius: 8px;
  background: var(--void);
}
.settings-nav-search .mono { color: var(--ink-3); font-size: 9px; padding: 2px 5px; background: var(--surface); border-radius: 3px; }
.settings-nav-search input { flex: 1; background: transparent; border: 0; color: var(--ink-1); font-size: 12px; outline: none; }
.settings-nav-group { display: flex; flex-direction: column; gap: 2px; }
.settings-nav-group-h { font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; padding: 0 10px 6px; }
.settings-nav-item {
  padding: 7px 10px; font-size: 13px; color: var(--ink-2); border-radius: 6px;
  text-align: left;
}
.settings-nav-item:hover { background: color-mix(in oklab, var(--ink-1) 5%, transparent); color: var(--ink-1); }
.settings-nav-item.on { background: color-mix(in oklab, var(--accent) 14%, transparent); color: var(--ink-1); }
.settings-nav-item.danger { color: var(--rust); }
.settings-nav-foot { padding-top: 12px; border-top: 1px solid var(--edge); }

.settings-main {
  padding: 40px 48px;
  max-width: 920px; width: 100%;
}
.set-h {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px;
  margin-bottom: 32px;
}
.set-h1 { font-family: var(--font-display); font-size: 36px; line-height: 1.05; letter-spacing: -0.02em; margin: 4px 0 8px; font-weight: 400; }
.set-lede { font-size: 14px; color: var(--ink-2); max-width: 640px; margin: 0; line-height: 1.5; }

.set-card {
  background: var(--surface); border: 1px solid var(--edge); border-radius: 12px;
  margin-bottom: 20px;
}
.set-card-h { padding: 16px 20px; border-bottom: 1px solid var(--edge); display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.set-card-t { font-family: var(--font-display); font-size: 16px; font-weight: 500; }
.set-card-body { padding: 4px 20px; }
.set-card-f { padding: 12px 20px; border-top: 1px solid var(--edge); background: color-mix(in oklab, var(--void) 30%, transparent); }

.set-row {
  display: grid; grid-template-columns: 260px 1fr;
  gap: 24px; align-items: center;
  padding: 16px 0; border-bottom: 1px dashed var(--edge);
}
.set-row:last-child { border-bottom: none; }
.set-row-h { font-size: 13px; color: var(--ink-1); font-weight: 500; }
.set-row-hint { font-size: 10px; margin-top: 3px; }
.set-row-ctl { display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; }

.set-input {
  padding: 8px 12px; border: 1px solid var(--edge); border-radius: 7px;
  background: var(--void); color: var(--ink-1); font-size: 13px;
  font-family: var(--font-sans); min-width: 260px; outline: none;
}
.set-input:focus { border-color: var(--accent); }
.set-input.mono { font-family: var(--font-mono); }
textarea.set-input { width: 100%; resize: vertical; }
select.set-input { cursor: pointer; }

.set-toggle {
  width: 40px; height: 22px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--edge);
  position: relative; cursor: pointer; transition: background 0.15s ease;
}
.set-toggle.on { background: var(--accent); border-color: transparent; }
.set-toggle-knob { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.2s ease; }
.set-toggle.on .set-toggle-knob { transform: translateX(18px); }

.set-seg {
  display: inline-flex; border: 1px solid var(--edge); border-radius: 8px; overflow: hidden;
  background: var(--void);
}
.set-seg button { padding: 6px 12px; font-size: 12px; color: var(--ink-2); border-right: 1px solid var(--edge); }
.set-seg button:last-child { border-right: none; }
.set-seg button.on { background: var(--accent); color: #fff; }

.set-pill { padding: 5px 10px; border-radius: 6px; font-size: 11px; background: var(--void); border: 1px solid var(--edge); }
.set-pill.on { background: color-mix(in oklab, var(--sage) 16%, transparent); color: var(--sage); border-color: transparent; }

.profile-top { display: flex; gap: 16px; align-items: center; padding: 12px 0; border-bottom: 1px dashed var(--edge); }
.avatar-lg { width: 64px; height: 64px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-family: var(--font-display); font-size: 24px; font-weight: 500; }
.avatar-sm { width: 32px; height: 32px; border-radius: 50%; background: color-mix(in oklab, var(--accent) 70%, var(--ink-1) 30%); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 500; flex-shrink: 0; }
.profile-top-text .mono { font-size: 10px; }
.profile-top-actions { display: flex; gap: 8px; margin-top: 6px; }

.set-quota-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 16px 0; }
.set-quota { padding: 14px; border: 1px solid var(--edge); border-radius: 8px; background: var(--void); }
.set-quota-v { font-family: var(--font-display); font-size: 22px; font-weight: 400; margin-top: 4px; }

.capt-head, .capt-row, .team-head, .team-row, .audit-head, .audit-row {
  display: grid; grid-template-columns: 160px 1fr auto;
  gap: 16px; padding: 12px 0; align-items: center;
  border-bottom: 1px dashed var(--edge);
  font-size: 13px;
}
.capt-head { padding-top: 4px; border-bottom-style: solid; font-size: 10px; }
.capt-row:last-child, .team-row:last-child, .audit-row:last-child { border-bottom: none; }
.team-head, .team-row { grid-template-columns: 2fr 1fr 1fr auto; }
.team-who { display: flex; gap: 10px; align-items: center; }
.team-n { font-size: 13px; font-weight: 500; }
.audit-head, .audit-row { grid-template-columns: 60px 200px 1fr 120px; }

.conn-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.conn-card {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
  padding: 14px; border: 1px solid var(--edge); border-radius: 10px; background: var(--surface);
}
.conn-glyph { width: 36px; height: 36px; border-radius: 8px; color: #fff; display: grid; place-items: center; font-family: var(--font-mono); font-weight: 600; }
.conn-n { font-family: var(--font-display); font-size: 15px; font-weight: 500; }
.conn-ctl { display: flex; gap: 8px; align-items: center; }

.api-key-row {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 12px; align-items: center;
  padding: 12px 0; border-bottom: 1px dashed var(--edge);
}
.api-key-row:last-child { border-bottom: none; }
.api-key-n { font-size: 13px; font-weight: 500; }
.api-key-val { font-size: 12px; color: var(--ink-2); }

.hook-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px; align-items: center; padding: 10px 0; }
.hook-events { font-size: 10px; }
.hook-state.on { color: var(--sage); padding: 3px 8px; background: color-mix(in oklab, var(--sage) 14%, transparent); border-radius: 4px; font-size: 10px; }

.set-billing-top { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; gap: 16px; flex-wrap: wrap; }
.set-billing-plan { font-family: var(--font-display); font-size: 24px; font-weight: 500; margin: 4px 0; }

.kbd-grid { display: flex; flex-direction: column; gap: 4px; padding: 8px 0; }
.kbd-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 16px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--edge); }
.kbd-row:last-child { border-bottom: none; }
.kbd-key { padding: 4px 8px; background: var(--void); border: 1px solid var(--edge); border-radius: 4px; font-size: 11px; text-align: center; }
.kbd-d { font-size: 13px; }

/* Loading / empty states for panels */
.panel-empty { padding: 24px; text-align: center; color: var(--ink-3); font-size: 13px; }
.panel-loading { padding: 24px; color: var(--ink-3); font-size: 12px; font-family: var(--font-mono); }

/* Responsive */
@media (max-width: 1024px) {
  .dash-main { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 960px) {
  .set-quota-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-page { grid-template-columns: 1fr; }
  .settings-nav { border-right: none; border-bottom: 1px solid var(--edge); }
  .settings-nav-inner { position: static; flex-direction: row; flex-wrap: wrap; }
  .settings-main { padding: 24px; }
  .set-row { grid-template-columns: 1fr; }
  .set-row-ctl { justify-content: flex-start; }
  .conn-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .dash-wrap { padding: 20px 20px 48px; }
  .dash-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .dash-head h1 { font-size: 40px; }
  .dash-head-meta { text-align: left; }
  .stat-grid { grid-template-columns: 1fr 1fr; }

  /* Topbar on phones: wrap into two rows so nav tabs stay reachable.
   * Row 1: brand + theme + avatar (app↔marketing switch + beta pill
   * hidden; they bloat the row and duplicate what's in the marketing
   * footer). Row 2: nav tabs (Dashboard / Constellation / Settings),
   * full width, left-aligned, scrollable if they still overflow. */
  .topbar {
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 12px 16px;
  }
  .topbar .brand-tag { display: none; }
  .topbar .app-mode-switch { display: none; }
  .topbar-right { gap: 8px; }
  .topbar .spacer { flex: 1; }
  .nav {
    order: 3;
    flex-basis: 100%;
    margin-left: 0;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a, .nav button { font-size: 12px; padding: 6px 12px; white-space: nowrap; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .dash-head h1 { font-size: 32px; }
}

/* =============================================================
   CONSTELLATION VIEW (ported from prototype styles.css)
   ============================================================= */

.constellation-wrap {
  position: relative;
  height: calc(100vh - 62px);
  overflow: hidden;
  background: var(--void);
}
.constellation-surface {
  position: absolute; inset: 0;
  overflow: hidden;
  cursor: grab;
}
.constellation-surface:active { cursor: grabbing; }

.const-controls {
  position: absolute;
  top: 18px; left: 18px; right: 18px;
  display: flex; justify-content: space-between; align-items: center;
  z-index: 2;
  gap: 12px;
  flex-wrap: wrap;
}

.seg-control {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 3px;
}
.seg-control button {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 6px;
  color: var(--ink-3);
  display: inline-flex; align-items: center; gap: 6px;
}
.seg-control button:hover { color: var(--ink-1); }
.seg-control button.on { background: var(--surface-2); color: var(--ink-1); }
.seg-control .dot { width: 7px; height: 7px; border-radius: 50%; }

.const-meta {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 6px 12px;
  font-family: var(--font-mono); font-size: 11px;
}
.meta-sep { width: 1px; height: 12px; background: var(--edge); }
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 var(--live);
  animation: livePulse 2s infinite;
}
@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(135,160,140,0.5); }
  70% { box-shadow: 0 0 0 8px rgba(135,160,140,0); }
  100% { box-shadow: 0 0 0 0 rgba(135,160,140,0); }
}

.hover-card {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 12px 14px;
  max-width: 280px;
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.hc-title { font-size: 13px; color: var(--ink-1); margin-bottom: 4px; }
.hc-meta { font-size: 10px; color: var(--ink-3); margin-bottom: 8px; text-transform: lowercase; }
.hc-summary { font-size: 12px; color: var(--ink-2); line-height: 1.5; }

.deselect-pill {
  position: absolute;
  top: 72px; right: 20px;
  z-index: 3;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  color: var(--ink-2);
  display: inline-flex; gap: 8px; align-items: center;
}
.deselect-pill:hover { color: var(--ink-1); border-color: var(--accent); }
.deselect-pill .mono {
  background: var(--void); padding: 2px 6px; border-radius: 3px;
  color: var(--ink-3); font-size: 10px;
}

.stat-overlay {
  position: absolute;
  bottom: 20px; right: 20px;
  width: 200px;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 14px;
  z-index: 2;
}
.stat-row {
  display: flex; justify-content: space-between;
  padding: 4px 0;
  font-size: 11px;
}

@keyframes fanIn {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: scale(1); }
}

/* =============================================================
   DETAIL SHEET (bottom sheet with thread / segment drill-down)
   ============================================================= */

.bs-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 39;
  animation: bsFadeIn 180ms ease-out;
}
/* Light mode: a cream-on-cream sheet against a cream page has no contrast.
   Use the ink-1 (near-black) token to mix a scrim that darkens the page
   behind the sheet while still feeling warm, not clinical. */
[data-mode="light"] .bs-backdrop {
  background: color-mix(in oklab, var(--ink-1) 40%, transparent);
}
@keyframes bsFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.bottom-sheet {
  position: fixed;
  left: 16px; right: 16px; bottom: 16px;
  max-width: 1180px; margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 14px;
  padding: 14px 24px 22px;
  z-index: 40;
  box-shadow: 0 -10px 40px rgba(0,0,0,0.3);
  animation: sheetIn 300ms cubic-bezier(0.2,0.9,0.3,1);
  max-height: 72vh;
  overflow-y: auto;
}
@keyframes sheetIn {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.bs-top {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 12px; margin-bottom: 16px;
  border-bottom: 1px solid var(--edge);
}
.small-btn { padding: 4px 10px; font-size: 11px; }

.crumbs { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crumb-link {
  font-size: 12px; color: var(--ink-3);
  border-bottom: 1px dashed var(--ink-4);
  padding: 2px 0;
}
.crumb-link:hover { color: var(--accent); border-color: var(--accent); }
.crumb-here { font-size: 12px; color: var(--ink-1); font-family: var(--font-display); }
.crumb-sep { color: var(--ink-4); }

.bs-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 24px; margin-bottom: 22px;
}
.bs-head h2 {
  font-family: var(--font-display); font-weight: 400; font-size: 26px;
  margin: 6px 0 8px; letter-spacing: -0.01em; line-height: 1.15;
}
.bs-meta { text-align: right; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.bs-meta .big { font-size: 22px; color: var(--ink-1); }
.bs-columns { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 28px; }
.bs-columns p { font-size: 13px; line-height: 1.55; color: var(--ink-2); margin: 0; }
.bs-columns.seg-cols { grid-template-columns: 1.6fr 1fr; }

.overlay-summary { font-size: 14px; line-height: 1.55; color: var(--ink-2); margin: 10px 0 24px; }

.sect-label {
  color: var(--ink-3); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.1em;
  margin-bottom: 10px;
}

.small-help { font-size: 10px; margin-left: 6px; text-transform: none; letter-spacing: 0; }

.seg-list, .rel-list {
  list-style: none; padding: 0; margin: 0;
}
.seg-list li, .rel-list li {
  display: flex; gap: 12px; align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--edge);
  font-size: 13px;
}
.seg-list li:last-child, .rel-list li:last-child { border-bottom: 0; }
.seg-list li.flag .seg-title { color: var(--accent); }
.seg-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.seg-title { flex: 1; color: var(--ink-1); }
.rel-list li { justify-content: space-between; }
.rel-title { color: var(--ink-1); font-size: 13px; }

.seg-list.compact li, .rel-list.compact li { padding: 5px 0; font-size: 12px; }

.seg-list.interactive li, .rel-list.interactive li {
  cursor: pointer; padding-right: 8px;
  border-radius: 4px;
  transition: background 120ms;
}
.seg-list.interactive li:hover, .rel-list.interactive li:hover {
  background: var(--surface-2);
  padding-left: 6px; padding-right: 6px;
  margin: 0 -6px;
}
.seg-arrow { color: var(--ink-4); font-size: 11px; }
.seg-list.interactive li:hover .seg-arrow,
.rel-list.interactive li:hover .seg-arrow { color: var(--accent); }

.rel-list.compact li { display: flex; align-items: center; gap: 10px; }
.rel-list.compact .rel-title { flex: 1; color: var(--ink-1); font-size: 12.5px; }
.rel-list .empty { color: var(--ink-3); font-style: italic; padding: 6px 0; }

.inline-link {
  color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px;
  text-decoration-color: var(--ink-4);
  font-family: var(--font-display); font-size: 13px; margin-left: 6px;
  background: none; border: 0; padding: 0; cursor: pointer;
}
.inline-link:hover { color: var(--accent); text-decoration-color: var(--accent); }

.depth-badge {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--edge);
  border-radius: 3px;
  font-size: 9px;
  color: var(--ink-2);
  margin-right: 8px;
  letter-spacing: 0.05em;
}

.sub-seg-list {
  background: var(--surface-2);
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 4px 10px;
  margin-bottom: 4px;
}
.sub-seg-list li { padding: 8px 4px; }

.capture-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 10px;
}
.cap {
  background: var(--void);
  border: 1px solid var(--edge);
  border-left: 2px solid var(--ink-4);
  border-radius: 6px;
  padding: 12px 14px;
}
.cap.cap-claude { border-left-color: var(--sage); }
.cap.cap-doc { border-left-color: var(--bone-node); }
.cap.cap-note { border-left-color: var(--accent); }
.cap.cap-gpt-4 { border-left-color: #8d9cba; }
.cap-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.cap-src { text-transform: lowercase; color: var(--ink-2); }
.cap-src.src-note { color: var(--accent); }
.cap-when { font-size: 10px; }
.cap-body { margin: 0; font-size: 13px; line-height: 1.55; color: var(--ink-1); }

.seg-backlink {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--edge);
  border-radius: 8px;
  background: var(--surface-2);
  font-size: 13px;
  color: var(--ink-1);
  text-align: left;
  cursor: pointer;
}
.seg-backlink:hover { border-color: var(--accent); }
.seg-backlink .seg-arrow { margin-left: auto; }

/* Constellation + detail-sheet responsive */
@media (max-width: 960px) {
  .bs-columns, .bs-columns.seg-cols { grid-template-columns: 1fr; }
  .stat-overlay { display: none; }
}
@media (max-width: 640px) {
  .const-controls { top: 12px; left: 12px; right: 12px; }
  .bottom-sheet { left: 8px; right: 8px; bottom: 8px; padding: 12px 16px 18px; }
  .bs-head { flex-direction: column; gap: 12px; }
  .bs-meta { text-align: left; align-items: flex-start; }
}
