/* Daniel AI — Personal AI home (Palette: #0B0B0B, #333533, #F2ECDD, #F5CB5C, #CD9C20) */

@font-face { font-family: "Fraunces"; src: url("../fonts/fraunces.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("../fonts/fraunces-italic.woff2") format("woff2"); font-weight: 100 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("../fonts/jetbrains-mono.woff2") format("woff2"); font-weight: 100 800; font-display: swap; }

:root {
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --sidebar-w: 292px;
  --content-w: 768px;
  --radius-s: 8px;
  --radius: 12px;
  --radius-l: 18px;
  --radius-xl: 26px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --text-base: 16px;
}

/* Dark (default) — exact palette: #0B0B0B, #333533, #F2ECDD, #F5CB5C, #CD9C20 */
:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B0B0B;
  --bg-2: #161716;
  --surface: #333533;
  --surface-2: #333533;
  --surface-3: #424542;
  --input-bg: #0B0B0B;
  --hover: rgba(242, 236, 221, .08);
  --active: rgba(245, 203, 92, .16);
  --border: rgba(242, 236, 221, .14);
  --border-strong: rgba(205, 156, 32, .55);
  --text: #F2ECDD;
  --text-2: #F2ECDD;
  --muted: #C4BEB0;
  --faint: #969288;
  --accent: #F5CB5C;
  --accent-strong: #CD9C20;
  --accent-ink: #0B0B0B;
  --accent-soft: rgba(245, 203, 92, .18);
  --accent-glow: rgba(205, 156, 32, .12);
  --user-bubble: #333533;
  --user-bubble-border: rgba(205, 156, 32, .48);
  --danger: #e26d5a;
  --ok: #8bc38a;
  --shadow-s: 0 1px 2px rgba(0, 0, 0, .45);
  --shadow: 0 10px 30px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .35);
  --shadow-l: 0 24px 64px rgba(0, 0, 0, .72), 0 4px 16px rgba(0, 0, 0, .45);
  --code-bg: #060606;
  --scrim: rgba(6, 6, 6, .76);
}

/* Light — #F2ECDD / #333533 / #0B0B0B / #CD9C20 / #F5CB5C */
[data-theme="light"] {
  color-scheme: light;
  --bg: #F2ECDD;
  --bg-2: #EAE3D1;
  --surface: #F7F3E8;
  --surface-2: #FCF9F2;
  --surface-3: #E3DBCA;
  --input-bg: #FCF9F2;
  --hover: rgba(51, 53, 51, .06);
  --active: rgba(205, 156, 32, .14);
  --border: rgba(51, 53, 51, .14);
  --border-strong: rgba(51, 53, 51, .28);
  --text: #0B0B0B;
  --text-2: #333533;
  --muted: #585A58;
  --faint: #848682;
  --accent: #CD9C20;
  --accent-strong: #B38616;
  --accent-ink: #0B0B0B;
  --accent-soft: rgba(205, 156, 32, .16);
  --accent-glow: rgba(245, 203, 92, .32);
  --user-bubble: #E5DEC9;
  --user-bubble-border: rgba(51, 53, 51, .15);
  --danger: #b84232;
  --ok: #3f7d4d;
  --shadow-s: 0 1px 2px rgba(11, 11, 11, .08);
  --shadow: 0 8px 28px rgba(11, 11, 11, .12), 0 2px 6px rgba(11, 11, 11, .06);
  --shadow-l: 0 24px 64px rgba(11, 11, 11, .18), 0 4px 14px rgba(11, 11, 11, .08);
  --code-bg: #1A1B1A;
  --scrim: rgba(11, 11, 11, .42);
}

[data-theme="dark"] .composer:focus-within {
  border-color: rgba(245, 203, 92, .55);
  box-shadow: var(--shadow), 0 0 0 3px rgba(245, 203, 92, .12);
}
[data-theme="dark"] .send:not(:disabled) {
  background: linear-gradient(145deg, #F5CB5C, #CD9C20);
  color: #0B0B0B;
  box-shadow: 0 4px 16px rgba(205, 156, 32, .32);
}
[data-theme="light"] .send:not(:disabled) {
  background: linear-gradient(145deg, #F5CB5C, #CD9C20);
  color: #0B0B0B;
}

[data-text="small"] { --text-base: 15px; }
[data-text="large"] { --text-base: 17.5px; }

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--font-ui);
  font-feature-settings: "cv11", "ss01", "ss03";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
::selection { background: var(--accent-soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ico { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }
.ico-s { width: 15px; height: 15px; }
.ico-l { width: 22px; height: 22px; }

* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100dvh;
  transition: grid-template-columns .28s var(--ease);
}
.app.sidebar-collapsed { grid-template-columns: 0 1fr; }
.app.sidebar-collapsed .sidebar { transform: translateX(-100%); opacity: 0; pointer-events: none; }

.drawer-scrim { display: none; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  transition: transform .28s var(--ease), opacity .2s;
  z-index: 40;
}
.sb-top { padding: 14px 12px 6px; display: flex; flex-direction: column; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: radial-gradient(120% 120% at 30% 20%, #F5CB5C 0%, #CD9C20 62%, #8A6712 100%);
  box-shadow: 0 4px 14px rgba(205, 156, 32, .35), inset 0 1px 0 rgba(242, 236, 221, .45);
  color: #0B0B0B;
}
.brand-mark svg { width: 17px; height: 17px; stroke-width: 2.2; }
.brand-name { font: 600 21px/1 var(--font-display); letter-spacing: -.01em; font-variation-settings: "opsz" 48, "SOFT" 50; }
.brand-sub { font-size: 13px; font-weight: 520; color: var(--muted); letter-spacing: .01em; }
.brand .spacer { flex: 1; }

.btn-new {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 550; font-size: 14px;
  box-shadow: var(--shadow-s);
  transition: background .15s, border-color .15s, transform .1s;
}
.btn-new:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn-new:active { transform: scale(.985); }
.btn-new .ico { color: var(--accent); }
.btn-new kbd { margin-left: auto; }

.search-trigger {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius);
  color: var(--muted); font-size: 14px;
  transition: background .15s, color .15s;
}
.search-trigger:hover { background: var(--hover); color: var(--text-2); }
kbd {
  font: 500 11px/1 var(--font-ui);
  color: var(--faint);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 3px 5px;
  margin-left: auto;
}

.sb-scroll { flex: 1; overflow-y: auto; padding: 4px 8px 16px; overscroll-behavior: contain; }
.sb-section { margin-top: 14px; }
.sb-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase;
  color: var(--faint); padding: 4px 10px 6px;
}
.sb-label button { color: var(--faint); padding: 2px; border-radius: 6px; display: grid; place-items: center; }
.sb-label button:hover { color: var(--text-2); background: var(--hover); }

.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 14px; font-weight: 500;
  text-align: left;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item.active { background: var(--active); color: var(--text); }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.cat-icon {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  color: var(--c, var(--accent));
  background: color-mix(in srgb, var(--c, var(--accent)) 16%, transparent);
}
.cat-icon .ico { width: 15px; height: 15px; }
.nav-item.active .cat-icon { background: color-mix(in srgb, var(--c, var(--accent)) 26%, transparent); }

.conv-group-label { font-size: 11.5px; color: var(--faint); padding: 12px 10px 4px; font-weight: 550; }
.conv-item {
  position: relative;
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 13.5px; color: var(--text-2);
  text-align: left;
  transition: background .12s, color .12s;
}
.conv-item:hover { background: var(--hover); color: var(--text); }
.conv-item.active { background: var(--active); color: var(--text); }
.conv-item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c, var(--faint)); flex: none; opacity: .9; }
.conv-item .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .pin { color: var(--faint); }
.conv-item .more {
  opacity: 0; color: var(--muted); padding: 2px; border-radius: 6px; display: grid; place-items: center;
  margin-right: -4px;
}
.conv-item:hover .more, .conv-item.active .more { opacity: 1; }
.conv-item .more:hover { background: var(--active); color: var(--text); }
.conv-item.streaming .dot { animation: pulse 1.2s ease-in-out infinite; background: var(--accent); }
.sb-empty { color: var(--faint); font-size: 13px; padding: 10px 12px; line-height: 1.5; }

