/* ==========================================================================
   44.01 AI Workspace
   Built on the 44.01 brand palette: Rock, Off-white and Canyon lead;
   Serpentine, Olivine, Shale, Sand and Calcite are used as accent shades.
   ========================================================================== */

:root {
  --rock: #070808;
  --off-white: #f1f0f0;
  --canyon: #df7626;
  --serpentine: #6f663f;
  --earth: #0d1802;
  --olivine: #8b9c44;
  --shale: #57544a;
  --sand: #beb290;
  --calcite: #eadac7;

  --font: "Poppins", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --side-w: 288px;
  --col-w: 772px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* Dark theme (default) */
  --bg: #0a0b0b;
  --bg-glow-1: rgba(223, 118, 38, 0.1);
  --bg-glow-2: rgba(139, 156, 68, 0.06);
  --side: rgba(16, 17, 17, 0.82);
  --surface: #141616;
  --surface-2: #1b1d1d;
  --surface-3: #232626;
  --glass: rgba(26, 28, 28, 0.72);
  --border: rgba(241, 240, 240, 0.08);
  --border-strong: rgba(241, 240, 240, 0.14);
  --text: #f1f0f0;
  --text-2: #c2beb4;
  --text-3: #8a867c;
  --accent: #df7626;
  --accent-hover: #ea8640;
  --accent-text: #f0a066;
  --accent-soft: rgba(223, 118, 38, 0.14);
  --accent-ring: rgba(223, 118, 38, 0.38);
  --on-accent: #ffffff;
  --success: #a4b65a;
  --danger: #ef6b5b;
  --user-bubble: #222525;
  --code-bg: #0f1111;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, 0.75), 0 8px 24px rgba(0, 0, 0, 0.35);
  --composer-shadow: 0 0 0 1px var(--border-strong), 0 18px 50px -18px rgba(0, 0, 0, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f4f0;
    --bg-glow-1: rgba(223, 118, 38, 0.09);
    --bg-glow-2: rgba(190, 178, 144, 0.22);
    --side: rgba(238, 234, 227, 0.86);
    --surface: #ffffff;
    --surface-2: #f3f0eb;
    --surface-3: #e9e5de;
    --glass: rgba(255, 255, 255, 0.78);
    --border: rgba(7, 8, 8, 0.08);
    --border-strong: rgba(7, 8, 8, 0.14);
    --text: #121313;
    --text-2: #4a4840;
    --text-3: #7b776c;
    --accent-text: #b4561a;
    --accent-soft: rgba(223, 118, 38, 0.12);
    --success: #6b7a2f;
    --danger: #c2412f;
    --user-bubble: #ebe5dc;
    --code-bg: #f7f5f1;
    --shadow-sm: 0 1px 2px rgba(7, 8, 8, 0.06);
    --shadow: 0 10px 30px -12px rgba(60, 45, 20, 0.18), 0 2px 6px rgba(7, 8, 8, 0.05);
    --shadow-lg: 0 30px 80px -24px rgba(60, 45, 20, 0.3), 0 8px 24px rgba(7, 8, 8, 0.08);
    --composer-shadow: 0 0 0 1px var(--border-strong), 0 16px 40px -18px rgba(60, 45, 20, 0.28),
      inset 0 1px 0 rgba(255, 255, 255, 0.9);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f6f4f0;
  --bg-glow-1: rgba(223, 118, 38, 0.09);
  --bg-glow-2: rgba(190, 178, 144, 0.22);
  --side: rgba(238, 234, 227, 0.86);
  --surface: #ffffff;
  --surface-2: #f3f0eb;
  --surface-3: #e9e5de;
  --glass: rgba(255, 255, 255, 0.78);
  --border: rgba(7, 8, 8, 0.08);
  --border-strong: rgba(7, 8, 8, 0.14);
  --text: #121313;
  --text-2: #4a4840;
  --text-3: #7b776c;
  --accent-text: #b4561a;
  --accent-soft: rgba(223, 118, 38, 0.12);
  --success: #6b7a2f;
  --danger: #c2412f;
  --user-bubble: #ebe5dc;
  --code-bg: #f7f5f1;
  --shadow-sm: 0 1px 2px rgba(7, 8, 8, 0.06);
  --shadow: 0 10px 30px -12px rgba(60, 45, 20, 0.18), 0 2px 6px rgba(7, 8, 8, 0.05);
  --shadow-lg: 0 30px 80px -24px rgba(60, 45, 20, 0.3), 0 8px 24px rgba(7, 8, 8, 0.08);
  --composer-shadow: 0 0 0 1px var(--border-strong), 0 16px 40px -18px rgba(60, 45, 20, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  color-scheme: light;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(1100px 600px at 85% -10%, var(--bg-glow-1), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, var(--bg-glow-2), transparent 60%);
  z-index: 0;
}
[hidden] {
  display: none !important;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}
a {
  color: inherit;
  text-decoration: none;
}
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
::selection {
  background: var(--accent-ring);
}
:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
  border-radius: 6px;
}
.kbd {
  margin-left: auto;
  font-family: var(--font);
  font-size: 11px;
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 6px;
  line-height: 18px;
}
.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  display: inline-block;
  flex: none;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Buttons ---------- */
.icon-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}
.icon-btn.sm {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}
.icon-btn.sm svg {
  width: 15px;
  height: 15px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover {
  background: var(--surface-2);
}
.btn:active {
  transform: translateY(1px);
}
.btn.primary {
  background: linear-gradient(180deg, #e8843a, var(--accent));
  border-color: transparent;
  color: var(--on-accent);
  box-shadow: 0 6px 18px -6px rgba(223, 118, 38, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.btn.primary:hover {
  background: linear-gradient(180deg, #f0924c, var(--accent-hover));
}
.btn.danger {
  background: var(--danger);
  border-color: transparent;
  color: #fff;
}
.btn.ghost {
  border-color: transparent;
  background: transparent;
}
.btn.ghost:hover {
  background: var(--surface-3);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Splash ---------- */
.splash {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 5;
  padding: 16px;
  background: radial-gradient(800px 500px at 50% 0%, rgba(223, 118, 38, 0.18), transparent 70%),
    radial-gradient(700px 500px at 50% 110%, rgba(139, 156, 68, 0.1), transparent 70%), var(--bg);
}
.splash-card {
  width: min(440px, 100%);
  text-align: center;
  padding: 44px 36px 32px;
  border-radius: 28px;
  background: var(--glass);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(24px) saturate(140%);
  -webkit-backdrop-filter: blur(24px) saturate(140%);
  animation: pop 0.5s var(--ease);
}
.splash-logo {
  height: 46px;
  width: auto;
}
.splash h1 {
  margin: 22px 0 6px;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.splash-sub {
  margin: 0 0 28px;
  color: var(--text-2);
  font-size: 14px;
}
.splash-status {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--text-2);
  font-size: 14px;
  min-height: 46px;
}
.btn-microsoft {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  height: 48px;
  border-radius: 14px;
  font-weight: 500;
  background: var(--text);
  color: var(--bg);
  transition: transform 0.15s var(--ease), box-shadow 0.15s;
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
}
.btn-microsoft:hover {
  transform: translateY(-1px);
}
.btn-microsoft svg {
  stroke: none;
}
.splash-foot {
  margin: 22px 0 0;
  font-size: 12px;
  color: var(--text-3);
}

/* ---------- Layout ---------- */
.app {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100vh;
  height: 100dvh;
}
.sidebar {
  width: var(--side-w);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--side);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  transition: margin-left 0.28s var(--ease), transform 0.28s var(--ease);
  z-index: 20;
}
.app.collapsed .sidebar {
  margin-left: calc(var(--side-w) * -1);
}
.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 12px 8px 18px;
}
.side-brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand-wordmark {
  height: 22px;
  width: auto;
  align-self: flex-start;
}
.brand-sub {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 500;
}
.side-actions {
  padding: 10px 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side-new {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 14px;
  color: var(--accent-text);
  transition: background 0.15s;
}
.side-new:hover {
  background: var(--accent-soft);
}
.side-new-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #e8843a, var(--accent));
  color: #fff;
  box-shadow: 0 4px 12px -4px rgba(223, 118, 38, 0.7);
}
.side-new-icon svg {
  width: 15px;
  height: 15px;
  stroke-width: 2.4;
}
.side-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
  width: 100%;
  text-align: left;
}
.side-link:hover,
.side-link.active {
  background: var(--surface-3);
  color: var(--text);
}
.side-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px 16px;
  scrollbar-width: thin;
}
.side-group-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  padding: 14px 12px 4px;
}
.conv-item {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 10px;
  transition: background 0.12s;
}
.conv-item a {
  flex: 1;
  min-width: 0;
  padding: 7px 12px;
  font-size: 13.5px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  mask-image: linear-gradient(90deg, #000 85%, transparent);
}
.conv-item:hover {
  background: var(--surface-3);
}
.conv-item.active {
  background: var(--surface-3);
}
.conv-item.active a,
.conv-item:hover a {
  color: var(--text);
}
.conv-item .icon-btn {
  position: absolute;
  right: 4px;
  opacity: 0;
  background: var(--surface-3);
}
.conv-item:hover .icon-btn,
.conv-item .icon-btn[aria-expanded="true"] {
  opacity: 1;
}
.conv-item.fresh a {
  animation: fade-up 0.4s var(--ease);
}
.side-empty {
  padding: 18px 12px;
  color: var(--text-3);
  font-size: 13px;
}
.side-foot {
  padding: 10px;
  border-top: 1px solid var(--border);
}
.user-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border-radius: 12px;
  text-align: left;
  transition: background 0.15s;
}
.user-btn:hover {
  background: var(--surface-3);
}
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--canyon), var(--serpentine));
}
.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.user-name {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-email {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chev {
  color: var(--text-3);
}

.main {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: 56px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}
#open-sidebar-btn {
  display: none;
}
.app.collapsed #open-sidebar-btn {
  display: inline-grid;
}
.topbar-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}
.title-btn {
  padding: 6px 10px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  transition: background 0.15s;
}
.title-btn:hover {
  background: var(--surface-3);
}
.crumb {
  color: var(--text-3);
  padding: 6px 4px 6px 10px;
  border-radius: 10px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.crumb:hover {
  color: var(--text);
}
.crumb-sep {
  color: var(--text-3);
}
.topbar-actions {
  display: flex;
  gap: 4px;
}
.mobile-only {
  display: none;
}
.view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.scrim {
  display: none;
}

/* ---------- Home ---------- */
.home {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 12vh;
  overflow-y: auto;
}
.greeting {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 30px;
  animation: fade-up 0.5s var(--ease);
}
.greeting img {
  width: 40px;
  height: 40px;
  filter: drop-shadow(0 6px 16px rgba(223, 118, 38, 0.35));
}
.greeting h1 {
  margin: 0;
  font-weight: 400;
  font-size: clamp(26px, 4vw, 38px);
  letter-spacing: -0.02em;
}
.home .composer-wrap {
  width: min(var(--col-w), 100%);
  animation: fade-up 0.5s 0.05s var(--ease) both;
}
.suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
  animation: fade-up 0.5s 0.1s var(--ease) both;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--glass);
  color: var(--text-2);
  font-size: 13px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  backdrop-filter: blur(10px);
}
.chip:hover {
  color: var(--text);
  border-color: var(--accent-ring);
  background: var(--accent-soft);
}
.chip svg {
  width: 15px;
  height: 15px;
  color: var(--accent-text);
}
.home-project {
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-2);
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
}

