/* ==================================================================
   ELQORIX AI — Research Workspace
   Part 1: tokens, themes, base, shell, sidebar, topbar
   ================================================================== */

:root {
  --font-sans: "Quicksand", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Quicksand", "Space Grotesk", "Inter", -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius-xs: 5px;
  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-pill: 999px;

  --sidebar-width: 272px;
  --chat-width: 800px;
  --answer-size: 15px;
  --topbar-height: 52px;
  --page-max: 1120px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-fast: cubic-bezier(0.4, 0, 0.2, 1);

  --danger: #f87171;
  --danger-strong: #ef4444;
  --success: #4ade80;
  --warning: #fbbf24;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 12px 34px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 28px 80px rgba(0, 0, 0, 0.62);
  --shadow-xl: 0 36px 110px rgba(0, 0, 0, 0.75);

  color-scheme: dark;
}

/* ------------------------------------------------------------------
   Themes
   ------------------------------------------------------------------ */

/* The elqorix theme mirrors the profile card: true black, dark gray
   surfaces, hairline white borders. */
html[data-theme="elqorix"] {
  --bg: #000000;
  --bg-deep: #000000;
  --sidebar: #050505;
  --surface: #0a0a0a;
  --surface-2: #111111;
  --surface-3: #1b1b1b;
  --input: #080808;
  --border: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.22);
  --text: #ffffff;
  --text-secondary: #a3a3a3;
  --muted: #6b6b6b;
  --dim: #454545;
  --backdrop: rgba(0, 0, 0, 0.72);
  --star-color: rgba(255, 255, 255, 0.55);
  --code-bg: #070707;
  --hero-glow: rgba(255, 255, 255, 0.09);
  color-scheme: dark;
}

html[data-theme="midnight"] {
  --bg: #050507;
  --bg-deep: #000000;
  --sidebar: #08080b;
  --surface: #0e0f13;
  --surface-2: #14151b;
  --surface-3: #1b1d25;
  --input: #0a0b0e;
  --border: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f0f1f5;
  --text-secondary: #b4b6c1;
  --muted: #858894;
  --dim: #5d606c;
  --backdrop: rgba(0, 0, 0, 0.68);
  --star-color: rgba(255, 255, 255, 0.6);
  --code-bg: #07080b;
  --hero-glow: rgba(91, 157, 255, 0.16);
  color-scheme: dark;
}

html[data-theme="aurora"] {
  --bg: #050813;
  --bg-deep: #02040a;
  --sidebar: #070b17;
  --surface: #0b1120;
  --surface-2: #111a2e;
  --surface-3: #17223b;
  --input: #070c18;
  --border: rgba(148, 163, 220, 0.12);
  --border-strong: rgba(148, 163, 220, 0.22);
  --text: #eef2ff;
  --text-secondary: #b6c0da;
  --muted: #8794b4;
  --dim: #5e6b8a;
  --backdrop: rgba(1, 3, 10, 0.72);
  --star-color: rgba(190, 205, 255, 0.7);
  --code-bg: #040812;
  --hero-glow: rgba(129, 140, 248, 0.2);
  color-scheme: dark;
}

html[data-theme="graphite"] {
  --bg: #0c0d0f;
  --bg-deep: #070809;
  --sidebar: #101113;
  --surface: #161719;
  --surface-2: #1c1e21;
  --surface-3: #25272b;
  --input: #101113;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --text: #f1f2f3;
  --text-secondary: #b8babf;
  --muted: #8b8e95;
  --dim: #63666d;
  --backdrop: rgba(0, 0, 0, 0.65);
  --star-color: rgba(255, 255, 255, 0.4);
  --code-bg: #0a0b0c;
  --hero-glow: rgba(200, 210, 225, 0.09);
  color-scheme: dark;
}

html[data-theme="ember"] {
  --bg: #0d0a08;
  --bg-deep: #070504;
  --sidebar: #110d0a;
  --surface: #191310;
  --surface-2: #211913;
  --surface-3: #2b2119;
  --input: #120e0b;
  --border: rgba(255, 226, 196, 0.09);
  --border-strong: rgba(255, 226, 196, 0.17);
  --text: #f7efe7;
  --text-secondary: #cbbdae;
  --muted: #9d8d7e;
  --dim: #746558;
  --backdrop: rgba(5, 2, 0, 0.7);
  --star-color: rgba(255, 226, 190, 0.55);
  --code-bg: #0a0705;
  --hero-glow: rgba(251, 191, 36, 0.15);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f5f6f8;
  --bg-deep: #eceef2;
  --sidebar: #fbfbfc;
  --surface: #ffffff;
  --surface-2: #f3f4f7;
  --surface-3: #e9ebf0;
  --input: #ffffff;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.17);
  --text: #121722;
  --text-secondary: #3d4555;
  --muted: #667085;
  --dim: #98a1b0;
  --backdrop: rgba(14, 20, 33, 0.38);
  --star-color: rgba(40, 55, 80, 0.28);
  --code-bg: #f4f5f8;
  --hero-glow: rgba(59, 130, 246, 0.12);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 12px 30px rgba(15, 23, 42, 0.09);
  --shadow-lg: 0 26px 70px rgba(15, 23, 42, 0.14);
  --shadow-xl: 0 34px 100px rgba(15, 23, 42, 0.18);
  color-scheme: light;
}

/* Accents */
html[data-accent="mono"] { --accent: #ffffff; }
html[data-accent="blue"] { --accent: #6da8ff; }
html[data-accent="violet"] { --accent: #b197fc; }
html[data-accent="emerald"] { --accent: #4ade80; }
html[data-accent="amber"] { --accent: #fbbf24; }
html[data-accent="rose"] { --accent: #fb7185; }
html[data-accent="cyan"] { --accent: #22d3ee; }

html[data-theme="light"][data-accent="mono"] { --accent: #111111; }
html[data-theme="light"][data-accent="blue"] { --accent: #2563eb; }
html[data-theme="light"][data-accent="violet"] { --accent: #7c3aed; }
html[data-theme="light"][data-accent="emerald"] { --accent: #059669; }
html[data-theme="light"][data-accent="amber"] { --accent: #b45309; }
html[data-theme="light"][data-accent="rose"] { --accent: #e11d48; }
html[data-theme="light"][data-accent="cyan"] { --accent: #0e7490; }

html {
  --accent-soft: color-mix(in srgb, var(--accent) 13%, transparent);
  --accent-softer: color-mix(in srgb, var(--accent) 7%, transparent);
  --accent-border: color-mix(in srgb, var(--accent) 34%, transparent);
  --accent-hover: color-mix(in srgb, var(--accent) 84%, #000 16%);
  --accent-ink: color-mix(in srgb, var(--accent) 70%, #000 30%);
  --accent-text: var(--accent);
}

html[data-theme="light"] {
  --accent-text: var(--accent-ink);
}

/* ------------------------------------------------------------------
   Base
   ------------------------------------------------------------------ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.26;
  background-image:
    radial-gradient(var(--star-color) 0.7px, transparent 0.9px),
    radial-gradient(var(--star-color) 0.6px, transparent 0.8px);
  background-size: 97px 97px, 151px 151px;
  background-position: 0 0, 41px 63px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 72%);
  mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 72%);
}

html[data-stars="off"] body::before {
  display: none;
}

html[data-theme="light"] body::before {
  opacity: 0.35;
}

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

a {
  color: inherit;
  text-decoration: none;
}

button {
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

svg {
  display: block;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input,
textarea,
select {
  font: inherit;
  color: inherit;
}

input::placeholder,
textarea::placeholder {
  color: var(--dim);
}

kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  padding: 3px 5px;
  border: 1px solid var(--border);
  border-bottom-color: var(--border-strong);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text) 13%, transparent);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--text) 24%, transparent);
  border: 3px solid transparent;
  background-clip: content-box;
}

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

/* ------------------------------------------------------------------
   App shell
   ------------------------------------------------------------------ */

.app {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100%;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
}

.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  width: var(--sidebar-width);
  height: 100%;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  z-index: 90;
  transition: width 0.22s var(--ease), transform 0.22s var(--ease);
}

.sidebar.collapsed {
  width: 0;
  overflow: hidden;
  border-right-color: transparent;
}

.sidebar-head {
  height: var(--topbar-height);
  flex-shrink: 0;
  padding: 0 14px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  border-radius: var(--radius-sm);
}

.brand-mark {
  width: 27px;
  height: 27px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #000000;
  color: #ffffff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.brand-mark img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.brand-text {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-text span {
  color: var(--muted);
  font-weight: 500;
}

.brand-version {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--dim);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 4px;
  line-height: 1.4;
}

.brand:hover .brand-mark {
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.sidebar-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-new-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.new-chat-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  transition: border-color 0.14s, background 0.14s, color 0.14s;
}

.new-chat-btn:hover {
  background: var(--surface-2);
  border-color: var(--accent-border);
}

.new-chat-btn kbd {
  font-size: 9px;
  padding: 2px 4px;
  background: transparent;
}

.new-chat-label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  white-space: nowrap;
}

.new-chat-label svg {
  width: 14px;
  height: 14px;
  color: var(--muted);
}

.icon-btn.bordered {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  width: 33px;
  height: auto;
  flex-shrink: 0;
}

.icon-btn.bordered:hover {
  border-color: var(--accent-border);
  background: var(--surface-2);
}

.thread-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: color-mix(in srgb, var(--text) 3.5%, transparent);
  transition: border-color 0.14s, background 0.14s;
}

.thread-search:focus-within {
  border-color: var(--accent-border);
  background: var(--surface);
}

.thread-search > svg {
  width: 13px;
  height: 13px;
  color: var(--dim);
  flex-shrink: 0;
}

.thread-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 12px;
  color: var(--text);
}

.thread-search input::-webkit-search-cancel-button {
  display: none;
}

.search-clear {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: var(--dim);
}

.search-clear:hover {
  color: var(--text);
  background: var(--surface-3);
}

.search-clear svg {
  width: 10px;
  height: 10px;
}

.thread-filters {
  display: flex;
  gap: 4px;
  padding: 0 1px;
}

.chip {
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--dim);
  font-size: 11px;
  font-weight: 500;
  transition: all 0.12s;
  white-space: nowrap;
}

.chip:hover {
  color: var(--text-secondary);
  background: var(--surface-2);
}

.chip.active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border);
}

.threads-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 7px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.count-pill {
  font-size: 9px;
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--dim);
}

.threads-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.thread-group-label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--dim);
  padding: 10px 8px 4px;
}

.thread-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 6px 7px 6px 9px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.thread-item:hover {
  background: var(--surface);
  color: var(--text);
}

.thread-item.active {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.thread-item.dragging {
  opacity: 0.4;
}

.thread-item.drag-over {
  box-shadow: inset 0 2px 0 var(--accent);
}

.thread-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.thread-title {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-title span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-item.active .thread-title {
  font-weight: 500;
}

.thread-meta {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--dim);
  display: flex;
  align-items: center;
  gap: 5px;
}

.thread-meta .meta-dot {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: currentColor;
}

.thread-pin-badge {
  width: 11px;
  height: 11px;
  color: var(--accent);
  flex-shrink: 0;
}

.thread-private-badge {
  width: 10px;
  height: 10px;
  color: var(--dim);
  flex-shrink: 0;
}

.thread-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.1s;
}

.thread-item:hover .thread-actions,
.thread-item.active .thread-actions {
  opacity: 1;
}

.thread-action {
  width: 21px;
  height: 21px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  color: var(--dim);
}

.thread-action:hover {
  color: var(--text);
  background: var(--surface-3);
}

.thread-action.pinned {
  color: var(--accent);
}

.thread-action svg {
  width: 11px;
  height: 11px;
}

.empty-mini {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 22px 12px;
  color: var(--dim);
  font-size: 11.5px;
  text-align: center;
  line-height: 1.45;
}

.empty-mini svg {
  width: 20px;
  height: 20px;
  opacity: 0.6;
}

.sidebar-nav {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}

.nav-item:hover {
  background: var(--surface);
  color: var(--text);
}

.nav-item.active {
  color: var(--text);
  background: var(--accent-soft);
}

.nav-item.active svg {
  color: var(--accent);
}

.nav-item svg {
  width: 14px;
  height: 14px;
  color: var(--dim);
  flex-shrink: 0;
}

.nav-item span:nth-child(2) {
  flex: 1;
}

.nav-hint {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.nav-count {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 1px 5px;
}

.sidebar-foot {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 9px 10px;
  border-top: 1px solid var(--border);
}

.foot-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 11.5px;
}

.foot-btn:hover {
  color: var(--text);
  background: var(--surface);
}

.foot-btn svg {
  width: 13px;
  height: 13px;
}

.palette-shortcut {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 9px;
}

.palette-shortcut:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.palette-shortcut svg {
  width: 9px;
  height: 9px;
}

.sidebar-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 5;
}

.sidebar-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2px;
  width: 1px;
  background: transparent;
  transition: background 0.15s;
}

.sidebar-resizer:hover::after,
.sidebar-resizer.dragging::after {
  background: var(--accent);
}

/* ------------------------------------------------------------------
   Main / topbar
   ------------------------------------------------------------------ */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

.topbar {
  height: var(--topbar-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 12px 0 10px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 40;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.icon-btn {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  color: var(--muted);
  transition: background 0.12s, color 0.12s;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn svg {
  width: 15px;
  height: 15px;
}

.icon-btn.danger-hover:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.crumb {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 12.5px;
}

.view-name {
  color: var(--muted);
  flex-shrink: 0;
}

.crumb-sep {
  color: var(--dim);
  flex-shrink: 0;
}

.thread-title {
  min-width: 0;
  max-width: min(46vw, 520px);
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 2px;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
  background: color-mix(in srgb, var(--warning) 10%, transparent);
  color: color-mix(in srgb, var(--warning) 85%, var(--text));
  font-family: var(--font-mono);
  font-size: 9px;
  white-space: nowrap;
}

.privacy-badge svg {
  width: 10px;
  height: 10px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.topbar .text-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 11.5px;
  transition: color 0.12s, background 0.12s;
}

.topbar .text-action:hover {
  color: var(--text);
  background: var(--surface-2);
}

.topbar .text-action svg {
  width: 13px;
  height: 13px;
}

.topbar-search {
  display: none;
}

.online-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  margin-right: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.03em;
  color: var(--dim);
  text-transform: uppercase;
}

.online-status .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--success) 14%, transparent);
}

.online-status.offline .dot {
  background: var(--danger);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--danger) 14%, transparent);
}

.online-status.offline {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 25%, transparent);
}

.main:not([data-view="chat"]) .chat-only {
  display: none;
}

.shared-banner {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--text-secondary);
  font-size: 11.5px;
  z-index: 30;
}

.shared-banner-text {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.shared-banner-text svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
  flex-shrink: 0;
}

.shared-banner-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.workspace {
  flex: 1;
  min-height: 0;
  position: relative;
}

.view {
  display: none;
  height: 100%;
  width: 100%;
}

.view.active {
  display: flex;
}

.view-chat {
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.view-page {
  display: none;
  overflow-y: auto;
  overflow-x: hidden;
}

.view-page.active {
  display: block;
}


/* ==================================================================
   Part 2: chat, hero, messages, markdown, composer
   ================================================================== */

.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

.chat-inner {
  width: min(var(--chat-width), calc(100% - 40px));
  margin: 0 auto;
  padding: 30px 0 128px;
  display: flex;
  flex-direction: column;
  gap: 34px;
  min-height: 100%;
}

/* ------------------------------------------------------------------
   Empty state / hero
   ------------------------------------------------------------------ */

.empty-state {
  position: relative;
  margin: auto;
  width: 100%;
  max-width: 860px;
  padding: 34px 0 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
  animation: heroIn 0.5s var(--ease) both;
}

.hero-glow {
  position: absolute;
  top: -110px;
  left: 50%;
  width: min(760px, 90vw);
  height: 420px;
  transform: translateX(-50%);
  background:
    radial-gradient(ellipse at center, var(--hero-glow) 0%, transparent 68%),
    radial-gradient(ellipse at 35% 45%, color-mix(in srgb, var(--accent) 6%, transparent), transparent 60%);
  filter: blur(8px);
  pointer-events: none;
  z-index: -1;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 65%, transparent);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.02em;
  backdrop-filter: blur(8px);
}

.hero-badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 9px var(--accent);
  animation: pulseGlow 2.4s infinite ease-in-out;
}

.hero-title {
  max-width: 720px;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(38px, 5.6vw, 62px);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.045em;
  background: linear-gradient(180deg, var(--text) 18%, color-mix(in srgb, var(--text) 46%, var(--muted)) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  max-width: 600px;
  margin: -2px 0 2px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.62;
}

.hero-chips {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: -2px;
}

.hero-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 50%, transparent);
  color: var(--dim);
  font-size: 9.5px;
  white-space: nowrap;
}

.hero-chip svg {
  width: 10px;
  height: 10px;
  color: var(--muted);
}

.starter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  margin-top: 8px;
  text-align: left;
}

