/* ── Fonts (self-hosted, SIL Open Font License) ───────────── */
@font-face { font-family: "Onest"; src: url("/fonts/onest-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Onest"; src: url("/fonts/onest-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Onest"; src: url("/fonts/onest-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Unbounded"; src: url("/fonts/unbounded-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/fonts/jetbrains-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }

/* ── Themes ───────────────────────────────────────────────── */
:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg: #161618;
  --sidebar: #0F0F11;
  --surface: #222226;
  --surface-2: #2C2C31;
  --surface-3: #37373D;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .14);
  --text: #ECECEE;
  --muted: #A1A1AA;
  --faint: #6E6E78;
  --invert: #ECECEE;
  --invert-text: #111113;
  --accent: #9B8CFF;
  --accent-soft: rgba(140, 123, 255, .14);
  --accent-text: #BDB3FF;
  --menu: #26262B;
  --shadow: 0 12px 40px rgba(0, 0, 0, .45);
  --mark-line: rgba(255, 255, 255, .28);
  --code-bg: #0D0D0F;
  --danger: #FF8A8A;
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #FFFFFF;
  --sidebar: #F7F7F8;
  --surface: #F4F4F6;
  --surface-2: #ECECF0;
  --surface-3: #E1E1E7;
  --line: rgba(0, 0, 0, .08);
  --line-strong: rgba(0, 0, 0, .14);
  --text: #18181B;
  --muted: #61616B;
  --faint: #9A9AA3;
  --invert: #18181B;
  --invert-text: #FFFFFF;
  --accent: #6A57F0;
  --accent-soft: #EFECFF;
  --accent-text: #5543D6;
  --menu: #FFFFFF;
  --shadow: 0 12px 40px rgba(20, 20, 40, .14);
  --mark-line: rgba(0, 0, 0, .22);
  --code-bg: #111114;
  --danger: #D93A3A;
}
:root {
  --grad: linear-gradient(135deg, #8C7BFF 0%, #4FA3FF 55%, #3FD9C2 100%);
  --font-body: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-brand: "Unbounded", "Onest", system-ui, sans-serif;
  --font-code: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --sidebar-w: 264px;
  --column: 768px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.65 var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
.defs { position: absolute; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
::selection { background: rgba(140, 123, 255, .35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }
svg { flex: none; }

/* One style for all line icons */
.icon-btn svg, .side-btn svg, .side-search svg, .upgrade svg, .upgrade-pill svg, .round-action svg, .mode-btn svg,
.chip svg, .act svg, .to-latest svg, .voice-ctl svg, .chat-delete svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ── The Vela logo ────────────────────────────────────────── */
.mark { display: block; overflow: visible; }
.sail { fill: url(#vela-grad); stroke: url(#vela-grad); stroke-width: 2.5; stroke-linejoin: round; transform-box: fill-box; transform-origin: 50% 100%; }

/* While the AI is thinking, the sails ripple as if catching wind. */
.thinking .sail { animation: flutter 1.1s ease-in-out infinite; }
.thinking .sail-2 { animation-delay: .22s; }
@keyframes flutter {
  0%, 100% { opacity: .4; transform: scaleY(.92) skewX(-3deg); }
  45% { opacity: 1; transform: scaleY(1) skewX(0); }
}

/* On a new chat, the sails rise once. */
.hero-mark .sail { animation: sail-up .7s var(--ease) both; }
.hero-mark .sail-1 { animation-delay: .1s; }
.hero-mark .sail-2 { animation-delay: .25s; }
@keyframes sail-up { from { opacity: 0; transform: translateY(8px) scaleY(.6); } }

/* ── Shell ────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100dvh; }
.app.collapsed { grid-template-columns: 1fr; }
.app.collapsed .sidebar { display: none; }

.sidebar {
  display: flex; flex-direction: column;
  min-height: 0;
  padding: 10px 10px 12px;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 2px 2px 8px 8px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand .mark { width: 26px; height: 26px; }
.brand-name { font: 700 17px/1 var(--font-brand); letter-spacing: .01em; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 0; border-radius: 10px; background: none;
  color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.side-actions { display: grid; gap: 2px; margin-bottom: 14px; }
.side-btn, .side-search {
  display: flex; align-items: center; gap: 11px;
  width: 100%; height: 38px;
  padding: 0 10px;
  border: 0; border-radius: 10px; background: none;
  font-size: 14.5px; font-weight: 500;
  text-align: left;
}
.side-btn:hover, .side-search:hover, .side-search:focus-within { background: var(--surface-2); }
.side-btn svg, .side-search svg { width: 18px; height: 18px; color: var(--muted); }
.side-search input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: none; background: transparent;
  font-size: 14.5px; font-weight: 500;
}
.side-search input::placeholder { color: var(--text); opacity: 1; }
.side-search input:focus::placeholder { color: var(--faint); }
.side-search input::-webkit-search-cancel-button { filter: grayscale(1); }

.chat-list { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.chat-group + .chat-group { margin-top: 16px; }
.chat-group-label { margin: 0 10px 4px; font-size: 12.5px; font-weight: 500; color: var(--faint); }
.chat-item { position: relative; display: flex; align-items: center; border-radius: 10px; }
.chat-item:hover, .chat-item:focus-within { background: var(--surface); }
.chat-item[aria-current="true"] { background: var(--surface-2); }
.chat-open {
  flex: 1; min-width: 0; height: 36px;
  padding: 0 10px;
  border: 0; background: none;
  font-size: 14.5px; color: var(--text);
  text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-delete {
  flex: none; width: 28px; height: 28px; margin-right: 4px;
  display: grid; place-items: center;
  border: 0; border-radius: 7px; background: none;
  color: var(--muted); opacity: 0;
}
.chat-delete svg { width: 15px; height: 15px; }
.chat-item:hover .chat-delete, .chat-item:focus-within .chat-delete, .chat-item[aria-current="true"] .chat-delete { opacity: 1; }
.chat-delete:hover { color: var(--danger); background: var(--surface-3); }
.chat-list-empty { margin: 4px 10px; font-size: 14px; color: var(--faint); }

.sidebar-bottom { display: grid; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.plan-card { padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); }
.plan-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.plan-name { font-size: 14px; font-weight: 600; }
.plan-count { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meter { height: 5px; border-radius: 5px; background: var(--surface-2); overflow: hidden; margin-bottom: 12px; }
.meter-fill { height: 100%; width: 100%; border-radius: inherit; background: var(--grad); transition: width .45s var(--ease); }
.meter.low .meter-fill { background: var(--danger); }
.upgrade {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 38px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface);
  font-size: 14px; font-weight: 600;
}
.upgrade svg { width: 17px; height: 17px; stroke: url(#vela-grad); stroke-width: 2; }
.upgrade:hover { background: var(--surface-2); }

/* Menus */
.menu-wrap { position: relative; }
.menu {
  position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 30;
  min-width: 220px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--menu);
  box-shadow: var(--shadow);
  animation: pop .14s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.98); } }
.menu-label { margin: 6px 10px 4px; font-size: 12.5px; color: var(--faint); }
.menu-item {
  position: relative;
  display: block; width: 100%;
  padding: 8px 34px 8px 10px;
  border: 0; border-radius: 9px; background: none;
  font-size: 14.5px; text-align: left;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); }
.menu-item[aria-checked="true"]::after {
  content: ""; position: absolute; right: 12px; top: 50%;
  width: 10px; height: 5px; margin-top: -4px;
  border-left: 2px solid var(--text); border-bottom: 2px solid var(--text);
  transform: rotate(-45deg);
}
.menu-item.danger { color: var(--danger); }
.menu-sep { border: 0; border-top: 1px solid var(--line); margin: 6px 4px; }
.model-menu { min-width: 300px; }
.model-item { display: grid; gap: 1px; padding-top: 9px; padding-bottom: 9px; }
.model-name { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.model-desc { font-size: 13px; color: var(--muted); }
.model-item.is-locked .model-name { color: var(--muted); }
.model-item.is-locked .model-name svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.reply-model { margin-left: 6px; font-size: 12.5px; color: var(--faint); align-self: center; }
.badge {
  padding: 1px 7px; border-radius: 999px;
  background: var(--grad); color: #fff;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
}

.scrim { display: none; }

/* ── Main ─────────────────────────────────────────────────── */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.column { width: 100%; max-width: var(--column); margin: 0 auto; padding: 0 24px; }

.topbar { display: flex; align-items: center; gap: 4px; min-height: 56px; padding: 9px 14px; }
.topbar-title { flex: 1; min-width: 0; margin: 0 0 0 8px; font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#openSidebar, .when-collapsed { display: none; }
.app.collapsed #openSidebar, .app.collapsed .when-collapsed { display: grid; }
.upgrade-pill {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 14px 0 11px;
  border: 0; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-text);
  font-size: 14px; font-weight: 600;
}
.upgrade-pill svg { width: 16px; height: 16px; }
.upgrade-pill:hover { filter: brightness(1.08); }

.thread { flex: 1 1 auto; min-height: 0; overflow-y: auto; }

/* New chat: greeting and box sit in the middle of the screen */
.hero { display: none; text-align: center; padding-bottom: 26px; }
.hero-mark { width: 52px; height: 52px; margin: 0 auto 16px; }
.hero-title { margin: 0; font-size: clamp(26px, 3.6vw, 32px); line-height: 1.2; font-weight: 500; letter-spacing: -.015em; }
.main.is-empty .thread { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; overflow: visible; }
.main.is-empty .hero { display: block; animation: rise .5s var(--ease) both; }
.main.is-empty .messages { display: none; }
.main.is-empty .composer-note { display: none; }
.suggest { display: none; }
.main.is-empty .suggest { display: block; flex: 1 1 0; min-height: 0; overflow-y: auto; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 16px 0 24px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 15px 0 13px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: transparent;
  font-size: 14.5px; color: var(--muted);
  transition: background-color .15s, color .15s;
}
.chip svg { width: 17px; height: 17px; }
.chip:hover { background: var(--surface); color: var(--text); }

/* ── Messages ─────────────────────────────────────────────── */
.messages { display: flex; flex-direction: column; gap: 26px; padding: 12px 0 40px; }
.msg-user { display: flex; flex-direction: column; align-items: flex-end; }
.bubble {
  max-width: min(82%, 600px);
  padding: 10px 18px;
  border-radius: 22px;
  background: var(--surface-2);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-ai { display: grid; grid-template-columns: 30px 1fr; gap: 14px; align-items: start; }
.msg-ai > .mark { width: 26px; height: 26px; margin-top: 1px; }
.ai-body { min-width: 0; }
.thinking-text {
  margin: 0; font-size: 15.5px;
  background: linear-gradient(90deg, var(--faint) 0%, var(--text) 50%, var(--faint) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.msg-actions { display: flex; gap: 2px; margin-top: 6px; margin-left: -7px; }
.msg-user .msg-actions { margin: 4px -4px 0 0; }
.msg .msg-actions { opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions, .msg.is-last .msg-actions { opacity: 1; }
@media (hover: none) { .msg .msg-actions { opacity: 1; } }
.act {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 0; border-radius: 8px; background: none;
  color: var(--muted);
}
.act svg { width: 17px; height: 17px; }
.act:hover { background: var(--surface-2); color: var(--text); }
.act.is-on { color: var(--accent-text); }
.msg-error { margin: 0; color: var(--danger); }
.retry-btn { margin-top: 10px; padding: 7px 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: none; font-size: 14px; font-weight: 500; }
.retry-btn:hover { background: var(--surface); }
.msg-stopped { margin: .5em 0 0; font-size: 13px; color: var(--faint); }

.edit-box { width: min(100%, 640px); padding: 12px 14px; border-radius: 22px; background: var(--surface-2); }
.edit-input { display: block; width: 100%; min-height: 48px; max-height: 320px; padding: 0; border: 0; outline: none; resize: none; background: transparent; line-height: 1.6; }
.edit-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.edit-actions button { height: 34px; padding: 0 14px; border-radius: 999px; font-size: 14px; font-weight: 500; }
.edit-cancel { border: 1px solid var(--line-strong); background: var(--bg); }
.edit-save { border: 0; background: var(--invert); color: var(--invert-text); }

/* Markdown inside replies */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .9em; }
.md h3, .md h4 { margin: 1.4em 0 .5em; line-height: 1.3; font-weight: 600; }
.md h3 { font-size: 19px; }
.md h4 { font-size: 16.5px; }
.md ul, .md ol { margin: 0 0 .9em; padding-left: 1.4em; }
.md li { margin: .3em 0; }
.md li > p { margin: 0; }
.md li > p + p { margin-top: .5em; }
.md li > ul, .md li > ol { margin: .3em 0 0; }
.md li::marker { color: var(--muted); }
.md a { color: var(--accent-text); text-underline-offset: 3px; }
.md strong { font-weight: 600; }
.md blockquote { margin: 0 0 .9em; padding: 2px 0 2px 16px; border-left: 3px solid var(--surface-3); color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.4em 0; }
.md code { font: 400 .88em/1.5 var(--font-code); padding: .14em .4em; background: var(--surface-2); border-radius: 6px; }
.md code, .md pre { font-variant-ligatures: none; }
.md .code { margin: 0 0 1em; background: var(--code-bg); color: #E6E6EA; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.md .code-head { display: flex; align-items: center; justify-content: space-between; padding: 7px 8px 7px 14px; font-size: 12.5px; color: #9A9AA6; background: rgba(255, 255, 255, .04); }
.md .code-head button { padding: 3px 9px; border: 0; border-radius: 6px; background: none; font-size: 12.5px; color: #9A9AA6; }
.md .code-head button:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.md pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.md pre code { padding: 0; background: none; color: inherit; font-size: 13.5px; line-height: 1.6; white-space: pre; }
.md .table-wrap { margin: 0 0 1em; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.md table { border-collapse: collapse; font-size: 14.5px; width: 100%; }
.md th, .md td { padding: 9px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.md tr:last-child td { border-bottom: 0; }
.md th { font-weight: 600; background: var(--surface); }
.md .al-c { text-align: center; }
.md .al-r { text-align: right; }

/* ── Composer ─────────────────────────────────────────────── */
.composer { padding: 4px 0 max(10px, env(safe-area-inset-bottom)); }
.composer .column { position: relative; }
.to-latest {
  position: absolute; left: 50%; top: -50px;
  width: 38px; height: 38px; margin-left: -19px;
  display: grid; place-items: center;
  border: 1px solid var(--line-strong); border-radius: 50%;
  background: var(--bg); color: var(--text);
  box-shadow: var(--shadow);
}
.limit-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 10px; padding: 11px 12px 11px 16px;
  border: 1px solid var(--line-strong); border-radius: 16px;
  background: var(--surface);
  font-size: 14.5px;
}
.limit-banner p { margin: 0; }
.link-btn { flex: none; height: 34px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--invert); color: var(--invert-text); font-weight: 600; font-size: 14px; }
.composer-box {
  border: 1px solid var(--line-strong);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .12);
  transition: border-color .15s;
}
[data-theme="light"] .composer-box { background: #fff; box-shadow: 0 6px 24px rgba(20, 20, 40, .08); }
.composer-box:focus-within { border-color: var(--faint); }
.composer textarea {
  display: block; width: 100%;
  min-height: 52px; max-height: 240px;
  padding: 15px 20px 4px;
  border: 0; outline: none; resize: none;
  background: transparent; line-height: 1.5;
}
.composer textarea::placeholder { color: var(--faint); }
.composer textarea:disabled { cursor: not-allowed; }
.composer-tools { display: flex; align-items: center; gap: 6px; padding: 6px 10px 10px 12px; }
.tools-spacer { flex: 1; }
.mode-btn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 34px; padding: 0 9px 0 13px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: transparent;
  font-size: 14px; font-weight: 500; color: var(--muted);
}
.mode-btn svg { width: 16px; height: 16px; }
.mode-btn:hover, .mode-btn[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }
.round-action {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--invert); color: var(--invert-text);
  transition: opacity .15s, transform .15s;
}
.round-action:not(:disabled):active { transform: scale(.93); }
.round-action:disabled { background: var(--surface-3); color: var(--faint); }
.round-action svg { width: 18px; height: 18px; stroke-width: 2.2; }
.send .i-stop { display: none; fill: currentColor; stroke: none; }
.send.is-stop .i-send { display: none; }
.send.is-stop .i-stop { display: block; }
.composer-note { margin: 8px 0 0; font-size: 12.5px; color: var(--faint); text-align: center; }

/* ── Voice mode (always dark) ─────────────────────────────── */
.voice {
  width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh;
  margin: 0; padding: 0; border: 0;
  color: #F2F2F5;
  background: radial-gradient(45% 35% at 50% 45%, rgba(79, 140, 255, .18), transparent 70%), #050507;
}
.voice[open] { animation: fade .3s var(--ease); }
.voice::backdrop { background: #050507; }
@keyframes fade { from { opacity: 0; } }
.voice-inner {
  height: 100%; max-width: 600px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center;
  padding: max(22px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom));
  text-align: center;
}
.voice-title { margin: 0; font-size: 16px; font-weight: 600; }
.voice-status { margin: 6px 0 0; min-height: 1.6em; font-size: 15px; color: #9A9AA6; }
.voice-stage { flex: 1; min-height: 0; width: 100%; display: grid; place-items: center; padding: 16px 0; }
.voice-transcript {
  width: 100%; margin: 0 0 28px; min-height: 3em; max-height: 28vh; overflow-y: auto;
  font-size: clamp(20px, 4.6vw, 26px); line-height: 1.3; font-weight: 500;
}
.voice-transcript .interim { color: #6E6E78; }
.voice-controls { display: flex; gap: 20px; }
.voice-ctl {
  width: 64px; height: 64px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .1); color: #fff;
}
.voice-ctl svg { width: 24px; height: 24px; }
.voice-ctl:hover { background: rgba(255, 255, 255, .16); }
.voice-ctl .i-mic-off { display: none; }
.voice-ctl.is-muted { background: #fff; color: #111; }
.voice-ctl.is-muted .i-mic { display: none; }
.voice-ctl.is-muted .i-mic-off { display: block; }
.voice-ctl.end { background: #E5484D; }
.voice-ctl.end:hover { background: #F05A5F; }

/* The voice orb */
.orb {
  --size: min(56vw, 260px);
  position: relative; display: inline-block;
  width: var(--size); height: var(--size);
  border-radius: 50%; isolation: isolate;
}
.orb::before {
  content: ""; position: absolute; inset: 7%; border-radius: 50%;
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, .7), transparent 20%),
    radial-gradient(circle at 72% 68%, rgba(63, 217, 194, .65), transparent 46%),
    radial-gradient(circle at 26% 72%, rgba(140, 123, 255, .85), transparent 50%),
    radial-gradient(circle at 64% 30%, rgba(79, 163, 255, .95), transparent 58%),
    #0F1638;
  animation: spin 16s linear infinite;
}
.orb::after {
  content: ""; position: absolute; inset: 5%; border-radius: 50%; z-index: -1;
  box-shadow: 0 0 calc(var(--size) * .35) rgba(79, 140, 255, .45), inset 0 0 calc(var(--size) * .12) rgba(255, 255, 255, .3);
}
.orb-ring {
  position: absolute; inset: 0;
  border-radius: 47% 53% 51% 49% / 52% 48% 52% 48%;
  border: 2px solid rgba(255, 255, 255, .85);
  box-shadow: 0 0 calc(var(--size) * .07) rgba(170, 200, 255, .9), inset 0 0 calc(var(--size) * .06) rgba(170, 200, 255, .6);
  animation: spin 9s linear infinite;
}
.orb-ring.r2 { inset: 2.5%; border-radius: 53% 47% 46% 54% / 47% 54% 46% 53%; opacity: .5; animation-duration: 13s; animation-direction: reverse; }
.orb-ring.r3 { inset: -2%; border-radius: 50% 50% 45% 55% / 55% 45% 51% 49%; opacity: .28; animation-duration: 19s; }
@keyframes spin { to { transform: rotate(360deg); } }
.orb.is-thinking::before { animation-duration: 2.4s; }
.orb.is-thinking .orb-ring { animation-duration: 1.8s; }
.orb.is-listening { animation: breathe 2.6s ease-in-out infinite; }
.orb.is-speaking { animation: talk .7s ease-in-out infinite alternate; }
.orb.is-idle { opacity: .75; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes talk { from { transform: scale(.97); } to { transform: scale(1.06); } }

/* ── Plans ────────────────────────────────────────────────── */
.plans {
  width: min(96vw, 1120px);
  max-height: min(92dvh, 880px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: var(--bg); color: var(--text);
  box-shadow: var(--shadow);
}
.plans[open] { animation: plans-in .28s var(--ease); }
@keyframes plans-in { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.plans::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(4px); }
.plans-inner { padding: 30px 30px 24px; }
.plans-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.plans-head h2 { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 600; letter-spacing: -.02em; }
.plans-sub { margin: 8px 0 0; color: var(--muted); font-size: 15.5px; }
.plan-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.plan {
  position: relative; display: flex; flex-direction: column;
  padding: 22px 20px 20px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: var(--bg);
}
.plan-title { margin: 0; display: flex; align-items: center; gap: 9px; font-size: 20px; font-weight: 600; }
.plan-title .mark { width: 22px; height: 22px; }
.plan-blurb { margin: 6px 0 18px; min-height: 2.9em; font-size: 14.5px; line-height: 1.45; color: var(--muted); }
.plan-price { margin: 0 0 18px; display: flex; align-items: baseline; gap: 6px; }
.plan-amount { font-size: 34px; line-height: 1; font-weight: 600; letter-spacing: -.03em; }
.plan-period { font-size: 14px; color: var(--muted); }
.plan-cta {
  width: 100%; height: 42px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface);
  font-weight: 600; font-size: 14.5px;
}
.plan-cta:disabled { color: var(--muted); }
.plan-cta.is-current { background: transparent; color: var(--text); }
.plan-perks { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 10px; }
.plan-perks li { position: relative; padding-left: 26px; font-size: 14.5px; line-height: 1.45; }
.plan-perks li::before {
  content: ""; position: absolute; left: 3px; top: .38em;
  width: 11px; height: 6px;
  border-left: 2px solid var(--text); border-bottom: 2px solid var(--text);
  transform: rotate(-45deg);
}
.plan-tag {
  position: absolute; top: 20px; right: 18px;
  padding: 3px 10px; border-radius: 999px;
  background: var(--grad); color: #fff;
  font-size: 12px; font-weight: 600;
}

/* Ultra: gradient border and glow */
.plan-ultra {
  border: 1.5px solid transparent;
  background: linear-gradient(var(--bg), var(--bg)) padding-box, var(--grad) border-box;
  box-shadow: 0 20px 60px -24px rgba(100, 120, 255, .55);
}
.plan-ultra .plan-cta { border: 0; background: var(--grad); color: #fff; }
.plan-ultra .plan-cta:disabled { opacity: .55; }
.plan-ultra .plan-perks li:first-child { font-weight: 600; }
.plans-fine { margin: 20px 2px 0; font-size: 13px; color: var(--muted); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1080px) {
  .plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .app, .app.collapsed { grid-template-columns: 1fr; }
  .app .sidebar, .app.collapsed .sidebar {
    display: flex;
    position: fixed; inset: 0 auto 0 0; z-index: 20;
    width: min(84vw, 300px);
    transform: translateX(-100%);
    transition: transform .25s var(--ease);
  }
  .app .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .5); }
  .scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 15; }
  #openSidebar, .when-collapsed { display: grid; }
  .topbar { padding: 8px 8px; }
  .topbar-title { text-align: center; margin: 0; }
  .upgrade-pill { height: 34px; padding: 0 12px 0 10px; font-size: 13.5px; }
  .column { padding: 0 14px; }
  /* Phone: greeting in the middle, chips + box at the bottom */
  .main.is-empty .thread { flex: 1 1 auto; justify-content: center; }
  .main.is-empty .hero { padding-bottom: 0; }
  .thread { order: 1; }
  .main.is-empty .suggest { order: 2; flex: none; overflow: visible; }
  .composer { order: 3; }
  .chips { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; margin: 0 -14px; padding: 4px 14px 10px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; height: 38px; font-size: 14px; }
  .msg-ai { grid-template-columns: 1fr; gap: 8px; }
  .msg-ai > .mark { width: 22px; height: 22px; }
  .composer-note { display: none; }
  .composer-note.show-mobile { display: block; }

  .plans { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .plans-inner { padding: 20px 16px 28px; }
  .plans-head { position: sticky; top: -20px; z-index: 1; margin: -20px -16px 18px; padding: 30px 16px 14px; background: var(--bg); }
  .plans-head h2 { font-size: 26px; }
}

@media (max-width: 640px) {
  .main:not(.is-empty) .upgrade-pill { width: 36px; padding: 0; justify-content: center; }
  .main:not(.is-empty) .upgrade-pill .pill-text { display: none; }
  .plan-grid { grid-template-columns: 1fr; }
  .plan-blurb { min-height: 0; }
}

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

/* ═════════════════════════════════════════════════════════════
   Accounts, attachments, images, dialogs
   ═════════════════════════════════════════════════════════════ */

/* Account button in the sidebar */
.account-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px;
  border: 0; border-radius: 12px; background: none;
  text-align: left;
}
.account-btn:hover, .account-btn[aria-expanded="true"] { background: var(--surface-2); }
.avatar {
  flex: none; width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%; overflow: hidden;
  background: var(--grad); color: #fff;
  font-weight: 600; font-size: 14px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.guest { background: none; color: var(--muted); }
.avatar svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.account-text { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.account-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-sub { font-size: 12.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-sub:empty { display: none; }
.account-chevron { width: 16px; height: 16px; fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.account-menu { left: 0; right: 0; min-width: 0; max-height: 70vh; overflow-y: auto; }

.signin-pill {
  height: 36px; padding: 0 16px;
  border: 0; border-radius: 999px;
  background: var(--invert); color: var(--invert-text);
  font-size: 14px; font-weight: 600;
}
.signin-pill:hover { opacity: .9; }
.loading-chat { color: var(--faint); text-align: center; padding: 40px 0; }

/* Composer: tools, chips, attachments */
.tool-btn {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--line-strong); border-radius: 50%;
  background: transparent; color: var(--muted);
}
.tool-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.tool-btn:hover, .tool-btn[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }
.icon-item { display: flex; align-items: center; gap: 11px; min-width: 230px; }
.icon-item svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mode-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 10px 0 11px;
  border: 0; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-text);
  font-size: 14px; font-weight: 500;
}
.mode-chip svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.chip-x { font-size: 16px; line-height: 1; opacity: .7; }
.composer-box.is-drop { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px 0; }
.att { position: relative; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--bg); }
.att-image { width: 64px; height: 64px; }
.att-image img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 11px; }
.att-file { display: grid; grid-template-columns: 30px 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 8px; height: 64px; max-width: 220px; padding: 0 30px 0 12px; }
.att-file > svg { grid-row: span 2; width: 26px; height: 26px; fill: none; stroke: var(--accent-text); stroke-width: 1.6; stroke-linejoin: round; }
.att-name { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; align-self: end; }
.att-size { font-size: 12px; color: var(--faint); align-self: start; }
.att.is-loading::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.18), transparent);
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite;
}
.att-remove {
  position: absolute; top: -7px; right: -7px;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--invert); color: var(--invert-text);
}
.att-remove svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }

/* Attachments and created images in the thread */
.msg-attachments { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-bottom: 8px; max-width: min(82%, 600px); }
.msg-thumb { display: block; width: 180px; height: 180px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); }
.msg-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-chip {
  display: inline-flex; align-items: center; gap: 8px;
  max-width: 260px; padding: 9px 14px;
  border: 1px solid var(--line-strong); border-radius: 14px;
  font-size: 14px;
}
.file-chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-chip svg { width: 18px; height: 18px; fill: none; stroke: var(--accent-text); stroke-width: 1.7; stroke-linejoin: round; }
.bubble.is-image-prompt::before { content: "Image: "; color: var(--muted); }
.generated { display: grid; gap: 10px; margin-bottom: 8px; }
.gen-image { position: relative; margin: 0; width: min(100%, 440px); aspect-ratio: 1; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.gen-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gen-download {
  position: absolute; top: 10px; right: 10px;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55); color: #fff;
  opacity: 0; transition: opacity .15s;
}
.gen-image:hover .gen-download, .gen-download:focus-visible { opacity: 1; }
@media (hover: none) { .gen-download { opacity: 1; } }
.gen-download svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Dialog sheets */
.sheet {
  width: min(94vw, 420px);
  max-height: min(92dvh, 760px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: var(--bg); color: var(--text);
  box-shadow: var(--shadow);
}
.sheet.wide { width: min(94vw, 560px); }
.sheet[open] { animation: plans-in .24s var(--ease); }
.sheet::backdrop { background: rgba(0, 0, 0, .55); backdrop-filter: blur(4px); }
.sheet-close { position: absolute; top: 12px; right: 12px; margin: 0; }
.sheet-inner { padding: 34px 28px 26px; text-align: center; }
.sheet-inner.left { text-align: left; }
.sheet-mark { width: 44px; height: 44px; margin: 0 auto 14px; }
.sheet h2 { margin: 0; font-size: 24px; line-height: 1.2; font-weight: 600; letter-spacing: -.015em; }
.sheet-sub { margin: 8px 0 20px; color: var(--muted); font-size: 15px; }
.sheet-fine { margin: 18px 0 0; font-size: 12.5px; color: var(--faint); }
.sheet-fine a { color: var(--muted); }
.sheet-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 22px; }
.form-error { margin: 0 0 14px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 90, 90, .12); color: var(--danger); font-size: 14px; text-align: left; }

.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; height: 46px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--bg); color: var(--text);
  font-weight: 500; text-decoration: none;
}
.google-btn:hover { background: var(--surface); }
.google-btn svg { width: 19px; height: 19px; }
.divider { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--faint); font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.email-form { display: grid; gap: 8px; text-align: left; }
.field-label { display: block; margin: 0; font-size: 14px; font-weight: 500; }
.field-label .badge { margin-left: 6px; vertical-align: 1px; }
.field-help { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.field {
  width: 100%; height: 46px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: 14px;
  background: var(--surface); outline: none;
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.area { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; line-height: 1.5; margin: 6px 0 18px; }
.field:disabled { opacity: .55; cursor: not-allowed; }
.code-field { text-align: center; font-size: 24px; letter-spacing: 8px; font-variant-numeric: tabular-nums; }
.code-hint { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.code-links { display: flex; justify-content: space-between; margin-top: 4px; }
.primary-btn {
  height: 46px; padding: 0 20px;
  border: 0; border-radius: 999px;
  background: var(--invert); color: var(--invert-text);
  font-weight: 600;
}
.primary-btn:disabled { opacity: .5; }
.email-form .primary-btn { margin-top: 6px; }
.ghost-btn { height: 42px; padding: 0 18px; border: 1px solid var(--line-strong); border-radius: 999px; background: none; font-weight: 500; }
.danger-btn { height: 42px; padding: 0 18px; border: 0; border-radius: 999px; background: #E5484D; color: #fff; font-weight: 600; }
.text-btn { padding: 4px 2px; border: 0; background: none; color: var(--accent-text); font-size: 14px; font-weight: 500; }
.text-btn.danger { color: var(--danger); }
.copy-row { display: flex; gap: 8px; }
.copy-row .field { flex: 1; font-size: 14px; }
.copy-row .primary-btn { flex: none; }
#stopShare { margin-top: 14px; }

.locked-field.is-locked textarea { background: var(--surface-2); }
#styleUnlock { margin: -12px 0 18px; }
.memory-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-top: 18px; border-top: 1px solid var(--line); }
.switch { position: relative; flex: none; width: 44px; height: 26px; margin-top: 2px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch input + span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); transition: background-color .15s; }
.switch input + span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .18s var(--ease); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:disabled + span { opacity: .45; }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.memory-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; max-height: 220px; overflow-y: auto; }
.memory-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 6px 8px 12px; border-radius: 10px; background: var(--surface); font-size: 14px; }
.memory-empty { padding: 10px 2px; font-size: 14px; color: var(--muted); }

/* Toast: shown as a popover so it sits above open dialogs */
.toast {
  position: fixed; inset: auto; z-index: 50;
  left: 50%; bottom: max(24px, env(safe-area-inset-bottom));
  translate: -50% 0;
  width: max-content; max-width: min(92vw, 460px);
  margin: 0; border: 0;
  padding: 11px 18px;
  border-radius: 14px;
  background: var(--invert); color: var(--invert-text);
  font-size: 14.5px; font-weight: 500;
  box-shadow: var(--shadow);
  overflow: visible;
  animation: pop .18s var(--ease);
}

@media (max-width: 860px) {
  .msg-thumb { width: 140px; height: 140px; }
  .sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 24px 24px 0 0; max-height: 92dvh; }
  .sheet-inner { padding: 30px 20px max(24px, env(safe-area-inset-bottom)); }
  .signin-pill { height: 34px; padding: 0 14px; }
}
