/* ============================== */
/* FONTS */
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src:
    url("/assets/fonts/AtkinsonHyperlegibleNext.woff2") format("woff2")
      tech(variations),
    url("/assets/fonts/AtkinsonHyperlegibleNext.woff2") format("woff2");
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  font-style: italic;
  font-weight: 200 800;
  font-display: swap;
  src:
    url("/assets/fonts/AtkinsonHyperlegibleNext-Italic.woff2") format("woff2")
      tech(variations),
    url("/assets/fonts/AtkinsonHyperlegibleNext-Italic.woff2") format("woff2");
}

/* ============================== */
/* DESIGN TOKENS */
:root {
  --bg: #0a0a0a;
  --bg-elev: #0d0d0d;
  --bg-elev-2: #161616;
  --surface: #161616;
  --surface-hover: #1f1f1f;
  --text: #ffffff;
  --text-dim: #b3b3b3;
  --text-faint: #707070;
  --border: #2a2a2a;
  --border-strong: #3a3a3a;
  --accent: #00e385;
  --accent-fg: #000;
  --accent-soft: rgba(0, 227, 133, 0.14);
  --accent-soft-strong: rgba(0, 227, 133, 0.24);
  --user-bubble: #1a1a1a;
  --code-bg: #0a0a0a;
  --code-border: #1f1f1f;
  --reasoning-text: #909090;
  --reasoning-bg: #0a0a0a;
  --danger: #ff5b5b;
  --warning: #f59e0b;
  --bg-raw: #0a0a0a;
  --bg-elev-raw: #0d0d0d;
  --bg-elev-2-raw: #161616;
  --surface-raw: #161616;
  --surface-hover-raw: #1f1f1f;
  --text-raw: #ffffff;
  --text-dim-raw: #b3b3b3;
  --text-faint-raw: #707070;
  --border-raw: #2a2a2a;
  --border-strong-raw: #3a3a3a;
  --user-bubble-raw: #1a1a1a;
  --code-bg-raw: #0a0a0a;
  --code-border-raw: #1f1f1f;
  --reasoning-text-raw: #909090;
  --reasoning-bg-raw: #0a0a0a;
  --danger-raw: #ff5b5b;
  --tint-strength: 8%;
  --font:
    "Atkinson Hyperlegible Next", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, "Helvetica Neue", Arial, "Noto Sans", system-ui, sans-serif;
  --mono:
    ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Monaco, Consolas,
    monospace;
  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --space-0: 2px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --radius-2xs: 2px;
  --radius-xs: 5px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-full: 999px;
  --duration-fast: 180ms;
  --duration: 300ms;
  --duration-slow: 500ms;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --sidebar-w: 272px;
  --sidebar-item-h: 36px;
  --composer-max: 800px;
  --z-composer: 3;
  --z-header: 5;
  --z-drawer-back: 49;
  --z-drawer: 50;
  --z-picker: 60;
  --z-modal: 100;
  --z-overlay: 1000;
  color-scheme: dark;
}

/* ============================== */
/* COLORS - LIGHT */
:root[data-theme="light"] {
  --bg: #f9fafb;
  --bg-elev: #f7f7f7;
  --bg-elev-2: #ebebeb;
  --surface: #f0f0f0;
  --surface-hover: #e5e5e5;
  --text: #0a0a0a;
  --text-dim: #4a4a4a;
  --text-faint: #767676;
  --border: #d0d0d0;
  --border-strong: #b8b8b8;
  --accent-soft: rgba(0, 180, 100, 0.12);
  --accent-soft-strong: rgba(0, 180, 100, 0.22);
  --user-bubble: #ececec;
  --code-bg: #f2f2f2;
  --code-border: #d8d8d8;
  --reasoning-text: #666666;
  --reasoning-bg: #f2f2f2;
  --danger: #d12c2c;
  color-scheme: light;
  --bg-raw: #f9fafb;
  --bg-elev-raw: #f7f7f7;
  --bg-elev-2-raw: #ebebeb;
  --surface-raw: #f0f0f0;
  --surface-hover-raw: #e5e5e5;
  --text-raw: #0a0a0a;
  --text-dim-raw: #4a4a4a;
  --text-faint-raw: #767676;
  --border-raw: #d0d0d0;
  --border-strong-raw: #b8b8b8;
  --user-bubble-raw: #ececec;
  --code-bg-raw: #f2f2f2;
  --code-border-raw: #d8d8d8;
  --reasoning-text-raw: #666666;
  --reasoning-bg-raw: #f2f2f2;
  --danger-raw: #d12c2c;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
  }
}

/* ============================== */
/* ACCENT TINT */
:root[data-tint="true"] {
  --bg: color-mix(
    in oklab,
    var(--bg-raw),
    var(--accent) calc(var(--tint-strength) * 0.5)
  );
  --bg-elev: color-mix(
    in oklab,
    var(--bg-elev-raw),
    var(--accent) calc(var(--tint-strength) * 0.7)
  );
  --bg-elev-2: color-mix(
    in oklab,
    var(--bg-elev-2-raw),
    var(--accent) calc(var(--tint-strength) * 0.9)
  );
  --surface: color-mix(
    in oklab,
    var(--surface-raw),
    var(--accent) calc(var(--tint-strength) * 1)
  );
  --surface-hover: color-mix(
    in oklab,
    var(--surface-hover-raw),
    var(--accent) calc(var(--tint-strength) * 1.3)
  );
  --user-bubble: color-mix(
    in oklab,
    var(--user-bubble-raw),
    var(--accent) calc(var(--tint-strength) * 1)
  );
  --code-bg: color-mix(
    in oklab,
    var(--code-bg-raw),
    var(--accent) calc(var(--tint-strength) * 0.6)
  );
  --code-border: color-mix(
    in oklab,
    var(--code-border-raw),
    var(--accent) calc(var(--tint-strength) * 1.2)
  );
  --reasoning-bg: color-mix(
    in oklab,
    var(--reasoning-bg-raw),
    var(--accent) calc(var(--tint-strength) * 0.6)
  );
  --reasoning-text: color-mix(
    in oklab,
    var(--reasoning-text-raw),
    var(--accent) calc(var(--tint-strength) * 0.8)
  );
  --border: color-mix(
    in oklab,
    var(--border-raw),
    var(--accent) calc(var(--tint-strength) * 1.5)
  );
  --border-strong: color-mix(
    in oklab,
    var(--border-strong-raw),
    var(--accent) calc(var(--tint-strength) * 1.8)
  );
  --text: color-mix(
    in oklab,
    var(--text-raw),
    var(--accent) calc(var(--tint-strength) * 0.35)
  );
  --text-dim: color-mix(
    in oklab,
    var(--text-dim-raw),
    var(--accent) calc(var(--tint-strength) * 0.7)
  );
  --text-faint: color-mix(
    in oklab,
    var(--text-faint-raw),
    var(--accent) calc(var(--tint-strength) * 0.9)
  );
  --danger: color-mix(
    in oklab,
    var(--danger-raw),
    var(--accent) calc(var(--tint-strength) * 0.5)
  );
}

/* ============================== */
/* TINT SLIDER */
.range:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ============================== */
/* BASE RESET & GLOBAL STYLES */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-lg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* ============================== */
/* FORM ELEMENT RESET */
button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
button {
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}
input,
textarea {
  background: none;
  border: 0;
  outline: 0;
}

/* ============================== */
/* SELECTION */
::selection {
  background: var(--accent-soft-strong);
  color: var(--text);
}

/* ============================== */
/* FOCUS RING */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-radius: inherit;
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
}

/* ============================== */
/* SCROLLBAR */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius);
  border: 2px solid var(--bg);
}
*::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}
*::-webkit-scrollbar-track {
  background: transparent;
}

/* ============================== */
/* LUCIDE ICONS */
.lucide {
  display: block;
  flex: none;
}

/* ============================== */
/* APP LAYOUT */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  overflow: hidden;
}
.app[data-sidebar-open="false"] .sidebar {
  margin-left: calc(-1 * var(--sidebar-w));
  border-right: 0;
  visibility: hidden;
  transition:
    margin-left var(--duration) var(--ease-out),
    visibility 0s linear var(--duration);
}

/* ============================== */
/* SIDEBAR TOGGLE */
.sidebar-toggle .icon-expand {
  display: none;
}
.app[data-sidebar-open="false"] .sidebar-toggle .icon-collapse {
  display: none;
}
.app[data-sidebar-open="false"] .sidebar-toggle .icon-expand {
  display: block;
}
.chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
  position: relative;
}

/* ============================== */
/* SIDEBAR */
.sidebar {
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  margin-left: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  min-width: 0;
  overflow: hidden;
  contain: layout style paint;
  transform: translateZ(0);
  transition:
    margin-left var(--duration) var(--ease-out),
    visibility 0s;
}

