/* Aria — responsive UI (mobile first: phone → tablet ≥720px → desktop ≥1100px) */
:root {
  --bg: #0a0f1f;
  --surface: rgba(19, 25, 50, .72);
  --surface-2: rgba(255, 255, 255, .045);
  --surface-3: rgba(255, 255, 255, .08);
  --line: rgba(160, 172, 255, .14);
  --line-strong: rgba(160, 172, 255, .3);
  --text: #eef0ff;
  --muted: #a0a8cc;
  --faint: #7d86ad;
  --teal: #5eead4;
  --indigo: #818cf8;
  --violet: #c084fc;
  --rose: #f43f5e;
  --danger: #fb7185;
  --grad: linear-gradient(135deg, var(--teal), var(--indigo) 55%, var(--violet));
  --me: linear-gradient(135deg, #5b54f0, #8b45f5);
  --r-lg: 24px;
  --r-md: 16px;
  --shadow: 0 24px 70px rgba(2, 5, 20, .55);
  --level: 0;
  --mouth: 0;
  --avatar: 76px;
  font-family: "Plus Jakarta Sans", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; flex: none; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

/* ---------- background ---------- */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background:
  radial-gradient(1200px 600px at 15% -10%, rgba(79, 70, 229, .35), transparent 60%),
  radial-gradient(900px 500px at 110% 110%, rgba(13, 148, 136, .28), transparent 60%), var(--bg); }
.orb { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .35; animation: drift 24s ease-in-out infinite alternate; }
.o1 { width: 46vmax; height: 46vmax; background: #3730a3; top: -18vmax; left: -14vmax; }
.o2 { width: 40vmax; height: 40vmax; background: #0f766e; bottom: -20vmax; right: -12vmax; animation-delay: -8s; }
.o3 { width: 28vmax; height: 28vmax; background: #7e22ce; top: 38%; left: 42%; opacity: .18; animation-delay: -14s; }
@keyframes drift { to { transform: translate(4vmax, 3vmax) scale(1.08); } }

/* ---------- app shell ---------- */
.app {
  height: 100vh; height: 100dvh; display: flex; flex-direction: column;
  max-width: 1360px; margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 30px; height: 30px; border-radius: 9px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 16px; font-weight: 800; letter-spacing: .2px; }
.brand-text span { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.badge svg { width: 13px; height: 13px; fill: none; stroke: var(--teal); stroke-width: 2.2; stroke-linecap: round; }
.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; min-width: 34px; padding: 0 10px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); font-size: 13px; font-weight: 600;
  transition: background .2s, border-color .2s;
}
.btn-ghost:hover { background: var(--surface-3); border-color: var(--line-strong); }
.btn-ghost svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.btn-ghost .lbl { display: none; }

/* ---------- layout ---------- */
.layout { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 0 12px; }

/* ---------- stage (phone: compact horizontal strip) ---------- */
.stage { flex: none; }
.stage-card {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.avatar-wrap { --size: var(--avatar); position: relative; width: var(--size); height: var(--size); flex: none; display: grid; place-items: center; }
.avatar-btn { all: unset; position: relative; z-index: 2; width: 100%; height: 100%; border-radius: 50%; cursor: default; }
body[data-state="speaking"] .avatar-btn { cursor: pointer; }
.avatar { width: 100%; height: 100%; border-radius: 50%; box-shadow: 0 12px 40px rgba(5, 8, 30, .6); }
.status-dot {
  position: absolute; z-index: 3; right: 4%; bottom: 6%; width: calc(var(--size) * .16); height: calc(var(--size) * .16);
  min-width: 11px; min-height: 11px; max-width: 22px; max-height: 22px; border-radius: 50%;
  background: #22c55e; border: 2px solid #111733; transition: background .3s;
}
body[data-state="listening"] .status-dot { background: var(--rose); }
body[data-state="thinking"] .status-dot { background: #f59e0b; }
body[data-state="speaking"] .status-dot { background: var(--indigo); }
body[data-state="error"] .status-dot { background: var(--danger); }

.halo {
  position: absolute; inset: -9%; z-index: 1; border-radius: 50%;
  background: conic-gradient(from 0deg, var(--teal), var(--indigo), var(--violet), var(--teal));
  filter: blur(calc(var(--size) * .06)); opacity: .32;
  transform: scale(calc(1 + var(--level) * .12)); transition: opacity .4s, transform .08s linear;
  animation: spin 14s linear infinite;
}
body[data-state="listening"] .halo { opacity: .85; }
body[data-state="speaking"] .halo { opacity: .6; transform: scale(calc(1 + var(--mouth) * .06)); }
body[data-state="thinking"] .halo { opacity: .5; animation-duration: 3s; }
body[data-state="error"] .halo { background: conic-gradient(var(--danger), #f59e0b, var(--danger)); opacity: .45; }
@keyframes spin { to { rotate: 360deg; } }

.orbit { position: absolute; inset: 0; z-index: 3; opacity: 0; transition: opacity .3s; pointer-events: none; animation: spin 2.4s linear infinite; }
.orbit i {
  position: absolute; top: 50%; left: 50%; width: calc(var(--size) * .045); height: calc(var(--size) * .045);
  min-width: 6px; min-height: 6px; max-width: 12px; max-height: 12px; border-radius: 50%;
  background: var(--c, var(--teal)); box-shadow: 0 0 12px var(--c, var(--teal));
  translate: -50% -50%; transform: rotate(var(--a, 0deg)) translateY(calc(var(--size) * -.56));
}
.orbit i:nth-child(2) { --a: 120deg; --c: var(--indigo); }
.orbit i:nth-child(3) { --a: 240deg; --c: var(--violet); }
body[data-state="thinking"] .orbit { opacity: 1; }

/* avatar parts */
.avatar .eye { transform-box: fill-box; transform-origin: center; animation: blink 5.5s infinite; }
.avatar .eye + .eye { animation-delay: .04s; }
@keyframes blink { 0%, 95%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.08); } }
.avatar .iris { transition: transform .5s ease; }
body[data-state="thinking"] .avatar .iris { transform: translate(4px, -4px); }
body[data-state="listening"] .avatar .iris { transform: translate(0, 1px) scale(1.06); }
.avatar .brows { transition: transform .4s ease; }
body[data-state="listening"] .avatar .brows { transform: translateY(-3px); }
body[data-state="thinking"] .avatar .brows { transform: translateY(-2px); }
.avatar .mouth-open { transform-box: fill-box; transform-origin: center; transform: scaleY(calc(var(--mouth) * 1.15)); opacity: calc(var(--mouth) * 4); transition: transform .06s linear; }
body[data-state="speaking"] .avatar .mouth-smile { opacity: calc(1 - var(--mouth) * 3); }
body[data-state="listening"] .avatar .mic-dot { fill: var(--rose); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.stage-text { flex: 1; min-width: 0; }
.eyebrow { margin: 0 0 2px; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--teal); }
body[data-state="listening"] .eyebrow { color: #fda4af; }
body[data-state="thinking"] .eyebrow { color: #fcd34d; }
body[data-state="error"] .eyebrow { color: var(--danger); }
.state-label { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.1px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.caption { margin: 4px 0 0; font-size: 13px; color: var(--muted); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.caption:empty { display: none; }
body[data-state="speaking"] .caption { color: var(--text); }

.voice-row { display: none; flex-direction: column; align-items: center; gap: 8px; }
.mic {
  position: relative; width: 72px; height: 72px; border-radius: 50%; border: 0; background: var(--grad);
  box-shadow: 0 14px 40px rgba(129, 140, 248, .45); display: grid; place-items: center;
  transition: transform .15s, box-shadow .2s, background .2s;
}
.mic:hover { transform: translateY(-2px); box-shadow: 0 18px 46px rgba(129, 140, 248, .55); }
.mic:active { transform: scale(.96); }
.mic:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.mic svg, .mic-mini svg { fill: none; stroke: #0a0f1f; stroke-width: 2.2; stroke-linecap: round; }
.mic .i-stop, .mic-mini .i-stop { display: none; fill: #fff; stroke: none; }
.mic-ring { position: absolute; inset: -8px; border-radius: 50%; border: 2px solid rgba(244, 63, 94, .6); opacity: 0; transform: scale(calc(1 + var(--level) * .5)); pointer-events: none; }
body[data-state="listening"] .mic, body[data-state="listening"] .mic-mini { background: var(--rose); box-shadow: 0 12px 34px rgba(244, 63, 94, .45); }
body[data-state="listening"] .mic .i-mic, body[data-state="listening"] .mic-mini .i-mic { display: none; }
body[data-state="listening"] .mic .i-stop, body[data-state="listening"] .mic-mini .i-stop { display: block; }
body[data-state="listening"] .mic-ring { opacity: 1; }
.hint { margin: 0; font-size: 12px; color: var(--faint); text-align: center; }

/* ---------- chat ---------- */
.chat {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg) var(--r-lg) 0 0; border-bottom: 0;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); box-shadow: var(--shadow); overflow: hidden;
}
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.chat-head h2 { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: .1px; }
.head-controls { display: flex; align-items: center; gap: 8px; }
.pill-select {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 26px 0 10px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); cursor: pointer;
}
.pill-select svg { width: 15px; height: 15px; fill: none; stroke: var(--teal); stroke-width: 1.8; }
.pill-select::after { content: ""; position: absolute; right: 11px; top: 50%; width: 6px; height: 6px; border-right: 1.6px solid var(--muted); border-bottom: 1.6px solid var(--muted); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.pill-select select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; font-size: 13px; font-weight: 600; outline: none; cursor: pointer; padding: 0; }
.pill-select select option { background: #141a34; color: var(--text); }
.pill-select:focus-within { border-color: rgba(94, 234, 212, .6); }
.switch { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 10px 0 6px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; user-select: none; font-size: 13px; font-weight: 600; color: var(--muted); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.track { width: 34px; height: 20px; border-radius: 999px; background: rgba(255, 255, 255, .14); position: relative; transition: background .2s; }
.thumb { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.switch input:checked + .track { background: var(--indigo); }
.switch input:checked + .track .thumb { transform: translateX(14px); }
.switch input:checked ~ .switch-lbl { color: var(--text); }
.switch input:focus-visible + .track { outline: 2px solid var(--teal); outline-offset: 2px; }

.log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px 14px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.log::-webkit-scrollbar { width: 8px; }
.log::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 8px; }

.welcome { margin: auto 0; padding: 6px 2px; }
.welcome-face { width: 52px; height: 52px; border-radius: 50%; margin-bottom: 12px; box-shadow: 0 8px 24px rgba(5, 8, 30, .5); }
.welcome h1 { margin: 0 0 8px; font-size: clamp(22px, 5.5vw, 30px); line-height: 1.15; letter-spacing: -.6px; font-weight: 800; }
.welcome h1 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.welcome p { margin: 0 0 16px; color: var(--muted); font-size: 14px; max-width: 46ch; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2);
  font-size: 13px; font-weight: 500; text-align: left; transition: background .2s, border-color .2s, transform .15s;
}
.chips button:hover { background: rgba(129, 140, 248, .14); border-color: rgba(129, 140, 248, .5); transform: translateY(-1px); }

.row { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; animation: rise .25s ease; }
.row.me { justify-content: flex-end; }
.row .face { width: 28px; height: 28px; border-radius: 50%; flex: none; box-shadow: 0 4px 12px rgba(5, 8, 30, .5); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.msg { max-width: min(88%, 620px); padding: 11px 14px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.6; }
.msg.me { background: var(--me); border-bottom-right-radius: 6px; box-shadow: 0 8px 24px rgba(91, 84, 240, .25); }
.msg.bot { background: rgba(255, 255, 255, .055); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.err { border-color: rgba(251, 113, 133, .5); color: #fecdd3; background: rgba(251, 113, 133, .08); }
.msg .meta { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.src { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: rgba(94, 234, 212, .1); color: var(--teal); border: 1px solid rgba(94, 234, 212, .25); }
.src.general { background: rgba(245, 158, 11, .12); color: #fcd34d; border-color: rgba(245, 158, 11, .35); }
.src.outside { background: rgba(148, 163, 184, .12); color: #cbd5e1; border-color: rgba(148, 163, 184, .35); }
.src.verify { background: rgba(56, 189, 248, .1); color: #7dd3fc; border-color: rgba(56, 189, 248, .35); }
.replay { all: unset; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); }
.replay:hover { color: var(--text); border-color: var(--line-strong); }
.replay.nudge { color: #0a0f1f; background: #5eead4; border-color: #5eead4; animation: nudge 1.2s ease-in-out 3; }
@keyframes nudge { 50% { transform: scale(1.08); } }
.voice-tag { font-size: 11px; opacity: .8; margin-right: 4px; }
.note { align-self: flex-start; margin: -6px 0 0 36px; font-size: 12px; color: var(--faint); }

/* "Did you know?" card shown while Aria is thinking */
.fact-card { width: min(88%, 520px); background: linear-gradient(135deg, rgba(94, 234, 212, .08), rgba(129, 140, 248, .1) 60%, rgba(192, 132, 252, .1)); border-color: rgba(129, 140, 248, .3); }
.fact-head { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--teal); }
.spark { font-size: 13px; animation: twinkle 1.6s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .35; transform: scale(.85); } }
.fact { margin: 6px 0 10px; font-size: 14px; line-height: 1.55; color: var(--text); min-height: 3.1em; }
.fact.in { animation: factIn .5s ease; }
@keyframes factIn { from { opacity: 0; transform: translateY(4px); } }
.fact-bar { height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.fact-bar i { display: block; width: 40%; height: 100%; border-radius: 3px; background: var(--grad); animation: slide 1.6s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-110%); } 100% { transform: translateX(260%); } }
.typing { display: inline-flex; flex-direction: column; gap: 6px; }
.typing .dots { display: inline-flex; gap: 5px; }
.typing .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bounce 1.2s infinite; }
.typing .dots i:nth-child(2) { animation-delay: .15s; }
.typing .dots i:nth-child(3) { animation-delay: .3s; }
.typing small { color: var(--muted); font-size: 12px; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

.composer { display: flex; align-items: center; gap: 8px; margin: 0 10px; padding: 6px; border: 1px solid var(--line); border-radius: 18px; background: rgba(8, 11, 26, .65); transition: border-color .2s, box-shadow .2s; }
.composer:focus-within { border-color: rgba(129, 140, 248, .65); box-shadow: 0 0 0 4px rgba(129, 140, 248, .12); }
.composer input { flex: 1; min-width: 0; height: 42px; padding: 0 6px; border: 0; background: transparent; outline: none; font-size: 15px; }
.composer input::placeholder { color: var(--faint); }
.mic-mini, .send { width: 42px; height: 42px; flex: none; border-radius: 13px; border: 0; display: grid; place-items: center; transition: background .2s, transform .15s, opacity .2s; }
.mic-mini { background: var(--grad); }
.send { background: var(--indigo); }
.send svg { fill: #fff; }
.send:hover { background: #6366f1; }
.mic-mini:active, .send:active { transform: scale(.94); }
.mic-mini:disabled, .send:disabled { opacity: .45; cursor: not-allowed; }
.foot { margin: 0; padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); font-size: 11px; color: var(--faint); text-align: center; line-height: 1.6; }
.foot .sep { opacity: .5; margin: 0 2px; }
.nowrap { white-space: nowrap; }
/* phones: keep the first two notes on one line and the Netcloud credit on its own line */
@media (max-width: 599px) {
  .foot .s2 { display: none; }
  .foot .brandline { display: block; }
}

/* ---------- small phones ---------- */
@media (max-width: 480px) {
  .brand-text span { display: none; } /* keep the privacy badge readable instead */
  .chat-head { justify-content: flex-end; padding: 8px 10px; }
  .chat-head h2 { display: none; }     /* room for language + Notes only + Voice */
  .head-controls { gap: 6px; }
  .switch { gap: 5px; padding: 0 8px 0 5px; font-size: 12px; }
  .track { width: 30px; height: 18px; }
  .thumb { width: 12px; height: 12px; }
  .switch input:checked + .track .thumb { transform: translateX(12px); }
  .pill-select { padding: 0 22px 0 8px; }
}
@media (max-width: 330px) {
  .badge span { display: none; }
  .badge { padding: 7px; }
  .pill-select svg { display: none; }
}

/* ---------- tablet ---------- */
@media (min-width: 720px) {
  :root { --avatar: 132px; }
  .top { padding: 16px 22px; }
  .brand img { width: 34px; height: 34px; }
  .btn-ghost .lbl { display: inline; }
  .btn-ghost { padding: 0 14px; }
  .layout { padding: 0 22px 18px; gap: 16px; }
  .stage-card { gap: 22px; padding: 18px 22px; }
  .state-label { font-size: 19px; }
  .caption { font-size: 14px; -webkit-line-clamp: 3; }
  .voice-row { display: flex; }
  .mic-mini { display: none; }
  .chat { border-radius: var(--r-lg); border-bottom: 1px solid var(--line); }
  .log { padding: 20px 20px; }
  .composer { margin: 0 14px; }
  .foot { padding-bottom: 12px; }
}

/* ---------- desktop ---------- */
@media (min-width: 1100px) {
  :root { --avatar: min(300px, 34vh); }
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(500px, 560px); gap: 28px; padding: 0 28px 24px; }
  .top { padding: 18px 28px; }
  .stage { display: flex; min-height: 0; }
  .stage-card {
    flex: 1; flex-direction: column; justify-content: center; text-align: center; gap: 18px;
    background: transparent; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; padding: 12px 24px;
  }
  .stage-text { flex: none; max-width: 520px; }
  .eyebrow { margin-bottom: 6px; }
  .state-label { font-size: clamp(20px, 1.8vw, 24px); -webkit-line-clamp: 3; }
  .caption { font-size: 15px; -webkit-line-clamp: 4; margin-top: 8px; }
  .voice-row { margin-top: 4px; }
  .mic { width: 80px; height: 80px; }
  .chat { height: 100%; }
}

/* short desktop windows */
@media (min-width: 1100px) and (max-height: 700px) {
  :root { --avatar: 200px; }
  .stage-card { gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
