/* DebAI26 chat */
:root {
  --bg: #ffffff;
  --side: #f6f6f7;
  --fg: #1d1f24;
  --fg-2: #4a4f59;
  --muted: #7a808c;
  --line: #e6e7ea;
  --line-2: #d6d8dd;
  --hover: #ececef;
  --bubble: #f1f2f4;
  --card: #ffffff;
  --accent: #5146e0;
  --accent-2: #0ea5a3;
  --accent-soft: #ecebfd;
  --accent-fg: #ffffff;
  --danger: #c23a1c;
  --danger-soft: #fdecea;
  --code-bg: #f6f7f9;
  --code-head: #eceef2;
  --tk-k: #7c3aed;
  --tk-s: #0b7a53;
  --tk-n: #b45309;
  --tk-c: #8a919c;
  --shadow: 0 1px 2px rgba(16, 18, 24, .06), 0 8px 24px rgba(16, 18, 24, .08);
  --shadow-lg: 0 12px 48px rgba(16, 18, 24, .18);
  --radius: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17181b; --side: #111214; --fg: #e9eaed; --fg-2: #c1c5cd; --muted: #8d939e; --line: #2a2c31;
    --line-2: #383b42; --hover: #24262b; --bubble: #26282d; --card: #1e1f23; --accent: #8c86ff; --accent-2: #2dd4bf;
    --accent-soft: #2a2850; --accent-fg: #101015; --danger: #ff8a70; --danger-soft: #3a1f19; --code-bg: #0f1012;
    --code-head: #1b1c20; --tk-k: #c4a5ff; --tk-s: #7ee2b8; --tk-n: #f5b971; --tk-c: #6f7682;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35); --shadow-lg: 0 12px 48px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17181b; --side: #111214; --fg: #e9eaed; --fg-2: #c1c5cd; --muted: #8d939e; --line: #2a2c31;
  --line-2: #383b42; --hover: #24262b; --bubble: #26282d; --card: #1e1f23; --accent: #8c86ff; --accent-2: #2dd4bf;
  --accent-soft: #2a2850; --accent-fg: #101015; --danger: #ff8a70; --danger-soft: #3a1f19; --code-bg: #0f1012;
  --code-head: #1b1c20; --tk-k: #c4a5ff; --tk-s: #7ee2b8; --tk-n: #f5b971; --tk-c: #6f7682;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35); --shadow-lg: 0 12px 48px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font: 15.5px/1.6 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent); }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

/* ---------- logo */
.logo { width: 28px; height: 28px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, #6d5dfc 0%, #3b82f6 55%, #14b8a6 100%); color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15); }
.logo svg { width: 17px; height: 17px; fill: #fff; stroke: none; }
.logo.big { width: 52px; height: 52px; border-radius: 16px; }
.logo.big svg { width: 30px; height: 30px; }

/* ---------- login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 60%), var(--bg); overflow: auto; }
.login-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 32px 28px 26px; box-shadow: var(--shadow); text-align: center; }
.login-card h1 { font-size: 1.35rem; margin: 16px 0 4px; letter-spacing: -.01em; }
.login-card .sub { color: var(--muted); margin: 0 0 24px; font-size: .95rem; }
.login-card form { text-align: left; }
.login-card label { display: block; font-size: .85rem; font-weight: 600; color: var(--fg-2); margin: 0 0 6px; }
.field { width: 100%; padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--bg);
  font-size: 16px; transition: border-color .15s, box-shadow .15s; }
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.field.code { font: 600 1.6rem/1 var(--mono); letter-spacing: .45em; text-align: center; padding: 14px 8px 14px 20px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 14px;
  padding: 12px 16px; border-radius: 12px; background: var(--fg); color: var(--bg); font-weight: 600;
  transition: opacity .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: default; }
.link { color: var(--fg-2); text-decoration: underline; text-underline-offset: 3px; font-size: .9rem; }
.login-card .note { color: var(--muted); font-size: .88rem; margin: 14px 0 0; text-align: center; }
.login-card .error { color: var(--danger); font-size: .9rem; margin: 10px 0 0; min-height: 1.2em; }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 272px minmax(0, 1fr); height: 100dvh; }
.shell.side-closed { grid-template-columns: 0 minmax(0, 1fr); }
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  min-width: 0; overflow: hidden; }
.shell.side-closed .side { border-right: 0; }
.side-top { display: flex; align-items: center; gap: 8px; padding: 14px 12px 10px 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--fg); font-weight: 650;
  font-size: 1.02rem; letter-spacing: -.01em; flex: 1; min-width: 0; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: var(--fg-2); flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--fg); }
.new-chat { display: flex; align-items: center; gap: 10px; margin: 4px 10px 8px; padding: 9px 12px; border-radius: 11px;
  border: 1px solid var(--line-2); background: var(--card); font-weight: 560; box-shadow: 0 1px 1px rgba(0, 0, 0, .03); }
.new-chat:hover { border-color: var(--accent); }
.new-chat kbd { margin-left: auto; font: 11px var(--mono); color: var(--muted); }
.search { display: flex; align-items: center; gap: 8px; margin: 0 10px 6px; padding: 0 10px; border-radius: 10px;
  color: var(--muted); }
.search:focus-within { background: var(--card); box-shadow: inset 0 0 0 1px var(--line-2); }
.search input { flex: 1; min-width: 0; border: 0; background: none; padding: 8px 0; outline: none; color: var(--fg); }
.search svg { width: 17px; height: 17px; }
.chat-list { flex: 1; overflow-y: auto; padding: 2px 8px 12px; scrollbar-width: thin; }
.group-h { font-size: .74rem; font-weight: 600; color: var(--muted); padding: 14px 10px 4px; letter-spacing: .02em; }
.chat-item { position: relative; display: flex; align-items: center; border-radius: 10px; }
.chat-item a { flex: 1; min-width: 0; padding: 8px 10px; color: var(--fg); text-decoration: none; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; font-size: .93rem; border-radius: 10px; }
.chat-item:hover, .chat-item.on { background: var(--hover); }
.chat-item.on a { font-weight: 560; }
.chat-item .row-acts { display: none; gap: 2px; padding-right: 4px; }
.chat-item:hover .row-acts, .chat-item.on .row-acts, .chat-item:focus-within .row-acts { display: flex; }
.row-acts button { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); }
.row-acts button:hover { color: var(--fg); background: var(--line); }
.row-acts svg { width: 16px; height: 16px; }
.chat-item input { flex: 1; min-width: 0; margin: 2px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--card); outline: none; font-size: .93rem; }
.list-empty { color: var(--muted); font-size: .9rem; padding: 16px 10px; }
.side-bottom { border-top: 1px solid var(--line); padding: 8px; display: grid; gap: 2px; }
.side-link, .user-btn { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px;
  width: 100%; text-align: left; font-size: .93rem; }
.side-link:hover, .user-btn:hover, .side-link.on { background: var(--hover); }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem;
  font-weight: 700; background: var(--accent-soft); color: var(--accent); flex: none; }
.user-btn .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scrim { display: none; }

/* ---------- main */
.main { position: relative; display: flex; flex-direction: column; min-width: 0; height: 100dvh; }
.top { display: flex; align-items: center; gap: 8px; padding: 10px 14px; min-height: 56px; }
.top-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: .98rem; }
.model-badge { display: inline-flex; align-items: center; gap: 7px; font-size: .8rem; color: var(--muted);
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.model-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
.scroller { flex: 1; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: auto; }
.thread { max-width: 780px; margin: 0 auto; padding: 8px 20px 24px; }
.thread.full { min-height: 100%; display: flex; flex-direction: column; }
.thread.full .hello { flex: 1; }
.login-card .logo { margin: 0 auto; }

/* ---------- empty state */
.hello { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 6vh 0 2vh; }
.hello h2 { font-size: 1.75rem; letter-spacing: -.02em; margin: 18px 0 4px; font-weight: 650; }
.hello p { color: var(--muted); margin: 0 0 26px; }
.ideas { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 620px; }
.idea { text-align: left; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--card);
  transition: border-color .15s, transform .15s, box-shadow .15s; display: flex; gap: 12px; align-items: flex-start; }
.idea:hover { border-color: var(--line-2); box-shadow: var(--shadow); transform: translateY(-1px); }
.idea .ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft);
  color: var(--accent); flex: none; }