/* ============================== */
/* BRAND */
.sidebar-top {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
}
.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-fg);
  display: grid;
  place-items: center;
  font-weight: bold;
  font-size: var(--text-base);
  flex: none;
}
.brand-name {
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================== */
/* ICON BUTTON */
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  color: var(--text);
  transition: transform var(--duration-fast) var(--ease);
}
.icon-btn:hover {
  background: var(--surface-hover);
}

/* ============================== */
/* SIDEBAR SEARCH */
.sidebar-search {
  position: relative;
  margin: var(--space-2) var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  height: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
}
.sidebar-search:focus-within {
  border-color: var(--accent);
  background: var(--bg-elev-2);
}
.sidebar-search input {
  flex: 1;
  min-width: 0;
  font-size: var(--text-base);
}

/* ============================== */
/* CONVERSATION LIST */
.conversation-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  position: relative;
}
.conversation-list > * {
  flex-shrink: 0;
}

/* ============================== */
/* CONVERSATION ITEM */
.conversation-item {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2);
  min-height: var(--sidebar-item-h);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  font-size: var(--text-base);
  user-select: none;
  transition: transform var(--duration-fast) var(--ease);
}
.conversation-item:hover {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
  z-index: 5;
}
.conversation-item[data-active="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}
.conversation-item .ci-title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ci-status {
  flex: none;
  width: 14px;
  height: 14px;
  display: none;
  align-items: center;
  justify-content: center;
}
.ci-status[data-state="streaming"] {
  display: inline-flex;
  cursor: pointer;
}
.ci-status[data-state="streaming"]::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: ci-spin var(--duration) linear infinite;
}
.ci-status[data-state="unseen"] {
  display: inline-flex;
}
.ci-status[data-state="unseen"]::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--accent);
}
@keyframes ci-spin {
  to {
    transform: rotate(360deg);
  }
}
.ci-snippet {
  flex-basis: 100%;
  min-width: 0;
  font-size: var(--text-base);
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: var(--space-1);
  padding-left: var(--space-2);
  border-left: 2px solid var(--border-strong);
}
.ci-snippet-mark {
  background: transparent;
  color: var(--accent);
  font-weight: bold;
}

/* ============================== */
/* HOVER-REVEAL ACTION PANELS */
.ci-actions,
.folder-actions {
  position: absolute;
  top: 50%;
  right: var(--space-0);
  display: flex;
  padding: var(--space-0);
  gap: var(--space-0);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  opacity: 0;
  transform: translateY(-50%) translateX(var(--space-1));
  transition:
    opacity var(--duration-fast) var(--ease),
    transform var(--duration-fast) var(--ease);
  z-index: 10;
  pointer-events: none;
}
.conversation-item:hover .ci-actions,
.folder-header:hover .folder-actions,
.conversation-item:focus-within .ci-actions,
.folder-header:focus-within .folder-actions {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
  pointer-events: auto;
}
@media (pointer: coarse) {
  .ci-actions,
  .folder-actions {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
    pointer-events: auto;
  }
  .reorder-btn,
  .star-btn {
    opacity: 1;
  }
  .bubble .content .code-block-wrap .code-copy,
  .bubble .content .code-block-wrap .code-download {
    opacity: 1;
  }
}

/* ============================== */
/* SHARED ICON BUTTON FOR ITEMS */
.ci-icon-btn {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-xs);
  color: var(--text-dim);
  background: transparent;
  border: 1px solid transparent;
  transition: transform var(--duration-fast) var(--ease);
}
.ci-icon-btn:hover {
  background: var(--bg-elev-2);
  border-color: var(--border);
  color: var(--text);
}
.conversation-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--sidebar-item-h);
  padding: var(--space-2) var(--space-3);
  color: var(--text-faint);
  font-size: var(--text-base);
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ============================== */
/* LIST SKELETON */
.conversation-skeleton {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.conversation-skeleton span {
  min-height: var(--sidebar-item-h);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
}
.conversation-skeleton[hidden] {
  display: none;
}
.conversation-skeleton .folder-skeleton {
  background: transparent;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-2);
}
.conversation-skeleton .folder-skeleton i {
  width: 14px;
  height: 14px;
  border-radius: var(--radius-xs);
  background: var(--border-strong);
  flex: none;
}
.conversation-skeleton .nested-skeleton {
  margin-left: var(--space-5);
}

/* ============================== */
/* FOLDERS */
.folder-section {
  display: flex;
  flex-direction: column;
}
.folder-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-2);
  min-height: var(--sidebar-item-h);
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  font-size: var(--text-base);
  transition: transform var(--duration-fast) var(--ease);
}
.folder-header:hover {
  background: var(--bg-elev-2);
  z-index: 5;
}
.folder-section.drag-over {
  background: color-mix(in srgb, var(--accent) 15%, var(--bg-elev-2));
  border-radius: var(--radius-sm);
  outline: 2px dashed var(--accent);
}
.folder-section.drag-over .conversation-item {
  background: transparent;
  border-color: transparent;
}
.folder-chevron {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-xs);
  background: transparent;
  border: 0;
  color: var(--text-dim);
  flex: none;
  transform: rotate(0deg);
  cursor: pointer;
}
.folder-chevron.expanded {
  transform: rotate(90deg);
}
.folder-chevron:hover {
  color: var(--text);
}
.folder-icon-btn {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  flex: none;
  cursor: pointer;
  border-radius: var(--radius-xs);
  transition: transform var(--duration-fast) var(--ease);
  margin-left: calc(-1 * var(--space-1));
}
.folder-icon-btn:hover {
  color: var(--text);
}
.folder-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.folder-rename-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg-elev-2);
  border: 1px solid var(--accent);
  outline: 0;
  padding: 0;
  margin: -1px 0 -1px -1px;
  box-sizing: border-box;
  border-radius: var(--radius-xs);
}
.folder-actions {
  flex: none;
}
.folder-actions .ci-icon-btn {
  width: 24px;
  height: 24px;
}
.reorder-btn {
  width: 24px;
  height: 24px;
}
.folder-expand-wrap {
  display: grid;
  grid-template-rows: 0fr;
}
.folder-expand-inner {
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding-left: var(--space-5);
  transition: opacity var(--duration) var(--ease);
}
.folder-expand-inner > :first-child {
  margin-top: var(--space-1);
}
.folder-expand-inner .conversation-item::before {
  content: "";
  position: absolute;
  left: calc(var(--space-5) / 2 - var(--space-5));
  top: 0;
  bottom: calc(-1 * var(--space-1));
  width: 2px;
  background: var(--border);
  border-radius: 1px;
  z-index: -1;
}
.folder-expand-inner .conversation-item::after {
  content: "";
  position: absolute;
  left: calc(var(--space-5) / 2 - var(--space-5));
  top: 50%;
  width: calc(var(--space-5) / 2);
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  z-index: -1;
}
.folder-expand-inner .conversation-item:last-child::before {
  bottom: 50%;
}
.folder-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--sidebar-item-h);
  padding: var(--space-2) var(--space-3);
  color: var(--accent);
  font-size: var(--text-base);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

/* ============================== */
/* DROP ZONE */
.ungrouped-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition:
    opacity var(--duration) var(--ease),
    transform var(--duration) var(--ease);
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  padding: var(--space-3) var(--space-4);
  margin: 0 var(--space-2) var(--space-1);
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: var(--text-base);
  text-align: center;
  background: var(--bg-elev);
}
.sidebar.is-dragging .ungrouped-drop {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.ungrouped-drop.drag-over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, var(--bg-elev-2));
}

/* ============================== */
/* STAR ICON */
.ci-star {
  flex: none;
  display: grid;
  place-items: center;
  color: var(--accent);
  margin-right: var(--space-1);
  transition: transform var(--duration-fast) var(--ease);
}

/* ============================== */
/* ITEM BUTTONS */
.reorder-btn,
.star-btn {
  opacity: 0;
  transition:
    opacity var(--duration-fast) var(--ease),
    transform var(--duration-fast) var(--ease);
}
.conversation-item:hover .reorder-btn,
.conversation-item:hover .star-btn,
.folder-header:hover .reorder-btn,
.conversation-item:focus-within .reorder-btn,
.conversation-item:focus-within .star-btn,
.folder-header:focus-within .reorder-btn {
  opacity: 1;
}
.star-btn svg {
  fill: none;
}
.conversation-item.is-starred .star-btn svg {
  fill: currentColor;
}

/* ============================== */
/* LIST RERENDER */
.no-anim-actions .ci-actions,
.no-anim-actions .folder-actions,
.no-anim-actions .reorder-btn,
.no-anim-actions .star-btn {
  transition: none;
}
.no-anim-actions .folder-header {
  transition: none;
}

