/* ── Tokens ─────────────────────────────────────────────────────────────────
   Dark, slate-teal-tinted neutrals. Rep = warm amber, Customer = cool sky.
   Foreground tokens chosen for AA on the surface. */
:root {
  --hue: 230;

  --surface:      oklch(0.18 0.018 var(--hue));
  --surface-2:    oklch(0.21 0.020 var(--hue));
  --surface-3:    oklch(0.25 0.022 var(--hue));
  --line:         oklch(0.30 0.020 var(--hue));

  --text:         oklch(0.96 0.010 var(--hue));
  --text-2:       oklch(0.78 0.020 var(--hue));
  --text-muted:   oklch(0.70 0.020 var(--hue));

  --rep:          oklch(0.78 0.130 75);
  --customer:     oklch(0.74 0.100 var(--hue));
  --live:         oklch(0.80 0.150 150);
  --danger:       oklch(0.70 0.160 25);

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;

  --radius: 10px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --font-ui: 'Hanken Grotesk', system-ui, sans-serif;
  --font-body: 'Literata', Georgia, serif;
  --font-mono: 'Martian Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  height: 100vh;
}

/* ── Left rail ──────────────────────────────────────────────────────────── */
.rail {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  padding: var(--space-xl);
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.rail__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.wordmark {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.chip {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-2);
  white-space: nowrap;
}
.chip--idle { color: var(--text-muted); }
.chip--incoming { color: var(--rep); border-color: color-mix(in oklch, var(--rep) 50%, var(--line)); }
.chip--live {
  color: var(--live);
  border-color: color-mix(in oklch, var(--live) 50%, var(--line));
}
.chip--live::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--live);
  vertical-align: middle;
  animation: pulse 1.6s var(--ease-out) infinite;
}
.chip--ended { color: var(--text-muted); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

/* Incoming banner — the one place the UI raises its voice */
.banner {
  padding: var(--space-lg);
  border-radius: var(--radius);
  background: color-mix(in oklch, var(--rep) 14%, var(--surface-3));
  border: 1px solid color-mix(in oklch, var(--rep) 40%, var(--line));
  animation: rise 0.4s var(--ease-out);
}
.banner__label {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--rep);
}
.banner__from {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.notice {
  margin: var(--space-sm) 0 0;
  font-size: 0.82rem;
  color: var(--text-2);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.btn {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.08s var(--ease-out), background 0.15s, opacity 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn--primary {
  background: var(--rep);
  color: oklch(0.22 0.04 75);
}
.btn--primary:not(:disabled):hover { background: color-mix(in oklch, var(--rep) 88%, white); }

.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-2);
}
.btn--ghost:not(:disabled):hover { color: var(--danger); border-color: color-mix(in oklch, var(--danger) 45%, var(--line)); }

.meta dl { margin: 0; display: flex; flex-direction: column; gap: var(--space-md); }
.meta div { display: flex; justify-content: space-between; align-items: baseline; }
.meta dt { font-size: 0.78rem; color: var(--text-muted); }
.meta dd { margin: 0; font-size: 0.92rem; color: var(--text); font-variant-numeric: tabular-nums; }

/* Past calls */
.past { margin-top: auto; }
.past__title {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 var(--space-md);
}
.past__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.past__empty { color: var(--text-muted); font-size: 0.85rem; padding: var(--space-sm) 0; }
.past__item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: var(--space-sm) var(--space-md);
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--font-ui);
  transition: background 0.12s, border-color 0.12s;
}
.past__item:hover { background: var(--surface-3); }
.past__item[aria-selected='true'] { border-color: var(--line); background: var(--surface-3); color: var(--text); }
.past__item-from { font-size: 0.9rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.past__item-sub { font-size: 0.74rem; color: var(--text-muted); margin-top: 2px; }
.past[aria-disabled='true'] { opacity: 0.5; pointer-events: none; }

/* ── Transcript ─────────────────────────────────────────────────────────── */
.transcript {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.transcript__scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3xl) var(--space-2xl);
}

.empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-sm);
}
.empty__lead { font-size: 1.3rem; font-weight: 500; margin: 0; color: var(--text-2); }
.empty__sub { font-size: 0.95rem; color: var(--text-muted); margin: 0; }

.lines {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 70ch;
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

.line { animation: rise 0.35s var(--ease-out); }
.line__head {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
  margin-bottom: 4px;
}
.line__speaker {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.line__time { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-muted); }
.line__text {
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.65;
  margin: 0;
  color: var(--text);
}

/* Speaker distinction: label + alignment + color (never color alone) */
.line--rep { padding-left: var(--space-2xl); }
.line--rep .line__head { flex-direction: row-reverse; }
.line--rep .line__speaker { color: var(--rep); }
.line--rep .line__text { text-align: right; }

.line--customer { padding-right: var(--space-2xl); }
.line--customer .line__speaker { color: var(--customer); }

.jump {
  position: absolute;
  bottom: var(--space-xl);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  cursor: pointer;
  box-shadow: 0 4px 16px oklch(0.1 0.02 var(--hue) / 0.5);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .chip--live::before { opacity: 1; }
}

/* ── Narrow screens ─────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: auto; min-height: 100vh; }
  .rail { border-right: none; border-bottom: 1px solid var(--line); }
  .past { margin-top: var(--space-lg); }
}
