/* ============================================================
   Algiz pHi — Orion Console
   Premium dark design tokens + components
   ============================================================ */

:root {
  /* Surfaces — near-black with a breath of blue, Apple-dark restraint */
  --bg:        #070A12;
  --bg-grad-1: #090D18;
  --bg-grad-2: #06080F;
  --panel:     #0A0E1A;   /* sidebar */
  --card:      #0E1320;
  --card-2:    #121829;
  --card2:     #121829;   /* alias used in inline styles */
  --elevated:  #161D30;
  --line:      rgba(255,255,255,0.07);
  --line-2:    rgba(255,255,255,0.12);
  --line2:     rgba(255,255,255,0.12);  /* alias */

  /* Ink */
  --ink:    #F4F7FB;
  --sub:    #AAB4C7;
  --muted:  #6C7689;
  --faint:  #444E62;

  /* Signature — the Orion glow */
  --indigo: #6366F1;
  --cyan:   #22D3EE;
  --glow:   #34E0F2;

  /* Semantic */
  --ok:   #34D399;
  --warn: #FBBF24;
  --bad:  #F87171;
  --off:  #38415A;

  /* Radii — generous, premium */
  --r-xs: 10px;
  --r-sm: 14px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 30px;

  /* Motion */
  --ease: cubic-bezier(.22,.61,.36,1);
  --ease-out: cubic-bezier(.16,1,.3,1);

  --accent: var(--cyan);
  --accent-2: var(--indigo);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01","cv01","cv02";
}

.font-mono { font-family: 'Geist Mono', ui-monospace, monospace; }

/* Ambient page background — subtle aurora, very restrained */
.app-bg::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 600px at 78% -8%, color-mix(in oklab, var(--indigo) 14%, transparent), transparent 60%),
    radial-gradient(760px 520px at 8% 108%, color-mix(in oklab, var(--cyan) 9%, transparent), transparent 55%),
    linear-gradient(180deg, var(--bg-grad-1), var(--bg-grad-2));
  z-index: 0;
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.08);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.16); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Typography helpers ---------- */
.h-display { font-weight: 600; letter-spacing: -0.03em; line-height: 1.02; }
.h-title   { font-weight: 600; letter-spacing: -0.02em; }
.eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted);
}
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- Card ---------- */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,.018), rgba(255,255,255,0)) , var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  position: relative;
}
.card-pad { padding: 22px; }
.card-hover { transition: border-color .3s var(--ease), transform .3s var(--ease), background .3s var(--ease); }
.card-hover:hover { border-color: var(--line-2); transform: translateY(-2px); }

.divider { height: 1px; background: var(--line); border: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 18px;
  border-radius: var(--r-sm);
  font-weight: 540; font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer; user-select: none;
  transition: all .2s var(--ease);
  white-space: nowrap;
}
.btn-sm { height: 34px; padding: 0 13px; font-size: 13px; border-radius: var(--r-xs); }
.btn svg { width: 17px; height: 17px; }
.btn-sm svg { width: 15px; height: 15px; }

.btn-primary {
  color: #04121A;
  background: linear-gradient(180deg, var(--glow), var(--cyan));
  box-shadow: 0 6px 22px -8px color-mix(in oklab, var(--cyan) 80%, transparent),
              inset 0 1px 0 rgba(255,255,255,.4);
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }

.btn-ghost { color: var(--sub); background: rgba(255,255,255,.04); border-color: var(--line); }
.btn-ghost:hover { color: var(--ink); background: rgba(255,255,255,.07); border-color: var(--line-2); }

.btn-quiet { color: var(--sub); background: transparent; }
.btn-quiet:hover { color: var(--ink); background: rgba(255,255,255,.05); }

.btn-danger { color: var(--bad); background: color-mix(in oklab, var(--bad) 12%, transparent); border-color: color-mix(in oklab, var(--bad) 28%, transparent); }
.btn-danger:hover { background: color-mix(in oklab, var(--bad) 20%, transparent); }