/* ============================== */
/* DRAG STATES */
.conversation-item.dragging {
  opacity: 0.4;
}
.conversation-item.dragging .ci-actions {
  opacity: 0;
  pointer-events: none;
}
.conversation-item.dragging::before,
.conversation-item.dragging::after {
  opacity: 0;
}
.folder-expand-inner .conversation-item:hover {
  z-index: auto;
}

/* ============================== */
/* POPOVERS */
.popover {
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 220px;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease);
  will-change: opacity;
  transform: translateZ(0);
}
.popover.visible {
  opacity: 1;
}
.icon-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-1);
}
.icon-grid-item {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: transform var(--duration-fast) var(--ease);
}
.icon-grid-item:hover {
  background: var(--surface);
  color: var(--text);
}
.icon-grid-item.selected {
  border-color: var(--accent);
  color: var(--accent);
}
.popover-buttons {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}
.popover .input {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  color: var(--text);
  font-size: var(--text-base);
  outline: 0;
}
.popover .input:focus {
  border-color: var(--accent);
}

/* ============================== */
/* RENAME INPUT */
.rename-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: var(--text-base);
  color: var(--text);
  background: var(--bg-elev-2);
  border: 1px solid var(--accent);
  outline: 0;
  padding: 0;
  margin: -1px 0 -1px -1px;
  width: 100%;
  box-sizing: border-box;
  border-radius: var(--radius-xs);
}
.rename-input:focus {
  background: var(--bg-elev);
  border-color: var(--accent);
}

/* ============================== */
/* SIDEBAR BOTTOM */
.sidebar-bottom {
  position: relative;
  border-top: 1px solid var(--border);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.menu-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  min-height: var(--sidebar-item-h);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: var(--text-base);
  text-align: left;
  text-decoration: none;
  width: 100%;
}
.menu-btn:hover {
  background: var(--surface);
  color: var(--text);
}
.menu-label {
  flex: 1;
}
#theme-toggle .icon-sun {
  display: none;
}
#theme-toggle .icon-moon {
  display: block;
}
:root[data-theme="light"] #theme-toggle .icon-sun {
  display: block;
}
:root[data-theme="light"] #theme-toggle .icon-moon {
  display: none;
}

/* ============================== */
/* CHAT HEADER */
.chat-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-bottom: 1px solid var(--border);
  transform: translateZ(0);
}
.header-spacer {
  flex: 1;
}

/* ============================== */
/* MODEL PILL */
.model-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: var(--text-base);
  max-width: min(420px, 60vw);
  transition: transform var(--duration-fast) var(--ease);
}
.model-pill:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}
.model-pill-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
.model-pill-free {
  flex: none;
  font-size: var(--text-sm);
  color: var(--accent);
  background: var(--bg-elev-2);
  padding: 0 var(--space-1);
  border-radius: var(--radius-xs);
  border: 1px solid var(--accent);
  text-transform: uppercase;
}
.model-pill[data-no-model="true"],
.model-pill[data-no-key="true"] {
  color: var(--text-faint);
  border-color: var(--border);
}
.model-pill[data-no-key="true"]:hover {
  border-color: var(--accent);
  color: var(--text);
}
.model-pill[data-restricted="true"] {
  border-color: var(--danger);
  color: var(--danger);
}
.model-pill[data-restricted="true"]:hover {
  color: var(--text);
}

/* ============================== */
/* CONTEXT BAR */
.context-bar-wrap {
  position: relative;
  flex: none;
  height: var(--space-1);
  background: var(--bg-elev-2);
}
.context-bar {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.context-bar-fill {
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform var(--duration-fast) var(--ease);
}
.context-bar[data-level="warn"] .context-bar-fill {
  background: var(--warning);
}
.context-bar[data-level="critical"] .context-bar-fill {
  background: var(--danger);
}
.context-bar-label {
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--text-xs);
  font-family: var(--mono);
  font-weight: bold;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: var(--space-1) var(--space-2);
  white-space: nowrap;
  pointer-events: none;
  z-index: 1;
}

/* ============================== */
/* MESSAGES */
.messages-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.messages {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-anchor: auto;
  contain: layout style paint;
  transform: translateZ(0);
}
.messages-inner {
  max-width: var(--composer-max);
  margin: 0 auto;
  padding: var(--space-4) var(--space-4)
    calc(var(--composer-pad, 160px) + var(--space-5));
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ============================== */
/* MESSAGE LAYOUT */
.message {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  contain: content;
}
.messages-inner.is-first-paint .message {
  animation: message-fade-in var(--duration-slow) var(--ease-out) both;
}
@keyframes message-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.message.message-enter {
  animation: message-enter var(--duration-slow) var(--ease-out) both;
}
@keyframes message-enter {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
.message[hidden] {
  display: none;
}
.message[data-user="true"] {
  flex-direction: row-reverse;
}
.message[data-user="true"] .bubble {
  max-width: 80%;
}

/* ============================== */
/* AVATAR */
.avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-weight: bold;
  font-size: var(--text-sm);
  flex: none;
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
  overflow: hidden;
}
.message[data-user="true"] .avatar {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: transparent;
  margin-top: 3px;
}
.message[data-user="true"] .avatar:has(img) {
  background: var(--surface);
  border-color: var(--border);
}
.message[data-user="true"] .avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.message:not([data-user="true"]) .avatar-mark {
  color: var(--text-faint);
}

/* ============================== */
/* BUBBLE */
.bubble {
  position: relative;
  min-width: 0;
  max-width: 100%;
  font-size: var(--text-lg);
  word-wrap: break-word;
  overflow-wrap: anywhere;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.bubble.user {
  background: var(--user-bubble);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
}
.message:not([data-user="true"]) .bubble > .content:first-child {
  padding-top: calc((34px - var(--text-lg) * 1.5) / 2);
}
.message:not([data-user="true"])
  .bubble
  > .content:first-child:has(
    > :is(.stream-formatted, .content)
      > :is(
        h1,
        h2,
        h3,
        h4,
        h5,
        h6,
        pre,
        blockquote,
        ul,
        ol,
        hr,
        table,
        .table-wrap,
        .code-block-wrap,
        .katex-display
      ):first-child
  ) {
  padding-top: 0;
}

/* ============================== */
/* BUBBLE CONTENT TYPOGRAPHY */
.bubble .content > *:first-child {
  margin-top: 0;
}
.bubble .content > .stream-formatted > *:first-child {
  margin-top: 0;
}
.bubble .content > *:last-child {
  margin-bottom: 0;
}
.bubble .content {
  line-height: 1.5;
}
.bubble .content p {
  margin: 0 0 var(--space-3);
}
.bubble .content p:last-child {
  margin-bottom: 0;
}
.bubble .content h1,
.bubble .content h2,
.bubble .content h3,
.bubble .content h4,
.bubble .content h5,
.bubble .content h6 {
  margin: var(--space-4) 0 var(--space-2);
  font-weight: bold;
}
.bubble .content h1 {
  font-size: 1.5em;
}
.bubble .content h2 {
  font-size: 1.3em;
}
.bubble .content h3 {
  font-size: 1.1em;
}
.bubble .content ul,
.bubble .content ol {
  margin: 0 0 var(--space-3);
  padding-left: var(--space-5);
}
.bubble .content li {
  margin: var(--space-1) 0;
}
.bubble .content li:has(> input[type="checkbox"]) {
  list-style: none;
  margin-left: calc(-1 * var(--space-5));
}
.bubble .content li > input[type="checkbox"] {
  accent-color: var(--accent);
  margin-right: var(--space-2);
}

/* ============================== */
/* LINKS */
.bubble .content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  transition: opacity var(--duration-fast) var(--ease);
}
.bubble .content a:hover {
  opacity: 0.8;
}

/* ============================== */
/* BLOCKQUOTES & HR */
.bubble .content blockquote {
  margin: 0 0 var(--space-3);
  padding: var(--space-1) var(--space-3);
  border-left: 2px solid var(--border-strong);
  color: var(--text-dim);
}
.bubble .content hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--space-4) 0;
}

