/* OffRails Chat. Light only, like the site (no dark cards or bands); code windows are the one dark surface. */
:root {
  --bg: #ffffff;
  --side: #f7f7f5;
  --bg-alt: #f3f3f1;
  --hover: #ececea;
  --active: #e9e7ff;
  --ink: #111111;
  --ink-2: #2b2b2b;
  --muted: #666661;
  --muted-2: #9b9b95;
  --line: #e5e5e1;
  --line-2: #efefec;
  --accent: #6c5cff;
  --accent-ink: #4a3bd6;
  --accent-soft: #f5f3ff;
  --accent-line: rgba(108, 92, 255, .22);
  --teal: #0f766e;
  --red: #dc2626;
  --shadow: 0 1px 2px rgba(17, 17, 17, .04), 0 12px 32px -16px rgba(17, 17, 17, .16);
  --shadow-lg: 0 1px 2px rgba(17, 17, 17, .05), 0 30px 70px -30px rgba(17, 17, 17, .32);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "PingFang SC", "Noto Sans SC", Roboto, sans-serif;
  --mono: "SF Mono", ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --side-w: 272px;
  --col: 780px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
body { position: fixed; inset: 0; overflow: hidden; font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; text-size-adjust: 100%; -webkit-text-size-adjust: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-ink); }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.offscreen { position: fixed; left: -9999px; top: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.5; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- layout */
.app { position: fixed; left: 0; top: var(--app-top, 0); width: 100%; height: var(--app-h, 100dvh); display: flex; overflow: hidden; }
.side { width: var(--side-w); flex: none; display: flex; flex-direction: column; background: var(--side); border-right: 1px solid var(--line); padding-top: env(safe-area-inset-top); padding-left: env(safe-area-inset-left); transition: margin-left .3s var(--ease-out), transform .32s var(--ease-out); z-index: 30; }
.app.side-collapsed .side { margin-left: calc(-1 * var(--side-w)); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; padding-right: env(safe-area-inset-right); }
.scrim { display: none; }
/* motion (owner, 2026-10-30: instant changes read as the app jumping by itself) */
:root { --ease-out: cubic-bezier(.32, .72, 0, 1); }
.chip, .icon-btn, .send, .btn { transition: transform .14s var(--ease-out), background .15s, border-color .15s; }
.chip:active, .icon-btn:active, .send:active, .btn:active { transform: scale(.95); }
.chip.bump { animation: bump .36s var(--ease-out); }
.thread.enter .msgs, .thread.enter .empty { animation: rise .26s var(--ease-out) both; }
.dlg[open] { animation: dlg-in .24s var(--ease-out); }
.dlg[open]::backdrop { animation: fade .24s ease-out; }

/* ---------------------------------------------------------------- buttons */
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 10px; background: none; color: var(--ink-2); flex: none; }
.icon-btn:hover { background: var(--hover); }
.icon-btn.mini { width: 26px; height: 26px; border-radius: 8px; color: var(--muted); }
.icon-btn.mini .ic { width: 16px; height: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid transparent; font-size: 14.5px; font-weight: 600; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn .ic { width: 16px; height: 16px; }
.btn.sm { height: 34px; padding: 0 13px; font-size: 13.5px; }
.btn.lg { height: 48px; padding: 0 22px; font-size: 15px; }
.btn.primary, .btn.dark { background: var(--ink); color: #fff; }
.btn.primary:hover, .btn.dark:hover { background: #2b2b2b; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { background: var(--bg-alt); }
.btn.danger { background: var(--red); color: #fff; }
.danger-text { color: var(--red) !important; }

/* ---------------------------------------------------------------- sidebar */
.side-top { display: flex; align-items: center; gap: 2px; padding: 10px 10px 6px; }
.brand { flex: 1; display: flex; align-items: center; gap: 9px; padding: 0 6px; color: var(--ink); text-decoration: none; font-weight: 650; font-size: 15.5px; letter-spacing: -.01em; }
.brand .logo { width: 24px; height: 20px; }
.side-search { display: flex; align-items: center; gap: 8px; height: 38px; margin: 4px 10px 6px; padding: 0 12px; border-radius: 12px; background: #fff; border: 1px solid var(--line); color: var(--muted); }
.side-search .ic { width: 17px; height: 17px; }
.side-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 14.5px; color: var(--ink); }
.side-search input::-webkit-search-cancel-button { opacity: .5; }
.side-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 8px 14px; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 6px 4px 10px; font-size: 12.5px; font-weight: 600; color: var(--muted); border-radius: 10px; }
.side-sub { padding: 12px 10px 3px; font-size: 12px; font-weight: 500; color: var(--muted-2); }
.side-none { margin: 0; padding: 6px 10px; font-size: 13px; color: var(--muted-2); }
.side-none.nested { padding-left: 38px; }
.side-item { display: flex; align-items: center; border-radius: 10px; }
.side-item:hover { background: var(--hover); }
.side-item.active { background: var(--active); }
.side-item.active .side-link { color: var(--ink); font-weight: 550; }
.side-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 4px 0 10px; border: 0; background: none; font-size: 14px; color: var(--ink-2); text-align: left; }
.side-title { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.side-item.nested .side-link { padding-left: 38px; }
.side-item .ic { width: 17px; height: 17px; color: var(--muted); }
.side-item .pin-ic { width: 14px; height: 14px; color: var(--accent); }
.side-more { width: 28px; height: 28px; margin-right: 4px; opacity: 0; color: var(--muted); }
.side-item:hover .side-more, .side-item.active .side-more, .side-more[aria-expanded="true"] { opacity: 1; }
.folder .chev { width: 14px; height: 14px; transition: transform .15s; }
.folder.open .chev { transform: rotate(90deg); }
.count { font-size: 12px; color: var(--muted-2); padding-right: 2px; }
.drop { outline: 2px dashed rgba(108, 92, 255, .5); outline-offset: -2px; background: var(--accent-soft) !important; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; animation: pulse 1.1s ease-in-out infinite; }
.side-foot { border-top: 1px solid var(--line); padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
.side-install { width: 100%; display: flex; align-items: center; gap: 8px; height: 38px; margin-bottom: 6px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--accent-line); background: var(--accent-soft); color: var(--accent-ink); font-size: 14px; font-weight: 600; }
.side-install .ic { width: 18px; height: 18px; }
.acct { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; border-radius: 12px; background: none; text-align: left; }
.acct:hover { background: var(--hover); }
.ava { width: 32px; height: 32px; flex: none; border-radius: 50%; background: radial-gradient(circle at 30% 25%, #ffffff 0 12%, transparent 13%), linear-gradient(135deg, #8b7dff, #6c5cff 45%, #19c9b6); box-shadow: inset 0 0 0 1px rgba(17, 17, 17, .06); }
.ava.lg { width: 44px; height: 44px; }
.acct-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.acct-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-credit { font-size: 12.5px; color: var(--muted); }
.acct-gear { width: 18px; height: 18px; color: var(--muted); }

/* ---------------------------------------------------------------- top bar + banners */
.top { display: flex; align-items: center; gap: 6px; min-height: 56px; padding: env(safe-area-inset-top) 10px 0; flex: none; }
.top-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 0 6px; font-size: 15px; font-weight: 600; }
.top-chat { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.brand-title { color: var(--ink-2); }
.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.crumb .ic { width: 16px; height: 16px; }
.crumb-sep { color: var(--muted-2); }
.env { flex: none; padding: 3px 9px; border-radius: 999px; background: #fef3c7; color: #92400e; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.banners { flex: none; padding: 0 16px; }
.banner { max-width: var(--col); margin: 6px auto 4px; display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 12px; border-radius: 16px; background: var(--accent-soft); border: 1px solid var(--accent-line); }
.banner-ic { width: 34px; height: 34px; flex: none; display: grid; place-items: center; border-radius: 10px; background: #fff; color: var(--accent); border: 1px solid #e4defe; }
.banner-ic .ic { width: 18px; height: 18px; }
.banner-text { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13.5px; line-height: 1.45; color: var(--ink-2); }
.banner-text b { font-size: 14px; color: #2e2578; }
.banner-actions { display: flex; gap: 6px; flex: none; }
.inline-ic { width: 16px; height: 16px; vertical-align: -3px; margin: 0 2px; color: var(--accent); }

/* ---------------------------------------------------------------- thread */
.thread { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; scroll-padding-bottom: 24px; }
.thread.is-empty { display: flex; flex-direction: column; }
.thread.is-empty .msgs { display: none; }
.msgs { max-width: var(--col); margin: 0 auto; padding: 8px 20px 28px; }
.msg { margin: 22px 0; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.bubble { max-width: min(80%, 640px); padding: 10px 16px; border-radius: 22px; background: var(--bg-alt); line-height: 1.55; overflow-wrap: anywhere; }
.bubble-text { white-space: pre-wrap; }
.bubble-files { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 8px; justify-content: flex-end; }
.bubble-files .file-chip { background: #fff; }
.bubble-imgs { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: min(80%, 640px); margin-bottom: 6px; }
.thumb { padding: 0; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--bg-alt); cursor: zoom-in; }
.thumb img { display: block; width: auto; height: auto; max-width: 220px; max-height: 220px; object-fit: cover; }
.bubble-imgs .thumb:not(:only-child) img { width: 120px; height: 120px; }
.lightbox { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); background: rgba(250, 250, 252, .96); cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; box-shadow: var(--shadow-lg); }
.msg.assistant { display: flex; gap: 14px; align-items: flex-start; }
.avatar { width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: #fff; margin-top: 1px; }
.avatar .logo { width: 18px; height: 15px; }
.body { flex: 1; min-width: 0; }
.actions { display: flex; align-items: center; gap: 2px; margin-top: 6px; opacity: 0; transition: opacity .15s; min-height: 30px; }
.msg:hover .actions, .actions.show, .actions:focus-within { opacity: 1; }
.act { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 8px; background: none; color: var(--muted); }
.act:hover { background: var(--hover); color: var(--ink); }
.act .ic { width: 17px; height: 17px; }
.act.done { color: var(--teal); }
.variants { display: inline-flex; align-items: center; font-size: 12.5px; color: var(--muted); }
.variants .act { width: 24px; }
.meta { margin-left: 8px; font-size: 12px; color: var(--muted-2); white-space: nowrap; }
.stopped { margin: 6px 0 0; font-size: 13px; color: var(--muted-2); }
.typing { display: flex; gap: 5px; height: 26px; align-items: center; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); animation: bounce 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
.err { margin-top: 8px; padding: 12px 14px; border-radius: 14px; background: #fff5f5; border: 1px solid #fecaca; color: #991b1b; font-size: 14px; }
.err p { margin: 0 0 10px; }
.err-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.err .btn.ghost { border-color: #fecaca; }
.edit-box { width: 100%; max-width: 640px; padding: 12px 12px 10px 16px; border-radius: 22px; background: var(--bg-alt); }
.edit-area { width: 100%; border: 0; outline: 0; background: none; resize: none; font-size: 16px; line-height: 1.55; }
.edit-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* thinking */
.think { margin: 0 0 10px; }
.think summary { display: inline-flex; align-items: center; gap: 7px; list-style: none; cursor: pointer; padding: 3px 10px 3px 8px; margin-left: -8px; border-radius: 999px; color: var(--muted); font-size: 14px; user-select: none; }
.think summary::-webkit-details-marker { display: none; }
.think summary:hover { background: var(--bg-alt); color: var(--ink-2); }
.think summary .ic { width: 16px; height: 16px; }
.think summary .chev { width: 14px; height: 14px; transition: transform .15s; }
.think[open] summary .chev { transform: rotate(180deg); }
.think.live summary span { background: linear-gradient(90deg, var(--muted-2) 0%, var(--ink) 40%, var(--muted-2) 80%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.6s linear infinite; }
.web-list { margin: 8px 0 4px; padding: 2px 0 2px 14px; border-left: 2px solid var(--line); list-style: none; display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; }
.web-q { color: var(--muted); margin-bottom: 4px; }
.web-link { display: flex; align-items: baseline; gap: 8px; padding: 3px 0; color: var(--ink-2); text-decoration: none; min-width: 0; }
.web-link:hover .web-title { text-decoration: underline; }
.web-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.web-host { flex: none; color: var(--muted-2); font-size: 12.5px; }
.chip .chip-globe { width: 14px; height: 14px; color: var(--accent); margin-left: -2px; }
.pop-switch { position: relative; flex: none; width: 36px; height: 22px; border-radius: 999px; background: #d6d6d2; transition: background .18s; }
.pop-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .18s var(--ease-out); }
.pop-switch.on { background: var(--accent); }
.pop-switch.on::after { transform: translateX(14px); }
.think-text { margin: 8px 0 4px; padding: 2px 0 2px 14px; border-left: 2px solid var(--line); color: var(--muted); font-size: 14px; line-height: 1.6; white-space: pre-wrap; max-height: 45vh; overflow-y: auto; }

/* ---------------------------------------------------------------- markdown */
.md { line-height: 1.7; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 14px; }
.md h2, .md h3, .md h4, .md h5, .md h6 { margin: 22px 0 10px; line-height: 1.35; font-weight: 650; letter-spacing: -.01em; }
.md h2 { font-size: 21px; }
.md h3 { font-size: 18px; }
.md h4 { font-size: 16px; }
.md h5, .md h6 { font-size: 15px; }
.md ul, .md ol { margin: 0 0 14px; padding-left: 24px; }
.md li { margin: 4px 0; }
.md li > ul, .md li > ol { margin: 4px 0; }
.md li.task { list-style: none; margin-left: -22px; }
.md li.task input { margin: 0 6px 0 0; vertical-align: -1px; accent-color: var(--accent); }
.md blockquote { margin: 0 0 14px; padding: 2px 0 2px 16px; border-left: 3px solid var(--accent-line); color: var(--ink-2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.md a { color: var(--accent-ink); text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 3px; }
.md strong { font-weight: 650; }
.md code.icode { display: inline; padding: .12em .38em; border-radius: 6px; background: var(--bg-alt); border: 1px solid var(--line-2); font-family: var(--mono); font-size: .875em; }
.table-wrap { overflow-x: auto; margin: 0 0 16px; border: 1px solid var(--line); border-radius: 12px; }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; }
.md th, .md td { padding: 8px 12px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: top; }
.md th { background: var(--side); font-weight: 600; }
.md tr:last-child td { border-bottom: 0; }
.md .al-center { text-align: center; }
.md .al-right { text-align: right; }
.md.streaming > :last-child::after { content: ""; display: inline-block; width: 9px; height: 9px; margin-left: 4px; border-radius: 50%; background: var(--ink); vertical-align: middle; animation: pulse 1s ease-in-out infinite; }
.md.streaming > .codeblock:last-child::after, .md.streaming > .table-wrap:last-child::after, .md.streaming > ul:last-child::after, .md.streaming > ol:last-child::after { display: none; }

/* code windows: the one dark surface */
.codeblock { margin: 6px 0 16px; border-radius: 14px; overflow: hidden; background: #0f1117; border: 1px solid #1d2130; }
.code-head { display: flex; align-items: center; justify-content: space-between; height: 36px; padding: 0 8px 0 14px; background: #171a24; color: #a3a9b8; font-size: 12.5px; }
.code-head .lang { font-family: var(--mono); text-transform: lowercase; }
.copy-code { height: 26px; padding: 0 10px; border: 0; border-radius: 7px; background: none; color: #c9cedb; font-size: 12.5px; }
.copy-code:hover { background: #242938; color: #fff; }
.copy-code.done { color: #5eead4; }
.codeblock pre { margin: 0; padding: 14px 16px; overflow-x: auto; color: #e6e8ee; font: 13.5px/1.6 var(--mono); tab-size: 2; }
.codeblock code { font: inherit; white-space: pre; }
.tk-kwd { color: #c792ea; }
.tk-str { color: #a5e3a0; }
.tk-cmnt { color: #6b7385; font-style: italic; }
.tk-num, .tk-bool { color: #f9b26b; }
.tk-func { color: #82aaff; }
.tk-type, .tk-class { color: #ffcb6b; }
.tk-oper { color: #89ddff; }
.tk-var { color: #f07178; }
.tk-section { color: #82aaff; font-weight: 600; }
.tk-insert { color: #a5e3a0; }
.tk-deleted, .tk-err { color: #ff8a8a; }
.tk-esc { color: #89ddff; }

/* ---------------------------------------------------------------- empty state */
.empty { margin: auto; width: 100%; max-width: var(--col); padding: 24px 20px; }
.empty-in { display: flex; flex-direction: column; align-items: center; text-align: center; }
.empty-logo { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 18px; background: var(--accent-soft); border: 1px solid #e4defe; margin: 0 auto 18px; }
.empty-logo .logo { width: 34px; height: 28px; }
.empty h1 { margin: 0; font-size: clamp(26px, 4vw, 32px); line-height: 1.2; font-weight: 650; letter-spacing: -.025em; }
.empty p { margin: 10px 0 26px; max-width: 520px; }
.suggs { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.sugg { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--line); background: #fff; text-align: left; transition: background .15s, border-color .15s; }
.sugg:hover { background: var(--side); border-color: #d9d9d4; }
.sugg b { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sugg span { font-size: 13.5px; color: var(--muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; }

/* ---------------------------------------------------------------- composer */
.to-bottom { position: absolute; left: 50%; bottom: 128px; transform: translateX(-50%); width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--ink-2); box-shadow: var(--shadow); z-index: 5; }
.to-bottom .ic { width: 18px; height: 18px; }
.composer-wrap { flex: none; padding: 4px 16px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #fff 18px); }
.composer { max-width: var(--col); margin: 0 auto; padding: 10px 10px 8px 14px; border-radius: 26px; background: #fff; border: 1px solid var(--line); box-shadow: 0 10px 34px -14px rgba(17, 17, 17, .2), 0 1px 2px rgba(17, 17, 17, .04); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: #d6d3ff; box-shadow: 0 10px 34px -14px rgba(74, 59, 214, .28), 0 0 0 4px rgba(108, 92, 255, .08); }
.composer textarea { display: block; width: 100%; min-height: 28px; max-height: 40vh; padding: 4px 4px 8px; border: 0; outline: 0; background: none; resize: none; font-size: 16px; line-height: 1.5; color: var(--ink); }
.composer textarea::placeholder { color: var(--muted-2); }
.tools { display: flex; align-items: center; gap: 6px; }
.tool { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); color: var(--muted); }
.tool .ic { width: 18px; height: 18px; }
.grow { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 9px 0 10px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-size: 13.5px; font-weight: 550; white-space: nowrap; min-width: 0; }
.chip:hover, .chip[aria-expanded="true"] { background: var(--bg-alt); }
.chip .ic { width: 16px; height: 16px; color: var(--muted); }
.chip .chev { width: 14px; height: 14px; }
.chip span { overflow: hidden; text-overflow: ellipsis; }
.chip.hot { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-ink); }
.chip.hot .ic { color: var(--accent); }
.chip.cool { border-color: #b8ebe4; background: #f0fdfa; color: var(--teal); }
.chip.cool .ic { color: var(--teal); }
.send { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--ink); color: #fff; transition: background .15s, transform .1s; }
.send .ic { width: 19px; height: 19px; stroke-width: 2.2; }
.send:disabled { background: #dcdcd8; cursor: default; }
.send:active:not(:disabled) { transform: scale(.94); }
.stop-sq { width: 12px; height: 12px; border-radius: 3px; background: #fff; }
.fine { margin: 8px 0 0; text-align: center; font-size: 12px; color: var(--muted-2); }
.files { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 8px; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 260px; height: 30px; padding: 0 6px 0 10px; border-radius: 10px; background: var(--bg-alt); font-size: 13px; color: var(--ink-2); }
.file-chip span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.file-chip .ic { width: 15px; height: 15px; color: var(--muted); }
.file-chip .x { width: 22px; height: 22px; display: grid; place-items: center; border: 0; border-radius: 6px; background: none; color: var(--muted); }
.file-chip .x:hover { background: var(--hover); }
.file-chip .x .ic { width: 13px; height: 13px; }
.file-thumb { position: relative; width: 56px; height: 56px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--bg-alt); }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-thumb .x { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; display: grid; place-items: center; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .92); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .18); }
.file-thumb .x .ic { width: 12px; height: 12px; }

/* ---------------------------------------------------------------- menus, dialogs, toast */
.pop { position: fixed; z-index: 60; min-width: 230px; max-width: min(330px, calc(100vw - 16px)); max-height: 70vh; overflow-y: auto; padding: 6px; border-radius: 16px; border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow-lg); transform-origin: var(--pop-origin, top left); }
.pop.in { animation: pop-in .2s var(--ease-out) both; }
.pop.out { animation: pop-out .13s ease-in both; pointer-events: none; }
.pop-item.picked, .pop-item.picked:hover { background: var(--accent-soft); }
.pop-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 10px; background: none; text-align: left; font-size: 14px; color: var(--ink); }
.pop-item:hover, .pop-item:focus-visible { background: var(--bg-alt); outline: 0; }
.pop-item .ic { width: 18px; height: 18px; color: var(--muted); }
.pop-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.pop-sub { font-size: 12.5px; color: var(--muted); }
.pop-item.on .pop-label { font-weight: 600; }
.pop-item .pop-check { color: var(--accent); }
.pop-item.danger, .pop-item.danger .ic { color: var(--red); }
.pop-section { padding: 8px 10px 4px; font-size: 12px; font-weight: 600; color: var(--muted-2); }
.pop-sep { height: 1px; margin: 6px 4px; background: var(--line); }
.dlg { width: min(460px, calc(100vw - 24px)); max-height: 88dvh; padding: 0; border: 0; border-radius: 22px; background: #fff; color: var(--ink); box-shadow: var(--shadow-lg); }
.dlg.wide { width: min(620px, calc(100vw - 24px)); }
.dlg.small { width: min(400px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(17, 17, 17, .28); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.dlg-in { display: flex; flex-direction: column; max-height: 88dvh; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 14px 8px 22px; }
.dlg-head h2 { margin: 0; font-size: 18px; line-height: 1.35; font-weight: 650; letter-spacing: -.01em; }
.dlg-head.bare { padding-bottom: 0; }
.confirm-text { margin: 0; font-size: 15.5px; line-height: 1.5; font-weight: 550; }
.dlg-body { padding: 4px 22px 14px; overflow-y: auto; }
.dlg-body:empty { display: none; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 18px 18px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack p { margin: 0; font-size: 14px; }
.field { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 16px; color: var(--ink); outline: 0; }
.field:focus { border-color: #c9c4ff; box-shadow: 0 0 0 4px rgba(108, 92, 255, .1); }
.field.area { min-height: 100px; resize: vertical; line-height: 1.5; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.switch { appearance: none; -webkit-appearance: none; position: relative; width: 44px; height: 26px; flex: none; margin: 0; border-radius: 999px; background: #d6d6d2; cursor: pointer; transition: background .18s; }
.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, .2); transition: transform .18s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }
.settings section { padding: 14px 0; border-top: 1px solid var(--line-2); }
.settings section:first-child { border-top: 0; padding-top: 4px; }
.settings h3 { margin: 0 0 10px; font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.set-text { display: flex; flex-direction: column; line-height: 1.4; }
.set-text b { font-size: 14.5px; font-weight: 550; }
.set-text span { font-size: 13px; color: var(--muted); }
.set-block { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.set-block b { font-size: 14.5px; font-weight: 550; }
.settings .muted.small { display: block; margin-top: 6px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.acct-card { display: flex; align-items: center; gap: 12px; }
.acct-card > div { display: flex; flex-direction: column; line-height: 1.4; }
.toast { position: fixed; left: 50%; bottom: calc(120px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 14px; border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow-lg); font-size: 14px; color: var(--ink); text-align: center; animation: toast .15s ease-out; }

/* ---------------------------------------------------------------- sign in */
.signin { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: max(20px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom)); overflow-y: auto; background: radial-gradient(60% 50% at 20% 10%, rgba(108, 92, 255, .10), transparent 70%), radial-gradient(50% 40% at 90% 90%, rgba(25, 201, 182, .10), transparent 70%), #f7f7fa; }
.signin-card { width: min(420px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 32px 26px 26px; border-radius: 28px; border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow-lg); text-align: center; }
.signin-card .empty-logo { margin-bottom: 4px; }
.signin-card h1 { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 650; letter-spacing: -.02em; }
.signin-card p { margin: 0; }
.signin-card .btn.lg { width: 100%; }
.divider { display: flex; align-items: center; gap: 10px; margin: 6px 0 0; font-size: 12.5px; color: var(--muted-2); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.code-row { display: flex; gap: 8px; }
.field.code { flex: 1; min-width: 0; text-align: center; font-family: var(--mono); font-size: 18px; letter-spacing: .16em; text-transform: uppercase; }
.data-note { margin: 0; font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.data-lead { display: block; margin-bottom: 4px; color: #991b1b; font-weight: 700; }
.signin-msg { min-height: 1.4em; font-size: 13.5px; color: #b91c1c; }

/* ---------------------------------------------------------------- touch screens: actions are always there */
@media (pointer: coarse) {
  .actions { opacity: 1; }
  .side-more { opacity: 1; }
  .side-search input { font-size: 16px; }
}

/* ---------------------------------------------------------------- wide screens */
@media (min-width: 801px) {
  .app:not(.side-collapsed) .open-side, .app:not(.side-collapsed) .top-new { display: none; }
}

/* ---------------------------------------------------------------- phones and small tablets: the sidebar is a drawer */
@media (max-width: 800px) {
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: min(86vw, 320px); margin-left: 0 !important; transform: translateX(-105%); box-shadow: none; }
  .app.side-open .side { transform: none; box-shadow: var(--shadow-lg); }
  .app.side-drag .side { box-shadow: var(--shadow-lg); }
  .app.side-drag .scrim { opacity: .6; transition: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(17, 17, 17, .25); opacity: 0; pointer-events: none; transition: opacity .32s var(--ease-out); }
  .app.side-open .scrim { opacity: 1; pointer-events: auto; }
  #side-toggle { display: none; }
  .top { min-height: 52px; padding-left: 6px; padding-right: 6px; }
  .top-title { justify-content: center; text-align: center; }
  .msgs { padding: 4px 16px 20px; }
  .msg { margin: 18px 0; }
  .bubble { max-width: 86%; }
  .to-bottom { bottom: 118px; }
}
@media (max-width: 640px) {
  .avatar { display: none; }
  .msg.assistant { gap: 0; }
  .fine { display: none; }
  .composer-wrap { padding: 2px 10px calc(8px + env(safe-area-inset-bottom)); }
  .composer { border-radius: 24px; padding: 8px 8px 8px 12px; }
  .chip { padding: 0 10px; gap: 5px; font-size: 13px; }
  .chip .chev { display: none; }
  .tools { gap: 5px; }
  .banners { padding: 0 10px; }
  .banner { gap: 10px; padding: 8px 8px 8px 10px; }
  .banner-ic { display: none; }
  .empty { padding: 16px 0; }
  .empty-in { padding: 0 16px; }
  .empty p { margin-bottom: 20px; }
  /* phones: no suggestion cards (owner, 2026-10-30), just the greeting */
  .suggs { display: none; }
  .dlg, .dlg.wide, .dlg.small { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom); animation: sheet .2s ease-out; }
  .toast { bottom: calc(96px + env(safe-area-inset-bottom)); }
  .meta { display: none; }
}

@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.8); } }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .45; } 40% { transform: translateY(-5px); opacity: 1; } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(var(--pop-dy, -6px)) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes pop-out { to { opacity: 0; transform: scale(.96); } }
@keyframes bump { 0% { transform: scale(.94); } 50% { transform: scale(1.06); box-shadow: 0 0 0 4px var(--accent-line); } 100% { transform: none; box-shadow: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes dlg-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .pop.in, .pop.out, .chip.bump, .thread.enter .msgs, .thread.enter .empty, .dlg[open], .dlg[open]::backdrop { animation: none !important; }
  .side, .scrim, .chip, .icon-btn, .send, .btn { transition: none !important; }
}
@keyframes sheet { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
