/* TNGN AI: dark newsroom look, blue + gold of the network's logo */
:root {
  --bg: #070b14;
  --surface: #0e1526;
  --surface-2: #151f36;
  --border: #22304d;
  --fg: #e9eef8;
  --muted: #93a1bd;
  --subtle: #64728f;
  --brand: #2f74ff;
  --brand-2: #5aa2ff;
  --gold: #f2b93b;
  --live: #ff4d5e;
  --ok: #2fd17c;
  --radius: 18px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f7fc; --surface: #ffffff; --surface-2: #eef2fa; --border: #d9e0ee;
    --fg: #121a2c; --muted: #51607d; --subtle: #8190ad; --brand: #1d5fe6; --brand-2: #1d5fe6;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(900px 500px at 10% -10%, color-mix(in oklab, var(--brand) 18%, transparent), transparent 60%),
              radial-gradient(700px 400px at 100% 0%, color-mix(in oklab, var(--gold) 9%, transparent), transparent 60%), var(--bg);
  color: var(--fg); font: 16px/1.6 var(--font); display: flex; flex-direction: column; min-height: 100dvh;
}
button, select, textarea, input { font: inherit; color: inherit; }
a { color: var(--brand-2); }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* header */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-left)); background: color-mix(in oklab, var(--bg) 82%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid color-mix(in oklab, var(--border) 60%, transparent); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 19px; letter-spacing: .04em; }
.brand-text em { font-style: normal; color: var(--gold); }
.brand-text small { color: var(--subtle); font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); margin-right: 6px; }
.status i { width: 8px; height: 8px; border-radius: 50%; background: var(--subtle); }
.status.ok i { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.status.wait i { background: var(--gold); animation: pulse 1.4s infinite; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; border: 1px solid transparent; background: none; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--fg); }
.icon-btn[aria-pressed="true"] { color: var(--gold); background: color-mix(in oklab, var(--gold) 14%, transparent); }
.icon-btn[aria-pressed="false"] .wave { opacity: .25; }

