/* Nest Console — layout and component styles */
:root {
  --void: #04050a;
  --surface: #0a0c12;
  --panel: #10141f;
  --panel-2: #151b28;
  --border: #2a3348;
  --text: #e8ecf4;
  --muted: #7b849c;
  --green: #5dffa8;
  --cyan: #4ee8d8;
  --magenta: #e879f9;
  --gold: #e8b84a;
  --warn: #f0c060;
  --deny: #ff6b7a;
  --persona: #f0b429;
  --glow-cyan: rgba(78, 232, 216, 0.12);
  --glow-mag: rgba(232, 121, 249, 0.1);
  --glow-green: rgba(93, 255, 168, 0.1);
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --display: "Syne", system-ui, sans-serif;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  background: var(--void);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background:
    radial-gradient(ellipse 70% 50% at 20% -10%, var(--glow-cyan), transparent 55%),
    radial-gradient(ellipse 50% 40% at 100% 0%, var(--glow-mag), transparent 50%),
    radial-gradient(ellipse 40% 30% at 50% 100%, var(--glow-green), transparent 45%),
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255,255,255,0.012) 2px, rgba(255,255,255,0.012) 4px);
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1480px;
  margin: 0 auto;
  padding: 14px 16px 20px;
  display: grid;
  gap: 12px;
}

/* ── Header ── */
.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--panel) 0%, var(--panel-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 0 40px var(--glow-cyan), inset 0 1px 0 rgba(255,255,255,0.04);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.base12-sigil {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--cyan);
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 800;
  font-size: 15px;
  color: var(--cyan);
  text-shadow: 0 0 20px var(--cyan);
  box-shadow: 0 0 24px var(--glow-cyan), inset 0 0 16px rgba(78,232,216,0.08);
  animation: sigil-pulse 5s ease-in-out infinite;
}

@keyframes sigil-pulse {
  0%, 100% { box-shadow: 0 0 24px var(--glow-cyan); }
  50% { box-shadow: 0 0 36px rgba(78,232,216,0.35); }
}

