:root {
  --bg: #0e1014;
  --panel: #171a21;
  --line: #262b36;
  --text: #e9ecf2;
  --muted: #9aa3b2;
  --me: #2f6fed;
  --accent: #ff6b5b;
  --ok: #34c77b;
  --warn: #f2b83b;
  --bad: #ef5350;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", sans-serif; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.screen { height: 100dvh; display: flex; flex-direction: column; }

/* pairing */
#pair { align-items: center; justify-content: center; padding: 24px; text-align: center; gap: 4px; }
.pair-icon { width: 84px; height: 84px; border-radius: 20px; margin-bottom: 8px; }
#pair h1 { margin: 0; font-size: 24px; }
#pair p { color: var(--muted); margin: 6px 0 16px; }
#pair-form { display: flex; gap: 8px; width: 100%; max-width: 320px; }
#code { flex: 1; min-width: 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); font-size: 20px; letter-spacing: 3px; text-align: center; }
#pair-form button { padding: 12px 18px; border-radius: 12px; border: 0; background: var(--me); font-weight: 600; }
.error { color: var(--bad); min-height: 1.4em; }

/* header */
header { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; border-bottom: 1px solid var(--line); }
.title { font-weight: 700; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 11px; font-size: 13px; }
.chip[aria-pressed="true"] { border-color: var(--me); background: rgba(47, 111, 237, .18); }
.hint { margin: 8px 16px 0; padding: 8px 12px; border-radius: 10px; background: var(--panel); color: var(--muted); font-size: 13px; }

/* conversation */
#log { flex: 1; overflow-y: auto; padding: 14px 16px 8px; display: flex; flex-direction: column; gap: 10px;
  -webkit-overflow-scrolling: touch; }
.msg { max-width: 86%; padding: 9px 13px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--me); border-bottom-right-radius: 6px; }
.msg.mac { align-self: flex-start; background: var(--panel); border-bottom-left-radius: 6px; }
.msg.thinking { color: var(--muted); }
.time { align-self: center; color: var(--muted); font-size: 12px; margin-top: 6px; }

.job { align-self: stretch; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; background: #12151b; }
.job-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.job-kind { font-weight: 600; color: var(--text); text-transform: capitalize; }
.job-state { font-weight: 600; }
.job.working .job-state { color: var(--warn); }
.job.done .job-state { color: var(--ok); }
.job.failed .job-state { color: var(--bad); }
.job-brief { color: var(--muted); font-size: 13px; margin-top: 4px; }
.job-progress { font-size: 13px; margin-top: 6px; color: var(--muted); }
.job.working .job-progress::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px;
  border-radius: 50%; background: var(--warn); animation: pulse 1s infinite alternate; }
.job-summary { margin-top: 8px; }
.job-more { margin-top: 8px; border: 0; background: none; color: var(--me); padding: 0; font-size: 14px; }
.job-details { margin-top: 8px; font-size: 14px; color: #cfd5df; overflow-wrap: anywhere; }
.job-details a { color: #7aa7ff; }
@keyframes pulse { from { opacity: .35; } to { opacity: 1; } }

/* bottom bar */
footer { border-top: 1px solid var(--line); padding: 8px 12px calc(env(safe-area-inset-bottom) + 10px); }
.status { min-height: 18px; font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 6px; }
.bar { display: flex; align-items: center; gap: 8px; }
#form { flex: 1; min-width: 0; }
#text { width: 100%; padding: 12px 14px; border-radius: 22px; border: 1px solid var(--line); background: var(--panel); }
.lang { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); font-size: 13px; flex: none; }
.mic { width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--accent); flex: none;
  display: grid; place-items: center; box-shadow: 0 6px 20px rgba(255, 107, 91, .35); }
.mic svg { width: 30px; height: 30px; fill: #fff; }
.mic.listening { background: var(--ok); animation: pulse .8s infinite alternate; }
.mic.busy { opacity: .6; }