.starter-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 15px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--text) 2.5%, transparent), transparent 55%),
    var(--surface);
  text-align: left;
  overflow: hidden;
  transition: transform 0.16s var(--ease), border-color 0.16s, background 0.16s, box-shadow 0.16s;
}

.starter-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(420px circle at 15% 0%, var(--accent-soft), transparent 55%);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.starter-btn:hover {
  border-color: var(--accent-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.starter-btn:hover::before {
  opacity: 1;
}

.starter-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.starter-icon {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--accent);
}

.starter-icon svg {
  width: 13px;
  height: 13px;
}

.starter-arrow {
  color: var(--dim);
  transition: color 0.15s, transform 0.15s;
}

.starter-arrow svg {
  width: 14px;
  height: 14px;
}

.starter-btn:hover .starter-arrow {
  color: var(--accent);
  transform: translateX(2px);
}

.starter-btn strong {
  position: relative;
  z-index: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.starter-btn > span:not(.starter-top):not(.starter-tag) {
  position: relative;
  z-index: 1;
  font-size: 11.5px;
  line-height: 1.48;
  color: var(--dim);
}

.starter-tag {
  position: relative;
  z-index: 1;
  align-self: flex-start;
  margin-top: 6px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dim);
}

.hero-footnote {
  margin-top: 2px;
  color: var(--dim);
  font-size: 10px;
}

.hero-footnote kbd {
  font-size: 8px;
  padding: 2px 4px;
  vertical-align: 1px;
}

@keyframes heroIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------------
   Message turns
   ------------------------------------------------------------------ */

.turn-wrapper {
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: turnIn 0.24s var(--ease) both;
}

.turn-wrapper + .turn-wrapper {
  padding-top: 30px;
  border-top: 1px solid var(--border);
}

@keyframes turnIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-query-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.user-query-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.user-query-text {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(20px, 2.3vw, 25px);
  font-weight: 600;
  line-height: 1.32;
  letter-spacing: -0.024em;
  color: var(--text);
  overflow-wrap: anywhere;
}

.user-query-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 9px;
}

.user-query-meta .meta-dot {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: currentColor;
}

.edit-query-btn {
  opacity: 0;
  transition: opacity 0.12s;
}

.user-query-row:hover .edit-query-btn,
.edit-query-btn:focus-visible {
  opacity: 1;
}

.user-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.user-attachment {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 260px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
}

.user-attachment svg {
  width: 10px;
  height: 10px;
  color: var(--dim);
  flex-shrink: 0;
}

.user-attachment span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Feedback states */
.feedback-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  font-size: 10.5px;
}

.feedback-bar svg {
  width: 12px;
  height: 12px;
  color: var(--accent);
}

/* ------------------------------------------------------------------
   Sources
   ------------------------------------------------------------------ */

.sources-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sources-head {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sources-head svg {
  width: 11px;
  height: 11px;
  color: var(--muted);
}

.sources-count {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 8px;
  letter-spacing: 0;
}

.sources-toggle {
  margin-left: auto;
  color: var(--dim);
  font-family: var(--font-sans);
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
}

.sources-toggle:hover {
  color: var(--text);
}

.sources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 7px;
}

.source-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: border-color 0.14s, background 0.14s, transform 0.14s;
}

.source-card:hover {
  border-color: var(--accent-border);
  background: var(--surface-2);
  transform: translateY(-1px);
}

.source-top {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8.5px;
}

.source-index {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 8px;
  font-weight: 600;
}

.source-provider {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-domain {
  margin-left: auto;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 110px;
}

.source-title {
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.source-snippet {
  color: var(--dim);
  font-size: 10px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.source-card:hover .source-title {
  color: var(--text);
}

.sources-skeleton {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 7px;
}

.source-skeleton {
  height: 76px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 45%, var(--surface) 90%);
  background-size: 220% 100%;
  animation: shimmer 1.5s infinite linear;
}

.research-status {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9.5px;
}

.research-status .spinner {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -40% 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ------------------------------------------------------------------
   Thinking accordion
   ------------------------------------------------------------------ */

.think-accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.15s;
}

.think-accordion.open {
  border-color: var(--border-strong);
}

.think-accordion.active {
  border-color: var(--accent-border);
  background:
    linear-gradient(90deg, var(--accent-softer), transparent 45%),
    var(--surface);
}

.think-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 11px;
  cursor: pointer;
  user-select: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  transition: background 0.12s, color 0.12s;
}

.think-header:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 2.5%, transparent);
}

.think-title-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.think-title-left svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.think-pulse {
  width: 6px;
  height: 6px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulseGlow 1.4s infinite ease-in-out;
}

.think-count {
  color: var(--dim);
  font-size: 8.5px;
}

.think-arrow {
  width: 12px;
  height: 12px;
  color: var(--dim);
  flex-shrink: 0;
  transition: transform 0.2s var(--ease);
}

.think-accordion.open .think-arrow {
  transform: rotate(180deg);
}

.think-body {
  display: none;
  padding: 11px 13px;
  border-top: 1px solid var(--border);
  background: var(--code-bg);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  line-height: 1.68;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 300px;
  overflow-y: auto;
}

.think-accordion.open .think-body {
  display: block;
}

.think-body:empty::before {
  content: "Waiting for a reasoning trace…";
  color: var(--dim);
  font-style: italic;
}

@keyframes pulseGlow {
  0%, 100% { opacity: 0.45; transform: scale(0.92); }
  50% { opacity: 1; transform: scale(1.14); }
}

/* ------------------------------------------------------------------
   Markdown body
   ------------------------------------------------------------------ */

.answer-body,
.markdown-body {
  color: var(--text);
  font-size: var(--answer-size);
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.answer-body > *:first-child,
.markdown-body > *:first-child {
  margin-top: 0;
}

.answer-body > *:last-child,
.markdown-body > *:last-child {
  margin-bottom: 0;
}

.answer-body p,
.markdown-body p {
  margin: 0 0 12px;
}

.answer-body h1,
.answer-body h2,
.answer-body h3,
.answer-body h4,
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 24px 0 8px;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.28;
  letter-spacing: -0.026em;
  color: var(--text);
}

.answer-body h1,
.markdown-body h1 { font-size: 24px; }
.answer-body h2,
.markdown-body h2 { font-size: 19px; }
.answer-body h3,
.markdown-body h3 { font-size: 16px; }
.answer-body h4,
.markdown-body h4 { font-size: 14px; }

.answer-body h1 + *,
.answer-body h2 + *,
.answer-body h3 + *,
.markdown-body h1 + *,
.markdown-body h2 + *,
.markdown-body h3 + * {
  margin-top: 0;
}

.answer-body a,
.markdown-body a {
  color: var(--accent-text);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
  transition: border-color 0.12s, color 0.12s;
}

.answer-body a:hover,
.markdown-body a:hover {
  border-bottom-color: var(--accent);
}

.answer-body strong,
.markdown-body strong {
  color: var(--text);
  font-weight: 600;
}

.answer-body em,
.markdown-body em {
  color: var(--text-secondary);
}

.answer-body del,
.markdown-body del {
  color: var(--dim);
}

.answer-body ul,
.answer-body ol,
.markdown-body ul,
.markdown-body ol {
  margin: 0 0 12px;
  padding-left: 22px;
}

.answer-body li,
.markdown-body li {
  margin: 3px 0;
  padding-left: 2px;
}

.answer-body li::marker,
.markdown-body li::marker {
  color: var(--dim);
}

.answer-body li > ul,
.answer-body li > ol,
.markdown-body li > ul,
.markdown-body li > ol {
  margin: 4px 0 2px;
}

.answer-body blockquote,
.markdown-body blockquote {
  margin: 12px 0;
  padding: 3px 0 3px 14px;
  border-left: 2px solid var(--accent-border);
  color: var(--text-secondary);
  font-style: italic;
}

.answer-body blockquote p:last-child,
.markdown-body blockquote p:last-child {
  margin-bottom: 0;
}

.answer-body hr,
.markdown-body hr {
  margin: 18px 0;
  border: none;
  border-top: 1px solid var(--border);
}

.answer-body code,
.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.87em;
  padding: 2px 5px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  color: color-mix(in srgb, var(--text) 88%, var(--accent));
  overflow-wrap: anywhere;
}

.answer-body pre code,
.markdown-body pre code {
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
}

.table-wrap {
  margin: 14px 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.answer-body table,
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  line-height: 1.55;
}

