/* BASECAMP — expedition command post. Mobile-first (380px). */
:root {
  --rock: #14181D;        /* deep basalt background */
  --rock-2: #1B2128;      /* raised surface */
  --rock-3: #232B34;      /* card border / hover */
  --snowline: #E8ECEF;    /* primary text */
  --alpenglow: #FF7A45;   /* single accent — action, fire, progress */
  --pine: #3E5C50;        /* calm secondary / success */
  --pine-bright: #5FA286;
  --haze: #8A97A3;        /* muted labels */
  --rope: #C9A227;        /* approval / gold moments only */
  --red: #E5533D;
  --disp: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tab-h: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--rock); color: var(--snowline); }
body { font-family: var(--body); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button { font-family: inherit; cursor: pointer; color: inherit; }
.hidden { display: none !important; }
.tnum { font-variant-numeric: tabular-nums; }
a { color: var(--alpenglow); }

/* ---- Top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(180deg, var(--rock), rgba(20,24,29,.85));
  border-bottom: 1px solid var(--rock-3); backdrop-filter: blur(8px);
}
.brand { font-family: var(--disp); font-weight: 700; letter-spacing: .14em; font-size: 20px; }
.brand-mark { color: var(--alpenglow); }
.topbar-right { display: flex; gap: 8px; }
.chip {
  font-family: var(--mono); font-size: 12px; padding: 6px 10px; border-radius: 999px;
  background: var(--rock-2); border: 1px solid var(--rock-3); color: var(--haze);
}
.chip-accent { color: var(--alpenglow); border-color: rgba(255,122,69,.35); }

.access-banner {
  background: var(--red); color: #fff; font-weight: 600; font-size: 13px;
  padding: 8px 14px; text-align: center; position: sticky; top: 0; z-index: 40;
}

/* ---- Layout ---- */
.view { padding: 14px 14px calc(var(--tab-h) + var(--safe-b) + 20px); max-width: 720px; margin: 0 auto; min-height: 60vh; }
.boot { color: var(--haze); text-align: center; padding: 30vh 0; font-family: var(--mono); }
.section-title { font-family: var(--disp); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: 15px; color: var(--haze); margin: 22px 4px 10px; }
.row { display: flex; gap: 12px; }
.grid { display: grid; gap: 12px; }

/* ---- Cards ---- */
.card {
  background: var(--rock-2); border: 1px solid var(--rock-3); border-radius: 14px;
  padding: 14px; position: relative;
}
.card h3 { margin: 0 0 6px; font-family: var(--disp); font-weight: 600; letter-spacing: .04em; font-size: 17px; }
.muted { color: var(--haze); }
.small { font-size: 12.5px; }
.big-num { font-family: var(--disp); font-weight: 700; font-size: 34px; line-height: 1; letter-spacing: .01em; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--pine-bright); } .dot-yellow { background: var(--rope); } .dot-red { background: var(--red); }

