/* Inter variable font — local, no CDN */
@font-face {
  font-family: "Inter";
  src: url("/vendor/fonts/InterVariable.woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* =========================================================
   Claude Remote — shadcn/zinc-inspired design system
   Plain CSS, semantic tokens, light + dark via [data-theme]
   ========================================================= */

/* ---------- Design tokens ---------- */
:root {
  /* zinc light (shadcn v4 values, hex equivalents) */
  --background: #ffffff;
  --foreground: #09090b;
  --card: #ffffff;
  --card-foreground: #09090b;
  --popover: #ffffff;
  --popover-foreground: #09090b;
  --primary: #18181b;
  --primary-foreground: #fafafa;
  --secondary: #f4f4f5;
  --secondary-foreground: #18181b;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;   /* ≥4.5:1 on card */
  --accent: #f4f4f5;
  --accent-foreground: #18181b;
  --destructive: #dc2626;
  --destructive-foreground: #ffffff;
  --success: #16a34a;
  --warning: #d97706;
  --info: #2563eb;
  --border: #e4e4e7;
  --input: #e4e4e7;
  --ring: #a1a1aa;
  --sidebar: #fafafa;
  --sidebar-foreground: #09090b;
  --sidebar-accent: #ececee;

  --radius: 10px;
  --radius-sm: calc(var(--radius) - 4px);
  --radius-md: calc(var(--radius) - 2px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 4px);

  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-fa: Vazirmatn, var(--font-sans);
}

[data-theme="dark"] {
  --background: #09090b;
  --foreground: #fafafa;
  --card: #111113;
  --card-foreground: #fafafa;
  --popover: #18181b;
  --popover-foreground: #fafafa;
  --primary: #fafafa;
  --primary-foreground: #18181b;
  --secondary: #27272a;
  --secondary-foreground: #fafafa;
  --muted: #27272a;
  --muted-foreground: #a1a1aa;
  --accent: #27272a;
  --accent-foreground: #fafafa;
  --destructive: #ef4444;
  --destructive-foreground: #ffffff;
  --success: #4ade80;
  --warning: #fbbf24;
  --info: #60a5fa;
  --border: rgb(255 255 255 / 0.10);   /* translucent white — shadcn dark convention */
  --input: rgb(255 255 255 / 0.15);
  --ring: #71717a;
  --sidebar: #101012;
  --sidebar-foreground: #fafafa;
  --sidebar-accent: #232326;
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
}

/* Themed scrollbars everywhere (mistake I2) */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 9999px;
}
*::-webkit-scrollbar-thumb:hover { filter: brightness(0.85); }
[data-theme="dark"] *::-webkit-scrollbar-thumb:hover { background: rgb(255 255 255 / 0.22); }

/* Visible focus ring per theme (mistakes S1/A3) */
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection { background: color-mix(in oklab, var(--primary) 20%, transparent); }

.text-muted { color: var(--muted-foreground); }
.hidden { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

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

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; white-space: nowrap;
  height: 36px; padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer;
  transition: background-color .12s ease, color .12s ease, border-color .12s ease, opacity .12s ease;
  user-select: none;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 45%, transparent); }

.btn-default { background: var(--primary); color: var(--primary-foreground); }
.btn-default:hover:not(:disabled) { background: color-mix(in oklab, var(--primary) 88%, var(--primary-foreground)); }
[data-theme="dark"] .btn-default:hover:not(:disabled) { background: color-mix(in oklab, var(--primary) 85%, var(--primary-foreground)); }

.btn-outline {
  border-color: var(--input); background: var(--background);
  box-shadow: var(--shadow-xs);
}
.btn-outline:hover:not(:disabled) { background: var(--accent); color: var(--accent-foreground); }
[data-theme="dark"] .btn-outline { background: color-mix(in oklab, var(--input) 30%, transparent); }
[data-theme="dark"] .btn-outline:hover:not(:disabled) { background: color-mix(in oklab, var(--input) 50%, transparent); }

.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.btn-secondary:hover:not(:disabled) { background: color-mix(in oklab, var(--secondary) 80%, var(--background)); }

.btn-ghost { background: transparent; color: var(--foreground); }
.btn-ghost:hover:not(:disabled) { background: var(--accent); color: var(--accent-foreground); }
[data-theme="dark"] .btn-ghost:hover:not(:disabled) { background: color-mix(in oklab, var(--accent) 50%, transparent); }

