:root {
  --paper: #ffffff;
  --mist: #f3f4f8;      /* soft surfaces: your messages, inputs, buttons */
  --line: #e7e8ef;
  --ink: #1b1d2a;       /* main text */
  --ink-2: #4b4f63;     /* secondary text */
  --muted: #8a8fa3;     /* times, hints */
  --sky: #7cc4ff;      /* light blue */
  --azure: #3b82f6;    /* main blue */
  --royal: #1d4ed8;    /* deep blue */
  --cyan: #22c3ee;     /* bright accent blue */
  --ok: #1fb57a;
  --danger: #e5484d;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Figtree', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--azure);
  outline-offset: 3px;
}
[hidden] { display: none !important; }

.screen {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(14px + var(--safe-t)) 20px calc(10px + var(--safe-b));
}

/* ── Welcome ── */
.welcome { justify-content: flex-end; padding-bottom: calc(40px + var(--safe-b)); }
.welcome-art { position: absolute; inset: 0 0 auto 0; height: 46vh; pointer-events: none; }
.welcome-art canvas { width: 100%; height: 100%; display: block; }
.welcome-copy { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.welcome-mark { width: 52px; height: 52px; border-radius: 16px; }
.welcome h1 {
  margin: 0;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 650;
  font-size: 56px;
  line-height: 1;
  letter-spacing: -0.03em;
}
.lede { margin: 0; color: var(--ink-2); font-size: 18px; max-width: 30ch; }
.fine { margin: 0; color: var(--muted); font-size: 13px; max-width: 34ch; }
.note { margin: 0; padding: 10px 14px; border-radius: 12px; background: #eef4ff; color: var(--royal); font-size: 14px; max-width: 36ch; }
.legal { display: flex; gap: 18px; font-size: 13px; }
.legal a { color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.legal a:hover { color: var(--ink); text-decoration-color: currentColor; }
.sheet-legal { justify-content: center; margin-top: 16px; }
.btn-ghost:disabled { opacity: 0.6; cursor: default; }
.warning { margin: 0; padding: 10px 14px; border-radius: 12px; background: #fff1f2; color: #b4232a; font-size: 14px; }
.btn-primary {
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 6px;
  background: var(--royal); color: #fff; text-decoration: none;
  font-weight: 600; padding: 15px 22px; border-radius: 999px;
}
.btn-primary svg { width: 18px; height: 18px; }

/* ── Header ── */
.header { display: flex; align-items: center; gap: 12px; padding: 4px 0 12px; }
.avatar { width: 44px; height: 44px; border-radius: 14px; flex: none; }
.hello { flex: 1; min-width: 0; }
.hello-line {
  margin: 0;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 22px; line-height: 1.15; font-weight: 500; letter-spacing: -0.02em; color: var(--ink-2);
}
.hello-line strong { font-weight: 650; color: var(--ink); }
.status { margin: 2px 0 0; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.status-dot.off { background: var(--muted); }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--paper); border: 1px solid var(--line);
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--ink-2); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ── Transcript ── */
.transcript {
  flex: 1; overflow-y: auto; padding: 12px 0 8px;
  display: flex; flex-direction: column; gap: 18px;
  scroll-behavior: smooth;
  mask-image: linear-gradient(to bottom, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%);
}
.empty { margin: auto 0; }
.empty-lead {
  margin: 0 0 16px;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 30px; line-height: 1.12; font-weight: 650; letter-spacing: -0.025em;
  max-width: 14ch;
}
.suggestions { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.suggestions button {
  background: none; border: 0; padding: 8px 0; text-align: left;
  font-size: 17px; color: var(--ink-2);
  border-bottom: 1px solid transparent;
}
.suggestions button:hover { color: var(--ink); border-bottom-color: var(--line); }

/* Your words: small pills on the right. Juno's words: large plain text. */
.msg { animation: rise 0.22s ease-out; }
.msg.user {
  align-self: flex-end; max-width: 82%;
  background: var(--mist); padding: 10px 14px; border-radius: 18px 18px 6px 18px;
  font-size: 15px; color: var(--ink-2);
}
.msg.bot { align-self: stretch; font-size: 20px; line-height: 1.45; letter-spacing: -0.005em; padding-right: 8px; }
.msg.bot.error { color: var(--danger); font-size: 17px; }
.msg time { display: block; margin-top: 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.msg.user time { text-align: right; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { font-size: 12px; font-weight: 500; color: var(--ink-2); background: var(--mist); border-radius: 999px; padding: 3px 10px; }
.chip.fail { color: var(--danger); background: #fff1f2; }
.typing { display: flex; gap: 6px; padding: 6px 0; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--royal); opacity: 0.3; animation: blink 1.1s infinite; }
.typing i:nth-child(2) { background: var(--azure); animation-delay: 0.15s; }
.typing i:nth-child(3) { background: var(--sky); animation-delay: 0.3s; }

/* ── Dock: wave + controls ── */
.dock { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.live { min-height: 24px; margin: 0; color: var(--ink-2); text-align: center; font-size: 16px; padding: 0 8px; }
.wave { width: 100%; height: 96px; display: block; }

.controls { display: grid; grid-template-columns: 56px 84px 56px; justify-content: center; align-items: center; gap: 36px; margin-top: 2px; }
.ctl {
  width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--paper); display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(27, 29, 42, 0.07);
  transition: opacity 0.2s, transform 0.15s;
}
.ctl svg { width: 22px; height: 22px; fill: none; stroke: var(--ink-2); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ctl svg .fill { fill: var(--royal); stroke: none; }
.ctl:disabled { opacity: 0.35; cursor: default; box-shadow: none; }
.ctl:disabled svg .fill { fill: var(--muted); }
.ctl[aria-pressed='true'] { background: var(--mist); }
.ctl:not(:disabled):active { transform: scale(0.94); }

.mic {
  position: relative; width: 84px; height: 84px; border-radius: 50%; border: 0;
  display: grid; place-items: center; color: #fff;
  background: radial-gradient(circle at 32% 26%, #b9e2ff 0%, var(--sky) 22%, var(--azure) 58%, var(--royal) 100%);
  box-shadow: 0 14px 34px rgba(37, 99, 235, 0.32);
  transition: transform 0.15s;
}
.mic svg { width: 30px; height: 30px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; position: relative; z-index: 1; }
.mic:active { transform: scale(0.95); }
.mic-ring { position: absolute; inset: -6px; border-radius: 50%; border: 2px solid transparent; }
.mic[data-state='listening'] .mic-ring { border-color: rgba(59, 130, 246, 0.45); animation: ripple 1.5s ease-out infinite; }
.mic[data-state='thinking'] .mic-ring { border-top-color: var(--royal); border-right-color: var(--cyan); animation: spin 0.9s linear infinite; }
.mic[data-state='speaking'] { box-shadow: 0 14px 40px rgba(34, 195, 238, 0.4); }
.state-label { margin: 4px 0 2px; color: var(--muted); font-size: 13px; font-weight: 500; }

.text-form {
  width: 100%; display: flex; gap: 8px; align-items: center;
  background: var(--mist); border-radius: 999px; padding: 6px 6px 6px 18px; margin-bottom: 6px;
}
.text-form input { flex: 1; background: transparent; border: 0; outline: none; font-size: 16px; min-width: 0; }
.text-form input::placeholder { color: var(--muted); }
.text-form button { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--azure); color: #fff; display: grid; place-items: center; }
.text-form button svg { width: 17px; height: 17px; }

/* ── Settings sheet ── */
.sheet { position: fixed; inset: 0; z-index: 10; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(27, 29, 42, 0.28); animation: fade 0.2s; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 520px; margin: 0 auto;
  background: var(--paper); border-radius: 26px 26px 0 0; padding: 10px 22px calc(26px + var(--safe-b));
  box-shadow: 0 -10px 40px rgba(27, 29, 42, 0.12);
  animation: slide 0.25s ease-out;
}
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 14px; }
.sheet h2 { margin: 0 0 14px; font-family: 'Bricolage Grotesque', sans-serif; font-size: 24px; font-weight: 650; letter-spacing: -0.02em; }
.info { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0 0 14px; font-size: 14px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; text-align: right; overflow-wrap: anywhere; color: var(--ink-2); }
.field { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 0; border-top: 1px solid var(--line); font-size: 15px; }
.field select { background: var(--mist); border: 0; border-radius: 10px; padding: 8px 10px; max-width: 62%; text-overflow: ellipsis; }
.field input[type='range'] { accent-color: var(--azure); width: 46%; }
.switch { appearance: none; width: 44px; height: 26px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background 0.2s; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); transition: transform 0.2s; }
.switch:checked { background: var(--azure); }
.switch:checked::after { transform: translateX(18px); }
.sheet-actions { display: grid; gap: 8px; margin-top: 10px; }
.btn-ghost { background: var(--mist); border: 0; padding: 13px; border-radius: 14px; font-weight: 600; }
.btn-ghost.danger { color: var(--danger); }

@keyframes ripple { 0% { transform: scale(0.95); opacity: 1; } 100% { transform: scale(1.3); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateY(100%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
@media (max-height: 700px) {
  .wave { height: 70px; }
  .msg.bot { font-size: 18px; }
}

/* ── Privacy policy and terms pages ── */
body.doc { overflow: auto; }
.doc-body { max-width: 680px; margin: 0 auto; padding: 32px 20px 80px; font-size: 16px; line-height: 1.65; color: var(--ink-2); }
.doc-home { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: 'Bricolage Grotesque', sans-serif; font-weight: 650; font-size: 20px; }
.doc-home img { border-radius: 10px; }
.doc-body h1 { margin: 36px 0 4px; font-family: 'Bricolage Grotesque', sans-serif; font-weight: 650; font-size: 40px; line-height: 1.1; letter-spacing: -0.025em; color: var(--ink); }
.doc-meta { margin: 0 0 28px; color: var(--muted); font-size: 14px; }
.doc-body h2 { margin: 36px 0 8px; font-family: 'Bricolage Grotesque', sans-serif; font-weight: 650; font-size: 22px; letter-spacing: -0.015em; color: var(--ink); }
.doc-body p, .doc-body li { max-width: 68ch; }
.doc-body ul { padding-left: 20px; }
.doc-body li { margin: 6px 0; }
.doc-body strong { color: var(--ink); font-weight: 600; }
.doc-body a { color: var(--royal); text-underline-offset: 3px; }