.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Toggle ---------- */
.toggle {
  --w: 44px; --h: 26px;
  width: var(--w); height: var(--h);
  border-radius: 99px; position: relative; cursor: pointer; flex: none;
  background: #1A2236; border: 1px solid var(--line);
  transition: background .25s var(--ease), border-color .25s var(--ease);
}
.toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 99px;
  background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.45);
  transition: transform .25s var(--ease-out), background .25s;
}
.toggle.on {
  background: linear-gradient(90deg, var(--indigo), var(--cyan));
  border-color: transparent;
}
.toggle.on::after { transform: translateX(18px); }

/* ---------- Inputs ---------- */
.field {
  width: 100%;
  background: #0A0F1C;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink);
  padding: 12px 14px;
  font-size: 14px; font-family: inherit;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), background .2s;
  outline: none;
}
.field::placeholder { color: var(--faint); }
.field:focus {
  border-color: color-mix(in oklab, var(--cyan) 55%, transparent);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--cyan) 12%, transparent);
  background: #0B1120;
}
textarea.field { resize: vertical; min-height: 96px; line-height: 1.6; }
.label { font-size: 12.5px; font-weight: 560; color: var(--sub); margin-bottom: 8px; display: block; letter-spacing: -.01em; }
.hint  { font-size: 12px; color: var(--muted); margin-top: 7px; line-height: 1.5; }

