/* Jas web app styles. Colors are tokens on :root; dark mode follows the system. */

:root {
  --cobalt: #2F55F4;
  --ink: #151515;
  --paper: #F6F4EF;
  --sky: #7B93FF;

  --bg: var(--paper);
  --bg-sidebar: #EEEBE4;
  --surface: #FFFFFF;
  --hover: rgba(21, 21, 21, 0.05);
  --active: rgba(21, 21, 21, 0.08);
  --text: var(--ink);
  --text-2: #4F4C46;
  --text-3: #6B675F;
  --border: #E3DFD6;
  --border-strong: #D2CDC2;
  --accent: var(--cobalt);
  --accent-hover: #2244D6;
  --on-accent: #FFFFFF;
  --accent-soft: rgba(47, 85, 244, 0.12);
  --user-bubble: #E9E5DC;
  --code-bg: #FBFAF7;
  --code-bar: #F1EEE7;
  --inline-code: rgba(21, 21, 21, 0.06);
  --danger: #B42318;
  --danger-soft: #FCEDEB;
  --danger-border: #F0C4BE;
  --warn: #8A4F00;
  --warn-soft: #FFF3DD;
  --warn-border: #F0D3A0;
  --scrim: rgba(21, 21, 21, 0.38);
  --shadow-1: 0 1px 2px rgba(21, 21, 21, 0.05), 0 2px 8px rgba(21, 21, 21, 0.04);
  --shadow-2: 0 12px 32px rgba(21, 21, 21, 0.14), 0 2px 6px rgba(21, 21, 21, 0.06);

  /* syntax colors */
  --hl-keyword: #2F55F4;
  --hl-string: #1F7A3A;
  --hl-comment: #807B71;
  --hl-number: #A35200;
  --hl-title: #7A3EC9;
  --hl-type: #0B6E82;
  --hl-attr: #A3245E;
  --hl-meta: #6B675F;
  --hl-del-bg: #FBE3E0;
  --hl-add-bg: #E1F3E4;

  --font-ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-read: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Charter, "Bitstream Charter", Georgia, serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --sidebar-w: 272px;
  --thread-w: 768px;
  --radius: 14px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151515;
    --bg-sidebar: #0F0F0F;
    --surface: #1F1F1F;
    --hover: rgba(255, 255, 255, 0.06);
    --active: rgba(255, 255, 255, 0.10);
    --text: #ECEAE5;
    --text-2: #BDB9B1;
    --text-3: #9D9990;
    --border: #2A2A2A;
    --border-strong: #3A3A3A;
    --accent: var(--sky);
    --accent-hover: #97AAFF;
    --on-accent: #151515;
    --accent-soft: rgba(123, 147, 255, 0.18);
    --user-bubble: #272727;
    --code-bg: #1A1A1A;
    --code-bar: #222222;
    --inline-code: rgba(255, 255, 255, 0.08);
    --danger: #FF9B90;
    --danger-soft: rgba(255, 120, 105, 0.10);
    --danger-border: rgba(255, 120, 105, 0.30);
    --warn: #F3BC63;
    --warn-soft: rgba(243, 188, 99, 0.10);
    --warn-border: rgba(243, 188, 99, 0.30);
    --scrim: rgba(0, 0, 0, 0.55);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 14px 36px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.4);

    --hl-keyword: #93A7FF;
    --hl-string: #93D49A;
    --hl-comment: #8C887F;
    --hl-number: #F2A766;
    --hl-title: #CDA8FF;
    --hl-type: #6FCFE0;
    --hl-attr: #F49AC1;
    --hl-meta: #A39F96;
    --hl-del-bg: rgba(255, 120, 105, 0.15);
    --hl-add-bg: rgba(120, 210, 130, 0.14);

    color-scheme: dark;
  }
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

[hidden] { display: none !important; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--accent); text-underline-offset: 2px; }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; left: 12px; top: -120px; z-index: 100;
  background: var(--surface); color: var(--text);
  padding: 8px 12px; border-radius: 10px; box-shadow: var(--shadow-2);
  text-decoration: none; transition: top .15s var(--ease);
}
.skip-link:focus { top: 12px; }