.answer-body th,
.answer-body td,
.markdown-body th,
.markdown-body td {
  padding: 8px 11px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.answer-body th:last-child,
.answer-body td:last-child,
.markdown-body th:last-child,
.markdown-body td:last-child {
  border-right: none;
}

.answer-body tr:last-child td,
.markdown-body tr:last-child td {
  border-bottom: none;
}

.answer-body th,
.markdown-body th {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 11.5px;
}

.answer-body tbody tr:hover,
.markdown-body tbody tr:hover {
  background: color-mix(in srgb, var(--text) 2%, transparent);
}

/* Code blocks */
.code-block {
  margin: 14px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--code-bg);
  overflow: hidden;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 30px;
  padding: 0 10px 0 12px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--text) 2.5%, transparent);
}

.code-lang {
  font-family: var(--font-mono);
  font-size: 8.5px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.copy-code {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 4px;
  color: var(--dim);
  font-size: 9px;
  transition: color 0.12s, background 0.12s;
}

.copy-code:hover {
  color: var(--text);
  background: var(--surface-3);
}

.copy-code svg {
  width: 10px;
  height: 10px;
}

.code-block pre {
  margin: 0;
  padding: 13px 14px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--text-secondary);
  tab-size: 2;
}

.code-block pre code {
  font-family: inherit;
}

.tok-keyword { color: #c792ea; }
.tok-string { color: #a5d6a7; }
.tok-comment { color: #5d6778; font-style: italic; }
.tok-number { color: #f2b880; }
.tok-func { color: #82aaff; }

html[data-theme="light"] .tok-keyword { color: #7c3aed; }
html[data-theme="light"] .tok-string { color: #047857; }
html[data-theme="light"] .tok-comment { color: #94a3b8; }
html[data-theme="light"] .tok-number { color: #b45309; }
html[data-theme="light"] .tok-func { color: #1d4ed8; }

/* Citation pills */
.citation-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  margin: 0 1px;
  border: 1px solid var(--accent-border);
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 600;
  line-height: 1;
  vertical-align: 1px;
  text-decoration: none;
  border-bottom: 1px solid var(--accent-border);
  transition: background 0.12s;
}

a.citation-tag:hover {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  border-bottom-color: var(--accent);
}

/* Task lists */
.task-item {
  list-style: none;
  margin-left: -18px;
}

.task-box {
  display: inline-grid;
  place-items: center;
  width: 12px;
  height: 12px;
  margin-right: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  vertical-align: -1px;
  color: var(--accent);
}

.task-box svg {
  width: 9px;
  height: 9px;
}

.task-box.checked {
  background: var(--accent);
  border-color: var(--accent);
  color: #04060a;
}

.stream-caret {
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-left: 2px;
  border-radius: 1px;
  background: var(--accent);
  vertical-align: -2px;
  animation: caretBlink 1s steps(2, start) infinite;
}

@keyframes caretBlink {
  0%, 45% { opacity: 1; }
  46%, 100% { opacity: 0; }
}

/* Answer footer */
.answer-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.01em;
}

.answer-meta span {
  white-space: nowrap;
}

.answer-meta .meta-dot {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: currentColor;
}

.answer-error {
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  color: var(--danger);
  font-size: 12px;
  line-height: 1.55;
}

.answer-stopped {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--warning);
  font-family: var(--font-mono);
  font-size: 9px;
}

/* Related */
.related-box {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 4px;
}

.related-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.related-title svg {
  width: 11px;
  height: 11px;
}

.related-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.related-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  text-align: left;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.related-item:hover {
  border-color: var(--accent-border);
  background: var(--surface-2);
  color: var(--text);
}

.related-item svg {
  width: 12px;
  height: 12px;
  color: var(--dim);
  flex-shrink: 0;
}

/* Turn actions */
.turn-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding-top: 2px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--dim);
  font-size: 10.5px;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}

.action-btn:hover {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
}

.action-btn.active {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.action-btn svg {
  width: 12px;
  height: 12px;
}

.action-btn.icon-only {
  width: 26px;
  padding: 0;
  justify-content: center;
}

.action-divider {
  width: 1px;
  height: 13px;
  margin: 0 4px;
  background: var(--border);
}

.speaking-btn {
  color: var(--accent) !important;
}

/* Jump to latest */
.jump-latest {
  position: absolute;
  left: 50%;
  bottom: 132px;
  z-index: 15;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transform: translateX(-50%);
  padding: 6px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  color: var(--text-secondary);
  font-size: 10.5px;
  box-shadow: var(--shadow-md);
  animation: jumpIn 0.2s var(--ease) both;
}

.jump-latest:hover {
  color: var(--text);
  border-color: var(--accent-border);
}

.jump-latest svg {
  width: 12px;
  height: 12px;
}

@keyframes jumpIn {
  from { opacity: 0; transform: translate(-50%, 4px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ------------------------------------------------------------------
   Composer
   ------------------------------------------------------------------ */

.composer-wrap {
  position: relative;
  z-index: 25;
  flex-shrink: 0;
  padding: 0 20px 12px;
  background: linear-gradient(180deg, transparent 0%, var(--bg) 26%);
}

.composer {
  position: relative;
  width: min(var(--chat-width), 100%);
  margin: 0 auto;
  padding: 12px 13px 9px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--text) 2%, transparent), transparent 55%),
    var(--surface);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.composer:focus-within {
  border-color: var(--accent-border);
  box-shadow: 0 16px 52px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--accent-soft);
}

html[data-theme="light"] .composer {
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.05);
}

.composer-drop-overlay {
  position: absolute;
  inset: 5px;
  z-index: 10;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 1.5px dashed var(--accent);
  border-radius: calc(var(--radius-xl) - 5px);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(6px);
  color: var(--text-secondary);
  pointer-events: none;
}

.composer.drag-active .composer-drop-overlay {
  display: flex;
}

.composer-drop-overlay svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
  margin-bottom: 3px;
}

.composer-drop-overlay strong {
  font-size: 12px;
  font-weight: 600;
}

.composer-drop-overlay span {
  color: var(--dim);
  font-size: 10px;
}

.composer-notice {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: -2px 0 8px;
  padding: 5px 8px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--text-secondary);
  font-size: 10.5px;
}

.composer-notice svg {
  width: 12px;
  height: 12px;
  color: var(--accent);
  flex-shrink: 0;
}

.composer-notice span {
  flex: 1;
  min-width: 0;
}

.composer-notice button {
  color: var(--accent-text);
  font-size: 10px;
  font-weight: 600;
}

.composer-notice button:hover {
  text-decoration: underline;
}

.attachment-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 1px 0 8px;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 240px;
  padding: 3px 5px 3px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 9.5px;
}

.attachment-chip > svg {
  width: 10px;
  height: 10px;
  color: var(--dim);
  flex-shrink: 0;
}

.attachment-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-chip-size {
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8px;
}

.attachment-remove {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 3px;
  color: var(--dim);
  flex-shrink: 0;
}

.attachment-remove:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.attachment-remove svg {
  width: 9px;
  height: 9px;
}

.composer-textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  max-height: 190px;
  padding: 2px 2px 4px;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.55;
}

.composer-textarea::placeholder {
  color: var(--dim);
}

.composer-textarea:focus {
  outline: none;
}

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.composer-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
}

.composer-left .pro-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 9px;
  transition: all 0.12s;
}

.composer-left .pro-toggle svg {
  width: 10px;
  height: 10px;
}

.composer-left .pro-toggle:hover {
  color: var(--text-secondary);
  background: var(--surface-2);
}

.composer-left .pro-toggle.active {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.composer-icon {
  width: 26px;
  height: 26px;
}

.composer-icon svg {
  width: 13px;
  height: 13px;
}

.composer-icon.active {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

.composer-icon.recording {
  color: var(--danger);
  animation: micPulse 1.3s infinite ease-in-out;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 28%, transparent); }
  50% { box-shadow: 0 0 0 5px transparent; }
}

.composer-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.token-count {
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8.5px;
  white-space: nowrap;
}

.send-btn {
  width: 31px;
  height: 31px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #04060a;
  transition: transform 0.12s, background 0.12s, opacity 0.12s;
}

.send-btn svg {
  width: 14px;
  height: 14px;
}

.send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: scale(1.04);
}

.send-btn:disabled {
  background: var(--surface-3);
  color: var(--dim);
  opacity: 0.6;
}

.stop-btn {
  background: var(--danger);
  color: #fff;
}

.stop-btn:hover {
  background: var(--danger-strong);
}

.stop-btn svg {
  width: 13px;
  height: 13px;
}

.footnote {
  width: min(var(--chat-width), 100%);
  margin: 6px auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px;
  color: var(--dim);
  font-size: 9.5px;
  text-align: center;
}

.footnote-sep {
  opacity: 0.5;
}

.footnote button {
  color: var(--dim);
  font-size: 9.5px;
}

