/* Mosaik web chat (/chat).
 *
 * The desktop app's own page, carried over: its tokens under the same names
 * (mosaik-desktop: styles/palette.py, metrics.py, core/appearance.py) and its
 * components rule for rule (resources/app/css: base, shell, composer, prose,
 * chat, reasoning and overlays), cut down to what a chat in a browser has.
 * The desktop's Python writes the theme into the page; here html.dark and
 * html.light are set before the first paint by js/chat/boot.js.
 */

@font-face {
  font-family: "Inter";
  src: url("../fonts/Inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2190-2199, U+21E7, U+2212, U+2215,
    U+2318, U+2325, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/Inter-latin-ext.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1EFF,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Maths: Latin Modern Math, under the GUST Font License (fonts/GUST-FONT-LICENSE.txt).
   It carries the MATH table browsers lay formulas out with, and loads only
   when a formula is on the page. */
@font-face {
  font-family: "Latin Modern Math";
  src: url("../fonts/LatinModernMath.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("../fonts/Fraunces-latin-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Fraunces";
  src: url("../fonts/Fraunces-latin-ext-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
    U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---- tokens ------------------------------------------------------------- */
:root {
  /* The tesserae: the same glass in both themes. */
  --tile-navy: #2e4574;
  --tile-oxblood: #87302f;
  --tile-teal: #1b605a;
  --tile-gold: #f6c453;
  --tile-amber: #dc9a33;
  --tile-ochre: #c9862a;
  --tile-cream: #eedcb4;
  --on-picture-light: #fbf6ec;
  --on-picture-dark: #1c1814;

  /* Light. */
  --bg: #ffffff;
  --sidebar: #f7f7f7;
  --surface: #ffffff;
  --surface-hover: #f1f1f1;
  --surface-pressed: #e7e7e7;
  --raised: #ffffff;
  --card: #fafafa;
  --border: #e6e6e6;
  --border-strong: #d4d4d4;
  --text: #191919;
  --text2: #5e5e5e;
  --text3: #8b8b8b;
  --accent: #dc9a33;
  --accent-hover: #cf8c26;
  --accent-pressed: #bd7d1d;
  --accent-text: #1f1a14;
  --accent-ink: #8a560e;
  --accent-wash: #fbf1e1;
  --selection-strong: #e6e6e6;
  --danger: #b3352a;
  --danger-text: #ffffff;
  --added: #1f7a48;
  --user-bubble: #f3f3f3;
  --code-bg: #1b1b1b;
  --code-fg: #e6e6e6;
  --code-border: #262626;
  --inline-code-bg: #f0f0f0;
  --link: #1a5fb4;
  --shimmer: #141414;
  --table-head: #f5f5f5;
  --table-zebra: #fbfbfb;
  --scrollbar: #d0d0d0;
  --scrollbar-hover: #b0b0b0;
  --input-bg: #ffffff;
  --scrim: #0f0f0f66;
  --shadow-cast: #1616161f;
  --shadow-soft: #16161612;
  --tok-k: #b18ae8;
  --tok-s: #7fd1a0;
  --tok-c: #6b7684;
  --tok-n: #7fd3e8;
  --tok-f: #79b8ff;

  /* Motion. */
  --dur-fast: 110ms;
  --dur: 170ms;
  --dur-slow: 260ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.36, 0.64, 1);

  /* Reading: Comfortable, as the app's default. */
  --font-sans: "Inter", "Segoe UI Variable Text", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Cascadia Code", "JetBrains Mono", "SF Mono", Consolas, "Courier New", monospace;
  --font-size: 15px;
  --line-height: 1.68;
  --block-gap: 0.95em;
  --message-gap: 28px;
  --density-pad: 11px;
  --reading-width: 820px;
  --meta: calc(var(--font-size) * 0.74);

  /* The page's own measures. */
  --header-h: 52px;
  --sidebar-w: 264px;
  --rail-w: 56px;
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --ui: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --ui-size: 13.5px;
  --ui-small: 12px;
  --ui-meta: 11.5px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-badge: 4px;
  --radius-control: 7px;
  --radius-card: 10px;
  --hairline: 1px;
  color-scheme: light;
}

html.dark {
  --bg: #171717;
  --sidebar: #111111;
  --surface: #1f1f1f;
  --surface-hover: #262626;
  --surface-pressed: #2e2e2e;
  --raised: #1d1d1d;
  --card: #1b1b1b;
  --border: #282828;
  --border-strong: #383838;
  --text: #ececec;
  --text2: #a3a3a3;
  --text3: #727272;
  --accent: #e0a23e;
  --accent-hover: #ebb050;
  --accent-pressed: #c98f2e;
  --accent-text: #1b1408;
  --accent-ink: #eab25a;
  --accent-wash: #2a2216;
  --selection-strong: #2c2c2c;
  --danger: #e5776b;
  --danger-text: #141414;
  --added: #5fc98a;
  --user-bubble: #242424;
  --code-bg: #111111;
  --code-fg: #e4e4e4;
  --code-border: #262626;
  --inline-code-bg: #252525;
  --link: #8fbaf2;
  --shimmer: #f4f4f4;
  --table-head: #1d1d1d;
  --table-zebra: #1a1a1a;
  --scrollbar: #3a3a3a;
  --scrollbar-hover: #525252;
  --input-bg: #1a1a1a;
  --scrim: #0000008c;
  --shadow-cast: #00000070;
  --shadow-soft: #00000047;
  --tok-c: #5b6672;
  color-scheme: dark;
}

/* ---- primitives (base.css) ------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--ui);
  font-size: var(--ui-size);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
  -webkit-tap-highlight-color: transparent;
}

button,
input,
textarea,
select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--link); }

::selection { background: color-mix(in srgb, var(--accent) 32%, transparent); }

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

svg { display: block; }
.icon { display: inline-flex; width: 16px; height: 16px; flex: none; }
.icon svg { width: 100%; height: 100%; }

.skip {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 200;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
}
.skip:focus { top: 12px; }

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  background-clip: padding-box;
  border: 3px solid transparent;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); background-clip: padding-box; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: var(--ui-size);
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--surface-hover); }
.btn:active:not(:disabled) { transform: translateY(0.5px) scale(0.99); background: var(--surface-pressed); }
.btn:disabled { opacity: 0.5; }
.btn .icon { width: 14px; height: 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 550; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.primary:active:not(:disabled) { background: var(--accent-pressed); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--danger-text); }
.btn.danger:hover:not(:disabled) { filter: brightness(1.06); background: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.btn.small { height: 26px; padding: 0 9px; font-size: var(--ui-small); }
.btn.large { height: 36px; padding: 0 16px; font-size: 14px; border-radius: 10px; }

.ibtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text2);
  flex: none;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}
.ibtn:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.ibtn:active:not(:disabled) { background: var(--surface-pressed); transform: scale(0.94); }
.ibtn:disabled { opacity: 0.4; }
.ibtn .icon { width: 16px; height: 16px; }
.ibtn.small { width: 24px; height: 24px; }
.ibtn.small .icon { width: 14px; height: 14px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  white-space: nowrap;
  max-width: 100%;
  min-width: 0;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}
.pill:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }
.pill:active:not(:disabled) { background: var(--surface-pressed); }
.pill .icon { width: 14px; height: 14px; }
.pill .chev { width: 12px; height: 12px; color: var(--text3); }
.pill .label { overflow: hidden; text-overflow: ellipsis; }
.pill.active { background: var(--accent-wash); color: var(--accent-ink); }
.pill.active:hover { background: color-mix(in srgb, var(--accent-wash) 80%, var(--accent) 20%); }

.field {
  width: 100%;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
  font-size: var(--ui-size);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
textarea.field { height: auto; min-height: 96px; padding: 9px 11px; line-height: 1.5; resize: vertical; }
.field::placeholder { color: var(--text3); }
.field:hover { border-color: color-mix(in srgb, var(--border-strong) 60%, var(--text3)); }
.field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  outline: none;
}

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; line-height: 1.45; position: relative; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box {
  flex: none;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  transition: background var(--dur) var(--ease);
}
.check .box::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform var(--dur) var(--ease-spring);
}
.check input:checked + .box { background: var(--accent); }
.check input:checked + .box::after { transform: translateX(14px); }
.check input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }
.check .check-text { display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; color: var(--text); padding-top: 1px; }
.check .check-text .form-hint { font-size: 12px; }

kbd {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  font-family: var(--ui);
  font-size: 11px;
  color: var(--text2);
  background: var(--surface);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-hover);
  color: var(--text2);
}
.tag.accent { background: var(--accent-wash); color: var(--accent-ink); }

.tile { display: inline-block; width: 8px; height: 8px; border-radius: 2px; flex: none; }
.tile.navy { background: var(--tile-navy); }
.tile.amber { background: var(--tile-amber); }
.tile.oxblood { background: var(--tile-oxblood); }
.tile.teal { background: var(--tile-teal); }
.tile.gold { background: var(--tile-gold); }

.mosaic-strip { display: block; width: 100%; height: 5px; flex: none; }

/* ---- popovers and menus -------------------------------------------------- */
.popover {
  position: fixed;
  z-index: 88;
  min-width: 180px;
  max-width: min(360px, calc(100vw - 16px));
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--raised);
  box-shadow: 0 1px 2px var(--shadow-soft), 0 12px 32px -6px var(--shadow-cast);
  transform-origin: var(--origin, top left);
  animation: pop-in var(--dur) var(--ease-out) both;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.popover > .mosaic-strip { width: calc(100% + 10px); margin: -5px -5px 5px; }
.popover.leaving { animation: pop-out 120ms var(--ease) both; pointer-events: none; }
@keyframes pop-in {
  from { opacity: 0; transform: translateY(var(--pop-y, -4px)) scale(0.97); }
  to { opacity: 1; transform: none; }
}
@keyframes pop-out { to { opacity: 0; transform: translateY(var(--pop-y, -4px)) scale(0.98); } }

.popover > .menu { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 32px;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: var(--ui-size);
  text-align: left;
  transition: background var(--dur-fast) var(--ease);
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-hover); outline: none; }
.menu-item:disabled { color: var(--text3); background: transparent; }
.menu-item .icon { width: 15px; height: 15px; color: var(--text2); }
.menu-item .hint { margin-left: auto; color: var(--text3); font-size: var(--ui-small); padding-left: 16px; }
.menu-item .check-mark { margin-left: auto; color: var(--accent-ink); width: 15px; height: 15px; }
.menu-item.danger, .menu-item.danger .icon { color: var(--danger); }
.menu-item .sub { display: block; color: var(--text3); font-size: var(--ui-small); margin-top: 1px; }
.menu-item .text { display: flex; flex-direction: column; min-width: 0; }
.menu-sep { height: 1px; margin: 5px 6px; background: var(--border); flex: none; }
.menu-title {
  padding: 8px 10px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text3);
}
.menu-note { max-width: 300px; padding: 8px 10px 6px; font-size: var(--ui-small); line-height: 1.45; color: var(--text2); }

/* ---- tooltips and toasts ---------------------------------------------------- */
#tooltip {
  position: fixed;
  z-index: 90;
  max-width: 300px;
  padding: 6px 9px;
  border-radius: 7px;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-line;
  pointer-events: none;
  opacity: 0;
  transform: translateY(2px);
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
#tooltip.shown { opacity: 1; transform: none; }
#tooltip kbd { background: transparent; color: inherit; border-color: color-mix(in srgb, var(--bg) 40%, transparent); height: 17px; margin-left: 6px; }

#toasts {
  position: fixed;
  left: 50%;
  top: calc(var(--header-h) + 14px);
  z-index: 95;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 520px;
  padding: 9px 14px;
  border-radius: 11px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  box-shadow: 0 10px 30px -8px var(--shadow-cast);
  animation: toast-in var(--dur-slow) var(--ease-out) both;
}
.toast .icon { width: 15px; height: 15px; }
.toast.leaving { animation: toast-out 200ms var(--ease) both; }
.toast.danger { background: var(--danger); color: var(--danger-text); }
.toast .toast-action {
  pointer-events: auto;
  flex: none;
  white-space: nowrap;
  margin: -4px -6px -4px 4px;
  padding: 4px 10px;
  border: 0;
  border-radius: 7px;
  background: color-mix(in srgb, var(--bg) 16%, transparent);
  color: inherit;
  font: 600 12.5px/1.2 var(--ui);
}
.toast .toast-action:hover { background: color-mix(in srgb, var(--bg) 28%, transparent); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-6px); } }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes settle-in { from { opacity: 0; transform: scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.spinner { width: 14px; height: 14px; animation: spin 0.9s linear infinite; }

.reduced-motion *,
.reduced-motion *::before,
.reduced-motion *::after {
  animation-duration: 1ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 1ms !important;
  scroll-behavior: auto !important;
}

/* ---- the frame (shell.css) --------------------------------------------------- */
#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
}

#sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  flex: none;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  transition: width var(--dur-slow) var(--ease-out), border-color var(--dur-slow) var(--ease);
  overflow: hidden;
  z-index: 3;
}
#app.collapsed #sidebar { width: var(--rail-w); }

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--header-h);
  padding: 0 12px;
  flex: none;
}
.brand .brand-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
  border-radius: var(--radius-sm);
}
.brand .brand-name img { width: 20px; height: 20px; flex: none; }
.brand .brand-name .web { color: var(--text3); font-weight: 500; font-size: 13px; }
.panel-toggle .icon path:nth-of-type(2) {
  opacity: 0;
  transform: translateX(1.5px);
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur) var(--ease-out);
}
.panel-toggle.opens .icon path:nth-of-type(2) { transform: translateX(-1.5px); }
.panel-toggle:is(:hover, :focus-visible) .icon path:nth-of-type(2) { opacity: 1; transform: none; }

