/* ===== Tokens ===== */
:root {
  --bg: #0a0d13;
  --panel: #10141d;
  --panel-alt: #151b27;
  --border: #232b3d;
  --border-soft: #1a2130;

  --text: #e7eaf0;
  --text-dim: #8a93a6;
  --text-faint: #545e73;

  --brand: #ff5c49;
  --brand-dim: #3a1912;
  --brand-blueshift: #6fb8ff;
  --accent-safe: #35b37e;
  --accent-safe-dim: #123626;
  --accent-warn: #e2a03f;
  --accent-warn-dim: #3a2c11;
  --accent-danger: #e5484d;
  --accent-danger-dim: #3a1518;

  --font-sans: "IBM Plex Sans", -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", monospace;

  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100vh;
}

body {
  background-image:
    radial-gradient(circle at 15% 0%, rgba(255, 92, 73, 0.06), transparent 40%),
    radial-gradient(circle at 85% 100%, rgba(53, 179, 126, 0.05), transparent 40%);
}

/* ===== Topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(16, 20, 29, 0.7);
}

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

/* Small emitter with wavefronts that stretch and redden as they expand —
   a nod to relativistic redshift (recession stretches wavelength toward red). */
.mark {
  position: relative;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.mark-core {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff3ef;
  box-shadow: 0 0 6px 1px var(--brand);
  transform: translate(-50%, -50%);
  animation: core-glow 2.4s ease-in-out infinite;
}
.mark-wave {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--brand-blueshift);
  opacity: 0;
  animation: redshift-wave 2.4s cubic-bezier(0.15, 0.6, 0.4, 1) infinite;
}
.mark-wave.w2 { animation-delay: 0.8s; }
.mark-wave.w3 { animation-delay: 1.6s; }
@keyframes redshift-wave {
  0%   { transform: scale(0.15); opacity: 0.9; border-color: var(--brand-blueshift); }
  45%  { opacity: 0.6; border-color: #ffffff; }
  100% { transform: scale(2.3); opacity: 0; border-color: var(--brand); }
}
@keyframes core-glow {
  0%, 100% { box-shadow: 0 0 4px 1px var(--brand); }
  50% { box-shadow: 0 0 8px 2px var(--brand); }
}

.topbar-titles { display: flex; flex-direction: column; line-height: 1.25; }
.platform-name {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.08em;
}
.platform-name-red { color: var(--brand); }
.platform-name-shift { color: #c9d6ff; }
.platform-sub {
  font-size: 12px;
  color: var(--text-dim);
}

.topbar-right { display: flex; align-items: center; gap: 18px; }

.mode-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.mode-btn {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 7px 14px;
  background: transparent;
  color: var(--text-faint);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.mode-btn:hover { color: var(--text-dim); }
.mode-btn.active[data-mode="demo"] {
  background: var(--accent-warn-dim);
  color: var(--accent-warn);
}
.mode-btn.active[data-mode="live"] {
  background: var(--accent-danger-dim);
  color: var(--accent-danger);
}

.clock {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  min-width: 72px;
  text-align: right;
}

/* ===== Status strip ===== */
.status-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 28px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  background: var(--accent-warn-dim);
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}
.status-strip.live {
  background: var(--accent-danger-dim);
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-warn);
  box-shadow: 0 0 0 3px rgba(226, 160, 63, 0.15);
}
.status-strip.live .status-dot {
  background: var(--accent-danger);
  box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.15);
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 2px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.tab {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 13px 16px 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--text);
  border-bottom-color: var(--brand);
}
.tab-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
}

/* ===== Main / panels ===== */
main {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px;
}

.panel { }

.limit-section { margin-bottom: 24px; }
.section-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.field-wide { grid-column: 1 / -1; }

.field {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  background: var(--bg);
  padding: 8px 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-wrap:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-dim);
}
.input-wrap input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
}
.input-wrap input[type="text"] { font-size: 14px; }
.input-wrap input::-webkit-outer-spin-button,
.input-wrap input::-webkit-inner-spin-button {
  opacity: 0.4;
}
.unit {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
}
.unit-prefix { order: -1; }
.hint {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--text-faint);
  line-height: 1.4;
}

/* ===== Kill switch ===== */
.killswitch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 20px;
}
.killswitch-text { display: flex; flex-direction: column; gap: 3px; }
.killswitch-label {
  font-size: 13px;
  font-weight: 600;
}
.killswitch-desc {
  font-size: 12px;
  color: var(--text-dim);
  max-width: 480px;
}
.killswitch {
  position: relative;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}
.killswitch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--accent-safe-dim);
  border: 1px solid var(--accent-safe);
  transition: background 0.2s, border-color 0.2s;
}
.killswitch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-safe);
  transition: transform 0.2s, background 0.2s;
}
.killswitch[aria-checked="false"] .killswitch-track {
  background: var(--accent-danger-dim);
  border-color: var(--accent-danger);
}
.killswitch[aria-checked="false"] .killswitch-thumb {
  transform: translateX(24px);
  background: var(--accent-danger);
}

/* ===== Footer / actions ===== */
.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
}
.form-footer-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
}
.form-footer-actions { display: flex; gap: 10px; }

.btn {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  border-radius: 4px;
  padding: 10px 18px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter 0.15s, background 0.15s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { filter: brightness(0.95); }
.btn-small { padding: 6px 12px; font-size: 12px; }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}
.btn-ghost:hover { color: var(--text); }

.btn-primary {
  background: var(--accent-warn);
  color: #1a1305;
}
.btn-primary.live-mode {
  background: var(--accent-danger);
  color: #2a0a0c;
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

/* ===== State / JSON tab ===== */
.state-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.json-viewer {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
}
.jv-key { color: #7dc4ff; }
.jv-string { color: #9fdca4; }
.jv-number { color: #e2a03f; }
.jv-bool-true { color: #35b37e; font-weight: 600; }
.jv-bool-false { color: #e5484d; font-weight: 600; }
.jv-null { color: var(--text-faint); }

/* ===== Footer ===== */
.foot {
  text-align: center;
  padding: 20px;
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-alt);
  border: 1px solid var(--accent-safe);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 12px 20px;
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.error { border-color: var(--accent-danger); }

/* ===== Responsive ===== */
@media (max-width: 700px) {
  .grid { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
  main { padding: 18px; }
  .tabs { padding: 0 16px; }
  .status-strip { padding: 8px 16px; }
}
