/* =================================================================
 * Simple (Codex Light inspired)
 * ================================================================= */
:root {
  color-scheme: light;
  font-family:
    ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  --bg: #fbfbf8;
  --text: #181713;
  --sidebar: #f0f0ec;
  --sidebar-start: #f3f3ef;
  --sidebar-end: #e8e8e2;
  --line: #dcddd6;
  --muted: #74746b;
  --soft: #f3f3ee;
  --card: #fffffb;
  --panel: #f6f6f1;
  --accent: #167c68;
  --button: #181713;
  --button-text: #ffffff;
  --nav-text: #26251f;
  --nav-muted: #68685f;
  --hover: rgba(0, 0, 0, 0.05);
  --field: rgba(255, 255, 251, 0.88);
  --entry: #181713;
  --avatar: #e6e7df;
  --avatar-text: #76776e;
  --code-bg: #ecede6;
  --code-text: #22221d;
  --quote: #c9cbc2;
  --link: #126d5d;
  --composer-bg: color-mix(in srgb, var(--card) 92%, transparent);
  --composer-border: #d5d8ce;
  --composer-shadow: 0 18px 54px rgba(31, 34, 26, 0.12);
  --scrim: rgba(0, 0, 0, 0.1);
  --warning-line: #f0b36b;
  --warning-bg: #fff8ed;
  --warning-text: #5b4632;
  --error: #c0392b;
  --state-ready: #168a5f;
  --state-running: #2e6fbb;
  --state-approval: #8f4c00;
  --state-interrupted: #6d5c00;
  --surface-under: #e6e7df;
  --surface-raised: #fffffb;
  --focus: #2d7ff9;
  --dock-width: 420px;
  --thread-width: 232px;
  --message-width: 1040px;
  --compact-radius: 8px;
  --control-height: 34px;
}

/* =================================================================
 * Cyberpunk — green terminal glow on near-black
 * ================================================================= */
:root[data-theme="cyberpunk"] {
  color-scheme: dark;
  font-family:
    "OCR A Std", "OCR A", "Andale Mono", "Share Tech Mono",
    "JetBrains Mono", "Cascadia Code", ui-monospace, "SFMono-Regular",
    Menlo, monospace;
  --bg: #020704;
  --text: #caffc8;
  --sidebar: #020704;
  --sidebar-start: rgba(2, 9, 5, 0.94);
  --sidebar-end: rgba(2, 6, 4, 0.96);
  --line: rgba(88, 255, 98, 0.2);
  --muted: #6ea878;
  --soft: rgba(82, 255, 92, 0.08);
  --card: rgba(3, 12, 7, 0.94);
  --panel: #030b07;
  --accent: #8dff74;
  --button: #62ff6b;
  --button-text: #021006;
  --nav-text: #b7ffb2;
  --nav-muted: #74aa77;
  --hover: rgba(98, 255, 107, 0.1);
  --field: rgba(2, 9, 5, 0.9);
  --entry: #caffc8;
  --avatar: rgba(98, 255, 107, 0.14);
  --avatar-text: #62ff6b;
  --code-bg: rgba(98, 255, 107, 0.1);
  --code-text: #dcffd8;
  --quote: rgba(98, 255, 107, 0.38);
  --link: #62ff6b;
  --composer-bg: rgba(2, 9, 5, 0.96);
  --composer-border: rgba(98, 255, 107, 0.3);
  --composer-shadow: 0 0 0 1px rgba(98, 255, 107, 0.12), 0 22px 52px rgba(15, 255, 53, 0.08);
  --scrim: rgba(0, 0, 0, 0.6);
  --warning-line: rgba(255, 221, 96, 0.5);
  --warning-bg: rgba(255, 221, 96, 0.08);
  --warning-text: #ffe97d;
  --error: #ff6f79;
  --state-ready: #62ff6b;
  --state-running: #62ff6b;
  --state-approval: #ffe97d;
  --state-interrupted: #ffe97d;
  --surface-under: #020704;
  --surface-raised: #05120a;
  --focus: #62ff6b;
  --glow-cyan: 0 0 8px rgba(98, 255, 107, 0.74), 0 0 22px rgba(98, 255, 107, 0.36);
  --glow-magenta: 0 0 8px rgba(141, 255, 116, 0.66), 0 0 22px rgba(141, 255, 116, 0.28);
}

/* =================================================================
 * Botanical — warm green / cream nature theme
 * ================================================================= */
:root[data-theme="botanical"] {
  color-scheme: light;
  font-family:
    ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  --bg: #faf9f0;
  --text: #1c2b1f;
  --sidebar: #eef2e6;
  --sidebar-start: #eef2e6;
  --sidebar-end: #eef2e6;
  --line: #d6dece;
  --muted: #647558;
  --soft: #edf3e5;
  --card: #fffef5;
  --panel: #f5f7ee;
  --accent: #2e7d4a;
  --button: #2e7d4a;
  --button-text: #fffef5;
  --nav-text: #1c2b1f;
  --nav-muted: #4d6040;
  --hover: rgba(46, 125, 74, 0.1);
  --field: rgba(255, 254, 245, 0.9);
  --entry: #1c2b1f;
  --avatar: #dce8d2;
  --avatar-text: #4d6040;
  --code-bg: #e4edd8;
  --code-text: #1c2b1f;
  --quote: #a4b896;
  --link: #2e7d4a;
  --composer-bg: rgba(255, 254, 245, 0.97);
  --composer-border: #c8d6bc;
  --composer-shadow: 0 12px 32px rgba(46, 100, 60, 0.1);
  --scrim: rgba(30, 60, 38, 0.15);
  --warning-line: #d4a24e;
  --warning-bg: #fef5de;
  --warning-text: #6b4c21;
  --error: #b14532;
  --state-ready: #2e7d4a;
  --state-running: #2f7aa0;
  --state-approval: #7a5216;
  --state-interrupted: #75601d;
}

/* =================================================================
 * Stigmata — extracted from the vending-machine title artwork
 * Palette: #010a14 / #121f31 / #3a455f / #8ba1c0 / #ab6872
 * ================================================================= */
:root[data-theme="stigmata"] {
  color-scheme: dark;
  font-family:
    "SF Pro Text", ui-sans-serif, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --bg: #01050b;
  --text: #edf4ff;
  --sidebar: rgba(1, 7, 15, 0.8);
  --sidebar-start: rgba(3, 10, 20, 0.9);
  --sidebar-end: rgba(7, 17, 30, 0.78);
  --line: rgba(139, 161, 192, 0.28);
  --muted: #8ba1c0;
  --soft: rgba(139, 161, 192, 0.13);
  --card: rgba(7, 13, 24, 0.78);
  --panel: rgba(4, 11, 22, 0.75);
  --accent: #a3c3e5;
  --button: #bed9f2;
  --button-text: #06101c;
  --nav-text: #dce9fa;
  --nav-muted: #8ba1c0;
  --hover: rgba(163, 195, 229, 0.12);
  --field: rgba(4, 10, 20, 0.78);
  --entry: #edf4ff;
  --avatar: rgba(163, 195, 229, 0.16);
  --avatar-text: #bed9f2;
  --code-bg: rgba(58, 69, 95, 0.48);
  --code-text: #dce9fa;
  --quote: rgba(190, 217, 242, 0.48);
  --link: #bed9f2;
  --composer-bg: rgba(5, 12, 23, 0.78);
  --composer-border: rgba(190, 217, 242, 0.38);
  --composer-shadow: 0 18px 52px rgba(0, 8, 18, 0.6), 0 0 0 1px rgba(190, 217, 242, 0.12);
  --scrim: rgba(0, 4, 10, 0.66);
  --warning-line: rgba(171, 104, 114, 0.66);
  --warning-bg: rgba(84, 45, 52, 0.24);
  --warning-text: #f1b9c2;
  --error: #f08d9a;
  --state-ready: #a3c3e5;
  --state-running: #84a9d5;
  --state-approval: #ab6872;
  --state-interrupted: #f1b9c2;
  --surface-under: #010a14;
  --surface-raised: #121f31;
  --focus: #bed9f2;
}

