/* Cloudless: a calm, warm chat UI. Light "parchment" and dark "warm grey" themes. */

@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 200 900; font-display: swap; src: url("../vendor/fonts/source-serif-4.woff2") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-style: italic; font-weight: 200 900; font-display: swap; src: url("../vendor/fonts/source-serif-4-italic.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("../vendor/fonts/inter.woff2") format("woff2"); }

:root {
  --bg: #faf9f5;
  --side: #f5f4ee;
  --surface: #ffffff;
  --raised: #f0eee6;
  --hover: #ebe9e0;
  --line: #e5e2d8;
  --line-strong: #d6d2c4;
  --text: #141413;
  --text-2: #3d3d3a;
  --muted: #64635d;
  --accent-text: #a24c31; /* accent for text on --accent-soft: 4.5:1 or more */
  --accent: #c96442;
  --accent-hover: #b5573a;
  --accent-soft: #f4e3dc;
  --on-accent: #ffffff;
  --accent-btn: #b5573a; --accent-btn-hover: #a24c31; /* filled buttons: white text at 4.5:1 or more */
  --code-bg: #f3f1ea;
  --shadow: 0 1px 2px rgba(20, 20, 19, .04), 0 4px 18px rgba(20, 20, 19, .06);
  --serif: "Source Serif 4", "Source Serif Pro", Charter, "Iowan Old Style", Georgia, Cambria, "Times New Roman", serif;
  --sans: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --radius: 20px;
  --side-w: 288px;
  --col: 768px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #262624; --side: #1f1e1d; --surface: #30302e; --raised: #141413; --hover: #2f2e2c;
    --line: #3a3936; --line-strong: #4a4845; --text: #faf9f5; --text-2: #e5e3da; --muted: #a6a39a;
    --accent: #d97757; --accent-hover: #e0876a; --accent-soft: #3d2b24; --on-accent: #1c1310; --accent-text: #e8957a; --accent-btn: #d97757; --accent-btn-hover: #e0876a;
    --code-bg: #1d1c1b; --shadow: 0 1px 2px rgba(0,0,0,.25), 0 6px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #262624; --side: #1f1e1d; --surface: #30302e; --raised: #141413; --hover: #2f2e2c;
  --line: #3a3936; --line-strong: #4a4845; --text: #faf9f5; --text-2: #e5e3da; --muted: #a6a39a;
  --accent: #d97757; --accent-hover: #e0876a; --accent-soft: #3d2b24; --on-accent: #1c1310; --accent-text: #e8957a; --accent-btn: #d97757; --accent-btn-hover: #e0876a;
  --code-bg: #1d1c1b; --shadow: 0 1px 2px rgba(0,0,0,.25), 0 6px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased; overflow: hidden; font-feature-settings: "cv11", "ss01";
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: flex; height: 100dvh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--side-w); flex: none; background: var(--side); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 10px 8px; gap: 6px;
  transition: margin-left .22s ease, transform .22s ease;
}
.app.preload .sidebar { transition: none; }
/* Collapsed on desktop: a slim icon rail instead of hiding completely. */
.sidebar { transition: width .22s ease, transform .22s ease; overflow: hidden; }
.app.side-closed .sidebar { width: 60px; }
.app.side-closed .brand, .app.side-closed .new-chat .label, .app.side-closed .chat-list,
.app.side-closed .user-meta, .app.side-closed .gear, .app.side-closed .side-search input, .app.side-closed .nav-link .label { display: none; }
.app.side-closed .side-top { justify-content: center; padding-left: 0; padding-right: 0; }
.app.side-closed .new-chat, .app.side-closed .user-btn, .app.side-closed .side-search, .app.side-closed .nav-link { justify-content: center; padding-left: 0; padding-right: 0; }
.app.side-closed .side-search { cursor: pointer; border-color: transparent; background: transparent; }
.app.side-closed .side-foot { border-top-color: transparent; }
.side-search {
  display: flex; align-items: center; gap: 8px; margin: 2px 0; padding: 7px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted);
}
.side-search:focus-within { border-color: var(--line-strong); }
.side-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: 14px var(--sans); }
.side-search:hover { color: var(--text); }
.search-hit { font-size: 12px; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; }
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 2px 4px 6px 8px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.brand-logo { width: 26px; height: 26px; border-radius: 7px; display: block; }
:root[data-theme="dark"] .brand-logo { box-shadow: 0 0 0 1px var(--line-strong); } /* keeps the dark icon visible on the dark sidebar */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-logo { box-shadow: 0 0 0 1px var(--line-strong); } }
.brand-name { font: 600 20px/1 var(--serif); letter-spacing: -.01em; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  border: 0; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

.new-chat {
  display: flex; align-items: center; gap: 10px; border: 0; background: transparent; border-radius: 10px;
  padding: 8px 10px; font-weight: 500; color: var(--text); text-align: left;
}
.new-chat:hover { background: var(--hover); }
.plus-dot { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; /* icon: 3:1 is enough */ }
.plus-dot svg { width: 15px; height: 15px; stroke-width: 2.4; }

.chat-list { flex: 1; overflow-y: auto; padding: 6px 0; scrollbar-width: thin; }
.group-label { font-size: 12px; color: var(--muted); padding: 14px 10px 4px; font-weight: 500; }
.chat-item {
  position: relative; display: flex; align-items: center; border-radius: 9px; margin: 1px 0;
}
.chat-item > .open {
  flex: 1; min-width: 0; border: 0; background: transparent; text-align: left; padding: 7px 34px 7px 10px;
  border-radius: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; color: var(--text-2);
}
.chat-item:hover > .open, .chat-item.active > .open { background: var(--hover); color: var(--text); }
.chat-item.active > .open { font-weight: 500; }
.chat-item .more {
  position: absolute; right: 4px; width: 28px; height: 28px; opacity: 0; border-radius: 7px;
}
.chat-item:hover .more, .chat-item.active .more, .chat-item .more:focus-visible { opacity: 1; }
.chat-item .rename-input {
  flex: 1; font: inherit; font-size: 14px; padding: 6px 9px; border-radius: 9px; border: 1px solid var(--accent);
  background: var(--surface); color: var(--text); outline: none;
}
.item-menu {
  position: absolute; right: 4px; top: 32px; z-index: 30; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 4px; min-width: 150px;
}
.item-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; border: 0; background: transparent;
  padding: 8px 10px; border-radius: 8px; font-size: 14px; text-align: left;
}
.item-menu button:hover { background: var(--hover); }
.item-menu .del { color: #c2412d; }
.empty-list { color: var(--muted); font-size: 13px; padding: 12px 10px; }

.side-foot { border-top: 1px solid var(--line); padding-top: 8px; }
.user-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent;
  padding: 8px; border-radius: 10px; text-align: left;
}
.user-btn:hover { background: var(--hover); }
.user-meta { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.user-name { font-weight: 500; font-size: 14px; }
.user-plan { font-size: 12px; color: var(--muted); }
.gear { color: var(--muted); }
.avatar {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex: none;
  object-fit: cover; box-shadow: 0 0 0 1px var(--line);
}
.avatar.sm { width: 26px; height: 26px; font-size: 12px; }

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.topbar { display: flex; align-items: center; gap: 4px; padding: 8px 12px; min-height: 52px; }
.topbar #side-open, .topbar #new-chat-top { display: none; }
.chat-title {
  flex: 1; min-width: 0; margin: 0 0 0 6px; font: 500 15px/1.3 var(--sans); color: var(--text-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.privacy-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; white-space: nowrap;
}
.privacy-pill svg { width: 13px; height: 13px; }

.thread { flex: 1; overflow-y: auto; scroll-behavior: smooth; padding: 0 20px; }
.messages { max-width: var(--col); margin: 0 auto; padding: 18px 0 32px; display: flex; flex-direction: column; gap: 22px; }

/* Start screen */
.main.empty .messages, .main.empty .dock { display: none; }
.main:not(.empty) .hero { display: none; }
.hero {
  min-height: 100%; display: flex; flex-direction: column; justify-content: center; align-items: center;
  max-width: var(--col); margin: 0 auto; padding: 0 0 12vh;
}
.greeting {
  display: flex; flex-direction: column; align-items: center; gap: 12px; margin: 0 0 28px; /* the logo mark sits centred above the text */
  font: 400 clamp(26px, 3.5vw, 40px)/1.2 var(--serif); letter-spacing: -.02em; color: var(--text-2); text-align: center; text-wrap: balance;
}
.spark { width: 58px; height: 38px; flex: none; background: url("../assets/mark.svg") center / contain no-repeat; }
:root[data-theme="dark"] .spark { background-image: url("../assets/mark-dark.svg"); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .spark { background-image: url("../assets/mark-dark.svg"); } }
.hero-slot { width: 100%; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text-2); font-size: 14px;
}
.chip:hover { background: var(--hover); color: var(--text); }
.chip svg { width: 16px; height: 16px; color: var(--muted); }

/* Composer */
.dock { padding: 0 20px 10px; }
.composer {
  max-width: var(--col); margin: 0 auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 14px 10px 18px;
  transition: border-color .15s;
}
.composer:focus-within { border-color: var(--line-strong); }
.composer textarea {
  display: block; width: 100%; border: 0; outline: 0; resize: none; background: transparent; color: var(--text);
  font: 16px/1.5 var(--sans); max-height: 40vh; min-height: 26px; padding: 2px 0;
}
.composer textarea::placeholder { color: var(--muted); }
.hero .composer textarea { min-height: 52px; }
.composer-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.model-wrap { position: relative; margin-left: auto; }
.model-btn {
  display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; color: var(--text-2);
  padding: 6px 8px; border-radius: 9px; font-size: 14px;
}
.model-btn:hover { background: var(--hover); }
.model-btn svg { width: 15px; height: 15px; color: var(--muted); }
.model-state { font-size: 12px; color: var(--muted); max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-state:empty { display: none; }
.send {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; border: 0;
  background: var(--accent); color: #fff; transition: background .15s, opacity .15s;
}
.send:hover:not(:disabled) { background: var(--accent-hover); }
.send:disabled { opacity: .4; cursor: default; }
.send svg { stroke-width: 2.4; }
.send .i-stop { display: none; fill: currentColor; stroke: none; }
.send.stop { background: var(--text); color: var(--bg); }
.send.stop .i-send { display: none; }
.send.stop .i-stop { display: block; }
.disclaimer { text-align: center; font-size: 12px; color: var(--muted); margin: 8px 0 0; }

/* Model menu */
.model-menu {
  position: absolute; right: 0; bottom: calc(100% + 8px); z-index: 50; width: min(380px, 86vw);
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 8px;
}
.hero .model-menu { bottom: auto; top: calc(100% + 8px); }
.engine-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--raised); padding: 3px; border-radius: 11px; margin-bottom: 6px; }
.engine-tabs button { border: 0; background: transparent; padding: 7px 8px; border-radius: 9px; font-size: 13px; font-weight: 500; color: var(--muted); }
.engine-tabs button small { display: block; font-weight: 400; font-size: 11px; }
.engine-tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.engine-tabs button:disabled { opacity: .45; cursor: not-allowed; }
.model-list { max-height: 46vh; overflow-y: auto; }
.model-opt { display: flex; align-items: center; gap: 8px; border-radius: 10px; padding-right: 8px; }
.model-opt:hover { background: var(--hover); }
.model-opt .pick {
  flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: left; border: 0; background: transparent;
  padding: 8px 10px; border-radius: 10px;
}
.model-opt .n { font-size: 14px; font-weight: 500; }
.model-opt .d { font-size: 12px; color: var(--muted); }
.model-opt .slot { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.model-opt[aria-checked="true"] .n::after { content: " ✓"; color: var(--accent); }

/* Download button + small round loader (composer and model menu) */
.dl-btn {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line-strong); background: var(--bg);
  color: var(--text-2); font-size: 12.5px; font-weight: 500; padding: 4px 10px 4px 8px; border-radius: 999px; white-space: nowrap;
}
.dl-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.dl-btn svg { width: 14px; height: 14px; stroke-width: 2.2; }
.dl-btn.sm { font-size: 12px; padding: 3px 9px 3px 7px; }
.ring {
  --p: 0; width: 16px; height: 16px; border-radius: 50%; flex: none; display: inline-block;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--line) 0);
  -webkit-mask: radial-gradient(circle, transparent 4.5px, #000 5px); mask: radial-gradient(circle, transparent 4.5px, #000 5px);
  animation: ring-spin 1.2s linear infinite;
}
@keyframes ring-spin { to { transform: rotate(360deg); } }
.ring-pct { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 30px; }
.model-state { display: inline-flex; align-items: center; gap: 6px; max-width: none; }
.menu-note { font-size: 12px; color: var(--muted); margin: 6px 10px 4px; }