.footnote button:hover {
  color: var(--muted);
  text-decoration: underline;
}

.footnote-status {
  font-family: var(--font-mono);
  font-size: 8.5px !important;
}

/* ------------------------------------------------------------------
   Custom dropdown
   ------------------------------------------------------------------ */

.custom-dropdown {
  position: relative;
  display: inline-flex;
}

.dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  white-space: nowrap;
  transition: all 0.12s;
  user-select: none;
}

.dropdown-trigger > svg:first-child {
  width: 10px;
  height: 10px;
  color: var(--dim);
}

.dropdown-trigger:hover,
.custom-dropdown.open .dropdown-trigger {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.dropdown-trigger .chevron {
  width: 9px;
  height: 9px;
  color: var(--dim);
  transition: transform 0.18s var(--ease);
}

.custom-dropdown.open .dropdown-trigger .chevron {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 120;
  width: 330px;
  max-width: calc(100vw - 28px);
  max-height: 360px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 96%, var(--bg));
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, 0.02);
  opacity: 0;
  visibility: hidden;
  transform: translateY(5px) scale(0.99);
  transform-origin: bottom left;
  transition: opacity 0.14s, transform 0.14s var(--ease), visibility 0.14s;
}

.custom-dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.dropdown-menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px 6px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.dropdown-menu-note {
  color: var(--dim);
  font-size: 7.5px;
  letter-spacing: 0;
  text-transform: none;
  opacity: 0.8;
}

.dropdown-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 8px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-align: left;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.dropdown-option:hover {
  background: var(--surface-2);
  color: var(--text);
}

.dropdown-option.selected {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--text);
}

.dropdown-option-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.dropdown-option-title {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-option-sub {
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-option-badge {
  padding: 1px 4px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--dim);
  font-size: 7.5px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dropdown-check {
  width: 12px;
  height: 12px;
  color: var(--accent);
  opacity: 0;
  flex-shrink: 0;
}

.dropdown-option.selected .dropdown-check {
  opacity: 1;
}

.dropdown-divider {
  height: 1px;
  margin: 4px 5px;
  background: var(--border);
}


/* ==================================================================
   Part 3: page views, discover, library
   ================================================================== */

.view-page {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 2.5%, transparent), transparent 320px);
}

.page-inner {
  width: min(var(--page-max), 100%);
  margin: 0 auto;
  padding: 40px 32px 90px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.page-head-copy {
  min-width: 0;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.eyebrow.accent {
  color: var(--accent-text);
}

.page-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(32px, 4vw, 44px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.page-head p {
  max-width: 620px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

/* Buttons */
.primary-btn,
.ghost-btn,
.danger-btn,
.small-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.13s;
}

.primary-btn {
  background: var(--accent);
  color: #04060a;
  border-color: var(--accent);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 18%, transparent);
}

.primary-btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

html[data-theme="light"] .primary-btn {
  color: #fff;
}

.ghost-btn {
  background: var(--surface);
  color: var(--text-secondary);
  border-color: var(--border);
}

.ghost-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.danger-btn {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 28%, transparent);
}

.danger-btn:hover {
  background: color-mix(in srgb, var(--danger) 22%, var(--surface));
  border-color: var(--danger);
}

.primary-btn svg,
.ghost-btn svg,
.danger-btn svg {
  width: 13px;
  height: 13px;
}

.small-btn {
  height: 26px;
  padding: 0 9px;
  font-size: 10px;
}

.primary-btn.small,
.ghost-btn.small,
.danger-btn.small {
  height: 28px;
  padding: 0 10px;
  font-size: 10.5px;
}

.text-link {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.text-link:hover {
  color: var(--accent-text);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Toolbars */
.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.page-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(340px, 100%);
  height: 34px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.14s;
}

.page-search:focus-within {
  border-color: var(--accent-border);
}

.page-search svg {
  width: 13px;
  height: 13px;
  color: var(--dim);
  flex-shrink: 0;
}

.page-search input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 12px;
}

.page-search.compact {
  width: 100%;
  height: 31px;
  background: var(--input);
}

.chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.chips .chip {
  padding: 4px 10px;
  border-color: var(--border);
  background: transparent;
  color: var(--dim);
  font-size: 10.5px;
}

.chips .chip:hover {
  color: var(--text-secondary);
  background: var(--surface);
}

.chips .chip.active {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

/* ------------------------------------------------------------------
   Discover
   ------------------------------------------------------------------ */

.discover-feature {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 20px;
  min-height: 190px;
  margin-bottom: 26px;
  padding: 28px 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(120deg, color-mix(in srgb, var(--accent) 8%, transparent), transparent 50%),
    var(--surface);
  overflow: hidden;
}

.discover-feature::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 80% 20%, var(--accent-soft), transparent 45%);
  pointer-events: none;
}

.discover-feature-copy {
  position: relative;
  z-index: 1;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.discover-feature h2 {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: clamp(23px, 3vw, 31px);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.03em;
}

.discover-feature p {
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.58;
}

.discover-feature-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: auto;
}

.discover-feature-art {
  position: relative;
  width: 210px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.orbit {
  position: absolute;
  border: 1px solid var(--accent-border);
  border-radius: 50%;
  opacity: 0.55;
}

.orbit-1 {
  width: 150px;
  height: 150px;
  animation: orbitSpin 28s linear infinite;
}

.orbit-1::before {
  content: "";
  position: absolute;
  top: -3px;
  left: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.orbit-2 {
  width: 110px;
  height: 110px;
  opacity: 0.4;
  animation: orbitSpin 19s linear infinite reverse;
}

.orbit-2::before {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 25%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.orbit-3 {
  width: 66px;
  height: 66px;
  opacity: 0.3;
  animation: orbitSpin 13s linear infinite;
}

.orbit-core {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--accent) 80%, #fff), var(--accent) 55%, transparent 90%);
  box-shadow: 0 0 30px var(--accent), 0 0 70px color-mix(in srgb, var(--accent) 35%, transparent);
}

@keyframes orbitSpin {
  to { transform: rotate(360deg); }
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.prompt-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 16px 16px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color 0.16s, transform 0.16s var(--ease), background 0.16s, box-shadow 0.16s;
}

.prompt-card:hover {
  border-color: var(--accent-border);
  background: var(--surface-2);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.prompt-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card-badge.accent {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.card-icon {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  flex-shrink: 0;
}

.card-icon svg {
  width: 13px;
  height: 13px;
}

.prompt-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.32;
  letter-spacing: -0.015em;
  color: var(--text);
}

.prompt-card p {
  margin: 0;
  color: var(--dim);
  font-size: 11.5px;
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.prompt-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: auto;
  padding-top: 6px;
}

.prompt-card-actions .primary-btn,
.prompt-card-actions .ghost-btn {
  height: 27px;
  padding: 0 9px;
  font-size: 10px;
}

.prompt-card-actions .icon-btn {
  width: 27px;
  height: 27px;
}

.prompt-card-actions .spacer {
  flex: 1;
}

.prompt-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8px;
}

.empty-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 62px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--muted);
}

.empty-panel svg {
  width: 26px;
  height: 26px;
  color: var(--dim);
  margin-bottom: 4px;
}

.empty-panel h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-panel p {
  max-width: 380px;
  margin: 0;
  color: var(--dim);
  font-size: 11.5px;
  line-height: 1.55;
}

.empty-panel .primary-btn {
  margin-top: 10px;
}

.recent-section {
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title-row h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 9px;
}

.recent-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-align: left;
  transition: border-color 0.14s, background 0.14s;
}

.recent-card:hover {
  border-color: var(--accent-border);
  background: var(--surface-2);
}

.recent-card-title {
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8.5px;
}

/* ------------------------------------------------------------------
   Prompt library
   ------------------------------------------------------------------ */

.library-code {
  margin-top: 5px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input);
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 9.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ------------------------------------------------------------------
   Generic empty mini used in sidebar/notes
   ------------------------------------------------------------------ */

.empty-mini span {
  max-width: 190px;
}


/* ==================================================================
   Part 4: notes and insights
   ================================================================== */

/* ------------------------------------------------------------------
   Notes
   ------------------------------------------------------------------ */

#view-notes {
  overflow: hidden;
}

.notes-page {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-bottom: 28px;
}

.notes-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 12px;
}

.notes-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.notes-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 1px;
}

.note-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 9px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
}

.note-item:hover {
  background: var(--surface-2);
}

.note-item.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.note-item-title {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item.active .note-item-title {
  color: var(--text);
}

.note-item-title svg {
  width: 9px;
  height: 9px;
  color: var(--accent);
  flex-shrink: 0;
}

.note-item-excerpt {
  color: var(--dim);
  font-size: 10px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-item-date {
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7.5px;
  opacity: 0.8;
}

.note-editor {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.note-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 40px 20px;
  text-align: center;
}

.note-empty-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--dim);
}