/* =================================================================
 * Global reset
 * ================================================================= */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

body::before {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--line) 36%, transparent) 1px, transparent 1px),
    linear-gradient(180deg, color-mix(in srgb, var(--line) 32%, transparent) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.32;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* --- Cyberpunk code-rain overlay (data-theme is on <html>) --- */
:root[data-theme="cyberpunk"] body::before {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 22% 18%, rgba(98, 255, 107, 0.12), transparent 28%),
    radial-gradient(circle at 78% 12%, rgba(141, 255, 116, 0.08), transparent 30%),
    repeating-linear-gradient(0deg, rgba(98, 255, 107, 0.05) 0 1px, transparent 1px 5px),
    linear-gradient(180deg, rgba(2, 7, 4, 0.82), rgba(2, 7, 4, 0.96));
  opacity: 1;
}

:root[data-theme="cyberpunk"] body::after {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: -40vh 0 0;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='640' viewBox='0 0 360 640'%3E%3Cstyle%3Etext%7Bfont-family:ui-monospace,Menlo,monospace;font-size:15px;font-weight:700;fill:%2362ff6b;fill-opacity:.42%7D%3C/style%3E%3Ctext x='16' y='24'%3E01%3C/text%3E%3Ctext x='16' y='62'%3E7F%3C/text%3E%3Ctext x='16' y='105'%3ESYS%3C/text%3E%3Ctext x='16' y='150'%3E10%3C/text%3E%3Ctext x='16' y='196'%3EA1%3C/text%3E%3Ctext x='16' y='250'%3EIO%3C/text%3E%3Ctext x='16' y='304'%3E00%3C/text%3E%3Ctext x='16' y='360'%3E3A%3C/text%3E%3Ctext x='16' y='414'%3ECLK%3C/text%3E%3Ctext x='16' y='468'%3E11%3C/text%3E%3Ctext x='16' y='522'%3ERUN%3C/text%3E%3Ctext x='16' y='580'%3E01%3C/text%3E%3Ctext x='82' y='10'%3E10%3C/text%3E%3Ctext x='82' y='54'%3EB8%3C/text%3E%3Ctext x='82' y='98'%3ENET%3C/text%3E%3Ctext x='82' y='142'%3E01%3C/text%3E%3Ctext x='82' y='188'%3EE2%3C/text%3E%3Ctext x='82' y='236'%3EBUS%3C/text%3E%3Ctext x='82' y='284'%3E11%3C/text%3E%3Ctext x='82' y='332'%3E72%3C/text%3E%3Ctext x='82' y='382'%3EIO%3C/text%3E%3Ctext x='82' y='436'%3E00%3C/text%3E%3Ctext x='82' y='492'%3EACK%3C/text%3E%3Ctext x='82' y='548'%3E10%3C/text%3E%3Ctext x='150' y='36'%3E11%3C/text%3E%3Ctext x='150' y='82'%3E0E%3C/text%3E%3Ctext x='150' y='128'%3E01%3C/text%3E%3Ctext x='150' y='174'%3E9C%3C/text%3E%3Ctext x='150' y='220'%3ESYS%3C/text%3E%3Ctext x='150' y='268'%3E10%3C/text%3E%3Ctext x='150' y='318'%3E5E%3C/text%3E%3Ctext x='150' y='368'%3EHEX%3C/text%3E%3Ctext x='150' y='420'%3E01%3C/text%3E%3Ctext x='150' y='472'%3E77%3C/text%3E%3Ctext x='150' y='526'%3EID%3C/text%3E%3Ctext x='150' y='584'%3E00%3C/text%3E%3Ctext x='224' y='18'%3E00%3C/text%3E%3Ctext x='224' y='66'%3EC1%3C/text%3E%3Ctext x='224' y='114'%3EACK%3C/text%3E%3Ctext x='224' y='162'%3E11%3C/text%3E%3Ctext x='224' y='210'%3E44%3C/text%3E%3Ctext x='224' y='258'%3E01%3C/text%3E%3Ctext x='224' y='306'%3E10%3C/text%3E%3Ctext x='224' y='354'%3EF4%3C/text%3E%3Ctext x='224' y='404'%3ENET%3C/text%3E%3Ctext x='224' y='456'%3E01%3C/text%3E%3Ctext x='224' y='510'%3E10%3C/text%3E%3Ctext x='224' y='568'%3EBUS%3C/text%3E%3Ctext x='300' y='42'%3E01%3C/text%3E%3Ctext x='300' y='92'%3E88%3C/text%3E%3Ctext x='300' y='142'%3ECLK%3C/text%3E%3Ctext x='300' y='192'%3EFE%3C/text%3E%3Ctext x='300' y='242'%3E13%3C/text%3E%3Ctext x='300' y='292'%3E11%3C/text%3E%3Ctext x='300' y='342'%3E90%3C/text%3E%3Ctext x='300' y='392'%3ERUN%3C/text%3E%3Ctext x='300' y='446'%3E00%3C/text%3E%3Ctext x='300' y='500'%3E6F%3C/text%3E%3Ctext x='300' y='558'%3E01%3C/text%3E%3C/svg%3E");
  background-size: 360px 640px;
  opacity: 0.34;
  animation: cyber-code-rain 18s linear infinite;
  mask-image: linear-gradient(90deg, transparent 0%, #000 10%, #000 90%, transparent 100%);
}

@keyframes cyber-code-rain {
  from {
    background-position: 0 -640px;
  }
  to {
    background-position: 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root[data-theme="cyberpunk"] body::after {
    animation: none;
    background-position: 0 -180px;
  }

  :root[data-theme="cyberpunk"] .workspace::before,
  :root[data-theme="cyberpunk"] h1,
  :root[data-theme="cyberpunk"] .send-button,
  :root[data-theme="cyberpunk"] .nav-command:hover,
  :root[data-theme="cyberpunk"] .theme-option:hover {
    animation: none;
  }
}

:root[data-theme="cyberpunk"] .workspace {
  position: relative;
  isolation: isolate;
  background:
    linear-gradient(180deg, rgba(5, 18, 10, 0.72), rgba(2, 7, 4, 0.36) 240px, rgba(2, 7, 4, 0.58)),
    rgba(2, 7, 4, 0.38);
}

:root[data-theme="cyberpunk"] .workspace::before {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, transparent 0 8%, rgba(98, 255, 107, 0.09) 8.5%, transparent 9.5% 22%, rgba(98, 255, 107, 0.06) 23%, transparent 24% 42%, rgba(98, 255, 107, 0.08) 43%, transparent 44% 63%, rgba(98, 255, 107, 0.05) 64%, transparent 65% 100%),
    repeating-linear-gradient(180deg, transparent 0 20px, rgba(98, 255, 107, 0.1) 21px, transparent 23px 44px);
  background-size: 260px 100%, 100% 88px;
  mix-blend-mode: screen;
  opacity: 0.2;
  animation: cyber-column-fall 9s linear infinite;
}

@keyframes cyber-column-fall {
  from {
    background-position: 0 -180px, 0 -88px;
  }
  to {
    background-position: 0 180px, 0 88px;
  }
}

/* --- Cyberpunk neon accents --- */
:root[data-theme="cyberpunk"] body {
  letter-spacing: 0.015em;
  text-shadow: 0 0 5px rgba(98, 255, 107, 0.2);
}

:root[data-theme="cyberpunk"] .send-button {
  box-shadow: var(--glow-cyan);
  animation: cyber-button-pulse 2.8s ease-in-out infinite;
}

:root[data-theme="cyberpunk"] .send-button:hover {
  box-shadow: var(--glow-cyan), 0 0 32px rgba(98, 255, 107, 0.46);
}

:root[data-theme="cyberpunk"] .nav-command#newThread {
  color: var(--button);
  border: 1px solid rgba(98, 255, 107, 0.34);
  background: rgba(98, 255, 107, 0.06);
}