.sb-foot { border-top: 1px solid var(--border); padding: 10px; display: flex; align-items: center; gap: 6px; }
.me {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 10px; text-align: left;
}
.me:hover { background: var(--hover); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font: 600 13px/1 var(--font-ui);
  color: #0B0B0B;
  background: linear-gradient(140deg, #F5CB5C, #CD9C20);
}
.me-name { font-weight: 600; font-size: 13.5px; }
.me-sub { font-size: 11.5px; color: var(--faint); }

.icon-btn {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  color: var(--muted);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { color: var(--accent); background: var(--accent-soft); }

/* ---------- Main ---------- */
.main { position: relative; display: flex; flex-direction: column; min-width: 0; height: 100dvh; background: var(--bg); }
.topbar {
  flex: none;
  height: 56px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px;
  border-bottom: 1px solid transparent;
  position: relative; z-index: 20;
  transition: border-color .2s, background .2s;
}
.topbar.scrolled { border-bottom-color: var(--border); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); }
.topbar .title-wrap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.topbar .conv-title {
  min-width: 0; font-weight: 600; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 4px 8px; border-radius: 8px; border: 1px solid transparent;
}
.topbar .conv-title:hover { background: var(--hover); }
.topbar .conv-title[contenteditable="true"] { background: var(--surface-2); border-color: var(--border-strong); outline: none; text-overflow: clip; }
.topbar .badge-off { color: var(--faint); display: inline-flex; align-items: center; gap: 5px; font-size: 12px; }

.cat-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px 4px 5px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 22%, transparent);
  white-space: nowrap; flex: none;
  transition: background .15s;
}
.cat-chip:hover { background: color-mix(in srgb, var(--c) 20%, transparent); }
.cat-chip .cat-icon { width: 20px; height: 20px; border-radius: 50%; background: color-mix(in srgb, var(--c) 22%, transparent); }
.cat-chip .cat-icon .ico { width: 12px; height: 12px; }
.cat-chip.none { --c: var(--muted); }
[data-theme="light"] .cat-chip { color: color-mix(in srgb, var(--c) 55%, #0B0B0B); }
[data-theme="light"] .cat-chip .cat-icon .ico { color: color-mix(in srgb, var(--c) 70%, #0B0B0B); }

.model-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 7px; border-radius: 10px;
  font-size: 13.5px; font-weight: 550; color: var(--text-2);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.model-btn:hover { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.model-btn .ico-s { color: var(--faint); }
.theme-picker {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 8px 0 9px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); font-size: 13px; font-weight: 520;
  transition: background .12s, border-color .12s, color .12s;
  flex: none;
}
.theme-picker:hover, .theme-picker:focus-within {
  background: var(--surface-2); border-color: var(--border-strong); color: var(--text);
}
.theme-picker .ico-s { color: var(--accent); pointer-events: none; }
.theme-select {
  appearance: none; -webkit-appearance: none;
  background: transparent; border: 0; outline: 0;
  color: inherit; font: inherit; cursor: pointer;
  padding-right: 16px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 6px) 50%, calc(100% - 2px) 50%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
.theme-select option { background: var(--surface-2); color: var(--text); }
.fam-badge {
  width: 22px; height: 22px; border-radius: 7px; flex: none;
  display: grid; place-items: center;
  font: 700 11px/1 var(--font-ui); letter-spacing: -.02em;
  color: #fff;
}
.fam-cursor { background: linear-gradient(140deg, #F5CB5C, #CD9C20); color: #0B0B0B; box-shadow: inset 0 0 0 1px rgba(242,236,221,.22); font-size: .8em; }
.fam-grok { background: linear-gradient(140deg, #333533, #0B0B0B); color: #F5CB5C; box-shadow: inset 0 0 0 1px rgba(245,203,92,.38); }
.fam-image { background: linear-gradient(140deg, #333533, #0B0B0B); color: #F5CB5C; box-shadow: inset 0 0 0 1px rgba(245,203,92,.48); }

/* ---------- Scroll area / views ---------- */
.scroller { flex: 1; overflow-y: auto; overflow-x: hidden; scroll-behavior: auto; overscroll-behavior: contain; position: relative; }
.view { min-height: 100%; display: flex; flex-direction: column; }
.wrap { width: 100%; max-width: var(--content-w); margin: 0 auto; padding: 0 24px; }

/* Home */
.home { position: relative; padding: 9vh 0 40px; }
.home::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 320px; pointer-events: none;
  background: radial-gradient(480px 160px at 50% 24%, rgba(245, 203, 92, .08), transparent 75%);
  opacity: .9;
}
.home > * { position: relative; }
.greet-kicker { font-size: 13px; color: var(--muted); letter-spacing: .02em; display: flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.greet-kicker .ember { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); animation: breathe 3.2s ease-in-out infinite; }
.greet {
  font: 420 clamp(34px, 5vw, 50px)/1.08 var(--font-display);
  font-variation-settings: "opsz" 120, "SOFT" 100, "WONK" 0;
  letter-spacing: -.022em;
  margin: 14px 0 6px;
}
.greet em { font-style: italic; color: var(--accent); font-variation-settings: "opsz" 120, "SOFT" 100, "WONK" 1; }
.greet-sub { color: var(--muted); font-size: 16.5px; margin: 0 0 28px; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px 6px 8px; border-radius: 999px;
  font-size: 13px; font-weight: 520; color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: background .12s, border-color .12s, color .12s, transform .1s;
}
.chip:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.chip:active { transform: scale(.97); }
.chip .ico { width: 14px; height: 14px; color: var(--c, var(--accent)); }
.chip.selected { color: var(--text); border-color: color-mix(in srgb, var(--c, var(--accent)) 55%, transparent); background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--surface)); }

.section-h { display: flex; align-items: baseline; justify-content: space-between; margin: 44px 0 12px; }
.section-h h2 { font: 500 19px/1.2 var(--font-display); letter-spacing: -.01em; margin: 0; font-variation-settings: "opsz" 36, "SOFT" 60; }
.section-h a, .section-h button { font-size: 13px; color: var(--muted); }
.section-h a:hover, .section-h button:hover { color: var(--text); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card {
  position: relative; text-align: left;
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 16px 14px;
  border-radius: var(--radius-l);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform .18s var(--ease), border-color .18s, background .18s, box-shadow .18s;
  min-height: 128px;
}
.card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--c, var(--accent)); opacity: .85; }
.card:hover { transform: translateY(-2px); border-color: var(--border-strong); background: var(--surface-2); box-shadow: var(--shadow); }
.card .card-top { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--c, var(--muted)); font-weight: 600; }
.card .card-top .when { margin-left: auto; color: var(--faint); font-weight: 500; }
.card .card-title { font-weight: 600; font-size: 14.5px; line-height: 1.35; color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .card-prev { font-size: 13px; color: var(--muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cards-empty { margin: 0; font-size: 13.5px; color: var(--muted); }

.memory-teaser {
  margin-top: 36px; display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: var(--radius-l);
  border: 1px dashed var(--border-strong); color: var(--muted); font-size: 13.5px;
}
.memory-teaser .ico { color: var(--accent); }
.memory-teaser button { margin-left: auto; color: var(--text-2); font-weight: 550; font-size: 13px; padding: 6px 10px; border-radius: 8px; }
.memory-teaser button:hover { background: var(--hover); color: var(--text); }

/* Category landing */
.space-head { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.space-icon {
  width: 56px; height: 56px; border-radius: 18px; flex: none;
  display: grid; place-items: center;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 16%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 25%, transparent), 0 10px 30px color-mix(in srgb, var(--c) 16%, transparent);
}
.space-icon .ico { width: 26px; height: 26px; }
.space-name { font: 460 34px/1.1 var(--font-display); letter-spacing: -.02em; margin: 0; font-variation-settings: "opsz" 96, "SOFT" 100; }
.space-tag { color: var(--muted); margin-top: 4px; font-size: 15px; }
.space-head .edit-space { margin-left: auto; }
.home.space::before { background: radial-gradient(520px 220px at 50% 36%, color-mix(in srgb, var(--c) 22%, transparent), transparent 72%); }

.starters { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 18px; }
.starter {
  text-align: left; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  font-size: 13.5px; color: var(--text-2); line-height: 1.45;
  display: flex; gap: 10px; align-items: flex-start;
  transition: background .12s, border-color .12s, color .12s;
}
.starter:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--c, var(--accent)) 40%, var(--border)); color: var(--text); }
.starter .ico { color: var(--c, var(--accent)); margin-top: 1px; width: 15px; height: 15px; }
.starter-wrap { position: relative; display: flex; }
.starter-wrap .starter { flex: 1; padding-right: 38px; }
.starter-edit {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center; color: var(--muted); opacity: 0; transition: opacity .12s, background .12s;
}
.starter-wrap:hover .starter-edit, .starter-edit:focus-visible { opacity: 1; }
.starter-edit:hover { background: var(--hover); color: var(--text); }
@media (hover: none) { .starter-edit { opacity: .7; } }
.starter-add { border-style: dashed; color: var(--muted); background: transparent; }
.starter-add:hover { background: var(--surface); }
.starter-hint { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }

.conv-rows { display: flex; flex-direction: column; }
.conv-row {
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 12px 12px; border-radius: var(--radius);
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.conv-row:last-child { border-bottom: 0; }
.conv-row:hover { background: var(--hover); }
.conv-row .r-main { flex: 1; min-width: 0; }
.conv-row .r-title { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-row .r-prev { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-row .r-when { font-size: 12px; color: var(--faint); white-space: nowrap; }

.gallery { columns: 3 200px; column-gap: 10px; }
.gallery .g-item { break-inside: avoid; margin-bottom: 10px; border-radius: 14px; overflow: hidden; position: relative; display: block; background: var(--surface); border: 1px solid var(--border); }
.gallery img { width: 100%; display: block; transition: transform .4s var(--ease); }
.gallery .g-item:hover img { transform: scale(1.03); }
.gallery .g-cap { position: absolute; inset: auto 0 0 0; padding: 28px 10px 8px; font-size: 12px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.65)); opacity: 0; transition: opacity .2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gallery .g-item:hover .g-cap { opacity: 1; }

/* ---------- Conversation ---------- */
.thread { padding: 18px 0 28px; }
.load-earlier { display: block; margin: 0 auto 14px; font-size: 13px; color: var(--muted); padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); }
.load-earlier:hover { color: var(--text); background: var(--hover); }
.convo-start { text-align: center; margin: 10px 0 26px; color: var(--faint); font-size: 12.5px; }
.convo-start .cat-chip { margin-bottom: 8px; }

.day {
  display: flex; align-items: center; gap: 14px;
  margin: 26px 0 18px; color: var(--faint);
  font-size: 12px; font-weight: 600; letter-spacing: .04em;
}
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.day .gap { font-weight: 500; color: var(--accent); opacity: .85; letter-spacing: 0; }

.msg { position: relative; margin: 0 0 22px; animation: rise .35s var(--ease) both; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .bubble {
  max-width: min(84%, 620px);
  padding: 11px 16px;
  background: var(--user-bubble);
  border: 1px solid var(--user-bubble-border);
  border-radius: 20px 20px 6px 20px;
  font-size: var(--text-base); line-height: 1.6;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.user .atts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-bottom: 6px; max-width: 84%; }
.msg .meta-row { display: flex; align-items: center; gap: 2px; min-height: 30px; opacity: 0; transition: opacity .15s; }
.msg:hover .meta-row, .msg.last .meta-row, .msg .meta-row:focus-within { opacity: 1; }
.msg.user .meta-row { justify-content: flex-end; margin-top: 2px; }
.msg .time { font-size: 11.5px; color: var(--faint); padding: 0 6px; }
.act {
  height: 28px; min-width: 28px; padding: 0 6px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  color: var(--faint); font-size: 12px; font-weight: 550;
  transition: background .12s, color .12s;
}
.act:hover { background: var(--hover); color: var(--text-2); }
.act.on { color: var(--accent); }
.act .ico { width: 15px; height: 15px; }

.msg.ai .who { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.msg.ai .who .fam-badge { width: 20px; height: 20px; border-radius: 6px; font-size: 10px; }
.msg.ai .who .web-tag { display: inline-flex; align-items: center; gap: 4px; font-weight: 500; color: var(--faint); }
.versions { display: inline-flex; align-items: center; gap: 0; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; margin-right: 4px; }
.versions .act { min-width: 24px; padding: 0 2px; }

.status-line {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 13.5px; color: var(--muted);
  padding: 4px 0 8px;
}
.status-line .spark { width: 16px; height: 16px; color: var(--accent); animation: spin 2.4s linear infinite; }
.status-line .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 2.2s linear infinite;
}

.reasoning { margin: 0 0 10px; }
.reasoning summary {
  list-style: none; cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--faint); padding: 3px 8px 3px 4px; border-radius: 8px;
}
.reasoning summary::-webkit-details-marker { display: none; }
.reasoning summary:hover { color: var(--text-2); background: var(--hover); }
.reasoning summary .ico { width: 13px; height: 13px; transition: transform .2s; }
.reasoning[open] summary .ico { transform: rotate(90deg); }
.reasoning .r-body {
  margin-top: 6px; padding: 8px 0 8px 14px; border-left: 2px solid var(--border-strong);
  color: var(--muted); font-size: 13.5px; line-height: 1.6; white-space: pre-wrap; max-height: 320px; overflow: auto;
}

/* Prose */
.prose { font-size: var(--text-base); line-height: 1.7; color: var(--text); overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 .85em; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--font-display); font-weight: 560; letter-spacing: -.01em; line-height: 1.3; margin: 1.4em 0 .5em; font-variation-settings: "opsz" 36, "SOFT" 60; }
.prose h1 { font-size: 1.45em; }
.prose h2 { font-size: 1.28em; }
.prose h3 { font-size: 1.12em; }
.prose h4 { font-size: 1em; }
.prose ul, .prose ol { margin: 0 0 .9em; padding-left: 1.4em; }
.prose li { margin: .28em 0; }
.prose li::marker { color: var(--faint); }
.prose ol li::marker { color: var(--muted); font-variant-numeric: tabular-nums; }
.prose strong { font-weight: 650; color: var(--text); }
.prose em { font-style: italic; }
.prose blockquote { margin: 0 0 1em; padding: .2em 0 .2em 1em; border-left: 3px solid var(--accent); color: var(--text-2); }
.prose hr { border: 0; height: 1px; background: var(--border-strong); margin: 1.6em 0; }
.prose a { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: var(--accent); }
.prose code { font-family: var(--font-mono); font-size: .86em; background: var(--surface-2); border: 1px solid var(--border); padding: .1em .38em; border-radius: 6px; }
.prose pre { position: relative; margin: 0 0 1em; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.prose pre code { display: block; padding: 14px 16px; overflow-x: auto; background: none; border: 0; font-size: 13.5px; line-height: 1.6; color: #F2ECDD; }
.prose pre .code-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; font: 500 11.5px var(--font-ui); color: #A5A196; background: rgba(242,236,221,.04); border-bottom: 1px solid rgba(242,236,221,.08); }
.prose pre .code-head button { color: #A5A196; display: inline-flex; gap: 5px; align-items: center; padding: 3px 7px; border-radius: 6px; font-size: 11.5px; }
.prose pre .code-head button:hover { background: rgba(245,203,92,.12); color: #F5CB5C; }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 1em; font-size: .92em; display: block; overflow-x: auto; }
.prose th, .prose td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.prose th { font-weight: 650; color: var(--text-2); border-bottom-color: var(--border-strong); white-space: nowrap; }
.prose tr:hover td { background: var(--hover); }
.prose img { max-width: 100%; border-radius: 10px; }
.prose .caret { display: inline-block; width: 8px; height: 1.05em; vertical-align: -2px; margin-left: 2px; border-radius: 2px; background: var(--accent); animation: blink 1s steps(2) infinite; }

/* highlight.js tokens (warm) */
.hljs-keyword, .hljs-selector-tag, .hljs-built_in { color: #f0a868; }
.hljs-string, .hljs-attr-value, .hljs-template-tag { color: #b9d08a; }
.hljs-number, .hljs-literal { color: #e89a9a; }
.hljs-comment, .hljs-quote { color: #7d7166; font-style: italic; }
.hljs-title, .hljs-section, .hljs-function .hljs-title { color: #8fc2e8; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-property { color: #e8c98f; }
.hljs-type, .hljs-class .hljs-title { color: #c6a8ef; }
.hljs-meta, .hljs-symbol { color: #9aa3b1; }

.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.source {
  display: inline-flex; align-items: center; gap: 6px; max-width: 240px;
  padding: 4px 10px 4px 6px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 12px; color: var(--text-2);
  transition: background .12s, border-color .12s;
}
.source:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; color: var(--text); }
.source .n { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-size: 10.5px; font-weight: 700; color: var(--muted); flex: none; }
.source .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source .h { color: var(--faint); font-size: 11px; white-space: nowrap; flex: none; }
.sources.collapsed .source.extra { display: none; }
.source.more { cursor: pointer; font: inherit; font-size: 12px; color: var(--muted); }

.mem-note {
  display: inline-flex; align-items: flex-start; gap: 8px;
  margin-top: 10px; padding: 7px 12px 7px 10px; border-radius: 12px;
  background: var(--accent-soft); color: var(--text-2); font-size: 12.5px; line-height: 1.45;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent);
  animation: rise .4s var(--ease) both;
}
.mem-note .ico { color: var(--accent); width: 14px; height: 14px; margin-top: 2px; }
.mem-note button { color: var(--accent); font-weight: 600; margin-left: 6px; font-size: 12.5px; }

.err-box {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
  color: var(--text-2); font-size: 14px;
}
.err-box .ico { color: var(--danger); margin-top: 1px; }
.err-box button { margin-left: auto; color: var(--text); font-weight: 600; font-size: 13px; padding: 4px 10px; border-radius: 8px; background: var(--hover); white-space: nowrap; }

/* Attachments */
.att-thumb { width: 92px; height: 92px; border-radius: 14px; overflow: hidden; border: 1px solid var(--border); background: var(--surface); display: block; }
.att-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.att-file {
  display: inline-flex; align-items: center; gap: 10px; max-width: 280px;
  padding: 8px 12px 8px 8px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); font-size: 13px; color: var(--text-2);
}
.att-file:hover { text-decoration: none; background: var(--surface-2); color: var(--text); }
.att-file .fi { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.att-file .fn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 550; }
.att-file .fs { font-size: 11.5px; color: var(--faint); }

.gen-image { position: relative; margin-top: 12px; border-radius: 18px; overflow: hidden; display: inline-block; max-width: 100%; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.gen-image img { display: block; max-width: 100%; max-height: 72vh; width: auto; height: auto; object-fit: contain; cursor: zoom-in; }
.gen-image .gi-actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; opacity: 0; transition: opacity .2s; }
.gen-image:hover .gi-actions { opacity: 1; }
.gen-image .gi-actions button, .gen-image .gi-actions a {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: rgba(15, 12, 10, .6); color: #fff; backdrop-filter: blur(8px);
}
.gen-image .gi-actions button:hover, .gen-image .gi-actions a:hover { background: rgba(15, 12, 10, .85); }
.painting {
  margin-top: 12px; width: min(100%, 520px); border-radius: 18px; position: relative; overflow: hidden;
  background: linear-gradient(120deg, var(--surface) 0%, var(--surface-3) 45%, var(--surface) 90%);
  background-size: 300% 100%; animation: shimmer 2.4s linear infinite;
  border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--muted);
}
.painting .ico { width: 30px; height: 30px; color: var(--accent); animation: breathe 2s ease-in-out infinite; }

/* Recap */
.recap {
  margin: 8px 0 26px; padding: 16px 18px; border-radius: var(--radius-l);
  background: linear-gradient(160deg, var(--accent-soft), transparent 70%), var(--surface);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  animation: rise .4s var(--ease) both;
}
.recap-h { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.recap-b { font: 400 16.5px/1.6 var(--font-display); font-variation-settings: "opsz" 24, "SOFT" 80; color: var(--text); }
.recap-b.loading { color: var(--muted); font-family: var(--font-ui); font-size: 14px; }

/* ---------- Composer ---------- */
.composer-dock { flex: none; padding: 0 0 18px; position: relative; z-index: 10; }
.composer-dock::before { content: ""; position: absolute; inset: -28px 0 0 0; pointer-events: none; background: linear-gradient(transparent, var(--bg) 26px); }
.composer-dock .wrap { position: relative; }
.composer {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--border-strong)); box-shadow: var(--shadow), 0 0 0 4px var(--accent-soft); }
.composer.drag { border-color: var(--accent); border-style: dashed; }
.composer textarea {
  display: block; width: 100%; resize: none; border: 0; outline: 0; background: transparent;
  padding: 16px 18px 6px; min-height: 56px; max-height: 40vh;
  font-size: var(--text-base); line-height: 1.55; color: var(--text);
}
.composer textarea::placeholder { color: var(--faint); }
.composer .tray { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px 0; }
.composer .tray:empty { display: none; }
.tray-item { position: relative; }
.tray-item .att-thumb { width: 64px; height: 64px; border-radius: 12px; }
.tray-item .att-file { padding: 6px 28px 6px 6px; }
.tray-item .att-file .fi { width: 28px; height: 28px; }
.tray-item .x {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center; background: var(--text); color: var(--bg); box-shadow: var(--shadow-s);
}
.tray-item .x .ico { width: 12px; height: 12px; stroke-width: 3; }
.tray-item.uploading { opacity: .55; }
.tray-item.uploading::after { content: ""; position: absolute; inset: 0; border-radius: 12px; background: linear-gradient(90deg, transparent, rgba(255,255,255,.12), transparent); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.c-bar { display: flex; align-items: center; gap: 4px; padding: 6px 8px 8px 10px; }
.c-bar .spacer { flex: 1; }
.tog {
  height: 34px; padding: 0 9px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 13px; font-weight: 550;
  transition: background .12s, color .12s;
}
.tog:hover { background: var(--hover); color: var(--text); }
.tog.on { color: var(--accent); background: var(--accent-soft); }
.tog .lbl { display: none; }
.tog.on .lbl { display: inline; }
.tog.rec { color: #fff; background: var(--danger); }
.tog.rec .ico { animation: breathe 1s ease-in-out infinite; }
.c-polish {
  height: 30px; padding: 0 10px; border-radius: 999px; flex: none;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 550; white-space: nowrap;
  color: var(--text-2); background: var(--surface); border: 1px solid var(--border-strong);
  transition: background .12s, border-color .12s, color .12s, opacity .12s;
}
.c-polish:hover:not(:disabled) { background: var(--hover); border-color: color-mix(in srgb, var(--accent) 45%, var(--border-strong)); color: var(--text); }
.c-polish:disabled { opacity: .4; cursor: default; }
.c-polish.busy { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border-strong)); opacity: 1; }
.c-polish.busy .ico { animation: breathe 1s ease-in-out infinite; }
.c-model { font-size: 12.5px; color: var(--faint); padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-flex; align-items: center; gap: 6px; border-radius: 8px; height: 30px; }
.c-model:hover { color: var(--text-2); background: var(--hover); }
.send {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 4px 14px var(--accent-glow);
  transition: transform .12s, background .15s, opacity .15s;
}
.send:hover { background: var(--accent-strong); }
.send:active { transform: scale(.93); }
.send:disabled { opacity: .35; cursor: default; box-shadow: none; }
.send .ico { stroke-width: 2.4; }
.send.stop { background: var(--text); color: var(--bg); }
.send.stop .ico { width: 14px; height: 14px; fill: currentColor; }
.c-hint { text-align: center; font-size: 11.5px; color: var(--faint); margin-top: 8px; }
.home .composer { box-shadow: var(--shadow-l); }

/* ---------- Popovers / menus ---------- */
.pop {
  position: fixed; z-index: 100;
  min-width: 220px; max-width: min(380px, calc(100vw - 20px));
  max-height: min(70vh, 560px); overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow-l);
  padding: 6px;
  animation: pop .16s var(--ease) both;
  transform-origin: top left;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: 9px;
  font-size: 14px; color: var(--text-2); text-align: left;
}
.menu-item:hover, .menu-item.kbd { background: var(--hover); color: var(--text); }
.menu-item .ico { color: var(--muted); width: 16px; height: 16px; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger .ico { color: var(--danger); }
.menu-item .check { margin-left: auto; color: var(--accent); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu-label { font-size: 11px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); padding: 8px 10px 4px; }

.model-pop { width: 360px; padding: 8px; }
.mp-fam { display: flex; align-items: center; gap: 10px; padding: 10px 8px 4px; }
.mp-fam .fam-name { font-weight: 650; font-size: 13.5px; }
.mp-fam .fam-maker { font-size: 12px; color: var(--faint); }
.mp-item { display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 8px 10px 8px 40px; border-radius: 10px; text-align: left; }
.mp-item:hover { background: var(--hover); }
.mp-item.sel { background: var(--accent-soft); }
.mp-item .mi-name { font-size: 14px; font-weight: 550; color: var(--text); }
.mp-item .mi-blurb { font-size: 12.5px; color: var(--muted); line-height: 1.4; margin-top: 1px; }
.mp-item .check { margin-left: auto; color: var(--accent); margin-top: 2px; }
.mp-foot { font-size: 12px; color: var(--faint); padding: 8px 10px 4px; border-top: 1px solid var(--border); margin-top: 6px; }

/* ---------- Modal ---------- */
.scrim { position: fixed; inset: 0; z-index: 90; background: var(--scrim); backdrop-filter: blur(3px); animation: fade .2s both; }
.modal {
  position: fixed; z-index: 95; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 40px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  box-shadow: var(--shadow-l);
  animation: modal .24s var(--ease) both;
}
.modal.wide { width: min(880px, calc(100vw - 24px)); height: min(680px, calc(100dvh - 40px)); }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 18px 20px 10px; }
.modal-h h3 { margin: 0; font: 520 21px/1.2 var(--font-display); letter-spacing: -.01em; font-variation-settings: "opsz" 48, "SOFT" 80; }
.modal-h .icon-btn { margin-left: auto; }
.modal-b { padding: 6px 20px 18px; overflow-y: auto; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; border-top: 1px solid var(--border); }
.modal p.lead { color: var(--muted); margin: 0 0 14px; font-size: 14px; line-height: 1.55; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 11px;
  font-weight: 600; font-size: 14px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong);
  transition: background .12s, border-color .12s, transform .08s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: default; }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field small { display: block; color: var(--faint); font-size: 12.5px; margin-top: 6px; line-height: 1.45; }
.input, .textarea, .select {
  width: 100%; padding: 10px 12px; border-radius: 11px;
  background: var(--input-bg, var(--bg-2)); border: 1px solid rgba(242, 236, 221, .22); color: var(--text);
  font-size: 14.5px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { resize: vertical; min-height: 96px; line-height: 1.55; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

.switch { display: flex; align-items: center; gap: 12px; padding: 10px 0; cursor: pointer; }
.switch input { display: none; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--surface-3); position: relative; transition: background .2s; flex: none; border: 1px solid var(--border-strong); }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-2); transition: transform .2s var(--ease), background .2s; }
.switch input:checked + .track { background: var(--accent); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(16px); background: #fff; }
.switch .sw-t { font-size: 14px; font-weight: 550; }
.switch .sw-d { font-size: 12.5px; color: var(--muted); margin-top: 1px; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--bg-2); border: 1px solid var(--border); }
.seg button { padding: 6px 14px; border-radius: 8px; font-size: 13px; font-weight: 550; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: var(--shadow-s); }

/* Settings */
.settings { display: grid; grid-template-columns: 200px 1fr; height: 100%; min-height: 0; }
.settings-nav { border-right: 1px solid var(--border); padding: 18px 10px; display: flex; flex-direction: column; gap: 2px; }
.settings-nav h3 { font: 520 21px/1.2 var(--font-display); margin: 0 10px 14px; font-variation-settings: "opsz" 48, "SOFT" 80; }
.settings-nav .nav-item .ico { color: var(--muted); }
.settings-nav .nav-item.active .ico { color: var(--accent); }
.settings-body { overflow-y: auto; padding: 22px 26px 30px; position: relative; }
.settings-body h4 { margin: 0 0 4px; font: 520 19px/1.3 var(--font-display); font-variation-settings: "opsz" 36, "SOFT" 70; }
.settings-body .lead { color: var(--muted); font-size: 14px; margin: 0 0 20px; line-height: 1.55; }
.settings-close { position: absolute; top: 14px; right: 14px; }
.settings-group { padding: 4px 0 18px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.settings-group:last-child { border-bottom: 0; }

.mem-list { display: flex; flex-direction: column; gap: 6px; }
.mem-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border);
}
.mem-item .mt { flex: 1; font-size: 14px; line-height: 1.5; outline: none; border-radius: 6px; }
.mem-item .mt[contenteditable="true"] { box-shadow: 0 0 0 2px var(--accent-soft); padding: 0 4px; }
.mem-item .ms { font-size: 11.5px; color: var(--faint); margin-top: 3px; }
.mem-item .ms a { color: var(--faint); text-decoration: underline; }
.mem-item .acts { display: flex; gap: 2px; opacity: .55; }
.mem-item:hover .acts { opacity: 1; }
.mem-add { display: flex; gap: 8px; margin-bottom: 14px; }

.space-list { display: flex; flex-direction: column; gap: 6px; }
.space-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--border); }
.space-row .sr-main { flex: 1; min-width: 0; }
.space-row .sr-name { font-weight: 600; font-size: 14px; }
.space-row .sr-tag { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.space-row.archived { opacity: .55; }
.space-row .sr-move { display: flex; flex-direction: column; }
.space-row .sr-move button { color: var(--faint); height: 16px; display: grid; place-items: center; }
.space-row .sr-move button:hover { color: var(--text); }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
.icon-grid button { height: 38px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); border: 1px solid var(--border); background: var(--bg-2); }
.icon-grid button:hover { color: var(--text); }
.icon-grid button.on { color: var(--c); border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; background: var(--s); border: 2px solid transparent; box-shadow: inset 0 0 0 2px var(--surface); }
.swatches button.on { border-color: var(--s); }

/* Palette */
.palette { top: 12vh; transform: translateX(-50%); width: min(640px, calc(100vw - 24px)); max-height: 70vh; }
.palette .p-input { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.palette .p-input .ico { color: var(--muted); }
.palette .p-input input { flex: 1; border: 0; outline: 0; background: none; font-size: 16.5px; }
.palette .p-results { overflow-y: auto; padding: 8px; }
.p-item { display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left; padding: 9px 10px; border-radius: 11px; }
.p-item:hover, .p-item.kbd { background: var(--hover); }
.p-item .p-main { flex: 1; min-width: 0; }
.p-item .p-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-item .p-snip { font-size: 13px; color: var(--muted); margin-top: 2px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.p-item mark { background: var(--accent-soft); color: var(--text); border-radius: 3px; padding: 0 1px; }
.p-item .p-when { font-size: 12px; color: var(--faint); white-space: nowrap; text-align: right; }
.p-item .p-more { font-size: 11px; margin-top: 3px; }
.p-empty { color: var(--faint); font-size: 14px; padding: 22px; text-align: center; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 120; background: rgba(6, 5, 4, .92); display: grid; place-items: center; animation: fade .2s both; cursor: zoom-out; }
.lightbox img { max-width: 94vw; max-height: 86vh; border-radius: 12px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.lightbox .lb-cap { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); width: min(760px, 92vw); text-align: center; color: rgba(255,255,255,.75); font-size: 13.5px; line-height: 1.5; }
.lightbox .lb-actions { position: absolute; top: 16px; right: 16px; display: flex; gap: 8px; }
.lightbox .lb-actions a, .lightbox .lb-actions button { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff; background: rgba(255,255,255,.1); }
.lightbox .lb-actions a:hover, .lightbox .lb-actions button:hover { background: rgba(255,255,255,.2); }

/* Toast */
.toasts { position: fixed; z-index: 130; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 12px; background: var(--text); color: var(--bg); font-size: 14px; font-weight: 550; box-shadow: var(--shadow-l); animation: rise .25s var(--ease) both; }
.toast.err { background: var(--danger); color: #fff; }
.toast button { color: inherit; text-decoration: underline; font-weight: 650; }

.jump-bottom {
  position: absolute; right: 50%; transform: translateX(50%); bottom: calc(100% + 10px);
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-2); box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.jump-bottom.show { opacity: 1; pointer-events: auto; }
.flash { animation: flash 2.2s var(--ease); border-radius: 14px; }

/* Login */
.login-page { overflow: auto; }
.login {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden;
}
.login::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, #0B0B0B 0%, #CD9C20 35%, #F5CB5C 50%, #CD9C20 65%, #0B0B0B 100%);
  pointer-events: none;
}
.login-card { position: relative; width: min(410px, 100%); text-align: center; }
.login-card .brand-mark { width: 58px; height: 58px; border-radius: 18px; margin: 0 auto 22px; border: 2px solid #CD9C20; }
.login-card .brand-mark svg { width: 30px; height: 30px; }
.login-card h1 { font: 420 40px/1.1 var(--font-display); letter-spacing: -.02em; margin: 0 0 8px; color: var(--text); font-variation-settings: "opsz" 120, "SOFT" 100; }
.login-card p { color: var(--muted); margin: 0 0 28px; font-size: 15.5px; }
.login-form {
  text-align: left; background: var(--surface); border: 1px solid #CD9C20;
  border-top: 3px solid #F5CB5C; border-radius: 20px; padding: 24px;
  box-shadow: var(--shadow-l);
}
.login-form .btn { width: 100%; height: 44px; margin-top: 8px; font-size: 15px; font-weight: 700; }
.login-form .btn.primary { background: #F5CB5C; color: #0B0B0B; border: 1px solid #CD9C20; }
.login-form .btn.primary:hover { background: #CD9C20; color: #0B0B0B; }
.login-err { color: var(--danger); font-size: 13.5px; margin: -4px 0 12px; display: flex; gap: 8px; align-items: center; }
.login-note { color: var(--muted); font-size: 13.5px; margin: -4px 0 12px; line-height: 1.45; }
.login-code { font: 600 26px/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .45em; text-align: center; padding-left: .45em; }
.login-alt { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: 14px; }
.login-alt .btn { font-size: 13.5px; height: 34px; }
.login-foot { margin-top: 22px; color: #CD9C20; font-size: 12.5px; letter-spacing: .02em; }

/* ---------- Animations ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes modal { from { opacity: 0; transform: translate(-50%, -48%) scale(.97); } to { opacity: 1; transform: translate(-50%, -50%); } }
.palette { animation-name: palette; }
@keyframes palette { from { opacity: 0; transform: translate(-50%, -8px) scale(.98); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes blink { 0% { opacity: 1; } 50% { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -100% 0; } }
@keyframes breathe { 0%, 100% { opacity: .65; transform: scale(1); } 50% { opacity: 1; transform: scale(1.06); } }
@keyframes pulse { 0%, 100% { opacity: .4; } 50% { opacity: 1; } }
@keyframes flash { 0%, 30% { background: var(--accent-soft); box-shadow: 0 0 0 8px var(--accent-soft); } 100% { background: transparent; box-shadow: 0 0 0 8px transparent; } }

@keyframes glow { 0%, 100% { opacity: .7; transform: translate(-50%, -50%) scale(1); } 50% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); } }

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

/* ---------- Responsive ---------- */
.only-mobile { display: none; }
@media (max-width: 900px) {
  .app, .app.sidebar-collapsed { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(320px, 86vw);
    transform: translateX(-102%); opacity: 1; pointer-events: auto;
    box-shadow: var(--shadow-l);
  }
  .app.drawer-open .sidebar { transform: none; }
  .app.sidebar-collapsed .sidebar { transform: translateX(-102%); opacity: 1; }
  .drawer-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity .25s; }
  .app.drawer-open .drawer-scrim { opacity: 1; pointer-events: auto; }
  .only-mobile { display: grid; }
  .only-desktop { display: none !important; }
  .wrap { padding: 0 14px; }
  .home { padding-top: 4vh; }
  .greet { font-size: 34px; }
  .starters { grid-template-columns: 1fr; }
  .msg.user .bubble { max-width: 90%; }
  .settings { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .settings-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 12px 10px; }
  .settings-nav h3 { display: none; }
  .settings-nav .nav-item { white-space: nowrap; width: auto; }
  .settings-body { padding: 18px 16px 26px; }
  .modal.wide { height: calc(100dvh - 20px); }
  .topbar { padding: 0 8px; }
  .topbar .model-btn { display: none; }
  .composer-dock { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .c-hint { display: none; }
  .msg .meta-row { opacity: 1; }
  .msg:not(.last) .meta-row .act:not(.keep) { display: none; }
}
@media (max-width: 560px) {
  .topbar .cat-chip .lbl { display: none; }
  .topbar .cat-chip { padding: 4px; }
  .c-bar { flex-wrap: wrap; row-gap: 6px; }
  .c-polish .c-polish-tail { display: none; }
  .cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .card { min-height: 112px; padding: 12px 12px 12px 14px; }
  .card .card-prev { -webkit-line-clamp: 2; }
  .space-name { font-size: 28px; }
}
@media (hover: none) {
  .conv-item .more { opacity: 1; }
  .gen-image .gi-actions { opacity: 1; }
}

/* Email a reply */
.modal.share-modal { width: min(1020px, calc(100vw - 24px)); height: min(720px, calc(100dvh - 40px)); }
.share-modal .modal-h > .ico { color: var(--accent); }
.share-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 380px) 1fr; border-top: 1px solid var(--border); }
.share-form { padding: 18px 20px; overflow-y: auto; border-right: 1px solid var(--border); }
.share-form .opt { font-style: normal; font-weight: 400; color: var(--faint); }
.to-wrap { position: relative; }
.to-box { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 44px; padding: 6px 8px; border-radius: 11px; background: var(--bg-2); border: 1px solid var(--border-strong); cursor: text; transition: border-color .15s, box-shadow .15s; }
.to-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.to-chips { display: contents; }
.to-input { flex: 1; min-width: 120px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 14.5px; padding: 4px; }
.to-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 4px 0 3px; border-radius: 999px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); font-size: 13.5px; font-weight: 550; max-width: 100%; }
.to-chip button { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: var(--muted); }
.to-chip button:hover { background: var(--hover); color: var(--text); }
.av { display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%; background: linear-gradient(140deg, #e8955a, #c8602a); color: #fff; font-size: 10.5px; font-weight: 700; letter-spacing: .02em; }
.to-sugg { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow-l); padding: 5px; }
.sugg-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 9px; text-align: left; font-size: 14px; }
.sugg-item .nm { font-weight: 550; }
.sugg-item .em { color: var(--faint); font-size: 12.5px; margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sugg-item.on, .sugg-item:hover { background: var(--hover); }
.to-quick { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.to-quick .q-lbl { font-size: 12px; color: var(--faint); margin-right: 2px; }
.to-quick .chip { margin: 0; padding: 4px 12px 4px 4px; }
.to-quick .chip .av { width: 22px; height: 22px; font-size: 10px; }
.share-preview { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #ffffff; border-radius: 0 0 22px 0; }
.pv-lbl { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 600; letter-spacing: .04em; color: #777; padding: 10px 16px; border-bottom: 1px solid #eee; }
.pv-lbl > span { flex: 1; }
.pv-reset { font: inherit; font-size: 12px; font-weight: 600; color: #b05a21; background: none; border: 0; padding: 0; cursor: pointer; }
.pv-reset:hover { text-decoration: underline; }
.share-frame { flex: 1; width: 100%; border: 0; background: #ffffff; }
.contact-item { align-items: center; }
.contact-fields { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr 1.4fr; gap: 6px 8px; }
.contact-fields .ms { grid-column: 1 / -1; }
.input.slim { padding: 6px 10px; font-size: 13.5px; border-radius: 9px; background: transparent; border-color: transparent; }
.input.slim:hover { border-color: var(--border); }
.input.slim:focus { background: var(--bg-2); }
@media (max-width: 900px) {
  .share-grid { grid-template-columns: 1fr; overflow-y: auto; }
  .share-form { border-right: 0; overflow: visible; }
  .share-preview { min-height: 460px; border-radius: 0; }
  .contact-fields { grid-template-columns: 1fr; }
}

[data-theme="light"] .input, [data-theme="light"] .textarea, [data-theme="light"] .select {
  border-color: rgba(51, 53, 51, .28);
}