.idea .ic svg { width: 18px; height: 18px; }
.idea b { display: block; font-weight: 600; font-size: .94rem; }
.idea span { display: block; color: var(--muted); font-size: .86rem; line-height: 1.4; margin-top: 2px; }

/* ---------- messages */
.msg { margin: 22px 0; animation: rise .25s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .bubble { max-width: min(85%, 640px); background: var(--bubble); padding: 10px 16px; border-radius: 20px;
  border-bottom-right-radius: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user .shots { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-bottom: 6px; }
.msg.user .shots img { height: 120px; max-width: 220px; object-fit: cover; border-radius: 14px; cursor: zoom-in;
  border: 1px solid var(--line); background: var(--bubble); }
.msg.user .tags { display: flex; gap: 6px; margin-bottom: 4px; }
.tag { font-size: .74rem; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px;
  display: inline-flex; gap: 4px; align-items: center; }
.tag svg { width: 12px; height: 12px; }
.msg .acts { display: flex; gap: 2px; margin-top: 4px; opacity: 0; transition: opacity .15s; align-items: center; }
.msg:hover .acts, .msg:focus-within .acts, .msg.last .acts { opacity: 1; }
.acts button { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; color: var(--muted); }
.acts button:hover { background: var(--hover); color: var(--fg); }
.acts button.on { color: var(--accent); }
.acts svg { width: 17px; height: 17px; }
.acts .meta { font-size: .76rem; color: var(--muted); margin-left: 6px; }
.edit-box { width: min(100%, 640px); background: var(--bubble); border-radius: 18px; padding: 10px; }
.edit-box textarea { width: 100%; border: 0; background: none; resize: none; outline: none; min-height: 60px; font-size: 15.5px; }
.edit-box .row { display: flex; justify-content: flex-end; gap: 8px; }
.pill { padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: .88rem; border: 1px solid var(--line-2); background: var(--card); }
.pill.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* assistant text */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .85em; }
.md h2, .md h3, .md h4, .md h5, .md h6 { margin: 1.3em 0 .5em; line-height: 1.3; letter-spacing: -.01em; }
.md h2 { font-size: 1.32rem; } .md h3 { font-size: 1.15rem; } .md h4, .md h5, .md h6 { font-size: 1rem; }
.md ul, .md ol { margin: 0 0 .9em; padding-left: 1.5em; }
.md li { margin: .25em 0; }
.md li > ul, .md li > ol { margin: .25em 0; }
.md li::marker { color: var(--muted); }
.md blockquote { margin: 0 0 .9em; padding: 2px 0 2px 14px; border-left: 3px solid var(--line-2); color: var(--fg-2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.4em 0; }
.md code { font: .88em/1.5 var(--mono); background: var(--bubble); padding: .12em .38em; border-radius: 6px; }
.md a { text-underline-offset: 3px; }
.md .task { display: inline-block; width: 14px; height: 14px; border: 1.5px solid var(--muted); border-radius: 4px;
  margin-right: 8px; vertical-align: -2px; }
.md .task.done { background: var(--accent); border-color: var(--accent); }
.code { margin: 0 0 1em; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--code-bg); }
.code-h { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 6px 14px;
  background: var(--code-head); font: 12px var(--mono); color: var(--muted); }
.code-copy { font: 600 12px var(--font); color: var(--fg-2); padding: 4px 10px; border-radius: 7px; }
.code-copy:hover { background: var(--hover); color: var(--fg); }
.code pre { margin: 0; padding: 14px 16px; overflow-x: auto; font: 13.5px/1.6 var(--mono); tab-size: 4; }
.code pre code { background: none; padding: 0; font: inherit; }
.tk-k { color: var(--tk-k); } .tk-s { color: var(--tk-s); } .tk-n { color: var(--tk-n); } .tk-c { color: var(--tk-c); font-style: italic; }
.table { overflow-x: auto; margin: 0 0 1em; border: 1px solid var(--line); border-radius: 12px; }
.table table { border-collapse: collapse; width: 100%; font-size: .93rem; }
.table th, .table td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { background: var(--side); font-weight: 600; }
.table tr:last-child td { border-bottom: 0; }
.table .al-right { text-align: right; } .table .al-center { text-align: center; }
.msg.streaming .md > :last-child::after, .msg.streaming .md:empty::after {
  content: ""; display: inline-block; width: 9px; height: 9px; margin-left: 4px; border-radius: 50%;
  background: var(--fg); vertical-align: middle; animation: blink 1s ease-in-out infinite; }
.msg.streaming .md > .code:last-child::after, .msg.streaming .md > .table:last-child::after { display: none; }
@keyframes blink { 50% { opacity: .25; transform: scale(.8); } }
.err { display: flex; gap: 10px; align-items: center; color: var(--danger); background: var(--danger-soft);
  padding: 10px 14px; border-radius: 12px; font-size: .92rem; margin-top: 6px; }
.err button { margin-left: auto; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.stopped { color: var(--muted); font-size: .86rem; margin-top: 4px; }

/* thinking */
.think { margin: 0 0 12px; }
.think summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--muted);
  font-size: .9rem; padding: 3px 0; user-select: none; }
