/* Header, brand lockup and status-pill rules live in
   ../shared/chrome.css — do not redefine them here. */
/* Design tokens ---------------------------------------------------------
   Field Notes: kraft-paper chassis, ink text, one rust accent thread
   running through every interactive/live element — matches the homepage
   and every other Thermalsock Labs app. The scope canvas itself is
   separately themeable (see js/themes.js — Field Notes is the default
   canvas theme too, with CRT/Modern Lab/Aurora/Woven still selectable),
   but the chrome around it (topbar, panels, buttons) always stays in
   this one house style regardless of which canvas theme is active.
   Type: Space Grotesk (display) + system sans (chrome labels) + IBM-Plex-style
   mono for dense numeric alignment, matching the homepage's type system.
   Corner radii follow the shared scale: 10px windows/panels, 6px
   controls/buttons, fully-rounded pills for status/nav badges.
------------------------------------------------------------------------- */

:root {
  --chassis: #0B0D12;
  --panel: #0F1118;
  --panel-raised: #161A22;
  --hairline: rgba(138, 160, 184, 0.16);
  --hairline-strong: rgba(138, 160, 184, 0.30);
  --text: #E7F4FF;
  --text-dim: #8AA0B8;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, monospace;
  --sans: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --serif-display: 'Space Grotesk', -apple-system, system-ui, sans-serif;

  --accent: #00C8FF;
  --accent-dim: rgba(0, 200, 255, 0.32);
  --accent-fg: #04222C;
  --danger: #FF5A6E;

  --amber: #FFB454;
  --violet: #A98CFF;
  --teal: #3FD9C4;
  --pink: #FF7BB0;
  --blue: #6FA8FF;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--chassis);
  color: var(--text);
  font-family: var(--sans);
}

/* --- Permission gate ("boot screen") ------------------------------------ */

.gate {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(0, 200, 255, 0.08), transparent 60%),
    var(--chassis);
}

/* [hidden] must win over the .gate/.app display:flex rules above and below —
   otherwise the browser's built-in "hidden means display:none" behavior gets
   silently overridden by our own class, and toggling .hidden in JS does
   nothing visible. This exact bug has already regressed once (lost during a
   full stylesheet rewrite) — do not remove this rule when restyling. */
.gate[hidden],
.app[hidden] {
  display: none;
}

.gate-panel {
  width: 100%;
  max-width: 440px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 32px;
  box-shadow: 0 20px 50px rgba(138, 160, 184, 0.18);
}

.gate-panel h1 {
  font-family: var(--serif-display);
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 2px;
  letter-spacing: 0.005em;
}

.gate-sub {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 0 0 20px;
}

.gate-copy {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-dim);
  margin: 0 0 24px;
}




select, input[type="range"], button {
  font-family: var(--sans);
}

select {
  width: 100%;
  background: var(--panel-raised);
  color: var(--text);
  border: 1px solid var(--hairline-strong);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
}

.btn-primary, .btn-secondary {
  width: 100%;
  padding: 11px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--hairline-strong);
  margin-top: 10px;
}
.btn-secondary:hover { border-color: var(--accent-dim); }

.gate-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 14px;
  line-height: 1.4;
}

/* --- Main app shell ------------------------------------------------------ */

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


.brand {
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.03em;
}
.brand span { color: var(--text-dim); }
.brand-home { color: inherit; text-decoration: none; }
.brand-home:hover { color: var(--accent, #e8a33d); text-decoration: underline; }


.page-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  background: rgba(138, 160, 184, 0.04);
  border: 1px solid var(--hairline);
  border-radius: 3px;
  padding: 3px;
}
.page-nav-link {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: var(--text-dim);
  padding: 6px 14px;
  border-radius: 3px;
}
.page-nav-link:hover { color: var(--text); }
.page-nav-link.active {
  color: var(--accent-fg);
  background: var(--accent);
  font-weight: 600;
}


.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: 3px;
  border: 1px solid var(--hairline-strong);
  background: rgba(138, 160, 184, 0.04);
  color: var(--text-dim);
}

