:root {
  color-scheme: dark;
  --bg: #262932; --well: #1f2229; --plate: #2d313b;
  --fg: #d4d8e6; --muted: #9aa3bb;
  --accent: #6a7af5; --green: #24a870; --danger: #c4483c;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#banner { position: fixed; z-index: 5; left: 0; right: 0; top: 0; padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: var(--danger); color: #fff; font-size: 14px; text-align: center; }

#login { min-height: 100%; max-width: 360px; margin: 0 auto; display: flex; flex-direction: column; justify-content: center; gap: 12px;
  padding: 24px max(24px, env(safe-area-inset-right)) 24px max(24px, env(safe-area-inset-left)); text-align: center; }
#login img { align-self: center; border-radius: 26px; }
#login h1 { margin: 4px 0 12px; font-size: 26px; }
#login input { padding: 14px 16px; border: 0; border-radius: 16px; background: var(--well); }
#login .primary { padding: 14px; border-radius: 16px; font-weight: 600; }
#loginError { min-height: 1.4em; margin: 0; color: #ff9c90; font-size: 14px; }

#app { height: 100%; height: 100dvh; display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 8px) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left)); background: var(--plate); }
header img { border-radius: 12px; }
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.who span { color: var(--muted); font-size: 13px; }
.ghost { padding: 8px 12px; border-radius: 12px; background: none; color: var(--muted); font-size: 14px; }

#feed { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; gap: 10px;
  padding: 14px max(12px, env(safe-area-inset-right)) 14px max(12px, env(safe-area-inset-left)); }
.msg { max-width: min(82%, 640px); padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.msg.zh { align-self: flex-start; background: var(--plate); border-bottom-left-radius: 6px; }
.msg.typing { color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { padding: 8px 14px; border-radius: 16px; background: var(--well); color: var(--fg); font-size: 15px; }
.chip.say { padding: 6px 10px; }
.card { display: block; width: 100%; text-align: left; padding: 10px 12px; margin-top: 10px; border-radius: 14px; background: var(--well); color: var(--fg); }
.card small { display: block; color: var(--muted); }

#pending { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 14px 0; color: var(--muted); font-size: 14px; }
footer { display: flex; align-items: flex-end; gap: 8px;
  padding: 8px max(10px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 8px) max(10px, env(safe-area-inset-left)); background: var(--plate); }
#input { flex: 1; min-width: 0; max-height: 40vh; padding: 11px 14px; border: 0; border-radius: 20px; resize: none; background: var(--well); }
.round { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--well); font-size: 20px; line-height: 1; }
.primary { background: var(--accent); color: #fff; }
#mic.rec { background: var(--green); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(36, 168, 112, .25); } }
@media (prefers-reduced-motion: reduce) { #mic.rec { animation: none; } }
