:root {
  --bg: #050506;
  --gold: #E3B341;
  --gold-soft: rgba(227, 179, 65, 0.6);
  --gold-dim: rgba(227, 179, 65, 0.25);
  --fg: #f0ece4;
  --muted: #999;
  --dim: #555;
  --panel: #0a0a0c;
  --border: #1a1a1f;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

/* ── Loading + hidden ────────────────────────────────────── */
#auth-loading {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

#auth-loading[hidden], #app[hidden] {
  display: none !important;
}

#app {
  display: grid;
  grid-template-rows: 56px 1fr 64px;
  height: 100vh;
}

/* ── TOP STATUS BAR ─────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.03em;
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-name {
  color: var(--fg);
  font-weight: 600;
  letter-spacing: 0.1em;
}

.brand-sep { color: var(--dim); }
.brand-tag { color: var(--muted); }

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  display: inline-block;
}

.status-dot.online {
  background: #52b788;
  box-shadow: 0 0 6px rgba(82, 183, 136, 0.6);
}

.online {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.topbar-stat {
  color: var(--muted);
}

/* ── MAIN 3-COLUMN LAYOUT ───────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 340px 1fr 420px;
  height: 100%;
  overflow: hidden;
}

/* ── LEFT SIDEBAR ───────────────────────────────────────── */
.sidebar {
  padding: 32px 28px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

#this-week h2,
#cope-spend h2,
.exchange-label {
  color: var(--gold);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

#this-week .this-week-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

#this-week .stat {
  border: none;
  padding: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
}

#this-week .stat .num {
  color: var(--gold);
  font-size: 2.5rem;
  font-weight: 400;
  font-family: "Inter", sans-serif;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

#this-week .stat .lbl {
  color: var(--muted);
  font-size: 10px;
  margin-top: 6px;
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.08em;
  text-transform: lowercase;
}

#this-week .this-week-note {
  display: none; /* superseded by the bottom ledger-note */
}

/* Cope spend (folded into sidebar bottom) */
#cope-spend {
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

#cope-spend .spend-body {
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
}

#cope-spend .spend-edit-btn {
  margin-top: 8px;
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  padding: 4px 10px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.05em;
  cursor: pointer;
}

#cope-spend .spend-edit-btn:hover {
  background: rgba(227, 179, 65, 0.08);
}

.ledger-note {
  margin-top: auto;
  color: var(--dim);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  line-height: 1.5;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── CENTER HERO ────────────────────────────────────────── */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 32px;
  overflow: hidden;
}

#mic-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.orb-stage {
  position: relative;
  width: 360px;
  height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.orb-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  pointer-events: none;
}

.orb-ring-outer {
  width: 360px;
  height: 360px;
  margin: -180px 0 0 -180px;
  border: 2px solid var(--gold-dim);
  animation: orb-breath 4s ease-in-out infinite;
}

.orb-ring-mid {
  width: 260px;
  height: 260px;
  margin: -130px 0 0 -130px;
  border: 1px dashed var(--gold-soft);
  transform-origin: center;
  animation: orb-spin 30s linear infinite;
}

.orb-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 220px;
  height: 220px;
  margin: -110px 0 0 -110px;
  border-radius: 50%;
  background: radial-gradient(
    circle at center,
    rgba(227, 179, 65, 0.45) 0%,
    rgba(227, 179, 65, 0.15) 40%,
    transparent 70%
  );
  filter: blur(10px);
  pointer-events: none;
  animation: orb-glow-breath 4s ease-in-out infinite;
}

.orb-stage.recording .orb-ring-outer {
  border-color: var(--gold-soft);
  animation: orb-breath 1.4s ease-in-out infinite;
}

.orb-stage.recording .orb-ring-mid {
  border-color: var(--gold);
  animation: orb-spin 8s linear infinite;
}

.orb-stage.recording .orb-glow {
  background: radial-gradient(
    circle at center,
    rgba(227, 179, 65, 0.7) 0%,
    rgba(227, 179, 65, 0.25) 40%,
    transparent 70%
  );
  animation: orb-glow-breath 1.4s ease-in-out infinite;
}

@keyframes orb-breath {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.04); opacity: 0.85; }
}

