
/* Site tokens are thin aliases over brand.css (the single source of truth). Light/dark switching
   happens in brand.css (explicit data-theme, or the OS when unset), so nothing here re-declares
   colours per theme. */
/* Arabic: self-hosted Cairo (variable weight). unicode-range limits it to Arabic code points, so
   Latin text keeps Inter/Montserrat and no extra bytes load for English users. */
@font-face {
  font-family: 'Cairo'; font-style: normal; font-weight: 200 1000; font-display: swap;
  src: url('cairo-arabic.woff2') format('woff2');
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
:root {
  --bg: var(--brand-ink-0); --bg-2: var(--brand-ink-1); --panel: var(--brand-ink-2);
  --raised: var(--brand-ink-3);
  --border: var(--brand-line); --border-strong: var(--brand-line-strong);
  --text: var(--brand-text); --muted: var(--brand-text-2); --faint: var(--brand-text-3);
  --accent: var(--brand-violet-500); --accent-hover: var(--brand-violet-400);
  --accent-text: var(--brand-violet-text);
  --danger: var(--brand-danger); --danger-bg: color-mix(in srgb, var(--brand-danger) 14%, transparent);
  --success: var(--brand-ok); --success-bg: color-mix(in srgb, var(--brand-ok) 14%, transparent);
  --shadow-sm: 0 2px 8px rgba(2, 4, 20, 0.35);
  --shadow-md: 0 10px 28px rgba(2, 4, 20, 0.45);
  --shadow-lg: 0 24px 64px rgba(2, 4, 20, 0.55);

  --font-sans: 'Cairo', var(--brand-font-ui);
  --font-display: 'Cairo', var(--brand-font-display);
  --font-serif: 'Cairo', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --font-mono: var(--brand-font-mono);
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px;
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px; --radius-xl: 18px;
}
:root[data-theme="light"] {
  --shadow-sm: 0 2px 8px rgba(40, 30, 120, 0.06);
  --shadow-md: 0 8px 24px rgba(40, 30, 120, 0.10);
  --shadow-lg: 0 20px 60px rgba(40, 30, 120, 0.14);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --shadow-sm: 0 2px 8px rgba(40, 30, 120, 0.06);
    --shadow-md: 0 8px 24px rgba(40, 30, 120, 0.10);
    --shadow-lg: 0 20px 60px rgba(40, 30, 120, 0.14);
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 var(--font-sans); -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; }
:focus-visible { outline: 2px solid var(--brand-violet-400); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 12px 20px; font-weight: 600; font-size: 15px; cursor: pointer;
  transition: all 0.2s;
}
.btn:hover { border-color: var(--border-strong); }
.btn { font-family: var(--font-display); letter-spacing: 0; }
.btn-primary {
  background: var(--brand-grad); color: #ffffff; border-color: transparent;
  box-shadow: 0 6px 22px color-mix(in srgb, var(--brand-violet-500) 38%, transparent), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn-primary:hover { background: var(--brand-grad-hover); border-color: transparent; }

.topbar {
  position: sticky; top: 0; z-index: 10; backdrop-filter: blur(14px) saturate(1.2);
  background: color-mix(in srgb, var(--bg) 82%, transparent); border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: inline-flex; align-items: center; line-height: 0; }
.brand .brand-logo { height: 36px; }
.chat-brand .brand-logo { height: 30px; }
.topnav { display: flex; gap: 30px; font-family: var(--font-display); font-weight: 500; font-size: 14px; color: var(--muted); }
.topnav a:hover { color: var(--text); }
.topnav-cta { padding: 8px 16px; font-size: 14px; }
.topnav-actions { display: flex; align-items: center; gap: 16px; }
.topnav-link { font-size: 14.5px; color: var(--muted); }
.topnav-link:hover { color: var(--text); }

.hero {
  max-width: 780px; margin: 0 auto; padding: 96px 24px 64px; text-align: center;
}
.hero h1 { font-size: 64px; line-height: 1.05; margin: 0 0 24px; letter-spacing: -0.02em; }
.hero-subtitle { font-size: 22px; color: var(--muted); margin: 0 0 40px; max-width: 600px; margin-left: auto; margin-right: auto; }
.hero-ctas { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-ctas .btn { padding: 14px 26px; font-size: 16px; }

.demo { max-width: 980px; margin: 0 auto; padding: 0 24px 70px; }
.demo-frame {
  border-radius: 16px; overflow: hidden; border: 1px solid var(--border);
  box-shadow: 0 40px 100px rgba(0,0,0,0.45); line-height: 0;
}
.demo-video { display: block; width: 100%; height: auto; }

.features { max-width: 1080px; margin: 0 auto; padding: 40px 24px 80px; }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.feature-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px;
  transition: transform 0.2s, border-color 0.2s;
}
.feature-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.feature-icon { font-size: 28px; margin-bottom: 12px; }
.feature-card h3 { font-size: 17px; margin: 0 0 8px; }
.feature-card p { color: var(--muted); margin: 0; font-size: 14.5px; }

.screenshots { background: var(--bg-2); padding: 60px 0; }
.screenshots-track {
  max-width: 1080px; margin: 0 auto; padding: 0 24px; display: flex; gap: 18px;
  overflow-x: auto; scroll-snap-type: x mandatory;
}
.screenshot-item { flex: 0 0 auto; scroll-snap-align: start; }
.screenshot-item img { display: block; max-height: 420px; border-radius: 12px; border: 1px solid var(--border); }
.screenshot-item figcaption { color: var(--muted); font-size: 13px; margin-top: 8px; text-align: center; }

.download { max-width: 780px; margin: 0 auto; padding: 70px 24px; text-align: center; }
.download h2 { font-size: 32px; margin: 0 0 8px; }
.section-sub { color: var(--muted); margin: 0 0 30px; }
.download-grid { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.download-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 24px; text-align: left; min-width: 240px;
  transition: border-color 0.2s;
}
.download-card:hover { border-color: var(--border-strong); }
.download-card .platform { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.download-card .version { color: var(--muted); font-size: 13px; margin-bottom: 12px; }

.changelog { max-width: 640px; margin: 0 auto; padding: 20px 24px 80px; }
.changelog h2 { font-size: 26px; text-align: center; margin: 0 0 30px; }
.changelog-entry { border-left: 2px solid var(--border); padding: 2px 0 22px 20px; position: relative; }
.changelog-entry::before {
  content: ''; position: absolute; left: -5px; top: 6px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent);
}
.changelog-entry .version { font-weight: 700; font-size: 15px; }
.changelog-entry .date { color: var(--muted); font-size: 13px; margin-left: 8px; }
.changelog-entry p { margin: 6px 0 0; color: var(--muted); font-size: 14.5px; white-space: pre-line; }

.footer {
  border-top: 1px solid var(--border); padding: 28px 24px; text-align: center;
  color: var(--muted); font-size: 13px;
}

.topnav-burger {
  display: none; background: none; border: 0; color: var(--text); font-size: 22px;
  cursor: pointer; line-height: 1; padding: 4px;
}
.topnav-signin-mobile { display: none; }
@media (max-width: 640px) {
  .hero h1 { font-size: 36px; }
  .topnav { display: none; }
  .topnav-burger { display: inline-flex; }
  .topnav.open {
    display: flex; flex-direction: column; gap: 4px; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--bg); border-bottom: 1px solid var(--border); padding: 12px 24px 16px;
    box-shadow: var(--shadow-md); z-index: 20;
  }
  /* Sign in moves into the mobile menu (above) instead of sitting in the topbar, where it was
     crowding the logo against the Download CTA and burger on narrow screens. */
  #signInLink { display: none; }
  .topnav-signin-mobile {
    display: block; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--border);
    color: var(--accent-text); font-weight: 600;
  }
  .topnav-actions { gap: 10px; }
  .topnav-cta { padding: 8px 12px; font-size: 13px; }
  .topnav.open a { padding: 10px 0; font-size: 16px; border-bottom: 1px solid var(--border); }
  .topnav.open a:last-child { border-bottom: 0; }
}

/* ─── Auth modal ─────────────────────────────────────────────────────────── */
.modal-overlay {
  /* Explicit offsets (not the `inset` shorthand) so the fixed overlay pins to the viewport even in
     browsers without `inset` support — otherwise it falls to its static position at the bottom of the
     document (under the footer), which is exactly the "modal appears under the footer" bug. */
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow-y: auto; overscroll-behavior: contain;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 28px; width: 340px; max-width: 100%; position: relative; margin: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,.55);
}
.modal h3 { margin: 0 0 16px; font-size: 19px; }
.settings-input {
  display: block; width: 100%; margin-bottom: 10px; padding: 10px 12px;
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; font: inherit; font-size: 14.5px;
}
.auth-submit-btn { width: 100%; justify-content: center; margin-top: 4px; }
.modal-error { color: var(--danger); font-size: 13px; min-height: 16px; margin-bottom: 4px; }
.auth-switch { text-align: center; font-size: 13.5px; color: var(--muted); margin-top: 16px; }
.auth-switch a { color: var(--accent); }
.modal-close-btn {
  position: absolute; top: 14px; inset-inline-end: 14px; background: none; border: 0;
  color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer;
}
.modal-close-btn:hover { color: var(--text); }
.verify-body { color: var(--muted); font-size: 13.5px; line-height: 1.5; margin: 0 0 14px; }
.verify-status { color: var(--success); font-size: 13px; margin-bottom: 10px; }
.verify-code-input { text-align: center; letter-spacing: 3px; }