/* ---------- Composer ---------- */
.composer-wrap {
  width: 100%;
}
.composer {
  container-type: inline-size;
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--composer-shadow);
  transition: box-shadow 0.2s;
  padding: 12px 12px 10px 16px;
}
.composer:focus-within {
  box-shadow: 0 0 0 1px var(--accent-ring), 0 0 0 4px var(--accent-soft), var(--shadow);
}
.composer textarea {
  display: block;
  width: 100%;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  min-height: 28px;
  max-height: 260px;
  padding: 4px 4px 8px 0;
  font-size: 15px;
  line-height: 1.6;
}
.composer textarea::placeholder {
  color: var(--text-3);
}
.composer-bar {
  display: flex;
  align-items: center;
  gap: 4px;
}
.composer-bar .spacer {
  flex: 1;
}
.tool-btn {
  height: 32px;
  min-width: 32px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  color: var(--text-2);
  border: 1px solid var(--border);
  font-size: 13px;
  transition: all 0.15s;
}
.tool-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}
.tool-btn.on {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: var(--accent-ring);
}
.tool-btn .label {
  display: none;
}
.tool-btn.on .label {
  display: inline;
}
.model-btn {
  white-space: nowrap;
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px 0 10px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--text-2);
  transition: background 0.15s;
}
.model-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}
.model-btn svg {
  width: 14px;
  height: 14px;
}
.send-btn {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(180deg, #e8843a, var(--accent));
  box-shadow: 0 6px 16px -6px rgba(223, 118, 38, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.12s, opacity 0.15s, filter 0.15s;
}
.send-btn:hover {
  filter: brightness(1.08);
}
.send-btn:active {
  transform: scale(0.94);
}
.send-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}
.send-btn svg {
  stroke-width: 2.4;
}
.send-btn.stop {
  background: var(--text);
  color: var(--bg);
  box-shadow: none;
}
.send-btn.stop svg {
  fill: currentColor;
  stroke: none;
  width: 12px;
  height: 12px;
}
.composer-note {
  text-align: center;
  color: var(--text-3);
  font-size: 11.5px;
  margin-top: 8px;
}
.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.composer-error {
  margin: 0 0 8px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
}
.attachments:empty {
  display: none;
}
.file-chip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 30px 8px 8px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  max-width: 240px;
  animation: pop 0.25s var(--ease);
}
.file-chip .file-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  overflow: hidden;
  flex: none;
}
.file-chip .file-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.file-chip .file-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.file-chip .file-name {
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-chip .file-size {
  font-size: 11px;
  color: var(--text-3);
}
.file-chip .remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-3);
}
.file-chip .remove:hover {
  background: var(--surface-3);
  color: var(--text);
}
.file-chip .remove svg {
  width: 12px;
  height: 12px;
}
.file-chip.uploading .file-icon {
  background: var(--surface-3);
}

