/* fw web UI. Material 3 Expressive on the Aphrody brand scheme (tonal-spot, seed #e2dbad);
   the color roles below are the generated values from aphrody-labs/ay brand/tokens/m3-tokens.json. */

:root {
  color-scheme: light;
  --md-sys-color-primary: #676013;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #efe58b;
  --md-sys-color-on-primary-container: #4e4800;
  --md-sys-color-secondary: #635f41;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #eae3bd;
  --md-sys-color-on-secondary-container: #4b472c;
  --md-sys-color-tertiary: #406653;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-tertiary-container: #c2ecd4;
  --md-sys-color-on-tertiary-container: #284e3c;
  --md-sys-color-error: #ba1a1a;
  --md-sys-color-on-error: #ffffff;
  --md-sys-color-error-container: #ffdad6;
  --md-sys-color-on-error-container: #93000a;
  --md-sys-color-surface: #fef9eb;
  --md-sys-color-on-surface: #1d1c14;
  --md-sys-color-on-surface-variant: #49473a;
  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: #f8f3e6;
  --md-sys-color-surface-container: #f3eee0;
  --md-sys-color-surface-container-high: #ede8da;
  --md-sys-color-surface-container-highest: #e7e2d5;
  --md-sys-color-outline: #7a7768;
  --md-sys-color-outline-variant: #cbc7b5;
  --md-sys-color-inverse-surface: #323127;
  --md-sys-color-inverse-on-surface: #f5f0e3;
  --md-sys-color-inverse-primary: #d3c972;
  --md-sys-color-scrim: #000000;

  /* Shape scale, including the expressive increased steps. */
  --shape-xs: 4px;
  --shape-s: 8px;
  --shape-m: 12px;
  --shape-l: 16px;
  --shape-l-inc: 20px;
  --shape-xl: 28px;
  --shape-xl-inc: 32px;
  --shape-xxl: 48px;
  --shape-full: 999px;

  /* Expressive motion: spatial springs overshoot, effects do not. */
  --motion-spatial-fast: 350ms cubic-bezier(0.42, 1.67, 0.21, 0.9);
  --motion-spatial: 500ms cubic-bezier(0.38, 1.21, 0.22, 1);
  --motion-effects-fast: 150ms cubic-bezier(0.31, 0.94, 0.34, 1);
  --motion-effects: 200ms cubic-bezier(0.34, 0.8, 0.34, 1);

  --font: "Google Sans Flex", "Google Sans", "Roboto Flex", system-ui, sans-serif;
  --font-code: "Google Sans Code", ui-monospace, "Cascadia Code", Consolas, monospace;
  --rail: 96px;
  --threads: 320px;
  --measure: 72ch;

  --state-hover: 8%;
  --state-press: 10%;
}

/* Dark roles: follow the system unless the person picked a theme (data-theme on <html>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --md-sys-color-primary: #d3c972;
    --md-sys-color-on-primary: #363100;
    --md-sys-color-primary-container: #4e4800;
    --md-sys-color-on-primary-container: #efe58b;
    --md-sys-color-secondary: #cdc7a3;
    --md-sys-color-on-secondary: #343117;
    --md-sys-color-secondary-container: #4b472c;
    --md-sys-color-on-secondary-container: #eae3bd;
    --md-sys-color-tertiary: #a6d0b8;
    --md-sys-color-on-tertiary: #0f3727;
    --md-sys-color-tertiary-container: #284e3c;
    --md-sys-color-on-tertiary-container: #c2ecd4;
    --md-sys-color-error: #ffb4ab;
    --md-sys-color-on-error: #690005;
    --md-sys-color-error-container: #93000a;
    --md-sys-color-on-error-container: #ffdad6;
    --md-sys-color-surface: #15140c;
    --md-sys-color-on-surface: #e7e2d5;
    --md-sys-color-on-surface-variant: #cbc7b5;
    --md-sys-color-surface-container-lowest: #0f0e07;
    --md-sys-color-surface-container-low: #1d1c14;
    --md-sys-color-surface-container: #212017;
    --md-sys-color-surface-container-high: #2c2a21;
    --md-sys-color-surface-container-highest: #37352c;
    --md-sys-color-outline: #949181;
    --md-sys-color-outline-variant: #49473a;
    --md-sys-color-inverse-surface: #e7e2d5;
    --md-sys-color-inverse-on-surface: #323127;
    --md-sys-color-inverse-primary: #676013;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --md-sys-color-primary: #d3c972;
  --md-sys-color-on-primary: #363100;
  --md-sys-color-primary-container: #4e4800;
  --md-sys-color-on-primary-container: #efe58b;
  --md-sys-color-secondary: #cdc7a3;
  --md-sys-color-on-secondary: #343117;
  --md-sys-color-secondary-container: #4b472c;
  --md-sys-color-on-secondary-container: #eae3bd;
  --md-sys-color-tertiary: #a6d0b8;
  --md-sys-color-on-tertiary: #0f3727;
  --md-sys-color-tertiary-container: #284e3c;
  --md-sys-color-on-tertiary-container: #c2ecd4;
  --md-sys-color-error: #ffb4ab;
  --md-sys-color-on-error: #690005;
  --md-sys-color-error-container: #93000a;
  --md-sys-color-on-error-container: #ffdad6;
  --md-sys-color-surface: #15140c;
  --md-sys-color-on-surface: #e7e2d5;
  --md-sys-color-on-surface-variant: #cbc7b5;
  --md-sys-color-surface-container-lowest: #0f0e07;
  --md-sys-color-surface-container-low: #1d1c14;
  --md-sys-color-surface-container: #212017;
  --md-sys-color-surface-container-high: #2c2a21;
  --md-sys-color-surface-container-highest: #37352c;
  --md-sys-color-outline: #949181;
  --md-sys-color-outline-variant: #49473a;
  --md-sys-color-inverse-surface: #e7e2d5;
  --md-sys-color-inverse-on-surface: #323127;
  --md-sys-color-inverse-primary: #676013;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 24px;
  font-variation-settings: "ROND" 100;
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; font-variation-settings: inherit; }
a { color: var(--md-sys-color-primary); }
[hidden] { display: none !important; }
.sprite { display: none; }
.icon { width: 24px; height: 24px; fill: currentColor; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -64px; z-index: 50; padding: 12px 20px; border-radius: var(--shape-full); background: var(--md-sys-color-inverse-surface); color: var(--md-sys-color-inverse-on-surface); }
.skip:focus { top: 8px; }
:focus-visible { outline: 3px solid var(--md-sys-color-secondary); outline-offset: 2px; }
.muted { color: var(--md-sys-color-on-surface-variant); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Type scale */
.headline-large { font-size: 32px; line-height: 40px; font-weight: 500; margin: 0; letter-spacing: 0; }
.headline-small { font-size: 24px; line-height: 32px; font-weight: 500; margin: 0; }
.title-large { font-size: 22px; line-height: 28px; font-weight: 500; margin: 0; }
.title-medium { font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: 0.15px; margin: 0; }
.body-large { font-size: 16px; line-height: 24px; margin: 0; }
.body-medium { font-size: 14px; line-height: 20px; margin: 0; }
.label-large { font-size: 14px; line-height: 20px; font-weight: 600; letter-spacing: 0.1px; }
.label-medium { font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.5px; }

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--rail) var(--threads) minmax(0, 1fr);
  height: 100dvh;
}
.rail {
  display: flex; flex-direction: column; align-items: center; gap: 40px;
  padding: 44px 0 24px;
  background: var(--md-sys-color-surface-container);
}
.rail-items { display: flex; flex-direction: column; gap: 12px; }
.rail-foot { margin-top: auto; }
.dest {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 80px; padding: 0 4px;
  color: var(--md-sys-color-on-surface-variant); text-decoration: none;
  font-size: 12px; line-height: 16px; font-weight: 600; letter-spacing: 0.5px;
}
.dest-pill {
  display: grid; place-items: center; width: 56px; height: 32px; border-radius: var(--shape-full);
  transition: background-color var(--motion-effects), width var(--motion-spatial-fast);
}
.dest:hover .dest-pill { background: color-mix(in srgb, var(--md-sys-color-on-surface) var(--state-hover), transparent); }
.dest[aria-current="page"] { color: var(--md-sys-color-on-surface); }
.dest[aria-current="page"] .dest-pill { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }

.threads {
  display: flex; flex-direction: column; min-height: 0;
  padding: 24px 12px 12px 0;
  background: var(--md-sys-color-surface-container);
}
.threads-head { display: grid; gap: 16px; padding: 12px 4px 16px 4px; }
.threads-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; }
#new-chat-drawer { display: none; }
.search {
  display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px;
  border-radius: var(--shape-full); background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface-variant);
}
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 16px; color: var(--md-sys-color-on-surface); }
.conv-list { flex: 1; overflow-y: auto; overflow-x: hidden; display: grid; align-content: start; gap: 2px; padding-right: 4px; }
.conv-item {
  display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 0 8px 0 16px;
  border-radius: var(--shape-full); color: var(--md-sys-color-on-surface-variant);
  text-decoration: none; cursor: pointer;
}
.conv-item:hover { background: color-mix(in srgb, var(--md-sys-color-on-surface) var(--state-hover), transparent); }
.conv-item[aria-current="true"] { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); font-weight: 600; }
.conv-item .ellipsis { flex: 1; min-width: 0; color: inherit; text-decoration: none; line-height: 56px; }
.conv-item .ellipsis:focus-visible { outline-offset: -3px; border-radius: var(--shape-full); }
.conv-item .icon-btn { visibility: hidden; }
.conv-item:hover .icon-btn, .conv-item:focus-within .icon-btn, .conv-item[aria-current="true"] .icon-btn { visibility: visible; }
.threads-empty { padding: 16px; color: var(--md-sys-color-on-surface-variant); }

.main {
  min-width: 0; min-height: 0; margin: 12px 12px 12px 0;
  border-radius: var(--shape-xl-inc);
  background: var(--md-sys-color-surface);
  overflow: hidden; outline: none;
}
.view { height: 100%; display: flex; flex-direction: column; min-height: 0; }
.page { overflow-y: auto; padding: 40px clamp(20px, 5vw, 64px) 64px; gap: 24px; }
.page-head { display: grid; gap: 8px; justify-items: start; max-width: var(--measure); }

/* ---------- Buttons ---------- */
.icon-btn {
  display: inline-grid; place-items: center; width: 48px; height: 48px; flex: none;
  border: 0; border-radius: var(--shape-full); background: transparent;
  color: var(--md-sys-color-on-surface-variant); cursor: pointer;
  transition: background-color var(--motion-effects-fast), border-radius var(--motion-spatial-fast);
}
.icon-btn:hover { background: color-mix(in srgb, var(--md-sys-color-on-surface) var(--state-hover), transparent); }
.icon-btn:active { border-radius: var(--shape-m); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 24px; border: 0; border-radius: var(--shape-full);
  font-size: 14px; font-weight: 600; letter-spacing: 0.1px; cursor: pointer;
  transition: border-radius var(--motion-spatial-fast), background-color var(--motion-effects-fast);
}
.btn .icon { width: 20px; height: 20px; }
.btn:active { border-radius: var(--shape-m); }
.btn.filled { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }
.btn.filled:hover { background: color-mix(in srgb, var(--md-sys-color-on-primary) var(--state-hover), var(--md-sys-color-primary)); }
.btn.tonal { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.btn.tonal:hover { background: color-mix(in srgb, var(--md-sys-color-on-secondary-container) var(--state-hover), var(--md-sys-color-secondary-container)); }
.btn.text { background: transparent; color: var(--md-sys-color-primary); padding: 0 16px; }
.btn.text:hover { background: color-mix(in srgb, var(--md-sys-color-primary) var(--state-hover), transparent); }
.btn.danger { color: var(--md-sys-color-error); }
.btn:disabled { opacity: 0.38; cursor: default; }

/* FAB: squarer at rest, rounder on hover, squeezes on press (expressive shape response). */
.fab {
  width: 56px; height: 56px; border: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container);
  border-radius: var(--shape-l);
  transition: border-radius var(--motion-spatial-fast), transform var(--motion-spatial-fast);
}
.fab:hover { border-radius: var(--shape-xl); }
.fab:active { transform: scale(0.92); }

/* ---------- Chat ---------- */
.top-bar {
  display: flex; align-items: center; gap: 8px; min-height: 72px; padding: 12px 16px 12px 24px;
}
.top-bar h1 { flex: 1; min-width: 0; }
#toggle-threads { display: none; }
.select {
  position: relative; display: inline-flex; align-items: center;
  height: 40px; border-radius: var(--shape-full);
  background: var(--md-sys-color-surface-container-high);
}
.select select {
  appearance: none; border: 0; background: transparent; height: 40px; max-width: min(38vw, 320px);
  padding: 0 40px 0 16px; border-radius: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  text-overflow: ellipsis;
}
.select::after {
  content: ""; position: absolute; right: 16px; width: 8px; height: 8px; pointer-events: none;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg);
}
.select select option { background: var(--md-sys-color-surface-container-high); }

.stream { flex: 1; min-height: 0; overflow-y: auto; padding: 8px clamp(16px, 4vw, 48px) 24px; scroll-behavior: smooth; }
.turn { max-width: var(--measure); margin: 0 auto 28px; display: grid; gap: 8px; }
.turn.user { justify-items: end; }
.turn.user .bubble {
  max-width: min(100%, 56ch); padding: 12px 20px;
  border-radius: var(--shape-xl) var(--shape-xl) var(--shape-s) var(--shape-xl);
  background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.turn.assistant .bubble { font-size: 17px; line-height: 28px; overflow-wrap: anywhere; }
.turn.error .bubble {
  padding: 16px 20px; border-radius: var(--shape-l-inc);
  background: var(--md-sys-color-error-container); color: var(--md-sys-color-on-error-container);
}
.turn.error .bubble strong { display: block; margin-bottom: 4px; }
.bubble p { margin: 0 0 12px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble h3, .bubble h4 { font-size: 20px; line-height: 28px; font-weight: 600; margin: 20px 0 8px; }
.bubble ul, .bubble ol { margin: 0 0 12px; padding-left: 24px; }
.bubble li { margin: 4px 0; }
.bubble code { font-family: var(--font-code); font-size: 0.9em; padding: 2px 6px; border-radius: var(--shape-xs); background: var(--md-sys-color-surface-container-high); }
.code-block { margin: 12px 0; border-radius: var(--shape-l); background: var(--md-sys-color-surface-container); overflow: hidden; }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 4px 16px; color: var(--md-sys-color-on-surface-variant); font-size: 12px; font-weight: 600; }
.code-head .icon-btn { width: 40px; height: 40px; }
.code-block pre { margin: 0; padding: 4px 16px 16px; overflow-x: auto; }
.code-block code { padding: 0; background: none; font-size: 14px; line-height: 22px; }
.meta { display: flex; align-items: center; gap: 4px; color: var(--md-sys-color-on-surface-variant); font-size: 12px; font-weight: 600; letter-spacing: 0.5px; }
.meta .icon-btn { width: 40px; height: 40px; }
.meta .icon { width: 20px; height: 20px; }
.reasoning { color: var(--md-sys-color-on-surface-variant); font-size: 14px; }
.reasoning summary { cursor: pointer; font-weight: 600; }
.reasoning div { white-space: pre-wrap; padding: 8px 0 0 16px; border-left: 2px solid var(--md-sys-color-outline-variant); }

/* Loading indicator: one shape morphing through the expressive set while fw answers. */
.thinking { display: flex; align-items: center; gap: 12px; color: var(--md-sys-color-on-surface-variant); }
.morph {
  width: 40px; height: 40px; background: var(--md-sys-color-primary);
  animation: morph 2.6s cubic-bezier(0.38, 1.21, 0.22, 1) infinite, spin 2.6s linear infinite;
}
@keyframes spin { to { rotate: 1turn; } }
@keyframes morph {
  0%, 100% { clip-path: polygon(100.0% 50.0%,94.6% 57.9%,89.7% 64.4%,91.6% 74.0%,87.6% 81.5%,77.6% 82.9%,72.0% 88.1%,67.0% 96.8%,58.1% 96.0%,50.0% 92.0%,41.9% 96.0%,33.0% 96.8%,28.0% 88.1%,22.4% 82.9%,12.4% 81.5%,8.4% 74.0%,10.3% 64.4%,5.4% 57.9%,0.0% 50.0%,5.4% 42.1%,10.3% 35.6%,8.4% 26.0%,12.4% 18.5%,22.4% 17.1%,28.0% 11.9%,33.0% 3.2%,41.9% 4.0%,50.0% 8.0%,58.1% 4.0%,67.0% 3.2%,72.0% 11.9%,77.6% 17.1%,87.6% 18.5%,91.6% 26.0%,89.7% 35.6%,94.6% 42.1%); }
  20% { clip-path: polygon(100.0% 50.0%,94.3% 57.8%,87.6% 63.7%,89.0% 72.5%,88.3% 82.1%,78.9% 84.5%,70.0% 84.6%,65.4% 92.3%,58.7% 99.2%,50.0% 95.0%,43.1% 89.4%,34.6% 92.3%,25.0% 93.3%,21.1% 84.5%,19.4% 75.7%,11.0% 72.5%,3.0% 67.1%,5.7% 57.8%,10.0% 50.0%,5.7% 42.2%,3.0% 32.9%,11.0% 27.5%,19.4% 24.3%,21.1% 15.5%,25.0% 6.7%,34.6% 7.7%,43.1% 10.6%,50.0% 5.0%,58.7% 0.8%,65.4% 7.7%,70.0% 15.4%,78.9% 15.5%,88.3% 17.9%,89.0% 27.5%,87.6% 36.3%,94.3% 42.2%); }
  40% { clip-path: polygon(100.0% 50.0%,96.8% 58.2%,89.3% 64.3%,82.0% 68.5%,77.9% 73.4%,76.1% 81.1%,73.2% 90.3%,67.1% 96.9%,58.4% 97.6%,50.0% 93.0%,43.5% 87.1%,37.7% 83.9%,30.3% 84.2%,20.8% 84.8%,12.0% 81.9%,7.5% 74.5%,8.5% 65.1%,12.1% 56.7%,14.0% 50.0%,12.1% 43.3%,8.5% 34.9%,7.5% 25.5%,12.0% 18.1%,20.8% 15.2%,30.2% 15.8%,37.7% 16.1%,43.5% 12.9%,50.0% 7.0%,58.4% 2.4%,67.1% 3.1%,73.2% 9.7%,76.1% 18.9%,77.9% 26.6%,82.0% 31.5%,89.3% 35.7%,96.8% 41.8%); }
  60% { clip-path: polygon(100.0% 50.0%,98.8% 58.6%,95.2% 66.5%,89.8% 73.0%,83.2% 77.9%,76.1% 81.1%,69.0% 82.9%,62.3% 83.7%,56.0% 84.0%,50.0% 84.0%,44.0% 84.0%,37.7% 83.7%,31.0% 82.9%,23.9% 81.1%,16.8% 77.9%,10.2% 73.0%,4.8% 66.5%,1.2% 58.6%,0.0% 50.0%,1.2% 41.4%,4.8% 33.5%,10.2% 27.0%,16.8% 22.1%,23.9% 18.9%,31.0% 17.1%,37.7% 16.3%,44.0% 16.0%,50.0% 16.0%,56.0% 16.0%,62.3% 16.3%,69.0% 17.1%,76.1% 18.9%,83.2% 22.1%,89.8% 27.0%,95.2% 33.5%,98.8% 41.4%); }
  80% { clip-path: polygon(100.0% 50.0%,96.8% 58.3%,91.5% 65.1%,89.4% 72.8%,87.8% 81.7%,81.7% 87.8%,72.8% 89.4%,65.1% 91.5%,58.3% 96.8%,50.0% 100.0%,41.7% 96.8%,34.9% 91.5%,27.3% 89.4%,18.3% 87.8%,12.2% 81.7%,10.6% 72.8%,8.5% 65.1%,3.2% 58.3%,0.0% 50.0%,3.2% 41.7%,8.5% 34.9%,10.6% 27.2%,12.2% 18.3%,18.3% 12.2%,27.2% 10.6%,34.9% 8.5%,41.7% 3.2%,50.0% 0.0%,58.3% 3.2%,65.1% 8.5%,72.7% 10.6%,81.7% 12.2%,87.8% 18.3%,89.4% 27.3%,91.5% 34.9%,96.8% 41.7%); }
}

/* Empty chat: the brand cookie holds the wordmark. */
.empty { max-width: var(--measure); margin: 0 auto; min-height: 100%; display: grid; align-content: center; justify-items: start; gap: 24px; padding: 32px 0; }
.mark {
  width: 132px; height: 132px; display: grid; place-items: center;
  background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container);
  clip-path: polygon(100.0% 50.0%,94.3% 57.8%,87.6% 63.7%,89.0% 72.5%,88.3% 82.1%,78.9% 84.5%,70.0% 84.6%,65.4% 92.3%,58.7% 99.2%,50.0% 95.0%,43.1% 89.4%,34.6% 92.3%,25.0% 93.3%,21.1% 84.5%,19.4% 75.7%,11.0% 72.5%,3.0% 67.1%,5.7% 57.8%,10.0% 50.0%,5.7% 42.2%,3.0% 32.9%,11.0% 27.5%,19.4% 24.3%,21.1% 15.5%,25.0% 6.7%,34.6% 7.7%,43.1% 10.6%,50.0% 5.0%,58.7% 0.8%,65.4% 7.7%,70.0% 15.4%,78.9% 15.5%,88.3% 17.9%,89.0% 27.5%,87.6% 36.3%,94.3% 42.2%);
  font-size: 52px; line-height: 1; font-weight: 800; font-variation-settings: "ROND" 100, "wdth" 125, "opsz" 144;
}
.empty h2 { font-size: 45px; line-height: 52px; font-weight: 500; margin: 0; letter-spacing: -0.5px; font-variation-settings: "ROND" 100, "opsz" 144; }
.empty p { margin: 0; max-width: 56ch; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px 0 12px;
  border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--shape-s);
  background: transparent; color: var(--md-sys-color-on-surface-variant); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: border-radius var(--motion-spatial-fast), background-color var(--motion-effects-fast);
}
.chip .icon { width: 18px; height: 18px; color: var(--md-sys-color-primary); }
.chip:hover { background: color-mix(in srgb, var(--md-sys-color-on-surface) var(--state-hover), transparent); border-radius: var(--shape-m); }

.composer {
  position: relative; display: flex; align-items: flex-end; gap: 8px;
  width: min(calc(100% - 32px), calc(var(--measure) + 32px)); margin: 0 auto;
  padding: 8px 8px 8px 24px; border-radius: var(--shape-xl);
  background: var(--md-sys-color-surface-container-high);
  transition: border-radius var(--motion-spatial);
}
.composer:focus-within { box-shadow: 0 0 0 2px var(--md-sys-color-primary); }
.composer textarea {
  flex: 1; min-height: 40px; max-height: 40vh; padding: 8px 0; border: 0; resize: none; outline: none;
  background: transparent; font-size: 17px; line-height: 24px;
}
.send {
  width: 48px; height: 48px; display: grid; place-items: center; flex: none; border: 0; cursor: pointer;
  border-radius: var(--shape-l); background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary);
  transition: border-radius var(--motion-spatial-fast), background-color var(--motion-effects);
}
.send:hover { border-radius: var(--shape-full); }
.send.stop { background: var(--md-sys-color-tertiary); color: var(--md-sys-color-on-tertiary); border-radius: var(--shape-m); }
.send:disabled { background: var(--md-sys-color-surface-container-highest); color: var(--md-sys-color-on-surface-variant); cursor: default; }
.composer-hint { text-align: center; margin: 8px 16px 16px; color: var(--md-sys-color-on-surface-variant); }

/* ---------- Lists (tools, models) ---------- */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-width: 960px; }
.list > li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px;
  padding: 16px 16px 16px 24px; background: var(--md-sys-color-surface-container-low);
}
.list > li:first-child { border-radius: var(--shape-l-inc) var(--shape-l-inc) var(--shape-xs) var(--shape-xs); }
.list > li:last-child { border-radius: var(--shape-xs) var(--shape-xs) var(--shape-l-inc) var(--shape-l-inc); }
.list > li:only-child { border-radius: var(--shape-l-inc); }
.list .item-text { display: grid; gap: 4px; min-width: 0; }
.list .item-name { font-family: var(--font-code); font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.list .item-desc { color: var(--md-sys-color-on-surface-variant); font-size: 14px; line-height: 20px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag { padding: 2px 10px; border-radius: var(--shape-s); background: var(--md-sys-color-tertiary-container); color: var(--md-sys-color-on-tertiary-container); font-size: 12px; font-weight: 600; letter-spacing: 0.3px; }
.tag.on { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }
.tag.off { background: var(--md-sys-color-surface-container-highest); color: var(--md-sys-color-on-surface-variant); }

/* ---------- System ---------- */
.system { display: grid; gap: 24px; max-width: 960px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 4px; }
.fact { padding: 16px 20px; background: var(--md-sys-color-surface-container-low); border-radius: var(--shape-xs); }
.fact:first-child { border-top-left-radius: var(--shape-l-inc); border-bottom-left-radius: var(--shape-l-inc); }
.fact:last-child { border-top-right-radius: var(--shape-l-inc); border-bottom-right-radius: var(--shape-l-inc); }
.fact dt { color: var(--md-sys-color-on-surface-variant); font-size: 12px; font-weight: 600; letter-spacing: 0.5px; }
.fact dd { margin: 4px 0 0; font-size: 22px; line-height: 28px; font-weight: 500; overflow-wrap: anywhere; }
.system h2 { margin: 8px 0 0; }
.endpoints { columns: 2 260px; margin: 0; padding: 0; list-style: none; font-family: var(--font-code); font-size: 14px; line-height: 28px; }
.result, .code {
  font-family: var(--font-code); font-size: 13px; line-height: 20px;
}
.result {
  margin: 0; max-height: 40vh; overflow: auto; padding: 16px; border-radius: var(--shape-l);
  background: var(--md-sys-color-surface-container); white-space: pre-wrap; overflow-wrap: anywhere;
}

/* ---------- Dialogs, fields, snackbar ---------- */
.dialog {
  width: min(560px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: var(--shape-xl);
  background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface);
}
.dialog.wide { width: min(720px, calc(100vw - 32px)); }
.dialog::backdrop { background: color-mix(in srgb, var(--md-sys-color-scrim) 40%, transparent); }
.dialog[open] { animation: dialog-in var(--motion-spatial); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } }
.dialog-body { display: grid; gap: 20px; padding: 24px; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.dialog-actions .danger { margin-right: auto; }
.field { display: grid; gap: 8px; }
.field textarea, .field input[type="text"] {
  width: 100%; padding: 12px 16px; border: 1px solid var(--md-sys-color-outline); border-radius: var(--shape-s);
  background: transparent; font-size: 16px; line-height: 24px; resize: vertical;
}
.field textarea:focus, .field input[type="text"]:focus { outline: none; border-color: var(--md-sys-color-primary); box-shadow: inset 0 0 0 1px var(--md-sys-color-primary); }
.field input[type="range"] { accent-color: var(--md-sys-color-primary); height: 32px; }
.field output { font-weight: 500; color: var(--md-sys-color-primary); margin-left: 8px; }

.snackbar {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40;
  max-width: min(560px, calc(100vw - 32px)); padding: 14px 20px; border-radius: var(--shape-xs);
  background: var(--md-sys-color-inverse-surface); color: var(--md-sys-color-inverse-on-surface);
  font-size: 14px; line-height: 20px;
}
.scrim { position: fixed; inset: 0; z-index: 20; background: color-mix(in srgb, var(--md-sys-color-scrim) 32%, transparent); }

/* ---------- Window size classes ---------- */
/* Medium (600-839) and expanded below 1200: the chat list becomes a modal drawer. */
@media (max-width: 1199px) {
  .app { grid-template-columns: var(--rail) minmax(0, 1fr); }
  .threads {
    position: fixed; z-index: 30; top: 0; bottom: 0; left: 0; width: min(360px, 88vw);
    padding: 24px 12px; border-radius: 0 var(--shape-l) var(--shape-l) 0;
    background: var(--md-sys-color-surface-container-low);
    transform: translateX(-104%); transition: transform var(--motion-spatial);
  }
  .threads.open { transform: none; }
  #toggle-threads { display: inline-grid; }
  #new-chat-drawer { display: inline-flex; }
  .top-bar { padding-left: 12px; }
}
/* Compact (< 600): the rail becomes a bottom navigation bar. */
@media (max-width: 599px) {
  :root { --rail: 0px; }
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .main { grid-row: 1; margin: 0; border-radius: 0; }
  .rail {
    grid-row: 2; flex-direction: row; justify-content: space-around; gap: 0;
    padding: 12px 8px calc(16px + env(safe-area-inset-bottom));
  }
  .rail .fab { position: fixed; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 10; display: none; }
  .rail-items { flex-direction: row; flex: 1; justify-content: space-around; gap: 0; }
  .dest { min-width: 64px; }
  .rail-foot { margin: 0; }
  .empty h2 { font-size: 36px; line-height: 44px; }
  .mark { width: 104px; height: 104px; font-size: 40px; }
  .composer { width: calc(100% - 16px); }
  .composer-hint { display: none; }
  .page { padding: 24px 16px 32px; }
  .list > li { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .morph { animation: none; clip-path: circle(50%); }
}
@media (forced-colors: active) {
  .send, .fab, .dest[aria-current="page"] .dest-pill { forced-color-adjust: none; border: 2px solid CanvasText; }
}