:root[data-theme="cyberpunk"] .nav-command#newThread:hover {
  background: rgba(98, 255, 107, 0.12);
  box-shadow: 0 0 10px rgba(98, 255, 107, 0.24);
}

:root[data-theme="cyberpunk"] .thread-item.active {
  color: var(--button);
  background: rgba(98, 255, 107, 0.08);
  border-left: 2px solid var(--button);
  padding-left: 40px;
}

:root[data-theme="cyberpunk"] .composer {
  border-color: rgba(98, 255, 107, 0.24);
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

:root[data-theme="cyberpunk"] .composer:focus-within {
  border-color: rgba(98, 255, 107, 0.24);
  box-shadow: var(--composer-shadow);
}

:root[data-theme="cyberpunk"] textarea:focus {
  outline: 0;
}

:root[data-theme="cyberpunk"] .access-button {
  color: var(--accent);
  text-shadow: 0 0 8px rgba(141, 255, 116, 0.48);
}

:root[data-theme="cyberpunk"] .run-state[data-state="ready"],
:root[data-theme="cyberpunk"] .run-state[data-state="done"] {
  border-color: rgba(98, 255, 107, 0.38);
  color: var(--state-ready);
  text-shadow: 0 0 6px rgba(98, 255, 107, 0.6);
  background: rgba(98, 255, 107, 0.06);
}

:root[data-theme="cyberpunk"] .run-state[data-state="running"],
:root[data-theme="cyberpunk"] .run-state[data-state="streaming"],
:root[data-theme="cyberpunk"] .run-state[data-state="interrupting"],
:root[data-theme="cyberpunk"] .run-state[data-state="connecting"] {
  border-color: rgba(98, 255, 107, 0.38);
  color: var(--state-running);
  text-shadow: 0 0 6px rgba(98, 255, 107, 0.6);
  background: rgba(98, 255, 107, 0.06);
}

:root[data-theme="cyberpunk"] .icon-button:hover {
  border-color: rgba(98, 255, 107, 0.44);
  color: var(--button);
  box-shadow: 0 0 8px rgba(98, 255, 107, 0.24);
}

:root[data-theme="cyberpunk"] h1 {
  color: var(--button);
  text-shadow:
    0 0 12px rgba(98, 255, 107, 0.42),
    1px 0 0 rgba(202, 255, 200, 0.22),
    -1px 0 0 rgba(76, 255, 91, 0.18);
  animation: cyber-text-glitch 6.5s steps(1, end) infinite;
}

:root[data-theme="cyberpunk"] .nav-command,
:root[data-theme="cyberpunk"] .thread-item,
:root[data-theme="cyberpunk"] .model-button,
:root[data-theme="cyberpunk"] .access-button,
:root[data-theme="cyberpunk"] .run-state {
  font-family:
    "OCR A Std", "OCR A", "Andale Mono", "Share Tech Mono",
    "JetBrains Mono", "Cascadia Code", ui-monospace, monospace;
}

:root[data-theme="cyberpunk"] .nav-command:hover,
:root[data-theme="cyberpunk"] .theme-option:hover {
  animation: cyber-text-glitch 1.6s steps(1, end) 1;
}

@keyframes cyber-text-glitch {
  0%,
  86%,
  100% {
    transform: translateX(0);
    filter: none;
  }
  88% {
    transform: translateX(-1px);
    filter: hue-rotate(16deg) saturate(1.35);
  }
  90% {
    transform: translateX(1px);
    text-shadow:
      2px 0 0 rgba(202, 255, 200, 0.5),
      -2px 0 0 rgba(72, 255, 91, 0.38),
      0 0 14px rgba(98, 255, 107, 0.72);
  }
  92% {
    transform: translateX(0);
    filter: contrast(1.25);
  }
}

@keyframes cyber-button-pulse {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.18);
  }
}

:root[data-theme="cyberpunk"] .entry-body a {
  text-shadow: 0 0 8px rgba(98, 255, 107, 0.4);
}

:root[data-theme="cyberpunk"] .entry-body code {
  color: var(--accent);
  background: rgba(98, 255, 107, 0.1);
  text-shadow: 0 0 6px rgba(98, 255, 107, 0.36);
}

:root[data-theme="cyberpunk"] .sidebar {
  border-right-color: rgba(98, 255, 107, 0.16);
}

:root[data-theme="stigmata"] body::before {
  background:
    linear-gradient(90deg, rgba(1, 5, 11, 0.9), rgba(1, 5, 11, 0.34) 44%, rgba(1, 5, 11, 0.78)),
    linear-gradient(180deg, rgba(1, 5, 11, 0.18), rgba(1, 5, 11, 0.82)),
    url("/assets/vending-machine-stigmata-theme.png") center center / cover no-repeat;
  opacity: 1;
}

:root[data-theme="stigmata"] .workspace {
  background:
    linear-gradient(90deg, rgba(1, 5, 11, 0.72), rgba(1, 5, 11, 0.18) 46%, rgba(1, 5, 11, 0.62)),
    linear-gradient(180deg, rgba(1, 5, 11, 0.52), rgba(1, 5, 11, 0.74) 62%, rgba(1, 5, 11, 0.9)),
    url("/assets/vending-machine-stigmata-theme.png") center center / cover no-repeat,
    #01050b;
}

:root[data-theme="stigmata"] .sidebar,
:root[data-theme="stigmata"] .titlebar,
:root[data-theme="stigmata"] .panel-card,
:root[data-theme="stigmata"] .composer {
  backdrop-filter: blur(18px) saturate(1.22);
}

:root[data-theme="stigmata"] .panel-card,
:root[data-theme="stigmata"] .composer,
:root[data-theme="stigmata"] .run-state {
  box-shadow:
    0 22px 52px rgba(0, 5, 13, 0.54),
    inset 0 1px 0 rgba(237, 244, 255, 0.08);
}

:root[data-theme="stigmata"] .nav-command#newThread .command-icon,
:root[data-theme="stigmata"] .send-button {
  box-shadow: 0 0 24px rgba(190, 217, 242, 0.22);
}

:root[data-theme="stigmata"] .theme-option.active,
:root[data-theme="stigmata"] .artifact-row.active,
:root[data-theme="stigmata"] .panel-tab.active {
  border-color: rgba(190, 217, 242, 0.68);
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--thread-width) 6px minmax(0, 1fr);
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