.btn-destructive { background: var(--destructive); color: var(--destructive-foreground); }
.btn-destructive:hover:not(:disabled) { background: color-mix(in oklab, var(--destructive) 88%, black); }

.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled,
.btn[aria-busy="true"],
.btn[aria-disabled="true"] {
  opacity: 0.5; cursor: not-allowed; pointer-events: auto;
}
.btn[aria-busy="true"]:active { transform: none; }

.btn-sm { height: 32px; padding: 0 12px; gap: 6px; font-size: 13px; }
.btn-icon { width: 36px; height: 36px; padding: 0; }
.btn-icon-sm { width: 32px; height: 32px; padding: 0; flex-shrink: 0; }
.btn-block { width: 100%; }

/* spinner for busy buttons */
.btn[aria-busy="true"]::before {
  content: "";
  width: 14px; height: 14px; flex-shrink: 0;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 9999px;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; width: fit-content;
  border-radius: 9999px;
  border: 1px solid transparent;
  padding: 2px 8px;
  font-size: 12px; font-weight: 500;
  white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; }
.badge-default { background: var(--primary); color: var(--primary-foreground); }
.badge-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.badge-outline { border-color: var(--border); color: var(--foreground); }
.badge-success { background: color-mix(in oklab, var(--success) 15%, transparent); color: var(--success); border-color: color-mix(in oklab, var(--success) 35%, transparent); }
.badge-warning { background: color-mix(in oklab, var(--warning) 15%, transparent); color: var(--warning); border-color: color-mix(in oklab, var(--warning) 35%, transparent); }
.badge-info { background: color-mix(in oklab, var(--info) 15%, transparent); color: var(--info); border-color: color-mix(in oklab, var(--info) 35%, transparent); }
.badge-destructive { background: color-mix(in oklab, var(--destructive) 15%, transparent); color: var(--destructive); border-color: color-mix(in oklab, var(--destructive) 35%, transparent); }

.status-dot {
  width: 7px; height: 7px; border-radius: 9999px; flex-shrink: 0;
  background: var(--muted-foreground);
}
.status-dot.idle { background: var(--success); }
.status-dot.busy { background: var(--info); animation: pulse 1.4s ease-in-out infinite; }
.status-dot.permission { background: var(--warning); animation: pulse 1.4s ease-in-out infinite; }
.status-dot.dead { background: var(--muted-foreground); opacity: .55; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- Inputs ---------- */
.input, textarea.input {
  height: 36px;
  width: 100%;
  min-width: 0;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--input);
  background: transparent;
  color: var(--foreground);
  font-family: inherit; font-size: 14px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
[data-theme="dark"] .input { background: color-mix(in oklab, var(--input) 25%, transparent); }
.input::placeholder, textarea.input::placeholder { color: var(--muted-foreground); }
.input:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 40%, transparent);
}

/* ---------- Cards ---------- */
.card {
  display: flex; flex-direction: column; gap: 24px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--card-foreground);
  padding-block: 24px;
  box-shadow: var(--shadow-xs);
}

/* ---------- Alerts ---------- */
.alert-destructive {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in oklab, var(--destructive) 35%, transparent);
  background: color-mix(in oklab, var(--destructive) 10%, transparent);
  color: var(--destructive);
  font-size: 13px;
}

/* =========================================================
   Login
   ========================================================= */
.login-view {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background:
    radial-gradient(1200px 600px at 70% -10%, color-mix(in oklab, var(--primary) 5%, transparent), transparent),
    var(--background);
}
.login-card { width: min(380px, 100%); padding: 28px; gap: 16px; }
.login-brand { display: flex; align-items: center; gap: 12px; }
.login-brand h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.login-brand p { margin: 2px 0 0; font-size: 13px; }
.field label {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 500;
}
.brand-icon {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--primary); color: var(--primary-foreground);
}
.brand-icon svg { width: 18px; height: 18px; }

/* =========================================================
   Shell layout (grid rows, 100dvh — mistake L1)
   ========================================================= */