.ico { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ico svg { width: 100%; height: 100%; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; flex: none;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--text-2);
  transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:disabled { opacity: .45; background: transparent; }
.icon-btn .ico { width: 20px; height: 20px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 6px 12px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 500;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .55; }
.btn .ico { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-danger { color: #151515; } }
.btn-danger:hover { filter: brightness(1.05); background: var(--danger); }

.byline {
  margin: 0; text-align: center;
  font-size: 12px; color: var(--text-3); letter-spacing: .01em;
}

.noscript { padding: 24px; text-align: center; }

/* ---------- boot ---------- */

.boot {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg);
}
.boot img { animation: breathe 1.6s ease-in-out infinite; border-radius: 13px; }
@keyframes breathe { 50% { opacity: .55; transform: scale(.96); } }

/* ---------- login ---------- */

.login {
  min-height: 100%; height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 20px calc(24px + env(safe-area-inset-bottom));
  gap: 32px;
}
.login-inner {
  width: 100%; max-width: 380px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.login-logo img { width: 132px; height: auto; display: block; }
.login-line {
  margin: 22px 0 28px;
  font-size: 17px; font-weight: 400; line-height: 1.45; color: var(--text-2);
  text-wrap: balance;
}
.login-line span {
  display: block; margin-bottom: 4px;
  font-family: var(--font-read); font-size: 27px; line-height: 1.2; color: var(--text);
  letter-spacing: -.005em;
}
.login-error {
  width: 100%; margin: -8px 0 16px; padding: 10px 12px;
  border: 1px solid var(--danger-border); background: var(--danger-soft); color: var(--danger);
  border-radius: 12px; font-size: 14px; text-align: left;
}
.google-btn {
  width: 100%; max-width: 320px; height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  border: 1px solid var(--border-strong); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font-size: 15.5px; font-weight: 600;
  box-shadow: var(--shadow-1);
  transition: background-color .15s, border-color .15s, transform .1s;
}
.google-btn:hover { border-color: var(--text-3); }
.google-btn:active { transform: translateY(1px); }
.google-btn:disabled { opacity: .7; }
.google-btn:focus-visible { border-radius: 999px; }
.g-logo { flex: none; }
.login-note { margin: 18px 0 0; font-size: 13.5px; color: var(--text-2); max-width: 32ch; }
.login-fine { margin: 10px 0 0; font-size: 12.5px; color: var(--text-3); max-width: 36ch; }
.login-fine a { color: inherit; }

/* ---------- app shell ---------- */

.app {
  display: flex;
  height: 100vh; height: 100dvh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w); flex: none;
  display: flex; flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  min-height: 0;
}
.app.sidebar-collapsed .sidebar { display: none; }

.sidebar-top {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 10px 6px;
}
.new-chat {
  flex: 1; display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font-size: 14.5px; font-weight: 500;
  box-shadow: var(--shadow-1);
  transition: border-color .15s;
}
.new-chat:hover { border-color: var(--text-3); }
.new-chat .ico { width: 18px; height: 18px; color: var(--accent); }
.new-chat-kbd {
  margin-left: auto; font: 11.5px var(--font-ui); color: var(--text-3);
  letter-spacing: .02em;
}
.sidebar-close { display: none; }

.convo-list {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 6px 8px 12px;
  overscroll-behavior: contain;
}
.convo-ul { list-style: none; margin: 0; padding: 0; }
.convo-group { margin-top: 14px; }
.convo-group:first-child { margin-top: 6px; }
.convo-group-label {
  margin: 0 0 4px; padding: 0 10px;
  font-size: 12px; font-weight: 600; color: var(--text-3);
}
.convo {
  position: relative; display: flex; align-items: center;
  border-radius: 10px;
}
.convo:hover, .convo:focus-within { background: var(--hover); }
.convo.current { background: var(--active); }
.convo-open {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 10px;
  border: 0; background: transparent; text-align: left;
  font-size: 14px; color: var(--text);
}
.convo-open:focus-visible { outline-offset: -2px; }
.convo-title { min-width: 0; flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.convo-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--accent); animation: breathe 1.4s ease-in-out infinite;
}
.convo-actions {
  display: flex; gap: 2px; padding-right: 4px;
  opacity: 0; transition: opacity .12s;
}
.convo:hover .convo-actions, .convo:focus-within .convo-actions, .convo.current .convo-actions { opacity: 1; }
.convo-actions .icon-btn { width: 28px; height: 28px; border-radius: 8px; }
.convo-actions .icon-btn .ico { width: 15px; height: 15px; }
.convo-rename {
  flex: 1; min-width: 0; height: 32px; margin: 2px 4px;
  padding: 0 8px; border: 1px solid var(--accent); border-radius: 8px;
  background: var(--surface); font-size: 14px;
}
.convo-empty { padding: 14px 12px; font-size: 13.5px; color: var(--text-3); }

.sidebar-foot {
  margin: 0; padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  font-size: 12px; color: var(--text-3);
  border-top: 1px solid var(--border);
}

.scrim {
  position: fixed; inset: 0; z-index: 30;
  background: var(--scrim);
  animation: fade-in .18s var(--ease);
}
@keyframes fade-in { from { opacity: 0; } }

.main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  position: relative;
}

