:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --line: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --vi: #2563eb;      /* người nói tiếng Việt */
  --zh: #b45309;      /* người nói tiếng Trung */
  --accent: #ef4444;  /* đang ghi âm */
  --ok: #22c55e;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: light) {
  :root { --bg:#f8fafc; --panel:#fff; --line:#e2e8f0; --text:#0f172a; --muted:#64748b; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  display: flex; flex-direction: column; overflow: hidden;
  padding-top: var(--safe-t);
}

header { display:flex; align-items:center; justify-content:space-between; padding: 12px 16px 6px; }
h1 { font-size: 18px; margin: 0; font-weight: 650; }
h1 span { color: var(--muted); margin: 0 2px; }
.head-right { display:flex; align-items:center; gap: 10px; }
.status { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.status.on { background: var(--ok); }
.status.off { background: var(--accent); }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 18px; padding: 6px; cursor: pointer; }

.modes { display:flex; gap: 6px; padding: 6px 16px 10px; }
.modes button {
  flex: 1; padding: 9px 6px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer;
}
.modes button[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }

main { flex: 1; overflow-y: auto; padding: 8px 16px 16px; display:flex; flex-direction:column; gap: 12px; scroll-behavior: smooth; }
.empty { margin: auto; text-align: center; color: var(--muted); max-width: 280px; }

.msg { max-width: 88%; border-radius: 18px; padding: 10px 14px; position: relative; word-wrap: break-word; }
.msg.vi { align-self: flex-end; background: var(--vi); color: #fff; border-bottom-right-radius: 6px; }
.msg.zh { align-self: flex-start; background: var(--zh); color: #fff; border-bottom-left-radius: 6px; }
.msg .src { font-size: 13px; opacity: .78; margin-bottom: 4px; }
.msg .out { font-size: 20px; font-weight: 600; line-height: 1.35; }
.msg .py { font-size: 14px; opacity: .85; margin-top: 3px; font-style: italic; }
.msg .meta { display:flex; align-items:center; gap: 10px; margin-top: 8px; font-size: 12px; opacity: .8; }
.msg .meta button {
  background: rgba(255,255,255,.2); border: 0; color: inherit; border-radius: 999px;
  padding: 4px 10px; font: inherit; cursor: pointer;
}
.msg.pending { opacity: .75; }
.msg.error { align-self: center; background: transparent; border: 1px dashed var(--line); color: var(--muted); font-size: 14px; }
.dots::after { content: "…"; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

footer {
  padding: 8px 16px calc(14px + var(--safe-b)); display:flex; flex-direction:column; align-items:center; gap: 10px;
  border-top: 1px solid var(--line); background: var(--bg);
}
.hint { min-height: 20px; font-size: 14px; color: var(--muted); text-align:center; }
.hint.rec { color: var(--accent); font-weight: 600; }
.mic {
  width: 76px; height: 76px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--text); color: var(--bg); display:grid; place-items:center;
  box-shadow: 0 6px 20px rgba(0,0,0,.3); transition: transform .12s;
}
.mic:active { transform: scale(.94); }
.mic.rec { background: var(--accent); color: #fff; animation: pulse 1.2s infinite; }
.mic.busy { opacity: .5; pointer-events: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(239,68,68,.6);} 100% { box-shadow: 0 0 0 22px rgba(239,68,68,0);} }

#textform { display:flex; gap: 8px; width: 100%; max-width: 560px; }
#textin {
  flex: 1; padding: 12px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font: inherit; font-size: 16px; min-width: 0;
}
.send { width: 46px; border-radius: 50%; border: 0; background: var(--vi); color:#fff; font-size: 18px; cursor:pointer; }