/* ---------- Chat ---------- */
.chat {
  flex: 1;
  min-height: 0;
  display: flex;
}
.chat-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.thread {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: auto;
  padding: 12px 16px 24px;
  scrollbar-gutter: stable both-edges;
}
.thread-inner {
  max-width: var(--col-w);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.chat-footer {
  flex: none;
  padding: 0 16px 14px;
  position: relative;
}
.chat-footer::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -28px;
  height: 28px;
  background: linear-gradient(transparent, var(--bg));
  pointer-events: none;
}
.chat-footer .composer-wrap {
  max-width: var(--col-w);
  margin: 0 auto;
}
.scroll-down {
  position: absolute;
  left: 50%;
  top: -52px;
  transform: translateX(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  color: var(--text-2);
  z-index: 2;
}

.msg {
  animation: fade-up 0.35s var(--ease);
}
.msg-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
.msg-user .bubble {
  max-width: min(85%, 640px);
  background: var(--user-bubble);
  padding: 10px 16px;
  border-radius: 20px 20px 6px 20px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg-user .attachments {
  justify-content: flex-end;
  margin: 0;
}
.msg-user .file-chip {
  padding-right: 12px;
}
.msg-actions {
  display: flex;
  gap: 2px;
  align-items: center;
  opacity: 0;
  transition: opacity 0.15s;
  color: var(--text-3);
  font-size: 12px;
}
.msg:hover .msg-actions,
.msg.last .msg-actions,
.msg-actions:focus-within {
  opacity: 1;
}
.msg-actions .model-tag {
  margin-left: 8px;
  color: var(--text-3);
}
.msg-actions .icon-btn.active {
  color: var(--accent-text);
}
.msg-assistant {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 14px;
}
.msg-assistant .mark {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.msg-assistant .mark img {
  width: 16px;
  height: 16px;
}
.msg-assistant.streaming .mark img {
  animation: breathe 1.6s ease-in-out infinite;
}
@keyframes breathe {
  50% {
    transform: scale(0.82) rotate(-8deg);
    opacity: 0.7;
  }
}
.msg-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.status-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-3);
  font-size: 13.5px;
}
.shimmer {
  background: linear-gradient(90deg, var(--text-3) 0%, var(--text) 50%, var(--text-3) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -100% 0;
  }
}
.thinking-box {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
  max-width: 100%;
}
.thinking-box summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 13.5px;
  color: var(--text-2);
}
.thinking-box summary::-webkit-details-marker {
  display: none;
}
.thinking-box summary svg.caret {
  margin-left: auto;
  transition: transform 0.2s;
  width: 15px;
  height: 15px;
}
.thinking-box[open] summary svg.caret {
  transform: rotate(180deg);
}
.thinking-text {
  padding: 2px 16px 14px;
  font-size: 13.5px;
  color: var(--text-2);
  white-space: pre-wrap;
  max-height: 320px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 260px;
  height: 28px;
  padding: 0 10px 0 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--text-2);
  transition: border-color 0.15s, color 0.15s;
}
.source:hover {
  border-color: var(--accent-ring);
  color: var(--text);
}
.source img {
  width: 16px;
  height: 16px;
  border-radius: 4px;
}
.source span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notice {
  font-size: 12.5px;
  color: var(--text-3);
  font-style: italic;
}
.error-card {
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.error-card svg {
  color: var(--danger);
  margin-top: 2px;
}

/* ---------- Markdown ---------- */
.md {
  font-size: 15px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}
.md > :first-child {
  margin-top: 0;
}
.md > :last-child {
  margin-bottom: 0;
}
.md p {
  margin: 0 0 14px;
}
.md h1,
.md h2,
.md h3,
.md h4 {
  font-weight: 600;
  line-height: 1.35;
  margin: 26px 0 10px;
  letter-spacing: -0.01em;
}
.md h1 {
  font-size: 22px;
}
.md h2 {
  font-size: 19px;
}
.md h3 {
  font-size: 16.5px;
}
.md h4 {
  font-size: 15px;
}
.md ul,
.md ol {
  margin: 0 0 14px;
  padding-left: 24px;
}
.md li {
  margin: 4px 0;
}
.md li::marker {
  color: var(--text-3);
}
.md a {
  color: var(--accent-text);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent-text) 40%, transparent);
  text-underline-offset: 3px;
}
.md a:hover {
  text-decoration-color: currentColor;
}
.md strong {
  font-weight: 600;
}
.md blockquote {
  margin: 0 0 14px;
  padding: 2px 0 2px 16px;
  border-left: 3px solid var(--accent);
  color: var(--text-2);
}
.md hr {
  border: 0;
  border-top: 1px solid var(--border-strong);
  margin: 22px 0;
}
.md :not(pre) > code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--accent-text);
}
.md .table-wrap {
  overflow-x: auto;
  margin: 0 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
}
.md table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}
.md th,
.md td {
  text-align: left;
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
}
.md th {
  font-weight: 600;
  background: var(--surface-2);
}
.md tr:last-child td {
  border-bottom: 0;
}
.md img {
  max-width: 100%;
  border-radius: 10px;
}
.code-block {
  margin: 0 0 16px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: var(--code-bg);
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 14px;
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-2);
}
.code-copy:hover {
  background: var(--surface-3);
  color: var(--text);
}
.code-copy svg {
  width: 14px;
  height: 14px;
}
.code-block pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
}
.code-block code {
  font-family: inherit;
}
.cursor {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
  animation: blink 1s ease-in-out infinite;
}
@keyframes blink {
  50% {
    opacity: 0.25;
    transform: scale(0.7);
  }
}