.sidebar-scrim {
  display: none;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  padding: 8px 10px 10px;
  background: linear-gradient(180deg, var(--sidebar-start) 0%, var(--sidebar-end) 100%);
  border-right: 1px solid var(--line);
}

.sidebar-resize-handle {
  position: relative;
  z-index: 4;
  display: grid;
  place-items: center;
  min-width: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: col-resize;
  touch-action: none;
}

.sidebar-resize-handle::before {
  content: "";
  width: 2px;
  height: 42px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 70%, transparent);
  opacity: 0;
  transition: opacity 140ms ease, background 140ms ease;
}

.sidebar-resize-handle:hover::before,
.sidebar-resize-handle:focus-visible::before,
body.resizing-sidebar .sidebar-resize-handle::before {
  background: var(--accent);
  opacity: 1;
}

.sidebar-windowbar {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 0 2px;
  color: var(--muted);
}

.window-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
}

.window-dot.red {
  background: #ff5f57;
}

.window-dot.yellow {
  background: #ffbd2e;
}

.window-dot.green {
  background: #28c840;
}

.window-spacer {
  flex: 1 1 auto;
}

.primary-nav {
  display: grid;
  gap: 3px;
}

.nav-command,
.settings {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: var(--control-height);
  border: 0;
  border-radius: var(--compact-radius);
  padding: 0 9px;
  background: transparent;
  color: var(--nav-text);
  font-size: 14px;
  font-weight: 450;
  text-align: left;
}

.nav-command span:last-child,
.settings span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
}

#newThread .command-icon {
  background: var(--button);
  color: var(--button-text);
  font-weight: 700;
}

.nav-command:hover,
.settings:hover {
  background: var(--hover);
}

.nav-command:hover .command-icon,
.settings:hover .command-icon {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--accent);
}

.nav-command.muted {
  color: var(--nav-muted);
}

.thread-section {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.section-title {
  padding: 8px 10px 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 680;
  letter-spacing: 0;
  text-transform: uppercase;
}

.thread-search {
  width: calc(100% - 8px);
  min-height: 34px;
  margin: 0 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--compact-radius);
  padding: 0 10px;
  background: var(--field);
  color: var(--text);
  font-size: 16px;
  outline: 0;
}

.thread-list {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.project-group {
  margin: 12px 0 18px;
}

.project-heading {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-size: 14px;
  font-weight: 450;
}

.project-heading > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.project-heading:hover,
button.project-heading.active {
  background: var(--hover);
  color: var(--text);
}

.project-icon-slot {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
}

.project-icon {
  display: block;
  width: 16px;
  height: 16px;
  color: currentColor;
}

.thread-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 8px;
  padding: 0 10px 0 42px;
  background: transparent;
  font-size: 13px;
  color: var(--nav-muted);
  text-align: left;
}

.thread-item:hover,
.thread-item.active {
  background: var(--hover);
}

.thread-item.active {
  color: var(--text);
  font-weight: 560;
}

.thread-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
}

.project-empty,
.project-more {
  padding: 4px 10px 4px 42px;
  color: color-mix(in srgb, var(--muted) 62%, transparent);
  font-size: 13px;
}

.project-more {
  color: var(--muted);
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 6px;
}

.project-more:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--muted) 14%, transparent);
}

.settings {
  color: var(--nav-text);
  align-self: end;
}

.workspace {
  display: grid;
  grid-template-rows: 38px minmax(0, 1fr);
  height: 100vh;
  height: 100svh;
  min-height: 0;
  min-width: 0;
  max-width: 100vw;
  overflow: hidden;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface-raised) 58%, transparent), transparent 140px),
    var(--bg);
}

.titlebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 70%, transparent);
  backdrop-filter: blur(12px);
}

.titlebar {
  padding: 0 12px;
}

.mobile-toggle {
  display: none;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--compact-radius);
  background: var(--card);
  color: var(--nav-text);
}

.title-stack {
  min-width: 0;
}

h1 {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  line-height: 18px;
}

p {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

#meta {
  display: none;
}

.title-actions {
  display: flex;
  justify-self: end;
  gap: 6px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--compact-radius);
  background: var(--card);
  color: var(--muted);
}

.icon-button svg,
.command-icon svg,
.ghost-button svg,
.thinking-button svg,
.voice-button svg,
.send-button svg,
.panel-close svg,
.artifact-row svg,
.terminal-row svg,
.source-row svg {
  display: block;
  flex: 0 0 auto;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, clamp(280px, var(--dock-width), 62vw));
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

body.hide-artifacts .content-grid {
  grid-template-columns: minmax(0, 1fr);
}

body.hide-artifacts .artifact-panel {
  display: none;
}

.conversation {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.conversation::before,
.conversation::after {
  content: "";
  pointer-events: none;
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
}

.conversation::before {
  top: 0;
  height: 20px;
  background: linear-gradient(180deg, var(--bg), transparent);
}

.conversation::after {
  bottom: 0;
  height: 96px;
  background: linear-gradient(0deg, var(--bg) 4%, color-mix(in srgb, var(--bg) 86%, transparent) 58%, transparent);
}

.log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px clamp(18px, 6vw, 96px) 20px;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.empty-thread {
  display: grid;
  place-items: center;
  min-height: 38vh;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  width: min(var(--message-width), 100%);
  max-width: var(--message-width);
  margin: 0 auto 22px;
  color: var(--entry);
}

.entry-avatar {
  display: none;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--avatar);
  color: var(--avatar-text);
  font-size: 11px;
  font-weight: 650;
}

.entry.user .entry-avatar {
  background: var(--button);
  color: var(--button-text);
}

.entry.user .entry-body {
  max-width: min(520px, 76%);
  margin-left: auto;
  border: 0;
  border-radius: 14px;
  padding: 11px 15px;
  background: color-mix(in srgb, var(--soft) 82%, var(--card));
}

.entry-body {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.58;
}

.entry.assistant .entry-body,
.entry.error .entry-body {
  max-width: var(--message-width);
}

.entry-body p,
.entry-body ul,
.entry-body ol,
.entry-body blockquote,
.entry-body pre {
  margin: 0 0 14px;
}

.entry-body p,
.artifact-preview p {
  overflow: visible;
  white-space: normal;
  color: inherit;
  font-size: inherit;
}

.entry-body p:last-child,
.entry-body ul:last-child,
.entry-body ol:last-child,
.entry-body blockquote:last-child,
.entry-body pre:last-child {
  margin-bottom: 0;
}

.entry-body ul,
.entry-body ol {
  padding-left: 1.45em;
}

.entry-body li {
  margin: 3px 0;
  padding-left: 0.12em;
}

.entry-body h2,
.entry-body h3,
.entry-body h4,
.entry-body h5 {
  margin: 0 0 10px;
  font-size: 1em;
  line-height: 1.42;
}

.entry-body code {
  border-radius: 6px;
  padding: 0.12em 0.36em;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.91em;
}

.entry-body pre {
  max-width: 100%;
  overflow-x: auto;
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--code-bg);
  color: var(--code-text);
  white-space: pre;
}

.entry-body pre code {
  padding: 0;
  background: transparent;
  font-size: 0.9em;
}

.entry-body blockquote {
  border-left: 3px solid var(--quote);
  padding-left: 12px;
  color: var(--muted);
}

.entry-body a {
  color: var(--link);
  text-decoration: none;
}

.entry-body a:hover {
  text-decoration: underline;
}

.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 210px));
  gap: 10px;
  margin-top: 12px;
}