/* ---------- top bar ---------- */

.topbar {
  position: relative; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  height: 56px; flex: none;
  padding: 0 12px;
  padding-top: env(safe-area-inset-top);
  box-sizing: content-box;
}
.brand { display: inline-flex; align-items: center; padding: 4px 6px; border-radius: 8px; }
.brand img { height: 26px; width: auto; display: block; }

.model-picker { position: relative; }
.model-btn {
  display: inline-flex; align-items: center; gap: 4px;
  height: 36px; padding: 0 8px 0 10px;
  border: 0; border-radius: 10px; background: transparent;
  font-size: 15px; font-weight: 600; color: var(--text);
  white-space: nowrap;
}
.model-btn:hover, .model-btn[aria-expanded="true"] { background: var(--hover); }
.model-btn .chev { width: 16px; height: 16px; color: var(--text-3); transition: transform .15s; }
.model-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.model-label .short { display: none; }

.menu {
  position: absolute; top: calc(100% + 6px); z-index: 50;
  min-width: 220px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-2);
  animation: pop .14s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }
.model-menu { left: 0; width: 330px; }
.account-menu { right: 0; width: 270px; }

.menu-item {
  display: flex; align-items: flex-start; gap: 10px; width: 100%;
  padding: 10px 12px;
  border: 0; border-radius: 10px; background: transparent;
  text-align: left; text-decoration: none; color: var(--text);
}
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); }
.menu-item:focus-visible { outline-offset: -2px; }
.menu-item.small { align-items: center; padding: 8px 12px; font-size: 14px; }
.menu-item .ico { width: 16px; height: 16px; color: var(--text-2); }
.mi-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.mi-title { font-weight: 600; font-size: 14.5px; }
.mi-desc { font-size: 13px; line-height: 1.4; color: var(--text-2); }
.mi-check { color: var(--accent) !important; visibility: hidden; margin-top: 2px; }
.menu-item[aria-checked="true"] .mi-check { visibility: visible; }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--border); }

.acct-head { padding: 8px 12px 6px; }
.acct-label { font-size: 12px; color: var(--text-3); }
.acct-email { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.acct-usage { margin-top: 4px; font-size: 12.5px; color: var(--text-2); }

.mock-badge {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--warn); background: var(--warn-soft); border: 1px solid var(--warn-border);
  padding: 2px 7px; border-radius: 999px;
}

.topbar-spacer { flex: 1; }