/* Syntax colours, tuned to the brand palette */
.hljs-comment,
.hljs-quote {
  color: var(--text-3);
  font-style: italic;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-doctag {
  color: #e0884a;
}
.hljs-string,
.hljs-regexp,
.hljs-addition {
  color: #a4b65a;
}
.hljs-number,
.hljs-symbol,
.hljs-bullet {
  color: #d6b98a;
}
.hljs-title,
.hljs-section,
.hljs-title.function_ {
  color: #8fb3d9;
}
.hljs-built_in,
.hljs-type,
.hljs-class .hljs-title {
  color: #c9a0dc;
}
.hljs-attr,
.hljs-attribute,
.hljs-variable,
.hljs-template-variable,
.hljs-params {
  color: #d8cfbc;
}
.hljs-meta,
.hljs-deletion {
  color: #ef6b5b;
}
:root[data-theme="light"] .hljs-keyword,
:root[data-theme="light"] .hljs-literal {
  color: #b4561a;
}
:root[data-theme="light"] .hljs-string {
  color: #5d6b22;
}
:root[data-theme="light"] .hljs-number {
  color: #8a6420;
}
:root[data-theme="light"] .hljs-title,
:root[data-theme="light"] .hljs-title.function_ {
  color: #2b5c8f;
}
:root[data-theme="light"] .hljs-built_in,
:root[data-theme="light"] .hljs-type {
  color: #7a3f99;
}
:root[data-theme="light"] .hljs-attr,
:root[data-theme="light"] .hljs-params,
:root[data-theme="light"] .hljs-variable {
  color: #57544a;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .hljs-keyword,
  :root:not([data-theme="dark"]) .hljs-literal {
    color: #b4561a;
  }
  :root:not([data-theme="dark"]) .hljs-string {
    color: #5d6b22;
  }
  :root:not([data-theme="dark"]) .hljs-number {
    color: #8a6420;
  }
  :root:not([data-theme="dark"]) .hljs-title,
  :root:not([data-theme="dark"]) .hljs-title.function_ {
    color: #2b5c8f;
  }
  :root:not([data-theme="dark"]) .hljs-built_in,
  :root:not([data-theme="dark"]) .hljs-type {
    color: #7a3f99;
  }
  :root:not([data-theme="dark"]) .hljs-attr,
  :root:not([data-theme="dark"]) .hljs-params,
  :root:not([data-theme="dark"]) .hljs-variable {
    color: #57544a;
  }
}

/* Inline edit of a sent message */
.edit-box {
  width: min(85%, 640px);
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--composer-shadow);
  padding: 12px;
}
.edit-box textarea {
  width: 100%;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  line-height: 1.6;
  min-height: 60px;
}
.edit-box .row {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

/* ---------- Projects ---------- */
.page {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px 48px;
}
.page-inner {
  max-width: 1040px;
  margin: 0 auto;
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 12px 0 26px;
}
.page-head h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.page-head p {
  margin: 4px 0 0;
  color: var(--text-2);
  font-size: 14px;
}
.search-input {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  padding: 0 14px 0 40px;
  outline: 0;
  margin-bottom: 20px;
}
.search-field {
  position: relative;
}
.search-field svg {
  position: absolute;
  left: 13px;
  top: 13px;
  color: var(--text-3);
}
.search-input:focus {
  border-color: var(--accent-ring);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 150px;
  padding: 20px;
  border-radius: 18px;
  border: 1px solid var(--border-strong);
  background: linear-gradient(160deg, var(--surface), var(--surface-2));
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease), box-shadow 0.2s, border-color 0.2s;
  overflow: hidden;
}
.project-card::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
}
.project-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-ring);
  box-shadow: var(--shadow);
}
.project-card h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.project-card p {
  margin: 0;
  color: var(--text-2);
  font-size: 13.5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.project-card .meta {
  margin-top: auto;
  font-size: 12px;
  color: var(--text-3);
}
.empty-state {
  text-align: center;
  padding: 64px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: 20px;
  color: var(--text-2);
}
.empty-state h3 {
  margin: 12px 0 6px;
  font-weight: 500;
  color: var(--text);
}
.empty-state p {
  margin: 0 0 18px;
  font-size: 14px;
}
.empty-state img {
  width: 40px;
  opacity: 0.9;
}

.project-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 28px;
  align-items: start;
}
.project-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 6px;
}
.project-title h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.project-desc {
  color: var(--text-2);
  margin: 0 0 22px;
}
.project-chats {
  margin-top: 26px;
}
.project-chats h4,
.panel h4 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
}
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 8px;
  transition: border-color 0.15s;
}
.list-row:hover {
  border-color: var(--border-strong);
}
.list-row .t {
  font-size: 14px;
  font-weight: 500;
}
.list-row .s {
  font-size: 12px;
  color: var(--text-3);
}
.panel {
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  padding: 16px;
  margin-bottom: 14px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.panel-head h4 {
  margin: 0;
}
.panel .instructions {
  font-size: 13px;
  color: var(--text-2);
  white-space: pre-wrap;
  max-height: 200px;
  overflow: auto;
}
.panel .muted {
  font-size: 13px;
  color: var(--text-3);
}
.kfile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
}
.kfile:hover {
  background: var(--surface-3);
}
.kfile .file-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 9.5px;
  font-weight: 600;
  flex: none;
}
.kfile .n {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kfile .icon-btn {
  opacity: 0;
}
.kfile:hover .icon-btn {
  opacity: 1;
}

/* ---------- Menus, modals, toasts ---------- */
.menu {
  position: fixed;
  z-index: 60;
  min-width: 200px;
  padding: 6px;
  border-radius: 14px;
  background: var(--glass);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  animation: pop 0.16s var(--ease);
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 13.5px;
  text-align: left;
  color: var(--text);
}
.menu-item:hover,
.menu-item.focus {
  background: var(--surface-3);
}
.menu-item.danger {
  color: var(--danger);
}
.menu-item .desc {
  display: block;
  font-size: 12px;
  color: var(--text-3);
}
.menu-item .check {
  margin-left: auto;
  color: var(--accent-text);
}
.menu-sep {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}
.menu-label {
  padding: 6px 10px 4px;
  font-size: 11.5px;
  color: var(--text-3);
}
.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  margin: 2px 6px 6px;
  border-radius: 10px;
  background: var(--surface-3);
}
.seg button {
  flex: 1;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-2);
}
.seg button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(5, 6, 6, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 16px;
  animation: fade-in 0.18s ease;
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
}
.modal {
  width: min(520px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  padding: 22px;
  animation: pop 0.22s var(--ease);
}
.modal.wide {
  width: min(820px, 100%);
}
.modal h2 {
  margin: 0 0 6px;
  font-size: 19px;
  font-weight: 500;
}
.modal .sub {
  margin: 0 0 18px;
  color: var(--text-2);
  font-size: 14px;
}
.modal .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
.field {
  display: block;
  margin-bottom: 14px;
}
.field span {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-2);
}
.field input,
.field textarea,
.field select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  padding: 10px 12px;
  outline: 0;
  line-height: 1.5;
}
.field textarea {
  resize: vertical;
  min-height: 90px;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent-ring);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-modal {
  padding: 0;
  overflow: hidden;
  width: min(620px, 100%);
}
.search-modal .search-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.search-modal input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
}
.search-results {
  max-height: 420px;
  overflow-y: auto;
  padding: 8px;
}
.search-results .menu-item .when {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.stat {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.stat .k {
  font-size: 12px;
  color: var(--text-3);
}
.stat .v {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table th,
.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.data-table th {
  color: var(--text-3);
  font-weight: 500;
  font-size: 12px;
}
.data-table td.num,
.data-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.toasts {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: pop 0.2s var(--ease);
  max-width: min(520px, calc(100vw - 32px));
}
.toast.error {
  background: var(--danger);
  color: #fff;
}

.drop-overlay {
  position: absolute;
  inset: 8px;
  z-index: 30;
  display: none;
  place-items: center;
  border-radius: 24px;
  border: 2px dashed var(--accent);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(6px);
}
.drop-overlay.show {
  display: grid;
}
.drop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
}
.drop-card svg {
  width: 40px;
  height: 40px;
  color: var(--accent);
}
.drop-card strong {
  color: var(--text);
  font-size: 17px;
  font-weight: 500;
}

/* ---------- Responsive ---------- */
@container (max-width: 560px) {
  .tool-btn.on .label {
    display: none;
  }
}
@media (max-width: 1100px) {
  .project-layout {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    margin-left: 0 !important;
    box-shadow: var(--shadow-lg);
  }
  .app.mobile-open .sidebar {
    transform: none;
  }
  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 15;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }
  .app.mobile-open .scrim {
    opacity: 1;
    pointer-events: auto;
  }
  #open-sidebar-btn {
    display: inline-grid !important;
  }
  #collapse-btn {
    display: none;
  }
  .mobile-only {
    display: inline-grid;
  }
  .project-layout {
    grid-template-columns: 1fr;
  }
  .page {
    padding: 8px 16px 40px;
  }
  .thread {
    padding: 8px 12px 20px;
  }
  .chat-footer {
    padding: 0 10px 10px;
  }
  .msg-assistant {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .msg-assistant .mark {
    width: 26px;
    height: 26px;
  }
  .tool-btn.on .label {
    display: none;
  }
  .msg-actions {
    opacity: 1;
  }
}

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