.shell {
  display: grid;
  grid-template-columns: 256px 1fr;
  height: 100vh;
  height: 100dvh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  display: flex; flex-direction: column;
  background: var(--sidebar);
  color: var(--sidebar-foreground);
  min-height: 0;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 8px;
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; letter-spacing: -0.01em;
}
.sidebar-content {
  flex: 1; min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.sidebar-group-label {
  margin: 4px 8px 2px;
  font-size: 12px; font-weight: 500;
  color: var(--muted-foreground);
}
.session-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 2px;
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  height: 32px;
  padding: 0 8px;
  border-radius: var(--radius-md);
  border: 0;
  background: transparent;
  color: inherit;
  font-family: inherit; font-size: 14px;
  text-align: start;
  cursor: pointer;
  transition: background-color .1s ease;
}
.nav-item:hover { background: var(--sidebar-accent); }
.nav-item.active {
  background: var(--sidebar-accent);
  font-weight: 500;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.icon-moon { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="dark"] .icon-sun { display: none; }

.session-item { position: relative; }
.session-item .nav-item { height: auto; padding: 8px; align-items: flex-start; }
.session-meta { flex: 1; min-width: 0; }
.session-row {
  display: flex; align-items: center; gap: 8px;
}
.session-name {
  font-weight: 500; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.session-time { margin-inline-start: auto; font-size: 11px; color: var(--muted-foreground); flex-shrink: 0; }
.session-sub {
  display: flex; align-items: center; gap: 6px;
  margin-top: 2px;
  color: var(--muted-foreground); font-size: 12px;
  min-width: 0;
}
.session-note {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  direction: rtl; text-align: end;
}
.session-status-label { flex-shrink: 0; }

.sidebar-footer {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px;
  border-top: 1px solid var(--border);
}

.sidebar-backdrop {
  position: fixed; inset: 0; z-index: 39;
  background: rgb(0 0 0 / 0.5);
}

.only-mobile { display: none; }

/* ---------- Main column ---------- */
.main {
  display: grid;
  grid-template-rows: 1fr;
  min-width: 0; min-height: 0;
  position: relative;
}
.empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 8px;
  padding: 32px;
  text-align: center;
}
.empty-state h2 { margin: 4px 0 0; font-size: 16px; font-weight: 600; }
.empty-state p { margin: 0; max-width: 320px; }
.empty-icon {
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  border-radius: var(--radius-xl);
  border: 1px dashed var(--border);
  color: var(--muted-foreground);
}
.empty-icon svg { width: 22px; height: 22px; }

.session-view {
  display: grid;
  grid-template-rows: auto 1fr auto;   /* topbar / transcript / composer (mistake L1) */
  min-height: 0;
  position: relative;
}

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  min-height: 52px;
}
.topbar-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-title h2 {
  margin: 0; font-size: 15px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-actions {
  display: flex; align-items: center; gap: 8px;
  margin-inline-start: auto;
}
.note-input { width: 200px; height: 32px; font-size: 13px; direction: rtl; }
.note-input::placeholder { direction: ltr; text-align: left; }

/* Transcript scroller */
.chat-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;             /* no layout shift when bar appears (I2) */
  min-height: 0;
  position: relative;
}
.chat-messages {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 16px 28px;
  display: flex; flex-direction: column; gap: 16px;
}
.chat-empty { padding: 48px 16px; text-align: center; }
.chat-loading { max-width: 800px; margin: 0 auto; padding: 20px 16px; display: flex; flex-direction: column; gap: 14px; }
.skeleton {
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--muted) 25%, var(--accent) 50%, var(--muted) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
}
.skeleton.skel-user { width: 55%; margin-inline-start: auto; }
.skeleton.skel-assistant.short { width: 65%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Message bubbles ---------- */
.msg { display: flex; flex-direction: column; min-width: 0; }
.msg-role {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 11px; font-weight: 500;
  color: var(--muted-foreground);
  padding-inline: 2px;
}
.msg-role .t { font-weight: 400; }
.msg-role time { unicode-bidi: isolate; }

.msg-user { align-items: flex-end; }     /* user bubble hugs the end side */
.msg-assistant { align-items: stretch; }

.bubble {
  min-width: 0;
  max-width: 88%;
  padding: 9px 13px;
  border-radius: var(--radius-lg);
  overflow-wrap: anywhere;               /* long URLs never blow out layout (L2) */
  word-break: normal;
}
.msg-user .bubble {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border-end-end-radius: var(--radius-sm);
}
.msg-assistant .bubble {
  max-width: 100%;
  padding: 2px;
}
.bubble p { margin: 0 0 .6em; }
.bubble > :last-child { margin-bottom: 0 !important; }

/* markdown content */
.bubble pre, .bubble code {
  direction: ltr; unicode-bidi: isolate; text-align: left;
  font-family: var(--font-mono); font-size: 12.5px;
}
.bubble :not(pre) > code {
  background: color-mix(in oklab, var(--foreground) 8%, transparent);
  padding: 1px 5px; border-radius: var(--radius-sm);
}
.code-wrap { position: relative; margin: .6em 0; }
.code-wrap pre {
  margin: 0;
  background: var(--popover);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  overflow-x: auto;
  white-space: pre-wrap;
  max-width: 100%;
}
.copy-btn {
  position: absolute; inset-block-start: 6px; inset-inline-end: 6px;
  opacity: 0;
  transition: opacity .12s ease;
}
.code-wrap:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.bubble ul, .bubble ol { margin: .4em 0; padding-inline-start: 1.4em; }
.bubble blockquote {
  margin: .5em 0;
  padding-inline-start: 12px;
  border-inline-start: 3px solid var(--border);
  color: var(--muted-foreground);
}
.bubble table { border-collapse: collapse; direction: ltr; margin: .6em 0; font-size: 13px; max-width: 100%; display: block; overflow-x: auto; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 5px 10px; }
.bubble img { max-width: 100%; height: auto; border-radius: var(--radius-md); }
[data-theme="dark"] .bubble img { filter: brightness(.92); }        /* anti-glare (D3) */
.bubble a { color: var(--info); text-underline-offset: 3px; }
.bubble h1, .bubble h2, .bubble h3, .bubble h4 { font-size: 1em; font-weight: 600; margin: .7em 0 .3em; }

/* thinking block */
.thinking { margin: 0; font-size: 13px; color: var(--muted-foreground); }
.thinking summary {
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  list-style: none;
  border-radius: var(--radius-sm);
  padding: 2px 4px;
}
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary:hover { background: var(--accent); color: var(--accent-foreground); }
.thinking summary svg { width: 14px; height: 14px; }
.thinking-body {
  margin: 6px 0 0;
  padding: 8px 12px;
  border-inline-start: 2px solid var(--border);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* tool cards */
.tool-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  overflow: hidden;
  margin: 4px 0;
  font-size: 13px;
}
.tool-head {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  cursor: pointer;
  user-select: none;
  direction: ltr;
}
.tool-head:hover { background: var(--accent); color: var(--accent-foreground); }
.tool-head svg.chev { width: 14px; height: 14px; margin-inline-start: auto; transition: transform .12s ease; flex-shrink: 0; }
.tool-card.open .tool-head svg.chev { transform: rotate(180deg); }
.tool-name { font-weight: 500; font-family: var(--font-mono); font-size: 12px; }
.tool-summary {
  color: var(--muted-foreground); font-size: 11.5px;
  font-family: var(--font-mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
  min-width: 0;
}
.tool-body {
  display: none;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  direction: ltr; text-align: left;
  font-family: var(--font-mono); font-size: 12px;
  white-space: pre-wrap; word-break: break-all;
  color: var(--muted-foreground);
  max-height: 280px; overflow-y: auto;
}
.tool-card.open .tool-body { display: block; }

/* new messages pill (mistake L4) */
.pill {
  position: absolute;
  bottom: calc(100% + 0px);
  inset-inline-start: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 14px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--popover); color: var(--popover-foreground);
  font-family: inherit; font-size: 12px; font-weight: 500;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
}
.pill:hover { background: var(--accent); }
.pill svg { width: 14px; height: 14px; }
.session-view { position: relative; }
#new-msg-pill { bottom: 148px; }

/* ---------- Composer ---------- */
.composer {
  position: relative;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--background);
}
/* live turn indicator — Claude Code style "✽ Zigzagging… (2m 4s · ↓ 348 tokens)" */
.live-indicator {
  position: absolute;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  top: -30px;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 12px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--popover);
  color: var(--popover-foreground);
  font-size: 12px; font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  z-index: 6;
}
.li-spinner {
  display: inline-block;
  color: var(--foreground);
  animation: li-spin 0.9s steps(8) infinite;
}
@keyframes li-spin { to { transform: rotate(360deg); } }
.li-stats { color: var(--muted-foreground); font-weight: 400; unicode-bidi: isolate; }
.composer-card {
  max-width: 800px;
  margin: 0 auto;
  border: 1px solid var(--input);
  border-radius: var(--radius-xl);
  background: var(--card);
  box-shadow: var(--shadow-xs);
  transition: border-color .12s ease;
}
.composer-card:focus-within {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 30%, transparent);
}
.attach-strip {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 10px 10px 0;
}
.attach-thumb { position: relative; }
.attach-thumb img {
  display: block;
  width: 56px; height: 56px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.attach-thumb button {
  position: absolute; inset-block-start: -6px; inset-inline-end: -6px;
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9999px;
  border: 0;
  background: var(--destructive); color: var(--destructive-foreground);
  font-size: 10px; line-height: 1;
  cursor: pointer;
}
.composer-row {
  display: flex; align-items: flex-end; gap: 4px;
  padding: 6px;
}
#composer-text {
  flex: 1;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--foreground);
  font-family: var(--font-fa);
  font-size: 14.5px;
  line-height: 1.6;
  max-height: 160px;
  padding: 6px 6px;
  unicode-bidi: plaintext;
  text-align: start;
}
#composer-text::placeholder { color: var(--muted-foreground); }
.composer-hint {
  max-width: 800px;
  margin: 6px auto 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted-foreground);
}
.composer-hint b { font-weight: 500; color: var(--foreground); }