.usage {
  display: inline-flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 999px;
  font-size: 12.5px; color: var(--text-2); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.usage-text .short { display: none; }
.usage-bar {
  position: relative; width: 36px; height: 4px; border-radius: 4px;
  background: var(--active); overflow: hidden;
}
.usage-bar > span {
  position: absolute; inset: 0 auto 0 0; width: 100%;
  background: var(--accent); border-radius: 4px;
  transition: width .3s var(--ease);
}
.usage.low { color: var(--warn); border-color: var(--warn-border); }
.usage.low .usage-bar > span { background: var(--warn); }
.usage.out { color: var(--danger); border-color: var(--danger-border); }

.account { position: relative; margin-left: 4px; }
.avatar-btn {
  width: 34px; height: 34px; border-radius: 50%;
  border: 0; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
  font-weight: 700; font-size: 14px; text-transform: uppercase;
}
.avatar-btn:focus-visible { border-radius: 50%; }

/* ---------- banners ---------- */

.banners { flex: none; }
.banner {
  display: flex; align-items: flex-start; gap: 10px;
  max-width: calc(var(--thread-w) + 40px); margin: 0 auto 6px; padding: 10px 14px;
  border: 1px solid var(--warn-border); background: var(--warn-soft); color: var(--warn);
  border-radius: 12px; font-size: 14px;
  width: calc(100% - 24px);
}
.banner .ico { width: 18px; height: 18px; margin-top: 1px; }
.banner.danger { border-color: var(--danger-border); background: var(--danger-soft); color: var(--danger); }
.banner code { font-family: var(--font-mono); font-size: 13px; }

/* ---------- thread ---------- */

.scroller {
  flex: 1; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  overscroll-behavior: contain;
}
.thread {
  max-width: calc(var(--thread-w) + 40px);
  margin: 0 auto;
  padding: 8px 20px 24px;
}

.msg { padding: 14px 0; }
.msg + .msg { padding-top: 10px; }

.msg-user { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.bubble {
  max-width: min(85%, 640px);
  padding: 10px 16px;
  background: var(--user-bubble);
  border-radius: 20px 20px 6px 20px;
  font-size: 16px; line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg-files { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: 85%; }

.msg-assistant {
  display: grid; grid-template-columns: 28px minmax(0, 1fr);
  column-gap: 14px;
}
.msg-avatar { width: 28px; height: 28px; border-radius: 8px; margin-top: 2px; display: block; }
.msg-body { min-width: 0; }

/* markdown */
.md {
  font-family: var(--font-read);
  font-size: 17px; line-height: 1.65;
  overflow-wrap: break-word;
}
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .85em; }
.md h1, .md h2, .md h3, .md h4 {
  font-family: var(--font-ui); line-height: 1.3; margin: 1.3em 0 .5em; font-weight: 650;
}
.md h1 { font-size: 1.35em; }
.md h2 { font-size: 1.2em; }
.md h3 { font-size: 1.06em; }
.md h4 { font-size: 1em; }
.md ul, .md ol { margin: 0 0 .9em; padding-left: 1.4em; }
.md li { margin: .25em 0; }
.md li > p { margin: 0 0 .4em; }
.md blockquote {
  margin: 0 0 .9em; padding: .1em 0 .1em 1em;
  border-left: 3px solid var(--border-strong); color: var(--text-2);
}
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.5em 0; }
.md a { word-break: break-word; }
.md strong { font-weight: 650; }
.md :not(pre) > code {
  font-family: var(--font-mono); font-size: .84em;
  padding: .12em .38em; border-radius: 6px;
  background: var(--inline-code);
  overflow-wrap: anywhere;
}
.md.streaming > p:last-child::after,
.md.streaming > ul:last-child > li:last-child::after,
.md.streaming > ol:last-child > li:last-child::after {
  content: ""; display: inline-block; vertical-align: -0.12em;
  width: .5em; height: 1.05em; margin-left: 2px;
  background: var(--accent); border-radius: 2px;
  animation: blink 1s steps(2, start) infinite;
}
@keyframes blink { to { visibility: hidden; } }

.table-wrap { overflow-x: auto; margin: 0 0 1em; border: 1px solid var(--border); border-radius: 10px; }
.md table { border-collapse: collapse; width: 100%; font-family: var(--font-ui); font-size: 14.5px; line-height: 1.45; }
.md th, .md td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.md th { font-weight: 600; background: var(--code-bar); white-space: nowrap; }
.md tr:last-child td { border-bottom: 0; }

.codeblock {
  margin: 0 0 1em;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--code-bg);
  overflow: hidden;
}
.codebar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 6px 4px 14px;
  background: var(--code-bar);
  font: 12.5px var(--font-ui); color: var(--text-2);
}
.copy-code {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px;
  border: 0; border-radius: 8px; background: transparent;
  font-size: 12.5px; color: var(--text-2);
}
.copy-code:hover { background: var(--hover); color: var(--text); }
.copy-code .ico { width: 14px; height: 14px; }
.codeblock pre {
  margin: 0; padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--font-mono); font-size: 13.5px; line-height: 1.6;
  tab-size: 4;
}
.codeblock code { font-family: inherit; background: none; padding: 0; }