/* ---------- Code steps, generated files, allowance ---------- */
.steps {
  border-top: 1px solid var(--border);
  max-height: 380px;
  overflow-y: auto;
  padding: 8px 12px 12px;
}
.step + .step {
  margin-top: 12px;
}
.step-label {
  font-size: 11.5px;
  color: var(--text-3);
  margin-bottom: 4px;
}
.step pre {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--code-bg);
  border: 1px solid var(--border);
}
.step .step-out {
  margin-top: 6px;
  color: var(--text-2);
  max-height: 180px;
  overflow: auto;
}
.outputs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.outputs .attachments {
  margin: 0;
}
.output-image {
  margin: 0;
  min-height: 60px;
  display: grid;
  place-items: center;
}
.output-image img {
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
}
.file-chip.downloadable {
  cursor: pointer;
  padding-right: 40px;
  transition: border-color 0.15s, background 0.15s;
}
.file-chip.downloadable:hover {
  border-color: var(--accent-ring);
  background: var(--accent-soft);
}
.file-chip .dl {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent-text);
}
.spend {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  margin-bottom: 18px;
}
.spend-head {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  margin-bottom: 8px;
}
.spend-track {
  height: 8px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
}
.spend-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--olivine), #a4b65a);
}
.spend-fill.high {
  background: linear-gradient(90deg, #e8843a, var(--accent));
}
.spend-fill.full {
  background: var(--danger);
}
.spend-note {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--text-3);
}
.limit-btn {
  height: 28px;
  padding: 0 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Artifacts ---------- */
.artifact-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(100%, 420px);
  margin: 4px 0 14px;
  padding: 10px 14px 10px 10px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, transform 0.15s var(--ease), box-shadow 0.15s;
}
.artifact-card:hover {
  border-color: var(--accent-ring);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.artifact-icon {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 17px;
  font-weight: 600;
}
.artifact-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}
.artifact-title {
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.artifact-sub {
  font-size: 12px;
  color: var(--text-3);
}
.artifact-card.writing .artifact-sub {
  color: var(--accent-text);
}
.artifact-panel {
  width: min(50%, 820px);
  flex: none;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--surface);
  animation: slide-in 0.25s var(--ease);
}
@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
}
.ap-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 10px 10px 16px;
  border-bottom: 1px solid var(--border);
}
.ap-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.ap-title strong {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ap-type {
  font-size: 12px;
  color: var(--text-3);
}
.ap-version {
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  padding: 0 6px;
  font-size: 12.5px;
}
.ap-tabs {
  margin: 0 4px;
}
.ap-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--surface);
}
.ap-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  display: block;
}
.ap-code {
  margin: 0;
  padding: 16px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  min-height: 100%;
  background: var(--code-bg);
  white-space: pre;
}
.ap-doc {
  padding: 24px 28px;
  max-width: 760px;
}
.icon-btn.active {
  color: var(--success);
}
@media (max-width: 1000px) {
  .artifact-panel {
    position: fixed;
    inset: 0;
    width: auto;
    z-index: 40;
  }
}