select.field { appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236C7689' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 38px;
}

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 11px; border-radius: 99px;
  font-size: 12px; font-weight: 560; letter-spacing: -.01em;
  background: rgba(255,255,255,.05); color: var(--sub); border: 1px solid var(--line);
}
.pill .dot { width: 7px; height: 7px; border-radius: 99px; background: var(--muted); }
.pill-ok  { color: var(--ok);  background: color-mix(in oklab, var(--ok) 12%, transparent);  border-color: color-mix(in oklab, var(--ok) 26%, transparent); }
.pill-ok .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.pill-off { color: var(--muted); }
.pill-off .dot { background: var(--off); }
.pill-accent { color: var(--cyan); background: color-mix(in oklab, var(--cyan) 12%, transparent); border-color: color-mix(in oklab, var(--cyan) 26%, transparent); }
.pill-accent .dot { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.pill-warn { color: var(--warn); background: color-mix(in oklab, var(--warn) 12%, transparent); border-color: color-mix(in oklab, var(--warn) 26%, transparent); }

/* ---------- Nav ---------- */
.nav-item {
  display: flex; align-items: center; gap: 12px;
  height: 44px; padding: 0 14px; border-radius: var(--r-sm);
  color: var(--muted); font-weight: 520; font-size: 14.5px;
  cursor: pointer; position: relative;
  transition: color .2s var(--ease), background .2s var(--ease);
}
.nav-item svg { width: 19px; height: 19px; flex: none; transition: transform .2s var(--ease); }
.nav-item:hover { color: var(--sub); background: rgba(255,255,255,.035); }
.nav-item.active { color: var(--ink); background: rgba(255,255,255,.055); }
.nav-item.active::before {
  content: ""; position: absolute; left: -8px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 99px;
  background: linear-gradient(var(--indigo), var(--cyan));
  box-shadow: 0 0 12px var(--cyan);
}
.nav-item.active svg { color: var(--cyan); }

/* ---------- Eye glow halo behind avatars ---------- */
.eye-halo { position: relative; }
.eye-halo::before {
  content: ""; position: absolute; inset: -18%;
  background: radial-gradient(closest-side, color-mix(in oklab, var(--glow) 38%, transparent), transparent 72%);
  filter: blur(8px); z-index: 0; pointer-events: none;
}
.eye-halo canvas { position: relative; z-index: 1; }

/* ---------- Heatmap ---------- */
.heat-cell { border-radius: 3px; aspect-ratio: 1; transition: transform .15s var(--ease); }
.heat-cell:hover { transform: scale(1.35); outline: 1px solid var(--line-2); }

/* ---------- Modal ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(4,6,12,.72);
  backdrop-filter: blur(10px) saturate(120%);
}
.sheet {
  background: var(--card); border: 1px solid var(--line-2);
  border-radius: var(--r-xl);
  box-shadow: 0 40px 120px -30px rgba(0,0,0,.8);
}

/* ---------- Chat bubbles ---------- */
.bubble { max-width: 76%; padding: 12px 15px; border-radius: 18px; font-size: 14.5px; line-height: 1.55; }
.bubble-user { background: linear-gradient(180deg, var(--indigo), color-mix(in oklab, var(--indigo) 84%, #000)); color: #fff; border-bottom-right-radius: 6px; }
.bubble-bot  { background: var(--elevated); color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 6px; }

/* ---------- Segmented control ---------- */
.seg { display: inline-flex; padding: 4px; gap: 4px; background: #0A0F1C; border: 1px solid var(--line); border-radius: var(--r-sm); }
.seg button {
  height: 34px; padding: 0 15px; border: 0; background: transparent; cursor: pointer;
  color: var(--muted); font-weight: 540; font-size: 13.5px; border-radius: 10px; font-family: inherit;
  transition: all .2s var(--ease);
}
.seg button.active { color: var(--ink); background: rgba(255,255,255,.08); box-shadow: inset 0 1px 0 rgba(255,255,255,.06); }

/* ---------- Radio card ---------- */
.radio-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--card-2);
  cursor: pointer; transition: all .2s var(--ease);
}
.radio-card:hover { border-color: var(--line-2); }
.radio-card.sel { border-color: color-mix(in oklab, var(--cyan) 55%, transparent); background: color-mix(in oklab, var(--cyan) 7%, var(--card-2)); }
.radio-dot { width: 20px; height: 20px; border-radius: 99px; border: 2px solid var(--faint); flex: none; position: relative; transition: border-color .2s; }
.radio-card.sel .radio-dot { border-color: var(--cyan); }
.radio-card.sel .radio-dot::after { content:""; position:absolute; inset: 3px; border-radius: 99px; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); }

/* ---------- Range ---------- */
input[type=range].slider { -webkit-appearance: none; appearance: none; height: 6px; border-radius: 99px; background: #1A2236; outline: none; }
input[type=range].slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 99px;
  background: #fff; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.5), 0 0 0 3px color-mix(in oklab, var(--cyan) 40%, transparent);
}

/* ---------- Misc ---------- */
.kbd { font-family: 'Geist Mono', monospace; font-size: 11px; padding: 2px 7px; border-radius: 6px; background: #0A0F1C; border: 1px solid var(--line); color: var(--sub); }
.glow-text { color: var(--cyan); text-shadow: 0 0 18px color-mix(in oklab, var(--cyan) 60%, transparent); }

.view-enter { animation: viewIn .5s var(--ease-out) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.stagger > * { animation: viewIn .5s var(--ease-out) both; }
.stagger > *:nth-child(1){animation-delay:.02s}
.stagger > *:nth-child(2){animation-delay:.06s}
.stagger > *:nth-child(3){animation-delay:.10s}
.stagger > *:nth-child(4){animation-delay:.14s}
.stagger > *:nth-child(5){animation-delay:.18s}
.stagger > *:nth-child(6){animation-delay:.22s}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

[x-cloak] { display: none !important; }

/* ---------- density (tweak) ---------- */
body.dense .card-pad { padding: 15px; }
body.dense .nav-item { height: 38px; }
body.dense .btn { height: 38px; }
body.dense .view-enter > * { gap: 12px; }

/* ---------- tweaks panel ---------- */
.tweaks-panel {
  position: fixed; right: 18px; bottom: 18px; z-index: 100;
  width: 304px; background: var(--card);
  border: 1px solid var(--line-2); border-radius: 20px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.8);
  overflow: hidden;
}
.tw-swatch { width: 30px; height: 30px; border-radius: 9px; cursor: pointer; border: 2px solid transparent; transition: transform .15s var(--ease); }
.tw-swatch:hover { transform: scale(1.1); }
.tw-swatch.sel { border-color: #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.4) inset; }