.md .katex { font-size: 1.06em; }
.md .katex-display { margin: .4em 0 1em; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* highlight.js tokens */
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-doctag, .hljs-section { color: var(--hl-keyword); }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-template-tag, .hljs-template-variable { color: var(--hl-string); }
.hljs-comment, .hljs-quote { color: var(--hl-comment); font-style: italic; }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-variable.constant_ { color: var(--hl-number); }
.hljs-title, .hljs-title.function_, .hljs-title.class_, .hljs-name { color: var(--hl-title); }
.hljs-built_in, .hljs-type, .hljs-class .hljs-title { color: var(--hl-type); }
.hljs-attr, .hljs-attribute, .hljs-property, .hljs-selector-attr, .hljs-selector-class, .hljs-selector-id, .hljs-tag { color: var(--hl-attr); }
.hljs-meta, .hljs-meta .hljs-keyword { color: var(--hl-meta); }
.hljs-deletion { background: var(--hl-del-bg); }
.hljs-addition { background: var(--hl-add-bg); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* status while waiting */
.status { font-family: var(--font-ui); padding-top: 3px; }
.status-main {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px;
  min-height: 28px;
  font-size: 15px; color: var(--text-2);
}
.status-text {
  color: var(--text-2);
  background: linear-gradient(90deg, var(--text-3) 0%, var(--text-3) 35%, var(--text) 50%, var(--text-3) 65%, var(--text-3) 100%);
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 2.4s linear infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0% 0; } }
.status-globe { width: 17px; height: 17px; color: var(--accent); display: none; animation: breathe 1.6s ease-in-out infinite; }
.status.searching .status-globe { display: inline-flex; }
.status.searching .dots { display: none; }
.status-meta { font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.status-note { margin: 6px 0 0; max-width: 56ch; font-size: 13.5px; line-height: 1.5; color: var(--text-3); }
.dots { display: inline-flex; gap: 4px; align-items: center; height: 18px; }
.dots i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  animation: dot 1.2s ease-in-out infinite;
}
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* sources under a reply */
.sources {
  list-style: none; margin: 14px 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.source {
  display: inline-flex; align-items: center; gap: 7px;
  max-width: 220px; height: 30px; padding: 0 11px 0 5px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface);
  font: 12.5px var(--font-ui); color: var(--text-2); text-decoration: none;
  transition: border-color .15s, color .15s, background-color .15s;
}
.source:hover { border-color: var(--border-strong); color: var(--text); background: var(--hover); }
.source:focus-visible { border-radius: 999px; }
.source-badge {
  flex: none; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-size: 10.5px; font-weight: 700;
}
.source-host { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* notes and errors under a reply */
.note {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px;
  margin-top: 10px; font: 13.5px var(--font-ui); color: var(--text-3);
}
.err {
  font-family: var(--font-ui); font-size: 14.5px; line-height: 1.5;
  padding: 12px 14px;
  border: 1px solid var(--danger-border); background: var(--danger-soft);
  border-radius: 12px; color: var(--text);
}
.err.warn { border-color: var(--warn-border); background: var(--warn-soft); }
.err-title { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--danger); }
.err.warn .err-title { color: var(--warn); }
.err-title .ico { width: 17px; height: 17px; }
.err-msg { margin: 4px 0 0; color: var(--text-2); }
.err-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.err-countdown { font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.msg-actions {
  display: flex; align-items: center; gap: 2px; margin: 6px 0 0 -8px;
  min-height: 32px;
  opacity: 0; transition: opacity .15s;
}
.msg-assistant:hover .msg-actions,
.msg-assistant:focus-within .msg-actions,
.msg-assistant.last .msg-actions { opacity: 1; }
@media (hover: none) { .msg-actions { opacity: 1; } }
.msg-actions .icon-btn { width: 32px; height: 32px; border-radius: 8px; }
.msg-actions .icon-btn .ico { width: 16px; height: 16px; }
.msg-model { margin-left: 6px; font: 12px var(--font-ui); color: var(--text-3); }

/* empty state */
.empty {
  max-width: calc(var(--thread-w) + 40px);
  margin: 0 auto; padding: 14vh 20px 24px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
}
.empty-icon { border-radius: 12px; }
.empty-title {
  margin: 18px 0 22px;
  font-family: var(--font-read); font-weight: 400; font-size: 30px; line-height: 1.2;
  letter-spacing: -.01em; text-wrap: balance;
}
.suggestions {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
  width: 100%; max-width: 640px;
}
.suggestion {
  padding: 12px 14px; min-height: 64px;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); color: var(--text);
  text-align: left; font-size: 14px; line-height: 1.4;
  transition: border-color .15s, background-color .15s;
}
.suggestion:hover { border-color: var(--border-strong); background: var(--hover); }
.suggestion small { display: block; margin-top: 2px; font-size: 12.5px; color: var(--text-3); }
.mock-help {
  width: 100%; max-width: 640px; margin-top: 20px; padding: 12px 14px;
  border: 1px dashed var(--warn-border); border-radius: 14px;
  text-align: left; font-size: 13px; color: var(--text-2);
}
.mock-help strong { color: var(--warn); }
.mock-help ul { margin: 6px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.mock-help button {
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px;
  padding: 3px 8px; font: 12.5px var(--font-mono); color: var(--text);
}
.mock-help button:hover { border-color: var(--border-strong); }

/* ---------- composer ---------- */

.composer-wrap { position: relative; flex: none; }
.composer {
  padding: 0 16px calc(8px + env(safe-area-inset-bottom));
}
.composer-box {
  max-width: var(--thread-w); margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  box-shadow: var(--shadow-1);
  padding: 10px 10px 8px 16px;
  transition: border-color .15s, box-shadow .15s;
}
.composer-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.composer-box.dragging { border-style: dashed; border-color: var(--accent); background: var(--accent-soft); }
.composer textarea {
  display: block; width: 100%;
  min-height: 26px; max-height: 40vh;
  padding: 4px 0;
  border: 0; outline: none; resize: none;
  background: transparent;
  font-size: 16px; line-height: 1.5;
  overflow-y: auto;
}
.composer textarea::placeholder { color: var(--text-3); }
.composer-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; margin-left: -8px; }
.composer-hint {
  flex: 1; min-width: 0;
  font-size: 12.5px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.composer-hint.warn { color: var(--warn); }
.word-count { font-size: 12.5px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.word-count.over { color: var(--danger); font-weight: 600; }
.word-count.near { color: var(--warn); }

.send-btn {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  transition: background-color .15s, opacity .15s, transform .1s;
}
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:active:not(:disabled) { transform: scale(.95); }
.send-btn:disabled { background: var(--active); color: var(--text-3); }
.send-btn:focus-visible { border-radius: 50%; }
.send-btn .ico { width: 18px; height: 18px; }
.send-btn .ico-stop { display: none; }
.send-btn.stop { background: var(--text); color: var(--bg); }
.send-btn.stop .ico-send { display: none; }
.send-btn.stop .ico-stop { display: inline-flex; }

.file-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.file-chips:not(:empty) { margin: 2px 0 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 100%;
  height: 30px; padding: 0 4px 0 10px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg);
  font-size: 13px; color: var(--text);
}
.chip .ico { width: 15px; height: 15px; color: var(--accent); }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chip-size { color: var(--text-3); white-space: nowrap; }
.chip button { width: 24px; height: 24px; border-radius: 6px; }
.chip button .ico { width: 14px; height: 14px; color: var(--text-2); }
.msg-files .chip { padding-right: 10px; background: var(--surface); }

.composer .byline { margin-top: 8px; }

.to-bottom {
  position: absolute; left: 50%; top: -48px; z-index: 5;
  transform: translateX(-50%);
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  box-shadow: var(--shadow-2);
}
.to-bottom:hover { color: var(--text); }
.to-bottom .ico { width: 18px; height: 18px; }
.to-bottom:focus-visible { border-radius: 50%; }

/* ---------- toast & dialog ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); z-index: 90;
  transform: translateX(-50%);
  max-width: min(92vw, 460px);
  padding: 10px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg);
  font-size: 14px; box-shadow: var(--shadow-2);
  animation: pop .16s var(--ease);
}

.dialog {
  width: min(92vw, 400px); padding: 20px;
  border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-2);
}
.dialog::backdrop { background: var(--scrim); }
.dialog form { margin: 0; }
.dialog-title { margin: 0 0 6px; font-size: 17px; font-weight: 650; }
.dialog-body { margin: 0 0 18px; color: var(--text-2); font-size: 14.5px; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- small screens ---------- */

@media (max-width: 820px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40;
    width: min(86vw, 304px);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform .22s var(--ease), visibility 0s linear .22s;
    box-shadow: var(--shadow-2);
    padding-top: env(safe-area-inset-top);
  }
  .app.sidebar-collapsed .sidebar { display: flex; }
  .app.drawer-open .sidebar {
    transform: none; visibility: visible;
    transition: transform .22s var(--ease), visibility 0s;
  }
  .sidebar-close { display: inline-grid; }
  .convo-actions { opacity: 1; }
  .new-chat-kbd { display: none; }
  .empty { padding-top: 8vh; }
}

@media (max-width: 560px) {
  .topbar { gap: 2px; padding: 0 8px; }
  .brand { padding: 4px; }
  .brand img { height: 22px; }
  .model-picker { position: static; }
  .model-menu { left: 8px; right: 8px; width: auto; }
  .model-label .long { display: none; }
  .model-label .short { display: inline; }
  .model-btn { padding: 0 4px 0 8px; font-size: 14.5px; }
  .usage { padding: 0 8px; height: 28px; }
  .usage-text .long { display: none; }
  .usage-text .short { display: inline; }
  .usage-bar { display: none; }
  .account-menu { right: -4px; }
  .thread { padding: 4px 14px 20px; }
  .msg-assistant { grid-template-columns: minmax(0, 1fr); }
  .msg-avatar { width: 24px; height: 24px; margin-bottom: 8px; border-radius: 7px; }
  .md { font-size: 16.5px; }
  .bubble { max-width: 90%; }
  .composer { padding: 0 10px calc(6px + env(safe-area-inset-bottom)); }
  .composer-hint { white-space: normal; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .empty-title { font-size: 25px; }
  .suggestions { grid-template-columns: minmax(0, 1fr); }
  .suggestion:nth-child(n+3) { display: none; }
  .banner { width: calc(100% - 16px); }
}

@media (max-width: 360px) {
  .brand { display: none; }
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    transition-delay: 0s !important;
    scroll-behavior: auto !important;
  }
  .dots i { animation: none !important; opacity: .7; }
  .dots i:nth-child(2) { opacity: .45; }
  .dots i:nth-child(3) { opacity: .25; }
  .boot img, .convo-dot, .status-globe { animation: none !important; }
  .md.streaming > p:last-child::after { animation: none !important; }
  .status-text { animation: none !important; background: none; -webkit-text-fill-color: currentColor; color: var(--text-2); }
}