/* ============================== */
/* ALERTS */
.bubble .content blockquote.alert {
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.bubble .content blockquote.alert .alert-title {
  font-weight: bold;
  font-size: var(--text-sm);
  margin: 0 0 var(--space-1);
}
.bubble .content blockquote.alert-note,
.bubble .content blockquote.alert-tip {
  border-left-color: var(--accent);
}
.bubble .content blockquote.alert-note .alert-title,
.bubble .content blockquote.alert-tip .alert-title {
  color: var(--accent);
}
.bubble .content blockquote.alert-important,
.bubble .content blockquote.alert-warning {
  border-left-color: var(--warning);
}
.bubble .content blockquote.alert-important .alert-title,
.bubble .content blockquote.alert-warning .alert-title {
  color: var(--warning);
}
.bubble .content blockquote.alert-caution {
  border-left-color: var(--danger);
}
.bubble .content blockquote.alert-caution .alert-title {
  color: var(--danger);
}

/* ============================== */
/* TABLES */
.bubble .content .table-wrap {
  overflow-x: auto;
  width: fit-content;
  max-width: 100%;
  margin: 0 0 var(--space-3);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.bubble .content .table-wrap::-webkit-scrollbar {
  height: 6px;
}
.bubble .content .table-wrap::-webkit-scrollbar-track {
  background: transparent;
}
.bubble .content .table-wrap::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-2xs);
}
.bubble .content table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--text-base);
  width: max-content;
}
.bubble .content th,
.bubble .content td {
  border: 1px solid var(--border);
  padding: var(--space-2) var(--space-3);
  text-align: left;
}
.bubble .content th {
  background: var(--surface);
  font-weight: bold;
}
.bubble .content tr:first-child td,
.bubble .content tr:first-child th {
  border-top: none;
}
.bubble .content tr:last-child td,
.bubble .content tr:last-child th {
  border-bottom: none;
}
.bubble .content tr td:first-child,
.bubble .content tr th:first-child {
  border-left: none;
}
.bubble .content tr td:last-child,
.bubble .content tr th:last-child {
  border-right: none;
}

/* ============================== */
/* IMAGES */
.bubble.user .content img {
  max-width: 100%;
  border-radius: var(--radius-sm);
}
.message:not([data-user="true"]) .bubble .content img {
  display: block;
  max-width: 100%;
  margin: var(--space-2) 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.message:not([data-user="true"]) .bubble .content img:not([src]) {
  display: none;
}

/* ============================== */
/* DETAILS */
.bubble .content details {
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.bubble .content summary {
  cursor: pointer;
  font-weight: bold;
}

/* ============================== */
/* DIAGRAMS */
.bubble .content .diagram {
  margin: 0 0 var(--space-3);
  overflow-x: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.bubble .content .diagram pre.diagram-source {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  font-family: var(--mono);
  font-size: 13.5px;
  white-space: pre;
}
.bubble .content .diagram-body svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  padding: var(--space-3);
}

/* ============================== */
/* PREVIEWS */
.bubble .content .preview {
  margin: 0 0 var(--space-3);
  background: #0d0d0d;
  border: 1px solid #2a2a2a;
  border-radius: var(--radius);
  overflow: hidden;
}
.preview .embed-head {
  border-bottom-color: #2a2a2a;
}
.preview .embed-label {
  color: #b3b3b3;
}
.preview .embed-toggle,
.preview .embed-action {
  color: #b3b3b3;
  border-color: #2a2a2a;
}
.preview .embed-toggle:hover,
.preview .embed-action:hover {
  color: #ffffff;
  border-color: #00e385;
}
.preview .embed-action[data-copied="true"] {
  color: #00e385;
  border-color: #00e385;
}
.embed-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
}
.embed-label {
  font-size: var(--text-base);
  font-weight: bold;
  color: var(--text-dim);
  margin-right: auto;
}
.embed-toggle {
  font-size: var(--text-sm);
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
}
.embed-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
}
.embed-action {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  cursor: pointer;
  flex: none;
}
.embed-action:hover {
  color: var(--text);
  border-color: var(--accent);
}
.embed-action svg {
  display: block;
}
.embed-action[data-copied="true"] {
  color: var(--accent);
  border-color: var(--accent);
}
.embed-action[data-copied="error"],
.code-copy[data-copied="error"] {
  color: var(--danger);
  border-color: var(--danger);
}
.embed-error {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--danger);
}
.preview-frame {
  display: block;
  width: 100%;
  height: 420px;
  border: 0;
  background: #fff;
}
.bubble .content .preview pre.preview-source {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  font-family: var(--mono);
  font-size: 13.5px;
  white-space: pre;
  background: #0a0a0a;
  border-color: #1f1f1f;
  color: #f8f8f2;
}

/* ============================== */
/* INLINE CODE */
.bubble .content code {
  font-family: var(--mono);
  font-size: 0.9em;
  padding: var(--space-1) var(--space-2);
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-xs);
}
.bubble .content mark {
  padding: 0 var(--space-1);
  background: var(--warning);
  color: var(--bg);
  border-radius: var(--radius-2xs);
}

/* ============================== */
/* CODE BLOCKS */
.bubble .content pre {
  margin: 0 0 var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  overflow-x: auto;
  contain: paint;
}
.bubble .content pre code {
  padding: 0;
  background: transparent;
  border: 0;
  font-size: 13.5px;
  white-space: pre;
}

/* ============================== */
/* CODE BLOCK WRAPPER */
.bubble .content .code-block-wrap {
  position: relative;
  margin: 0 0 var(--space-3);
}
.bubble .content .code-block-wrap pre {
  margin: 0;
}
.bubble .content .code-block-wrap .code-lang {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-faint);
  font-family: var(--mono);
  text-transform: lowercase;
  pointer-events: none;
}

/* ============================== */
/* CODE ACTIONS */
.bubble .content .code-block-wrap .code-copy,
.bubble .content .code-block-wrap .code-download {
  position: absolute;
  bottom: var(--space-2);
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-xs);
  color: var(--text-faint);
  opacity: 0;
  transition:
    opacity var(--duration-fast) var(--ease),
    transform var(--duration-fast) var(--ease);
}
.bubble .content .code-block-wrap .code-copy {
  right: var(--space-2);
}
.bubble .content .code-block-wrap .code-download {
  right: 36px;
}
.bubble .content .code-block-wrap:hover .code-copy,
.bubble .content .code-block-wrap:focus-within .code-copy,
.bubble .content .code-block-wrap:hover .code-download,
.bubble .content .code-block-wrap:focus-within .code-download {
  opacity: 1;
}
.bubble .content .code-block-wrap .code-copy:hover,
.bubble .content .code-block-wrap .code-download:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.bubble .content .code-block-wrap .code-copy[data-copied="true"] {
  color: var(--accent);
}

/* ============================== */
/* MESSAGE ACTIONS */
.message-actions {
  display: flex;
  gap: var(--space-1);
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast) var(--ease);
}
.message:hover .message-actions {
  opacity: 1;
  pointer-events: auto;
}

/* ============================== */
/* USER ACTIONS */
.message[data-user="true"] .message-actions {
  position: absolute;
  bottom: var(--space-1);
  right: var(--space-1);
  padding: 3px;
  gap: var(--space-0);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ============================== */
/* ASSISTANT ACTIONS */
.message[data-user="false"] .message-actions {
  margin-top: 0;
}
@media (hover: hover) and (pointer: fine) {
  .message[data-user="false"] .message-actions {
    height: 22px;
  }
}
.message:focus-within .message-actions {
  opacity: 1;
  pointer-events: auto;
}
@media (pointer: coarse) {
  .message-actions {
    opacity: 1;
    pointer-events: auto;
  }
}
.message-actions .icon-btn {
  width: 24px;
  height: 24px;
  color: var(--text-faint);
  border-radius: var(--radius-xs);
  transition: transform var(--duration-fast) var(--ease);
}
.message-actions .icon-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.message-actions .icon-btn.copied {
  color: var(--accent);
}

/* ============================== */
/* MESSAGE META */
.message-meta {
  font-size: var(--text-sm);
  color: var(--text-faint);
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
  margin-top: 0;
}
.message:not([data-user="true"])[data-empty="true"] .bubble {
  justify-content: center;
  min-height: 34px;
}
.message:not([data-user="true"])[data-empty="true"] .bubble > .content {
  display: none;
}
.message:not([data-user="true"])[data-empty="true"] .message-meta {
  margin-top: 0;
}
.message:not([data-user="true"])[data-empty="true"] .message-actions {
  display: none;
}
.message-meta .meta-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  background: transparent;
  border: 1px solid var(--text-faint);
  color: var(--text-dim);
  font-size: var(--text-sm);
}
.message-meta button.meta-pill {
  cursor: pointer;
}
.message-meta .meta-pill[data-kind="interrupted"] {
  border-color: var(--warning);
  color: var(--warning);
}
.message-meta button.meta-pill[data-kind="interrupted"]:hover {
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  color: var(--warning);
}
.message-meta .meta-pill[data-kind="error"] {
  border-color: var(--danger);
  color: var(--danger);
}
.message-meta button.meta-pill[data-kind="error"]:hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}
.message-meta .meta-pill[data-kind="compacted"] {
  border-color: var(--accent);
  color: var(--accent);
}
.message-meta .meta-pill[data-kind="skill"] {
  border-color: var(--accent);
  color: var(--accent);
  padding: var(--space-1);
  border-radius: var(--radius-xs);
}
.message[data-user="true"] .message-meta .meta-pill[data-kind="skill"] {
  margin-left: calc(-1 * var(--space-1));
}
.message-meta .meta-pill svg {
  display: block;
  flex: none;
}

