:root {
  color-scheme: light dark;
  --bg: #f6f7f8;
  --surface: #ffffff;
  --text: #17191c;
  --muted: #6f747c;
  --line: #e4e6e9;
  --accent: #ff4f4a;
  --accent-dark: #e83c38;
  --success: #18864b;
  --success-bg: #e9f7ee;
  --danger: #c93632;
  --danger-bg: #fff0ef;
  --radius: 14px;
  --shadow: 0 14px 34px rgba(22, 25, 30, .08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; color: var(--text); background: var(--bg); font-size: 16px; line-height: 1.55; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .58; }
input, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; color: var(--text);
  background: var(--surface); padding: 14px 15px; outline: 0;
}
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,79,74,.13); }
label { display: block; margin: 14px 0 7px; font-weight: 650; font-size: .91rem; }
.primary, .secondary {
  width: 100%; min-height: 52px; border-radius: 12px; font-weight: 750; border: 1px solid transparent;
}
.primary { color: #fff; background: var(--accent); }
.primary:hover { background: var(--accent-dark); }
.secondary { color: var(--text); background: var(--surface); border-color: var(--line); }
.text-button { border: 0; background: transparent; color: var(--muted); padding: 8px; font-weight: 650; }
.text-button.accent { color: var(--accent); }
.status { min-height: 25px; margin: 10px 0; color: var(--muted); font-size: .92rem; }
.status.error { color: var(--danger); }
.status.success { color: var(--success); }
.login-page { min-height: 100svh; }
.auth-shell { min-height: 100svh; display: grid; place-items: center; padding: 28px 20px; }
.auth-panel { width: min(100%, 390px); text-align: center; }
.brand-icon {
  width: 86px; height: 86px; display: grid; place-items: center; margin: 0 auto 22px;
  border-radius: 25px; background: var(--accent); box-shadow: 0 16px 30px rgba(255,79,74,.24);
}
.brand-icon svg { width: 53px; fill: #fff; stroke: #fff; stroke-width: 4; stroke-linecap: round; }
.auth-panel h1 { font-size: 2.2rem; letter-spacing: -.04em; margin: 0 0 5px; }
.lead { color: var(--muted); margin: 0 0 36px; }
.auth-panel form { text-align: left; }
.privacy-note { color: var(--muted); font-size: .82rem; margin-top: 26px; }
.topbar { position: sticky; top: 0; z-index: 5; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); }
.topbar-inner { max-width: 620px; margin: auto; min-height: 62px; display: flex; align-items: center; gap: 10px; padding: 0 16px; }
.topbar h1 { flex: 1; font-size: 1.15rem; margin: 0; }
.mini-brand { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: var(--accent); font-weight: 800; }
.app-shell { max-width: 620px; margin: 0 auto; padding: 14px 16px calc(46px + env(safe-area-inset-bottom)); }
.network-status { display: flex; align-items: center; gap: 8px; margin: 0 0 24px; padding: 9px 12px; border-radius: 10px; font-size: .87rem; }
.network-status span { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.network-status.online { color: var(--success); background: var(--success-bg); }
.network-status.offline { color: var(--danger); background: var(--danger-bg); }
.section-heading { display: flex; align-items: center; justify-content: space-between; }
h2 { font-size: 1rem; margin: 0 0 11px; }
.speaker-row { display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.speaker-row > div:nth-child(2) { flex: 1; min-width: 0; }
.speaker-row strong, .speaker-row small { display: block; }
.speaker-row small, .speaker-choice small { color: var(--muted); font-size: .8rem; }
.speaker-glyph { width: 38px; height: 45px; display: grid; place-items: center; border-radius: 9px; background: #22272c; color: #fff; }
.online-pill { color: var(--success); background: var(--success-bg); padding: 3px 8px; border-radius: 999px; font-size: .75rem; }
.speaker-list { margin-top: 8px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.speaker-choice { width: 100%; display: flex; justify-content: space-between; text-align: left; padding: 13px 14px; border: 0; border-bottom: 1px solid var(--line); color: var(--text); background: var(--surface); }
.speaker-choice:last-child { border-bottom: 0; }
.speaker-choice.selected { color: var(--accent); }
.composer { margin-top: 28px; }
.textarea-wrap { position: relative; }
textarea { resize: vertical; min-height: 190px; padding-bottom: 38px; line-height: 1.65; }
#char-count { position: absolute; right: 13px; bottom: 12px; color: var(--muted); font-size: .82rem; }
.send-button { font-size: 1.05rem; margin-bottom: 10px; }
.history-section { margin-top: 30px; }
.history-list { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.history-item { display: flex; gap: 12px; justify-content: space-between; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.history-item:last-child { border: 0; }
.history-item p { margin: 0 0 3px; overflow-wrap: anywhere; }
.history-item time { color: var(--muted); font-size: .77rem; }
.history-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.history-actions button { border: 0; color: var(--accent); background: transparent; padding: 7px; font-size: .78rem; }
.empty { color: var(--muted); text-align: center; padding: 24px; border: 1px dashed var(--line); border-radius: var(--radius); }
.settings-panel { margin-top: 30px; border-top: 1px solid var(--line); padding-top: 16px; }
.settings-panel summary { cursor: pointer; color: var(--muted); font-weight: 650; }
.settings-panel form { margin-top: 12px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.setup-shell { max-width: 620px; margin: 0 auto; padding: 28px 17px 60px; }
.setup-header { margin-bottom: 30px; }
.setup-header h1 { margin: 0; font-size: 1.65rem; }
.setup-header p { margin: 6px 0 0; color: #a85b00; background: #fff7e8; padding: 10px 12px; border-radius: 10px; }
.setup-step { display: grid; grid-template-columns: 35px 1fr; gap: 10px; margin-bottom: 24px; }
.setup-step > div:last-child { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.setup-step h2 { margin: 0; font-size: 1.08rem; }
.setup-step p { color: var(--muted); font-size: .86rem; }
.step-number { width: 28px; height: 28px; display: grid; place-items: center; color: #fff; background: var(--accent); border-radius: 50%; font-weight: 800; }
.setup-step.complete .step-number { background: var(--success); }
.setup-speaker { display: flex; align-items: center; justify-content: space-between; margin: 10px 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.setup-speaker small { display: block; color: var(--muted); }
.setup-speaker input { width: 22px; height: 22px; accent-color: var(--accent); }
.setup-success { text-align: center; padding: 100px 20px; }
.success-mark { margin: auto; width: 70px; height: 70px; display: grid; place-items: center; color: #fff; background: var(--success); border-radius: 50%; font-size: 2rem; }
.button-link { display: grid; place-items: center; text-decoration: none; margin-top: 28px; }
@media (min-width: 700px) {
  .app-shell { padding-top: 28px; }
  .auth-panel { padding: 38px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111417; --surface: #1b1f23; --text: #f3f4f5; --muted: #a7adb5; --line: #343a41;
    --success-bg: #163c29; --danger-bg: #421e1d; --shadow: 0 14px 34px rgba(0,0,0,.28);
  }
  .setup-header p { color: #ffc069; background: #3b2a13; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }

