:root {
  --bg: #0e0f12;
  --panel: #15171c;
  --border: #2a2d36;
  --text: #e8e8ee;
  --dim: #888a93;
  --accent: #ffc94a;
  --warn: #ff5f5f;
  --ok: #54d984;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.45;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; letter-spacing: 0.18em; }
.status { color: var(--dim); flex: 1; }
.controls { display: flex; gap: 6px; align-items: center; }
button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 10px;
  font: inherit;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button:disabled, input:disabled {
  opacity: 0.46;
  cursor: not-allowed;
}
button.loading {
  position: relative;
  color: var(--dim);
}
button.loading::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border: 2px solid var(--dim);
  border-top-color: var(--accent);
  border-radius: 50%;
  vertical-align: -1px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
input, textarea {
  background: #0a0b0e;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 8px;
  font: inherit;
  width: 100%;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 8, 11, 0.84);
}
.auth-gate-card {
  width: min(360px, calc(100vw - 32px));
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 22px;
}
.auth-gate-card h1 {
  margin: 18px 0 6px;
  font-size: 18px;
  letter-spacing: 0;
}
.auth-gate-card p {
  margin: 0 0 18px;
  color: var(--dim);
}
.auth-gate-card button {
  width: 100%;
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 12px;
  padding: 12px;
  height: calc(100vh - 50px);
}

.storyboard-panel {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  min-height: 0;
}
.panel-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.panel-header h2 { margin: 0; font-size: 14px; letter-spacing: 0.12em; }
.hint { color: var(--dim); font-size: 11px; }

.storyboard {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.storyboard .empty {
  color: var(--dim);
  text-align: center;
  padding: 60px 20px;
}

.checkpoint {
  border: 1px solid var(--border);
  background: #101216;
  padding: 10px;
  flex-shrink: 0;
}
.checkpoint-header {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 8px;
}
.checkpoint-status-pill {
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 2px 6px;
  border-radius: 2px;
  background: #1d2129;
  color: var(--dim);
}
.checkpoint.committed .checkpoint-status-pill { background: #234c3a; color: var(--ok); }
.checkpoint.current .checkpoint-status-pill { background: #4c4523; color: var(--accent); }

.branch {
  border: 1px solid var(--border);
  padding: 8px;
  margin-top: 8px;
}
.branch-label { font-weight: 600; }
.branch-narrative { color: var(--dim); margin: 4px 0 8px; }

.frames-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.frame {
  aspect-ratio: 16/9;
  background: #06070a;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  cursor: pointer;
  position: relative;
  font-size: 11px;
}
.frame img { width: 100%; height: 100%; object-fit: cover; }
.frame .frame-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  padding: 4px 6px;
  font-size: 10px;
}

.reject-bar {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--border);
}
.reject-bar input { flex: 1; }

.side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}
.side > section {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 10px;
}
.side h3 { margin: 0 0 8px; font-size: 11px; letter-spacing: 0.16em; color: var(--dim); }

.transcript, .terminal {
  flex: 1;
  overflow-y: auto;
  font-size: 11px;
  max-height: 220px;
}
.transcript .turn { margin-bottom: 4px; }
.transcript .speaker { color: var(--accent); margin-right: 6px; }
.terminal .ev { color: var(--dim); }
.terminal .ev.warn { color: var(--warn); }
.terminal .ev.ok { color: var(--ok); }

#mic-btn.on { background: #4c2323; color: #ffaaaa; }

/* billing */
.billing-card .row {
  display: flex; justify-content: space-between;
  font-size: 12px; margin-bottom: 4px;
  gap: 12px;
}
.billing-card .row.pct { color: var(--dim); font-size: 11px; }
.billing-offer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.billing-offer span {
  color: var(--accent);
  font-weight: 700;
}
.billing-note {
  margin: 8px 0 0;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.45;
}
.info-tip {
  width: 18px;
  height: 18px;
  padding: 0;
  margin-left: 4px;
  border-radius: 50%;
  color: var(--accent);
  font-weight: 800;
  text-align: center;
  line-height: 16px;
}
.billing-card .bar {
  height: 6px; background: #2a2a2a; border-radius: 3px;
  margin: 6px 0 4px 0; overflow: hidden;
}
.billing-card .bar-fill { height: 100%; background: var(--ok); transition: width 0.2s; }
.billing-card .bar-warn .bar-fill { background: var(--warn); }
.billing-card .bar-over .bar-fill { background: #c44; }
.billing-actions { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.billing-actions button { font-weight: bold; }