/* ============================== */
/* STREAMING CURSOR */
.stream-cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--accent);
  margin-left: var(--space-1);
  vertical-align: -0.15em;
  border-radius: var(--radius-2xs);
  animation: cursor-blink 1.1s linear infinite;
  will-change: opacity;
  filter: drop-shadow(
    0 0 4px color-mix(in srgb, var(--accent) 50%, transparent)
  );
}
.stream-cursor[hidden] {
  display: none;
}
.stream-formatted:empty {
  display: none;
}
@keyframes cursor-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.15;
  }
}

/* ============================== */
/* USER ATTACHMENTS */
.user-attachments {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
  margin-left: calc(-1 * var(--space-1));
  margin-right: calc(-1 * var(--space-1));
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  border-radius: var(--radius-sm);
}
.user-attachment-chip {
  width: 56px;
  height: 56px;
  min-width: 56px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
}
.user-attachment-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0;
}

/* ============================== */
/* REASONING & WEB SEARCH PANELS */
.reasoning.panel-fresh,
.web-search.panel-fresh {
  animation: panel-fade var(--duration-slow) var(--ease-out) both;
}
@keyframes panel-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ============================== */
/* SHARED CHEVRON STYLE */
.reasoning .chevron,
.web-search .chevron {
  width: 14px;
  height: 14px;
  display: inline-grid;
  place-items: center;
  color: currentColor;
  flex: none;
  transform-origin: center;
  transition: transform var(--duration) var(--ease);
  opacity: 0.7;
}
.reasoning .chevron svg,
.web-search .chevron svg {
  display: block;
  width: 14px;
  height: 14px;
}
.reasoning[data-open="true"] .chevron,
.web-search[data-open="true"] .chevron {
  transform: rotate(90deg);
}

/* ============================== */
/* REASONING PANEL */
.reasoning {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--reasoning-bg);
  overflow: hidden;
  contain: layout style;
  width: var(--composer-max);
  max-width: 100%;
  align-self: flex-start;
}
.reasoning > .reasoning-toggle {
  width: 100%;
  height: 32px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  font-weight: bold;
  color: var(--reasoning-text);
  text-align: left;
  font-family: var(--font);
}
.reasoning > .reasoning-toggle:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.reasoning-elapsed {
  font-family: var(--mono);
  color: var(--text-faint);
  margin-left: auto;
}
.reasoning-elapsed[hidden] {
  display: none;
}
.reasoning-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--duration-slow) var(--ease);
  contain: layout style;
}
.reasoning[data-open="true"] .reasoning-body {
  grid-template-rows: 1fr;
}
.reasoning-inner {
  overflow: hidden;
  min-height: 0;
  max-height: min(60vh, 500px);
  padding: 0 var(--space-3);
  line-height: 1.5;
  font-size: var(--text-base);
  color: var(--reasoning-text);
  font-style: italic;
  opacity: 0;
  transition: opacity var(--duration-slow) var(--ease);
}
.reasoning[data-open="true"] .reasoning-inner {
  opacity: 1;
}
.reasoning[data-open-complete="true"] .reasoning-inner {
  overflow-y: auto;
}
.reasoning-text {
  padding-bottom: var(--space-2);
}
.reasoning-text:empty {
  padding-bottom: 0;
}
.reasoning-text > * {
  margin: 0;
}
.reasoning-text > * + * {
  margin-top: var(--space-2);
}
.reasoning-text a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  transition: opacity var(--duration-fast) var(--ease);
}
.reasoning-text a:hover {
  opacity: 0.8;
}
.reasoning-pending {
  margin-top: var(--space-1);
}
.reasoning-pending:empty {
  display: none;
}
.reasoning-pending:not(:empty) {
  padding-bottom: var(--space-2);
}

/* ============================== */
/* WEB SEARCH PANEL */
.web-search {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--reasoning-bg);
  overflow: hidden;
  contain: layout style;
  width: var(--composer-max);
  max-width: 100%;
  align-self: flex-start;
}
.web-search[hidden] {
  display: none;
}
.web-search > .web-search-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: bold;
  color: var(--reasoning-text);
  text-align: left;
  font-family: var(--font);
}
.web-search > .web-search-toggle:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.web-search-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.web-search-icon {
  display: block;
  flex: none;
}
.web-search-count {
  color: var(--text-faint);
  font-family: var(--mono);
}
.web-search-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--duration-slow) var(--ease);
  contain: layout style;
}
.web-search[data-open="true"] .web-search-body {
  grid-template-rows: 1fr;
}
.web-search-inner {
  overflow: hidden;
  min-height: 0;
  max-height: min(60vh, 500px);
  padding: 0 var(--space-2);
  font-size: var(--text-base);
  color: var(--reasoning-text);
  opacity: 0;
  transition: opacity var(--duration-slow) var(--ease);
}
.web-search[data-open="true"] .web-search-inner {
  opacity: 1;
}
.web-search[data-open-complete="true"] .web-search-inner {
  overflow-y: auto;
}
.web-search-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-2) 0;
  border-top: 1px dashed var(--border);
  margin-top: 0;
}
.web-search-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-xs);
  text-decoration: none;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
}
.web-search-item:hover {
  background: var(--surface-hover);
  border-color: var(--border);
}
.web-search-favicon {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-2xs);
  flex: none;
  background: var(--surface);
  object-fit: contain;
}
.web-search-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.web-search-title {
  font-size: var(--text-base);
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.web-search-site {
  font-size: var(--text-sm);
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================== */
/* SCREEN READER STATUS */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ============================== */
/* EMPTY STATE */
.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.empty-state[hidden] {
  display: none;
}
.empty-state-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-6) var(--space-5);
  text-align: center;
  user-select: none;
}
.empty-state-title {
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-dim);
}
.empty-state-sub {
  margin-top: var(--space-1);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}
.empty-state-logo {
  width: 20px;
  height: 20px;
  flex: none;
}
.empty-state-actions {
  margin-top: var(--space-4);
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  pointer-events: auto;
}
.empty-state-actions[hidden] {
  display: none;
}
.empty-state-link {
  color: inherit;
  text-decoration: none;
  pointer-events: auto;
}
.empty-state-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ============================== */
/* JUMP TO BOTTOM */
.jump-to-bottom {
  position: absolute;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%) translateY(8px);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  display: grid;
  place-items: center;
  z-index: 4;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  cursor: pointer;
  transition:
    transform var(--duration-fast) var(--ease),
    opacity var(--duration-fast) var(--ease),
    visibility 0s linear var(--duration-fast);
  will-change: transform, opacity;
}
.jump-to-bottom.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    transform var(--duration-fast) var(--ease),
    opacity var(--duration-fast) var(--ease),
    visibility 0s;
}
.jump-to-bottom:hover {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent);
}
.jump-to-bottom:active {
  transform: translateX(-50%) translateY(0) scale(0.92);
}
.jump-to-bottom svg {
  transform: translateY(1px);
}

/* ============================== */
/* IMAGE & FILE OVERLAY */
.image-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-overlay);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
}
.image-overlay[data-open="true"] {
  opacity: 1;
}
.image-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  transform: scale(0.95);
  opacity: 0;
  transition:
    transform var(--duration) var(--ease-out),
    opacity var(--duration) var(--ease-out);
}
.image-overlay[data-open="true"] img {
  transform: scale(1);
  opacity: 1;
}
.file-overlay-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 90vw;
  max-height: 90vh;
  width: 70vw;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  cursor: default;
  transform: scale(0.95);
  opacity: 0;
  transition:
    transform var(--duration) var(--ease-out),
    opacity var(--duration) var(--ease-out);
}
.image-overlay[data-open="true"] .file-overlay-container {
  transform: scale(1);
  opacity: 1;
}
.file-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.file-overlay-name {
  font-size: var(--text-base);
  font-weight: bold;
  color: var(--text);
}
.file-overlay-close {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.file-overlay-close:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.file-overlay-content {
  padding: var(--space-3);
  overflow: auto;
  flex: 1;
  background: var(--bg);
}
.file-overlay-pre {
  margin: 0;
  padding: var(--space-3);
  overflow: auto;
  flex: 1;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: var(--text-base);
  white-space: pre-wrap;
  word-break: break-word;
}
.file-overlay-pre code {
  font-family: inherit;
  background: transparent;
}

/* ============================== */
/* COMPOSER */
.composer-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-composer);
  padding: var(--space-4);
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  pointer-events: none;
}
.composer-wrap > .composer,
.composer-wrap > .dots-wave,
.composer-wrap > .edit-bar {
  pointer-events: auto;
}

