/* ============================================================
   OBIA COCKPIT — visual system
   Built to the obia-cockpit-main reference rendering.
   Single screen. No build step. No dependencies.
   ============================================================ */

:root {
  color-scheme: dark;

  --ink:      #dfe9f3;
  --ink-soft: #c6d6e5;
  --muted:    #8fa5b9;
  --dim:      #7f95aa;   /* AA floor on the cellar backdrop */

  --cyan:   #5cc8f0;
  --teal:   #5fd39a;
  --amber:  #e0a44e;
  --red:    #e8756a;

  --card:       rgba(9, 17, 26, .58);
  --card-line:  rgba(126, 170, 208, .22);
  --inner-line: rgba(126, 170, 208, .13);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", sans-serif;
  --display: var(--sans);
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;

  --type-label: 12px;
  --type-small: 14px;
  --type-body: 16px;
  --type-title: clamp(24px, 6vw, 32px);
  --weight-regular: 400;
  --weight-medium: 520;
  --weight-strong: 620;

  /* Presentation-only values loaded from public/ui-config.json. */
  --core-primary: #5bd6b5;
  --core-accent: #d8a85a;

  --topbar-h: 58px;
  --banner-h: 0px;
}

* { box-sizing: border-box; }
html { height: 100%; background: #04070b; }

body {
  height: 100dvh; margin: 0; overflow: hidden;
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  background: #04070b;
}

.auth-gate {
  position: fixed; z-index: 200; inset: 0; display: grid; place-items: center;
  min-height: 100dvh; padding: max(22px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(2,10,8,.91), rgba(2,7,6,.98)), radial-gradient(ellipse at 50% 18%, rgba(49,132,108,.16), transparent 56%);
  transition: opacity .2s ease;
}
.auth-gate[hidden] { display: none; }
.auth-gate-leaving { opacity: 0; pointer-events: none; }
.auth-gate-panel { width: min(100%, 520px); }
.auth-gate-panel h1 { max-width: 14ch; margin: 10px 0 16px; color: #f2eee5; font: 400 clamp(34px, 9vw, 58px)/1.03 var(--display); }
.auth-gate-copy { max-width: 46ch; margin: 0 0 28px; color: #b8c3bb; font-size: 16px; line-height: 1.55; }
.auth-gate-panel label { display: block; margin-bottom: 8px; color: #dce6df; font-size: 13px; }
.auth-gate-action { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; }
.auth-gate-action input, .auth-gate-action button { min-height: 52px; border: 1px solid rgba(123,172,153,.38); border-radius: 12px; }
.auth-gate-action input { min-width: 0; padding: 0 14px; background: rgba(2,14,11,.72); color: #f4efe5; font-size: 16px; }
.auth-gate-action button { padding: 0 17px; background: #4fc4a5; color: #03100d; font-weight: 700; }
.auth-gate-status { min-height: 24px; margin: 17px 0 7px; color: #77d6bc; line-height: 1.5; }
.auth-gate-panel > .ghost-button { min-height: 44px; color: #dff8f0; background: rgba(13,48,39,.72); border-color: rgba(91,214,181,.38); }
.auth-gate-note { margin: 18px 0 0; color: #87968d; font-size: 12px; line-height: 1.5; }
@media (max-width: 520px) { .auth-gate-action { grid-template-columns: 1fr; } .auth-gate-action button { width: 100%; } }

button, input, select { font: inherit; }
button, select { color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible,
a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--cyan); outline-offset: 2px; border-radius: 4px;
}
h1, h2, h3 { margin: 0; font-weight: 400; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; z-index: 200; top: .7rem; left: .7rem;
  padding: .6rem 1rem; color: #04121c; background: var(--cyan);
  border-radius: 8px; text-decoration: none; font-weight: 600;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* thin scrollbars in the few places that scroll */
.card-inner, .response, .proposal-list, .source-grid, .settings, .ev-window-body {
  scrollbar-width: thin; scrollbar-color: rgba(126,170,208,.26) transparent;
}
.card-inner::-webkit-scrollbar, .response::-webkit-scrollbar,
.proposal-list::-webkit-scrollbar, .source-grid::-webkit-scrollbar,
.settings::-webkit-scrollbar, .ev-window-body::-webkit-scrollbar { width: 6px; height: 6px; }
.card-inner::-webkit-scrollbar-thumb, .response::-webkit-scrollbar-thumb,
.proposal-list::-webkit-scrollbar-thumb, .source-grid::-webkit-scrollbar-thumb,
.settings::-webkit-scrollbar-thumb, .ev-window-body::-webkit-scrollbar-thumb {
  background: rgba(126,170,208,.24); border-radius: 4px;
}

/* ============================================================
   BACKDROP — the cellar
   ============================================================ */

.backdrop {
  position: fixed; inset: 0; z-index: 0;
  background: #04070b url("/backdrop.jpg") center/cover no-repeat;
}
.backdrop-veil {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(ellipse 58% 62% at 50% 46%, rgba(4, 8, 13, .90) 0%, rgba(4, 8, 13, .55) 45%, transparent 78%),
    radial-gradient(ellipse 80% 70% at 50% 50%, transparent 40%, rgba(3, 6, 10, .82) 100%),
    linear-gradient(180deg, rgba(4,8,13,.85) 0%, transparent 22%, transparent 70%, rgba(3,6,10,.88) 100%);
}

/* ============================================================
   PREVIEW BANNER (dev only)
   ============================================================ */

.preview-banner {
  position: fixed; z-index: 300; top: 0; left: 0; right: 0; height: 28px;
  display: flex; gap: 12px; align-items: center; justify-content: center;
  background: repeating-linear-gradient(135deg, rgba(224,164,78,.22) 0 12px, rgba(224,164,78,.10) 12px 24px);
  border-bottom: 1px solid rgba(224,164,78,.45);
  color: var(--amber); font-size: 11px; letter-spacing: .05em;
}
.preview-banner[hidden] { display: none; }
.preview-banner strong { letter-spacing: .18em; }
.preview-banner span { color: #f2dcb4; }
body.has-preview-banner { --banner-h: 28px; }
body.has-preview-banner .topbar { top: 28px; }

/* ============================================================
   TOP BAR
   ============================================================ */

.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  height: var(--topbar-h);
  padding: 0 clamp(18px, 2.6vw, 40px);
  display: flex; align-items: center;
}

.brand {
  color: var(--ink); text-decoration: none;
  font-size: clamp(17px, 1.35vw, 21px); font-weight: 300; letter-spacing: .38em;
}

.system-state {
  position: absolute; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 9px;
}
.system-state strong {
  font-size: 11.5px; font-weight: 400; letter-spacing: .24em;
  text-transform: uppercase; color: var(--ink-soft);
}

.state-pip {
  width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto;
  background: var(--cyan); box-shadow: 0 0 10px rgba(92,200,240,.7);
}
.state-pip[data-state="listening"] { animation: pip 1.5s ease-out infinite; }
.state-pip[data-state="thinking"],
.state-pip[data-state="tooling"]   { animation: pip 2.3s ease-out infinite; }
.state-pip[data-state="speaking"]  { animation: pip 1.1s ease-out infinite; }
.state-pip[data-state="review_required"] { background: var(--amber); box-shadow: 0 0 10px rgba(224,164,78,.7); }
.state-pip[data-state="alert"]     { background: var(--red);   box-shadow: 0 0 10px rgba(232,117,106,.7); }
.state-pip[data-state="offline"]   { background: var(--red);   box-shadow: 0 0 10px rgba(232,117,106,.7); }
@keyframes pip {
  0%   { box-shadow: 0 0 0 0    rgba(92,200,240,.5); }
  100% { box-shadow: 0 0 0 11px rgba(92,200,240,0); }
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.conn { display: inline-flex; }
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--amber); box-shadow: 0 0 8px currentColor; color: var(--amber);
}
.status-dot.online  { background: var(--teal); color: var(--teal); }
.status-dot.offline { background: var(--red);  color: var(--red); }
.clock {
  color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums;
  padding-right: 6px;
}
.glyph {
  width: 26px; height: 26px; display: grid; place-items: center;
  border: 0; background: transparent; color: var(--muted);
  transition: color .18s;
}
.glyph:hover { color: var(--ink); }
.glyph svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }

/* ============================================================
   COCKPIT — free layout over the cellar
   ============================================================ */

.cockpit {
  position: fixed; z-index: 10;
  top: calc(var(--topbar-h) + var(--banner-h)); left: 0; right: 0; bottom: 0;
}

/* ---- the graph sits directly on the backdrop, no frame ---- */
.graph-layer { position: absolute; inset: 0; z-index: 1; }
#graph-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#graph-canvas[data-interactive="true"] { cursor: pointer; }
#graph-canvas.dragging { cursor: grabbing; }

.graph-overlay {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  display: grid; justify-items: center; gap: 7px;
  padding: 22px 28px; text-align: center;
  border: 1px solid var(--card-line); border-radius: 13px;
  background: rgba(6, 12, 19, .82); backdrop-filter: blur(8px);
}
.graph-overlay[hidden] { display: none; }
.graph-overlay-title { margin: 0; font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.graph-overlay[data-tone="error"] .graph-overlay-title { color: var(--red); }
.graph-overlay[data-tone="setup"] .graph-overlay-title { color: var(--amber); }
.graph-overlay-body { margin: 0; max-width: 42ch; color: var(--dim); font-size: 12.5px; }

.node-card {
  position: absolute; z-index: 6; pointer-events: none;
  min-width: 190px; max-width: 290px; padding: 10px 12px;
  border: 1px solid var(--card-line); border-radius: 10px;
  background: rgba(6, 12, 19, .95);
  box-shadow: 0 24px 60px rgba(0,0,0,.6); font-size: 11.5px;
}
.node-card .nc-type { color: var(--cyan); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; }
.node-card .nc-title { display: block; margin: 4px 0 6px; color: var(--ink); font-size: 12.5px; }
.node-card dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; }
.node-card dt { color: var(--dim); }
.node-card dd { margin: 0; color: var(--muted); }
.node-card .nc-restricted { display: block; margin-top: 6px; color: var(--amber); font-size: 10.5px; }

.graph-controls {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 15.5%;
  z-index: 4; display: flex; gap: 6px; opacity: 0; transition: opacity .25s;
}
.cockpit:hover .graph-controls, .graph-controls:focus-within { opacity: 1; }
.graph-controls button {
  min-width: 30px; height: 28px; padding: 0 9px;
  border: 1px solid var(--inner-line); border-radius: 7px;
  background: rgba(6, 12, 19, .78); color: var(--muted); font-size: 12px;
}
.graph-controls button:hover { color: var(--ink); border-color: var(--card-line); }

/* ============================================================
   FLOATING COLUMNS
   ============================================================ */

.column {
  position: absolute; z-index: 3;
  top: 4%; bottom: 17.5%;
  width: clamp(228px, 19vw, 320px);
  display: flex; flex-direction: column;
  gap: clamp(16px, 4.5vh, 54px);
  min-height: 0;
}
.column-left  { left: clamp(16px, 2.6vw, 46px); }
.column-right { right: clamp(16px, 2.6vw, 46px); }

/* ---- card ---- */

.card {
  display: flex; flex-direction: column; min-height: 0;
  flex: 0 1 auto;
  padding: 16px 17px 17px;
  border: 1px solid var(--card-line); border-radius: 15px;
  background: var(--card);
  backdrop-filter: blur(13px);
  box-shadow: 0 26px 70px rgba(0,0,0,.42), inset 0 1px rgba(255,255,255,.05);
}
.card-head {
  flex: 0 0 auto;
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 2px 4px 14px;
}
.card-head h2 {
  font-size: clamp(16px, 1.3vw, 20px); font-weight: 300;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink);
}
.freshness { color: var(--dim); font-size: 10px; white-space: nowrap; }
.freshness[data-tone="stale"] { color: var(--amber); }
.freshness[data-tone="error"] { color: var(--red); }

/* rows scroll area — the rows themselves carry the borders */
.card-inner {
  flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain;
  padding: 1px;
}

.card-action {
  flex: 0 0 auto; margin-top: 12px; width: 100%;
}

.ghost-button {
  padding: 9px 12px;
  border: 1px solid var(--inner-line); border-radius: 9px;
  background: rgba(92, 200, 240, .05); color: var(--cyan);
  font-size: 12px; letter-spacing: .02em; transition: background .18s, border-color .18s;
}
.ghost-button:hover { background: rgba(92, 200, 240, .11); border-color: var(--card-line); }

.link-button {
  border: 0; background: transparent; color: var(--cyan);
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; padding: 4px 6px;
}

/* ============================================================
   ROWS — icon, title, subtitle, meta, chevron
   ============================================================ */

.row-list { list-style: none; margin: 0; padding: 0; }
.row-list:empty::after {
  content: attr(data-empty);
  display: block; padding: 15px 14px; color: var(--dim); font-size: 12px;
}
.state-note { margin: 0; padding: 15px 14px; color: var(--dim); font-size: 12px; line-height: 1.5; }
.state-note[data-tone="error"] { color: var(--red); }
.state-note[data-tone="setup"] { color: var(--amber); }
.state-note .state-hint { display: block; margin-top: 4px; font-size: 11px; }

/* each row is its own bordered box, like the reference rendering */
.row {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  align-items: center; gap: 0 12px;
  padding: 11px 12px;
  margin-bottom: 9px;
  border: 1px solid var(--inner-line);
  border-radius: 12px;
  background: rgba(255,255,255,.012);
  cursor: pointer; transition: background .16s, border-color .16s;
}
.row-list > .row:last-child { margin-bottom: 0; }
.row:hover, .row:focus-visible { background: rgba(92, 200, 240, .05); border-color: var(--card-line); }
.row[aria-current="true"] { background: rgba(92, 200, 240, .09); border-color: var(--card-line); }

.row-icon {
  grid-row: 1 / span 2; grid-column: 1;
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--inner-line); border-radius: 50%;
  color: var(--muted);
}
.row-icon.square { border-radius: 10px; }
.row-icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.25; stroke-linecap: round; stroke-linejoin: round; }
.row[data-tone="urgent"]  .row-icon { color: var(--red);   border-color: rgba(232,117,106,.42); }
.row[data-tone="warn"]    .row-icon { color: var(--amber); border-color: rgba(224,164,78,.42); }
.row[data-tone="ok"]      .row-icon { color: var(--teal);  border-color: rgba(95,211,154,.34); }
.row[data-tone="waiting"] .row-icon { color: var(--cyan);  border-color: rgba(92,200,240,.34); }

.row-title {
  grid-row: 1; grid-column: 2;
  font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Only urgent recolours the title — the icon carries every other tone,
   exactly as in the reference rendering. */
.row[data-tone="urgent"] .row-title { color: var(--red); }

.row-sub {
  grid-row: 2; grid-column: 2;
  margin-top: 2px; color: var(--muted); font-size: 11px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.row-spark { grid-row: 1 / span 2; grid-column: 3; width: 78px; height: 26px; opacity: .85; }
.row-spark path { fill: none; stroke: var(--cyan); stroke-width: 1.2; }

.row-dot {
  grid-row: 1 / span 2; grid-column: 3;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); box-shadow: 0 0 8px currentColor;
}
.row[data-tone="urgent"]  .row-dot { background: var(--red);   color: var(--red); }
.row[data-tone="warn"]    .row-dot { background: var(--amber); color: var(--amber); }
.row[data-tone="ok"]      .row-dot { background: var(--teal);  color: var(--teal); }
.row[data-tone="waiting"] .row-dot { background: var(--cyan);  color: var(--cyan); }

/* shape marker so status is never carried by colour alone */
.row-dot::after {
  content: ''; position: absolute; margin: -7px 0 0 -3px;
  font-size: 8px; color: inherit;
}
.row-flag {
  grid-row: 1; grid-column: 3;
  font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim);
  white-space: nowrap;
}
.row[data-tone="urgent"]  .row-flag::before { content: '▲ '; }
.row[data-tone="warn"]    .row-flag::before { content: '◆ '; }
.row[data-tone="ok"]      .row-flag::before { content: '● '; }
.row[data-tone="waiting"] .row-flag::before { content: '◷ '; }

.row-chevron {
  grid-row: 1 / span 2; grid-column: 4;
  width: 14px; height: 14px; color: var(--dim);
}
.row-chevron svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.row:hover .row-chevron { color: var(--ink); }

/* app.js renders plain <li><strong><span> into #attention-list —
   keep that readable even without icons */
.row-list li:not(.row):not(.state-note) {
  padding: 11px 13px; border-top: 1px solid var(--inner-line);
}
.row-list li:not(.row):not(.state-note) strong {
  display: block; font-size: 12px; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-soft);
}
.row-list li:not(.row):not(.state-note) span {
  display: block; margin-top: 2px; color: var(--muted); font-size: 11px;
}

/* ============================================================
   COMMAND BAR
   ============================================================ */

/* Cut-corner octagon: the outer form is the 1px "border",
   the inner div is the surface, both clipped to the same shape. */
.command-bar {
  --cut: 18px;
  position: absolute; z-index: 5;
  left: clamp(16px, 2.6vw, 46px); right: clamp(16px, 2.6vw, 46px);
  bottom: clamp(14px, 2.6vh, 30px);
  padding: 1px;
  background: var(--card-line);
  clip-path: polygon(
    var(--cut) 0, calc(100% - var(--cut)) 0,
    100% var(--cut), 100% calc(100% - var(--cut)),
    calc(100% - var(--cut)) 100%, var(--cut) 100%,
    0 calc(100% - var(--cut)), 0 var(--cut));
  filter: drop-shadow(0 26px 40px rgba(0,0,0,.5));
}
.command-bar-inner {
  min-height: clamp(74px, 10vh, 98px);
  display: flex; align-items: center; gap: clamp(10px, 1.6vw, 26px);
  padding: 12px clamp(16px, 2vw, 30px);
  background: rgba(7, 13, 21, .82);
  backdrop-filter: blur(15px);
  clip-path: polygon(
    var(--cut) 0, calc(100% - var(--cut)) 0,
    100% var(--cut), 100% calc(100% - var(--cut)),
    calc(100% - var(--cut)) 100%, var(--cut) 100%,
    0 calc(100% - var(--cut)), 0 var(--cut));
}

.mic-orb, .send-orb {
  flex: 0 0 auto;
  width: clamp(44px, 3.4vw, 56px); aspect-ratio: 1;
  display: grid; place-items: center;
  border: 1px solid var(--card-line); border-radius: 50%;
  background: rgba(255,255,255,.02); color: var(--ink-soft);
  transition: border-color .18s, background .18s, color .18s;
}
.mic-orb svg, .send-orb svg {
  width: 45%; height: 45%; fill: none; stroke: currentColor;
  stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round;
}
.mic-orb:hover, .send-orb:hover { border-color: rgba(92,200,240,.55); color: var(--cyan); }
.mic-orb.recording {
  background: var(--cyan); color: #04121c; border-color: var(--cyan);
  box-shadow: 0 0 26px rgba(92,200,240,.4);
}

/* --- waveform --- */
.wave {
  flex: 1 1 0; min-width: 0; height: 34px;
  display: flex; align-items: center; gap: 2px; overflow: hidden;
}
.wave i {
  flex: 1 1 auto; min-width: 1px; max-width: 2px; height: 12%;
  background: rgba(150, 200, 235, .5); border-radius: 1px;
  transition: height .22s ease;
}
.wave-right { justify-content: flex-end; }
body[data-voice="listening"] .wave i,
body[data-voice="speaking"]  .wave i { animation: bar 1.05s ease-in-out infinite alternate; background: rgba(150, 210, 245, .8); }
@keyframes bar { from { height: 8%; } to { height: 78%; } }

/* --- centre --- */
.command-centre {
  flex: 0 1 auto; min-width: 0;
  width: clamp(300px, 40%, 720px);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-align: center;
}
.transcript {
  margin: 0; color: var(--dim); font-size: 11px;
  letter-spacing: .04em;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* the centred speech/response line — kept modest so long answers
   stay comfortable */
.response {
  max-height: 5.2em; overflow: auto;
  color: var(--ink); font-size: clamp(13px, 1vw, 15.5px); font-weight: 300;
  letter-spacing: .01em;
  line-height: 1.5; white-space: pre-wrap; width: 100%;
}
.response:empty { display: none; }
.command-bar input {
  width: 100%; padding: 5px 8px; text-align: center;
  border: 0; background: transparent; color: var(--ink); outline: 0;
  font-size: 13.5px;
}
.command-bar input::placeholder { color: var(--dim); }
.answer-meta {
  margin: 0; color: var(--dim); font-size: 9.5px;
  letter-spacing: .1em; text-transform: uppercase;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ============================================================
   OVERLAY PANELS — sources, proposals
   ============================================================ */

.overlay-panel {
  position: fixed; z-index: 35;
  width: clamp(280px, 27vw, 400px);
  max-height: 46dvh;
  display: flex; flex-direction: column;
  border: 1px solid var(--card-line); border-radius: 14px;
  background: rgba(7, 13, 21, .93); backdrop-filter: blur(16px);
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.overlay-panel[hidden] { display: none; }
.overlay-sources { left: clamp(16px, 2.6vw, 46px); bottom: calc(clamp(14px, 2.6vh, 30px) + clamp(76px, 10vh, 100px) + 14px); }
.overlay-review  { right: clamp(16px, 2.6vw, 46px); bottom: calc(clamp(14px, 2.6vh, 30px) + clamp(76px, 10vh, 100px) + 14px); }

.overlay-head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--inner-line);
}
.overlay-head h2 { flex: 1; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink); }
.overlay-close { width: 22px; height: 22px; border: 0; background: transparent; color: var(--dim); font-size: 17px; line-height: 1; }
.overlay-close:hover { color: var(--ink); }

.pill {
  padding: 2px 8px; border: 1px solid var(--inner-line); border-radius: 100px;
  color: var(--muted); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
}
.pill.warning { color: var(--amber); border-color: rgba(224,164,78,.32); }

.source-grid { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px; display: grid; gap: 9px; align-content: start; }
.source-card { width: 100%; padding: 10px 12px; text-align: left; color: inherit; border: 1px solid var(--inner-line); border-radius: 9px; background: rgba(255,255,255,.014); cursor: pointer; }
.source-card:hover, .source-card:focus-visible { border-color: var(--cyan); background: rgba(116,210,255,.07); outline: none; }
.source-card .source-type { color: var(--cyan); font-size: 9px; letter-spacing: .14em; text-transform: uppercase; }
.source-card strong { display: block; margin: 4px 0 3px; font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
.source-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }

.proposal-list { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px; display: grid; gap: 10px; }
.review-boundary-title { margin: 18px 0 4px; color: var(--muted); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.knowledge-approval-card .approval-facts dd { white-space: pre-wrap; overflow-wrap: anywhere; }
.proposal-card {
  padding: 12px; border: 1px solid rgba(224,164,78,.3);
  border-left: 3px solid var(--amber); border-radius: 9px;
  background: rgba(224,164,78,.05);
}
.proposal-card h3 { margin: 0 0 4px; font-size: 12px; font-weight: 600; }
.proposal-card p  { margin: 0; color: var(--muted); font-size: 11px; }
.proposal-card .proposal-destination { margin-top: 6px; color: var(--amber); }
.proposal-exact {
  max-height: 120px; overflow: auto; margin: 9px 0 6px; padding: 9px;
  border: 1px solid var(--inner-line); border-radius: 7px; background: rgba(0,0,0,.32);
  color: var(--muted); font: 10px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere;
}
.proposal-proof { margin: 3px 0; color: var(--dim); font-size: 10px; overflow-wrap: anywhere; }

/* Confirm is deliberately heavier than Reject. Do not equalise. */
.proposal-actions { display: flex; gap: 7px; margin-top: 11px; }
.proposal-actions button {
  padding: 10px 13px; border-radius: 8px; font-size: 12px;
  border: 1px solid var(--inner-line); background: transparent; color: var(--muted);
}
.proposal-actions .review {
  flex: 2; border-color: var(--amber); background: rgba(224,164,78,.17);
  color: #ffd79a; font-weight: 600;
}
.proposal-actions .review:hover { background: rgba(224,164,78,.27); }

/* ============================================================
   EVIDENCE WINDOWS
   ============================================================ */

.window-layer { position: fixed; inset: 0; z-index: 38; pointer-events: none; }
.ev-window {
  position: absolute; pointer-events: auto;
  min-width: 280px; min-height: 170px;
  display: flex; flex-direction: column;
  border: 1px solid var(--card-line); border-radius: 12px;
  background: rgba(8, 14, 22, .95); backdrop-filter: blur(18px);
  box-shadow: 0 30px 80px rgba(0,0,0,.6); overflow: hidden;
}
.ev-window.pinned { border-color: rgba(224,164,78,.45); }
.ev-window-bar {
  display: flex; align-items: center; gap: 9px; padding: 9px 11px;
  border-bottom: 1px solid var(--inner-line); background: rgba(255,255,255,.022);
  cursor: grab; user-select: none; touch-action: none;
}
.ev-window-bar.dragging { cursor: grabbing; }
.ev-window-title { flex: 1; min-width: 0; font-size: 11px; letter-spacing: .13em; text-transform: uppercase;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-window-bar button { width: 23px; height: 23px; display: grid; place-items: center; border: 0; border-radius: 5px; background: transparent; color: var(--dim); }
.ev-window-bar button:hover { color: var(--ink); background: rgba(255,255,255,.06); }
.ev-window-body { flex: 1; overflow: auto; padding: 12px; font-size: 12.5px; }
.ev-window-meta { padding: 8px 12px; border-top: 1px solid var(--inner-line); color: var(--dim); font-size: 10px; }
.ev-window-resize { position: absolute; right: 0; bottom: 0; width: 15px; height: 15px; cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, var(--card-line) 50%); }

/* ============================================================
   SETTINGS
   ============================================================ */

.settings {
  position: fixed; z-index: 60; top: 0; right: 0;
  width: min(400px, 94vw); height: 100dvh; padding: 22px; overflow-y: auto;
  background: #070d15; border-left: 1px solid var(--card-line);
  box-shadow: -30px 0 90px rgba(0,0,0,.65);
}
.settings-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 18px; border-bottom: 1px solid var(--inner-line); }
.eyebrow { margin: 0 0 3px; color: var(--cyan); font-size: 9.5px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; }
.settings-header h2 { font-size: 17px; }
.setting-row { display: flex; gap: 18px; justify-content: space-between; align-items: center; padding: 15px 0; border-bottom: 1px solid var(--inner-line); }
.setting-row span strong, .setting-row span small { display: block; }
.setting-row span strong { font-size: 12.5px; font-weight: 500; }
.setting-row span small { margin-top: 3px; color: var(--muted); font-size: 10.5px; line-height: 1.45; }
.setting-row select { max-width: 145px; padding: 7px; border: 1px solid var(--inner-line); border-radius: 7px; background: #0c1520; font-size: 11.5px; }
.setting-row input { accent-color: var(--cyan); }
.connector-status { padding: 13px 0; border-bottom: 1px solid var(--inner-line); }
.connector-status strong, .connector-status small { display: block; }
.connector-status strong { color: var(--cyan); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; }
.connector-status small { margin-top: 5px; color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.database-login { margin-top: 18px; padding: 14px; border: 1px solid var(--inner-line); border-radius: 10px; }
.database-login > div strong, .database-login > div small { display: block; }
.database-login > div strong { color: var(--cyan); font-size: 11.5px; }
.database-login > div small { margin-top: 3px; color: var(--muted); font-size: 10.5px; }
.database-login form { margin-top: 11px; display: grid; gap: 8px; }
.database-login form label span { display: block; margin-bottom: 3px; color: var(--muted); font-size: 10.5px; }
.database-login form input { width: 100%; padding: 8px; color: var(--ink); border: 1px solid var(--inner-line); border-radius: 7px; background: #081019; }
.database-login form button { padding: 9px; border: 0; border-radius: 7px; background: var(--cyan); color: #04121c; font-weight: 600; }
.database-login > p { margin: 9px 0 0; color: var(--dim); font-size: 10.5px; line-height: 1.5; }
.database-login .database-sign-out { width: 100%; margin: 11px 0 0; }
.database-login [hidden] { display: none !important; }
.database-login .auth-copy { color: var(--muted); }
.database-login .auth-provider-status, .database-login .auth-message { color: var(--cyan); font-size: 10.5px; line-height: 1.5; }
.database-login .auth-method small { display: block; margin-top: 5px; color: var(--muted); font-size: 10.5px; }
.password-fallback { margin-top: 11px; padding-top: 11px; border-top: 1px solid var(--inner-line); }
.password-fallback summary { color: var(--muted); cursor: pointer; font-size: 11.5px; }
.password-fallback > p { margin: 7px 0 0; color: var(--dim); font-size: 10.5px; line-height: 1.5; }
.settings-foot { margin-top: 20px; padding: 13px; border: 1px solid rgba(92,200,240,.16); border-radius: 10px; }
.settings-foot strong { color: var(--cyan); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; }
.settings-foot p { margin: 6px 0 0; color: var(--muted); font-size: 11.5px; line-height: 1.5; }

.scrim { position: fixed; z-index: 55; inset: 0; background: rgba(0,0,0,.62); backdrop-filter: blur(2px); }
.toast {
  position: fixed; z-index: 90; left: 50%; bottom: calc(clamp(14px, 2.6vh, 30px) + clamp(76px, 10vh, 100px) + 18px);
  transform: translateX(-50%);
  padding: 10px 17px; border: 1px solid var(--card-line); border-radius: 9px;
  background: #0d1a26; color: var(--ink); box-shadow: 0 24px 60px rgba(0,0,0,.6); font-size: 12.5px;
}

/* ============================================================
   STARTUP
   ============================================================ */

.startup {
  position: fixed; z-index: 250; inset: 0; display: grid; place-items: end center;
  padding-bottom: 12vh;
  background: radial-gradient(ellipse 70% 60% at 50% 50%, rgba(4,7,11,.92), #03060a 78%);
  transition: opacity .8s ease;
}
.startup[hidden] { display: none; }
.startup.dismissing { opacity: 0; pointer-events: none; }
.startup-inner { display: grid; justify-items: center; gap: 22px; text-align: center; padding: 24px; }
.startup-phase { margin: 0; color: var(--ink-soft); font-size: 12px; letter-spacing: .34em; text-transform: uppercase; }
.startup-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 26px; }
.startup-checks li { display: grid; justify-items: center; gap: 8px; color: var(--dim); font-size: 9px; letter-spacing: .16em; }
.startup-checks i { width: 17px; height: 17px; border-radius: 50%; border: 1px solid var(--inner-line); display: grid; place-items: center; font-style: normal; font-size: 10px; }
.startup-checks li[data-status="pending"] i { animation: pip 1.8s ease-out infinite; }
.startup-checks li[data-status="ok"] { color: var(--cyan); }
.startup-checks li[data-status="ok"] i { border-color: var(--cyan); }
.startup-checks li[data-status="ok"] i::after { content: '✓'; }
.startup-checks li[data-status="degraded"] { color: var(--amber); }
.startup-checks li[data-status="degraded"] i { border-color: var(--amber); }
.startup-checks li[data-status="degraded"] i::after { content: '!'; }
.startup-checks li[data-status="failed"] { color: var(--red); }
.startup-checks li[data-status="failed"] i { border-color: var(--red); }
.startup-checks li[data-status="failed"] i::after { content: '×'; }
.startup-note { margin: 0; color: var(--dim); font-size: 12.5px; }

/* ============================================================
   PREFERENCES
   ============================================================ */

body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important;
  transition-duration: .001ms !important; scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}
body.low-graphics .backdrop { background-image: none; }
body.low-graphics .card, body.low-graphics .command-bar,
body.low-graphics .overlay-panel, body.low-graphics .ev-window {
  backdrop-filter: none; background: #070d15;
}

.pilot-home { display: none; }
.ambient-results, .ambient-query, .ambient-subject { display: none; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-height: 880px) {
  :root { --topbar-h: 52px; }
  .column { top: 3%; gap: clamp(12px, 3vh, 30px); }
  .command-bar-inner { min-height: 70px; }
}
@media (max-height: 720px) {
  .column { bottom: 15%; }
  .response { max-height: 6em; }
  .row { padding: 9px 11px; }
  .row-icon { width: 30px; height: 30px; }
}

@media (max-width: 1180px) {
  .column { width: clamp(210px, 22vw, 260px); }
  .command-centre { width: clamp(240px, 34%, 460px); }
}

/* The cockpit NEVER scrolls the page. At every size it stays a single
   fixed screen; panels compress and scroll internally instead. */
@media (max-width: 1000px) {
  .column { width: clamp(186px, 24vw, 230px); }
  .card { padding: 12px 12px 13px; }
  .card-head h2 { font-size: 14px; }
  .row { padding: 9px 10px; margin-bottom: 7px; gap: 0 9px; grid-template-columns: 30px 1fr auto auto; }
  .row-icon { width: 30px; height: 30px; }
  .row-spark { width: 54px; }
  .command-centre { width: clamp(210px, 34%, 420px); }
  .graph-controls { opacity: 1; }
}
@media (max-width: 760px) {
  html, body { min-width: 0; max-width: 100%; overflow-x: hidden; }
  body { overflow-y: auto; padding-bottom: calc(128px + env(safe-area-inset-bottom)); }
  .topbar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .topbar .graph-reset, #graph-reset, #alerts-glyph { display: none; }
  .pilot-home {
    position: relative; z-index: 8; display: block;
    width: 100%; max-width: 540px; min-height: calc(100dvh - var(--topbar-h));
    margin: var(--topbar-h) auto 0; padding: 28px max(16px, env(safe-area-inset-right)) 156px max(16px, env(safe-area-inset-left));
  }
  .pilot-home-head h1 { margin: 4px 0 6px; font-size: clamp(27px, 8vw, 38px); line-height: 1.08; }
  .pilot-home-head > p:last-child { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.45; }
  .pilot-primary-actions { display: grid; gap: 12px; margin-top: 26px; }
  .pilot-primary-actions button {
    min-height: 72px; width: 100%; padding: 14px 16px; text-align: left;
    border: 1px solid var(--card-line); border-radius: 14px;
    background: rgba(8, 17, 27, .9); color: var(--ink);
  }
  .pilot-primary-actions button:focus-visible, .pilot-primary-actions button:active { border-color: var(--cyan); outline: 2px solid rgba(92,200,240,.28); outline-offset: 2px; }
  .pilot-primary-actions span, .pilot-primary-actions small { display: block; }
  .pilot-primary-actions span { font-size: 17px; font-weight: 620; }
  .pilot-primary-actions small { margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.35; }
  .pilot-secondary-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
  .pilot-secondary-actions button {
    min-height: 44px; padding: 10px 13px; border: 1px solid var(--inner-line); border-radius: 999px;
    background: rgba(8, 17, 27, .75); color: var(--muted); font-size: 12px;
  }
  .pilot-action-status { min-height: 42px; margin: 16px 2px 0; color: var(--cyan); font-size: 13px; line-height: 1.45; }
  .cockpit .graph-layer, .cockpit .column { display: none; }
  .cockpit { pointer-events: none; }
  .command-bar { pointer-events: auto; position: fixed; left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); }
  .command-bar-inner { padding: 10px 12px; gap: 8px; }
  .command-bar input { min-height: 44px; text-align: left; font-size: 16px; }
  .mic-orb, .send-orb { width: 48px; min-width: 48px; min-height: 48px; }
  .command-bar .link-button { display: none; }
  .settings { width: 100%; max-width: none; padding: 20px max(16px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  /* Phone: cards become compact chips pinned to the sides; the graph
     and command bar keep the whole screen. Still no page scroll. */
  .column { top: 2%; bottom: 20%; width: clamp(150px, 26vw, 190px); gap: 8px; }
  .card { padding: 9px; border-radius: 12px; }
  .card-head { padding: 0 2px 8px; }
  .card-head h2 { font-size: 11px; letter-spacing: .12em; }
  .freshness { display: none; }
  .row { grid-template-columns: 24px 1fr; gap: 0 7px; padding: 7px 8px; }
  .row-icon { width: 24px; height: 24px; grid-row: 1; }
  .row-icon svg { width: 13px; height: 13px; }
  .row-sub, .row-spark, .row-dot, .row-flag, .row-chevron { display: none; }
  .row-title { font-size: 10px; }
  .wave { display: none; }
  .command-centre { width: 100%; flex: 1 1 auto; }
  .response { font-size: 14px; max-height: 3.2em; }
  .overlay-panel { width: min(320px, 86vw); }
  .ev-window { inset: 8px !important; width: auto !important; height: auto !important; }
}

/* ============================================================
   AMBIENT MOBILE GRAPH
   The phone home is the real Obsidian graph. Context appears only
   after a request or a deliberate node selection.
   ============================================================ */
@media (max-width: 760px) {
  html, body { width: 100%; height: 100%; min-width: 0; overflow: hidden; }
  body { padding: 0; background: #020807; }
  .backdrop { background-position: 48% center; opacity: .22; }
  .backdrop-veil {
    background:
      radial-gradient(circle at 50% 43%, rgba(13,68,61,.24), rgba(2,8,7,.62) 42%, rgba(2,6,6,.96) 88%),
      linear-gradient(180deg, rgba(2,7,7,.5), rgba(2,7,7,.92));
  }
  .topbar {
    height: calc(54px + env(safe-area-inset-top)); padding-top: env(safe-area-inset-top);
    padding-left: max(18px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right));
    background: linear-gradient(180deg, rgba(2,8,7,.96), rgba(2,8,7,0));
  }
  .brand { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; font-family: var(--display); font-size: 18px; letter-spacing: .28em; }
  .system-state { left: auto; right: max(56px, calc(48px + env(safe-area-inset-right))); transform: none; gap: 7px; }
  .system-state strong { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; letter-spacing: .08em; text-transform: none; }
  .state-pip { width: 7px; height: 7px; background: #39a88b; box-shadow: 0 0 12px rgba(57,168,139,.7); }
  .topbar-actions { gap: 0; }
  .topbar-actions .conn, .topbar-actions .clock, #graph-reset, #alerts-glyph { display: none; }
  .topbar .glyph { min-width: 44px; min-height: 44px; }

  .pilot-home { display: none; }
  .cockpit {
    pointer-events: auto; top: calc(44px + env(safe-area-inset-top)); bottom: 0;
    overflow: hidden;
  }
  .cockpit .graph-layer { display: block; inset: 0 0 calc(102px + env(safe-area-inset-bottom)); }
  .cockpit .column { display: none; }
  #graph-canvas { cursor: default; }
  .node-card, .graph-controls { display: none; }
  .graph-overlay { top: 44%; width: min(82vw, 330px); padding: 18px 20px; background: rgba(4,14,12,.9); border-color: rgba(57,168,139,.28); }

  .ambient-query {
    position: absolute; z-index: 9; left: 16px; right: 16px; bottom: calc(112px + env(safe-area-inset-bottom));
    display: block; margin: 0; text-align: center; pointer-events: none;
    color: #f4efe5; font-family: var(--display); font-size: clamp(18px, 5.2vw, 23px); line-height: 1.25;
    text-shadow: 0 4px 22px #000;
    opacity: 0; transform: translateY(5px); transition: opacity .2s ease, transform .2s ease;
  }
  .ambient-query:not([hidden]) { opacity: .96; transform: none; }

  .ambient-results {
    position: absolute; z-index: 10; inset: 12% 12px 31%;
    display: block; pointer-events: none;
  }
  .ambient-results[hidden] { display: none; }
  .ambient-result {
    position: absolute; width: min(56vw, 226px); min-height: 78px; padding: 13px 38px 12px 15px;
    border: 1px solid rgba(168,184,172,.26); border-radius: 16px;
    background: rgba(5,15,13,.92); color: #f4efe5; text-align: left; pointer-events: auto;
    box-shadow: 0 18px 48px rgba(0,0,0,.45), inset 0 1px rgba(255,255,255,.025);
    backdrop-filter: blur(10px); transform: translateY(8px) scale(.98); opacity: 0;
    animation: ambient-card-in .24s ease forwards;
  }
  .ambient-result:nth-child(1) { left: 0; top: 29%; }
  .ambient-result:nth-child(2) { right: 0; top: 52%; animation-delay: .06s; }
  .ambient-result:nth-child(3) { left: 7%; top: 71%; animation-delay: .12s; }
  .ambient-result::after { content: '›'; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: #a8b8ac; font-size: 26px; }
  .ambient-result-kicker { display: block; color: #d8a85a; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
  .ambient-result-title { display: block; margin-top: 3px; font-size: 15px; line-height: 1.25; }
  .ambient-result-detail { display: block; margin-top: 5px; color: #a8b8ac; font-size: 12.5px; line-height: 1.3; }
  @keyframes ambient-card-in { to { transform: none; opacity: 1; } }

  .command-bar {
    pointer-events: auto; position: fixed; z-index: 45;
    left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom)); height: 72px; clip-path: none;
    border: 1px solid rgba(168,184,172,.3); border-radius: 36px;
    background: rgba(4,15,13,.92); box-shadow: 0 16px 54px rgba(0,0,0,.5);
    backdrop-filter: blur(12px);
  }
  .command-bar::before { display: none; }
  .command-bar-inner { height: 100%; padding: 8px 8px 8px 16px; gap: 8px; background: transparent; clip-path: none; }
  .command-centre { width: 100%; flex: 1 1 auto; min-width: 0; }
  .command-bar .transcript, .command-centre .response, .command-centre .answer-meta { display: none; }
  .command-bar input { min-height: 48px; padding: 0; border: 0; background: transparent; color: #f4efe5; text-align: left; font-size: 16px; }
  .command-bar input::placeholder { color: #91a59b; opacity: .9; }
  .mic-orb { order: 3; width: 54px; min-width: 54px; height: 54px; min-height: 54px; border-color: rgba(57,168,139,.7); background: rgba(57,168,139,.18); }
  .send-orb { order: 2; width: 46px; min-width: 46px; height: 46px; min-height: 46px; }
  .wave, .command-bar .link-button { display: none; }
  body[data-ambient-state="listening"] .mic-orb { animation: ambient-mic 1.25s ease-out infinite; }
  @keyframes ambient-mic { 0% { box-shadow: 0 0 0 0 rgba(57,168,139,.42); } 100% { box-shadow: 0 0 0 16px rgba(57,168,139,0); } }

  .ambient-subject {
    position: fixed; z-index: 80; inset: max(10px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
    display: flex; flex-direction: column; overflow: hidden;
    border: 1px solid rgba(168,184,172,.28); border-radius: 22px;
    background: linear-gradient(180deg, rgba(12,31,25,.99), rgba(3,12,10,.995));
    color: #f4efe5; box-shadow: 0 28px 90px rgba(0,0,0,.78);
  }
  .ambient-subject[hidden] { display: none; }
  .ambient-subject-head { display: flex; gap: 12px; align-items: center; padding: 18px 16px 14px; border-bottom: 1px solid rgba(168,184,172,.16); }
  .ambient-subject-head > div { flex: 1; min-width: 0; }
  .ambient-subject-head h2 { margin-top: 3px; font-size: clamp(23px, 7vw, 31px); line-height: 1.12; }
  .ambient-subject-close { width: 48px; height: 48px; flex: 0 0 48px; border: 1px solid rgba(168,184,172,.26); border-radius: 50%; background: transparent; color: #f4efe5; font-size: 27px; }
  .ambient-subject-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 20px 18px 28px; }
  .ambient-subject-copy { color: #f4efe5; font-size: 17px; line-height: 1.58; white-space: pre-wrap; overflow-wrap: anywhere; }
  .ambient-subject-meta { margin: 20px 0 0; padding-top: 14px; border-top: 1px solid rgba(168,184,172,.16); color: #a8b8ac; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
  .ambient-subject-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
  .ambient-subject-actions button { min-height: 48px; padding: 11px 16px; border: 1px solid rgba(216,168,90,.5); border-radius: 12px; background: rgba(216,168,90,.1); color: #f4efe5; }
  body.ambient-subject-open .graph-layer { opacity: .3; transform: scale(.985); transition: opacity .2s ease, transform .2s ease; }
  body.ambient-subject-open .command-bar, body.ambient-subject-open .ambient-results, body.ambient-subject-open .ambient-query { visibility: hidden; }

  .settings { width: 100%; max-width: none; }
}

@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
  .ambient-result, .ambient-query, .graph-layer, .mic-orb { animation: none !important; transition: none !important; transform: none !important; }
}

/* ============================================================
   AMBIENT GRAPH SHELL — CANONICAL DEFAULT
   The old cockpit remains in the DOM for its data and review contracts,
   but it is never permanent chrome. The living vault graph is the home.
   ============================================================ */
html, body { width: 100%; height: 100%; min-width: 0; overflow: hidden; }
body {
  padding: 0;
  background:
    radial-gradient(circle at 50% 34%, rgba(9, 62, 54, .22), transparent 34%),
    radial-gradient(circle at 16% 48%, rgba(48, 125, 99, .06), transparent 28%),
    radial-gradient(circle at 84% 58%, rgba(189, 146, 69, .045), transparent 26%),
    #010705;
}
.backdrop {
  background-image:
    radial-gradient(circle at 20% 25%, rgba(89, 216, 179, .07) 0 1px, transparent 1.4px),
    radial-gradient(circle at 72% 68%, rgba(220, 174, 85, .055) 0 1px, transparent 1.3px),
    linear-gradient(118deg, transparent 43%, rgba(44, 120, 101, .035) 49%, transparent 55%);
  background-size: 43px 43px, 61px 61px, 100% 100%;
  filter: none; opacity: .46;
}
.backdrop-veil {
  background:
    radial-gradient(ellipse 72% 53% at 50% 38%, rgba(4, 25, 21, .08), rgba(1, 7, 5, .44) 66%, #010705 100%),
    linear-gradient(180deg, rgba(1,7,5,.06), rgba(1,7,5,.72));
}

.topbar {
  height: calc(72px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) max(28px, env(safe-area-inset-right)) 0 max(28px, env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(1,7,5,.96), rgba(1,7,5,0)); border: 0;
}
.brand { min-width: 0; min-height: 54px; display: inline-flex; align-items: center; font: 400 clamp(25px, 5vw, 38px)/1 var(--display); letter-spacing: .17em; }
.system-state { left: auto; right: max(28px, env(safe-area-inset-right)); transform: none; gap: 11px; }
.system-state strong { max-width: none; font: 400 clamp(14px, 3.2vw, 19px)/1.2 var(--display); letter-spacing: .01em; text-transform: none; color: #e5ebe5; }
.state-pip { width: 11px; height: 11px; background: #5bd6b5; box-shadow: 0 0 18px rgba(91,214,181,.76); }
.state-pip[data-state="limited"] { background: var(--amber); box-shadow: 0 0 18px rgba(224,164,78,.68); }
.topbar-actions { display: none; }

.pilot-home, .cockpit .column, .graph-controls, .node-card { display: none !important; }
.cockpit { pointer-events: auto; inset: 0; overflow: hidden; }
.cockpit .graph-layer {
  display: block !important; position: absolute; z-index: 2;
  inset: calc(62px + env(safe-area-inset-top)) 0 calc(98px + env(safe-area-inset-bottom));
}
#graph-canvas { position: relative; z-index: 3; cursor: default; }
.graph-overlay {
  top: auto; bottom: 14px; z-index: 7; width: min(78vw, 320px); padding: 11px 15px;
  border-radius: 15px; background: rgba(3,17,14,.88); border-color: rgba(91,214,181,.26);
  box-shadow: 0 12px 36px rgba(0,0,0,.34); backdrop-filter: blur(12px);
}
.graph-overlay-title { margin-bottom: 2px; }
.graph-overlay-body { max-width: 34ch; }

.command-bar {
  --cut: 0; pointer-events: auto; position: fixed; z-index: 45;
  left: 50%; right: auto; bottom: max(18px, env(safe-area-inset-bottom));
  width: min(calc(100% - 34px), 780px); height: 78px; padding: 0;
  transform: translateX(-50%); clip-path: none; background: transparent; filter: none;
}
.command-bar::before { display: none; }
.command-bar-inner { min-height: 78px; height: 78px; padding: 0; gap: 13px; background: transparent; clip-path: none; backdrop-filter: none; }
.ambient-menu, .mic-orb {
  flex: 0 0 68px; width: 68px; height: 68px; display: grid; place-items: center;
  border: 1px solid rgba(91,214,181,.58); border-radius: 50%;
  background: rgba(3,18,15,.9); color: #d9eee8;
  box-shadow: inset 0 0 22px rgba(91,214,181,.05), 0 10px 32px rgba(0,0,0,.38);
}
.ambient-menu { border-color: rgba(216,168,90,.62); }
.ambient-menu span { display: block; width: 25px; height: 1.5px; margin: 3px auto; border-radius: 2px; background: #e9e3d8; }
.command-centre {
  order: 2; flex: 1 1 auto; width: auto; height: 68px; min-width: 0; padding: 0 24px;
  justify-content: center; align-items: stretch; border: 1px solid rgba(173,191,180,.36); border-radius: 36px;
  background: rgba(3,14,12,.9); box-shadow: inset 0 0 36px rgba(28,97,78,.06), 0 12px 34px rgba(0,0,0,.34); backdrop-filter: blur(16px);
}
.ambient-menu { order: 1; }
.mic-orb { order: 3; border-width: 2px; background: radial-gradient(circle, rgba(77,209,174,.25), rgba(3,18,15,.94) 64%); box-shadow: 0 0 24px rgba(68,209,173,.14), inset 0 0 22px rgba(91,214,181,.1); }
.mic-orb svg { width: 43%; height: 43%; stroke-width: 1.5; }
.send-orb, .command-bar .wave, .command-bar .transcript, .command-centre .response, .command-centre .answer-meta, .command-bar .link-button { display: none !important; }
.command-bar input { min-height: 64px; padding: 0; border: 0; background: transparent; text-align: left; color: #eef2ec; font-size: clamp(16px, 3vw, 20px); }
.command-bar input::placeholder { color: #87938c; opacity: .86; }
body[data-ambient-state="listening"] .mic-orb { animation: ambient-mic 1.2s ease-out infinite; }

.ambient-query { left: 18px; right: 18px; bottom: calc(198px + env(safe-area-inset-bottom)); font-size: clamp(18px, 4vw, 28px); }
.ambient-thread {
  position: fixed; z-index: 34; left: 50%; bottom: calc(112px + env(safe-area-inset-bottom));
  width: min(calc(100% - 46px), 660px); max-height: 124px; margin: 0; padding: 0;
  display: grid; gap: 8px; overflow-y: auto; overscroll-behavior: contain; transform: translateX(-50%); list-style: none; pointer-events: auto;
  scrollbar-width: thin; scrollbar-color: rgba(91,214,181,.36) transparent; -webkit-overflow-scrolling: touch;
}
.ambient-thread:empty { display: none; }
.ambient-thread-turn { display: flex; gap: 9px; align-items: flex-start; min-width: 0; opacity: .94; animation: ambient-thread-in .2s ease-out; }
.ambient-thread-turn span { flex: 0 0 34px; color: #66cbb0; font-size: 10px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; }
.ambient-thread-content { min-width: 0; flex: 1; }
.ambient-thread-turn p { min-width: 0; margin: 0; color: #cad5cf; font-size: 13px; line-height: 1.4; white-space: normal; overflow-wrap: anywhere; }
.ambient-thread-user p { color: #f0eee8; }
.ambient-thread-turn[data-failed="true"] p { color: #dfa06f; }
.ambient-play-reply { min-height: 44px; margin-top: 8px; padding: 0 15px; border: 1px solid rgba(91,214,181,.52); border-radius: 10px; background: rgba(3,22,17,.94); color: #dff8f0; font: 650 13px/1 var(--sans); }
.ambient-play-reply:focus-visible { outline: 2px solid #74d2ff; outline-offset: 2px; }
@keyframes ambient-thread-in { from { opacity: 0; transform: translateY(5px); } }
.ambient-results { inset: 16% 18px 38%; }
.ambient-result { width: min(42vw, 300px); min-height: 96px; padding: 16px 43px 15px 18px; border-color: rgba(168,184,172,.28); border-radius: 19px; background: rgba(4,14,12,.94); }
.ambient-result:nth-child(1) { left: 0; top: 42%; }
.ambient-result:nth-child(2) { right: 0; top: 62%; }
.ambient-result:nth-child(3) { left: 8%; top: 80%; }

.ambient-subject {
  position: fixed; z-index: 80; inset: max(12px, env(safe-area-inset-top)) max(10px, calc((100vw - 760px) / 2)) max(10px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; overflow: hidden; border: 1px solid rgba(168,184,172,.28); border-radius: 24px;
  background: linear-gradient(180deg, rgba(11,31,25,.995), rgba(2,11,9,.998)); color: #f4efe5; box-shadow: 0 28px 90px rgba(0,0,0,.8);
}
.ambient-subject[hidden] { display: none; }
.ambient-subject-head { display: flex; gap: 12px; align-items: center; padding: 20px 18px 16px; border-bottom: 1px solid rgba(168,184,172,.16); }
.ambient-subject-head > div { flex: 1; min-width: 0; }
.ambient-subject-head h2 { margin-top: 3px; font: 400 clamp(25px, 6vw, 36px)/1.12 var(--display); }
.ambient-subject-close { width: 50px; height: 50px; flex: 0 0 50px; border: 1px solid rgba(168,184,172,.26); border-radius: 50%; background: transparent; color: #f4efe5; font-size: 28px; }
.ambient-subject-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 20px 30px; }
.ambient-subject-next { margin: 0 0 18px; padding: 15px 16px; border: 1px solid rgba(216,168,90,.38); border-radius: 15px; background: rgba(216,168,90,.08); }
.ambient-subject-next[hidden] { display: none; }
.ambient-subject-next span { display: block; margin-bottom: 5px; color: #d8a85a; font-size: 10px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; }
.ambient-subject-next p { margin: 0; color: #f4efe5; font-size: 16px; line-height: 1.45; }
.ambient-subject-copy { color: #f4efe5; font-size: 17px; line-height: 1.58; white-space: pre-wrap; overflow-wrap: anywhere; }
.ambient-subject-meta { margin: 20px 0 0; color: #a8b8ac; }
.ambient-subject-actions { display: flex; gap: 10px; margin-top: 18px; }
.ambient-subject-actions button { min-height: 48px; padding: 11px 16px; border: 1px solid rgba(216,168,90,.5); border-radius: 12px; background: rgba(216,168,90,.1); color: #f4efe5; }
body.ambient-subject-open .graph-layer { opacity: .25; transform: scale(.985); }
body.ambient-subject-open .command-bar, body.ambient-subject-open .ambient-results, body.ambient-subject-open .ambient-query, body.ambient-subject-open .ambient-thread { visibility: hidden; }

@media (max-height: 760px) {
  .cockpit .graph-layer { bottom: calc(82px + env(safe-area-inset-bottom)); }
  .command-bar { bottom: max(10px, env(safe-area-inset-bottom)); height: 64px; }
  .command-bar-inner { min-height: 64px; height: 64px; }
  .ambient-menu, .mic-orb { flex-basis: 58px; width: 58px; height: 58px; }
  .command-centre { height: 58px; }
  .command-bar input { min-height: 54px; }
  .ambient-thread { bottom: calc(86px + env(safe-area-inset-bottom)); max-height: min(30dvh, 190px); }
}

@media (max-width: 520px) {
  .topbar { height: calc(62px + env(safe-area-inset-top)); padding-left: max(22px, env(safe-area-inset-left)); padding-right: max(22px, env(safe-area-inset-right)); }
  .brand { font-size: 27px; }
  .system-state { right: max(22px, env(safe-area-inset-right)); }
  .system-state strong { font-size: 16px; }
  .cockpit .graph-layer { inset: calc(54px + env(safe-area-inset-top)) 0 calc(92px + env(safe-area-inset-bottom)); }
  .command-bar { width: calc(100% - 24px); }
  .ambient-menu, .mic-orb { flex-basis: 64px; width: 64px; height: 64px; }
  .command-centre { height: 64px; padding: 0 18px; }
  .command-bar input { min-height: 60px; font-size: 17px; }
  .ambient-thread { bottom: calc(92px + env(safe-area-inset-bottom)); width: calc(100% - 34px); max-height: min(32dvh, 240px); padding: 12px; border-radius: 14px; background: linear-gradient(180deg, rgba(2,12,10,.42), rgba(2,12,10,.86)); }
  .ambient-thread-turn p { font-size: 12.5px; }
  .ambient-results { inset: 13% 10px 40%; }
  .ambient-result { width: min(60vw, 235px); min-height: 82px; }
}

@media (max-width: 760px) {
  .command-bar { bottom: calc(max(10px, env(safe-area-inset-bottom)) + var(--keyboard-offset, 0px)); }
  .ambient-thread {
    bottom: calc(92px + env(safe-area-inset-bottom) + var(--keyboard-offset, 0px));
    transition: height .22s ease, max-height .22s ease, background-color .22s ease, border-color .22s ease;
  }
  .ambient-thread:not([data-expanded="true"]) {
    max-height: 100px; overflow: hidden; cursor: pointer;
  }
  .ambient-thread:not([data-expanded="true"]) .ambient-thread-turn:not([data-preview="true"]) { display: none; }
  .ambient-thread:not([data-expanded="true"]) .ambient-thread-user p {
    overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1;
  }
  .ambient-thread:not([data-expanded="true"]) .ambient-thread-assistant p {
    overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  }
  .ambient-thread[data-expanded="true"] {
    height: min(64dvh, 520px); max-height: calc(100dvh - 190px - var(--keyboard-offset, 0px));
    padding: 18px 16px 22px; border: 1px solid rgba(91,214,181,.24); border-radius: 20px 20px 14px 14px;
    background: linear-gradient(180deg, rgba(4,23,18,.97), rgba(2,12,10,.985));
    box-shadow: 0 -18px 54px rgba(0,0,0,.48); scroll-padding-block: 18px;
  }
  body.obia-keyboard-open .ambient-thread[data-expanded="true"] {
    height: min(45dvh, 330px); max-height: calc(100dvh - 176px - var(--keyboard-offset, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .mic-orb, .ambient-result, .graph-layer, .ambient-thread { animation: none !important; transition: none !important; }
}

/* ============================================================
   OBIA TYPE SYSTEM
   One native UI family with a small, deliberate role-based scale.
   This final layer prevents legacy cockpit rules from fragmenting
   the ambient iPhone interface.
   ============================================================ */
.brand {
  font-family: var(--sans);
  font-size: clamp(25px, 6vw, 30px);
  font-weight: var(--weight-medium);
  line-height: 1;
  letter-spacing: .22em;
}
.system-state strong {
  font-family: var(--sans);
  font-size: var(--type-small);
  font-weight: var(--weight-medium);
  line-height: 1.25;
  letter-spacing: .01em;
}
.graph-overlay-title {
  font-size: var(--type-label);
  font-weight: var(--weight-strong);
  line-height: 1.35;
  letter-spacing: .12em;
}
.graph-overlay-body {
  font-size: var(--type-small);
  font-weight: var(--weight-regular);
  line-height: 1.55;
}
.graph-overlay .ghost-button {
  font-size: var(--type-small);
  font-weight: var(--weight-medium);
}
.command-bar input {
  font-family: var(--sans);
  font-size: var(--type-body);
  font-weight: var(--weight-regular);
  line-height: 1.35;
  letter-spacing: 0;
}
.ambient-result-kicker, .ambient-subject .eyebrow {
  font-size: var(--type-label);
  font-weight: var(--weight-strong);
  line-height: 1.35;
  letter-spacing: .1em;
}
.ambient-result-title {
  font-size: var(--type-body);
  font-weight: var(--weight-strong);
  line-height: 1.3;
}
.ambient-result-detail {
  font-size: var(--type-small);
  font-weight: var(--weight-regular);
  line-height: 1.45;
}
.ambient-subject-head h2 {
  font-family: var(--sans);
  font-size: var(--type-title);
  font-weight: var(--weight-strong);
  line-height: 1.15;
  letter-spacing: -.015em;
}
.ambient-subject-copy {
  font-size: var(--type-body);
  font-weight: var(--weight-regular);
  line-height: 1.62;
}
.ambient-subject-meta {
  font-size: var(--type-small);
  line-height: 1.5;
}
.ambient-subject-actions button {
  font-size: var(--type-small);
  font-weight: var(--weight-medium);
}
.ambient-subject-source-list { display: grid; gap: 9px; margin-top: 18px; }
.ambient-subject-source-list[hidden] { display: none; }
.ambient-source-link {
  display: grid; gap: 3px; width: 100%; min-height: 52px; padding: 11px 13px;
  border: 1px solid rgba(91,214,181,.24); border-radius: 12px;
  background: rgba(91,214,181,.055); color: #f4efe5; text-align: left;
}
.ambient-source-link strong { font-size: var(--type-small); font-weight: var(--weight-strong); }
.ambient-source-link span { color: #a8b8ac; font-size: 12px; line-height: 1.4; }
.ambient-source-link:disabled { opacity: .58; }
.mic-orb svg, .glyph svg {
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