/* ---------- Messages ---------- */
.msg { position: relative; }
.msg.user { align-self: flex-end; max-width: 85%; display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .bubble {
  display: flex; gap: 10px; align-items: flex-start; background: var(--raised); border-radius: 14px; padding: 10px 14px 10px 10px;
}
:root[data-theme="dark"] .msg.user .bubble { background: #141413; }
.msg.user .text { white-space: pre-wrap; word-wrap: break-word; padding-top: 2px; min-width: 0; }
.msg.user .edit-box { width: min(640px, 70vw); }
.msg.user .edit-box textarea {
  width: 100%; min-height: 80px; border: 1px solid var(--line-strong); border-radius: 12px; padding: 10px 12px;
  font: inherit; background: var(--surface); color: var(--text); resize: vertical;
}
.edit-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.btn { border: 1px solid var(--line); background: var(--surface); padding: 6px 14px; border-radius: 9px; font-size: 14px; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.accent { background: var(--accent-btn); color: var(--on-accent); border-color: var(--accent-btn); }
.btn.accent:hover { background: var(--accent-btn-hover); border-color: var(--accent-btn-hover); }

.msg.assistant { font: 16.5px/1.65 var(--serif); color: var(--text); }
.actions { display: flex; align-items: center; gap: 2px; margin-top: 4px; opacity: 0; transition: opacity .15s; font-family: var(--sans); }
.msg:hover .actions, .msg.assistant:last-child .actions, .actions:focus-within { opacity: 1; }
.msg.streaming .actions { display: none; }
.act { display: grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.act:hover { background: var(--hover); color: var(--text); }
.act svg { width: 16px; height: 16px; }
.meta { font-size: 12px; color: var(--muted); margin-left: 6px; }

/* Markdown */
.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(--serif); font-weight: 600; line-height: 1.3; margin: 1.2em 0 .5em; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.25em; } .md h3 { font-size: 1.1em; } .md h4 { font-size: 1em; }
.md ul, .md ol { margin: 0 0 .85em; padding-left: 1.5em; }
.md li { margin: .25em 0; }
.md li::marker { color: var(--muted); }
.md a { color: var(--accent); text-underline-offset: 2px; }
.md blockquote { margin: 0 0 .85em; padding-left: 14px; border-left: 3px solid var(--line-strong); color: var(--text-2); }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 1.2em 0; }
.md code { font: .86em/1.5 var(--mono); background: var(--code-bg); border: 1px solid var(--line); padding: 1px 5px; border-radius: 6px; }
.code-block { margin: 0 0 1em; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--code-bg); font-family: var(--sans); }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 6px 14px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); }
.copy-code { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 3px 8px; border-radius: 6px; }
.copy-code:hover { background: var(--hover); color: var(--text); }
.code-block pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.code-block code { background: none; border: 0; padding: 0; font: 13.5px/1.6 var(--mono); }
.table-wrap { overflow-x: auto; margin: 0 0 1em; }
.md table { border-collapse: collapse; font: 14px/1.5 var(--sans); }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.md th { background: var(--raised); font-weight: 600; }