.image-preview {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
}

.image-preview img {
  display: block;
  width: 100%;
  max-height: 210px;
  object-fit: contain;
  background: var(--soft);
}

.markdown-image {
  display: block;
  max-width: min(100%, 320px);
  margin: 10px 0 14px;
}

.image-preview figcaption {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 7px 9px;
  color: var(--muted);
  font-size: 12px;
}

.entry.status .entry-body {
  color: var(--muted);
  white-space: pre-wrap;
}

.entry.status.status-group {
  max-width: var(--message-width);
  grid-template-columns: minmax(0, 1fr);
  margin-bottom: 20px;
}

.status-details {
  min-width: 0;
  color: var(--muted);
}

.status-details summary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  min-height: 31px;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.status-details summary::-webkit-details-marker {
  display: none;
}

.status-details summary::after {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.6px solid currentColor;
  border-bottom: 1.6px solid currentColor;
  color: var(--muted);
  transform: translateY(-1px) rotate(45deg);
  transition: transform 160ms ease;
}

.status-details summary::before {
  content: "›";
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--soft);
  color: var(--muted);
  font-size: 15px;
}

.status-details[open] summary::after {
  transform: rotate(180deg);
}

.status-summary-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.status-count {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 2px 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
}

.status-list {
  margin: 8px 0 0;
  padding: 0 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.status-list li {
  padding-left: 4px;
}

.entry.error .entry-body {
  color: var(--error);
  white-space: pre-wrap;
}

.entry-tools {
  min-width: 28px;
  color: var(--muted);
  font-size: 12px;
  opacity: 0;
  transition: opacity 140ms ease;
}

.entry-tool-button {
  position: relative;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.entry-tool-button::before,
.entry-tool-button::after {
  content: "";
  position: absolute;
  width: 11px;
  height: 11px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
}

.entry-tool-button::before {
  left: 7px;
  top: 6px;
}

.entry-tool-button::after {
  left: 10px;
  top: 9px;
  background: var(--bg);
}

.entry-tool-button:hover {
  background: var(--hover);
  color: var(--nav-text);
}

.entry:hover .entry-tools,
.entry:focus-within .entry-tools {
  opacity: 1;
}

.review-digest-entry {
  max-width: var(--message-width);
}

.review-digest-entry .entry-body {
  width: 100%;
}

.review-digest {
  display: grid;
  gap: 12px;
}

.review-reference-toggle {
  color: var(--muted);
  font-size: 13px;
}

.review-reference-toggle summary {
  cursor: pointer;
}

.artifact-card-list {
  display: grid;
  gap: 10px;
}

.chat-artifact-card {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--card) 96%, transparent);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--text) 8%, transparent);
}

.chat-artifact-card:hover {
  border-color: color-mix(in srgb, var(--accent) 54%, var(--line));
  background: var(--soft);
}

.chat-artifact-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: var(--soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
}

.chat-artifact-copy {
  min-width: 0;
}

.chat-artifact-copy strong,
.chat-artifact-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-artifact-copy strong {
  font-size: 15px;
  font-weight: 650;
}

.chat-artifact-copy small {
  color: var(--muted);
  font-size: 13px;
}

.chat-artifact-open {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  background: var(--card);
  color: var(--text);
  font-size: 13px;
}

.diff-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--card) 94%, transparent);
}

.diff-card-header,
.diff-file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  padding: 10px 14px;
}

.diff-card-header {
  border-bottom: 1px solid var(--line);
}

.diff-card-header > span,
.diff-file-stat,
.row-diff-stat {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  white-space: nowrap;
}

.diff-file-row {
  grid-template-columns: minmax(0, 1fr) auto 18px;
  width: 100%;
  border: 0;
  border-top: 1px solid color-mix(in srgb, var(--line) 64%, transparent);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.diff-file-row:first-child {
  border-top: 0;
}

.diff-file-row:hover {
  background: var(--soft);
}

.diff-file-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diff-file-chevron {
  color: var(--muted);
  text-align: right;
}

.diff-add {
  color: #06a33b;
}

.diff-del {
  color: #d62424;
}

.approval {
  position: relative;
  z-index: 8;
  align-self: center;
  width: min(var(--message-width), calc(100% - 40px));
  margin: 0 0 10px;
  padding: 14px;
  border: 1px solid var(--warning-line);
  border-radius: var(--compact-radius);
  background: var(--warning-bg);
}

.approval pre {
  max-height: 160px;
  overflow: auto;
  margin: 8px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--warning-text);
  font-size: 12px;
}

.run-state {
  position: relative;
  z-index: 8;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: min(var(--message-width), calc(100% - 40px));
  min-height: 28px;
  margin: 0 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.run-state-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
}

.run-state[data-state="ready"],
.run-state[data-state="done"] {
  border-color: color-mix(in srgb, var(--state-ready) 28%, var(--line));
  color: var(--state-ready);
  background: color-mix(in srgb, var(--state-ready) 7%, var(--card));
}

.run-state[data-state="running"],
.run-state[data-state="streaming"],
.run-state[data-state="interrupting"],
.run-state[data-state="syncing"],
.run-state[data-state="connecting"] {
  border-color: color-mix(in srgb, var(--state-running) 30%, var(--line));
  color: var(--state-running);
  background: color-mix(in srgb, var(--state-running) 7%, var(--card));
}

.run-state[data-state="approval"] {
  border-color: color-mix(in srgb, var(--state-approval) 34%, var(--line));
  color: var(--state-approval);
  background: color-mix(in srgb, var(--state-approval) 9%, var(--card));
}

.run-state[data-state="interrupted"] {
  border-color: color-mix(in srgb, var(--state-interrupted) 34%, var(--line));
  color: var(--state-interrupted);
  background: color-mix(in srgb, var(--state-interrupted) 8%, var(--card));
}

.run-state[data-state="error"],
.run-state[data-state="disconnected"] {
  border-color: color-mix(in srgb, var(--error) 34%, var(--line));
  color: var(--error);
  background: color-mix(in srgb, var(--error) 7%, var(--card));
}

.run-state[data-state="running"] .run-state-dot,
.run-state[data-state="streaming"] .run-state-dot,
.run-state[data-state="interrupting"] .run-state-dot,
.run-state[data-state="syncing"] .run-state-dot,
.run-state[data-state="connecting"] .run-state-dot {
  animation: run-state-pulse 980ms ease-in-out infinite;
}

@keyframes run-state-pulse {
  0%,
  100% {
    transform: scale(0.8);
    opacity: 0.45;
  }

  50% {
    transform: scale(1.25);
    opacity: 1;
  }
}

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

  .run-state-dot {
    animation: none !important;
  }
}