/* ─── Chat app ───────────────────────────────────────────────────────────── */
.chat-view { display: flex; height: 100vh; height: 100dvh; }
.chat-sidebar {
  width: 260px; flex: 0 0 260px; background: var(--bg); border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px;
}
.chat-brand { font-family: var(--font-serif); font-weight: 500; letter-spacing: 0.01em; }
.chat-sidebar-top-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.chat-icon-btn {
  background: none; border: 0; color: var(--muted); border-radius: var(--radius-sm);
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  font-size: 13px; cursor: pointer; flex: 0 0 auto; line-height: 1;
}
.chat-icon-btn:hover { color: var(--text); background: var(--panel); }
/* "+ New chat" reads as a quiet, bordered row (Claude/ChatGPT convention) rather than a
   filled accent CTA — it's the FIRST action in the sidebar, not a special one. */
.chat-new-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; margin: 14px 0 10px;
  background: none; border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--text); font: inherit; font-size: 14px; font-weight: 500; padding: 9px 12px; cursor: pointer;
}
.chat-new-btn:hover { background: var(--panel); border-color: var(--border-strong); }
.chat-new-btn:disabled { opacity: 0.55; cursor: default; }
.chat-search-input {
  width: 100%; margin-bottom: 10px; padding: 8px 10px; background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 13.5px;
}
.chat-search-input:focus { outline: none; border-color: var(--border-strong); }
.chat-mode-pill {
  font-size: 12.5px; color: var(--muted); background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; text-align: center;
}
.chat-mode-pill.connected { color: var(--success); border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.chat-mode-pill.warn { color: var(--warning, #fbbf24); border-color: color-mix(in srgb, var(--warning, #fbbf24) 40%, transparent); }
.chat-mode-pill.down { color: var(--danger, #f87171); border-color: color-mix(in srgb, var(--danger, #f87171) 40%, transparent); }
.chat-mode-pill:hover { filter: brightness(1.15); }
.chat-mode-pill:focus-visible { outline: 2px solid var(--accent, #8b5cf6); outline-offset: 2px; }
.link-status { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel); font-weight: 600; }
.link-status.link-computer { border-color: color-mix(in srgb, var(--success) 45%, transparent); }
.link-status.link-connecting, .link-status.link-reconnecting { border-color: color-mix(in srgb, var(--warning, #fbbf24) 45%, transparent); }
.link-status.link-disconnected, .link-status.link-revoked, .link-status.link-unauthorized, .link-status.link-replaced { border-color: color-mix(in srgb, var(--danger, #f87171) 45%, transparent); }
.link-fact { margin-top: 8px; font-size: 13px; color: var(--text); }
.link-hint { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.link-actions { display: flex; gap: 8px; margin-top: 14px; }
.link-section { margin-top: 18px; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.link-device { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.link-device-main { flex: 1; min-width: 0; }
.link-device-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-device-meta { font-size: 12px; color: var(--muted); }
.chat-session-activity { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-inline-start: 6px; }
.chat-session-activity.running { background: var(--accent, #8b5cf6); animation: chatActivityPulse 1.2s ease-in-out infinite; }
.chat-session-activity.needs { width: 16px; height: 16px; line-height: 16px; text-align: center; font-size: 11px; font-weight: 700; color: #1a1300; background: var(--warning, #fbbf24); }
@keyframes chatActivityPulse { 50% { opacity: .35; } }
.chat-session-list {
  flex: 0 1 auto; max-height: 45vh; overflow-y: auto; margin: 4px -8px 0; padding: 0 8px;
  display: flex; flex-direction: column; gap: 2px; min-height: 0;
}
.chat-session-group-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); padding: 10px 10px 4px;
}
.chat-session-group-label:first-child { padding-top: 4px; }
.chat-session-item {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 8px;
  cursor: pointer; color: var(--muted); font-size: 13.5px;
}
.chat-session-item:hover { background: var(--panel); color: var(--text); }
.chat-session-item.active { background: var(--panel); color: var(--text); }
.chat-session-item.renaming { padding: 4px 6px; cursor: default; }
.chat-session-star { color: var(--accent); font-size: 12px; flex: 0 0 auto; }
.chat-session-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-session-rename-input, .chat-session-title-input {
  width: 100%; background: var(--bg-2); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 5px 8px; font: inherit; font-size: 13.5px;
}
.chat-session-menu-btn {
  background: none; border: 0; color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer;
  padding: 3px 6px; border-radius: 4px; visibility: hidden;
}
.chat-session-item:hover .chat-session-menu-btn { visibility: visible; }
.chat-session-menu-btn:hover { color: var(--text); background: color-mix(in srgb, var(--text) 8%, transparent); }
.chat-session-empty { font-size: 12.5px; color: var(--muted); padding: 8px 10px; }
.chat-session-list.busy { opacity: 0.55; pointer-events: none; }
.chat-new-btn:disabled { opacity: 0.55; cursor: default; }
.chat-sidebar-spacer { flex: 1; }

.chat-account-chip {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: start;
  background: none; border: 1px solid transparent; border-radius: var(--radius-md);
  padding: 8px; cursor: pointer; color: var(--text); font: inherit;
}
.chat-account-chip:hover { background: var(--panel); border-color: var(--border); }
.chat-account-avatar {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%; background: var(--brand-grad);
  color: #ffffff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13.5px;
}
.chat-account-info { display: flex; flex-direction: column; min-width: 0; }
.chat-account-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-account-plan { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  background: var(--bg);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.chat-topbar-right { display: flex; align-items: center; gap: 12px; }
.chat-session-title-btn {
  background: none; border: 1px solid transparent; border-radius: var(--radius-sm);
  color: var(--text); font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer;
  padding: 6px 8px; max-width: 50vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-session-title-btn:hover:not(:disabled) { background: var(--panel); border-color: var(--border); }
.chat-session-title-btn:disabled { cursor: default; color: var(--muted); }
.chat-model-btn {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 12px; font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.chat-model-btn:hover { border-color: var(--border-strong); }

.chat-messages-wrap { flex: 1; position: relative; min-height: 0; display: flex; }
.chat-messages {
  flex: 1; overflow-y: auto; padding: 32px 24px; display: flex; flex-direction: column; gap: 22px;
  background: var(--bg);
}
.chat-empty-state { margin: auto; text-align: center; color: var(--muted); max-width: 420px; padding: 40px 20px; }
.chat-empty-glyph { display: flex; align-items: center; justify-content: center; margin-bottom: 22px; filter: drop-shadow(0 0 26px color-mix(in srgb, var(--brand-violet-500) 55%, transparent)); }
.chat-empty-mark { width: 60px; height: auto; display: block; }
.chat-empty-state h2 { font-size: 30px; color: var(--text); font-family: var(--font-serif); font-weight: 500; margin: 0 0 12px; }
.chat-empty-subtitle { font-size: 15px; color: var(--muted); margin: 0; line-height: 1.6; }

.chat-scroll-bottom-btn {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  width: 36px; height: 36px; border-radius: 50%; background: var(--raised);
  border: 1px solid var(--border-strong); color: var(--text); font-size: 16px; cursor: pointer;
  box-shadow: var(--shadow-md); display: flex; align-items: center; justify-content: center;
}
.chat-scroll-bottom-btn:hover { background: var(--panel); }

.chat-file-card {
  align-self: flex-start; display: flex; align-items: center; gap: 10px; max-width: 480px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 10px 14px; font-size: 13.5px;
}
.chat-file-card-icon { font-size: 16px; }
.chat-file-card-label { flex: 1; color: var(--muted); }
.chat-file-card-btn { padding: 6px 12px; font-size: 12.5px; }

/* Per-file delivery cards (chat.js renderFilesReady) */
.chat-files {
  align-self: flex-start; display: flex; flex-direction: column; gap: 4px; width: min(480px, 100%);
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 10px 14px; font-size: 13.5px;
}
.chat-files-head { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.chat-file-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.chat-file-meta { flex: 1; min-width: 0; }
.chat-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-file-size { color: var(--muted); font-size: 12px; }
.chat-file-actions { display: flex; gap: 6px; flex-shrink: 0; }
.chat-files-more > summary { cursor: pointer; color: var(--muted); font-size: 12.5px; padding: 4px 0; }
.chat-files-zip {
  align-self: flex-start; background: none; border: 0; padding: 4px 0; cursor: pointer;
  color: var(--muted); font: inherit; font-size: 12.5px; text-decoration: underline;
}
.chat-files-zip:hover { color: inherit; }

.chat-disclaimer {
  max-width: 780px; margin: 8px auto 0; text-align: center; color: var(--muted); font-size: 11.5px;
}

.chat-msg {
  max-width: 720px; margin-bottom: 8px;
  animation: fadeInUp 0.3s ease-out forwards;
  opacity: 0;
  transform: translateY(8px);
}
@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.chat-msg-user { align-self: flex-end; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.chat-bubble-image { max-width: 260px; max-height: 220px; border-radius: 12px; border: 1px solid var(--border); }
.chat-msg-user .chat-bubble {
  background: var(--brand-bubble); color: var(--text); border: 1px solid var(--brand-line-strong);
  border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg); padding: 10px 16px;
}
.chat-msg-assistant {
  align-self: flex-start;
  display: flex;
  gap: 10px;
}
.chat-msg-assistant-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-grad);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 2px;
}
.chat-msg-assistant .chat-bubble {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px 14px 14px 4px;
  padding: 12px 16px; white-space: pre-wrap; line-height: 1.55;
  box-shadow: var(--shadow-sm);
}
.chat-msg-error .chat-bubble { border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); }

.chat-activity-line {
  font-size: 13px; color: var(--muted); padding: 8px 16px;
  text-align: center;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
.chat-typing-indicator {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.chat-typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing 1.4s infinite ease-in-out;
}
.chat-typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.chat-typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.6; }
  40% { transform: scale(1); opacity: 1; }
}
.chat-tool-row {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-size: 13px; font-family: ui-monospace, Consolas, monospace;
}
.chat-tool-row .tool-name { color: var(--accent); font-weight: 600; }
.chat-tool-row .tool-result { color: var(--muted); margin-top: 4px; white-space: pre-wrap; }

.chat-approval-card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px;
}
.chat-approval-card .reason { color: var(--muted); font-size: 13.5px; margin: 6px 0 12px; }
.chat-approval-card .cmd {
  font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--bg);
  padding: 8px 10px; border-radius: 6px; margin-bottom: 10px; display: block;
}
.chat-approval-actions { display: flex; gap: 8px; }
.chat-approval-actions .btn { padding: 7px 14px; font-size: 13.5px; }

/* ─── AI-action approval popup (command/plan/edit) — matches the desktop app's modal style,
   used when the agent is remotely driving the user's own machine and needs a decision before
   proceeding, instead of the inline chat-approval-card above. */
.approval-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 200;
  backdrop-filter: blur(2px); animation: approval-overlay-in 0.15s ease-out both;
}
@keyframes approval-overlay-in { from { opacity: 0; } to { opacity: 1; } }
.approval-card {
  background: var(--raised); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; width: min(420px, 92vw); max-height: 82vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: approval-card-in 0.18s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes approval-card-in {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.approval-card .modal-icon {
  width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center;
  justify-content: center; font-size: 18px; margin-bottom: 12px;
}
.modal-icon-plan { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-text); }
.modal-icon-cmd  { background: rgba(234,179,8,0.15); color: #eab308; }
.modal-icon-edit { background: rgba(59,130,246,0.12); color: #3b82f6; }
.approval-card h3 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.approval-card .modal-subtitle { font-size: 12.5px; color: var(--muted); margin: 0 0 12px; line-height: 1.5; }
.approval-card code {
  display: block; background: var(--bg-2); padding: 10px 12px; border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: 12.5px; margin: 10px 0; word-break: break-all;
  white-space: pre-wrap; border: 1px solid var(--border);
}
.approval-card .plan-body {
  white-space: pre-wrap; font-size: 13.5px; line-height: 1.5; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin: 10px 0;
}
.approval-card .edit-approval-files { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.approval-card .diff-file-section {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px;
}
.approval-card .diff-file-path { font-family: var(--font-mono); font-size: 12.5px; }
.approval-card .approval-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.chat-composer-wrap { padding: 20px 24px 32px; border-top: 1px solid var(--border); background: var(--bg); }
/* Two rows: the input itself, then a controls bar (attach + mode toggle on the left,
   model/effort + mic/voice + send on the right) — matches Claude's composer layout instead of
   everything crammed into one row. */
.chat-composer {
  max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px;
  background: var(--panel); border: 1px solid var(--border-strong); border-radius: 18px; padding: 14px 14px 10px;
  box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s;
}
.chat-composer:focus-within { border-color: var(--brand-violet-400); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-violet-500) 26%, transparent), var(--shadow-sm); }
.chat-input {
  width: 100%; background: transparent; border: 0; color: var(--text); font: inherit; font-size: 15px;
  resize: none; outline: 0; max-height: 160px; overflow-y: auto; padding: 4px 6px;
  box-sizing: border-box;
}
.chat-input::placeholder {
  color: var(--muted);
}
.chat-input:focus { outline: none; }
.chat-composer-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chat-composer-controls-left, .chat-composer-controls-right { display: flex; align-items: center; gap: 6px; }
.chat-send-btn, .chat-stop-btn { padding: 8px 16px; }
.chat-composer-controls .chat-icon-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border);
}
.chat-composer-controls .chat-icon-btn:hover { background: var(--raised); }
.chat-mic-btn.active { background: var(--accent); border-color: transparent; color: #fff; }
.chat-voice-btn.listening { background: var(--accent); border-color: transparent; color: #fff; animation: voicePulse 1.6s ease-in-out infinite; }
.chat-voice-btn.speaking { background: #e2892e; border-color: transparent; color: #fff; }
@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb, 88, 101, 242), 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(var(--accent-rgb, 88, 101, 242), 0); }
}
.chat-image-preview {
  max-width: 780px; margin: 0 auto 10px; position: relative; display: inline-flex;
}
.chat-image-preview img {
  max-height: 88px; border-radius: 10px; border: 1px solid var(--border); display: block;
}
.chat-image-remove {
  position: absolute; top: -8px; inset-inline-end: -8px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  cursor: pointer; font-size: 14px; line-height: 1; padding: 0;
}
.chat-image-remove:hover { background: var(--accent); color: #ffffff; border-color: transparent; }

.chat-menu-btn { display: none; }
.chat-sidebar-backdrop {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 19; background: rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
@media (max-width: 780px) {
  .chat-menu-btn { display: inline-flex; width: 40px; height: 40px; }
  .chat-menu-btn svg { width: 20px; height: 20px; }
  .chat-topbar-left { display: flex; align-items: center; gap: 4px; min-width: 0; }
  .chat-sidebar {
    position: fixed; z-index: 20; height: 100%; transform: translateX(-100%);
    transition: transform .2s; box-shadow: var(--shadow-lg);
  }
  .chat-sidebar.open { transform: translateX(0); }
  .chat-sidebar-backdrop.show { display: block; opacity: 1; pointer-events: auto; }
  .chat-topbar { padding: 12px 14px; }
  .chat-messages { padding: 20px 14px; }
  .chat-composer-wrap { padding: 12px 12px 16px; }
  .chat-composer { border-radius: 16px; padding: 10px 10px 8px; }
  .chat-session-title-btn { max-width: 42vw; }
  .chat-msg { max-width: 100%; }
  .chat-msg-assistant { gap: 8px; }
  .chat-msg-assistant-avatar { width: 30px; height: 30px; }
  .chat-bubble-image { max-width: 100%; }
  .chat-composer-controls { flex-wrap: wrap; }
  .chat-composer-controls-right { margin-inline-start: auto; }
  .chat-mode-toggle-btn { padding: 5px 9px; }
  .chat-model-btn { padding: 6px 9px; font-size: 12px; }
  .chat-send-btn, .chat-stop-btn { padding: 7px 13px; }
  .chat-disclaimer { font-size: 10.5px; }
  /* Pin the app to the VISUAL viewport (see trackViewport in ui.js): correct under the mobile URL bar
     and with the on-screen keyboard open, so the composer is never pushed off-screen. */
  .chat-view { position: fixed; top: var(--app-top, 0px); left: 0; right: 0; height: var(--app-h, 100dvh); }
  .chat-sidebar { top: var(--app-top, 0px); height: var(--app-h, 100dvh); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .chat-topbar { padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 12px max(14px, env(safe-area-inset-left)); }
  .chat-messages { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
  .chat-composer-wrap { padding: 12px max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  /* iOS Safari zooms the whole page when a focused field's font is under 16px. */
  .chat-composer .chat-input, input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], input[type="url"], textarea, select { font-size: 16px; }
}

/* ─── Rich renderer (renderer.js) ────────────────────────────────────────── */
/* Steps: an assistant turn = optional thinking trace + streamed markdown + tool cards. */
.wd-step { max-width: 780px; align-self: stretch; }
.wd-step-body { line-height: 1.6; font-size: 15px; }
.wd-step-tools { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }

.wd-step-actions { display: flex; gap: 2px; margin-top: 6px; }
.wd-action-btn {
  background: none; border: 0; color: var(--muted); font-size: 13px; cursor: pointer;
  padding: 5px 7px; border-radius: var(--radius-sm); line-height: 1;
}
.wd-action-btn:hover { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }
.wd-action-btn.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.wd-action-btn.done { color: var(--success); }

.wd-thinking { margin-bottom: 6px; }
.wd-thinking-toggle {
  background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px;
  cursor: pointer; padding: 2px 0; font-style: italic;
}
.wd-thinking-toggle:hover { color: var(--text); }
.wd-thinking-toggle::before { content: '▸ '; font-style: normal; }
.wd-thinking.open .wd-thinking-toggle::before { content: '▾ '; }
.wd-thinking-body {
  color: var(--muted); font-size: 13px; line-height: 1.5; white-space: pre-wrap;
  border-inline-start: 2px solid var(--border); padding: 4px 0; padding-inline-start: 12px; margin: 4px 0 8px;
}

/* Markdown */
.wd-markdown .md-paragraph { margin: 0 0 10px; }
.wd-markdown .md-paragraph:last-child { margin-bottom: 0; }
.wd-markdown .md-header { margin: 16px 0 8px; font-size: 16px; }
.wd-markdown h3.md-header { font-size: 17px; }
.wd-markdown .md-list { margin: 0 0 10px; padding-inline-start: 22px; }
.wd-markdown .md-li { margin: 3px 0; }
.wd-markdown .md-hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.wd-markdown code {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 5px;
  padding: 1px 6px; font-family: ui-monospace, Consolas, monospace; font-size: 13px;
}
.wd-markdown a { color: var(--accent); }
.wd-markdown a:hover { text-decoration: underline; }

.md-code-block { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; margin: 10px 0; overflow: hidden; }
.md-code-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 12px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted);
}
.md-code-copy {
  background: none; border: 0; color: var(--muted); font-size: 12px; cursor: pointer; padding: 2px 6px;
}
.md-code-copy:hover { color: var(--text); }
.md-code-inner {
  margin: 0; padding: 12px 14px; overflow-x: auto;
  font-family: ui-monospace, Consolas, monospace; font-size: 13px; line-height: 1.55;
}

/* Tool cards */
.wd-tool-entry { background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.wd-tool-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer;
  font-size: 13.5px; user-select: none;
}
.wd-tool-row:hover { background: color-mix(in srgb, var(--text) 3%, transparent); }
.wd-tool-verb { font-weight: 600; }
.wd-tool-target {
  color: var(--muted); font-family: ui-monospace, Consolas, monospace; font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1;
}
.wd-tool-chevron { color: var(--muted); font-size: 11px; transition: transform .15s; }
.wd-tool-entry.expanded .wd-tool-chevron { transform: rotate(90deg); }
.wd-tool-status { width: 16px; text-align: center; font-size: 12px; flex: 0 0 16px; }
.wd-tool-status.done { color: var(--success); }
.wd-tool-status.error { color: var(--danger); }
.wd-tool-status.declined { color: var(--muted); }
.wd-tool-status.pending {
  width: 12px; height: 12px; flex-basis: 12px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: wd-spin 0.8s linear infinite;
}
@keyframes wd-spin { to { transform: rotate(360deg); } }

.wd-tool-panel { border-top: 1px solid var(--border); padding: 10px 12px; max-height: 420px; overflow: auto; }
.wd-output {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; line-height: 1.5; color: var(--text);
}
.wd-output.terminal { background: var(--brand-inset); border-radius: 8px; padding: 10px 12px; }
.wd-output.error { color: var(--danger); }
.wd-note { color: var(--muted); font-size: 13px; }
.wd-note.declined { font-style: italic; }
.wd-image { max-width: 100%; border-radius: 10px; display: block; margin-bottom: 8px; }

/* Diffs */
.wd-diff-section { margin-bottom: 10px; }
.wd-diff-section:last-child { margin-bottom: 0; }
.wd-diff-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px;
}
.wd-diff-path { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; color: var(--text); }
.wd-diff-stats { display: inline-flex; gap: 6px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.wd-diff-stats .add { color: var(--success); }
.wd-diff-stats .del { color: var(--danger); }
.wd-diff-body {
  border: 1px solid var(--border); border-radius: 8px; overflow-x: auto;
  font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; line-height: 1.5;
}
.wd-diff-row { padding: 0 10px; white-space: pre; }
.wd-diff-row.add { background: var(--success-bg); color: #b8f2bd; }
.wd-diff-row.del { background: var(--danger-bg); color: #ffb3b3; }
.wd-diff-skip { padding: 2px 10px; color: var(--muted); font-size: 11.5px; font-style: italic; }

/* ─── Shared UI primitives (ui.js) ───────────────────────────────────────── */
.fui-menu-root {
  z-index: 200; background: var(--raised); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 6px; min-width: 200px;
  box-sizing: border-box;
}
.fui-menu-root.fui-menu-scroll { overflow-y: auto; overscroll-behavior: contain; }
.fui-menu { display: flex; flex-direction: column; }
.fui-menu-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm);
  font-size: 13.5px; cursor: pointer; position: relative; color: var(--text);
}
.fui-menu-item:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.fui-menu-item.danger { color: var(--danger); }
.fui-menu-icon { width: 16px; text-align: center; flex: 0 0 16px; }
.fui-menu-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.fui-menu-shortcut { color: var(--muted); font-size: 11.5px; }
.fui-menu-caret { color: var(--muted); }
.fui-menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.fui-submenu {
  position: absolute; inset-inline-start: 100%; top: -6px; margin-inline-start: 4px;
  background: var(--raised); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 6px; min-width: 180px;
}

.fui-modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.fui-modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 24px; width: 420px; max-width: calc(100vw - 32px); max-height: calc(100vh - 64px); max-height: calc(100dvh - 64px);
  overflow-y: auto; position: relative; box-shadow: var(--shadow-lg);
}
.fui-modal-title { margin: 0 20px 14px 0; font-size: 18px; }
.fui-modal-close {
  position: absolute; top: 18px; inset-inline-end: 18px; background: none; border: 0;
  color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer;
}
.fui-modal-close:hover { color: var(--text); }
.fui-modal-body { color: var(--text); font-size: 14px; }
.fui-modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

.fui-toast-host {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 300;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.fui-toast {
  display: flex; align-items: center; gap: 10px; background: var(--raised);
  border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  padding: 10px 14px; font-size: 13.5px; box-shadow: var(--shadow-md); max-width: 360px;
}
.fui-toast-success { border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.fui-toast-error { border-color: rgba(255,139,139,0.35); }
.fui-toast-close { background: none; border: 0; color: var(--muted); font-size: 15px; cursor: pointer; }
.fui-toast-close:hover { color: var(--text); }

.fui-toggle {
  width: 38px; height: 22px; border-radius: 999px; background: var(--bg-2);
  border: 1px solid var(--border-strong); position: relative; cursor: pointer; padding: 0; flex: 0 0 auto;
  transition: background .15s;
}
.fui-toggle.checked { background: var(--accent); border-color: transparent; }
.fui-toggle-knob {
  position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--text); transition: transform .15s;
}
.fui-toggle.checked .fui-toggle-knob { transform: translateX(16px); background: #12100e; }

/* Progress bar (shared primitive — Settings/Usage bars consume this) */
.fui-progress { flex: 1; height: 8px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.fui-progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .2s; }

/* Tooltip (shared primitive — hover-positioned label for icon-only controls) */
.fui-tooltip {
  position: fixed; z-index: 400; background: var(--raised); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 5px 9px; font-size: 12px; line-height: 1.3; box-shadow: var(--shadow-sm);
  pointer-events: none; max-width: 240px;
}

/* Searchable submenu (shared primitive — e.g. "Add to project") */
.fui-menu-search {
  width: 100%; margin-bottom: 6px; padding: 6px 8px; background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit; font-size: 13px;
}
.fui-menu-search:focus { outline: none; border-color: var(--border-strong); }
.fui-menu-empty { color: var(--muted); font-size: 12.5px; padding: 6px 8px; }

/* ─── Artifact panel (artifacts.js) ──────────────────────────────────────── */
.artifact-panel {
  width: 520px; flex: 0 0 auto; display: flex; flex-direction: column;
  background: var(--bg); border-inline-start: 1px solid var(--border); position: relative; min-width: 0;
}
.artifact-panel-drag {
  position: absolute; inset-inline-start: -3px; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 5;
}
.artifact-panel-drag:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.artifact-panel-header {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.artifact-panel-tabs { display: flex; gap: 2px; background: var(--panel); border-radius: var(--radius-sm); padding: 2px; flex: 0 0 auto; }
.artifact-tab {
  border: 0; background: none; color: var(--muted); font-size: 12.5px; font-weight: 600;
  padding: 5px 10px; border-radius: 6px; cursor: pointer;
}
.artifact-tab.active { background: var(--raised); color: var(--text); }
.artifact-panel-title {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 13px; color: var(--text); text-align: center;
}
.artifact-panel-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.artifact-copy-btn { padding: 6px 10px; font-size: 12.5px; }
.artifact-close-btn {
  background: none; border: 0; color: var(--muted); font-size: 18px; line-height: 1;
  cursor: pointer; padding: 4px 6px;
}
.artifact-close-btn:hover { color: var(--text); }
.artifact-panel-body { flex: 1; min-height: 0; position: relative; }
.artifact-code-view {
  margin: 0; height: 100%; overflow: auto; padding: 16px; box-sizing: border-box;
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6; color: var(--text);
  white-space: pre; background: var(--bg);
}
.artifact-preview-view { width: 100%; height: 100%; border: 0; background: #fff; }

.wd-artifact-chip {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--panel);
  cursor: pointer; font-size: 13px; max-width: 320px;
}
.wd-artifact-chip:hover { border-color: var(--border-strong); }
.wd-artifact-chip-icon { flex: 0 0 auto; }
.wd-artifact-chip-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wd-artifact-chip-open { color: var(--muted); font-size: 12px; flex: 0 0 auto; }
.wd-artifact-chip-thumb {
  width: 22px; height: 22px; flex: 0 0 22px; border-radius: 5px; object-fit: cover;
  background: var(--bg-2); border: 1px solid var(--border);
}

/* ─── Settings modal (settings.js) ───────────────────────────────────────── */
.settings-modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  width: 720px; max-width: calc(100vw - 32px); height: 560px; max-height: calc(100vh - 64px); max-height: calc(100dvh - 64px);
  position: relative; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; padding: 0;
}
.settings-title { margin: 0; padding: 18px 20px 14px; font-size: 17px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.settings-close { top: 16px; }
.settings-layout { flex: 1; min-height: 0; display: flex; }
.settings-nav { flex: 0 0 180px; border-inline-end: 1px solid var(--border); padding: 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.settings-nav-item {
  display: flex; align-items: center; gap: 10px; text-align: start; background: none; border: 0;
  color: var(--muted); padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13.5px;
}
.settings-nav-item:hover { background: color-mix(in srgb, var(--text) 5%, transparent); color: var(--text); }
.settings-nav-item.active { background: var(--raised); color: var(--text); }
.settings-nav-icon { width: 16px; text-align: center; flex: 0 0 16px; }
.settings-body { flex: 1; min-width: 0; overflow-y: auto; padding: 20px 24px; }
.settings-h4 { margin: 18px 0 8px; font-size: 13px; color: var(--text); }
.settings-h4:first-child { margin-top: 0; }
.settings-hint { color: var(--muted); font-size: 12.5px; margin: 0 0 8px; }
.settings-textarea { resize: vertical; font-family: var(--font-sans); }
.settings-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.settings-save-status { color: var(--success); font-size: 12.5px; }
.settings-field {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13.5px;
}
.settings-field-label { color: var(--muted); }
.settings-badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; background: color-mix(in srgb, var(--text) 8%, transparent); color: var(--muted); margin-inline-start: 6px;
}
.settings-badge.success { background: var(--success-bg); color: var(--success); }
.settings-badge.danger { background: var(--danger-bg); color: var(--danger); }
.settings-loading { color: var(--muted); font-size: 13px; }
.settings-plan-list { display: flex; flex-direction: column; gap: 8px; }
.settings-plan-row {
  border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.settings-plan-row > :first-child { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.settings-plan-name { font-weight: 600; font-size: 13.5px; }
.settings-upgrade-form { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.settings-payment-list { display: flex; flex-direction: column; }
.settings-usage-row { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.settings-usage-label { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

/* ─── Settings: Skills (Claude-parity Phase 6) ───────────────────────────── */
.settings-skills-actions { margin-top: 0; margin-bottom: 4px; }
.settings-back-link {
  background: none; border: 0; color: var(--muted); font-size: 12.5px; cursor: pointer;
  padding: 0 0 10px; display: block;
}
.settings-back-link:hover { color: var(--text); }
.settings-skill-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.settings-skill-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 12px;
}
.settings-skill-info { min-width: 0; }
.settings-skill-title { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }

/* ─── Settings: Privacy / Account danger zone / Memory completion (Claude-parity gap audit) ─── */
.settings-toggle-row { display: flex; align-items: flex-start; gap: 12px; margin-top: 12px; }
.settings-toggle-row .settings-hint { margin: 2px 0 0; flex: 1; }
.settings-danger-zone { border: 1px solid var(--danger-bg); border-radius: var(--radius-md); padding: 14px; margin-top: 20px; }
.settings-theme-picker { display: flex; gap: 8px; margin-top: 8px; }
.settings-theme-option {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius-md); background: none;
  color: var(--muted); font: inherit; font-size: 13px; padding: 10px 8px; cursor: pointer; text-align: center;
}
.settings-theme-option:hover { color: var(--text); border-color: var(--border-strong); }
.settings-theme-option.active { color: var(--text); border-color: var(--accent); background: var(--raised); }
.memory-edits-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; max-height: 220px; overflow-y: auto; }
.memory-edit-row { display: flex; justify-content: space-between; gap: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); padding: 8px 10px; font-size: 12.5px; }
.memory-edit-preview { color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.memory-edit-meta { color: var(--muted); white-space: nowrap; }

/* ─── Directory (site/directory.js, Claude-parity Phase 6) ───────────────── */
.directory-modal { width: 680px; height: 70vh; max-height: 640px; }
.directory-tabs { display: flex; gap: 4px; padding: 0 20px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.directory-tab {
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted);
  font: inherit; font-size: 13.5px; padding: 10px 12px; cursor: pointer;
}
.directory-tab:hover:not(.disabled) { color: var(--text); }
.directory-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.directory-tab.disabled { color: var(--muted); opacity: 0.55; cursor: default; }
.directory-body { display: flex; flex-direction: column; }
.directory-toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
.directory-toolbar .settings-input { margin: 0; }
.directory-toolbar input.settings-input { flex: 1; }
.directory-filter, .directory-sort { flex: 0 0 auto; width: auto; }
.directory-grid { flex: 1; overflow-y: auto; }
.directory-card { align-items: center; }
.directory-empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.directory-empty-glyph { font-size: 32px; margin-bottom: 8px; }
.chat-directory-nav-btn { flex: 0 0 auto; }

/* ─── Projects (site/projects.js, Claude-parity Phase 6) ─────────────────── */
.projects-modal { width: 560px; }
.projects-body { display: flex; flex-direction: column; }
.projects-row { align-items: flex-start; }

/* ─── Sidebar: desktop rail (collapse/expand) + mobile drawer (open/close) ─────────────────────
   Desktop: .collapsed shrinks the sidebar to a 64px icon rail. The rail stacks vertically — the
   logo MARK (the lockup clipped to its left glyph), then the expand button — so nothing can overlap
   the toggle. Phones never use the rail: the sidebar is always a full-width drawer there, so the
   saved "collapsed" preference is ignored (the .collapsed class is not even applied, see chat.js). */
.chat-sidebar { transition: width .15s, flex-basis .15s, padding .15s; }
.chat-sidebar-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.chat-brand { display: inline-flex; align-items: center; min-width: 0; }
.chat-brand .brand-logo { max-width: none; flex: 0 0 auto; }
.chat-sidebar-toggle { width: 32px; height: 32px; }
.chat-sidebar-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chat-sidebar-toggle .sb-ico-close { display: none; }
[dir="rtl"] .chat-sidebar-toggle .sb-ico-panel { transform: scaleX(-1); }
.chat-sidebar-nav { display: flex; flex-direction: column; gap: 2px; margin: 10px 0; }
.chat-sidebar-nav-item {
  display: flex; align-items: center; gap: 10px; background: none; border: 0; text-align: start;
  color: var(--muted); font: inherit; font-size: 13.5px; padding: 7px 10px; border-radius: 8px; cursor: pointer;
}
.chat-sidebar-nav-item:hover { background: var(--panel); color: var(--text); }
.chat-sidebar-nav-icon { flex: 0 0 18px; display: inline-flex; align-items: center; justify-content: center; }
.chat-sidebar-nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (min-width: 781px) {
  .chat-sidebar.collapsed { width: 64px; flex-basis: 64px; padding: 16px 10px; }
  .chat-sidebar.collapsed .chat-sidebar-top { flex-direction: column; align-items: center; gap: 10px; }
  /* Show only the mark: the lockup is ~3.8:1, the mark is its leftmost ~0.78:1 slice. */
  .chat-sidebar.collapsed .chat-brand { width: 24px; height: 30px; overflow: hidden; justify-content: flex-start; flex: 0 0 auto; }
  .chat-sidebar.collapsed .chat-sidebar-top-actions { flex-direction: column; }
  .chat-sidebar.collapsed #chatSearchBtn,
  .chat-sidebar.collapsed .chat-search-input,
  .chat-sidebar.collapsed .chat-mode-pill,
  .chat-sidebar.collapsed .chat-session-list,
  .chat-sidebar.collapsed .chat-sidebar-nav-label,
  .chat-sidebar.collapsed .chat-account-info { display: none !important; }
  .chat-sidebar.collapsed .chat-new-btn { padding: 9px; justify-content: center; font-size: 0; }
  .chat-sidebar.collapsed .chat-sidebar-nav-item { justify-content: center; padding: 8px; }
  .chat-sidebar.collapsed .chat-account-chip { justify-content: center; padding: 8px; }
}

@media (max-width: 780px) {
  /* Declared after the desktop transition above so it wins. A closed drawer is also hidden from
     focus/AT (visibility flips after the slide-out finishes). */
  .chat-sidebar { width: min(300px, 86vw); flex: 0 0 auto; transition: transform .2s, visibility 0s linear .2s; visibility: hidden; }
  .chat-sidebar.open { transition: transform .2s, visibility 0s; visibility: visible; }
  .chat-sidebar-toggle { width: 40px; height: 40px; }
  .chat-sidebar-toggle .sb-ico-panel { display: none; }
  .chat-sidebar-toggle .sb-ico-close { display: block; }
  .chat-sidebar-toggle svg { width: 20px; height: 20px; }
}

/* ─── Chats / Artifacts gallery pages (Claude-parity gap audit) ──────────── */
.fui-page-modal { width: 640px; max-height: calc(100vh - 96px); max-height: calc(100dvh - 96px); }
.chat-list-page-search {
  width: 100%; margin-bottom: 12px; padding: 9px 12px; background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-md); font: inherit; font-size: 14px;
}
.chat-list-page-search:focus { outline: none; border-color: var(--border-strong); }
.chat-list-page-rows { display: flex; flex-direction: column; gap: 2px; max-height: 55vh; overflow-y: auto; }
.chat-list-page-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 10px; border-radius: 8px; cursor: pointer;
  color: var(--text); font-size: 13.5px;
}
.chat-list-page-row:hover { background: var(--panel); }
.chat-list-page-row .title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list-page-row .meta { color: var(--muted); font-size: 12px; flex: 0 0 auto; }
.chat-list-page-row .unread-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: 0 0 7px; }

.artifact-gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; max-height: 60vh; overflow-y: auto;
}
.artifact-gallery-card {
  border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; background: var(--bg-2);
}
.artifact-gallery-card:hover { border-color: var(--border-strong); }
.artifact-gallery-card .kind { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.artifact-gallery-card .title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artifact-gallery-card .updated { font-size: 11.5px; color: var(--muted); }
.artifact-gallery-empty { color: var(--muted); font-size: 13.5px; padding: 20px 4px; text-align: center; }

/* ─── Session-list unread indicator ───────────────────────────────────────── */
.chat-session-unread-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: 0 0 6px; }
.chat-session-item.unread .chat-session-title { color: var(--text); font-weight: 600; }

/* ─── Header star toggle ──────────────────────────────────────────────────── */
.chat-topbar-title-group { display: flex; align-items: center; gap: 2px; min-width: 0; }
.chat-header-star-btn {
  background: none; border: 0; color: var(--muted); font-size: 15px; cursor: pointer;
  padding: 6px 8px; border-radius: var(--radius-sm); flex: 0 0 auto; line-height: 1;
}
.chat-header-star-btn:hover { color: var(--text); background: var(--panel); }
.chat-header-star-btn.starred { color: var(--accent); }

/* ─── Update banner + composer promo slots (generic, hidden by default) ──── */
.chat-update-banner {
  display: flex; align-items: center; justify-content: center; gap: 12px; padding: 8px 16px;
  background: var(--accent); color: #ffffff; font-size: 13px; font-weight: 600; text-align: center;
}
.chat-update-banner-dismiss {
  background: none; border: 0; color: inherit; font-size: 15px; cursor: pointer; line-height: 1; padding: 0 4px;
}
.chat-composer-promo {
  max-width: 780px; margin: 0 auto 8px; display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 8px 12px; font-size: 12.5px; color: var(--text);
}
.chat-composer-promo-text { flex: 1; }
.chat-composer-promo-dismiss { background: none; border: 0; color: var(--muted); font-size: 14px; cursor: pointer; line-height: 1; }
.chat-composer-promo-dismiss:hover { color: var(--text); }

/* ─── Rich markdown renderer ─────────────────────────────────────────────── */
.wd-markdown {
  line-height: 1.6;
  max-width: 100%;
}
.wd-markdown p {
  margin: 0 0 12px;
}
.wd-markdown p:last-child {
  margin-bottom: 0;
}
.wd-markdown strong {
  font-weight: 600;
}
.wd-markdown em {
  font-style: italic;
}
.wd-markdown code {
  background: var(--bg-2);
  padding: 2px 4px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.9em;
}
.wd-markdown pre {
  background: var(--bg-2);
  border-radius: 8px;
  padding: 12px;
  overflow-x: auto;
  margin: 12px 0;
}
.wd-markdown pre code {
  background: transparent;
  padding: 0;
  font-size: 0.9em;
}
.wd-markdown .md-code-block {
  margin: 12px 0;
}
.wd-markdown .md-code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--muted);
}
.wd-markdown .md-code-copy {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}
.wd-markdown .md-code-copy:hover {
  border-color: var(--border-strong);
}
.wd-markdown .md-code-copy.done {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}
.wd-markdown .md-code-lang {
  font-family: var(--font-mono);
}
.wd-markdown .md-list {
  margin: 8px 0;
  padding-inline-start: 24px;
}
.wd-markdown .md-li {
  margin: 4px 0;
}
.wd-markdown .md-header {
  margin: 16px 0 8px;
  font-weight: 600;
}
.wd-markdown .md-header h1, .wd-markdown .md-header h2, .wd-markdown .md-header h3 {
  margin: 0;
}
.wd-markdown .md-hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}
.wd-image {
  max-width: 100%;
  border-radius: 12px;
  margin: 8px 0;
  border: 1px solid var(--border);
}
/* ─── Tool entries ───────────────────────────────────────────────────────── */
.wd-tool-entry {
  margin: 8px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  overflow: hidden;
}
.wd-tool-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
}
.wd-tool-row:hover {
  background: var(--raised);
}
.wd-tool-status {
  width: 16px;
  text-align: center;
}
.wd-tool-status.pending {
  color: var(--muted);
  animation: pulse 1.5s infinite;
}
.wd-tool-status.done {
  color: var(--success);
}
.wd-tool-status.error {
  color: var(--danger);
}
.wd-tool-status.declined {
  color: var(--danger);
}
.wd-tool-cancel-btn {
  margin-inline-start: auto;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}
.wd-tool-cancel-btn:hover:not(:disabled) { background: var(--raised); color: var(--text); }
.wd-tool-cancel-btn:disabled { opacity: 0.6; cursor: default; }
.wd-tool-chevron {
  transition: transform 0.2s;
}
.wd-tool-entry.expanded .wd-tool-chevron {
  transform: rotate(90deg);
}
.wd-tool-panel {
  padding: 12px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  max-height: 400px;
  overflow-y: auto;
}
.wd-tool-panel pre {
  margin: 0;
  white-space: pre-wrap;
}
.wd-tool-panel pre.terminal {
  background: #1a1a1a;
  color: #fff;
  padding: 12px;
  border-radius: 8px;
}
.wd-tool-panel pre.error {
  color: var(--danger);
}
.wd-note {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 0;
}
.wd-note.declined {
  color: var(--danger);
}
/* ─── Diff view ────────────────────────────────────────────────────────── */
.wd-diff-section {
  margin: 8px 0;
}
.wd-diff-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.wd-diff-path {
  font-family: var(--font-mono);
}
.wd-diff-stats {
  display: flex;
  gap: 8px;
}
.wd-diff-stats .add {
  color: var(--success);
}
.wd-diff-stats .del {
  color: var(--danger);
}
.wd-diff-body {
  background: var(--bg-2);
  border-radius: 0 0 8px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.4;
}
.wd-diff-row {
  padding: 2px 8px;
  white-space: pre-wrap;
}
.wd-diff-row.add {
  background: rgba(126,231,135,0.1);
  color: var(--success);
}
.wd-diff-row.del {
  background: rgba(255,139,139,0.1);
  color: var(--danger);
}
.wd-diff-skip {
  text-align: center;
  color: var(--muted);
  padding: 4px 0;
  font-size: 12px;
}
/* ─── Step entries ──────────────────────────────────────────────────────── */
.wd-step {
  margin: 8px 0;
}
.wd-thinking {
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
}
.wd-thinking-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
}
.wd-thinking-toggle:hover {
  border-color: var(--border-strong);
}
.wd-thinking-body {
  margin-top: 4px;
  padding: 8px 12px;
  background: var(--bg-2);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
}
.wd-step-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}
.wd-action-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
}
.wd-action-btn:hover {
  border-color: var(--border-strong);
}
.wd-action-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
/* ─── Skills slash-autocomplete ───────────────────────────────────────────── */
.chat-skill-autocomplete {
  max-width: 780px; margin: 0 auto 8px; background: var(--raised); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md); overflow: hidden; max-height: 220px; overflow-y: auto;
}
.chat-skill-autocomplete-item { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; cursor: pointer; }
.chat-skill-autocomplete-item:hover, .chat-skill-autocomplete-item.active { background: color-mix(in srgb, var(--text) 6%, transparent); }
.chat-skill-autocomplete-title { font-size: 13.5px; font-weight: 600; }
.chat-skill-autocomplete-desc { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-skill-autocomplete-empty { padding: 10px 12px; color: var(--muted); font-size: 12.5px; }

/* ─── Command palette (Ctrl+K) ────────────────────────────────────────────── */
.fui-palette-modal { width: 560px; padding: 0; overflow: hidden; }
.fui-palette-input {
  width: 100%; padding: 16px 20px; background: transparent; color: var(--text); border: 0;
  border-bottom: 1px solid var(--border); font: inherit; font-size: 16px;
}
.fui-palette-input:focus { outline: none; }
.fui-palette-results { max-height: 50vh; overflow-y: auto; padding: 8px; }

/* ─── Pricing + checkout pages ────────────────────────────────────────────── */
.pricing-hero { padding: 60px 24px 20px; text-align: center; }
.pricing-section { max-width: 1080px; margin: 0 auto; padding: 20px 24px 80px; }
.pricing-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px;
}
.pricing-card { display: flex; flex-direction: column; gap: 10px; position: relative; }
.pricing-card-trial { border-color: var(--accent); }
.pricing-card h3 { margin: 0; }
.pricing-price { display: flex; align-items: baseline; gap: 4px; }
.pricing-price-amount { font-size: 32px; font-weight: 700; }
.pricing-price-unit { color: var(--muted); font-size: 14px; }
.pricing-choose-btn { justify-content: center; margin-top: auto; }

.checkout-main { max-width: 560px; margin: 0 auto; padding: 40px 24px 80px; }
.checkout-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 28px; display: flex; flex-direction: column; gap: 12px;
}
.checkout-auth { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.checkout-tabs { display: flex; gap: 8px; margin-top: 8px; }
.checkout-tab-btn { flex: 1; justify-content: center; }
.checkout-tab-active { border-color: var(--accent); color: var(--accent); }
.checkout-tab-body { display: flex; flex-direction: column; gap: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.checkout-widget-wrap { margin-top: 10px; }
.checkout-widget-iframe { width: 100%; height: 600px; border: 1px solid var(--border); border-radius: var(--radius-md); }

/* ─── Claude-style tool/step timeline ────────────────────────────────────────
   Overrides the two earlier .wd-tool-* blocks above (they duplicate each other in a few
   places, pre-existing tech debt — left alone rather than risking a silent regression by
   merging them here). This is the redesign pass toward the quiet, connected step list Claude's
   own UI uses: a small tool-type icon per row instead of a generic checkmark, rows connected by
   a thin rail instead of separate bordered cards, and a compact filename+diff-count chip
   instead of a bare +N/−N. */
.wd-step-tools {
  position: relative;
  gap: 0;
}
.wd-step-tools::before {
  content: '';
  position: absolute;
  inset-inline-start: 13px;
  top: 13px;
  bottom: 13px;
  width: 1px;
  background: var(--border);
  z-index: 0;
}
.wd-tool-entry {
  background: transparent;
  border: none;
  border-radius: 0;
  margin: 0;
  position: relative;
  z-index: 1;
}
.wd-tool-row {
  padding: 6px 4px;
  gap: 10px;
  border-radius: var(--radius-sm);
}
.wd-tool-row:hover { background: color-mix(in srgb, var(--text) 4%, transparent); }
.wd-icon { display: inline-flex; align-items: center; justify-content: center; line-height: 0; color: currentColor; }
.wd-icon svg { display: block; }
.wd-tool-status {
  width: 26px; height: 26px; flex: 0 0 26px;
  border-radius: 8px; background: var(--bg-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.wd-tool-status.pending { animation: none; border-color: var(--border); }
.wd-tool-status.done { color: var(--text); }
.wd-tool-status.declined, .wd-tool-status.error { background: var(--danger-bg); border-color: transparent; color: var(--danger); }
.wd-tool-verb { font-weight: 500; color: var(--muted); }
.wd-tool-target { color: var(--text); }
.wd-file-badge {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 2px 10px; font-size: 11.5px; font-family: var(--font-mono);
}
.wd-file-badge-name { color: var(--muted); }
.wd-file-badge .add { color: var(--success); }
.wd-file-badge .del { color: var(--danger); }
.wd-tool-panel {
  margin-inline-start: 34px;
  border-top: none;
  border-inline-start: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 0;
}

/* ─── Composer mode toggle (Auto/Chat/Plan) — Claude's Chat/Cowork pill pattern ───────────── */
.chat-mode-toggle {
  display: flex; gap: 2px; background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px;
}
.chat-mode-toggle-btn {
  background: none; border: 0; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600;
  padding: 5px 12px; border-radius: 999px; cursor: pointer;
}
.chat-mode-toggle-btn:hover { color: var(--text); }
.chat-mode-toggle-btn.active { background: var(--raised); color: var(--text); box-shadow: var(--shadow-sm); }

/* The crypto checkout quote. The cents are a per-user nonce, not decoration, so the amount is
   set large and monospaced — a user who transcribes it loosely does not get matched. */
.checkout-amount {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0.75rem 0 0.25rem;
  user-select: all;
}

/* Scroll lock while a modal is open (toggled by chat.js) */
html.modal-open, html.modal-open body { overflow: hidden; }

/* ─── Mobile hardening ──────────────────────────────────────────────────── */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button, a, .fui-menu-item, .chat-icon-btn { touch-action: manipulation; }
.chat-messages { overscroll-behavior: contain; }
/* Fingers need bigger targets than cursors. */
@media (pointer: coarse) {
  .chat-composer-controls .chat-icon-btn { width: 40px; height: 40px; }
  .chat-model-btn, .chat-mode-toggle-btn { min-height: 38px; }
  .chat-send-btn, .chat-stop-btn { min-height: 40px; }
  .fui-menu-item { padding: 12px 12px; min-height: 44px; }
}
/* Submenus fly out to the right on desktop; on a phone there is no room, so expand inline. */
@media (max-width: 640px) {
  .fui-submenu, .fui-submenu-open { position: static; margin: 4px 0 0 12px; box-shadow: none; min-width: 0; }
}
.chat-back-link { white-space: nowrap; }
.chat-lang-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap; line-height: 1; flex: 0 0 auto;
}
.chat-lang-btn:hover { border-color: var(--border-strong); }
/* The full "Back to forge.softup.agency" label wrapped onto two lines and crowded the title on phones. */
@media (max-width: 780px) {
  .chat-back-label { display: none; }
  .chat-back-link { font-size: 20px; line-height: 1; padding: 6px 10px; }
}

/* ─── RTL / Arabic ──────────────────────────────────────────────────────────
   Layout mirrors via logical properties above; what remains is direction-bearing glyphs and content
   that must never flip. */
[dir="rtl"] .chat-back-link > span[aria-hidden] { display: inline-block; transform: scaleX(-1); }
/* Code, shell output, paths and diffs are always left-to-right. */
pre, code, .md-code-block, .md-code-inner, .wd-diff, .wd-diff-path, .diff-file-path, .wd-output, .approval-card .cmd {
  direction: ltr; text-align: left; unicode-bidi: isolate;
}
[dir="rtl"] .fui-toggle.checked .fui-toggle-knob { transform: translateX(-16px); }
@media (max-width: 780px) {
  [dir="rtl"] .chat-sidebar { transform: translateX(100%); }
  [dir="rtl"] .chat-sidebar.open { transform: translateX(0); }
}
:lang(ar) body { line-height: 1.7; }
/* Disclosure triangles point toward the reading direction when collapsed. */
[dir="rtl"] .wd-tool-chevron { transform: scaleX(-1); }
[dir="rtl"] .wd-tool-entry.expanded .wd-tool-chevron { transform: rotate(90deg); }
[dir="rtl"] .wd-thinking-toggle::before { content: '◂ '; }
[dir="rtl"] .wd-thinking.open .wd-thinking-toggle::before { content: '▾ '; }
[dir="rtl"] .fui-menu-caret { display: inline-block; transform: scaleX(-1); }

/* ─── Voice input, password reveal, top-bar shortcuts, mobile composer + settings (2026-10-21) ──── */
.password-field { position: relative; display: block; }
.password-field .settings-input { width: 100%; padding-inline-end: 46px; box-sizing: border-box; }
.password-toggle {
  position: absolute; inset-block: 0; inset-inline-end: 0; width: 44px; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--muted); cursor: pointer; border-radius: var(--radius-sm);
}
.password-toggle:hover, .password-toggle:focus-visible { color: var(--text); }
.password-toggle .pw-eye-off, .password-toggle.revealed .pw-eye { display: none; }
.password-toggle.revealed .pw-eye-off { display: block; }

.chat-topbar-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.chat-topbar-btn:hover { background: var(--raised); }
.chat-newchat-top { display: none; }
.chat-topbar-right { gap: 8px; }

.chat-voice-bar {
  max-width: 780px; margin: 0 auto 8px; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--panel);
  --lvl: 0;
}
.chat-voice-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; animation: voicePulse 1.6s ease-in-out infinite; }
.chat-voice-bar.busy .chat-voice-dot { animation: none; opacity: .5; }
.chat-voice-label { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.chat-voice-time { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.chat-voice-level { flex: 1 1 40px; height: 6px; border-radius: 3px; background: var(--bg-2); overflow: hidden; min-width: 24px; }
.chat-voice-level i { display: block; height: 100%; width: calc(var(--lvl) * 100%); background: var(--accent); border-radius: 3px; transition: width .08s linear; }
.chat-voice-bar.busy .chat-voice-level i { width: 100%; opacity: .25; }
.chat-voice-bar .btn { padding: 6px 14px; min-height: 32px; border-radius: 999px; font-size: 13px; flex: 0 0 auto; }

.voice-consent { width: 420px; max-width: calc(100vw - 32px); padding: 22px; box-sizing: border-box; }
.voice-consent h3 { margin: 0 0 10px; font-size: 17px; }
.voice-consent p { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.voice-consent-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.voice-consent-actions .btn { min-height: 40px; }

.settings-voice { border: 1px solid var(--border); border-radius: var(--radius-md, 12px); padding: 14px; background: var(--bg-2); }
.settings-voice p { margin: 0 0 10px; font-size: 13px; line-height: 1.55; color: var(--muted); }
.settings-voice .settings-row { margin-top: 10px; }

@media (max-width: 780px) {
  .chat-newchat-top { display: inline-flex; }
  .chat-back-link { display: none; }
  .chat-topbar-btn { width: 38px; height: 38px; }
  .chat-lang-btn { padding: 6px 8px; }

  /* Composer: one tidy row — attach · model (fills) · mic · voice · send — with the mode switch on its own line below. */
  .chat-composer-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
  .chat-composer-controls-left, .chat-composer-controls-right { display: contents; }
  .chat-attach-btn { order: 1; }
  .chat-model-btn { order: 2; flex: 1 1 0; min-width: 0; max-width: none; overflow: hidden; text-overflow: ellipsis; text-align: start; padding-inline-end: 24px; position: relative; }
  .chat-model-btn::after { content: '▾'; position: absolute; inset-inline-end: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 11px; }
  .chat-mic-btn { order: 3; } .chat-voice-btn { order: 4; }
  .chat-send-btn, .chat-stop-btn { order: 5; }
  .chat-mode-toggle { order: 6; flex: 1 0 100%; }
  .chat-mode-toggle-btn { flex: 1; text-align: center; min-height: 36px; }
  .chat-composer-controls .chat-icon-btn { width: 40px; height: 40px; }
  .chat-voice-bar { border-radius: 16px; flex-wrap: wrap; }
  .chat-voice-level { order: 5; flex: 1 0 100%; }

  /* Settings: full-screen sheet with a horizontally scrolling tab strip instead of a 180px sidebar. */
  .fui-modal-overlay:has(> .settings-modal) { padding: 0; align-items: stretch; justify-content: stretch; }
  .settings-modal { width: 100vw; max-width: 100vw; height: 100%; max-height: none; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top, 0px); }
  .settings-title { padding: 14px 56px 12px 16px; }
  .settings-close { top: calc(10px + env(safe-area-inset-top, 0px)); inset-inline-end: 8px; width: 40px; height: 40px; }
  .settings-layout { flex-direction: column; }
  .settings-nav { flex: 0 0 auto; flex-direction: row; overflow-x: auto; overflow-y: hidden; border-inline-end: 0; border-bottom: 1px solid var(--border); padding: 8px 10px; gap: 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-nav-item { flex: 0 0 auto; white-space: nowrap; min-height: 40px; padding: 8px 14px; border-radius: 999px; }
  .settings-nav-item.active { box-shadow: inset 0 0 0 1px var(--border-strong, var(--border)); }
  .settings-body { padding: 16px max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .settings-row { flex-wrap: wrap; }
  .settings-row .btn { min-height: 44px; }
  .settings-input { min-height: 44px; }
  .auth-modal .settings-input, .auth-submit-btn { min-height: 46px; }
}
@media (pointer: coarse) { .password-toggle { width: 48px; } }
@media (prefers-reduced-motion: reduce) { .chat-voice-dot, .chat-voice-btn.listening { animation: none; } }

.auth-consent { display: flex; align-items: flex-start; gap: 10px; margin: 10px 0 2px; font-size: 12.5px; line-height: 1.5; color: var(--muted); cursor: pointer; text-align: start; }
.auth-consent input { margin-top: 3px; flex: none; width: 16px; height: 16px; accent-color: var(--accent, #8b5cf6); }
.data-consent-list { margin: 8px 0 12px; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; line-height: 1.5; }

.wd-rate-pop { margin: 8px 0 4px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); display: flex; flex-direction: column; gap: 10px; max-width: 480px; }
.wd-rate-title { font-weight: 600; font-size: 13px; }
.wd-rate-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.wd-rate-chip { border: 1px solid var(--border); background: transparent; color: inherit; border-radius: 999px; padding: 4px 12px; font-size: 12.5px; cursor: pointer; }
.wd-rate-chip.on { background: var(--accent, #8b5cf6); border-color: transparent; color: #fff; }
.wd-rate-comment { resize: vertical; min-height: 52px; font: inherit; font-size: 13px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: inherit; }
.wd-rate-note { font-size: 11.5px; color: var(--muted); }
.wd-rate-actions { display: flex; gap: 8px; justify-content: flex-end; }
.wd-rate-failed { outline: 1px solid var(--danger, #f87171); border-radius: 8px; }

/* Collapsed rail: show the standalone MARK image — never the lockup clipped to its left edge (that depended on the
   lockup's aspect ratio and overflow behaviour, and could show a sliver of the wordmark next to the icon). */
.chat-brand .brand-mark { display: none; height: 30px; width: auto; }
@media (min-width: 781px) {
  .chat-sidebar.collapsed .chat-brand { width: auto; height: auto; overflow: visible; justify-content: center; cursor: pointer; }
  .chat-sidebar.collapsed .chat-brand .brand-logo { display: none !important; }
  .chat-sidebar.collapsed .chat-brand .brand-mark { display: block; }
}
.chat-link-dot { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; }
.chat-link-dot:hover { background: var(--panel); }
.chat-link-dot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chat-link-dot-led { width: 10px; height: 10px; border-radius: 50%; background: var(--warning, #fbbf24); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning, #fbbf24) 22%, transparent); }
.chat-link-dot[data-state="computer"] .chat-link-dot-led { background: var(--success, #22c55e); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success, #22c55e) 22%, transparent); }
.chat-link-dot[data-state="cloud"] .chat-link-dot-led { background: var(--accent, #8b5cf6); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #8b5cf6) 22%, transparent); }
.chat-link-dot[data-state="disconnected"] .chat-link-dot-led, .chat-link-dot[data-state="revoked"] .chat-link-dot-led,
.chat-link-dot[data-state="unauthorized"] .chat-link-dot-led, .chat-link-dot[data-state="replaced"] .chat-link-dot-led { background: var(--danger, #f87171); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger, #f87171) 22%, transparent); }