.pill.mode {
  color: var(--violet);
  border-color: rgba(106, 90, 156, 0.35);
  background: rgba(106, 90, 156, 0.08);
}

.pill.live { color: var(--text-dim); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}
.status-dot.live {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.stage {
  flex: 1;
  display: flex;
  gap: 18px;
  padding: 18px 22px 26px 22px;
  min-height: 0;
}

/* --- Scope display --------------------------------------------------- */

.scope-wrap {
  flex: 1;
  min-width: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--hairline);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.6), inset 0 0 2px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(138, 160, 184, 0.08);
  position: relative;
  background: #000;
}

#scopeCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* --- Right panel ------------------------------------------------------ */

.panel {
  width: 280px;
  flex-shrink: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}



.chip.violet { background: rgba(106, 90, 156, 0.15); color: var(--violet); }
.chip.pink { background: rgba(163, 74, 114, 0.15); color: var(--pink); }





.status-value {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}
.status-value.trig { color: var(--accent); }
.status-value.hold { color: #fbbf24; }
.status-value.armed { color: #fbbf24; }

/* --- Hero stat card ----------------------------------------------------- */

.hero-card {
  background: linear-gradient(160deg, var(--panel-raised), var(--panel));
  border: 1px solid rgba(0, 200, 255, 0.22);
  box-shadow: 0 0 0 1px rgba(0, 200, 255, 0.08), 0 8px 24px rgba(138, 160, 184, 0.14);
}

.hero-label {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.hero-value {
  font-family: var(--mono);
  font-size: 36px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.1;
  text-shadow: 0 0 1px rgba(0, 200, 255, 0.15);
  margin-bottom: 4px;
  word-break: break-word;
}
.hero-unit {
  font-size: 16px;
  color: var(--text-dim);
  text-shadow: none;
  margin-left: 4px;
}

.hero-sub {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--text-dim);
  min-height: 15px;
}

@media (max-width: 800px) {
  .stage { flex-direction: column; }
  .panel { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .card { flex: 1 1 220px; }
}

/* --- Support widget & legal bar ------------------------------------------ */

#supportWidget {
  position: fixed;
  left: 14px;
  bottom: 34px;
  z-index: 10;
}
#supportWidget img { display: block; }

#legalBar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 5px 12px;
  font-size: 10.5px;
  color: var(--text-dim);
  background: rgba(11, 13, 18, 0.9);
  border-top: 1px solid var(--hairline);
}
#legalBar a { color: var(--text-dim); text-decoration: none; }
#legalBar a:hover { color: var(--accent); }

/* Site-wide brand thread: header lockup uses the shared Thermalsock Labs
   display face (Space Grotesk), legal bar stays mono for that technical-footer
   feel — matches the homepage and every other app page. Scoped to just
   these connective-tissue elements -- the app's own interior chrome
   (buttons, panel labels, chips) keeps its established --sans/--mono
   system untouched. */
.brand-sub, #legalBar, #legalBar a {
  font-family: var(--mono);
}

/* --- Side-by-side oscillator view ---------------------------------------
   Osc 1 and Osc 2 were separate tabs with identical layouts, so comparing
   them meant flipping back and forth from memory. */
.both-view .both-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.both-view .both-col > .view { display: block; }
@media (max-width: 1000px) {
  .both-view .both-grid { grid-template-columns: 1fr; }
}

/* The divide table is eight near-identical rows per sub, of which one
   matters. Give the selected row real weight so the closest divisor is
   findable at a glance instead of by reading all eight. */
.divide-table tr.is-selected td {
  background: rgba(0, 200, 255, 0.13);
  color: var(--text);
  font-weight: 600;
}
.divide-table tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.divide-table tr.is-near td { background: rgba(0, 200, 255, 0.05); }

.reference-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: var(--paper-deep, var(--panel));
  border: 1px solid var(--hairline);
  border-radius: 10px;
}
.reference-bar .hint { margin: 0; flex: 1; min-width: 200px; }