/* Streaming cursor: a small pulsing cloud after the text. */
.msg.streaming .md > :last-child::after, .msg.streaming .md:empty::after {
  content: ""; display: inline-block; width: 16px; height: 16px; margin-left: 4px; vertical-align: -2px;
  background: var(--accent); -webkit-mask: url("../assets/cloud-mark.svg") center / contain no-repeat; mask: url("../assets/cloud-mark.svg") center / contain no-repeat;
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .35; transform: scale(.85) rotate(0); } 50% { opacity: 1; transform: scale(1) rotate(45deg); } }

/* Thinking */
.thinking { margin: 0 0 12px; border: 1px solid var(--line); border-radius: 12px; font: 14px/1.55 var(--sans); background: var(--bg); }
.thinking summary { list-style: none; cursor: pointer; padding: 8px 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary::before { content: "›"; display: inline-block; transition: transform .15s; font-size: 16px; line-height: 1; }
.thinking[open] summary::before { transform: rotate(90deg); }
.thinking.live .think-label { background: linear-gradient(90deg, var(--muted) 0%, var(--text) 50%, var(--muted) 100%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.6s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.think-body { padding: 0 14px 12px; color: var(--muted); white-space: pre-wrap; max-height: 320px; overflow-y: auto; }

/* Download / load card */
.load-card {
  border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; background: var(--surface);
  font: 14.5px/1.5 var(--sans); box-shadow: var(--shadow);
}
.load-card h3 { margin: 0 0 4px; font: 600 16px/1.3 var(--sans); }
.load-card p { margin: 0 0 12px; color: var(--text-2); }
.load-card .row { display: flex; gap: 8px; flex-wrap: wrap; }
.progress { height: 6px; border-radius: 99px; background: var(--raised); overflow: hidden; margin: 8px 0 6px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.load-card .ptext { font-size: 12px; color: var(--muted); }
.error-card { border-color: #e0b4a8; background: var(--accent-soft); }

/* Toast */
.toast {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 8px 14px; border-radius: 10px; font-size: 13px; z-index: 100; box-shadow: var(--shadow); white-space: nowrap;
  animation: toast-in .2s ease both; pointer-events: none;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }
.toast.in-dialog { position: fixed; bottom: 24px; }
.toast.has-act { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 14px; }
.toast-act { background: transparent; color: inherit; border: 1px solid color-mix(in srgb, var(--bg) 45%, transparent); border-radius: 7px; padding: 3px 10px; font: inherit; font-weight: 600; cursor: pointer; }
.toast-act:hover, .toast-act:focus-visible { background: color-mix(in srgb, var(--bg) 18%, transparent); }

/* Settings dialog */
.dialog { border: 1px solid var(--line); border-radius: 18px; padding: 0; width: min(520px, 92vw); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0,0,0,.35); }
.dialog-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 16px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { margin: 0; font: 500 22px/1.2 var(--serif); }
/* Settings: two columns on wide screens, so everything fits without scrolling. */
#settings { width: min(940px, 94vw); }
#settings .dialog-body { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 36px; align-items: start; }
#settings .dialog-head { grid-column: 1 / -1; }
.set-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 760px) { #settings .dialog-body { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field > span { font-weight: 500; }
.field small { color: var(--muted); font-weight: 400; }
.field select, .field textarea {
  font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--text);
}
.field input[type="range"] { accent-color: var(--accent); }
.muted { color: var(--muted); margin: 0; font-size: 13px; }
.danger { align-self: flex-start; border: 1px solid #d9a092; background: transparent; color: #c2412d; padding: 7px 14px; border-radius: 9px; font-size: 14px; }
.danger:hover { background: var(--accent-soft); }
.danger-row { display: flex; gap: 8px; flex-wrap: wrap; }
.danger.solid { background: #c2412d; border-color: #c2412d; color: #fff; }
.danger.solid:hover { background: #a93623; }
.danger:disabled { opacity: .6; cursor: progress; }
:root[data-theme="dark"] .danger:not(.solid) { color: #f0907c; border-color: #7a3a2e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .danger:not(.solid) { color: #f0907c; border-color: #7a3a2e; } }

/* ---------- Small screens ---------- */
@media (max-width: 820px) {
  .sidebar { position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; transform: translateX(0); box-shadow: var(--shadow); }
  .app.side-closed .sidebar { transform: translateX(-105%); width: var(--side-w); }
  .app.side-closed .topbar #side-open, .app.side-closed .topbar #new-chat-top { display: inline-grid; }
  .thread { padding: 0 14px; }
  .dock { padding: 0 10px 8px; }
  .privacy-pill { display: none; }
  .msg.user { max-width: 92%; }
}

/* ---------- Polish ---------- */
.msg { animation: rise .28s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
.greeting { animation: rise .5s ease both; }
.hero .composer { animation: rise .5s .05s ease both; }
.chips { animation: rise .5s .1s ease both; }
.composer { transition: border-color .15s, box-shadow .2s; }
.composer:focus-within { box-shadow: 0 1px 2px rgba(20,20,19,.05), 0 8px 28px rgba(20,20,19,.09); }
.chip { transition: background .15s, color .15s, transform .15s; }
.chip:hover { transform: translateY(-1px); }
.new-chat:hover .plus-dot { transform: rotate(90deg); }
.plus-dot { transition: transform .2s ease; }

/* Scroll-to-bottom button */
.to-bottom {
  position: absolute; left: 50%; bottom: 128px; transform: translateX(-50%); z-index: 5;
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); box-shadow: var(--shadow); display: grid; place-items: center; animation: rise .2s ease both;
}
.to-bottom:hover { color: var(--text); border-color: var(--line-strong); }

/* Attachments */
.attach { width: 32px; height: 32px; border: 0; border-radius: 10px; color: var(--text-2); }
.attach:hover { background: var(--hover); color: var(--text); }
.attach svg { stroke-width: 2; }
.attachments { display: flex; gap: 10px; margin: -2px -4px 12px; padding: 2px 4px 4px; overflow-x: auto; scrollbar-width: thin; }
.file-card {
  position: relative; flex: none; width: 150px; height: 104px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); overflow: hidden; cursor: pointer; display: flex; flex-direction: column;
  transition: border-color .15s, box-shadow .15s, transform .15s; animation: rise .22s ease both; text-align: left;
}
.file-card:hover, .file-card:focus-visible { border-color: var(--line-strong); box-shadow: 0 4px 14px rgba(20, 20, 19, .08); transform: translateY(-1px); }
.fc-peek {
  flex: 1; margin: 0; padding: 8px 10px 0; font: 9.5px/1.45 var(--mono); color: var(--muted); white-space: pre; overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 45%, transparent); mask-image: linear-gradient(#000 45%, transparent);
}
.fc-foot { padding: 0 10px 8px; display: flex; flex-direction: column; gap: 3px; }
.fc-name { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.fc-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.fc-type { font: 600 9.5px/1 var(--sans); letter-spacing: .04em; padding: 3px 5px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); }
.fc-x {
  position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--text-2); display: grid; place-items: center; opacity: 0; transition: opacity .15s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.fc-x svg { width: 12px; height: 12px; stroke-width: 2.4; }
.file-card:hover .fc-x, .fc-x:focus-visible { opacity: 1; }
@media (hover: none) { .fc-x { opacity: 1; } }
.msg.user .files { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-bottom: 8px; }
.msg.user .file-card { width: 132px; height: 92px; background: var(--surface); }

/* Drop overlay */
.view#view-chat { position: relative; }
.drop-overlay {
  position: absolute; inset: 10px; z-index: 30; display: none; place-items: center; border-radius: 22px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); border: 2px dashed var(--accent); backdrop-filter: blur(3px);
}
#view-chat.dragging .drop-overlay { display: grid; animation: rise .15s ease both; }
.drop-box { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text-2); pointer-events: none; text-align: center; }
.drop-box svg { width: 40px; height: 40px; color: var(--accent); stroke-width: 1.5; margin-bottom: 4px; }
.drop-box strong { font: 500 22px/1.2 var(--serif); color: var(--text); }
.drop-box span { font-size: 13px; color: var(--muted); }

/* File preview dialog */
.file-dialog { width: min(860px, 94vw); }
.file-dialog .dialog-body { gap: 10px; }
.fp-title { min-width: 0; display: flex; flex-direction: column; }
.fp-title h2 { font: 500 18px/1.3 var(--sans) !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-body { max-height: 70vh; overflow: auto; }
.fp-body .code-block { margin: 0; }
.fp-body .code-head { display: none; }

/* Syntax colours */
.tok-kw { color: #a2401f; font-weight: 500; }
.tok-str { color: #2f6b31; }
.tok-com { color: #8b887d; font-style: italic; }
.tok-num { color: #9a5b00; }
.tok-fn { color: #2c5da8; }
.tok-type { color: #7b4bb3; }
.tok-dec { color: #8a6d00; }
:root[data-theme="dark"] .tok-kw { color: #f09a78; } :root[data-theme="dark"] .tok-str { color: #9ccf86; }
:root[data-theme="dark"] .tok-com { color: #8a877e; } :root[data-theme="dark"] .tok-num { color: #e6b866; }
:root[data-theme="dark"] .tok-fn { color: #82aaff; } :root[data-theme="dark"] .tok-type { color: #c7a2f0; } :root[data-theme="dark"] .tok-dec { color: #e0c46c; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tok-kw { color: #f09a78; } :root:not([data-theme="light"]) .tok-str { color: #9ccf86; }
  :root:not([data-theme="light"]) .tok-com { color: #8a877e; } :root:not([data-theme="light"]) .tok-num { color: #e6b866; }
  :root:not([data-theme="light"]) .tok-fn { color: #82aaff; } :root:not([data-theme="light"]) .tok-type { color: #c7a2f0; } :root:not([data-theme="light"]) .tok-dec { color: #e0c46c; }
}
.app.side-closed .side-foot { margin-top: auto; }

/* ---------- Sidebar sections ---------- */
.side-nav { display: flex; flex-direction: column; gap: 1px; margin-top: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; text-decoration: none;
  color: var(--text-2); font-size: 14px; font-weight: 500;
}
.nav-link:hover { background: var(--hover); color: var(--text); }
.nav-link.active { background: var(--hover); color: var(--text); }
.nav-link svg { color: var(--muted); }
.nav-link.active svg { color: var(--accent); }
.recents-label { padding-top: 12px; }
.app.side-closed .recents-label { display: none; }

/* ---------- Header: separator, breadcrumb, title menu ---------- */
.topbar { position: relative; z-index: 20; background: var(--bg); transition: border-color .2s, box-shadow .2s; border-bottom: 1px solid transparent; }
.main.has-title .topbar { border-bottom-color: var(--line); box-shadow: 0 1px 0 rgba(20, 20, 19, .02), 0 6px 16px -14px rgba(20, 20, 19, .25); }
.crumbs { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; margin: 0 0 0 6px; font: 500 15px/1.3 var(--sans); }
.crumb { color: var(--muted); text-decoration: none; padding: 5px 8px; border-radius: 8px; white-space: nowrap; max-width: 30%; overflow: hidden; text-overflow: ellipsis; display: inline-flex; align-items: center; gap: 6px; }
.crumb:hover { background: var(--hover); color: var(--text); }
.crumb-sep { color: var(--line-strong); font-size: 18px; line-height: 1; }
.title-btn {
  display: inline-flex; align-items: center; gap: 6px; min-width: 0; border: 0; background: transparent; padding: 5px 8px;
  border-radius: 8px; color: var(--text); font: inherit; cursor: default;
}
.main:not(.has-title) .title-btn { display: none; } /* nothing to show or open on the start screen */
.title-btn.has-menu { cursor: pointer; }
.title-btn.has-menu:hover, .title-btn[aria-expanded="true"] { background: var(--hover); }
.title-btn .chev { width: 15px; height: 15px; color: var(--muted); display: none; }
.title-btn.has-menu .chev { display: block; }
.chat-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-rename { flex: 1; max-width: 420px; }
.title-menu { position: absolute; left: 0; top: calc(100% + 6px); right: auto; min-width: 230px; font-size: 14px; }
.chat-item .item-menu, .title-menu { max-height: 60vh; overflow-y: auto; }
.item-menu button { color: var(--text); }
.item-menu button svg { width: 16px; height: 16px; color: var(--muted); }
.item-menu button .sub { margin-left: auto; }
.item-menu button.current { color: var(--accent); cursor: default; }
.item-menu button:disabled:hover { background: transparent; }
.item-menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
.menu-label { font-size: 12px; color: var(--muted); padding: 6px 10px 4px; font-weight: 500; }
.item-menu .del svg { color: currentColor; }

/* New chat inside a project */
.project-pill {
  display: inline-flex; align-items: center; gap: 7px; margin: -12px 0 14px; padding: 5px 8px 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 500; animation: rise .3s ease both;
}
.project-pill svg { width: 15px; height: 15px; color: var(--accent); }
.project-pill .x { color: var(--muted); width: 13px; height: 13px; }
.project-pill:hover { border-color: var(--line-strong); }
.project-pill:hover .x { color: var(--text); }

/* ---------- Pages (Projects, Notes) ---------- */
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view.page { overflow-y: auto; padding: 0 24px; }
.page-inner { max-width: 960px; margin: 0 auto; padding: 34px 0 60px; animation: rise .3s ease both; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-title { margin: 0; font: 400 34px/1.15 var(--serif); letter-spacing: -.02em; }
.page-sub { color: var(--muted); margin: 6px 0 24px; max-width: 640px; }
.btn { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--text); }
.btn svg { width: 16px; height: 16px; }
.btn.primary svg, .btn.accent svg { stroke-width: 2.2; }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.danger.sm { padding: 4px 10px; font-size: 13px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; }
.card h3 { margin: 0 0 4px; font: 600 15px/1.3 var(--sans); }
.card .field input, .card .field textarea, .field input:not([type]) {
  font: inherit; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--text);
}
.new-project { margin-bottom: 22px; display: flex; flex-direction: column; gap: 12px; max-width: 640px; animation: rise .25s ease both; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.project-card {
  display: flex; flex-direction: column; gap: 6px; padding: 18px; border-radius: 16px; background: var(--surface);
  border: 1px solid var(--line); text-decoration: none; color: var(--text); min-height: 150px; transition: border-color .15s, transform .15s, box-shadow .15s;
}
.project-card:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow); }
.project-card strong { font: 600 16px/1.3 var(--sans); }
.project-card p { margin: 0; color: var(--text-2); font-size: 14px; flex: 1; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pc-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); margin-bottom: 4px; }
.pc-meta { font-size: 12px; color: var(--muted); }
.empty-box { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 48px 20px; border: 1px dashed var(--line-strong); border-radius: 18px; }
.empty-box p { margin: 0 0 10px; color: var(--muted); }
.eb-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); margin-bottom: 6px; }
.eb-icon svg { width: 22px; height: 22px; }

.rows { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); }
.row-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; text-align: left; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; color: var(--text); text-decoration: none; width: 100%;
}
.row-item:last-child { border-bottom: 0; }
.row-item:hover { background: var(--hover); }
.ri-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--raised); color: var(--muted); flex: none; }
.ri-icon.note { background: var(--accent-soft); color: var(--accent); }
.ri-icon svg { width: 16px; height: 16px; }
.ri-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ri-title { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-2); background: var(--raised); border-radius: 999px; padding: 2px 9px 2px 7px; white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.badge svg { width: 12px; height: 12px; color: var(--accent); }
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* One project */
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 14px; margin: 0 0 14px -4px; padding: 4px 8px 4px 4px; border-radius: 8px; }
.back:hover { color: var(--text); background: var(--hover); }
.back svg { width: 16px; height: 16px; }
.project-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; }
.project-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 16px; }
.project-side textarea { width: 100%; margin-top: 8px; font: 14px/1.5 var(--sans); padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); resize: vertical; }
.title-row { display: flex; align-items: center; gap: 12px; }
.title-input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: 400 32px/1.2 var(--serif); letter-spacing: -.02em; padding: 2px 0; border-bottom: 1px dashed transparent; }
.title-input:hover, .title-input:focus { border-bottom-color: var(--line-strong); }
.desc-input { width: 100%; border: 0; outline: 0; resize: none; background: transparent; color: var(--text-2); font: 15px/1.5 var(--sans); padding: 4px 0; overflow: hidden; }
.saved { font-size: 12px; color: var(--muted); white-space: nowrap; }
.start-chat {
  display: flex; align-items: center; gap: 12px; width: 100%; margin: 18px 0 26px; padding: 16px 18px; border-radius: 18px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--muted); font-size: 15px; text-align: left;
  transition: border-color .15s, color .15s;
}
.start-chat:hover { border-color: var(--line-strong); color: var(--text); }
.section { margin-bottom: 26px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.section-head h3 { margin: 0; font: 600 14px/1.3 var(--sans); color: var(--text-2); }
.k-files { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.k-file { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 8px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.k-meter { margin-top: 10px; }
.progress.over > i { background: #c2412d; }

/* One note */
.note-page { max-width: 820px; }
.note-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.note-proj { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); }
.note-proj select { font: 13px var(--sans); padding: 5px 8px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.segmented { display: inline-flex; background: var(--raised); border-radius: 9px; padding: 2px; }
.seg { border: 0; background: transparent; padding: 4px 12px; border-radius: 7px; font-size: 13px; color: var(--muted); }
.seg.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.note-bar .saved { margin-left: auto; }
.note-body {
  width: 100%; min-height: 55vh; border: 0; outline: 0; resize: vertical; background: transparent; color: var(--text);
  font: 16.5px/1.7 var(--serif);
}
.note-preview { font: 16.5px/1.65 var(--serif); min-height: 40vh; }

@media (max-width: 900px) {
  .project-grid { grid-template-columns: 1fr; }
  .project-side { position: static; }
  .view.page { padding: 0 14px; }
  .page-title { font-size: 28px; }
  .crumb { max-width: 40%; }
}

/* Profile */
.profile-row { display: flex; align-items: center; gap: 14px; }
.avatar.lg { width: 64px; height: 64px; }
.profile-fields { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.profile-fields input { font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); }
.row-start { display: flex; gap: 8px; flex-wrap: wrap; }

/* "Made in India" footer */
.made-in { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; color: var(--muted); }
.made-in .heart { width: 13px; height: 13px; fill: #e0414f; stroke: none; animation: beat 1.6s ease-in-out infinite; transform-origin: center; }
@keyframes beat { 0%, 60%, 100% { transform: scale(1); } 15% { transform: scale(1.22); } 30% { transform: scale(.96); } 45% { transform: scale(1.12); } }
.made-corner { position: absolute; right: 18px; bottom: 10px; z-index: 6; font-size: 12px; pointer-events: none; }
.made-corner .made-in { pointer-events: auto; }
.made-corner { display: flex; align-items: center; gap: 10px; }
.about-link { pointer-events: auto; color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; min-height: 24px; padding: 0 4px; }
.about-link:hover, .about-link:focus-visible { color: var(--text); text-decoration: underline; }
@media (max-width: 820px) {
  .made-corner { right: 12px; bottom: 4px; font-size: 11px; }
  .dock { padding-bottom: 22px; }
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { max-width: 640px; margin: 15vh auto; padding: 0 24px; font: 17px/1.6 var(--sans); }
.noscript h1 { font: 400 34px/1.2 var(--serif); }

/* Message footer: time always visible; action buttons appear on hover (always on touch screens). */
.actions { opacity: 1 !important; }
.actions .act { opacity: .75; transition: opacity .15s, background .15s, color .15s; }
.msg:hover .actions .act, .actions .act:focus-visible { opacity: 1; }
.when { font-size: 11.5px; color: var(--muted); white-space: nowrap; font-family: var(--sans); padding: 0 4px; }
.msg.user .actions { gap: 0; }
.msg.user .actions .when { order: -1; }
.msg.assistant .meta + .when::before { content: "·"; margin-right: 6px; }
.msg.assistant .meta:empty + .when::before { content: none; }

/* File cards: type icon + size */
.file-card { height: 118px; }
.msg.user .file-card { height: 112px; }
.fc-top { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 0 8px; }
.fc-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: color-mix(in srgb, var(--fc) 14%, transparent); color: var(--fc); }
.fc-icon svg { width: 15px; height: 15px; stroke-width: 2; }
.fc-type { font: 700 9px/1 var(--sans); letter-spacing: .05em; padding: 3px 6px; border-radius: 5px; background: color-mix(in srgb, var(--fc) 14%, transparent); color: var(--fc); margin-right: 22px; }
.fc-peek { padding-top: 6px; font-size: 9px; }
.fc-size { font-weight: 600; color: var(--text-2); }
.fc-meta .fc-size::after { content: "·"; margin-left: 6px; color: var(--muted); font-weight: 400; }

/* ---------- Side panel (HTML preview, PDF) ---------- */
.side-panel {
  width: clamp(380px, 46vw, 820px); flex: none; display: flex; flex-direction: column; background: var(--surface);
  border-left: 1px solid var(--line); box-shadow: -10px 0 30px -24px rgba(20, 20, 19, .35); animation: slide-in .25s cubic-bezier(.2, .7, .2, 1) both;
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sp-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 14px; min-height: 52px; border-bottom: 1px solid var(--line); }
.sp-icon .fc-icon { width: 30px; height: 30px; }
.sp-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sp-title strong { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-title .muted { font-size: 12px; }
.sp-body { flex: 1; min-height: 0; display: flex; background: var(--bg); }
.sp-frame { flex: 1; width: 100%; height: 100%; border: 0; background: #fff; }
.sp-code { flex: 1; overflow: auto; padding: 14px; }
.sp-code .code-block { margin: 0; }
.sp-code .code-head { display: none; }
.code-actions { display: inline-flex; gap: 2px; }
.preview-code { color: var(--accent) !important; font-weight: 600; }
.app.panel-open .made-corner { display: none; }
@media (max-width: 820px) {
  .side-panel { position: fixed; inset: 0; z-index: 60; width: 100%; }
}

/* ---------- UI audit fixes (task 33) ---------- */
/* The open model menu must sit above the suggestion chips (their entrance animation creates a stacking context). */
.hero .composer { position: relative; z-index: 5; }
.composer:has(.model-menu:not([hidden])) { z-index: 40; position: relative; }
/* Streaming cursor sits inline after the last word, not on a new line. */
.msg.streaming .md > ul:last-child::after, .msg.streaming .md > ol:last-child::after,
.msg.streaming .md > .code-block:last-child::after, .msg.streaming .md > .table-wrap:last-child::after { display: none; }
/* Cards are UI, not the model's voice: use the interface font. */
.load-card, .load-card p, .load-card .btn { font-family: var(--sans); }
.load-card p { font-size: 14.5px; }
/* Side panel subtitle stays on one line. */
.sp-title .muted { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Think toggle */
.think-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 11px 0 9px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 13px; font-weight: 500;
  transition: background .15s, color .15s, border-color .15s;
}
.think-btn svg { width: 16px; height: 16px; }
.think-btn:hover { color: var(--text); border-color: var(--line-strong); }
.think-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--accent-text); }
.empty-answer { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font: 14px/1.4 var(--sans); color: var(--muted); padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: 12px; }

/* ---------- Command palette ---------- */
kbd { font: 600 11px/1 var(--sans); padding: 3px 6px; border-radius: 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; background: var(--surface); color: var(--muted); white-space: nowrap; }
.kbd-hint { cursor: pointer; }
.app.side-closed .kbd-hint { display: none; }
.palette {
  width: min(640px, 94vw); padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text);
  box-shadow: 0 24px 80px rgba(20, 20, 19, .28); margin-top: 12vh; overflow: hidden;
}
.palette::backdrop { background: rgba(20, 20, 19, .32); backdrop-filter: blur(2px); }
.palette[open] { animation: rise .18s ease both; }
.pal-search { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.pal-search input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font: 16px var(--sans); }
.pal-list { max-height: min(56vh, 460px); overflow-y: auto; padding: 6px; }
.pal-group { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 10px 10px 4px; }
.pal-item { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 10px; color: var(--text); }
.pal-item[aria-selected="true"] { background: var(--hover); }
.pal-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--raised); color: var(--muted); flex: none; }
.pal-item[aria-selected="true"] .pal-icon { background: var(--accent-soft); color: var(--accent); }
.pal-icon svg { width: 15px; height: 15px; }
.pal-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pal-label { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pal-empty { color: var(--muted); padding: 22px 14px; text-align: center; margin: 0; font-size: 14px; }
.pal-key { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; font-size: 14px; border-radius: 10px; }
.pal-key:nth-child(even) { background: var(--bg); }
.pal-key kbd + kbd { margin-left: 4px; }
.pal-foot { display: flex; gap: 16px; padding: 9px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.pal-foot kbd { margin-right: 3px; }

/* Memory meter */
.mem { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px; border-radius: 999px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; cursor: default; }
.mem:hover, .mem:focus-visible { background: var(--hover); }
.mem-ring { --p: 0; width: 16px; height: 16px; border-radius: 50%; background: conic-gradient(var(--mc, var(--muted)) calc(var(--p) * 1%), var(--line) 0);
  -webkit-mask: radial-gradient(circle, transparent 4px, #000 4.5px); mask: radial-gradient(circle, transparent 4px, #000 4.5px); }
.mem.warn { --mc: #b26a00; color: #b26a00; }
.mem.full { --mc: #c2412d; color: #c2412d; }
.mem-tip {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%); width: 270px; padding: 9px 11px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: 12.5px; line-height: 1.45; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .15s; z-index: 60; white-space: normal;
}
.hero .mem-tip { bottom: auto; top: calc(100% + 10px); }
.mem:hover .mem-tip, .mem:focus-visible .mem-tip { opacity: 1; }

/* Context window slider */
.ctx-row { display: flex; align-items: center; gap: 12px; }
.ctx-row input { flex: 1; accent-color: var(--accent); }
.ctx-row strong { font-size: 13px; white-space: nowrap; min-width: 118px; text-align: right; }
.ctx-ticks { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); padding: 0 2px; margin-right: 130px; }
.ctx-ticks .on { color: var(--accent); font-weight: 600; }
.mem { cursor: pointer; }

/* ---------- Web tools ---------- */
.tools-wrap { position: relative; }
.tools-menu {
  position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 50; width: min(400px, 88vw);
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 8px;
  animation: rise .16s ease both;
}
.hero .tools-menu { bottom: auto; top: calc(100% + 8px); }
.tools-head { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px 8px; }
.tools-head b { font-size: 14px; }
.tools-head span { font-size: 12px; color: var(--muted); }
.tool-opt { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; cursor: pointer; }
.tool-opt:hover { background: var(--hover); }
.tool-opt kbd { flex: none; }
.tool-ic { flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.tool-ic svg, .tool-step svg, .slash-opt svg, .sources svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tool-txt b { font-size: 14px; font-weight: 600; }
.tool-txt small { font-size: 12px; color: var(--muted); line-height: 1.35; }
.tools-menu .menu-note code { font-size: 11.5px; }
.switch {
  appearance: none; flex: none; width: 34px; height: 20px; border-radius: 99px; background: var(--line-strong);
  position: relative; cursor: pointer; transition: background .15s; margin: 0;
}
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(14px); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.disclaimer.web-on { color: var(--accent); }

/* "/" command list above the message box */
.composer { position: relative; }
.slash-list {
  position: absolute; left: 10px; right: 10px; bottom: calc(100% + 6px); z-index: 55; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; animation: rise .14s ease both;
}
.hero .slash-list { bottom: auto; top: calc(100% + 6px); }
.slash-opt { display: grid; grid-template-columns: 18px 60px 1fr; align-items: center; column-gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; color: var(--text-2); }
.slash-opt b { font: 600 13px var(--mono, ui-monospace, monospace); color: var(--text); }
.slash-opt span { font-size: 14px; }
.slash-opt small { grid-column: 3; font-size: 12px; color: var(--muted); }
.slash-opt.active, .slash-opt:hover { background: var(--hover); }
.slash-opt.active b { color: var(--accent); }

/* Tool steps and sources in a reply */
/* Live status of a reply: what the app is really doing, step by step */
.trace { margin: 0 0 12px; font: 13.5px/1.4 var(--sans); color: var(--muted); }
.trace-sum { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; padding: 3px 8px 3px 4px; margin-left: -4px; border-radius: 8px; user-select: none; }
.trace-sum::-webkit-details-marker { display: none; }
.trace-sum::before { content: "›"; display: inline-block; transition: transform .15s; font-size: 16px; line-height: 1; }
.trace[open] > .trace-sum::before { transform: rotate(90deg); }
.trace-sum:hover { background: var(--hover); color: var(--text-2); }
.trace-sum:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.trace-sum small, .ts-time { font-variant-numeric: tabular-nums; color: var(--muted); opacity: .85; font-size: 12px; }
.trace-sum .shimmer { background: linear-gradient(90deg, var(--muted) 0%, var(--text) 50%, var(--muted) 100%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.6s linear infinite; }
.trace-list { list-style: none; margin: 6px 0 2px; padding: 2px 0 2px 14px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.trace-step { display: flex; align-items: center; gap: 8px; }
.trace-step.enter { animation: rise .18s ease both; }
.trace-step .ts-text { min-width: 0; overflow-wrap: anywhere; }
.trace-step .ts-time { margin-left: auto; padding-left: 10px; flex: none; }
.trace-step svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; color: var(--accent); flex: none; }
.trace-step.running { color: var(--text-2); }
.trace-step.warn svg { color: #b7791f; }
.trace-step.stopped svg { color: var(--muted); }
.tool-step.error, .trace-step.error { color: var(--danger, #c2412d); }
.tool-step.error svg, .trace-step.error svg { color: currentColor; }
.tool-step .spin, .trace-step .spin { width: 14px; height: 14px; flex: none; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sources { margin-top: 14px; font-family: var(--sans); }
.sources-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.sources ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.sources a {
  display: grid; grid-template-columns: auto auto 1fr; grid-template-rows: auto auto; column-gap: 7px; align-items: center;
  max-width: 260px; padding: 7px 11px 7px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  color: var(--text); text-decoration: none; transition: border-color .15s, background .15s;
}
.sources a:hover, .sources a:focus-visible { border-color: var(--accent); background: var(--hover); }
.sources a b { grid-row: span 2; width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; font-size: 11.5px; background: var(--accent-soft); color: var(--accent); }
.sources a svg { grid-row: span 2; color: var(--muted); }
.sources a span { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sources a small { grid-column: 3; font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.md a.cite {
  display: inline-grid; place-items: center; min-width: 17px; height: 17px; padding: 0 4px; margin: 0 1px; border-radius: 5px;
  font: 600 11px/1 var(--sans); vertical-align: 2px; background: var(--accent-soft); color: var(--accent); text-decoration: none;
}
.md a.cite:hover, .md a.cite:focus-visible { background: var(--accent); color: var(--on-accent, #fff); }
@media (prefers-reduced-motion: reduce) { .trace-step.enter { animation: none; } .trace-sum .shimmer { animation: none; color: var(--text-2); background: none; } .tool-step .spin, .trace-step .spin { animation-duration: 2.4s; } .tools-menu, .slash-list { animation: none; } }

/* ---------- Artifacts ---------- */
.ri-icon.art { background: var(--accent-soft); color: var(--accent); }
.ri-icon.art.code { background: var(--raised); color: var(--text-2); }
.kind-wrap { position: relative; }
.kind-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 200px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px;
  animation: rise .16s ease both;
}
.empty-box .kind-menu { right: auto; left: 50%; transform: translateX(-50%); }
.kind-menu button { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; color: var(--text); font: 14px var(--sans); padding: 8px 10px; border-radius: 9px; text-align: left; cursor: pointer; }
.kind-menu button:hover, .kind-menu button:focus-visible { background: var(--hover); outline: none; }
.kind-menu svg { width: 16px; height: 16px; color: var(--accent); fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.art-page { max-width: 1040px; }
.art-bar select, .lang-input { font: 13px var(--sans); padding: 5px 8px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.lang-input { width: 150px; }
.art-bar .btn svg, .shared-banner svg, .kind-badge svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.art-bar .spacer { flex: 1; }
.art-stage { height: min(72vh, 720px); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; background: #fff; }
.art-stage .sp-frame { flex: 1; }
.art-doc { font: 16.5px/1.65 var(--serif); }
.art-code .code-block { margin: 0; }
.art-editor { font: 13.5px/1.6 var(--mono); tab-size: 2; min-height: 60vh; padding: 14px; border: 1px solid var(--line) !important; border-radius: 14px; background: var(--code-bg); white-space: pre; overflow: auto; }
.share-box { display: flex; flex-direction: column; gap: 8px; margin: 0 0 14px; }
.share-row { display: flex; gap: 8px; }
.share-input { flex: 1; min-width: 0; font: 13px var(--mono); padding: 7px 10px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--text); }
.share-note { margin: 0; font-size: 13px; }
.share-warn { margin: 0; font-size: 13px; color: #a2401f; }
:root[data-theme="dark"] .share-warn { color: #f0a080; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .share-warn { color: #f0a080; } }
.shared-banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); color: var(--text); margin-bottom: 14px; }
.shared-banner .sb-icon { color: var(--accent); margin-top: 2px; }
.shared-banner p { margin: 2px 0 0; font-size: 13.5px; color: var(--text-2); }
.shared-title { margin: 4px 0 0; }
@media (max-width: 700px) { .art-bar .spacer { display: none; } .lang-input { width: 120px; } }
@media (prefers-reduced-motion: reduce) { .kind-menu { animation: none; } }
.art-doc [data-save-artifact] { display: none; } /* already an artifact */