.hidden {
  display: none;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

.actions button {
  min-height: 36px;
  border: 1px solid var(--button);
  border-radius: 9px;
  padding: 0 14px;
  background: var(--button);
  color: var(--button-text);
}

.actions .secondary {
  border-color: var(--line);
  background: var(--card);
  color: var(--text);
}

.composer-stack {
  position: sticky;
  z-index: 9;
  bottom: max(14px, env(safe-area-inset-bottom));
  align-self: center;
  flex: 0 0 auto;
  width: min(var(--message-width), calc(100% - 40px));
  max-width: 100%;
  margin: 0 0 max(14px, env(safe-area-inset-bottom));
}

.composer {
  position: relative;
  width: 100%;
  min-height: 70px;
  margin: 0 0 6px;
  border: 1px solid var(--composer-border);
  border-radius: 14px;
  background: var(--composer-bg);
  box-shadow: var(--composer-shadow);
  backdrop-filter: blur(18px);
  overflow: visible;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.composer:focus-within {
  border-color: var(--composer-border);
  box-shadow: var(--composer-shadow);
}

.composer::before {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 72%, transparent);
}

.slash-skill-menu {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(100% + 8px);
  z-index: 20;
  display: grid;
  gap: 4px;
  max-height: min(320px, 52vh);
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 16px 38px rgba(18, 20, 22, 0.16);
}

.slash-skill-menu.hidden {
  display: none;
}

.slash-skill-row {
  display: grid;
  grid-template-columns: minmax(72px, auto) 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.slash-skill-row[aria-selected="true"],
.slash-skill-row:hover {
  background: var(--soft);
}

.slash-skill-command {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  color: var(--accent-strong);
}

.slash-skill-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.slash-skill-copy strong,
.slash-skill-copy small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slash-skill-copy small,
.slash-skill-empty {
  color: var(--muted);
  font-size: 12px;
}

.slash-skill-empty {
  padding: 10px 12px;
}

.attachments {
  display: none;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 14px 0;
}

.attachments.has-attachments {
  display: flex;
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 240px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 10px 4px 5px;
  background: var(--soft);
  color: var(--nav-muted);
  overflow: hidden;
}

.attachment-chip img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--soft);
}

.attachment-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

textarea {
  width: 100%;
  height: 30px;
  min-height: 30px;
  max-height: 180px;
  resize: vertical;
  border: 0;
  padding: 7px 18px 0;
  background: transparent;
  color: inherit;
  outline: 0;
  font-size: 14px;
  line-height: 1.45;
}

textarea:focus,
textarea:focus-visible {
  outline: 0;
  outline-offset: 0;
}

textarea::placeholder {
  color: color-mix(in srgb, var(--muted) 78%, transparent);
}

body.prompt-modal-open {
  overflow: hidden;
}

.prompt-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--scrim) 72%, transparent);
}

.prompt-modal.hidden {
  display: none;
}

.prompt-modal-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(900px, 100%);
  height: min(760px, 100%);
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 24px 70px color-mix(in srgb, var(--text) 18%, transparent);
  overflow: hidden;
}

.prompt-modal-header,
.prompt-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}

.prompt-modal-header {
  border-bottom: 1px solid var(--line);
}

.prompt-modal-header h2 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
}

.prompt-modal-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
  color: var(--muted);
}

.prompt-modal-input {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: none;
  resize: none;
  padding: 18px;
  font-size: 17px;
  line-height: 1.58;
}

.prompt-modal-footer {
  border-top: 1px solid var(--line);
}

.prompt-modal-footer button {
  min-height: 42px;
  border: 1px solid var(--button);
  border-radius: 11px;
  padding: 0 18px;
  background: var(--button);
  color: var(--button-text);
}

.prompt-modal-footer .secondary {
  border-color: var(--line);
  background: var(--card);
  color: var(--text);
}

.workspace-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  min-height: 20px;
  padding: 0 6px;
  color: var(--nav-muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.2;
}

.workspace-strip.empty {
  opacity: 0.62;
}

.workspace-place,
.workspace-branch {
  display: flex;
  align-items: center;
  min-width: 0;
}

.workspace-place {
  gap: 6px;
}

.workspace-branch {
  gap: 7px;
  justify-content: flex-end;
}

.workspace-repo,
.workspace-location,
.branch-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-repo {
  flex: 0 1 auto;
  min-width: 96px;
  max-width: 32%;
  color: var(--nav-text);
}

.workspace-location {
  flex: 1 1 auto;
}

.branch-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.branch-name {
  max-width: min(220px, 30vw);
  color: var(--nav-text);
}

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

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 10px 4px;
}

.composer-left,
.composer-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ghost-button,
.access-button,
.model-button,
.expand-button,
.interrupt-button,
.voice-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border: 0;
  border-radius: 8px;
  padding: 0 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.ghost-button:hover,
.access-button:hover,
.model-button:hover,
.thinking-button:hover,
.expand-button:hover,
.interrupt-button:hover,
.voice-button:hover {
  background: var(--hover);
  color: var(--nav-text);
}

.access-button {
  gap: 4px;
  color: var(--accent);
}

.model-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--nav-text);
  white-space: nowrap;
  max-width: 154px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.access-label,
.model-button-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.button-chevron-icon {
  display: block;
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  opacity: 0.72;
}

.expand-button {
  width: 30px;
  padding: 0;
}

.voice-button {
  position: relative;
  width: 30px;
  padding: 0;
}

.voice-button.listening {
  color: var(--accent);
}

.interrupt-button {
  gap: 5px;
  flex: 0 0 auto;
  min-width: 64px;
  height: 36px;
  border: 1px solid var(--warning-line);
  border-radius: 999px;
  padding: 0 10px;
  background: var(--warning-bg);
  color: var(--warning-text);
  font-weight: 650;
  letter-spacing: 0;
}

.interrupt-button:hover {
  border-color: var(--warning-line);
  background: color-mix(in srgb, var(--warning-bg) 82%, var(--hover));
  color: var(--warning-text);
}

.interrupt-button:disabled {
  opacity: 0.48;
}

.interrupt-button.hidden {
  display: none;
}

.interrupt-icon {
  position: relative;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  background: transparent;
  clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%);
}

.interrupt-icon::before,
.interrupt-icon::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 50%;
  border-top: 2px solid currentColor;
}

.interrupt-icon::before {
  transform: translateY(-50%) rotate(45deg);
}

.interrupt-icon::after {
  transform: translateY(-50%) rotate(-45deg);
}

.interrupt-label {
  line-height: 1;
  white-space: nowrap;
}

.model-menu {
  position: absolute;
  right: 52px;
  bottom: calc(100% + 12px);
  z-index: 28;
  width: min(420px, calc(100vw - 30px));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 8px;
  background: var(--card);
  color: var(--text);
  box-shadow: 0 20px 44px color-mix(in srgb, var(--text) 12%, transparent);
}

.model-menu-label {
  padding: 4px 16px 12px;
  color: var(--muted);
  font-size: 12px;
}

.model-menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-size: 14px;
}

.model-menu-row:hover,
.model-menu-row.active {
  background: var(--soft);
}

.model-menu-separator {
  height: 1px;
  margin: 8px 16px;
  background: var(--line);
}

.checkmark,
.chevron {
  color: var(--muted);
  font-size: 22px;
}

.send-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 11px;
  background: var(--button);
  color: var(--button-text);
  font-size: 22px;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.send-button:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 9px 20px color-mix(in srgb, var(--button) 20%, transparent);
}

.send-button:disabled {
  opacity: 0.42;
}

.artifact-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  padding: 10px 14px 10px 8px;
  border-left: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  background: transparent;
  overflow: hidden;
}

.right-resize-handle {
  position: absolute;
  inset: 10px auto 10px 0;
  width: 8px;
  min-width: 8px;
}

.panel-card {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: color-mix(in srgb, var(--card) 94%, transparent);
  box-shadow:
    0 10px 26px color-mix(in srgb, var(--text) 5%, transparent),
    inset 0 1px 0 color-mix(in srgb, #fff 66%, transparent);
  overflow: hidden;
}

.panel-card.primary-panel {
  flex: 1 1 auto;
  min-height: 0;
}

.panel-card.primary-panel #artifactList {
  flex: 0 0 auto;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

.panel-title > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  margin: -2px 0 10px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--compact-radius);
  background: color-mix(in srgb, var(--soft) 62%, transparent);
}