.side-actions { display: flex; flex-direction: column; gap: 2px; padding: 2px 10px 6px; flex: none; }

.nav {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: var(--ui-size);
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.nav .icon { width: 17px; height: 17px; color: var(--text2); }
.nav:hover { background: var(--surface-hover); }
.nav:active { transform: scale(0.99); }
.nav .hint { margin-left: auto; color: var(--text3); font-size: 12px; }
.nav.primary { font-weight: 600; }
.nav .label { overflow: hidden; text-overflow: ellipsis; }

/* New chat is filled only on a new chat: a field of amber tiles that fades in under the words. */
.amber-fill {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), filter var(--dur-fast) var(--ease);
}
:is(.nav, .ibtn).primary > :not(.amber-fill) { position: relative; }
:is(.nav, .ibtn).primary.current { background: transparent; color: var(--accent-text); }
:is(.nav, .ibtn).primary.current .icon { color: var(--accent-text); }
:is(.nav, .ibtn).primary.current .amber-fill { opacity: 1; }
:is(.nav, .ibtn).primary.current:hover .amber-fill { filter: brightness(1.06); }

.side-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 10px 12px;
  scrollbar-gutter: stable;
}
.side-scroll::-webkit-scrollbar { width: 8px; }

.group { margin-top: 6px; }
.group-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  height: 30px;
  padding: 10px 12px 4px;
  background: var(--sidebar);
  color: var(--text3);
  font-size: 12px;
  font-weight: 600;
}

.row {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 32px;
  padding: 0 4px 0 10px;
  margin: 1px 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: var(--ui-size);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.row .open {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  height: 100%;
  margin-left: -10px;
  padding: 0 0 0 10px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
}
.row .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row:hover { background: var(--surface-hover); }
.row.selected { background: var(--selection-strong); font-weight: 550; }
.row .more {
  flex: none;
  width: 24px;
  height: 24px;
  opacity: 0;
  color: var(--text2);
  transition: opacity var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.row:hover .more, .row .more.open, .row:focus-within .more, .row.selected .more { opacity: 1; }
.row .more:hover { background: var(--surface-pressed); }
.row .pin-mark { flex: none; display: inline-flex; margin-right: 7px; color: var(--text3); }
.row .pin-mark .icon { width: 13px; height: 13px; }
.row .busy-dot { width: 6px; height: 6px; flex: none; margin: 0 6px; border-radius: 50%; background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite; }
.row.entering { animation: rise-in var(--dur-slow) var(--ease-out) both; }
.side-empty { padding: 26px 14px; color: var(--text3); font-size: 12.5px; line-height: 1.5; text-align: center; }

.side-foot { flex: none; }
.side-foot .mosaic-strip { height: 6px; }
/* The one row at the bottom of the sidebar: your account and its menu (account.js). */
.account-side { display: flex; align-items: center; gap: 4px; padding: 8px 10px 10px; cursor: default; outline: none; }
.account-who-side {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 7px 8px;
  border-radius: var(--radius-md);
  transition: background var(--dur-fast) var(--ease);
}
.account-side:hover .account-who-side,
.account-side.open .account-who-side,
.account-side:focus-visible .account-who-side { background: var(--surface-hover); }
.account-side:focus-visible .account-who-side { box-shadow: 0 0 0 2px var(--accent); }
.account-side .theme-toggle { flex: none; }
.account-chev { flex: none; width: 14px; height: 14px; margin-left: auto; color: var(--text3); }
.account-glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-wash);
  color: var(--accent-ink);
}
.account-glyph .icon { width: 16px; height: 16px; }
.account-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.account-text b, .account-text span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.account-text b { color: var(--text); font-size: 13.5px; font-weight: 600; }
.account-text span { color: var(--text3); font-size: 12px; }
.account-text span.alert { color: var(--accent-ink); }
.account-pic { position: relative; display: inline-flex; flex: none; }
.account-avatar { display: inline-flex; width: 30px; height: 30px; overflow: hidden; border-radius: 8px; }
.account-avatar svg { width: 100%; height: 100%; }
.account-pic.alert::after {
  content: "";
  position: absolute;
  top: -2px;
  right: -2px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--sidebar);
  border-radius: 50%;
  background: var(--accent);
}
.account-rail .account-avatar { width: 24px; height: 24px; border-radius: 6px; }
.account-rail .account-glyph { width: 26px; height: 26px; border-radius: 8px; }
.account-rail .account-glyph .icon { width: 15px; height: 15px; }

/* Settings › Account. */
.account-body { display: flex; flex-direction: column; gap: 12px; }
.account-line { display: flex; align-items: center; gap: 8px; color: var(--text2); font-size: 13px; line-height: 1.45; }
.account-line .icon { width: 15px; height: 15px; flex: none; color: var(--accent); }
.account-line.danger { color: var(--danger); }
.account-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.account-who { display: flex; flex-direction: column; gap: 8px; }
.account-who b { font-size: 14px; font-weight: 600; }
.account-join { display: flex; flex-direction: column; gap: 6px; }
.account-code, .account-request {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--accent-wash);
}
.account-request { border-color: var(--border-strong); background: var(--surface); }
.account-code-text, .account-digits {
  color: var(--text);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.08em;
  user-select: all;
}
.account-digits { margin-top: 4px; font-size: 22px; letter-spacing: 0.16em; }
.account-code-input { font-family: var(--font-mono, ui-monospace, monospace); letter-spacing: 0.04em; }

.side-foot .get-app {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 10px 8px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text2);
  font-size: 12.5px;
  line-height: 1.35;
  text-decoration: none;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.side-foot .get-app:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-hover); }
.side-foot .get-app .icon { width: 16px; height: 16px; color: var(--accent-ink); }
.side-foot .get-app b { display: block; color: var(--text); font-weight: 600; }

.rail { display: none; flex-direction: column; align-items: center; gap: 6px; height: 100%; padding: 11px 0 12px; }
#app.collapsed .rail { display: flex; }
#app.collapsed .expanded-only { display: none !important; }
.rail .logo { display: block; width: 26px; height: 26px; margin-bottom: 8px; }
.rail .logo img { width: 100%; height: 100%; }
.rail .ibtn { width: 34px; height: 34px; border-radius: 10px; }
.rail .ibtn .icon { width: 17px; height: 17px; }
.rail .ibtn.primary { position: relative; overflow: hidden; }
.rail .spacer { flex: 1; }

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

#header {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--header-h);
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--border);
  flex: none;
  position: relative;
  z-index: 2;
  background: var(--bg);
  transition: background var(--dur-slow) var(--ease), border-color var(--dur-slow) var(--ease);
}
#header .menu-open { display: none; margin-left: -6px; }
#header .title {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#header .title.swap { animation: rise-in var(--dur) var(--ease-out); }
.header-tools { display: flex; align-items: center; gap: 4px; margin-left: auto; flex: none; }

#stage { position: relative; flex: 1; min-width: 0; min-height: 0; overflow: hidden; }
.view { position: absolute; inset: 0; }

#dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  padding: 0 24px 26px;
  pointer-events: none;
  transition: transform 520ms var(--ease-out);
}
#dock > * { pointer-events: auto; }
#app.settled #dock { transition: none; }

/* ---- the New Chat picture --------------------------------------------------- */
#backdrop { position: absolute; inset: 0; z-index: 0; display: none; overflow: hidden; pointer-events: none; }
#app:is(.fresh, .dismissing) #backdrop { display: block; }
#backdrop .scene { position: absolute; inset: 0; animation: fade-in 360ms var(--ease-out) both; }
#backdrop .scene-plate { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#backdrop canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: cover; }
#backdrop::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: calc(var(--header-h) + 90px);
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 58%, transparent) 0%,
    color-mix(in srgb, var(--bg) 30%, transparent) 40%, transparent 100%);
  transition: opacity 600ms var(--ease);
}
#app.dismissing #backdrop::after { opacity: 0; }
html.light #app:is(.fresh, .dismissing) #header {
  --text2: var(--text);
  --text3: var(--text);
  text-shadow: 0 0 2px var(--bg), 0 0 8px var(--bg);
}
#app:is(.fresh, .dismissing) #header { background: transparent; border-bottom-color: transparent; }
#app:is(.fresh, .dismissing) #sidebar { border-right-color: transparent; }
#view-chat > .scene-pick {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px 0 9px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  color: var(--text2);
  font-size: 12.5px;
  box-shadow: 0 1px 2px var(--shadow-soft);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease),
    color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
#view-chat > .scene-pick .icon { width: 14px; height: 14px; }
#view-chat > .scene-pick:hover { color: var(--text); background: var(--surface); }
#app.fresh #view-chat > .scene-pick { opacity: 1; pointer-events: auto; transform: none; }
#app.fresh #dock { transform: translateY(calc((var(--dock-h, 150px) - 26px) / 2 + 26px - (100dvh - var(--header-h)) / 2)); }
#app:is(.fresh, .dismissing) #view-chat > .veil { opacity: 0; }

/* ---- the conversation (chat.css) ------------------------------------------- */
#view-chat .conversation {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 11px;
  scroll-behavior: auto;
}
#view-chat .column {
  max-width: calc(var(--reading-width) + 48px);
  margin: 0 auto;
  padding: 28px 24px calc(var(--dock-h, 150px) + 40px);
  font-family: var(--font-sans);
  font-size: var(--font-size);
  line-height: var(--line-height);
}
#view-chat > .veil {
  position: absolute;
  left: 0;
  right: 11px;
  bottom: 0;
  height: calc(var(--dock-h, 150px) + 24px);
  pointer-events: none;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 0%, transparent) 0%,
    color-mix(in srgb, var(--bg) 82%, transparent) 42%, var(--bg) 72%);
  z-index: 2;
  transition: opacity 520ms var(--ease);
}
#view-chat > .jump {
  position: absolute;
  left: 50%;
  bottom: calc(var(--dock-h, 150px) + 6px);
  z-index: 7;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--text2);
  background: var(--raised);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease), color var(--dur-fast) var(--ease);
  box-shadow: 0 6px 18px -6px var(--shadow-cast);
}
#view-chat > .jump.visible { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
#view-chat > .jump:hover { color: var(--text); border-color: var(--accent); }
#view-chat > .jump .icon { width: 15px; height: 15px; }

#view-chat .msg { margin: 0 0 var(--message-gap); animation: rise-in var(--dur-slow) var(--ease-out) both; }
#view-chat .msg.still { animation: none; }
#view-chat .msg.user { display: flex; flex-direction: column; align-items: flex-end; }
#view-chat .msg.user .bubble {
  max-width: 78%;
  padding: calc(var(--density-pad) + 1px) 18px;
  border-radius: 18px;
  background: var(--user-bubble);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
#view-chat .msg.assistant { display: grid; grid-template-columns: 22px minmax(0, 1fr); column-gap: 12px; }
#view-chat .msg.assistant > * { grid-column: 2; }
#view-chat .msg.assistant > .avatar {
  grid-column: 1;
  grid-row: 1 / span 6;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border-radius: 6px;
  overflow: hidden;
}
#view-chat .msg.assistant > .avatar img { width: 100%; height: 100%; display: block; }
#view-chat .msg.assistant.working > .avatar img { animation: breathe 1.8s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { transform: scale(1); filter: saturate(1); }
  50% { transform: scale(0.86) rotate(-6deg); filter: saturate(1.25) brightness(1.1); }
}
#view-chat .msg.assistant .body { overflow-wrap: break-word; min-height: 1.2em; }
#view-chat .msg.assistant .body:empty { display: none; }

#view-chat .caret-block {
  display: inline-block;
  width: 0.5em;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.16em;
  border-radius: 2px;
  background: var(--accent);
  animation: caret 1.1s ease-in-out infinite;
}
@keyframes caret { 50% { opacity: 0.45; transform: scaleY(0.92); } }

#view-chat .actions {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 28px;
  margin-top: 4px;
  margin-left: -6px;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
#view-chat .msg:hover .actions,
#view-chat .actions:focus-within,
#view-chat .msg.assistant.latest .actions,
#view-chat .msg.failed .actions { opacity: 1; }
#view-chat .msg.user .actions { justify-content: flex-end; margin-left: 0; margin-right: -6px; }
#view-chat .msg.working .actions { visibility: hidden; }
#view-chat .act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text3);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
#view-chat .act:hover { background: var(--surface-hover); color: var(--text); }
#view-chat .act:active { transform: scale(0.92); }
#view-chat .act .icon { width: 14px; height: 14px; }
#view-chat .act.done { color: var(--added); }
#view-chat .actions .meta {
  margin-left: 8px;
  min-width: 0;
  font-size: var(--meta);
  color: var(--text3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#view-chat .msg.failed:not(.partial) .actions [data-action="copy"] { display: none; }
#view-chat .msg.assistant:not(.latest) .actions [data-action="regenerate"] { display: none; }

#view-chat .editor {
  width: 100%;
  max-width: 82%;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  animation: settle-in var(--dur) var(--ease-out);
}
#view-chat .editor textarea {
  width: 100%;
  min-height: 70px;
  resize: vertical;
  font: inherit;
  color: var(--text);
  background: var(--input-bg);
  border: 1px solid var(--accent);
  border-radius: 16px;
  padding: 12px 16px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
}
#view-chat .editor-row { display: flex; gap: 8px; }

#view-chat .error {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 11px;
  margin: 4px 0 0;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-md);
  background: var(--card);
  font-family: var(--ui);
  font-size: 14px;
  line-height: 1.5;
  animation: settle-in var(--dur) var(--ease-out);
}
#view-chat .error > .icon { color: var(--danger); flex: none; margin-top: 2px; }
#view-chat .error .error-main { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
#view-chat .error .text { color: var(--danger); overflow-wrap: anywhere; }
#view-chat .error .error-details { font-size: var(--ui-meta); color: var(--text3); }
#view-chat .error .error-details summary { cursor: pointer; width: max-content; user-select: none; }
#view-chat .error .error-details summary:hover { color: var(--text2); }
#view-chat .error .error-details .said {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: var(--ui-meta);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 180px;
  overflow: auto;
}
#view-chat .error .error-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-left: auto; }

#view-chat .cut-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 2px;
  padding: 6px 6px 6px 10px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  font-family: var(--ui);
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text2);
  animation: settle-in var(--dur) var(--ease-out);
}
#view-chat .cut-note > .icon { width: 14px; height: 14px; color: var(--text3); }
#view-chat .cut-note .cut-text { flex: 1; min-width: 0; }

/* The files sent with a question, above its bubble. */
#view-chat .msg.user .files {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 8px;
  max-width: 78%;
  margin-bottom: 8px;
}
#view-chat .file-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 260px;
  min-height: 48px;
  padding: 7px 14px 7px 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-family: var(--ui);
  text-align: left;
  line-height: 1.35;
}
#view-chat button.file-card { cursor: zoom-in; }
#view-chat .file-card .kind {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-wash);
  color: var(--accent-ink);
}
#view-chat .file-card .kind .icon { width: 16px; height: 16px; }
#view-chat .file-card .text { display: flex; flex-direction: column; min-width: 0; }
#view-chat .file-card .name { font-size: 13px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view-chat .file-card .sub { font-size: 11.5px; color: var(--text3); }
#view-chat .file-card.picture { padding: 0; overflow: hidden; min-height: 0; }
#view-chat .file-card.picture img { display: block; max-width: 240px; max-height: 180px; width: auto; height: auto; object-fit: cover; }

/* ---- the work line ------------------------------------------------------- */
#view-chat .work { margin: 0 0 calc(var(--block-gap) * 0.6); font-family: var(--ui); }
#view-chat .work summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  list-style: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  padding: 3px 0;
  user-select: none;
}
#view-chat .work summary::-webkit-details-marker { display: none; }
#view-chat .work .caret { width: 12px; height: 12px; flex: none; color: var(--text3); transition: transform var(--dur) var(--ease); order: 3; }
#view-chat .work[open] .caret { transform: rotate(90deg); }
#view-chat .work .glyph { display: inline-flex; width: 14px; height: 14px; flex: none; color: var(--text3); }
#view-chat .work .phase {
  display: inline-block;
  white-space: nowrap;
  background-image: linear-gradient(100deg, var(--text3) 0%, var(--text3) 40%, var(--shimmer) 50%, var(--text3) 60%, var(--text3) 100%);
  background-size: 300% 100%;
  background-position: 100% 0;
  background-repeat: no-repeat;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#view-chat .work.running .phase { animation: sweep 1.9s cubic-bezier(0.5, 0, 0.5, 1) infinite; }
#view-chat .work:not(.running) .phase { color: var(--text3); background-image: none; }
@keyframes sweep { from { background-position: 100% 0; } to { background-position: 0% 0; } }
.reduced-motion #view-chat .work.running .phase { animation: none; color: var(--text2); background-image: none; }
#view-chat .work .avatars { display: inline-flex; align-items: center; padding-left: 3px; order: 4; }
#view-chat .work .avatars .dot { margin-left: -3px; }
#view-chat .work .avatars .dot:first-child { margin-left: 0; }
#view-chat .work .detail { display: flex; flex-direction: column; gap: 8px; margin: 7px 0 4px; animation: rise-in var(--dur) var(--ease-out); }
#view-chat .dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--bg);
  font-size: 8.5px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  user-select: none;
  overflow: hidden;
}
#view-chat .dot.t0 { background: var(--tile-navy); }
#view-chat .dot.t1 { background: var(--tile-oxblood); }
#view-chat .dot.t2 { background: var(--tile-teal); }
#view-chat .dot.t3 { background: var(--tile-ochre); }

.reasoning-window {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--raised);
  box-shadow: 0 1px 2px var(--shadow-soft);
  overflow: hidden;
  font-size: 0.85em;
}
.reasoning-window .rw-head { display: flex; align-items: center; gap: 6px; padding: 5px 10px; color: var(--text3); border-bottom: 1px solid var(--border); }
.reasoning-window .rw-head > .icon { width: 13px; height: 13px; flex: none; }
.reasoning-window .rw-label { font-weight: 600; color: var(--text2); }
.reasoning-window .rw-count { flex: 1; min-width: 0; color: var(--text3); font-variant-numeric: tabular-nums; }
.reasoning-window .rw-label + .rw-count:not(:empty)::before { content: "· "; }
.reasoning-window .rw-body {
  max-height: min(16em, 38vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 12px 7px 10px;
  color: var(--text2);
  line-height: 1.45;
  overflow-wrap: break-word;
}
.reasoning-window .rw-body > :first-child { margin-top: 0; }
.reasoning-window .rw-body > :last-child { margin-bottom: 0; }
.reasoning-window .rw-body p { margin: 0 0 0.3em; }
.reasoning-window .rw-body :is(h1, h2, h3, h4, h5, h6) { margin: 0.55em 0 0.05em; font-size: 1em; font-weight: 620; line-height: 1.4; color: var(--text); border: 0; padding: 0; }
.reasoning-window .rw-body :is(ul, ol) { margin: 0 0 0.3em; padding-left: 1.2em; }
.reasoning-window .rw-body li { margin: 0; }
.reasoning-window .rw-body code { font-family: var(--font-mono); font-size: 0.95em; }
.reasoning-window .rw-body .code-block { margin: 0 0 0.45em; border-radius: 6px; background: var(--code-bg); color: var(--code-fg); }
.reasoning-window .rw-body .code-head { display: none; }
.reasoning-window .rw-body .code-body { margin: 0; padding: 5px 8px; white-space: pre-wrap; overflow-wrap: anywhere; }

#view-chat .work .sources { list-style: none; margin: 0; padding: 4px; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; background: var(--raised); }
#view-chat .work .sources li { border-radius: 8px; padding: 4px 6px; transition: background var(--dur-fast) var(--ease); }
#view-chat .work .sources li:hover { background: var(--surface-hover); }
#view-chat .work .sources .s-row { display: flex; align-items: center; gap: 7px; text-decoration: none; color: var(--text); font-size: 12.5px; }
#view-chat .work .sources .num { min-width: 14px; color: var(--text3); font-variant-numeric: tabular-nums; text-align: right; }
#view-chat .work .sources .s-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view-chat .work .sources .s-host { color: var(--text3); flex: none; margin-left: auto; padding-left: 8px; }

/* ---- answers (prose.css) ------------------------------------------------------ */
#view-chat .body > *:first-child { margin-top: 0; }
#view-chat .body > *:last-child { margin-bottom: 0; }
#view-chat .body p { margin: 0 0 var(--block-gap); }
#view-chat .body :is(h1, h2, h3, h4, h5, h6) {
  margin: calc(var(--block-gap) * 1.9) 0 calc(var(--block-gap) * 0.8);
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.01em;
}
#view-chat .body h1 { font-size: 1.5em; }
#view-chat .body h2 { font-size: 1.29em; padding-bottom: 0.34em; border-bottom: var(--hairline) solid var(--border); }
#view-chat .body h3 { font-size: 1.13em; }
#view-chat .body h4 { font-size: 1em; }
#view-chat .body :is(h5, h6) { font-size: 0.93em; color: var(--text2); }
#view-chat .body :is(ul, ol) { margin: 0 0 var(--block-gap); padding-left: 1.55em; }
#view-chat .body li { margin: 0 0 calc(var(--block-gap) * 0.34); }
#view-chat .body li:last-child { margin-bottom: 0; }
#view-chat .body li > :is(ul, ol) { margin: calc(var(--block-gap) * 0.34) 0 0; }
#view-chat .body li > p { margin: 0 0 calc(var(--block-gap) * 0.34); }
#view-chat .body li > p:last-child { margin-bottom: 0; }
#view-chat .body li::marker { color: var(--text3); }
#view-chat .body ol li::marker { font-variant-numeric: tabular-nums; }
#view-chat .body li.task-item { list-style: none; position: relative; }
#view-chat .body .task-box {
  position: absolute;
  left: -1.42em;
  top: calc((var(--line-height) - 0.98) * 0.5em);
  width: 0.98em;
  height: 0.98em;
  border: 1.5px solid var(--border-strong);
  border-radius: 0.28em;
  background: var(--bg);
}
#view-chat .body .task-box.done { background: var(--accent); border-color: var(--accent); }
#view-chat .body .task-box.done::after {
  content: "";
  position: absolute;
  left: 0.29em;
  top: 0.1em;
  width: 0.24em;
  height: 0.48em;
  border: solid var(--accent-text);
  border-width: 0 0.12em 0.12em 0;
  transform: rotate(45deg);
}
#view-chat .body li.task-item.done { color: var(--text2); }
#view-chat .body blockquote {
  margin: 0 0 var(--block-gap);
  padding: 0.15em 0 0.15em 1.1em;
  border-left: 3px solid var(--border-strong);
  color: var(--text2);
}
#view-chat .body hr { border: 0; border-top: var(--hairline) solid var(--border); margin: calc(var(--block-gap) * 1.8) 0; }
#view-chat .body a {
  color: var(--link);
  text-decoration: none;
  border-bottom: var(--hairline) solid color-mix(in srgb, var(--link) 35%, transparent);
  overflow-wrap: anywhere;
}
#view-chat .body a:hover { border-bottom-color: var(--link); }
#view-chat .body strong { font-weight: 650; color: var(--text); }
#view-chat .body del { color: var(--text3); }
#view-chat .body code {
  font-family: var(--font-mono);
  font-size: 0.895em;
  background: var(--inline-code-bg);
  padding: 0.12em 0.36em;
  border-radius: var(--radius-badge);
  overflow-wrap: anywhere;
}
#view-chat .table-wrap {
  margin: 0 0 var(--block-gap);
  overflow-x: auto;
  border: var(--hairline) solid var(--border);
  border-radius: var(--radius-card);
  background: var(--card);
}
#view-chat .body table { border-collapse: collapse; width: 100%; font-size: 0.945em; }
#view-chat .body thead th {
  background: var(--table-head);
  color: var(--text);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  padding: 10px 16px;
  border-bottom: var(--hairline) solid var(--border-strong);
}
#view-chat .body tbody td { padding: 10px 16px; border-bottom: var(--hairline) solid var(--border); vertical-align: top; }
#view-chat .body tbody tr:last-child td { border-bottom: 0; }
#view-chat .body tbody tr:nth-child(even) { background: var(--table-zebra); }
#view-chat .body :is(th, td).align-center { text-align: center; }
#view-chat .body :is(th, td).align-right { text-align: right; }
#view-chat .body :is(th, td).align-left { text-align: left; }
#view-chat .code-block {
  margin: 0 0 var(--block-gap);
  border: var(--hairline) solid var(--code-border);
  border-radius: var(--radius-card);
  background: var(--code-bg);
  overflow: hidden;
  box-shadow: 0 1px 2px var(--shadow-soft);
}
#view-chat .code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 14px;
  border-bottom: var(--hairline) solid var(--code-border);
  background: color-mix(in srgb, var(--code-bg) 92%, var(--code-fg) 4%);
}
#view-chat .code-lang {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--ui);
  font-size: var(--meta);
  font-weight: 500;
  color: color-mix(in srgb, var(--code-fg) 62%, transparent);
}
#view-chat .code-lang::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--tile-oxblood); }
#view-chat .code-copy {
  font: inherit;
  font-family: var(--ui);
  font-size: var(--meta);
  font-weight: 500;
  color: color-mix(in srgb, var(--code-fg) 55%, transparent);
  background: transparent;
  border: var(--hairline) solid transparent;
  border-radius: var(--radius-control);
  padding: 3px 9px;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
#view-chat .code-copy:hover { background: color-mix(in srgb, var(--code-fg) 9%, transparent); color: var(--code-fg); }
#view-chat .code-copy.copied { color: var(--accent); }
#view-chat .code-body {
  margin: 0;
  padding: 14px 18px;
  color: var(--code-fg);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.875em;
  line-height: 1.58;
}
#view-chat .code-body code { background: none; padding: 0; border-radius: 0; font-size: inherit; overflow-wrap: normal; }
.tok-k { color: var(--tok-k); }
.tok-s { color: var(--tok-s); }
.tok-c { color: var(--tok-c); font-style: italic; }
.tok-n { color: var(--tok-n); }
.tok-f { color: var(--tok-f); }
.tok-del { color: #e5776b; }
.tok-add { color: #5fc98a; }
/* Maths: TeX a model wrote, drawn as MathML (tex.js). A displayed formula is
   centred on a line of its own and scrolls sideways rather than pushing the
   column wider. TeX the converter can't read shows as written, in mono. */
#view-chat .body math { font-family: "Latin Modern Math", "Cambria Math", "STIX Two Math", math; font-size: 1.14em; }
#view-chat .body .math-block {
  margin: calc(var(--block-gap) * 0.9) 0;
  padding: 0.2em 0;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
}
#view-chat .body .math-block math { font-size: 1.22em; }
#view-chat .body mtd[columnalign="left"] { text-align: left; }
#view-chat .body mtd[columnalign="right"] { text-align: right; }
#view-chat .body mtable.align mtd { padding-inline: 0; }
#view-chat .body mtable.align mtd:nth-child(odd) { padding-inline-start: 1.2em; }
#view-chat .body mtable.align mtd:first-child { padding-inline-start: 0; }
#view-chat .body .boxed { padding: 0.15em 0.3em; border: var(--hairline) solid currentColor; }
#view-chat .body .math-inline { font-family: var(--font-mono); font-size: 0.9em; color: var(--text); }
#view-chat .body .math-raw {
  padding: 0.5em 0.8em;
  border-radius: var(--radius-card);
  background: var(--card);
  border: var(--hairline) solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.9em;
  white-space: pre-wrap;
}

/* ---- the New Chat page --------------------------------------------------- */
#view-chat .welcome { position: static; }
@property --copy-scrim { syntax: "<number>"; inherits: true; initial-value: 0.32; }
#view-chat .welcome .copy {
  position: absolute;
  left: 50%;
  bottom: calc(50% + (var(--dock-h, 150px) - 26px) / 2 + 22px);
  translate: -50% 0;
  width: min(var(--reading-width), calc(100% - 48px));
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  isolation: isolate;
  transition: --copy-scrim 700ms var(--ease);
  animation: rise-in 520ms var(--ease-out) 120ms both;
}
#view-chat .welcome .copy::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -56px -12% -40px;
  pointer-events: none;
  background: radial-gradient(closest-side,
    color-mix(in srgb, var(--on-picture-dark) calc(var(--copy-scrim) * 100%), transparent) 0%,
    color-mix(in srgb, var(--on-picture-dark) calc(var(--copy-scrim) * 72%), transparent) 45%,
    color-mix(in srgb, var(--on-picture-dark) calc(var(--copy-scrim) * 28%), transparent) 75%, transparent 100%);
}
#view-chat .welcome.leaving .copy { animation: copy-out 280ms var(--ease) both; }
@keyframes copy-out { to { opacity: 0; transform: translateY(-14px); } }
#view-chat .welcome h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(28px, 3.2vw, 40px);
  font-weight: 560;
  letter-spacing: -0.02em;
  line-height: 1.12;
  font-variation-settings: "SOFT" 50, "WONK" 0;
  text-wrap: balance;
  animation: rise-in 520ms var(--ease-out) 80ms both;
}
#view-chat .welcome p {
  margin: 8px 0 0;
  max-width: 62ch;
  text-wrap: balance;
  font-size: 15.5px;
  line-height: 1.55;
  animation: rise-in 520ms var(--ease-out) 140ms both;
}
#view-chat .welcome :is(h1, p) {
  color: var(--on-picture-light);
  text-shadow: 0 1px 1px color-mix(in srgb, var(--on-picture-dark) 60%, transparent),
    0 1px 3px color-mix(in srgb, var(--on-picture-dark) 50%, transparent),
    0 0 1px color-mix(in srgb, var(--on-picture-dark) 65%, transparent),
    0 0 12px color-mix(in srgb, var(--on-picture-dark) 45%, transparent);
}
#view-chat .welcome .kicker {
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tile-gold);
  text-shadow: 0 1px 2px color-mix(in srgb, var(--on-picture-dark) 70%, transparent);
}
#view-chat .welcome .chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 760px;
  margin-top: 20px;
}
#view-chat .welcome .chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: var(--ui-size);
  font-weight: 500;
  box-shadow: 0 1px 1px var(--shadow-soft);
  animation: rise-in 480ms var(--ease-out) both;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    transform var(--dur) var(--ease-spring), box-shadow var(--dur) var(--ease);
}
#view-chat .welcome .chip:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: 0 8px 18px -10px var(--shadow-cast); }
#view-chat .welcome .chip:active { transform: translateY(0) scale(0.98); }
#view-chat .welcome .chip.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
#view-chat .welcome .chip.primary:hover { background: var(--accent-hover); }
#view-chat .welcome .chip .icon { width: 15px; height: 15px; }
#view-chat .welcome .assistant-chip { padding: 0 12px 0 5px; background: color-mix(in srgb, var(--surface) 92%, transparent); }
#view-chat .welcome .assistant-chip .glyph { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; color: #fff; }
#view-chat .welcome .assistant-chip .glyph .icon { width: 14px; height: 14px; }
#view-chat .welcome .assistant-chip.on {
  border-color: var(--accent);
  background: var(--accent-wash);
  color: var(--accent-ink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.glyph.navy { background: var(--tile-navy); }
.glyph.amber { background: var(--tile-amber); }
.glyph.oxblood { background: var(--tile-oxblood); }
.glyph.teal { background: var(--tile-teal); }
#view-chat .welcome .fine {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--on-picture-light);
  opacity: 0.9;
  text-shadow: 0 1px 2px color-mix(in srgb, var(--on-picture-dark) 70%, transparent),
    0 0 10px color-mix(in srgb, var(--on-picture-dark) 55%, transparent);
}

/* ---- the composer (composer.css) ---------------------------------------------- */
.composer {
  position: relative;
  width: 100%;
  max-width: var(--reading-width);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 12px 9px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: 0 1px 2px var(--shadow-soft), 0 10px 32px -10px var(--shadow-cast);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
html.light .composer { border-color: var(--border); }
.composer:focus-within {
  border-color: color-mix(in srgb, var(--border-strong) 55%, var(--text3));
  box-shadow: 0 1px 2px var(--shadow-soft), 0 14px 40px -12px var(--shadow-cast);
}
.composer.dropping, html.light .composer.dropping {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent), 0 14px 40px -12px var(--shadow-cast);
}
.composer .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.composer .chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 3px 0 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  font-size: 12.5px;
  color: var(--text2);
  max-width: 260px;
  animation: settle-in var(--dur) var(--ease-out) both;
}
.composer .chip .icon { width: 14px; height: 14px; }
.composer .chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer .chip .ibtn { width: 20px; height: 20px; border-radius: 6px; }
.composer .chip .ibtn .icon { width: 12px; height: 12px; }
.composer .chip .thumb { width: 18px; height: 18px; margin-left: -3px; flex: none; border-radius: 5px; object-fit: cover; background: var(--surface); }
.composer .chip.danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); color: var(--danger); }
.composer .chip.assistant { color: var(--accent-ink); background: var(--accent-wash); border-color: transparent; }
.composer .line { display: flex; align-items: flex-end; gap: 10px; }
.composer .line > .ibtn { margin-bottom: 2px; }
.composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 26px;
  max-height: 260px;
  margin: 0;
  padding: 4px 0 5px;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15.5px;
  line-height: 1.5;
  overflow-y: auto;
}
.composer textarea::placeholder { color: var(--text3); }
.send {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border: 0;
  border-radius: 10px;
  background: var(--surface-pressed);
  color: var(--text3);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
    transform var(--dur) var(--ease-spring), box-shadow var(--dur) var(--ease);
}
.send .icon { width: 16px; height: 16px; }
.send.ready {
  background: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 1px 0 color-mix(in srgb, #fff 20%, transparent) inset, 0 2px 6px -2px color-mix(in srgb, var(--accent) 60%, transparent);
}
.send.ready:hover { background: var(--accent-hover); transform: translateY(-1px); }
.send.ready:active { transform: scale(0.94); }
.send.stop { background: var(--text); color: var(--bg); }
.send.stop:hover { transform: scale(1.04); }
.send.stop .icon { width: 14px; height: 14px; }
.send.stop .icon svg rect { fill: currentColor; }
.composer .tools { display: flex; align-items: center; gap: 2px; min-width: 0; margin-left: -6px; }
.composer .tools .grow { flex: 1; min-width: 8px; }
.composer .tools .model-pill { max-width: 260px; }
.composer .tools .model-pill .mark { width: 15px; height: 15px; color: var(--text2); display: inline-flex; flex: none; }
.composer .tools .model-pill .mark svg { width: 100%; height: 100%; }
.composer-note {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--text3);
}
.drop-outline {
  position: fixed;
  inset: 8px;
  z-index: 60;
  border: 2px solid var(--accent);
  border-radius: var(--radius-xl);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease-out), visibility var(--dur);
}
body.dragging-files .drop-outline { opacity: 1; visibility: visible; }

/* ---- dialogs (overlays.css) ------------------------------------------------- */
.dialog-layer,
.palette-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 32px;
}
.dialog-layer .scrim,
.palette-layer .scrim { position: absolute; inset: 0; background: var(--scrim); animation: fade-in 200ms var(--ease) both; }
.dialog-layer.leaving .scrim,
.palette-layer.leaving .scrim { animation: fade-out 160ms var(--ease) both; }
.dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(520px, 100%);
  max-height: min(86vh, 860px);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--raised);
  box-shadow: 0 1px 2px var(--shadow-soft), 0 24px 64px -16px var(--shadow-cast), 0 0 0 1px color-mix(in srgb, var(--text) 3%, transparent);
  animation: dialog-in 260ms var(--ease-out) both;
  outline: none;
  overflow: hidden;
}
.dialog-layer.leaving .dialog { animation: dialog-out 150ms var(--ease) both; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(0.975); } to { opacity: 1; transform: none; } }
@keyframes dialog-out { to { opacity: 0; transform: translateY(4px) scale(0.985); } }
.dialog.small { width: min(440px, 100%); }
.dialog.medium { width: min(640px, 100%); }
.dialog.settings { width: min(900px, 100%); height: min(680px, 90vh); }
.dialog.picture { width: auto; max-width: min(1100px, 100%); }
.dialog-head { display: flex; align-items: center; gap: 10px; padding: 18px 16px 6px 24px; flex: none; }
.dialog-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-family: var(--display);
  font-size: 21px;
  font-weight: 560;
  letter-spacing: -0.012em;
  color: var(--text);
  font-variation-settings: "SOFT" 40, "opsz" 36;
}
.dialog-head .close { color: var(--text3); }
.dialog-body { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 24px 20px; display: flex; flex-direction: column; gap: 16px; }
.dialog-text { margin: 0; color: var(--text2); font-size: 14px; line-height: 1.6; white-space: pre-line; }
.dialog.small .dialog-body { gap: 12px; padding-bottom: 22px; }
.dialog-foot { display: flex; align-items: center; gap: 8px; padding: 14px 20px 16px 24px; border-top: 1px solid var(--border); flex: none; }
.dialog.small .dialog-foot { border-top: 0; padding-top: 0; padding-bottom: 20px; }
.foot-spacer { flex: 1; }
.dialog .full-picture { display: block; max-width: 100%; max-height: 72vh; margin: 0 auto; border-radius: var(--radius-sm); }

.form-row { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text); }
.form-hint { font-size: 12px; color: var(--text3); line-height: 1.5; }
.form-hint a { color: var(--link); }
.form-error { color: var(--danger); font-size: 12.5px; }
.form-error:empty { display: none; }
.form-section-title { margin-top: 4px; font-size: 11px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text3); }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.field-with-button { display: flex; align-items: center; gap: 8px; }
.field-with-button > .field { flex: 1; min-width: 0; }

.dropdown {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text);
  text-align: left;
}
.dropdown:hover { border-color: color-mix(in srgb, var(--border-strong) 60%, var(--text3)); }
.dropdown .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown .chev { width: 14px; height: 14px; color: var(--text3); }
.dropdown .mark { width: 16px; height: 16px; display: inline-flex; color: var(--text2); }

.segmented {
  position: relative;
  display: inline-flex;
  align-self: flex-start;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border-radius: 11px;
  background: var(--surface-hover);
  max-width: 100%;
}
.segmented button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  font-weight: 550;
  white-space: nowrap;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.segmented button .icon { width: 14px; height: 14px; }
.segmented button:hover { color: var(--text); }
.segmented button.on { color: var(--text); background: var(--raised); box-shadow: 0 1px 2px var(--shadow-soft), 0 0 0 1px var(--border); }
html.dark .segmented button.on { background: var(--surface-pressed); box-shadow: 0 1px 2px var(--shadow-soft); }

.slider { display: flex; align-items: center; gap: 14px; }
.slider input[type="range"] { flex: 1; height: 20px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; accent-color: var(--accent); }
.slider input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--fill, 50%), var(--border-strong) var(--fill, 50%));
}
.slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border-radius: 50%;
  background: #fff;
  border: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.06);
}
.slider-value { min-width: 46px; text-align: right; color: var(--text2); font-size: 13px; font-variant-numeric: tabular-nums; }

/* Settings (js/chat/settings.js), as the desktop app draws it (mosaik-desktop css/settings.css). */
.dialog-body.settings-body {
  flex-direction: row;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* ---- the list of pages ----------------------------------------------------- */
.settings-nav {
  display: flex;
  flex-direction: column;
  width: 224px;
  flex: none;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--sidebar) 70%, var(--raised));
}
.settings-search {
  position: relative;
  display: flex;
  align-items: center;
  margin: 12px 10px 6px;
  flex: none;
}
.settings-search-glyph {
  position: absolute;
  left: 10px;
  width: 14px;
  height: 14px;
  color: var(--text3);
  pointer-events: none;
}
.settings-search-input {
  width: 100%;
  height: 32px;
  padding: 0 52px 0 31px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg, var(--surface));
  color: var(--text);
  font: inherit;
  font-size: var(--ui-size);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.settings-search-input::-webkit-search-cancel-button { display: none; }
.settings-search-input::placeholder { color: var(--text3); }
.settings-search-input:hover { border-color: var(--border-strong); }
.settings-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.settings-search-clear { position: absolute; right: 4px; }
.settings-search-kbd {
  position: absolute;
  right: 8px;
  height: 18px;
  padding: 0 5px;
  font-size: 10.5px;
  color: var(--text3);
  pointer-events: none;
}
.settings-search-input:focus ~ .settings-search-kbd,
.settings-search-clear:not([hidden]) ~ .settings-search-kbd { display: none; }

/* Scrolls on its own when the window is short; the search and the
   assistant stay where they are. */
.settings-nav-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px 10px 12px;
}
.settings-group {
  padding: 14px 10px 5px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
}
.settings-group:first-child { padding-top: 8px; }
.settings-tab {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  padding: 0 8px 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text2);
  font-size: var(--ui-size);
  text-align: left;
  flex: none;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
.settings-tab .icon { width: 15px; height: 15px; flex: none; }
.settings-tab-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-tab:hover { background: var(--surface-hover); color: var(--text); }
.settings-tab.on { background: var(--selection-strong); color: var(--text); font-weight: 600; }
.settings-tab.on .icon { color: var(--accent-ink); }
.settings-tab.dim { opacity: 0.42; }
.settings-tab.dim:hover { opacity: 0.8; }
.settings-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent-wash);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 650;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* The assistant that can set everything above, set apart at the foot. */
.settings-nav-foot { flex: none; padding: 8px 10px 10px; border-top: 1px solid var(--border); }
.settings-tab.settings-helper { width: 100%; color: var(--text2); }
.settings-tab.settings-helper .icon { color: var(--accent-ink); }

/* ---- the page ---------------------------------------------------------------- */
.settings-pane { flex: 1; min-width: 0; overflow-y: auto; padding: 24px 32px 32px; scroll-padding: 24px; }
.settings-page { display: flex; flex-direction: column; gap: 18px; max-width: 580px; }
.settings-page.entering { animation: rise-in var(--dur-slow) var(--ease-out) both; }
.page-intro { display: flex; flex-direction: column; gap: 6px; padding-bottom: 4px; }
.page-intro h3 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.page-intro .dialog-text { font-size: 13px; color: var(--text2); }

/* A ? beside a label: what a technical word means. */
.form-label { display: inline-flex; align-items: center; gap: 5px; }
.label-tip { display: inline-flex; color: var(--text3); cursor: help; }
.label-tip .icon { width: 13px; height: 13px; }
.label-tip:hover { color: var(--accent-ink); }

/* Pointed at from a search: a soft wash that fades. */
.settings-found { position: relative; isolation: isolate; }
.settings-found::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -6px -10px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
  pointer-events: none;
  animation: settings-found 3.2s var(--ease) both;
}
@keyframes settings-found { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* ---- Advanced ---------------------------------------------- */
/* One quiet line under a hairline, its count and a chevron; open, its
   settings sit on the page like the rest. */
.settings-advanced { border-top: 1px solid var(--border); margin-top: 4px; }
.settings-advanced > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 -8px;
  padding: 12px 8px 4px;
  list-style: none;
  cursor: pointer;
  color: var(--text2);
  font-size: var(--ui-size);
  border-radius: var(--radius-sm);
  user-select: none;
  transition: color var(--dur-fast) var(--ease);
}
.settings-advanced > summary::-webkit-details-marker { display: none; }
.settings-advanced > summary:hover { color: var(--text); }
.settings-advanced > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.settings-advanced .advanced-title { font-weight: 600; }
.advanced-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--surface-hover);
  color: var(--text3);
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.advanced-chev { width: 15px; height: 15px; margin-left: auto; color: var(--text3); transition: transform var(--dur) var(--ease); }
.settings-advanced[open] > summary .advanced-chev { transform: rotate(180deg); }
.settings-advanced .advanced-body { display: flex; flex-direction: column; gap: 18px; padding: 14px 0 2px; }
.settings-advanced[open] .advanced-body { animation: rise-in var(--dur) var(--ease-out) both; }
.settings-page .muted { opacity: 0.5; pointer-events: none; }

/* ---- search results ------------------------------------------------------- */
.settings-results { gap: 14px; }
.results-head { font-size: 12px; color: var(--text3); }
.result-group { display: flex; flex-direction: column; gap: 2px; }
.result-page {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px 4px;
  font-size: 12px;
  font-weight: 650;
  color: var(--text2);
}
.result-page .icon { width: 14px; height: 14px; color: var(--accent-ink); }
.result-area { color: var(--text3); font-weight: 500; }
.result-area::before { content: "·"; margin-right: 7px; }
.result-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 13.5px;
}
.result-row.active { background: var(--surface-hover); }
.result-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.result-title { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-weight: 550; }
.result-text {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.result-tag {
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--surface-hover);
  color: var(--text3);
  font-size: 10.5px;
  font-weight: 600;
}
.result-row mark { padding: 0 1px; border-radius: 3px; background: var(--accent-wash); color: var(--accent-ink); }
.results-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 56px 24px;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
}
.results-empty > .icon { width: 22px; height: 22px; margin-bottom: 4px; }
.results-empty b { color: var(--text); font-size: 14px; }
.results-empty .btn { margin-top: 8px; }


.status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
}
.status-card > .icon { width: 18px; height: 18px; color: var(--text3); }
.status-card.ok > .icon { color: var(--added); }
.status-card .text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.status-card .headline { font-weight: 600; font-size: 13.5px; }
.status-card .detail { color: var(--text3); font-size: 12.5px; }
.note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-wash);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}
.note > .icon { flex: none; width: 16px; height: 16px; margin-top: 2px; color: var(--accent-ink); }
.note p { margin: 0 0 6px; }
.note p:last-child { margin: 0; }
.plain-list { margin: 0; padding-left: 18px; color: var(--text2); font-size: 13px; line-height: 1.6; }

/* ---- the palette -------------------------------------------------------------- */
.palette-layer { place-items: start center; padding-top: 12vh; z-index: 80; }
.palette {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(640px, 100%);
  max-height: min(560px, 72vh);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--raised);
  box-shadow: 0 1px 2px var(--shadow-soft), 0 28px 70px -18px var(--shadow-cast);
  overflow: hidden;
  animation: dialog-in 220ms var(--ease-out) both;
}
.palette-layer.leaving .palette { animation: dialog-out 140ms var(--ease) both; }
.palette-head { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px 0 18px; border-bottom: 1px solid var(--border); flex: none; }
.palette-head > .icon { width: 18px; height: 18px; color: var(--text3); }
.palette-input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 16px; color: var(--text); }
.palette-input::placeholder { color: var(--text3); }
.palette-input::-webkit-search-cancel-button { display: none; }
.palette-list { flex: 1; min-height: 0; overflow-y: auto; padding: 6px; }
.palette-title { padding: 10px 12px 5px; font-size: 11px; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text3); }
.palette-row { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 7px 12px; border-radius: 10px; cursor: pointer; }
.palette-row.hot { background: var(--surface-hover); }
.palette-row .row-icon { display: grid; place-items: center; width: 26px; height: 26px; flex: none; border-radius: 8px; color: var(--text2); }
.palette-row .row-icon .icon { width: 15px; height: 15px; }
.palette-row .text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.palette-row .label { font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-row .detail { font-size: 12.5px; color: var(--text3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-row mark { background: var(--accent-wash); color: var(--text); border-radius: 4px; padding: 0 1px; margin: 0 -1px; }
.palette-row .side { color: var(--text3); font-size: 12px; white-space: nowrap; }
.palette-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 34px; color: var(--text3); }
.palette-empty .icon { width: 22px; height: 22px; }
.palette-foot { display: flex; gap: 18px; padding: 9px 18px; border-top: 1px solid var(--border); color: var(--text3); font-size: 12px; flex: none; }
.palette-foot kbd { height: 18px; padding: 0 5px; margin-right: 3px; font-size: 10.5px; }

/* ---- the model picker ---------------------------------------------------------- */
.popover.model-popover { padding: 0; max-width: min(380px, calc(100vw - 16px)); width: 380px; }
.popover.model-popover > .mosaic-strip { width: 100%; margin: 0; }
.model-picker { display: flex; flex-direction: column; min-height: 0; max-height: min(470px, 70vh); }
.picker-head { display: flex; align-items: center; gap: 9px; padding: 0 12px; height: 44px; border-bottom: 1px solid var(--border); color: var(--text3); flex: none; }
.picker-search { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: 14px; color: var(--text); }
.picker-search::placeholder { color: var(--text3); }
.picker-search::-webkit-search-cancel-button { display: none; }
.picker-list { flex: 1; min-height: 0; overflow-y: auto; padding: 5px; }
.picker-title { padding: 8px 10px 4px; font-size: 11px; font-weight: 650; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text3); }
.picker-row { display: flex; align-items: center; gap: 10px; padding: 7px 8px 7px 9px; border-radius: 9px; cursor: pointer; }
.picker-row.hot { background: var(--surface-hover); }
.picker-row .text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.picker-row .name { font-size: 13.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-row .meta { font-size: 11.5px; color: var(--text3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-row .badges { display: inline-flex; gap: 4px; color: var(--text3); }
.picker-row .badges .icon { width: 13px; height: 13px; }
.picker-row .tick { color: var(--accent-ink); }
.picker-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 22px; color: var(--text3); font-size: 13px; text-align: center; }
.picker-all {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  padding: 0 14px;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  flex: none;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.picker-all:hover { background: var(--surface-hover); color: var(--text); }
.picker-all .hint { margin-left: auto; color: var(--text3); font-size: 12px; }
.model-avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 8px;
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}
html.light .model-avatar { background: var(--raised); }
.model-avatar svg { width: 16px; height: 16px; }
.model-avatar .initials { font-size: 11px; font-weight: 700; color: var(--text2); }

/* ---- phones and narrow windows ----------------------------------------------------- */
.drawer-scrim { display: none; }
@media (max-width: 760px) {
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(300px, 86vw);
    z-index: 65;
    transform: translateX(-102%);
    transition: transform var(--dur-slow) var(--ease-out);
    box-shadow: 0 0 40px var(--shadow-cast);
  }
  #app.collapsed #sidebar { width: min(300px, 86vw); }
  #app.collapsed .expanded-only { display: flex !important; }
  #app.collapsed .rail { display: none; }
  #app.drawer #sidebar { transform: none; }
  .drawer-scrim {
    position: fixed;
    inset: 0;
    z-index: 64;
    display: block;
    background: var(--scrim);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-slow) var(--ease);
  }
  #app.drawer .drawer-scrim { opacity: 1; pointer-events: auto; }
  .brand .panel-toggle { display: none; }
  #header { padding: 0 8px 0 12px; }
  #header .menu-open { display: inline-flex; }
  #view-chat .conversation { padding: 0; }
  #view-chat .column { padding: 18px 16px calc(var(--dock-h, 150px) + 30px); }
  #view-chat > .veil { right: 0; }
  #view-chat .msg.user .bubble, #view-chat .msg.user .files { max-width: 88%; }
  #view-chat .msg.assistant { grid-template-columns: minmax(0, 1fr); }
  #view-chat .msg.assistant > .avatar { display: none; }
  #view-chat .msg.assistant > * { grid-column: 1; }
  #view-chat .editor { max-width: 100%; }
  #dock { padding: 0 10px 10px; }
  .composer { padding: 10px 10px 7px 12px; border-radius: 18px; }
  .composer textarea { font-size: 16px; }
  .composer .tools .model-pill { max-width: 46vw; }
  .composer .tools .pill.optional .label { display: none; }
  #app.fresh #dock { transform: none; }
  #view-chat .welcome .copy { bottom: calc(var(--dock-h, 150px) + 28px); width: calc(100% - 32px); }
  #view-chat .welcome h1 { font-size: 27px; }
  #view-chat .welcome .chips { gap: 6px; margin-top: 16px; }
  #view-chat .welcome .chip { height: 32px; padding: 0 11px; font-size: 13px; }
  #view-chat .welcome .assistant-chip { padding: 0 10px 0 4px; }
  #view-chat > .scene-pick { display: none; }
  .dialog-layer { padding: 12px; }
  .dialog.settings { height: min(720px, 92vh); }
  .dialog-body.settings-body { flex-direction: column; }
  .settings-nav { width: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .settings-search { margin: 10px 10px 4px; }
  .settings-search-input { font-size: 16px; }
  .settings-nav-list { flex-direction: row; overflow-x: auto; overflow-y: hidden; gap: 2px; padding: 4px 8px 8px; scrollbar-width: none; }
  .settings-nav-list::-webkit-scrollbar { display: none; }
  .settings-group { display: none; }
  .settings-tab { white-space: nowrap; }
  .settings-tab-label { overflow: visible; }
  .settings-pane { padding: 18px 16px 24px; }
  .palette-layer { padding: 12px; padding-top: 8vh; }
  #view-chat .error .error-actions { margin-left: 0; }
}
@media (max-width: 420px) {
  .composer .tools .search-pill .label, .composer .tools .reason-pill .label { display: none; }
}
@media (hover: none) {
  .settings-search-kbd { display: none; }
  #view-chat .actions { opacity: 1; }
  .row .more { opacity: 1; }
  .nav .hint { display: none; }
}

.noscript { max-width: 460px; margin: 20vh auto 0; padding: 0 16px; font-size: 15px; line-height: 1.6; color: var(--text2); text-align: center; }