.think summary::-webkit-details-marker { display: none; }
.think summary svg { width: 15px; height: 15px; transition: transform .2s; }
.think[open] summary svg.chev { transform: rotate(180deg); }
.think summary .live { background: linear-gradient(90deg, var(--muted) 0%, var(--fg) 50%, var(--muted) 100%);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shine 1.6s linear infinite; }
@keyframes shine { to { background-position: -200% 0; } }
.think-body { margin: 6px 0 0 3px; padding: 2px 0 2px 14px; border-left: 2px solid var(--line-2); color: var(--muted);
  font-size: .9rem; white-space: pre-wrap; max-height: 320px; overflow-y: auto; }

/* pictures */
.pic { margin: 0 0 12px; width: min(100%, var(--pw, 520px)); }
.pic .frame { position: relative; border-radius: 16px; overflow: hidden; background: var(--bubble);
  aspect-ratio: var(--ar, 1); border: 1px solid var(--line); }
.pic img { display: block; width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.pic .wait { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; padding: 16px;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .22) 50%, transparent 70%),
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 22%, var(--bubble)), color-mix(in srgb, var(--accent-2) 18%, var(--bubble)));
  background-size: 250% 100%, 100% 100%; animation: sweep 2.2s linear infinite; }
@keyframes sweep { from { background-position: 150% 0, 0 0; } to { background-position: -100% 0, 0 0; } }
.pic .note { font-size: .88rem; color: var(--fg); font-weight: 500; margin-bottom: 8px; text-shadow: 0 1px 0 rgba(255,255,255,.2); }
.bar { height: 6px; border-radius: 999px; background: rgba(127, 127, 140, .25); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--accent); transition: width .6s ease; }
.pic .cap { display: flex; gap: 2px; align-items: center; margin-top: 6px; }
.pic .cap button, .pic .cap a { display: inline-flex; gap: 6px; align-items: center; font-size: .84rem; color: var(--fg-2);
  padding: 6px 10px; border-radius: 9px; text-decoration: none; }