.brand h1 {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--cyan), var(--magenta));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand p {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.1em;
  margin-top: 2px;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pill {
  font-size: 10px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pill.live { border-color: var(--green); color: var(--green); }
.pill.live::before { content: "● "; animation: blink 2s step-end infinite; }
.pill.cyan { border-color: var(--cyan); color: var(--cyan); }
.pill.mag { border-color: var(--magenta); color: var(--magenta); }

@keyframes blink { 50% { opacity: 0.35; } }

/* ── Grid ── */
.grid {
  display: grid;
  grid-template-columns: 1fr 1.1fr 0.9fr;
  gap: 12px;
}

@media (max-width: 1100px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .col-quotes { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.panel-head h2 {
  font-family: var(--display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.panel-head h2.cyan { color: var(--cyan); }
.panel-head h2.green { color: var(--green); }
.panel-head h2.mag { color: var(--magenta); }
.panel-head h2.gold { color: var(--gold); }

.panel-body { padding: 12px 14px; flex: 1; overflow: auto; }

/* ── Status ── */
.status-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.stat {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.stat .label {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.stat .value {
  font-size: 18px;
  font-weight: 600;
  margin-top: 4px;
  font-family: var(--display);
}

.stat .value.green { color: var(--green); }
.stat .value.cyan { color: var(--cyan); }
.stat .value.mag { color: var(--magenta); }

.ns-row {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 3px;
  margin-top: 12px;
}

.ns-cell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--void);
  color: var(--muted);
  transition: all 0.2s;
}

.ns-cell.on {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(78,232,216,0.08);
  box-shadow: 0 0 10px var(--glow-cyan);
}

.ns-cell.model { border-color: var(--magenta); color: var(--magenta); }
.ns-cell.app { border-color: var(--green); color: var(--green); }
.ns-cell.periph { border-color: var(--gold); color: var(--gold); }

.status-source {
  margin-top: 10px;
  font-size: 9px;
  color: var(--muted);
}

.status-source.ok { color: var(--green); }
.status-source.mock { color: var(--warn); }

/* ── Terminal ── */
.terminal {
  min-height: 320px;
  max-height: 420px;
  overflow-y: auto;
  font-size: 12px;
  padding: 4px 0;
}

.t-line { margin-bottom: 3px; white-space: pre-wrap; word-break: break-word; }
.t-dim { color: var(--muted); }
.t-ok { color: var(--green); }
.t-info { color: var(--cyan); }
.t-warn { color: var(--warn); }
.t-err { color: var(--deny); }
.t-mag { color: var(--magenta); }
.t-head {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--gold);
  margin: 10px 0 4px;
}

.cmd-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.cmd-prompt {
  color: var(--magenta);
  white-space: nowrap;
  font-weight: 500;
}

#cmd-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font: inherit;
  caret-color: var(--cyan);
}

.cmd-hint {
  font-size: 9px;
  color: var(--muted);
  margin-top: 6px;
}

/* ── Quotes ── */
.quote-stage {
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

.quote-text {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.45;
  color: var(--text);
  transition: opacity 0.5s ease;
}

.quote-text.fade { opacity: 0; }

.quote-meta {
  margin-top: 12px;
  font-size: 10px;
  color: var(--magenta);
  letter-spacing: 0.08em;
}

.quote-dots {
  display: flex;
  gap: 6px;
  margin-top: 14px;
}

.quote-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.3s;
}

.quote-dots span.active { background: var(--magenta); box-shadow: 0 0 8px var(--magenta); }

/* ── Pipeline ── */
.pipeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pipe-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 11px;
}

.pipe-item.done { border-left: 3px solid var(--green); }
.pipe-item.active { border-left: 3px solid var(--cyan); }
.pipe-item.next { border-left: 3px solid var(--magenta); opacity: 0.85; }

.pipe-tag {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--muted);
}

.pipe-item.done .pipe-tag { color: var(--green); }
.pipe-item.active .pipe-tag { color: var(--cyan); }

/* ── Zero Trust ── */
.zt-ring {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 0;
}

.zt-visual {
  width: 100px;
  height: 100px;
  position: relative;
}

.zt-visual svg { width: 100%; height: 100%; transform: rotate(-90deg); }

.zt-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 800;
  color: var(--green);
}

.zt-list { display: flex; flex-direction: column; gap: 6px; }

.zt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.zt-row .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.zt-row .dot.pass { background: var(--green); box-shadow: 0 0 8px var(--green); }
.zt-row .dot.warn { background: var(--warn); }
.zt-row .dot.info { background: var(--cyan); }

/* ── Vector Collapse prep ── */
.panel-vector-collapse .panel-head {
  flex-wrap: wrap;
  gap: 8px;
}

.pill.warn {
  border-color: var(--warn);
  color: var(--warn);
}

.vc-refresh-btn {
  margin-left: auto;
  font-size: 10px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--cyan);
  cursor: pointer;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.vc-refresh-btn:hover {
  border-color: var(--cyan);
  background: rgba(78, 232, 216, 0.06);
}

.vc-layout {
  display: grid;
  grid-template-columns: 140px 1fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .vc-layout { grid-template-columns: 1fr; }
}

.vc-readiness {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.vc-ring {
  width: 100px;
  height: 100px;
  position: relative;
}

.vc-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.vc-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 22px;
  font-weight: 800;
  color: var(--magenta);
}

.vc-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0 0 8px;
}

.vc-meta {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--mono);
  margin: 8px 0 0;
  text-align: center;
}

.vc-bars {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 4px;
  align-items: end;
  height: 72px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.vc-bar {
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--magenta), rgba(167, 139, 250, 0.35));
  min-height: 4px;
  transition: height 0.3s ease;
}

.vc-bar.dim {
  opacity: 0.2;
  background: var(--border);
}