@keyframes orb-glow-breath {
  0%, 100% { opacity: 0.75; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

@keyframes orb-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .orb-ring-outer, .orb-ring-mid, .orb-glow {
    animation: none !important;
  }
}

.mic-btn {
  position: relative;
  z-index: 2;
  background: transparent;
  color: var(--gold);
  border: none;
  padding: 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: opacity 200ms ease;
}

.mic-btn .mic-icon {
  font-size: 2.5rem;
  line-height: 1;
}

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

.peak-meter {
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.peak-meter .bar {
  width: 4px;
  height: 4px;
  background: var(--gold);
  border-radius: 2px;
  transition: height 60ms linear;
}

.voice-status {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--dim);
  min-height: 1.2em;
  letter-spacing: 0.05em;
}

.hero-headline {
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 4rem;
  color: var(--fg);
  letter-spacing: -0.03em;
  text-align: center;
  line-height: 1.05;
}

.briefcase {
  width: 80px;
  height: 70px;
  margin-top: 8px;
}

.briefcase svg { width: 100%; height: 100%; }

/* ── RIGHT EXCHANGE ─────────────────────────────────────── */
.exchange {
  padding: 32px 28px;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.exchange-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.exchange-bars {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 18px;
}

.exchange-bars span {
  width: 3px;
  background: var(--gold);
  border-radius: 2px;
  display: inline-block;
  height: 6px;
}
.exchange-bars span:nth-child(1) { height: 10px; }
.exchange-bars span:nth-child(2) { height: 16px; }
.exchange-bars span:nth-child(3) { height: 8px; }
.exchange-bars span:nth-child(4) { height: 14px; }
.exchange-bars span:nth-child(5) { height: 6px; }
.exchange-bars span:nth-child(6) { height: 12px; }
.exchange-bars span:nth-child(7) { height: 18px; }
.exchange-bars span:nth-child(8) { height: 10px; }
.exchange-bars span:nth-child(9) { height: 14px; }
.exchange-bars span:nth-child(10) { height: 6px; }

#cope-transcript {
  min-height: 1.5rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 16px;
}

#cope-transcript .you { color: #888; }
#cope-transcript .cope { color: var(--fg); }

.exchange-feed {
  flex: 1;
  overflow-y: auto;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  white-space: pre-wrap;
}

#live-exchange.exchange-feed h2 {
  display: none;
}

#live-exchange .exchange-body {
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.exchange-stack {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  color: var(--dim);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.05em;
}

.stack-latency { color: var(--muted); }

/* ── BOTTOM CTA BAR ─────────────────────────────────────── */
.cta-bar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 24px;
  padding: 0 32px;
  border-top: 1px solid var(--border);
}

.cta-text {
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.02em;
}

.cta-built {
  color: var(--dim);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
}

.cta-notify {
  background: var(--gold);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  padding: 10px 22px;
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 120ms ease;
}

.cta-notify:hover {
  background: #f0c14b;
}

/* ── NOTIFICATION PREFS MODAL ───────────────────────────── */
.prefs-dialog {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 2rem;
  min-width: 380px;
  font-family: "Inter", sans-serif;
}

.prefs-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.prefs-dialog h2 {
  color: var(--gold);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.95rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.prefs-dialog .prefs-sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.prefs-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  font-size: 0.95rem;
  cursor: pointer;
}

.prefs-row input {
  accent-color: var(--gold);
}

.prefs-actions {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.prefs-actions button {
  background: var(--gold);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  padding: 0.5rem 1.25rem;
  font-family: "Inter", sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.prefs-actions .prefs-cancel {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--muted);
}

.prefs-status {
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--gold);
  font-family: "JetBrains Mono", monospace;
}

/* ── RESPONSIVE: stack on narrow screens ───────────────── */
@media (max-width: 1100px) {
  body { overflow-y: auto; }
  #app { height: auto; grid-template-rows: 56px auto 64px; }
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .sidebar, .exchange {
    border-left: none;
    border-right: none;
    border-top: 1px solid var(--border);
  }
  .hero-headline { font-size: 2.5rem; }
  .orb-stage { width: 280px; height: 280px; }
  .orb-ring-outer { width: 280px; height: 280px; margin: -140px 0 0 -140px; }
}

/* ── RESIDUAL REVENUE (sidebar section) ──────────────────── */
#residual h2 { font-size: 12px; letter-spacing: 0.08em; color: var(--muted, #8a8a8a); margin: 18px 0 8px; }
.residual-total { font-size: 22px; font-weight: 700; color: #f0ece4; }
.residual-total-lbl { font-size: 11px; font-weight: 400; color: #8a8a8a; }
.residual-list { margin-top: 8px; }
.residual-row { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; color: #cfc9bf; }
.residual-trend { margin-top: 10px; border-top: 1px solid rgba(255,255,255,.08); padding-top: 8px; }
.residual-trend-h { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: #8a8a8a; margin-bottom: 4px; }
.residual-trend-row { display: flex; justify-content: space-between; font-size: 11px; color: #8a8a8a; padding: 2px 0; }
.residual-empty { font-size: 12px; color: #8a8a8a; }