/* ============================== */
/* EDIT BAR */
.edit-bar {
  max-width: var(--composer-max);
  margin: 0 auto var(--space-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-size: var(--text-base);
  color: var(--text);
}
.edit-bar[hidden] {
  display: none;
}
.edit-bar-label {
  font-weight: bold;
}
.edit-bar-cancel {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: var(--text-sm);
  cursor: pointer;
}
.edit-bar-cancel:hover {
  background: var(--accent);
  color: var(--accent-fg);
}

/* ============================== */
/* SKILL CHIP */
.skill-chip {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-2);
  margin: var(--space-2) var(--space-2) 0 var(--space-2);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text);
  width: fit-content;
}
.skill-chip-icon {
  color: var(--accent);
  font-weight: bold;
  font-family: var(--mono);
}
.skill-chip-remove {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  line-height: 1;
  color: var(--accent);
  font-size: var(--text-lg);
}
.skill-chip-remove:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* ============================== */
/* SKILLS PICKER */
.skills-picker {
  position: fixed;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  max-height: min(178px, 40vh);
  overflow-y: auto;
  padding: var(--space-1);
  z-index: var(--z-picker);
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  pointer-events: none;
  transition:
    opacity var(--duration) var(--ease-out),
    transform var(--duration) var(--ease-out);
  will-change: opacity, transform;
}
.skills-picker.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.skills-picker-item {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  border: 1px solid transparent;
  scroll-margin: var(--space-1) 0;
}
.skills-picker-item:hover {
  background: var(--surface);
}
.skills-picker-item[data-selected="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.skills-picker-name {
  font-size: var(--text-base);
  color: var(--text);
}
.skills-picker-desc {
  font-size: var(--text-sm);
  color: var(--text-dim);
}
.skills-picker-empty {
  padding: var(--space-4);
  text-align: center;
  color: var(--text-faint);
  font-size: var(--text-base);
}

/* ============================== */
/* DOTS WAVE ANIMATION */
.dots-wave {
  --wave-dur: 1.8s;
  --wave-step: calc(var(--wave-dur) / 23);
  max-width: var(--composer-max);
  margin: 0 auto var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 16px;
}
.dots-wave span {
  width: 5px;
  height: 5px;
  border-radius: var(--radius-full);
  background: var(--text-faint);
  display: block;
  opacity: 0.45;
}
.dots-wave.is-streaming {
  --wave-dur: 1.2s;
}
.dots-wave.is-streaming span {
  background: var(--accent);
  animation: dots-wave-active var(--wave-dur) cubic-bezier(0.45, 0, 0.55, 1)
    infinite;
  animation-delay: calc(var(--i, 0) * -1 * var(--wave-step));
  will-change: transform, opacity;
}
@keyframes dots-wave-active {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(0.75);
    opacity: 0.55;
  }
  50% {
    transform: translate3d(0, -6px, 0) scale(1.1);
    opacity: 1;
  }
}

/* ============================== */
/* COMPOSER SHELL */
.composer {
  max-width: var(--composer-max);
  margin: 0 auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  contain: layout style;
}
.composer:focus-within {
  border-color: var(--accent);
  background: var(--bg-elev-2);
}
.composer[data-disabled="true"] {
  pointer-events: none;
}
.composer-inner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  min-height: 48px;
}

/* ============================== */
/* COMPOSER ICON BUTTON */
.composer-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: transform var(--duration-fast) var(--ease);
  flex: none;
  align-self: flex-end;
}
.composer-icon:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.composer-icon[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  color: var(--text-faint);
  border-color: var(--border);
  background: var(--surface);
}

/* ============================== */
/* TOGGLE VARIANTS */
.composer-icon.web-search-toggle,
.composer-icon.reasoning-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  padding: 0;
  gap: 0;
}
.composer-icon.web-search-toggle > svg,
.composer-icon.reasoning-toggle > svg {
  display: block;
  margin: 0;
}
.composer-icon.web-search-toggle:hover,
.composer-icon.reasoning-toggle:hover {
  color: var(--text);
}

/* ============================== */
/* TOGGLE STATE */
.composer-icon[data-on="true"] {
  color: var(--accent);
  border-color: var(--accent);
}
.composer-icon[data-on="true"]:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--surface);
}

/* ============================== */
/* REASONING MENU */
.reasoning-menu {
  position: fixed;
  z-index: var(--z-picker);
  min-width: 200px;
  max-height: min(320px, 60vh);
  overflow-y: auto;
  padding: var(--space-1);
  display: flex;
  flex-direction: column;
  gap: var(--space-0);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  pointer-events: none;
  transition:
    opacity var(--duration-fast) var(--ease),
    transform var(--duration-fast) var(--ease-out);
  will-change: opacity, transform;
}
.reasoning-menu.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.reasoning-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font-size: var(--text-base);
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
}
.reasoning-menu-item:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text);
}
.reasoning-menu-item[data-active="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.reasoning-menu-check {
  width: 16px;
  flex: none;
  text-align: center;
}
.reasoning-menu-separator {
  height: 1px;
  background: var(--border);
  margin: var(--space-1) var(--space-2);
}

/* ============================== */
/* COMPOSER INPUT */
#composer-input {
  flex: 1;
  resize: none;
  font: inherit;
  font-size: var(--text-lg);
  padding: var(--space-2);
  min-height: 24px;
  max-height: 200px;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font-family: var(--font);
  overflow-y: auto;
  field-sizing: content;
}
#composer-input::placeholder {
  color: var(--text-faint);
}

/* ============================== */
/* SEND BUTTON */
.send-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  align-self: flex-end;
  transition: transform var(--duration-fast) var(--ease);
}
.send-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.send-btn[data-active="true"] {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-fg);
}
.send-btn[data-active="true"]:hover {
  border-color: var(--accent);
}
.send-btn[data-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  color: var(--text-faint);
  border-color: var(--border);
  background: var(--surface);
}
.send-btn .stop-icon {
  display: none;
}
.send-btn[data-state="streaming"] .send-icon {
  display: none;
}
.send-btn[data-state="streaming"] .stop-icon {
  display: block;
}
.send-btn[data-state="streaming"] {
  background: var(--text);
  border-color: transparent;
  color: var(--bg);
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
}

/* ============================== */
/* DISABLED COMPOSER */
.composer-wrap[data-disabled="true"] .dots-wave {
  display: none;
}

/* ============================== */
/* COMPOSER ATTACHMENTS */
.composer-attachments {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-2);
  padding: var(--space-2);
  margin-top: calc(-1 * var(--space-2));
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.composer-attachments[hidden] {
  display: none;
}
.attachment-chip {
  position: relative;
  width: 56px;
  height: 56px;
  min-width: 56px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.attachment-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.attachment-file-icon {
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}
.attachment-file-ext {
  font-size: var(--text-sm);
  font-weight: bold;
  color: var(--text-dim);
  text-transform: uppercase;
  padding-bottom: var(--space-1);
}
.attachment-chip .remove {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform var(--duration-fast) var(--ease);
}
.attachment-chip-warn {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger) inset;
}
.attachment-chip-warn::after {
  content: "!";
  position: absolute;
  top: var(--space-1);
  left: var(--space-1);
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  background: var(--danger);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}
.attachment-chip-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger) inset;
}
.user-attachment-file {
  width: 120px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text);
  text-align: center;
  padding: var(--space-1) var(--space-2);
  overflow: hidden;
  word-break: break-all;
}
.user-attachment-file-label {
  font-size: var(--text-sm);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================== */
/* MODALS */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--space-4);
}
.modal[hidden] {
  display: none;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
  will-change: opacity;
}
.modal[data-open="true"] .modal-backdrop {
  opacity: 1;
}
.modal-panel {
  position: relative;
  width: min(880px, 100%);
  height: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transform: translateY(8px) scale(0.98);
  opacity: 0;
  transition:
    transform var(--duration) var(--ease-out),
    opacity var(--duration) var(--ease-out);
  transform-origin: center;
  will-change: transform, opacity;
}
.modal[data-open="true"] .modal-panel {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* ============================== */
/* MODAL HEADER */
.modal-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: bold;
  flex: 1;
}
.modal-header-titles {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex: 1;
  min-width: 0;
}
.modal-header .icon-btn {
  border: 1px solid var(--border);
}
.modal-header .icon-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.model-picker-subtitle {
  font-size: var(--text-sm);
  color: var(--text-faint);
}
.modal-body {
  padding: var(--space-4);
  overflow-y: auto;
  flex: 1;
}

