:root {
  color-scheme: light;
  --bg: #edf4f2;
  --card: #ffffff;
  --ink: #183035;
  --muted: #63777b;
  --brand: #2e6e73;
  --brand-dark: #21565b;
  --accent: #e9a85d;
  --danger: #a84040;
  --line: #d5e1df;
  --shadow: 0 10px 30px rgba(25, 63, 67, .10);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.app-shell { width: min(760px, 100%); margin: 0 auto; padding: 18px 14px 30px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.eyebrow { color: var(--brand); font-size: .72rem; font-weight: 800; letter-spacing: .18em; }
h1 { margin: 2px 0 0; font-size: 2rem; line-height: 1; }
h1 span { font-size: .8rem; color: var(--muted); font-weight: 600; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--brand); font-size: 1.7rem; }
.hidden { display: none !important; }
.status-card { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow); }
.status-card strong, .status-card small { display: block; }
.status-card small { color: var(--muted); margin-top: 2px; }
.status-dot { width: 13px; height: 13px; border-radius: 50%; background: #c29b42; box-shadow: 0 0 0 5px rgba(194,155,66,.15); flex: 0 0 auto; }
.status-dot.ok { background: #3a9868; box-shadow: 0 0 0 5px rgba(58,152,104,.15); }
.status-dot.error { background: var(--danger); box-shadow: 0 0 0 5px rgba(168,64,64,.15); }
.transcript { min-height: 230px; max-height: 46vh; overflow-y: auto; margin: 14px 0; padding: 4px 2px; scroll-behavior: smooth; }
.message { max-width: 88%; margin: 9px 0; padding: 12px 14px; border-radius: 18px; line-height: 1.45; white-space: pre-wrap; box-shadow: 0 4px 14px rgba(25,63,67,.06); }
.message.user { margin-left: auto; background: var(--brand); color: white; border-bottom-right-radius: 5px; }
.message.mira { background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.message .meta { display: block; font-size: .68rem; opacity: .7; margin-top: 6px; }
.sources { margin: 7px 0 13px; padding-left: 12px; font-size: .85rem; }
.sources a { color: var(--brand-dark); display: block; margin: 5px 0; }
.action-link { display: inline-block; margin-top: 8px; padding: 9px 12px; border-radius: 10px; background: #e5f0ef; color: var(--brand-dark); text-decoration: none; font-weight: 750; }
.radio-panel { display: grid; grid-template-columns: 1fr minmax(100px, 180px) auto; align-items: center; gap: 10px; background: #fff5e8; border: 1px solid #f0d2ad; padding: 11px 12px; border-radius: 14px; margin-bottom: 12px; }
.radio-panel small, .radio-panel strong { display: block; }
.radio-panel small { color: #8b5c28; font-weight: 800; }
.radio-buttons { display: flex; gap: 6px; }
.small-play, .small-danger { border: 0; color: white; border-radius: 10px; padding: 9px 11px; }
.small-play { background: var(--brand); }
.small-danger { background: var(--danger); }
.talk-area { text-align: center; }
.talk-btn { width: min(280px, 78vw); aspect-ratio: 2.5 / 1; border: 0; border-radius: 999px; background: linear-gradient(145deg, var(--brand), var(--brand-dark)); color: white; box-shadow: 0 14px 30px rgba(33,86,91,.25); display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 4px auto 7px; transition: transform .15s ease, background .15s ease; }
.talk-btn:active { transform: scale(.98); }
.talk-btn.recording { background: linear-gradient(145deg, #b44848, #8d3030); animation: pulse 1.4s infinite; }
.talk-btn.busy { background: #7a8d90; }
.talk-btn .mic-icon { font-size: .8rem; margin-bottom: 2px; }
.talk-btn #talkLabel { font-size: 1.45rem; font-weight: 850; letter-spacing: .04em; }
.talk-btn small { opacity: .85; }
#recordHint { color: var(--muted); font-size: .82rem; margin: 0 0 12px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 15px rgba(180,72,72,.10); } }
.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.quick-actions button, .station-grid button { border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 11px 8px; border-radius: 12px; font-weight: 700; }
.text-entry { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }
.text-entry input, .memory-form input { min-width: 0; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 13px; font-size: 1rem; }
.text-entry button, .memory-form button { border: 0; border-radius: 12px; padding: 0 16px; background: var(--brand); color: white; font-weight: 800; }
.settings { margin-top: 12px; background: rgba(255,255,255,.65); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.settings summary { font-weight: 800; cursor: pointer; }
.settings label { display: block; margin-top: 12px; color: var(--muted); font-size: .85rem; }
.settings select { width: 100%; margin-top: 5px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: white; }
.station-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.privacy { color: var(--muted); font-size: .78rem; line-height: 1.4; }
dialog { width: min(620px, calc(100% - 24px)); border: 0; border-radius: 18px; padding: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(15,35,38,.45); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; }
.dialog-head h2 { margin: 0; }
.memory-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 14px 0; }
.memory-list { max-height: 48vh; overflow-y: auto; }
.memory-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.memory-item button { border: 0; background: #f3dede; color: var(--danger); border-radius: 9px; padding: 7px 9px; }
.danger-outline { width: 100%; margin-top: 14px; border: 1px solid var(--danger); background: white; color: var(--danger); border-radius: 10px; padding: 10px; font-weight: 750; }
@media (max-width: 480px) {
  .app-shell { padding: 12px 10px 26px; }
  .transcript { max-height: 42vh; }
  .radio-panel { grid-template-columns: 1fr auto; }
  .radio-panel input { grid-column: 1 / -1; width: 100%; }
  .station-grid { grid-template-columns: repeat(2, 1fr); }
}
.status-dot.warning { background: #c29b42; box-shadow: 0 0 0 5px rgba(194,155,66,.15); }
.secondary-btn { width: 100%; margin-top: 10px; border: 1px solid var(--brand); background: white; color: var(--brand-dark); border-radius: 10px; padding: 10px; font-weight: 750; }
.token-form { display: grid; gap: 10px; margin-top: 14px; }
.token-form label { font-weight: 750; }
.token-form input { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 13px; }
.token-form button { border: 0; border-radius: 12px; padding: 12px 16px; background: var(--brand); color: white; font-weight: 800; }
.dialog-head p { margin: 6px 0 0; color: var(--muted); }
.form-error { color: var(--danger); font-weight: 700; }