/* drag-over highlight */
body.dragging-over .composer-card {
  border-color: var(--info);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--info) 25%, transparent);
}

/* ---------- Terminal pane ---------- */
.term-pane {
  display: flex; flex-direction: column;
  height: 42%;
  border-top: 1px solid var(--border);
  background: var(--popover);
  min-height: 0;
}
.term-head {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted-foreground);
}
.term-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.term-title svg { width: 14px; height: 14px; }
.term-link {
  margin-inline-start: auto;
  color: var(--info);
  text-decoration: none;
  font-size: 12px;
}
.term-link:hover { text-decoration: underline; }
.term-frame { flex: 1; width: 100%; border: 0; background: var(--background); min-height: 0; }

/* ---------- Toasts (mistake I5) ---------- */
.toasts {
  position: fixed;
  bottom: 16px;
  inset-inline-end: 16px;
  z-index: 60;
  display: flex; flex-direction: column; gap: 8px;
  max-width: min(340px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--popover);
  color: var(--popover-foreground);
  font-size: 13px;
  box-shadow: var(--shadow-xs);
  animation: toast-in .18s ease-out;
}
.toast.success { border-color: color-mix(in oklab, var(--success) 40%, transparent); }
.toast.error { border-color: color-mix(in oklab, var(--destructive) 40%, transparent); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
}