.panel-tab {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 28px;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  line-height: 1;
}

.panel-tab:hover,
.panel-tab.active {
  background: var(--card);
  color: var(--text);
}

.panel-tab.active {
  box-shadow: 0 1px 2px color-mix(in srgb, var(--text) 9%, transparent);
}

.panel-close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--compact-radius);
  background: var(--soft);
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}

.panel-close:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.artifact-row,
.terminal-row,
.source-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: var(--compact-radius);
  padding: 7px 8px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  overflow-wrap: anywhere;
}

.artifact-row.no-icon {
  grid-template-columns: minmax(0, 1fr);
}

.artifact-row > svg,
.terminal-row > svg,
.source-row > svg {
  margin-top: 2px;
}

.artifact-row span,
.terminal-row span,
.source-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.panel-row-icon {
  display: grid;
  place-items: center;
  width: 22px;
  min-height: 20px;
  border-radius: 6px;
  background: var(--soft);
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.panel-row-copy {
  display: block;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: normal;
}

.artifact-row strong,
.artifact-row small {
  display: block;
  overflow-wrap: break-word;
  word-break: normal;
}

.artifact-row strong {
  font-size: 13px;
  font-weight: 600;
  line-height: 18px;
}

.artifact-row small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.artifact-row:hover {
  background: var(--soft);
}

.artifact-row:disabled {
  cursor: default;
  opacity: 0.62;
}

.artifact-row.workspace-row,
.artifact-row.review-row {
  grid-template-columns: 24px minmax(0, 1fr) auto auto;
}

.row-actions {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
}

.row-actions span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 6px;
  background: var(--card);
}

.artifact-row.active {
  background: var(--soft);
  font-weight: 600;
}

.artifact-browser-list {
  max-height: min(28vh, 240px);
  overflow: auto;
  padding-right: 4px;
}

.artifact-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.artifact-preview-title {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artifact-preview-close {
  flex: 0 0 auto;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 9px;
  background: var(--soft);
  color: var(--muted);
}

.artifact-preview-close:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.terminal-row,
.source-row {
  color: var(--nav-muted);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
}

.artifact-preview {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  max-height: none;
  overflow: auto;
  margin: 8px 0 0;
  overflow-wrap: anywhere;
  color: var(--entry);
  font-size: 13px;
  line-height: 1.58;
}

.artifact-preview p,
.artifact-preview ul,
.artifact-preview ol,
.artifact-preview blockquote,
.artifact-preview pre {
  margin: 0 0 12px;
}

.artifact-preview p:last-child,
.artifact-preview ul:last-child,
.artifact-preview ol:last-child,
.artifact-preview blockquote:last-child,
.artifact-preview pre:last-child {
  margin-bottom: 0;
}

.artifact-preview h2,
.artifact-preview h3,
.artifact-preview h4,
.artifact-preview h5 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.artifact-preview.markdown-preview h1 {
  margin: 0 0 16px;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 1.55em;
  line-height: 1.25;
}

.artifact-preview.markdown-preview h2 {
  margin-top: 22px;
  padding-bottom: 0.28em;
  border-bottom: 1px solid var(--line);
  font-size: 1.25em;
}

.artifact-preview.markdown-preview h3 {
  margin-top: 18px;
  font-size: 1.08em;
}

.artifact-preview.markdown-preview img {
  max-width: 100%;
  height: auto;
  border-style: none;
  vertical-align: middle;
}

.artifact-preview.markdown-preview p[align="center"] {
  text-align: center;
}

.artifact-preview.markdown-preview table {
  display: block;
  max-width: 100%;
  overflow: auto;
  border-spacing: 0;
  border-collapse: collapse;
}

.artifact-preview.markdown-preview th,
.artifact-preview.markdown-preview td {
  border: 1px solid var(--line);
  padding: 6px 10px;
}

.artifact-preview.markdown-preview tr:nth-child(2n) {
  background: var(--soft);
}

.artifact-preview ul,
.artifact-preview ol {
  padding-left: 1.35em;
}

.artifact-preview li {
  margin: 3px 0;
}

.artifact-preview code {
  border-radius: 5px;
  padding: 0.1em 0.32em;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.9em;
}

.artifact-preview pre {
  max-width: 100%;
  overflow-x: auto;
  border-radius: 9px;
  padding: 10px 12px;
  background: var(--code-bg);
  white-space: pre;
}

.artifact-preview pre code {
  padding: 0;
  background: transparent;
}

.artifact-preview blockquote {
  border-left: 3px solid var(--quote);
  padding-left: 10px;
  color: var(--muted);
}

.artifact-preview a {
  color: var(--link);
  text-decoration: none;
}

.artifact-preview a:hover {
  text-decoration: underline;
}

.artifact-preview.image-artifact-preview {
  max-height: none;
}

.artifact-preview.image-artifact-preview .image-gallery {
  grid-template-columns: minmax(0, 1fr);
  margin-top: 0;
}

.artifact-preview.image-artifact-preview .image-preview img {
  max-height: calc(100vh - 220px);
}

.theme-settings {
  margin: 0 0 14px;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--line);
}