.pic .cap button:hover, .pic .cap a:hover { background: var(--hover); color: var(--fg); }
.pic .cap > :first-child { margin-left: -10px; }
.shell:not(.side-closed) #sideOpen { display: none; }
.pic .cap svg { width: 16px; height: 16px; }
.pic .fail.quiet { color: var(--muted); background: var(--bubble); }
.pic .fail { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center;
  color: var(--danger); font-size: .92rem; background: var(--danger-soft); }
.pic .prompt { font-size: .82rem; color: var(--muted); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- composer */
.composer-wrap { padding: 0 16px calc(10px + env(safe-area-inset-bottom)); }
.composer { max-width: 780px; margin: 0 auto; background: var(--card); border: 1px solid var(--line-2); border-radius: 24px;
  box-shadow: var(--shadow); padding: 10px 10px 8px 14px; transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--line-2)); }
.composer.drop { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.composer textarea { display: block; width: 100%; border: 0; outline: none; resize: none; background: none;
  padding: 6px 4px; max-height: 40dvh; min-height: 28px; font-size: 16px; line-height: 1.5; }
.composer textarea::placeholder { color: var(--muted); }
.tools { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.tools .grow { flex: 1; }
.tool { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: var(--fg-2); }
.tool:hover { background: var(--hover); color: var(--fg); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--fg-2); font-size: .86rem; font-weight: 550; transition: all .15s; }
.chip svg { width: 17px; height: 17px; }
.chip:hover { background: var(--hover); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.send { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--fg);
  color: var(--bg); transition: opacity .15s, transform .1s; }
.send:disabled { opacity: .25; cursor: default; }
.send:not(:disabled):active { transform: scale(.94); }
.send svg { width: 19px; height: 19px; stroke-width: 2.2; }
.send.stop svg { fill: currentColor; stroke: none; width: 14px; height: 14px; }
.mic.rec { background: var(--danger); color: #fff; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 45%, transparent); }
  50% { box-shadow: 0 0 0 7px transparent; } }
.rec-time { font: 600 .84rem var(--mono); color: var(--danger); margin-right: 4px; }
.attachments { display: flex; gap: 8px; flex-wrap: wrap; padding: 2px 0 8px; }
.attachments:empty { display: none; }
.att { position: relative; width: 64px; height: 64px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line);
  background: var(--bubble); }