/* ---- Countdown / ascent strip ---- */
.mission-strip { margin-bottom: 6px; }
.countdown { display: flex; align-items: baseline; gap: 8px; }
.countdown .n { font-family: var(--disp); font-weight: 700; font-size: 30px; color: var(--snowline); }
.countdown .l { color: var(--haze); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.ascent-wrap { position: relative; margin: 8px 0 4px; }
.ascent-svg { width: 100%; height: 92px; display: block; }
.ascent-path { fill: none; stroke: var(--rock-3); stroke-width: 2; }
.ascent-progress { fill: none; stroke: var(--alpenglow); stroke-width: 2.5; stroke-linecap: round; }
.ascent-climber { fill: var(--alpenglow); filter: drop-shadow(0 0 6px rgba(255,122,69,.7)); }
.ascent-flag { fill: var(--haze); }
.ascent-flag.reached { fill: var(--rope); }
.ascent-goal { fill: var(--rope); font-family: var(--disp); }

/* ---- Pillars ---- */
.pillars { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.pillar { text-align: left; }
.pillar .lab { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--haze); }
.pillar .v { font-family: var(--disp); font-weight: 700; font-size: 22px; margin-top: 4px; }
.pillar .sub { font-size: 11.5px; color: var(--haze); margin-top: 2px; }
@media (max-width: 400px) { .pillar .v { font-size: 19px; } }

/* ---- Fires ---- */
.fire { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: rgba(229,83,61,.08); border: 1px solid rgba(229,83,61,.3); margin-bottom: 8px; }
.fire .flame { color: var(--alpenglow); }
.fire .due { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--red); white-space: nowrap; }
.badge { font-size: 10.5px; font-family: var(--mono); padding: 2px 6px; border-radius: 5px; background: var(--rock-3); color: var(--haze); text-transform: uppercase; }
.badge.high { color: var(--red); } .badge.overdue { background: var(--red); color: #fff; }

/* ---- Project grid ---- */
.proj-grid { grid-template-columns: 1fr 1fr; }
@media (max-width: 420px) { .proj-grid { grid-template-columns: 1fr; } }
.proj .top { display: flex; align-items: center; gap: 8px; }
.proj .blocker { color: var(--alpenglow); font-size: 12.5px; margin-top: 6px; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--rock-3); background: var(--rock-2); color: var(--snowline); font-weight: 500; font-size: 14px; min-height: 42px; }
.btn:active { transform: translateY(1px); }
.btn-accent { background: var(--alpenglow); border-color: var(--alpenglow); color: #180d07; font-weight: 600; }
.btn-gold { background: var(--rope); border-color: var(--rope); color: #1c1607; font-weight: 600; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; min-height: 34px; font-size: 12.5px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Inputs ---- */
input, textarea, select { font-family: var(--body); font-size: 15px; background: var(--rock); color: var(--snowline); border: 1px solid var(--rock-3); border-radius: 10px; padding: 11px 12px; width: 100%; }
textarea { resize: vertical; min-height: 60px; }
label.fld { display: block; margin: 10px 0; }
label.fld .lab { display: block; font-size: 12px; color: var(--haze); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .06em; }

/* ---- Bottom tab nav ---- */
.tabnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(20,24,29,.94); border-top: 1px solid var(--rock-3); backdrop-filter: blur(10px);
  padding-bottom: var(--safe-b); height: calc(var(--tab-h) + var(--safe-b));
}
.tab { background: none; border: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--haze); font-size: 10.5px; letter-spacing: .04em; }
.tab .ti { font-size: 19px; line-height: 1; }
.tab.active { color: var(--alpenglow); }
.tab-capture .ti { color: var(--alpenglow); font-weight: 700; }