.note-empty-mark svg {
  width: 20px;
  height: 20px;
}

.note-empty h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
}

.note-empty p {
  margin: 0 0 8px;
  color: var(--dim);
  font-size: 11.5px;
}

.note-editor-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 20px 8px;
}

.note-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.note-meta {
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-actions {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}

.note-actions .icon-btn {
  width: 27px;
  height: 27px;
}

.note-actions .icon-btn svg {
  width: 13px;
  height: 13px;
}

.note-actions .icon-btn[aria-pressed="true"] {
  color: var(--accent);
  background: var(--accent-soft);
}

.note-title-input {
  width: 100%;
  padding: 16px 0 6px;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-display);
  font-size: clamp(22px, 2.8vw, 30px);
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
}

.note-title-input::placeholder {
  color: var(--dim);
}

.note-body-input {
  flex: 1;
  width: 100%;
  min-height: 240px;
  padding: 8px 0 14px;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.72;
}

.note-preview {
  flex: 1;
  min-height: 0;
  padding: 10px 0 20px;
  overflow-y: auto;
  font-size: 13.5px;
}

.note-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 7px;
  border-top: 1px solid var(--border);
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8.5px;
}

.autosave-status {
  color: var(--dim);
}

.autosave-status.saved {
  color: var(--success);
}

.autosave-status.saving {
  color: var(--warning);
}

/* ------------------------------------------------------------------
   Insights
   ------------------------------------------------------------------ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 16px;
}

.stat-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 13px 13px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-border), transparent);
  opacity: 0.5;
}

.stat-label {
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.035em;
  color: var(--text);
}

.stat-sub {
  color: var(--dim);
  font-size: 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.insights-grid {
  display: grid;
  grid-template-columns: 1.45fr 0.85fr;
  gap: 12px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.panel-head p {
  margin: 2px 0 0;
  color: var(--dim);
  font-size: 9.5px;
}

.panel-badge {
  flex-shrink: 0;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
}

/* Activity chart */
.activity-chart {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 148px;
  padding-top: 8px;
  border-bottom: 1px solid var(--border);
}

.activity-bar-wrap {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.activity-bar {
  width: 100%;
  max-width: 26px;
  min-height: 3px;
  border-radius: 3px 3px 1px 1px;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 24%, transparent));
  opacity: 0.85;
  transition: opacity 0.12s, height 0.3s var(--ease);
}

.activity-bar-wrap:hover .activity-bar {
  opacity: 1;
}

.activity-bar.empty {
  height: 3px;
  background: var(--border-strong);
}

.activity-count {
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7.5px;
  line-height: 1;
  height: 9px;
  opacity: 0;
  transition: opacity 0.12s;
}

.activity-bar-wrap:hover .activity-count {
  opacity: 1;
}

.chart-axis {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7.5px;
  padding: 0 2px;
}

/* Streak */
.streak-value {
  font-family: var(--font-display);
  font-size: 58px;
  font-weight: 700;
  line-height: 0.95;
  letter-spacing: -0.05em;
  color: var(--accent);
  margin-top: 4px;
}

.streak-label {
  margin-top: -2px;
  color: var(--muted);
  font-size: 10.5px;
}

.streak-days {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: auto;
  padding-top: 12px;
}

.streak-day {
  flex: 1;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7.5px;
  text-transform: uppercase;
}

.streak-day.hit {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

/* Bar lists */
.bar-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) 2.2fr 28px;
  align-items: center;
  gap: 8px;
}

.bar-label {
  color: var(--text-secondary);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, transparent));
}

.bar-value {
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8px;
  text-align: right;
}

/* Storage */
.storage-meter {
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}

.storage-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 40%, transparent));
  transition: width 0.4s var(--ease);
}

.storage-meter.large {
  height: 8px;
}

.storage-rows {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.storage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8.5px;
}

.storage-row strong {
  color: var(--muted);
  font-weight: 400;
}

/* Timeline */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 0 0 12px;
}

.timeline-item[data-open-thread] {
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.timeline-item[data-open-thread]:hover {
  background: var(--surface-2, rgba(255, 255, 255, 0.035));
}

.timeline-item:last-child {
  padding-bottom: 0;
}

.timeline-rail {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 3px;
  align-self: stretch;
}

.timeline-dot {
  width: 5px;
  height: 5px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
}

.timeline-line {
  flex: 1;
  width: 1px;
  margin-top: 3px;
  background: var(--border);
}

.timeline-item:last-child .timeline-line {
  display: none;
}

.timeline-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.timeline-title {
  color: var(--text-secondary);
  font-size: 10.5px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.timeline-meta {
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7.5px;
}

@media (max-width: 1180px) {
  .stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .insights-grid {
    grid-template-columns: 1fr;
  }
  .notes-layout {
    grid-template-columns: 230px minmax(0, 1fr);
  }
  .discover-feature-art {
    width: 150px;
    opacity: 0.8;
  }
}

@media (max-width: 860px) {
  .page-inner {
    padding: 30px 18px 80px;
  }
  .notes-page {
    height: auto;
  }
  #view-notes {
    overflow-y: auto;
  }
  .notes-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }
  .notes-sidebar {
    max-height: 240px;
  }
  .note-editor {
    min-height: 520px;
  }
  .discover-feature {
    padding: 22px;
    min-height: 165px;
  }
  .discover-feature-art {
    display: none;
  }
  .stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .page-head {
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
  }
  .page-head .primary-btn {
    width: 100%;
  }
  .page-head h1 {
    font-size: 34px;
  }
  .card-grid {
    grid-template-columns: 1fr;
  }
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stat-value {
    font-size: 23px;
  }
  .page-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .page-search {
    width: 100%;
  }
  .chips {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .chips::-webkit-scrollbar {
    display: none;
  }
  .discover-feature {
    padding: 20px 18px;
  }
  .discover-feature-actions {
    flex-wrap: wrap;
  }
  .notes-page {
    padding-bottom: 40px;
  }
  .note-editor-body {
    padding: 0 14px 8px;
  }
}


/* ==================================================================
   Part 5: modals and settings
   ================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--backdrop);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: fadeBackdrop 0.16s ease both;
}

@keyframes fadeBackdrop {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: min(640px, 100%);
  max-height: min(88vh, 900px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: modalIn 0.2s var(--ease) both;
}

.modal-lg {
  width: min(940px, 100%);
}

.modal-sm {
  width: min(440px, 100%);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.988); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 19px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.028em;
}

.modal-head p {
  margin: 4px 0 0;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.5;
}

.modal-close {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 18px 20px 20px;
  overflow-y: auto;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input);
  color: var(--text);
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.13s;
}

.field textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
  font-family: var(--font-mono);
  font-size: 11.5px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent-border);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.modal-form .modal-actions {
  padding: 4px 0 0;
  border-top: none;
}

.confirm-mark {
  margin: 4px 20px 0;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 11%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
  color: var(--danger);
}

.confirm-mark svg {
  width: 19px;
  height: 19px;
}

#confirmModal .modal-actions {
  border-top: none;
  padding-top: 18px;
}

/* ------------------------------------------------------------------
   Settings
   ------------------------------------------------------------------ */

.settings-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
}

.settings-tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--text) 1.2%, transparent);
  overflow-y: auto;
}

.settings-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 11.5px;
  text-align: left;
  transition: all 0.12s;
}

.settings-tab svg {
  width: 13px;
  height: 13px;
  color: var(--dim);
  flex-shrink: 0;
}

.settings-tab:hover {
  color: var(--text);
  background: var(--surface-2);
}

.settings-tab.active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.settings-tab.active svg {
  color: var(--accent);
}

.settings-content {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px 26px;
}

.settings-panel {
  display: none;
  flex-direction: column;
  gap: 24px;
}

.settings-panel.active {
  display: flex;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.settings-group-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.settings-group-head p {
  margin: 2px 0 0;
  color: var(--dim);
  font-size: 10px;
  line-height: 1.5;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.theme-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-align: left;
  transition: border-color 0.13s, background 0.13s;
}

.theme-card:hover {
  border-color: var(--border-strong);
}

.theme-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}

.theme-preview {
  position: relative;
  height: 54px;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.theme-preview::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 17px;
  background: rgba(0, 0, 0, 0.14);
  border-right: 1px solid rgba(255, 255, 255, 0.07);
}

.theme-preview span {
  position: relative;
  display: block;
  width: 5px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.24);
}