.vc-check-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vc-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.vc-row .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.vc-row .dot.pass { background: var(--green); box-shadow: 0 0 8px var(--green); }
.vc-row .dot.warn { background: var(--warn); }

.vc-row .detail {
  font-size: 9px;
  color: var(--muted);
  font-family: var(--mono);
}

#vc-phase-pill.ready { border-color: var(--green); color: var(--green); }
#vc-phase-pill.arming { border-color: var(--cyan); color: var(--cyan); }
#vc-phase-pill.dormant { border-color: var(--muted); color: var(--muted); }

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.footer strong { color: var(--cyan); font-weight: 500; }

.api-badge {
  font-size: 9px;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px dashed var(--border);
  color: var(--muted);
}

.api-badge.connected { border-color: var(--green); color: var(--green); border-style: solid; }

.gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: grid;
  place-items: center;
  background: rgba(4, 5, 10, 0.92);
  backdrop-filter: blur(12px);
}
.gate-overlay.hidden { display: none; }
.gate-card {
  width: min(400px, 92vw);
  padding: 28px 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.gate-card h2 {
  font-family: var(--display);
  font-size: 14px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}
.gate-card p { color: var(--muted); font-size: 12px; margin-bottom: 18px; }
.gate-card input {
  width: 100%;
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--mono);
  margin-bottom: 12px;
}
.gate-card button {
  width: 100%;
  padding: 11px;
  border-radius: 8px;
  border: 1px solid rgba(232,184,74,0.4);
  background: rgba(232,184,74,0.1);
  color: var(--gold);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}
.gate-error { color: var(--deny); font-size: 11px; min-height: 1.2em; margin-top: 8px; }

.pathway-hint {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 10px;
  line-height: 1.45;
}

.pathway-scroll {
  position: relative;
}

.pathway-scroll::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 6px;
  width: 28px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, var(--panel));
  opacity: 0;
  transition: opacity 0.2s;
}

.pathway-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.pathway-btn {
  display: block;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.25);
  color: var(--text);
  text-decoration: none;
  font-size: 11px;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}
.pathway-btn:hover { border-color: var(--cyan); background: rgba(78,232,216,0.06); }
.pathway-btn.active {
  border-color: var(--gold);
  background: rgba(232,184,74,0.1);
  box-shadow: 0 0 0 1px rgba(232,184,74,0.15);
}
.pathway-btn .tag { display: block; font-size: 9px; color: var(--muted); margin-top: 4px; letter-spacing: 0.06em; }
.pathway-frame {
  width: 100%;
  height: 420px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #000;
  margin-top: 12px;
}

.pathway-frame:not([hidden]) {
  display: block;
}

/* ── Responsive ── */
@media (max-width: 720px) {
  .app {
    padding: 10px max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    gap: 10px;
  }

  .header {
    padding: 12px 14px;
  }

  .brand h1 {
    font-size: 14px;
    letter-spacing: 0.1em;
  }

  .brand p {
    font-size: 9px;
  }

  .header-meta {
    width: 100%;
  }

  .panel-body {
    padding: 10px 12px;
  }

  .terminal {
    min-height: 220px;
    max-height: 320px;
  }

  .ns-cell {
    font-size: 8px;
  }

  .footer {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }

  .gate-card {
    padding: 24px 18px;
    margin: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }

  .pathway-hint {
    font-size: 10px;
    margin-bottom: 8px;
  }

  .pathway-scroll::after {
    opacity: 1;
  }

  .pathway-grid {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding: 2px 4px 8px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .pathway-btn {
    flex: 0 0 auto;
    min-width: 128px;
    min-height: 44px;
    scroll-snap-align: start;
    padding: 12px 14px;
  }

  .pathway-btn .tag {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
  }

  .pathway-frame {
    height: min(56vh, 520px);
    min-height: 260px;
    margin-top: 10px;
  }
}

@media (max-width: 380px) {
  .pathway-btn {
    min-width: 112px;
    font-size: 10px;
  }

  .stat .value {
    font-size: 16px;
  }
}