/* ============================== */
/* FORM ELEMENTS */
.field-help {
  font-size: var(--text-sm);
  color: var(--text-faint);
}
.input,
.textarea,
.select {
  width: 100%;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-base);
  color: var(--text);
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}
.select {
  padding-right: var(--space-6);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px 14px;
}
.textarea {
  min-height: 80px;
  resize: vertical;
  font-family: var(--font);
}
.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--accent);
  background: var(--bg-elev);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--text-faint);
}
.input-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}
.input-row .input {
  flex: 1;
  min-width: 0;
}

/* ============================== */
/* BUTTONS */
.btn {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: var(--text-base);
  cursor: pointer;
}
.btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}
.btn-ghost:hover {
  background: var(--surface);
  color: var(--text);
}
.btn-danger {
  background: transparent;
  border-color: var(--border);
  color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

/* ============================== */
/* PROVIDER CARDS */
.provider-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.provider-card .provider-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.provider-card .provider-name {
  font-weight: bold;
  font-size: var(--text-base);
  color: var(--text);
}
.provider-card .provider-state {
  font-size: var(--text-sm);
  color: var(--text-faint);
  margin-left: auto;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
  flex: none;
  min-width: 72px;
  text-align: center;
}
.provider-card .provider-state[data-state="ok"] {
  color: var(--accent);
  border-color: var(--accent);
}
.provider-card .provider-state[data-state="error"] {
  color: var(--danger);
  border-color: var(--danger);
}
.provider-status {
  font-size: var(--text-sm);
  line-height: 1.5;
  min-height: 1.5em;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.provider-status[data-kind="ok"] {
  color: var(--accent);
}
.provider-status[data-kind="err"] {
  color: var(--danger);
}

/* ============================== */
/* BUDGET BAR */
.provider-budget:empty {
  display: none;
}
.provider-budget-bar {
  height: 4px;
  background: var(--border);
  border-radius: var(--radius-2xs);
  overflow: hidden;
  margin-bottom: var(--space-1);
}
.provider-budget-fill {
  height: 100%;
  width: 100%;
  background: var(--accent);
  border-radius: var(--radius-2xs);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform var(--duration) var(--ease);
}
.provider-budget-text {
  font-size: var(--text-sm);
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.provider-card .input-row {
  flex-wrap: wrap;
}
.provider-card .input-row .btn {
  flex: none;
  min-width: 84px;
}

/* ============================== */
/* ACCENT SWATCHES */
.accent-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}
.swatch {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  cursor: pointer;
  position: relative;
}
.swatch:hover {
  border-color: var(--border-strong);
}
.swatch[data-active="true"] {
  border-color: var(--text);
}
.swatch[data-active="true"]::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: var(--radius-full);
  border: 2px solid var(--bg);
  pointer-events: none;
}
.swatch-input {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  border: 1px dashed var(--border-strong);
  background: transparent;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  padding: 0;
}
.swatch-input::-webkit-color-swatch-wrapper {
  padding: 0;
}
.swatch-input::-webkit-color-swatch {
  border: 0;
  border-radius: var(--radius-full);
}
.swatch-input::-moz-color-swatch {
  border: 0;
  border-radius: var(--radius-full);
}
.contrast-note {
  font-size: var(--text-sm);
  color: var(--danger);
  margin-top: var(--space-2);
}

/* ============================== */
/* TOGGLE */
.toggle {
  width: 36px;
  height: 20px;
  background: var(--border-strong);
  border: 0;
  padding: 0;
  border-radius: var(--radius-full);
  position: relative;
  cursor: pointer;
  flex: none;
}
.toggle::after {
  content: "";
  position: absolute;
  top: var(--space-0);
  left: var(--space-0);
  width: 16px;
  height: 16px;
  background: var(--text);
  border-radius: var(--radius-full);
  transition: transform var(--duration) var(--ease);
  pointer-events: none;
}
.toggle[data-on="true"] {
  background: var(--accent);
}
.toggle[data-on="true"]::after {
  transform: translateX(16px);
}
.toggle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ============================== */
/* RANGE SLIDER */
.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: var(--radius-2xs);
  outline: 0;
  margin: var(--space-2) 0;
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: var(--radius-full);
  cursor: pointer;
}
.range::-webkit-slider-thumb:hover {
  border-color: var(--border-strong);
}
.range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: var(--radius-full);
  border: 0;
  cursor: pointer;
}

/* ============================== */
/* SETTINGS */
#settings-modal .modal-body {
  padding: 0;
  overflow: hidden;
}
.settings-layout {
  display: flex;
  gap: 0;
  height: 100%;
}
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: 200px;
  flex: none;
  padding: var(--space-2);
  border-right: 1px solid var(--border);
  background: var(--bg-elev);
}
.settings-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font-size: var(--text-base);
  text-align: left;
  cursor: pointer;
}
.settings-nav-item:hover {
  background: var(--surface);
  color: var(--text);
}
.settings-nav-item.is-active {
  background: var(--accent-soft);
  color: var(--text);
}
.settings-nav-item.is-active .settings-nav-icon {
  color: var(--accent);
}
.settings-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  flex: none;
}
.settings-nav-label {
  font-weight: normal;
}
.settings-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: var(--space-3);
}
.settings-content-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

/* ============================== */
/* SETTINGS GROUPS */
.settings-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.settings-group-title {
  font-size: var(--text-sm);
  color: var(--text-faint);
  font-weight: normal;
  text-transform: uppercase;
  margin: 0 0 var(--space-3) 0;
}

/* ============================== */
/* SETTINGS ROWS */
.settings-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
}
.settings-row-stacked {
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
}
.settings-row-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.settings-row-label {
  font-size: var(--text-base);
  color: var(--text);
}
.settings-row-help {
  font-size: var(--text-sm);
  color: var(--text-faint);
}
.settings-row-control {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.settings-row-control .input,
.settings-row-control .select,
.settings-row-control .textarea {
  width: auto;
  min-width: 200px;
}
.settings-row-stacked .settings-row-control {
  width: 100%;
}
.settings-row-stacked .settings-row-control .input,
.settings-row-stacked .settings-row-control .select,
.settings-row-stacked .settings-row-control .textarea {
  width: 100%;
  min-width: 0;
}
.range-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 220px;
}
.range-wrap .range {
  flex: 1;
  min-width: 120px;
}
.range-readout {
  font-family: var(--mono);
  font-size: var(--text-base);
  color: var(--text);
  min-width: 32px;
  text-align: right;
}
.tint-control {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.btn-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.data-storage-note {
  font-family: var(--mono);
  font-size: var(--text-sm);
  color: var(--text-faint);
  min-width: 240px;
}
.data-storage-note[data-kind="error"] {
  color: var(--danger);
}
.data-storage-note[data-kind="ok"] {
  color: var(--accent);
}

/* ============================== */
/* MODEL PICKER */
.model-picker-panel {
  width: min(820px, 100%);
  height: 620px;
}
.model-picker-search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
}
.model-picker-search input {
  flex: 1;
  font-size: var(--text-base);
  color: var(--text);
}
.model-picker-list {
  overflow-y: auto;
  flex: 1;
  padding: var(--space-2);
  contain: layout style;
}
.model-group-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-faint);
  text-transform: uppercase;
  padding: var(--space-2) var(--space-3) var(--space-1);
  font-weight: bold;
}
.lab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: var(--radius-xs);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: var(--text-sm);
  font-weight: bold;
  text-transform: none;
  overflow: hidden;
}
.lab-badge[data-dark="true"] {
  background: #101010;
  border-color: #2a2a2a;
}
.lab-badge .lab-icon {
  width: 18px;
  height: 18px;
  display: block;
}
.lab-badge .lab-icon-mask {
  background: #7624f4;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
}
:root[data-theme="dark"] .lab-badge .lab-icon-mask--openrouter {
  background: #c8ff00;
}
.lab-badge .lab-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--text-faint);
}
:root[data-theme="dark"] .lab-badge[data-mono="true"] .lab-icon {
  filter: invert(1);
}
.model-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-1);
}
.model-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  cursor: pointer;
  contain: content;
  min-width: 0;
}
.model-row:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}
.model-row[data-active="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.model-row .model-id {
  font-family: var(--font);
  font-size: var(--text-base);
  color: var(--text);
  min-width: 0;
  flex: 1;
  overflow-wrap: anywhere;
}
.chip {
  font-size: var(--text-sm);
  padding: 0 var(--space-1);
  border-radius: var(--radius-xs);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  text-transform: uppercase;
}
.chip[data-kind="free"] {
  flex: none;
  color: var(--accent);
  border-color: var(--accent);
}
.model-empty {
  padding: var(--space-5);
  text-align: center;
  color: var(--text-faint);
  font-size: var(--text-base);
}