/* ---- JARVIS chat ---- */
.jarvis { display: flex; flex-direction: column; height: calc(100dvh - var(--tab-h) - var(--safe-b) - 58px); }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px 2px 10px; }
.msg { max-width: 88%; padding: 11px 13px; border-radius: 14px; font-size: 14.5px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--pine); color: #eef6f2; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--rock-2); border: 1px solid var(--rock-3); border-bottom-left-radius: 4px; }
.msg.assistant.speaking { border-color: rgba(255,122,69,.5); }
.chat-input { display: flex; gap: 8px; align-items: flex-end; padding: 8px 0 4px; }
.chat-input textarea { min-height: 44px; max-height: 120px; }
.mic-btn { min-width: 52px; min-height: 52px; border-radius: 50%; background: var(--rock-2); border: 1px solid var(--rock-3); font-size: 22px; display: grid; place-items: center; }
.mic-btn.listening { background: var(--alpenglow); border-color: var(--alpenglow); color: #180d07; animation: pulse 1.2s infinite; }
.send-btn { min-width: 52px; min-height: 52px; border-radius: 50%; background: var(--alpenglow); color: #180d07; border: none; font-size: 20px; }

/* ---- Thinking stream (climbing log) ---- */
.thinking-chip { position: fixed; bottom: calc(var(--tab-h) + var(--safe-b) + 12px); left: 50%; transform: translateX(-50%); z-index: 25; background: var(--rock-2); border: 1px solid var(--rock-3); border-radius: 999px; padding: 7px 14px; display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; color: var(--haze); box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--alpenglow); animation: pulse 1.1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(1.35); } }
.trace { font-family: var(--mono); font-size: 11.5px; background: #0F1318; border: 1px solid var(--rock-3); border-radius: 10px; padding: 10px; margin-top: 8px; overflow-x: auto; }
.trace .line { display: flex; gap: 8px; padding: 2px 0; white-space: nowrap; }
.trace .ts { color: #4d5966; }
.trace .k-plan { color: var(--rope); } .trace .k-tool { color: var(--alpenglow); } .trace .k-result { color: var(--pine-bright); } .trace .k-status { color: var(--haze); } .trace .k-error { color: var(--red); }
.trace-toggle { font-family: var(--mono); font-size: 11px; color: var(--haze); background: none; border: 1px dashed var(--rock-3); border-radius: 8px; padding: 4px 8px; margin-top: 6px; }
.spin { display: inline-block; animation: spin 0.9s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } }

/* ---- Proposal card ---- */
.proposal { border: 1px solid var(--rope); background: rgba(201,162,39,.08); border-radius: 12px; padding: 12px; margin: 4px 0; }
.proposal .ptitle { font-family: var(--disp); font-weight: 600; letter-spacing: .04em; color: var(--rope); font-size: 15px; }
.proposal pre { font-family: var(--mono); font-size: 11.5px; background: #0F1318; border-radius: 8px; padding: 8px; overflow-x: auto; margin: 8px 0; color: var(--snowline); }
.proposal.invalid { border-color: var(--red); }

/* ---- Capture ---- */
.capture-hero { display: grid; place-items: center; gap: 16px; padding: 20px 0; }
.capture-btn { width: 130px; height: 130px; border-radius: 50%; background: radial-gradient(circle at 50% 40%, #ff8d5f, var(--alpenglow)); border: none; color: #180d07; font-size: 52px; box-shadow: 0 12px 40px rgba(255,122,69,.35); display: grid; place-items: center; }
.capture-btn.listening { animation: pulse 1.1s infinite; }

/* ---- Registry views ---- */
.seg { display: flex; gap: 4px; background: var(--rock-2); border: 1px solid var(--rock-3); border-radius: 10px; padding: 4px; margin-bottom: 12px; }
.seg button { flex: 1; padding: 8px; border-radius: 7px; border: none; background: none; color: var(--haze); font-size: 12.5px; font-weight: 500; }
.seg button.active { background: var(--alpenglow); color: #180d07; }
.dl-item { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 10px; background: var(--rock-2); border: 1px solid var(--rock-3); margin-bottom: 8px; }
.dl-item .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.dl-actions { display: flex; gap: 6px; margin-top: 8px; }

/* ---- Reveal animation ---- */
@media (prefers-reduced-motion: no-preference) {
  .reveal { animation: rise .5s cubic-bezier(.2,.7,.3,1) both; }
  .reveal-1 { animation-delay: .05s; } .reveal-2 { animation-delay: .12s; } .reveal-3 { animation-delay: .2s; } .reveal-4 { animation-delay: .28s; }
  @keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
  .ascent-progress { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1.1s ease forwards; }
  @keyframes draw { to { stroke-dashoffset: var(--off); } }
}

/* ---- Toast ---- */
.toast { position: fixed; bottom: calc(var(--tab-h) + var(--safe-b) + 16px); left: 50%; transform: translateX(-50%); background: var(--rock-3); color: var(--snowline); padding: 10px 16px; border-radius: 10px; z-index: 50; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.5); border: 1px solid var(--rock-3); max-width: 90vw; }
.toast.err { border-color: var(--red); }
.toast.ok { border-color: var(--pine-bright); }

/* ---- Misc ---- */
.notconn { font-family: var(--mono); font-size: 11.5px; color: var(--haze); border: 1px dashed var(--rock-3); border-radius: 8px; padding: 6px 8px; display: inline-block; }
.deep-link { color: var(--alpenglow); font-size: 12px; text-decoration: none; }
.spend-meter { height: 6px; background: var(--rock-3); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.spend-meter > i { display: block; height: 100%; background: var(--alpenglow); }
.err-boundary { padding: 24px; text-align: center; color: var(--haze); }
.err-boundary h2 { color: var(--red); font-family: var(--disp); }

/* ============ V2 · THE BRIDGE ============ */
/* 6-tab nav */
.tabnav-6 { grid-template-columns: repeat(6, 1fr); }
.tabnav-6 .tab { font-size: 9.5px; }
.tabnav-6 .tab .ti { font-size: 17px; }

/* ---- Neural Core ---- */
.nc-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.core-hero { position: relative; padding: 10px; overflow: hidden; }
.core-canvas { position: relative; height: 240px; border-radius: 12px; background: radial-gradient(circle at 50% 45%, #0d1620, var(--rock)); overflow: hidden; }
.core-toggle { position: absolute; top: 12px; right: 12px; z-index: 3; }
.jarvis-core-bg { position: absolute; inset: 0; z-index: 0; opacity: .55; pointer-events: none; }
.jarvis .chat-log, .jarvis .chat-input { position: relative; z-index: 1; }

/* status ticker */
.core-ticker { display: flex; flex-wrap: wrap; gap: 10px; font-family: var(--mono); font-size: 10.5px; padding: 2px 2px 10px; letter-spacing: .04em; }
.tick-l { color: var(--haze); }
.tick-v.ok { color: var(--pine-bright); } .tick-v.warn { color: var(--alpenglow); } .tick-v.accent { color: var(--alpenglow); } .tick-v.muted { color: var(--snowline); }

/* docked panels */
.core-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.core-panel { background: var(--rock); border: 1px solid var(--rock-3); border-radius: 10px; padding: 10px; }
.core-panel:first-child { grid-column: 1 / -1; }
.cp-lab { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; color: var(--haze); margin-bottom: 6px; }
.cp-line { padding: 1px 0; }
.cp-sub { font-family: var(--mono); font-size: 10px; color: var(--haze); margin-top: 4px; }
.cp-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cp-tile { background: var(--rock-2); border-radius: 8px; padding: 6px 8px; }
.cp-tv { font-family: var(--disp); font-weight: 700; font-size: 18px; }
.cp-tl { font-size: 10px; color: var(--haze); text-transform: uppercase; letter-spacing: .06em; }

/* ---- Conductor Map ---- */
.map-stage { height: calc(100dvh - var(--tab-h) - var(--safe-b) - 150px); min-height: 340px; border: 1px solid var(--rock-3); border-radius: 12px; overflow: hidden; background: radial-gradient(circle at 50% 0%, #0f151b, var(--rock)); touch-action: none; }
.map-svg { width: 100%; height: 100%; display: block; cursor: grab; }
.map-svg:active { cursor: grabbing; }
.map-link { fill: none; stroke: var(--rock-3); stroke-width: 1.4; }
.map-link-faint { stroke: #202832; stroke-width: 1; }
.map-root-rect { fill: rgba(255,122,69,.12); stroke: var(--alpenglow); stroke-width: 1.4; }
.map-root-text { fill: var(--alpenglow); font-family: var(--mono); font-size: 12px; font-weight: 500; }
.map-branch-text { fill: var(--snowline); font-family: var(--disp); font-size: 13px; letter-spacing: .06em; }
.map-leaf-rect { fill: var(--rock-2); stroke: var(--rock-3); stroke-width: 1; }
.map-leaf-rect.leaf-action_tool { stroke: rgba(201,162,39,.5); }
.map-leaf-rect.leaf-cron { stroke: rgba(95,162,134,.5); }
.map-leaf-rect.leaf-integration { stroke-dasharray: 3 2; }
.map-leaf-text { fill: var(--snowline); font-family: var(--mono); font-size: 10.5px; }
.map-leaf-sub { fill: var(--haze); font-family: var(--mono); font-size: 8.5px; }
.map-cad { font-size: 10px; }
.map-node { cursor: pointer; }
.map-node:active .map-leaf-rect { fill: var(--rock-3); }
.map-dot-green { fill: var(--pine-bright); } .map-dot-red { fill: var(--red); } .map-dot-grey { fill: var(--haze); }
.map-dot-core { fill: var(--alpenglow); } .map-dot-yellow { fill: var(--rope); }
.map-legend { display: flex; flex-wrap: wrap; gap: 12px; font-family: var(--mono); font-size: 11px; color: var(--haze); padding: 10px 4px; }

/* ---- Bottom sheet ---- */
.sheet-back { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; }
.sheet { width: 100%; max-width: 720px; margin: 0 auto; background: var(--rock-2); border: 1px solid var(--rock-3); border-radius: 18px 18px 0 0; padding: 14px 16px calc(20px + var(--safe-b)); max-height: 82vh; overflow-y: auto; transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.7,.3,1); }
.sheet.up { transform: none; }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--rock-3); margin: 0 auto 10px; }
.sheet-out { margin-top: 10px; }

@media (prefers-reduced-motion: reduce) { .sheet { transition: none; } }