.theme-preview span:nth-child(1) { height: 26px; }
.theme-preview span:nth-child(2) { height: 18px; width: 32px; }
.theme-preview span:nth-child(3) { height: 12px; width: 20px; }

.theme-elqorix { background: #000000; }
.theme-elqorix span:nth-child(2) { background: #1c1c1c; }
.theme-elqorix span:nth-child(3) { background: #ffffff; }

.theme-midnight { background: #050507; }
.theme-midnight span:nth-child(2) { background: #26344d; }
.theme-midnight span:nth-child(3) { background: #3b82f6; }

.theme-aurora { background: #070c1a; }
.theme-aurora span:nth-child(2) { background: #2a2250; }
.theme-aurora span:nth-child(3) { background: #a78bfa; }

.theme-graphite { background: #131416; }
.theme-graphite span:nth-child(2) { background: #2e3034; }
.theme-graphite span:nth-child(3) { background: #cbd5e1; }

.theme-ember { background: #17100b; }
.theme-ember span:nth-child(2) { background: #3d2a17; }
.theme-ember span:nth-child(3) { background: #fbbf24; }

.theme-light { background: #f4f5f8; border-color: rgba(0, 0, 0, 0.12); }
.theme-light::before { background: #e9ebf0; border-right-color: rgba(0, 0, 0, 0.08); }
.theme-light span:nth-child(1) { background: #cbd5e1; }
.theme-light span:nth-child(2) { background: #e2e8f0; }
.theme-light span:nth-child(3) { background: #3b82f6; }

.theme-card-label {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-secondary);
}

.theme-card small {
  color: var(--dim);
  font-size: 8.5px;
  line-height: 1.35;
}

.accent-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.accent-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--swatch);
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 2px var(--surface), 0 0 0 1px var(--border);
  transition: transform 0.12s, box-shadow 0.12s;
}

.accent-swatch:hover {
  transform: scale(1.08);
}

.accent-swatch.active {
  box-shadow: inset 0 0 0 2px var(--surface), 0 0 0 2px var(--accent);
  transform: scale(1.04);
}

.range-row {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 9px 0;
}

.range-row > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 10.5px;
}

.range-row output {
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 9px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) var(--range-progress, 50%), var(--surface-3) var(--range-progress, 50%));
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong);
  transition: transform 0.12s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.12);
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--text);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.setting-copy strong {
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 500;
}

.setting-copy small {
  color: var(--dim);
  font-size: 9px;
  line-height: 1.45;
}

.switch {
  position: relative;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  transition: background 0.15s, border-color 0.15s;
}

.switch span {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--dim);
  transition: transform 0.16s var(--ease), background 0.15s;
}

.switch[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
}

.switch[aria-checked="true"] span {
  transform: translateX(14px);
  background: #04060a;
}

.select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 10.5px;
}

.select-row:last-child {
  border-bottom: none;
}

.select-row select {
  min-width: 210px;
  max-width: 60%;
  padding: 6px 26px 6px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input);
  color: var(--text);
  font-size: 10.5px;
  outline: none;
}

.select-row select:focus {
  border-color: var(--accent-border);
}

.shortcut-grid {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 10.5px;
}

.shortcut-row span {
  flex: 1;
}

.shortcut-row:last-child {
  border-bottom: none;
}

.storage-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.storage-summary-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.storage-summary-copy strong {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
}

.storage-summary-copy span {
  color: var(--dim);
  font-size: 9px;
  line-height: 1.45;
}

.setting-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.danger-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 11px;
  border: 1px solid color-mix(in srgb, var(--danger) 18%, var(--border));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--danger) 3.5%, transparent);
}

.danger-row > div {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.danger-row strong {
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 500;
}

.danger-row small {
  color: var(--dim);
  font-size: 9px;
}

.about-hero {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(120deg, var(--accent-soft), transparent 60%), var(--surface-2);
}

.about-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
}

.about-mark svg {
  width: 21px;
  height: 21px;
}

.about-hero h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
}

.about-hero p {
  margin: 2px 0 0;
  color: var(--dim);
  font-size: 10px;
}

.info-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 10.5px;
}

.info-row:last-child {
  border-bottom: none;
}

.info-row span {
  color: var(--dim);
}

.info-row strong {
  color: var(--text-secondary);
  font-weight: 500;
}

.info-row strong.ok {
  color: var(--success);
}

.info-row strong.bad {
  color: var(--danger);
}

.about-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.about-note {
  margin: 0;
  color: var(--dim);
  font-size: 9.5px;
  line-height: 1.6;
  padding-top: 2px;
}

@media (max-width: 760px) {
  .modal-backdrop {
    padding: 10px;
  }
  .modal {
    max-height: 92vh;
    border-radius: var(--radius-lg);
  }
  .settings-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .settings-tabs {
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px;
    gap: 4px;
    scrollbar-width: none;
  }
  .settings-tabs::-webkit-scrollbar {
    display: none;
  }
  .settings-tab {
    width: auto;
    white-space: nowrap;
    padding: 7px 10px;
  }
  .settings-tab svg {
    display: none;
  }
  .settings-content {
    padding: 16px;
  }
  .theme-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .setting-row {
    gap: 10px;
  }
  .select-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }
  .select-row select {
    width: 100%;
    max-width: none;
  }
  .danger-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .shortcut-row {
    font-size: 10px;
  }
}


/* ==================================================================
   Part 6: palette, menus, toasts, responsive, utilities
   ================================================================== */

/* ------------------------------------------------------------------
   Command palette
   ------------------------------------------------------------------ */

.palette-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 11vh 16px 16px;
  background: var(--backdrop);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeBackdrop 0.14s ease both;
}

.palette {
  width: min(680px, 100%);
  max-height: min(72vh, 620px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface) 97%, var(--bg));
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: paletteIn 0.18s var(--ease) both;
}

@keyframes paletteIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.992); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.palette-input-row {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 15px;
  border-bottom: 1px solid var(--border);
}

.palette-input-row > svg {
  width: 15px;
  height: 15px;
  color: var(--dim);
  flex-shrink: 0;
}

.palette-input-row input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
}

.palette-input-row kbd {
  flex-shrink: 0;
}

.palette-results {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px;
}

.palette-group-label {
  padding: 8px 9px 4px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  text-align: left;
  color: var(--text-secondary);
  transition: background 0.08s, border-color 0.08s;
}

.palette-item:hover,
.palette-item.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--text);
}

.palette-item-icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
}

.palette-item.active .palette-item-icon {
  color: var(--accent);
  border-color: var(--accent-border);
}

.palette-item-icon svg {
  width: 12px;
  height: 12px;
}

.palette-item-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.palette-item-label {
  color: inherit;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.palette-item-sub {
  color: var(--dim);
  font-size: 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.palette-item kbd {
  flex-shrink: 0;
  font-size: 8px;
  padding: 2px 4px;
}

.palette-empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--dim);
  font-size: 11px;
}

.palette-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  color: var(--dim);
  font-size: 8.5px;
}

.palette-footer span {
  display: flex;
  align-items: center;
  gap: 3px;
}

.palette-footer kbd {
  font-size: 7.5px;
  padding: 2px 3px;
  min-width: 14px;
}

/* ------------------------------------------------------------------
   Context menu
   ------------------------------------------------------------------ */

.context-menu {
  position: fixed;
  z-index: 1300;
  min-width: 210px;
  max-width: 280px;
  padding: 5px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 97%, var(--bg));
  box-shadow: var(--shadow-lg);
  animation: menuIn 0.12s var(--ease) both;
}

@keyframes menuIn {
  from { opacity: 0; transform: translateY(-3px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 11px;
  text-align: left;
  transition: background 0.09s, color 0.09s;
}

.menu-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.menu-item.active {
  color: var(--accent-text);
  background: var(--accent-soft);
}

.menu-item svg {
  width: 12px;
  height: 12px;
  color: var(--dim);
  flex-shrink: 0;
}

.menu-item:hover svg {
  color: var(--muted);
}

.menu-item.danger {
  color: var(--danger);
}

.menu-item.danger svg {
  color: var(--danger);
}

.menu-item.danger:hover {
  background: color-mix(in srgb, var(--danger) 11%, transparent);
}

.menu-item .menu-shortcut {
  margin-left: auto;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 8px;
}

.menu-sep {
  height: 1px;
  margin: 4px 5px;
  background: var(--border);
}

.menu-label {
  padding: 5px 8px 3px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 7.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ------------------------------------------------------------------
   Toasts
   ------------------------------------------------------------------ */

.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1400;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--border-strong);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 97%, var(--bg));
  box-shadow: var(--shadow-md);
  color: var(--text-secondary);
  pointer-events: auto;
  animation: toastIn 0.24s var(--ease) both;
}