.att img { width: 100%; height: 100%; object-fit: cover; }
.att .busy { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .35); color: #fff; }
.att.bad { outline: 2px solid var(--danger); }
.att .x { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: rgba(0, 0, 0, .65);
  color: #fff; display: grid; place-items: center; }
.att .x svg { width: 12px; height: 12px; stroke-width: 2.4; }
.foot { text-align: center; color: var(--muted); font-size: .75rem; padding: 7px 0 0; }
.to-bottom { position: absolute; left: 50%; transform: translateX(-50%); bottom: 150px; width: 36px; height: 36px;
  border-radius: 50%; background: var(--card); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  display: grid; place-items: center; color: var(--fg-2); z-index: 5; }
.to-bottom svg { width: 18px; height: 18px; }

/* ---------- gallery */
.gallery-h { display: flex; align-items: baseline; gap: 10px; margin: 8px 0 16px; }
.gallery-h h2 { margin: 0; font-size: 1.4rem; letter-spacing: -.01em; }
.gallery-h span { color: var(--muted); font-size: .9rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.grid button { aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--bubble); border: 1px solid var(--line); }
.grid img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s; }
.grid button:hover img { transform: scale(1.04); }
.empty-note { color: var(--muted); text-align: center; padding: 60px 0; }

/* ---------- lightbox, popover, toast */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(8, 9, 12, .92); display: flex; flex-direction: column;
  animation: fade .15s ease both; }
@keyframes fade { from { opacity: 0; } }
.lightbox .lb-top { display: flex; gap: 6px; justify-content: flex-end; padding: 12px; }
.lightbox .lb-top button, .lightbox .lb-top a { display: inline-flex; gap: 8px; align-items: center; color: #fff; padding: 8px 12px;
  border-radius: 10px; background: rgba(255, 255, 255, .1); font-size: .9rem; text-decoration: none; }
