:root {
  --bg: #0a0a0b;
  --fg: #e8e8ea;
  --dim: #6a6a70;
  --accent: #e3b53f;   /* 74:30 gold */
  --green: #3fbb7e;    /* capture mode */
  --line: #1d1d20;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "SF Pro Text", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
}

header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--dim);
}
.brand { letter-spacing: .02em; }
.brand .dot { color: var(--accent); }
#status { color: var(--dim); }
.controls { display: flex; align-items: center; gap: 14px; }
.toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--green); }
#history-btn, #new-chat-btn {
  background: none; border: 1px solid transparent; color: var(--dim);
  font-size: 13px; cursor: pointer; padding: 4px 10px; border-radius: 6px;
  font-family: inherit;
}
#history-btn { font-size: 20px; padding: 2px 8px; }
#history-btn:hover, #new-chat-btn:hover { background: var(--line); color: var(--fg); }
#new-chat-btn { border-color: var(--line); }

main {
  overflow-y: auto;
  padding: 24px 20px 40px;
  max-width: 760px; margin: 0 auto; width: 100%;
}

.hint { color: var(--dim); font-size: 14px; text-align: center; margin-top: 10vh; }
.hint kbd {
  background: var(--line); padding: 2px 6px; border-radius: 4px;
  font-family: ui-monospace, monospace; font-size: 12px;
}

.turn { margin-bottom: 28px; }
.turn .role {
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--dim); margin-bottom: 4px;
}
.turn.user .role { color: var(--accent); }
.turn .text { white-space: pre-wrap; }
.turn.tool {
  font-family: ui-monospace, monospace; font-size: 12px;
  color: var(--dim); border-left: 2px solid var(--line); padding-left: 10px;
  margin-bottom: 12px;
}

footer {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 0 26px; border-top: 1px solid var(--line);
}

#ptt {
  background: transparent; border: none; cursor: pointer; padding: 0;
  transition: transform .12s ease;
}
#ptt:active { transform: scale(0.96); }

#ptt .ring { fill: none; stroke: var(--line); stroke-width: 2; }
#ptt .core { fill: var(--accent); transition: fill .2s, r .2s; }

body[data-state="recording"] #ptt .ring { stroke: var(--accent); }
body[data-state="recording"] #ptt .core { fill: #fff; animation: pulse 1.1s ease-in-out infinite; }
body[data-state="thinking"] #ptt .core { fill: var(--dim); }
body[data-state="speaking"] #ptt .core { fill: var(--accent); animation: breathe 2s ease-in-out infinite; }
body[data-mode="capture"] #ptt .core { fill: var(--green); }

@keyframes pulse {
  0%, 100% { r: 22; }
  50% { r: 26; }
}
@keyframes breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}

.ptt-label {
  font-size: 12px; color: var(--dim);
}

dialog#history-dialog {
  background: #111113; color: var(--fg); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0; width: min(520px, 92vw);
  max-height: 70vh;
}
dialog::backdrop { background: rgba(0,0,0,.6); }
.history-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
#history-close {
  background: none; border: none; color: var(--dim); font-size: 20px;
  cursor: pointer;
}
#history-list {
  list-style: none; margin: 0; padding: 8px 0; overflow-y: auto; max-height: 60vh;
}
#history-list li {
  padding: 10px 16px; font-size: 13px; cursor: pointer;
  border-bottom: 1px solid var(--line);
}
#history-list li:hover { background: var(--line); }
#history-list .ts { color: var(--dim); font-size: 11px; }
