:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #16191f;
  --muted: #5d6573;
  --line: #e2e5ea;
  --accent: #2563eb;
  --accent-soft: #e8efff;
  --user: #16191f;
  --user-ink: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --speaking: #fef3c7;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --panel: #1a1d24;
    --ink: #e8eaee;
    --muted: #9aa3b2;
    --line: #2b303a;
    --accent: #6d9bff;
    --accent-soft: #1e2a44;
    --user: #e8eaee;
    --user-ink: #111318;
    --ok: #4ade80;
    --warn: #fbbf24;
    --bad: #f87171;
    --speaking: #3d3216;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100vh;
}

.app { height: 100%; display: flex; gap: 16px; padding: 16px; }

.voice { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }

body.hosted .voice { flex: 0 0 440px; }

.screen-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.screen-head { color: var(--muted); font-size: 13px; }
.screen-frame { flex: 1; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; align-items: flex-start; justify-content: center; }
.screen-frame img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }

@media (max-width: 1000px) {
  body { height: auto; }
  .app { flex-direction: column; height: auto; }
  body.hosted .voice { flex: none; height: 85vh; }
  .screen-panel { height: 70vh; }
}

.overlay { position: fixed; inset: 0; background: rgba(10, 12, 16, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.overlay[hidden] { display: none; }
.card { background: var(--panel); color: var(--ink); border-radius: 14px; padding: 22px; max-width: 460px; width: 100%; display: grid; gap: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.card h2 { margin: 0; font-size: 20px; }
.card p { margin: 0; }
.card .fine { color: var(--muted); font-size: 13px; }
.passcode { display: grid; gap: 4px; font-weight: 600; font-size: 14px; }
.passcode input { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 16px; }
.gate-message { color: var(--bad); min-height: 1.2em; font-size: 14px; }
.card button { padding: 11px 16px; border-radius: 10px; border: 0; background: var(--accent); color: #fff; font-weight: 600; font-size: 15px; cursor: pointer; }
.notice { align-self: center; color: var(--warn); font-size: 13px; font-weight: 600; text-align: center; }

.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
h1 { font-size: 20px; margin: 0; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--line);
  color: var(--muted);
  max-width: 55%;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pill.listening { background: #dcfce7; color: #166534; }
.pill.thinking { background: var(--accent-soft); color: var(--accent); }
.pill.acting { background: #ffedd5; color: #9a3412; }
.pill.speaking { background: var(--speaking); color: var(--warn); }

.controls { display: flex; gap: 10px; align-items: center; }

.mic {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: 999px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.mic .dot { width: 12px; height: 12px; border-radius: 50%; background: #fff; opacity: .6; }
.mic[aria-pressed="true"] { background: #dc2626; }
.mic[aria-pressed="true"] .dot { opacity: 1; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { transform: scale(1.5); opacity: .4; } }

.ghost {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.hearing { margin: 0; min-height: 1.4em; color: var(--muted); font-style: italic; }
.support { margin: 0; color: var(--bad); font-size: 13px; }

.steps { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.steps ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.steps li { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; }
.steps li::before { content: "○"; width: 16px; text-align: center; }
.steps li.done { color: var(--ok); }
.steps li.done::before { content: "✓"; font-weight: 700; }
.steps li.current { color: var(--ink); font-weight: 600; }
.steps li.current::before { content: "▶"; color: var(--accent); }

.transcript { flex: 1; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.log { height: 100%; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }

.msg { max-width: 85%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--user); color: var(--user-ink); border-bottom-right-radius: 4px; }
.msg.agent { align-self: flex-start; background: var(--accent-soft); border-bottom-left-radius: 4px; }
.msg.agent.speaking { outline: 2px solid var(--warn); }
.msg .heard { background: var(--speaking); border-radius: 3px; }
.msg .cut { text-decoration: line-through; opacity: .55; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; opacity: .8; }
.msg.user .tag { color: #fbbf24; }
.msg.agent .tag { color: var(--warn); }

.action { align-self: flex-start; font: 12.5px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); padding-left: 6px; overflow-wrap: anywhere; }
.action.ok::before { content: "✓ "; color: var(--ok); }
.action.error::before { content: "✗ "; color: var(--bad); }
.action.skipped::before { content: "⤼ "; color: var(--warn); }
.action.error .detail { color: var(--bad); }
.error-line { color: var(--bad); font-size: 13px; }

.typed { display: flex; gap: 8px; }
.typed input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 15px;
}
.typed button { padding: 10px 16px; border-radius: 10px; border: 0; background: var(--ink); color: var(--bg); font-weight: 600; cursor: pointer; }