.lightbox .lb-top button:hover, .lightbox .lb-top a:hover { background: rgba(255, 255, 255, .2); }
.lightbox .lb-img { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 12px 12px; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }
.lightbox .lb-cap { color: rgba(255, 255, 255, .75); font-size: .88rem; text-align: center; padding: 0 20px 18px;
  max-width: 900px; margin: 0 auto; }
.popover { position: fixed; z-index: 40; min-width: 240px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; animation: rise .15s ease both; }
.popover .pop-h { padding: 8px 10px 6px; font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.popover button.item { display: flex; gap: 10px; align-items: center; width: 100%; padding: 9px 10px; border-radius: 9px;
  text-align: left; font-size: .93rem; }
.popover button.item:hover { background: var(--hover); }
.popover button.item svg { width: 18px; height: 18px; color: var(--fg-2); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; margin: 2px 4px 6px; padding: 3px;
  background: var(--side); border-radius: 10px; }
.seg button { padding: 6px; border-radius: 8px; font-size: .84rem; color: var(--fg-2); }
.seg button.on { background: var(--card); color: var(--fg); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); font-weight: 600; }
.sep { height: 1px; background: var(--line); margin: 4px 6px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px;
  pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
#toast div { background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow-lg);
  font-size: .92rem; animation: rise .2s ease both; text-align: center; }

/* ---------- private chat */
.priv-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--fg-2); font-size: .84rem; font-weight: 560; white-space: nowrap; flex: none; }
.priv-btn:hover { background: var(--hover); color: var(--fg); }
.priv-btn svg { width: 16px; height: 16px; }
.priv-btn[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.composer.private { border-style: dashed; border-color: var(--fg-2); }
.priv-note { display: flex; gap: 8px; align-items: center; justify-content: center; color: var(--muted);
  font-size: .82rem; margin: 6px 0 0; }
.priv-note svg { width: 15px; height: 15px; }
.priv-logo { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--fg);
  color: var(--bg); }
.priv-logo svg { width: 28px; height: 28px; }
.hello.private p { max-width: 420px; line-height: 1.55; }

