/* foxytalk console — widget-family palette carried over; layout serves the
   two screens (home list + call timeline) rendered by console/app.js. */

:root {
  color-scheme: light dark;
  --bg: #fafafa;
  --fg: #18181b;
  --muted: #71717a;
  --border: #e4e4e7;
  --surface: #f4f4f5;
  --user: #1d4ed8;
  --assistant: #b45309;
  --error: #b91c1c;
  --accent: #16a34a;
  --hilite: #16a34a22;
  --rec: #dc2626;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --fg: #fafafa;
    --muted: #a1a1aa;
    --border: #27272a;
    --surface: #18181b;
  }
}

/* ── reset + base ──────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.5 system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
}
#root {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.5rem;
}
a { color: var(--accent); }

/* ── header ────────────────────────────────────────────────────────────── */
header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}
h1 { font-size: 1.4rem; margin: 0; letter-spacing: -0.02em; }
h1 a { color: inherit; text-decoration: none; }
.meta { display: flex; gap: 1rem; font-size: 0.8rem; color: var(--muted); flex-wrap: wrap; }
.meta code { color: var(--fg); font-family: ui-monospace, SFMono-Regular, monospace; }

/* ── shared bits ───────────────────────────────────────────────────────── */
button {
  font: inherit;
  padding: 0.4rem 0.9rem;
  border-radius: 0.375rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  font-size: 0.85rem;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }
button#start:not(:disabled) { background: var(--accent); color: white; border-color: var(--accent); }

#status { font-size: 0.85rem; color: var(--muted); }
#status.recording { color: var(--accent); font-weight: 600; }
#status.error { color: var(--error); }
#status.connecting { color: var(--muted); font-style: italic; }

.hint { font-size: 0.8rem; color: var(--muted); }
.warn { color: var(--error); }

.rec-chip {
  color: var(--rec);
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── home ──────────────────────────────────────────────────────────────── */
.home {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 44rem;
}
.card h2, .calls h2 {
  font-size: 0.72rem;
  margin: 0 0 0.25rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
}
.form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
}
.form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.78rem; color: var(--muted); }
.form input,
.form select {
  font: inherit;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  background: var(--bg);
  color: var(--fg);
}
.form .hint { font-size: 0.7rem; opacity: 0.8; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }

.calls { display: flex; flex-direction: column; gap: 0.2rem; }
.callrow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  text-decoration: none;
  color: var(--fg);
}
.callrow:hover { background: var(--surface); }
.callrow-id { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 0.82rem; overflow-wrap: anywhere; }
.callrow-meta {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}
.callrow-dur { font-variant-numeric: tabular-nums; }

/* ── call view ─────────────────────────────────────────────────────────── */
.callview {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.callbar {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.callbar .back { text-decoration: none; font-size: 1rem; }
.call-id { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 0.85rem; overflow-wrap: anywhere; }
.ended { font-size: 0.8rem; color: var(--muted); }
.spacer { flex: 1; }
.owner-controls { display: flex; gap: 0.75rem; align-items: center; }

/* transport (replay) */
#transport {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
}
#play {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  padding: 0;
  font-size: 1rem;
}
#scrub { flex: 1; min-width: 10rem; accent-color: var(--accent); }
#tc { font-variant-numeric: tabular-nums; font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
#transport label { font-size: 0.8rem; color: var(--muted); white-space: nowrap; user-select: none; }
#tracks { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
#no-audio { font-size: 0.8rem; color: var(--muted); font-style: italic; }
.track-badge {
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--error);
  border-radius: 999px;
}

/* tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); }
.tabs button {
  border: none;
  background: none;
  color: var(--muted);
  border-radius: 0;
  padding: 0.4rem 0.9rem;
  border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--fg); border-bottom-color: var(--accent); }

/* timeline panes. display:flex ties with the UA [hidden]{display:none} on
   specificity and wins by source order, so re-assert hidden explicitly. */
.timeline[hidden] { display: none; }
.timeline { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#transcript { flex: 1; min-height: 0; overflow-y: auto; padding: 0.25rem 0.2rem 2rem; }
#table { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 0.6rem; padding-top: 0.25rem; }

/* transcript rows (ported from the viewer) */
.row { display: flex; gap: 0.6rem; padding: 0.2rem 0.4rem; border-radius: 6px; cursor: pointer; align-items: baseline; }
.row:hover { background: var(--surface); }
.row.current { background: var(--hilite); }
.row .t { flex: 0 0 5.5rem; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.8rem; }
.row .body { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* Utterance rows — the old live widget's tabular look (time | ROLE | text),
   so the conversation stands out from the muted event notes around it. */
.row.utter { padding: 0.35rem 0.4rem; border-radius: 0; border-bottom: 1px solid var(--border); }
.row.utter .role {
  flex: 0 0 5rem;
  margin: 0;
  font-weight: 700;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.row.utter pre {
  flex: 1;
  min-width: 0;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.83rem;
}

.ghost-btn {
  font-size: 0.7rem;
  padding: 0.2rem 0.55rem;
  border-radius: 0.3rem;
  color: var(--muted);
}
.ghost-btn:hover { color: var(--fg); border-color: var(--muted); }
.role { font-weight: 600; margin-right: 0.4rem; }
.role.user { color: var(--user); }
.role.assistant { color: var(--assistant); }
.role.system { color: var(--muted); }
.note { color: var(--muted); font-size: 0.85rem; }
.note.warn { color: var(--error); }
.chip {
  display: inline-block;
  padding: 0 0.4rem;
  margin-left: 0.3rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.72rem;
  color: var(--muted);
}
details { margin-top: 0.15rem; }
details summary { color: var(--muted); font-size: 0.8rem; cursor: pointer; }
details pre {
  margin: 0.25rem 0 0;
  padding: 0.5rem;
  background: var(--surface);
  border-radius: 6px;
  font-size: 0.78rem;
  white-space: pre-wrap;
  overflow-x: auto;
}

/* table tab (ported from the viewer) */
#controls { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
#controls input {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.85rem;
}
#filters { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.fchip {
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
  user-select: none;
}
.fchip.on { color: var(--fg); border-color: var(--accent); }
.twrap { flex: 1; min-height: 0; overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.82rem; }
th, td { text-align: left; padding: 0.2rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--bg); }
td.t { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
td.ty { white-space: nowrap; font-weight: 500; }
td.detail { overflow-wrap: anywhere; color: var(--fg); }
tr { cursor: pointer; }
tr:hover td { background: var(--surface); }
tr.current td { background: var(--hilite); }

/* ── shot-clock panel (owner, live) ────────────────────────────────────── */
.clock-panel {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
  flex-wrap: wrap;
}
.clock-head { display: flex; align-items: center; gap: 0.5rem; }
.clock-title {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  color: var(--muted);
}
.activity-badge {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.12rem 0.4rem;
  border-radius: 0.25rem;
  border: 1px solid var(--border);
  color: var(--muted);
}
.activity-badge[data-activity="LOOKUP"] { color: var(--assistant); border-color: var(--assistant); }
.activity-badge[data-activity="IDLE"] { color: var(--accent); border-color: var(--accent); }
.clock-timers { display: flex; gap: 1.25rem; }
.timer { display: flex; align-items: baseline; gap: 0.35rem; }
.timer-label { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.timer-val {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}

/* ── responsive fallback ───────────────────────────────────────────────── */
@media (max-width: 720px) {
  #root { padding: 0.75rem; }
  .callrow { flex-direction: column; gap: 0.15rem; }
  .callrow-meta { flex-wrap: wrap; white-space: normal; }
}