.toast.leaving {
  animation: toastOut 0.18s ease both;
}

.toast.success {
  border-left-color: var(--success);
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.warning {
  border-left-color: var(--warning);
}

.toast-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  margin-top: 1px;
}

.toast.success .toast-icon {
  background: color-mix(in srgb, var(--success) 12%, transparent);
  color: var(--success);
}

.toast.error .toast-icon {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}

.toast.warning .toast-icon {
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  color: var(--warning);
}

.toast-icon svg {
  width: 10px;
  height: 10px;
}

.toast-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.toast-title {
  color: var(--text);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.35;
}

.toast-message {
  color: var(--dim);
  font-size: 9.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.toast-close {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 3px;
  color: var(--dim);
}

.toast-close:hover {
  color: var(--text);
  background: var(--surface-3);
}

.toast-close svg {
  width: 9px;
  height: 9px;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(12px) scale(0.98); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(12px); }
}

/* ------------------------------------------------------------------
   Small shared bits
   ------------------------------------------------------------------ */

.loading-dots::after {
  content: "";
  display: inline-block;
  width: 14px;
  text-align: left;
  animation: dots 1.2s steps(4, end) infinite;
}

@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

.pulse-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulseGlow 1.4s infinite;
}

/* Focus outline for keyboard users only */
:focus:not(:focus-visible) {
  outline: none;
}

/* ------------------------------------------------------------------
   Responsive shell
   ------------------------------------------------------------------ */

@media (max-width: 1100px) {
  :root {
    --sidebar-width: 250px;
  }
  .page-inner {
    padding-left: 24px;
    padding-right: 24px;
  }
  .stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .topbar .text-action span {
    display: none;
  }
  .topbar .text-action {
    width: 30px;
    padding: 0;
    justify-content: center;
  }
  .topbar-search {
    display: grid;
  }
  .chat-inner {
    width: min(var(--chat-width), calc(100% - 32px));
  }
  .composer-wrap {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(86vw, 310px) !important;
    transform: translateX(-101%);
    box-shadow: var(--shadow-xl);
    border-right: 1px solid var(--border);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar.collapsed {
    width: min(86vw, 310px) !important;
    overflow: visible;
    border-right-color: var(--border);
  }
  .sidebar-resizer {
    display: none;
  }
  .online-status .label {
    display: none;
  }
  .online-status {
    padding: 3px 5px;
  }
  .insights-grid {
    grid-template-columns: 1fr;
  }
  .activity-panel {
    grid-column: auto;
  }
}

@media (max-width: 720px) {
  .topbar {
    padding-right: 7px;
  }
  .crumb {
    max-width: 52vw;
  }
  .thread-title {
    max-width: 40vw;
  }
  .online-status {
    display: none;
  }
  .starter-grid {
    grid-template-columns: 1fr;
  }
  .hero-title {
    font-size: clamp(34px, 9vw, 48px);
  }
  .hero-sub {
    font-size: 13px;
  }
  .hero-chips {
    gap: 4px;
  }
  .hero-chip {
    font-size: 8.5px;
  }
  .chat-inner {
    width: calc(100% - 24px);
    padding-top: 22px;
    gap: 26px;
  }
  .turn-wrapper + .turn-wrapper {
    padding-top: 22px;
  }
  .composer-wrap {
    padding: 0 10px 9px;
  }
  .composer {
    padding: 10px 11px 8px;
    border-radius: var(--radius-lg);
  }
  .composer-left .pro-toggle span {
    display: none;
  }
  .composer-left .pro-toggle {
    width: 24px;
    justify-content: center;
    padding: 0;
  }
  .composer-left .pro-toggle svg {
    width: 11px;
    height: 11px;
  }
  .dropdown-menu {
    width: 290px;
  }
  .user-query-text {
    font-size: 20px;
  }
  .sources-grid,
  .sources-skeleton {
    grid-template-columns: 1fr;
  }
  .sources-grid .source-card:nth-child(n+4) {
    display: none;
  }
  .sources-box.expanded .source-card:nth-child(n+4) {
    display: flex;
  }
  .footnote {
    font-size: 8.5px;
  }
  .footnote-status {
    display: none;
  }
  .jump-latest {
    bottom: 122px;
  }
  .page-inner {
    padding: 24px 14px 70px;
  }
  .modal-backdrop {
    padding: 8px;
  }
  .modal-head {
    padding: 16px 15px 13px;
  }
  .modal-form {
    padding: 14px 15px 16px;
  }
  .modal-actions {
    padding: 12px 15px;
  }
  .theme-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .insights-grid {
    gap: 10px;
  }
  .panel {
    padding: 14px;
  }
  .settings-content {
    padding: 14px;
  }
  .stat-grid {
    gap: 7px;
  }
  .stat-card {
    padding: 11px;
  }
  .stat-value {
    font-size: 22px;
  }
  .note-editor {
    min-height: 460px;
  }
  .note-title-input {
    font-size: 23px;
  }
  .toast-stack {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
  }
}

@media (max-width: 520px) {
  .topbar .chat-only {
    display: none;
  }
  .topbar-right {
    gap: 0;
  }
  .topbar {
    gap: 6px;
  }
  .crumb {
    max-width: 56vw;
  }
  .thread-title {
    max-width: 45vw;
  }
  .view-name {
    display: none;
  }
  .crumb-sep {
    display: none;
  }
  .privacy-badge span {
    display: none;
  }
  .composer-bar {
    gap: 4px;
  }
  .token-count {
    display: none;
  }
  .composer-left {
    gap: 2px;
  }
  .composer-left .pro-toggle {
    display: none;
  }
  .dropdown-trigger {
    max-width: 118px;
    overflow: hidden;
  }
  .dropdown-trigger #modeTriggerLabel {
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .dropdown-menu {
    width: min(300px, calc(100vw - 20px));
  }
  .hero-title {
    font-size: 34px;
  }
  .hero-badge {
    font-size: 8px;
  }
  .hero-chips {
    display: none;
  }
  .starter-btn {
    padding: 12px 13px;
  }
  .starter-btn > span:not(.starter-top):not(.starter-tag) {
    font-size: 10.5px;
  }
  .action-btn span {
    display: none;
  }
  .action-btn {
    width: 27px;
    justify-content: center;
    padding: 0;
  }
  .action-divider {
    margin: 0 2px;
  }
  .discover-feature-actions .primary-btn,
  .discover-feature-actions .ghost-btn {
    flex: 1;
  }
  .page-head h1 {
    font-size: 31px;
  }
  .theme-grid {
    grid-template-columns: 1fr;
  }
  .shortcut-row {
    font-size: 9.5px;
  }
  .shortcut-row kbd {
    font-size: 8px;
  }
  .settings-tab {
    padding: 6px 8px;
    font-size: 10px;
  }
  .setting-copy small {
    font-size: 8.5px;
  }
  .select-row {
    font-size: 10px;
  }
  .modal-head h2 {
    font-size: 17px;
  }
  .notes-sidebar {
    max-height: 210px;
  }
}

/* ------------------------------------------------------------------
   Reduced motion & print
   ------------------------------------------------------------------ */

html[data-reduce-motion="on"] *,
html[data-reduce-motion="on"] *::before,
html[data-reduce-motion="on"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

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

html[data-density="compact"] .chat-inner {
  gap: 24px;
  padding-top: 20px;
}

html[data-density="compact"] .turn-wrapper + .turn-wrapper {
  padding-top: 20px;
}

html[data-density="compact"] .turn-wrapper {
  gap: 11px;
}

html[data-density="compact"] .prompt-card {
  padding: 12px 13px;
}

html[data-density="compact"] .starter-btn {
  padding: 11px 13px;
}

html[data-density="compact"] .thread-item {
  min-height: 32px;
}

@media print {
  body {
    background: #fff;
    color: #111;
    overflow: visible;
  }
  .sidebar,
  .topbar,
  .composer-wrap,
  .jump-latest,
  .turn-actions,
  .hero-footnote,
  .sources-box,
  .related-box,
  .toast-stack,
  .modal-backdrop,
  .palette-backdrop,
  .context-menu {
    display: none !important;
  }
  .app,
  .main,
  .workspace,
  .view,
  .view-chat,
  .chat-scroll {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }
  .chat-inner {
    width: 100% !important;
    padding: 0 !important;
  }
  .answer-body {
    color: #111;
  }
  .turn-wrapper + .turn-wrapper {
    border-top-color: #ddd;
  }
  .think-accordion {
    border-color: #ddd;
  }
  .think-body {
    max-height: none;
    overflow: visible;
  }
}