/* ---------- read answers aloud + voice mode */
.tool[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.send.talk svg { width: 20px; height: 20px; stroke-width: 2.2; }
.voice { position: fixed; inset: 0; z-index: 45; display: flex; flex-direction: column; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px calc(22px + env(safe-area-inset-bottom));
  background: radial-gradient(70vmax 55vmax at 50% 40%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 70%), var(--bg);
  animation: fade .2s ease both; overflow: hidden; }
.v-top { width: 100%; max-width: 780px; display: flex; align-items: center; gap: 10px; min-height: 44px; }
.v-title { font-weight: 650; letter-spacing: -.01em; }
.v-top .grow { flex: 1; }
.v-cc { font: 700 .74rem var(--font); letter-spacing: .06em; padding: 5px 9px; border-radius: 8px;
  border: 1.5px solid var(--line-2); color: var(--muted); }
.v-cc[aria-pressed="true"] { color: var(--fg); border-color: var(--fg-2); }
.v-mid { flex: 1; min-height: 0; width: 100%; max-width: 620px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 22px; }
.orb { --lvl: 0; position: relative; flex: none; width: min(56vw, 30vh, 230px); aspect-ratio: 1; border-radius: 50%;
  transform: scale(calc(.94 + var(--lvl) * .34)); transition: transform 80ms linear, filter .4s, opacity .4s; }
.orb .core { position: absolute; inset: 0; border-radius: 50%; animation: breathe 3.4s ease-in-out infinite; }
.orb .core::before, .orb .core::after { content: ""; position: absolute; inset: 0; border-radius: 50%; }
.orb .core::before {
  background: radial-gradient(circle at 34% 28%, #ffffff 0, #c7d2fe 13%, #818cf8 36%, #4f46e5 60%, #1e1b4b 100%);
  box-shadow: 0 0 calc(34px + var(--lvl) * 80px) color-mix(in srgb, #6366f1 55%, transparent),
    inset 0 -22px 46px rgba(20, 184, 166, .42), inset 0 10px 30px rgba(255, 255, 255, .25); }
.orb .core::after { background: conic-gradient(from 0deg, transparent 0, rgba(45, 212, 191, .45) 18%, transparent 36%,
    rgba(255, 255, 255, .28) 58%, transparent 76%); mix-blend-mode: screen; filter: blur(9px); animation: swirl 8s linear infinite; }
@keyframes breathe { 50% { transform: scale(.965); } }
@keyframes swirl { to { transform: rotate(360deg); } }
.voice[data-state="hear"] .orb { filter: saturate(1.25) brightness(1.08); }
.voice[data-state="think"] .orb .core { animation: think 1.3s ease-in-out infinite; }
.voice[data-state="think"] .orb .core::after { animation-duration: 2.2s; }
@keyframes think { 50% { transform: scale(.86); opacity: .82; } }
.voice[data-state="start"] .orb, .voice[data-state="pause"] .orb, .voice[data-state="error"] .orb,
.voice.muted:not([data-state="speak"]) .orb { filter: grayscale(.85); opacity: .5; }
.v-status { color: var(--fg-2); font-size: 1rem; min-height: 1.6em; text-align: center; font-weight: 500; }
.v-cap { display: none; width: 100%; text-align: center; }
.voice.cc .v-cap { display: grid; gap: 10px; }
.v-cap p { margin: 0; overflow-wrap: anywhere; }
.v-cap p:empty { display: none; }
.v-cap .you { color: var(--muted); font-size: .95rem; }
.v-cap .ai { color: var(--fg); font-size: 1.1rem; line-height: 1.5; }
.v-pic .pic { margin: 0 auto; }
.v-pic .note { font-size: .82rem; }
.v-bottom { display: flex; gap: 32px; justify-content: center; align-items: center; padding-top: 10px; }
.v-btn { width: 62px; height: 62px; border-radius: 50%; display: grid; place-items: center; background: var(--hover);
  color: var(--fg); transition: background .15s, transform .1s; }
.v-btn:active { transform: scale(.94); }
.v-btn svg { width: 26px; height: 26px; }
.v-btn[aria-pressed="true"] { background: var(--danger); color: #fff; }
.v-btn.end { background: var(--fg); color: var(--bg); }
@media (max-height: 560px) { .v-mid { gap: 12px; } .v-pic { display: none; } }

/* ---------- phone */
@media (max-width: 860px) {
  .shell, .shell.side-closed { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; z-index: 30; inset: 0 auto 0 0; width: min(86vw, 320px); transform: translateX(-102%);
    transition: transform .22s ease; box-shadow: var(--shadow-lg); border-right: 0; }
  .shell.side-open .side { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .35); opacity: 0;
    pointer-events: none; transition: opacity .2s; }
  .shell.side-open .scrim { opacity: 1; pointer-events: auto; }
  .hide-phone { display: none !important; }
  .thread { padding: 4px 16px 20px; }
  .top { padding: 8px 8px 8px 8px; min-height: 52px; }
  .model-badge { font-size: .74rem; padding: 4px 9px; }
  .ideas { grid-template-columns: 1fr; }
  .idea:nth-child(n+3) { display: none; }
  .hello h2 { font-size: 1.45rem; }
  .composer-wrap { padding: 0 10px calc(8px + env(safe-area-inset-bottom)); }
  .chip .lbl { display: none; }
  .chip[aria-pressed="true"] .lbl { display: inline; }   /* switched on: say what it is */
  .chip { padding: 0 10px; }
  .msg .acts { opacity: 1; }
  .row-acts { display: flex !important; }
  .chat-item .row-acts button:not(.keep) { display: none; }
  .chat-item.on .row-acts button { display: grid; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
}
@media (min-width: 861px) { .hide-desktop { display: none !important; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