/* ---------- Research, sharing, memory ---------- */
.research-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--accent-text);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 9px 2px 7px;
}
.research-tag svg {
  width: 13px;
  height: 13px;
}
.share-btn {
  height: 30px;
  font-size: 13px;
  margin-left: auto;
  flex: none;
}
.topbar-title .title-btn {
  min-width: 0;
}
.link-row {
  display: flex;
  gap: 8px;
}
.link-row input {
  flex: 1;
  min-width: 0;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  padding: 0 12px;
  font-size: 13px;
}
.danger-text {
  color: var(--danger);
}
.share-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid var(--accent-ring);
  background: var(--accent-soft);
}
.share-banner div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.share-banner span {
  font-size: 13px;
  color: var(--text-2);
}
.switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex: none;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch span {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  cursor: pointer;
  transition: background 0.2s;
}
.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s var(--ease);
}
.switch input:checked + span {
  background: var(--accent);
  border-color: transparent;
}
.switch input:checked + span::after {
  transform: translateX(18px);
}
.mem-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 50vh;
  overflow-y: auto;
}
.mem-file {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}
.mem-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 6px 6px 12px;
  font-size: 13px;
  font-weight: 500;
}
.mem-file pre {
  margin: 0;
  padding: 0 12px 12px;
  font-family: var(--font);
  font-size: 13px;
  white-space: pre-wrap;
  color: var(--text-2);
}
.check-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
}
.check-row input {
  margin-top: 4px;
  accent-color: var(--accent);
}
.check-row span {
  display: flex;
  flex-direction: column;
  font-size: 13.5px;
}
.check-row em {
  font-style: normal;
  color: var(--text-3);
  font-size: 12.5px;
}
.badge {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--accent-text);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 3px 10px 3px 8px;
}
.badge svg {
  width: 13px;
  height: 13px;
}
.project-share-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: -10px 0 20px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 13px;
  color: var(--text-2);
}
.project-share-note svg {
  color: var(--accent-text);
  margin-top: 2px;
}
.search-hit {
  align-items: flex-start;
}
.hit-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.hit-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hit-snippet {
  font-size: 12px;
  color: var(--text-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.hit-snippet:empty {
  display: none;
}
.hit-snippet mark {
  background: var(--accent-soft);
  color: var(--accent-text);
  border-radius: 3px;
  padding: 0 2px;
}
@container (max-width: 640px) {
  .tool-btn.on .label {
    display: none;
  }
}
.ap-diagram {
  height: 100%;
  display: grid;
  place-items: center;
}
.ap-error {
  padding: 24px;
  color: var(--text-2);
  font-size: 14px;
}
