:root {
  --bg: #f6f7f9; --surface: #fff; --text: #14181f; --muted: #667085; --line: #e4e7ec;
  --brand: #0f766e; --brand-ink: #fff; --user: #0f766e; --user-ink: #fff; --bot: #eef1f4; --err: #b42318;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116; --surface: #161b22; --text: #e8ecf1; --muted: #8b95a5; --line: #262d38;
    --brand: #2dd4bf; --brand-ink: #04211e; --user: #115e59; --user-ink: #fff; --bot: #1d242e; --err: #f97066;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, "Segoe UI", Roboto, sans-serif; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); font-size: .9rem; }

.logo { width: 44px; height: 44px; border-radius: 12px; background: var(--brand); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 1.3rem; }
.logo.sm { width: 28px; height: 28px; border-radius: 8px; font-size: .95rem; }

/* Đăng nhập */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(900px 500px at 15% -10%, color-mix(in srgb, var(--brand) 18%, transparent), transparent), var(--bg); }
.login-shell { width: 100%; max-width: 820px; display: grid; grid-template-columns: 1fr 1fr; background: var(--surface);
  border: 1px solid var(--line); border-radius: 20px; overflow: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.12); }
.login-side { padding: 36px 30px; background: linear-gradient(160deg, var(--brand), color-mix(in srgb, var(--brand) 55%, #000));
  color: var(--brand-ink); display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.login-side .logo { background: rgba(255,255,255,.18); color: inherit; }
.login-side h2 { margin: 6px 0 0; font-size: 1.4rem; line-height: 1.25; }
.login-side ul { margin: 0; padding-left: 18px; display: grid; gap: 8px; opacity: .92; font-size: .95rem; }
.login-form { padding: 36px 30px; display: grid; gap: 12px; align-content: center; }
.login-form h1 { margin: 0; font-size: 1.5rem; }
.login-form p { margin: 0; }
.small { font-size: .8rem; }
.pw { position: relative; display: block; }
.pw input { width: 100%; padding-right: 44px; }
.eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: transparent; border: 0; font-size: 1.05rem; padding: 6px 9px; opacity: .65; }
.eye[aria-pressed="true"] { opacity: 1; }
.warn { color: #b54708; font-size: .85rem; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); }
@media (max-width: 700px) { .login-shell { grid-template-columns: 1fr; } .login-side { display: none; } .login-form { padding: 28px 22px; } }
label { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }
input { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; color: var(--text); }
input:focus-visible, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.err { color: var(--err); min-height: 1.4em; font-size: .9rem; }
.primary { background: var(--brand); color: var(--brand-ink); border: 0; border-radius: 10px; padding: 11px 18px; font-weight: 600; }
.primary:disabled { opacity: .55; cursor: default; }

/* Chat */
.app { height: 100%; max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; background: var(--surface);
  border-inline: 1px solid var(--line); }
header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; }
.tools { display: flex; align-items: center; gap: 6px; }
.ghost { background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; }
.ghost[aria-pressed="false"] { opacity: .5; }
.heli-btn[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); opacity: 1; }
.heli-status { padding: 8px 16px; font-size: .9rem; color: var(--muted); border-top: 1px solid var(--line); background: var(--bg); }
.heli-status[data-mode="awake"] { color: var(--brand); font-weight: 600; }
.heli-status[data-mode="busy"] { font-style: italic; }
.log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--user); color: var(--user-ink); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--bot); border-bottom-left-radius: 4px; }
.msg.err { color: var(--err); }
.msg.typing { color: var(--muted); font-style: italic; }
.hint { margin: auto; text-align: center; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.chip { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: .9rem; }
.chip:hover { border-color: var(--brand); }

.composer { display: flex; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.composer input { flex: 1; min-width: 0; }
.mic { width: 46px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-size: 1.2rem; }
.mic.rec { background: var(--err); border-color: var(--err); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .mic.rec { animation: none; } }
@media (max-width: 520px) { #who { display: none; } }