/* ============================== */
/* RESTRICTED MODEL ROWS */
.model-row[data-restricted="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.model-row[data-warning="true"] {
  border: 1px solid var(--danger);
  background: var(--surface);
}
.guardrail-link {
  display: inline-block;
  margin-top: var(--space-2);
  font-size: var(--text-base);
  color: var(--accent);
  text-decoration: none;
}
.guardrail-link:hover {
  text-decoration: underline;
}

/* ============================== */
/* SKILLS SETTINGS */
.skill-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.skill-list-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  text-align: left;
}
.skill-list-name {
  font-size: var(--text-base);
  color: var(--text);
}
.skill-list-desc {
  font-size: var(--text-sm);
  color: var(--text-faint);
}

/* ============================== */
/* CONFIRM MODAL */
.confirm-modal .modal-panel {
  width: min(440px, 100%);
  height: auto;
  max-height: 80vh;
}
.confirm-modal .modal-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.confirm-title {
  font-size: var(--text-lg);
  font-weight: bold;
  margin: 0;
  flex: 1;
}
.confirm-message {
  margin: 0;
  font-size: var(--text-base);
  color: var(--text-dim);
  white-space: pre-wrap;
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* ============================== */
/* KATEX */
.bubble .content .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: var(--space-2) 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.bubble .content .katex-fallback {
  font-family: var(--mono);
  font-size: 0.9em;
  padding: var(--space-1) var(--space-2);
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-xs);
  color: var(--text-dim);
}

/* ============================== */
/* SYNTAX HIGHLIGHTING */
code[class*="language-"],
pre[class*="language-"] {
  color: #f8f8f2;
  background: none;
  font-family: var(--mono);
  font-size: var(--text-base);
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  word-wrap: normal;
  -moz-tab-size: 4;
  tab-size: 4;
  -webkit-hyphens: none;
  hyphens: none;
}
pre[class*="language-"] {
  padding: 1em;
  margin: 0.5em 0;
  overflow: auto;
  border-radius: 0.5em;
}
:not(pre) > code[class*="language-"] {
  padding: 0.1em 0.3em;
  border-radius: 0.3em;
  white-space: normal;
}

/* ============================== */
/* DARK THEME TOKENS */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #6272a4;
}
.token.punctuation {
  color: #f8f8f2;
}
.token.namespace {
  opacity: 0.7;
}
.token.property,
.token.tag,
.token.constant,
.token.symbol,
.token.deleted {
  color: #ff5555;
}
.token.boolean,
.token.number {
  color: #bd93f9;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.inserted {
  color: #50fa7b;
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string,
.token.variable {
  color: #f8f8f2;
}
.token.atrule,
.token.attr-value,
.token.function,
.token.class-name {
  color: #8be9fd;
}
.token.keyword {
  color: #ff79c6;
}
.token.regex,
.token.important {
  color: #ffb86c;
}
.token.important,
.token.bold {
  font-weight: bold;
}
.token.italic {
  font-style: italic;
}
.token.entity {
  cursor: help;
}

/* ============================== */
/* LIGHT THEME TOKENS */
:root[data-theme="light"] code[class*="language-"],
:root[data-theme="light"] pre[class*="language-"] {
  color: #282a36;
}
:root[data-theme="light"] .token.comment,
:root[data-theme="light"] .token.prolog,
:root[data-theme="light"] .token.doctype,
:root[data-theme="light"] .token.cdata {
  color: #6272a4;
}
:root[data-theme="light"] .token.punctuation {
  color: #282a36;
}
:root[data-theme="light"] .token.namespace {
  opacity: 0.7;
}
:root[data-theme="light"] .token.property,
:root[data-theme="light"] .token.tag,
:root[data-theme="light"] .token.constant,
:root[data-theme="light"] .token.symbol,
:root[data-theme="light"] .token.deleted {
  color: #e06c75;
}
:root[data-theme="light"] .token.boolean,
:root[data-theme="light"] .token.number {
  color: #6f42c1;
}
:root[data-theme="light"] .token.selector,
:root[data-theme="light"] .token.attr-name,
:root[data-theme="light"] .token.string,
:root[data-theme="light"] .token.char,
:root[data-theme="light"] .token.inserted {
  color: #22863a;
}
:root[data-theme="light"] .token.operator,
:root[data-theme="light"] .token.entity,
:root[data-theme="light"] .token.url,
:root[data-theme="light"] .language-css .token.string,
:root[data-theme="light"] .style .token.string,
:root[data-theme="light"] .token.variable {
  color: #282a36;
}
:root[data-theme="light"] .token.atrule,
:root[data-theme="light"] .token.attr-value,
:root[data-theme="light"] .token.function,
:root[data-theme="light"] .token.class-name {
  color: #6f42c1;
}
:root[data-theme="light"] .token.keyword {
  color: #d73a49;
}
:root[data-theme="light"] .token.regex,
:root[data-theme="light"] .token.important {
  color: #e36209;
}
:root[data-theme="light"] .token.important,
:root[data-theme="light"] .token.bold {
  font-weight: bold;
}
:root[data-theme="light"] .token.italic {
  font-style: italic;
}
:root[data-theme="light"] .token.entity {
  cursor: help;
}

/* ============================== */
/* RESPONSIVE */
.sidebar-toggle {
  display: grid;
}
.mobile-new-chat {
  display: none;
}
@media (max-width: 768px) {
  .app .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    margin-left: 0;
    visibility: hidden;
    z-index: var(--z-drawer);
    transform: translateX(-100%);
    will-change: transform;
    transition:
      transform var(--duration) var(--ease-out),
      visibility 0s linear var(--duration);
  }
  .app[data-sidebar-open="true"] .sidebar {
    transform: translateX(0);
    visibility: visible;
    transition:
      transform var(--duration) var(--ease-out),
      visibility 0s;
  }
  .app[data-sidebar-open="false"] .sidebar {
    margin-left: 0;
    transform: translateX(-100%);
    visibility: hidden;
    transition:
      transform var(--duration) var(--ease-out),
      visibility 0s linear var(--duration);
  }
  .app::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: var(--z-drawer-back);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration) var(--ease-out);
  }
  .app[data-sidebar-open="true"]::after {
    opacity: 1;
    pointer-events: auto;
  }
  .mobile-new-chat {
    display: grid;
    margin-left: auto;
  }
  .header-spacer {
    display: none;
  }
  .model-pill {
    display: flex;
    flex: 1;
    max-width: none;
  }
  .composer-wrap {
    padding: var(--space-2);
  }
  .message .avatar {
    display: none;
  }
  .jump-to-bottom {
    bottom: 110px;
  }
  .model-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .model-row .model-id {
    font-size: var(--text-sm);
  }
}

/* ============================== */
/* SETTINGS RESPONSIVE */
@media (max-width: 640px) {
  .settings-layout {
    flex-direction: column;
  }
  .settings-nav {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: var(--space-1);
  }
  .settings-nav-item {
    white-space: nowrap;
  }
  .settings-content {
    padding: var(--space-4);
  }
  .settings-row {
    flex-direction: column;
    align-items: stretch;
  }
  .settings-row-control {
    width: 100%;
  }
  .settings-row-control .input,
  .settings-row-control .select,
  .settings-row-control .textarea {
    width: 100%;
    min-width: 0;
  }
}

/* ============================== */
/* BOOT ERROR SCREEN */
.boot-error {
  position: fixed;
  inset: 0;
  z-index: 2147483647;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  font-family: var(--font);
  animation: boot-fade-in 200ms var(--ease-out) both;
}
@keyframes boot-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.boot-error-panel {
  max-width: 480px;
  width: min(480px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: center;
}
.boot-error-icon {
  color: var(--danger);
}
.boot-error-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
}
.boot-error-message {
  margin: 0;
  font-size: var(--text-base);
  color: var(--text-dim);
  line-height: 1.5;
}
.boot-error-details {
  width: 100%;
  text-align: left;
  font-size: var(--text-sm);
}
.boot-error-details summary {
  cursor: pointer;
  color: var(--text-dim);
  padding: var(--space-1) 0;
  user-select: none;
}
.boot-error-details summary:hover {
  color: var(--text);
}
.boot-error-details code {
  display: block;
  padding: var(--space-2);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-family: var(--mono);
  font-size: var(--text-xs);
  color: var(--danger);
  word-break: break-word;
  white-space: pre-wrap;
  max-height: 240px;
  overflow-y: auto;
}
.boot-error-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* ============================== */
/* REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0ms !important;
    animation-duration: 0ms !important;
    animation-iteration-count: 1 !important;
  }
  .messages {
    scroll-behavior: auto;
  }
}