/* chat */
.chat { flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 24px 16px 12px; display: flex; flex-direction: column; gap: 18px; }
.hero { margin: auto 0; text-align: center; padding: 24px 0 8px; }
.hero h1 { font-size: clamp(26px, 5vw, 38px); line-height: 1.15; margin: 22px 0 8px; letter-spacing: -.01em; }
.hero h1 span { background: linear-gradient(90deg, var(--brand-2), var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--muted); max-width: 560px; margin: 0 auto 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chips button { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 9px 15px; cursor: pointer; font-size: 14.5px; color: var(--muted); }
.chips button:hover { border-color: var(--brand); color: var(--fg); }

.orb { position: relative; width: 112px; height: 112px; border-radius: 50%; border: 0; cursor: pointer; color: #fff;
  background: radial-gradient(circle at 35% 30%, #6aa6ff, var(--brand) 45%, #0b3fa8); box-shadow: 0 18px 60px -12px color-mix(in oklab, var(--brand) 70%, transparent); }
.orb svg { width: 42px; height: 42px; position: relative; }
.orb-ring { position: absolute; inset: -10px; border-radius: 50%; border: 2px solid color-mix(in oklab, var(--brand) 45%, transparent); animation: ring 2.8s infinite; }
.orb-ring.r2 { animation-delay: 1.4s; }
.orb.listening { background: radial-gradient(circle at 35% 30%, #ff8a96, var(--live) 50%, #a3122a); }

.msg { display: flex; gap: 12px; align-items: flex-start; animation: rise .25s ease-out; }
.msg.user { justify-content: flex-end; }
.msg .bubble { max-width: min(680px, 86%); padding: 12px 16px; border-radius: var(--radius); }
.msg.user .bubble { background: linear-gradient(135deg, var(--brand), #1b4fc7); color: #fff; border-bottom-right-radius: 6px; white-space: pre-wrap; }
.msg.ai .bubble { background: var(--surface); border: 1px solid var(--border); border-top-left-radius: 6px; }
.msg.ai .avatar { width: 34px; height: 34px; flex: none; margin-top: 2px; }
.bubble p { margin: 0 0 .7em; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: .2em 0 .8em; padding-left: 1.3em; }
.bubble sup a { text-decoration: none; font-size: 11px; font-weight: 700; padding: 1px 5px; border-radius: 6px; background: color-mix(in oklab, var(--brand) 22%, transparent); }
.typing { display: inline-flex; gap: 5px; padding: 4px 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
.wait-note { color: var(--subtle); font-size: 13.5px; margin-left: 6px; }
.err { color: var(--live); }

.sources { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.sources a { display: flex; gap: 8px; align-items: baseline; max-width: 100%; text-decoration: none; color: var(--fg); font-size: 13.5px;
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: 7px 11px; }
.sources a:hover { border-color: var(--brand); }
.sources b { color: var(--brand-2); flex: none; }
.sources span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch; }
.sources small { color: var(--subtle); flex: none; }
.msg-tools { display: flex; gap: 4px; margin-top: 8px; }
.msg-tools button { border: 0; background: none; color: var(--subtle); cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 8px; }
.msg-tools button:hover { background: var(--surface-2); color: var(--fg); }
.msg-tools svg { width: 16px; height: 16px; }

/* composer */
.composer-wrap { position: sticky; bottom: 0; padding: 10px 16px max(14px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }
.composer, .convo, .fine, .live { max-width: 860px; margin-left: auto; margin-right: auto; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px; border-radius: 22px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 14px 40px -20px rgba(0, 0, 0, .6); }
.composer:focus-within { border-color: color-mix(in oklab, var(--brand) 70%, var(--border)); }
.composer textarea { flex: 1; resize: none; border: 0; outline: 0; background: none; padding: 10px 4px; max-height: 180px; line-height: 1.45; }
.mic, .send { position: relative; flex: none; width: 46px; height: 46px; border-radius: 15px; border: 0; cursor: pointer; display: grid; place-items: center; }
.mic { background: var(--surface-2); color: var(--fg); overflow: hidden; }
.mic svg, .send svg { position: relative; z-index: 1; }
.mic .level { position: absolute; inset: auto 0 0 0; height: 0; background: color-mix(in oklab, var(--live) 45%, transparent); transition: height .08s; }
.mic[aria-pressed="true"] { background: var(--live); color: #fff; }
.send { background: var(--brand); color: #fff; }
.send:disabled { opacity: .45; cursor: default; }
.send .i-stop { display: none; } .send.stop .i-stop { display: block; } .send.stop .i-send { display: none; }
.live { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; padding: 8px 14px; border-radius: 14px; font-size: 14.5px; color: var(--muted);
  background: color-mix(in oklab, var(--live) 10%, var(--surface)); border: 1px solid color-mix(in oklab, var(--live) 30%, var(--border)); }
.live .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--live); flex: none; animation: pulse 1s infinite; }
.live.speaking { color: var(--fg); }
.live.processing .dot { background: var(--gold); }
.live.answering { color: var(--fg); background: color-mix(in oklab, var(--brand) 12%, var(--surface)); border-color: color-mix(in oklab, var(--brand) 35%, var(--border)); }
.live.answering .dot { background: var(--brand-2); }
#liveText { flex: 1; min-width: 0; }
.live-btn { flex: none; border: 1px solid var(--border); background: var(--surface); color: var(--fg); border-radius: 999px; padding: 5px 14px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.live-btn:hover { border-color: var(--live); color: var(--live); }
.convo { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; font-size: 14px; color: var(--muted); cursor: pointer; }
.convo small { color: var(--subtle); }
.convo input { accent-color: var(--brand); width: 17px; height: 17px; }
.fine { margin-top: 6px; font-size: 12px; color: var(--subtle); }

/* settings */
.settings { border: 1px solid var(--border); border-radius: 18px; background: var(--surface); color: var(--fg); padding: 22px; width: min(380px, calc(100vw - 32px)); }
.settings::backdrop { background: rgba(0, 0, 0, .55); }
.settings h2 { margin: 0 0 14px; font-size: 19px; }
.settings label { display: grid; gap: 6px; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
.settings .check { display: flex; align-items: flex-start; gap: 10px; color: var(--fg); }
.settings .check input { accent-color: var(--brand); width: 17px; height: 17px; margin-top: 3px; }
.settings .check small { display: block; color: var(--subtle); font-size: 12.5px; }
.settings select { padding: 9px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.settings .ghost, .settings menu button { width: 100%; padding: 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; margin-bottom: 8px; }
.settings menu { padding: 0; margin: 8px 0 0; }
.settings menu button { background: var(--brand); border-color: var(--brand); color: #fff; }

@keyframes ring { from { transform: scale(.9); opacity: .9; } to { transform: scale(1.35); opacity: 0; } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes blink { 50% { opacity: .2; } }
@keyframes rise { from { transform: translateY(6px); opacity: 0; } }
@media (max-width: 560px) {
  .brand-text small, .status span, .convo small { display: none; }
  .msg .bubble { max-width: 92%; }
  .orb { width: 96px; height: 96px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