/* =========================================================
   Mobile (mistake L1/L3)
   ========================================================= */
@media (max-width: 768px) {
  .shell { grid-template-columns: 1fr; }
  .only-mobile { display: inline-flex; }

  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: 40;
    width: min(300px, 84vw);
    transform: translateX(-105%);
    transition: transform .22s ease;
    border-inline-end: 1px solid var(--border);
  }
  [dir="rtl"] .sidebar { transform: translateX(105%); inset-inline-start: auto; inset-inline-end: 0; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open { overflow: hidden; }

  .topbar { padding: 8px 10px; }
  .note-input { display: none; }
  .chat-messages { padding: 14px 10px 22px; }
  .composer { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
  .composer-hint { display: none; }
  #new-msg-pill { bottom: 110px; }
}

/* ---------- Syntax highlighting (dual-theme, mistake D4) ---------- */
/* Scoped highlight.js token colors driven by theme tokens */
.hljs { color: var(--foreground); background: transparent; }
:root, [data-theme="light"] {
  --hl-comment: #6e7781; --hl-keyword: #cf222e; --hl-string: #0a3069;
  --hl-number: #0550ae;  --hl-title: #8250df;   --hl-attr: #953800;
}
[data-theme="dark"] {
  --hl-comment: #8b949e; --hl-keyword: #ff7b72; --hl-string: #a5d6ff;
  --hl-number: #79c0ff;  --hl-title: #d2a8ff;   --hl-attr: #ffa657;
}
.hljs-comment, .hljs-quote { color: var(--hl-comment); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-doctag,
.hljs-name, .hljs-meta .hljs-keyword { color: var(--hl-keyword); }
.hljs-string, .hljs-regexp, .hljs-addition { color: var(--hl-string); }
.hljs-number, .hljs-symbol, .hljs-bullet { color: var(--hl-number); }
.hljs-title, .hljs-section, .hljs-title.function_ { color: var(--hl-title); }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable,
.hljs-type, .hljs-class .hljs-title { color: var(--hl-attr); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 600; }