.theme-settings-title {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.theme-options {
  display: grid;
  gap: 8px;
}

.theme-option {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  column-gap: 10px;
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  background: var(--card);
  color: var(--text);
  text-align: left;
}

.theme-option:hover,
.theme-option.active {
  border-color: var(--accent);
  background: var(--soft);
}

.theme-option strong,
.theme-option small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-option strong {
  font-size: 13px;
  font-weight: 620;
}

.theme-option small {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

.theme-swatch {
  grid-row: span 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 42px;
  height: 34px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.theme-swatch span {
  min-width: 0;
}

[data-theme-choice="simple"] .theme-swatch span:nth-child(1) {
  background: #ffffff;
}

[data-theme-choice="simple"] .theme-swatch span:nth-child(2) {
  background: #f5f5f5;
}

[data-theme-choice="simple"] .theme-swatch span:nth-child(3) {
  background: #0169cc;
}

[data-theme-choice="cyberpunk"] .theme-swatch span:nth-child(1) {
  background: #020704;
}

[data-theme-choice="cyberpunk"] .theme-swatch span:nth-child(2) {
  background: #62ff6b;
}

[data-theme-choice="cyberpunk"] .theme-swatch span:nth-child(3) {
  background: #b7ffb2;
}

[data-theme-choice="botanical"] .theme-swatch span:nth-child(1) {
  background: #faf9f0;
}

[data-theme-choice="botanical"] .theme-swatch span:nth-child(2) {
  background: #2e7d4a;
}

[data-theme-choice="botanical"] .theme-swatch span:nth-child(3) {
  background: #d6dece;
}

[data-theme-choice="stigmata"] .theme-swatch span:nth-child(1) {
  background: #010a14;
}

[data-theme-choice="stigmata"] .theme-swatch span:nth-child(2) {
  background: #8ba1c0;
}

[data-theme-choice="stigmata"] .theme-swatch span:nth-child(3) {
  background: #ab6872;
}

@media (max-width: 1100px) {
  .content-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .artifact-panel {
    display: none;
  }

  body.show-panel .artifact-panel {
    position: fixed;
    inset: 62px 12px max(12px, env(safe-area-inset-bottom)) 12px;
    z-index: 24;
    display: grid;
    align-content: start;
    max-width: 460px;
    margin-left: auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 20px 46px color-mix(in srgb, var(--text) 16%, transparent);
  }
}

@media (max-width: 980px) {
  .app-shell {
    --thread-width: 248px;
    grid-template-columns: var(--thread-width) 6px minmax(0, 1fr);
  }

  .sidebar {
    padding-inline: 10px;
  }

  .log {
    padding-inline: clamp(20px, 6vw, 64px);
  }

  .composer-stack {
    width: min(760px, calc(100% - 32px));
  }

  .run-state {
    width: min(760px, calc(100% - 32px));
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar-resize-handle {
    display: none;
  }

  .sidebar-scrim {
    position: fixed;
    inset: 0;
    z-index: 19;
    display: block;
    border: 0;
    background: transparent;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  body.show-sidebar .sidebar-scrim {
    opacity: 1;
    pointer-events: auto;
    background: var(--scrim);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 20;
    width: min(86vw, 320px);
    transform: translateX(-100%);
    transition: transform 180ms ease;
    box-shadow: 18px 0 30px color-mix(in srgb, var(--text) 14%, transparent);
  }

  body.show-sidebar .sidebar {
    transform: translateX(0);
  }

  .mobile-toggle {
    display: inline-block;
  }

  .titlebar {
    display: flex;
    align-items: center;
    padding: 0 10px;
  }

  .title-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 6px;
  }

  .title-stack {
    flex: 1 1 auto;
    min-width: 0;
  }

  .mobile-toggle {
    flex: 0 0 auto;
  }

  h1 {
    font-size: 14px;
  }

  #meta {
    max-width: 100%;
  }

  .log {
    padding: 22px 14px 28px;
  }

  .entry {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
    margin-bottom: 22px;
  }

  .entry-avatar,
  .entry-tools {
    display: none;
  }

  .entry-body {
    font-size: 14px;
    line-height: 1.58;
  }

  .entry.user .entry-body {
    position: relative;
    width: min(100%, 88vw);
    margin-left: auto;
    border-radius: 12px;
    padding: 16px 16px 14px;
  }

  .entry.user .entry-body::before {
    content: "你";
    display: block;
    margin-bottom: 6px;
    color: color-mix(in srgb, var(--accent) 68%, var(--nav-text));
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.02em;
  }

  .image-gallery {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .image-preview {
    border-radius: 9px;
  }

  .image-preview img {
    max-height: 180px;
  }

  .artifact-browser-list {
    max-height: 34vh;
  }

  .markdown-image {
    max-width: 100%;
  }

  .project-heading {
    min-height: 36px;
    font-size: 14px;
  }

  .project-group {
    margin: 10px 0 16px;
  }

  .thread-item {
    min-height: 36px;
    padding-left: 38px;
    font-size: 13px;
  }

  .project-empty,
  .project-more {
    padding-left: 38px;
    font-size: 13px;
  }

  .composer-stack {
    width: calc(100vw - 18px);
    margin-bottom: max(7px, env(safe-area-inset-bottom));
  }

  .composer {
    min-height: 72px;
    border-radius: 12px;
  }

  .workspace-strip {
    min-height: 22px;
    padding: 0 3px;
    font-size: 11px;
  }

  .workspace-branch {
    gap: 5px;
  }

  .workspace-repo {
    min-width: 86px;
    max-width: 34%;
  }

  .branch-name {
    max-width: 30vw;
  }

  .run-state {
    width: calc(100vw - 18px);
    min-height: 30px;
    margin-bottom: 7px;
    padding: 0 11px;
    font-size: 12px;
  }

  .attachments {
    gap: 6px;
    padding: 8px 10px 0;
  }

  .attachment-chip {
    min-height: 30px;
    max-width: 180px;
    padding: 3px 8px 3px 4px;
    font-size: 12px;
  }

  .attachment-chip img {
    width: 24px;
    height: 24px;
  }

  textarea {
    height: 32px;
    min-height: 32px;
    max-height: 112px;
    resize: none;
    padding: 8px 14px 0;
    color: var(--text);
    font-size: 16px;
    line-height: 1.34;
  }

  .composer-footer {
    gap: 8px;
    padding: 0 9px 8px;
  }

  .composer-left,
  .composer-right {
    gap: 7px;
  }

  .ghost-button,
  .access-button,
  .model-button,
  .thinking-button,
  .expand-button,
  .interrupt-button,
  .voice-button {
    padding-inline: 5px;
    min-height: 30px;
    font-size: 14px;
  }

  .thinking-button,
  .expand-button,
  .voice-button {
    width: 30px;
  }

  .interrupt-button {
    min-width: 58px;
    height: 32px;
    padding: 0 8px;
  }

  .interrupt-icon {
    width: 16px;
    height: 16px;
  }

  .send-button {
    width: 34px;
    height: 34px;
    font-size: 20px;
  }

  .access-button {
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 520px) {
  .titlebar {
    width: 100vw;
    max-width: 100vw;
  }

  .titlebar {
    gap: 6px;
    position: relative;
    padding-right: 48px;
  }

  .mobile-toggle {
    min-width: 62px;
    padding: 0 7px;
  }

  .icon-button {
    min-width: 32px;
    height: 32px;
    border-radius: 9px;
  }

  h1 {
    font-size: 13px;
  }

  #meta {
    display: none;
  }

  #connect {
    display: none;
  }

  #menuButton {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
  }

  .log {
    padding: 18px 14px 14px;
  }

  .entry {
    margin-bottom: 18px;
  }

  textarea {
    height: 40px;
    min-height: 40px;
    max-height: 104px;
    padding: 9px 13px 3px;
  }

  textarea::placeholder {
    color: color-mix(in srgb, var(--muted) 86%, transparent);
  }

  .composer {
    min-height: 72px;
    border-radius: 12px;
  }

  .prompt-modal {
    align-items: stretch;
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
  }

  .prompt-modal-card {
    width: 100%;
    height: 100%;
    border-radius: 16px;
  }

  .prompt-modal-input {
    padding: 14px;
    font-size: 16px;
  }

  .composer-footer {
    gap: 6px;
    padding-bottom: 7px;
  }

  .composer-left,
  .composer-right {
    gap: 5px;
  }

  .access-button {
    max-width: 92px;
  }

  .model-button {
    max-width: 66px;
  }

  .model-menu {
    right: 8px;
    width: calc(100vw - 30px);
  }

  .image-preview img {
    max-height: 168px;
  }
}

@media (max-width: 380px) {
  .mobile-toggle {
    min-width: 42px;
    max-width: 42px;
    overflow: hidden;
    padding: 0;
    color: transparent;
    position: relative;
  }

  .mobile-toggle::before {
    content: "☰";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--nav-text);
    font-size: 18px;
  }

  .icon-button {
    min-width: 30px;
    height: 30px;
  }

  .composer-left,
  .composer-right {
    gap: 5px;
  }

  .access-button {
    max-width: 82px;
  }

  .model-button {
    max-width: 52px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .branch-label {
    display: none;
  }

  .ghost-button,
  .access-button,
  .model-button,
  .thinking-button,
  .interrupt-button,
  .voice-button {
    font-size: 13px;
  }

  .interrupt-button {
    min-width: 30px;
    width: 30px;
    height: 30px;
    padding: 0;
  }

  .interrupt-label {
    display: none;
  }

  .thread-time {
    max-width: 42px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .image-preview img {
    max-height: 148px;
  }
}
