/*
 * LemixCode web UI. Plain CSS in the style of shadcn/ui (style "Mira", base colour Neutral, Inter, Lucide icons, default radius).
 * Token names and values follow the shadcn neutral theme (https://ui.shadcn.com/docs/theming); component metrics follow the Mira
 * style (button 28px, text 12px, radius 8px / cards 10px). Light theme; the `.dark` block holds the shadcn dark tokens.
 */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/InterVariable.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 14px;
  --background: #ffffff;
  --foreground: #0a0a0a;
  --card: #ffffff;
  --card-foreground: #0a0a0a;
  --popover: #ffffff;
  --popover-foreground: #0a0a0a;
  --primary: #000000;
  --primary-foreground: #fafafa;
  --secondary: #f5f5f5;
  --secondary-foreground: #171717;
  --muted: #f5f5f5;
  --muted-foreground: #6b6b6b; /* shadcn #737373, darkened a little to keep AA contrast on --muted */
  --accent: #f5f5f5;
  --accent-foreground: #171717;
  --destructive: #e7000b;
  --destructive-foreground: #c10007; /* text colour on tinted destructive backgrounds (AA) */
  --border: #e5e5e5;
  --input: #e5e5e5;
  --ring: #a1a1a1;
  /* The page behind the cards is a very light grey, the cards are white. */
  --canvas: #f5f5f5;
  --field: #fafafa; /* shadcn bg-input/20 on white */
  /* Status colours that shadcn leaves to the app (Tailwind green/amber/red 700 on 50). */
  --success: #15803d;
  --success-soft: #f0fdf4;
  --success-line: #bbf7d0;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --warning-line: #fde68a;
  --destructive-soft: #fef2f2;
  --destructive-line: #fecaca;
  /* One metric for every button, menu trigger, tab, toolbar control and input (Mira "default" size). */
  --control-h: 28px;
  --control-px: 8px;
  --control-gap: 6px;
  --control-fs: 12px;
  --control-fw: 500;
  --control-radius: 8px;
  --pane-header-h: 52px; /* both pane headers: 28px controls with 12px above and below */
  --icon-size: 16px;
  --icon-size-sm: 14px;
  --ring-focus: 0 0 0 2px rgba(161, 161, 161, .3);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -2px rgba(0, 0, 0, .1);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  /* Aliases kept for the standalone document pages (concept.html, state-machines.html). */
  --text: var(--foreground);
  --text-muted: #525252;
  --text-faint: var(--muted-foreground);
  --surface: var(--card);
  --surface-muted: #fafafa;
  --surface-strong: var(--muted);
  --line: var(--border);
  --line-strong: #d4d4d4;
  --accent-hover: #262626;
  --accent-soft: var(--muted);
  --accent-line: #d4d4d4;
  --danger: var(--destructive-foreground);
  --danger-soft: var(--destructive-soft);
  --danger-line: var(--destructive-line);
  --shadow-sm: var(--shadow-xs);
  --shadow-lg: var(--shadow-md);
}

.dark {
  color-scheme: dark;
  --background: #0a0a0a;
  --foreground: #fafafa;
  --card: #171717;
  --card-foreground: #fafafa;
  --popover: #171717;
  --popover-foreground: #fafafa;
  --primary: #e5e5e5;
  --primary-foreground: #171717;
  --secondary: #262626;
  --secondary-foreground: #fafafa;
  --muted: #262626;
  --muted-foreground: #a1a1a1;
  --accent: #404040;
  --accent-foreground: #fafafa;
  --destructive: #ff6467;
  --destructive-foreground: #ff6467;
  --border: rgba(255, 255, 255, .1);
  --input: rgba(255, 255, 255, .15);
  --ring: #737373;
  --canvas: #0a0a0a;
  --field: rgba(255, 255, 255, .05);
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, .1);
  --success-line: rgba(74, 222, 128, .3);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, .1);
  --warning-line: rgba(251, 191, 36, .3);
  --destructive-soft: rgba(255, 100, 103, .1);
  --destructive-line: rgba(255, 100, 103, .3);
  --text-muted: #a1a1a1;
  --surface-muted: #1f1f1f;
  --line-strong: #404040;
  --accent-hover: #fafafa;
  --accent-line: #404040;
}

* { box-sizing: border-box; border-color: var(--border); }
html { min-width: 320px; background: var(--canvas); }
body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--canvas);
  color: var(--foreground);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--foreground); text-underline-offset: 3px; }
h1, h2, h3, h4, p { margin-top: 0; }
h1, h2, h3, h4 { color: var(--foreground); font-weight: 600; letter-spacing: -.01em; line-height: 1.25; }
code { font-family: var(--mono); font-size: .9em; overflow-wrap: anywhere; }
[hidden] { display: none !important; }
::selection { color: var(--primary-foreground); background: var(--primary); }
.sr-only { width: 1px !important; height: 1px !important; position: absolute !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; clip-path: inset(50%) !important; white-space: nowrap !important; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
kbd { height: 20px; min-width: 20px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 0 4px; border-radius: 3px; background: var(--muted); color: var(--muted-foreground); font-family: var(--font); font-size: 10px; font-weight: 500; line-height: 1; }

/* ---------- shared layout ---------- */
.page { width: min(100%, 1200px); margin: 0 auto; padding: 28px 22px 56px; }
.page-narrow { width: min(100%, 600px); margin: 0 auto; padding: 36px 20px 56px; }
.center-screen { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.eyebrow { margin: 0 0 8px; color: var(--muted-foreground); font-size: 10px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; }
.section-heading { margin-bottom: 16px; }
.section-heading h1 { margin-bottom: 6px; font-size: 24px; }
.section-heading p { max-width: 640px; margin-bottom: 0; color: var(--muted-foreground); }
.muted { color: var(--muted-foreground); }
.subtle { color: var(--muted-foreground); }
.mono { font-family: var(--mono); }

/* ---------- repository header (left pane) ---------- */
.repository-title { min-width: 0; display: flex; align-items: center; gap: 8px; }
.repository-title .repository-name { min-width: 0; overflow: hidden; font-size: 14px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.repository-title .repository-name.placeholder { color: var(--muted-foreground); }
.repository-title .repository-switch { flex: none; margin-left: -6px; }
.settings-link { color: var(--foreground); }

/* ---------- custom select (shadcn Select; see shared/select.js) ---------- */
.select { min-width: 0; max-width: 100%; position: relative; display: inline-flex; vertical-align: middle; }
.field .select, .compact-field .select { display: flex; width: 100%; }
.field .select-trigger { width: 100%; }
/* The native select stays in the DOM as the source of truth but is not shown. */
.select-native { width: 1px; height: 1px; position: absolute; overflow: hidden; margin: -1px; padding: 0; border: 0; opacity: 0; clip: rect(0, 0, 0, 0); clip-path: inset(50%); pointer-events: none; white-space: nowrap; }
.select-popover { max-height: 288px; position: fixed; z-index: 100; overflow-y: auto; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--popover); color: var(--popover-foreground); box-shadow: var(--shadow-md); }
.select-option { min-height: var(--control-h); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 8px; border-radius: var(--radius-md); cursor: pointer; font-size: var(--control-fs); line-height: 1.25; white-space: nowrap; user-select: none; }
.select-option > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.select-option.active { background: var(--accent); color: var(--accent-foreground); }
.select-option[aria-disabled="true"] { cursor: not-allowed; opacity: .5; }
.select-check { width: var(--icon-size-sm); height: var(--icon-size-sm); flex: none; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }

/* ---------- icons ---------- */
.btn svg, .round-btn svg, .chrome-action svg, .device-toggle svg, .composer-control svg:not(.menu-chevron) { width: var(--icon-size); height: var(--icon-size); flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.menu-chevron, .select-chevron { width: var(--icon-size-sm); height: var(--icon-size-sm); display: block; flex: none; color: var(--muted-foreground); fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; transform-origin: center; transition: transform .15s ease; }
/* The "sparkles" glyph (Lucide) in empty states replaces the text star. */
.chat-empty > span, .claude-connect > span {
  width: 32px; height: 32px; display: block; margin-bottom: 4px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--muted); font-size: 0; line-height: 0;
  position: relative; color: var(--foreground);
}
.chat-empty > span::after, .claude-connect > span::after {
  width: 16px; height: 16px; position: absolute; inset: 7px; background: currentColor; content: "";
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z'/%3E%3Cpath d='M20 3v4M22 5h-4M4 17v2M5 18H3'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z'/%3E%3Cpath d='M20 3v4M22 5h-4M4 17v2M5 18H3'/%3E%3C/svg%3E") center / contain no-repeat;
}

/*
 * One control system (shadcn Button, size "default"). Every button, link button, menu trigger, tab, toolbar control and
 * select trigger shares the metrics of :root (--control-h, --control-px, --control-fs, --control-radius, --icon-size).
 * Variants only change colours: primary = black, secondary = outline (white, grey border), ghost = text only.
 */
.btn, .round-btn, .select-trigger, .composer-control, .tab, .chrome-action, .device-toggle button, .zoom-control button,
.preview-target-switch button, .pick-menu > .pick-trigger, .chip, .agent-interrupt, .field-password .pw-toggle {
  height: var(--control-h); min-height: var(--control-h); display: inline-flex; align-items: center; justify-content: center; gap: var(--control-gap);
  appearance: none; margin: 0; padding: 0 var(--control-px); border: 1px solid transparent; border-radius: var(--control-radius); background: transparent; color: var(--foreground);
  cursor: pointer; font-family: var(--font); font-size: var(--control-fs); font-weight: var(--control-fw); line-height: 1; text-align: center; text-decoration: none; white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.btn-icon, .round-btn, .chrome-action { width: var(--control-h); min-width: var(--control-h); padding: 0; }
.btn-arrow { font-size: var(--control-fs); font-weight: var(--control-fw); }
.btn-block { width: 100%; }
/* default = primary */
.btn-primary, .round-btn.send { border-color: var(--primary); background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover:not(:disabled), .round-btn.send:hover:not(:disabled) { background: rgba(0, 0, 0, .8); }
/* secondary = outline */
.btn-secondary, .select-trigger, .composer-control, .pick-menu > .pick-trigger, .chip { border-color: var(--border); background: var(--background); color: var(--foreground); }
.btn-secondary:hover:not(:disabled), .select-trigger:hover:not(:disabled), .select-trigger[aria-expanded="true"], .composer-control:hover, .composer-menu[open] > .composer-control, .pick-menu > .pick-trigger:hover, .pick-menu[open] > .pick-trigger, .chip:hover { background: var(--accent); color: var(--accent-foreground); }
/* ghost */
.btn-ghost, .chrome-action, .round-btn, .agent-interrupt, .field-password .pw-toggle { color: var(--foreground); }
.btn-ghost:hover:not(:disabled), .chrome-action:hover, .round-btn:hover:not(:disabled, .send), .agent-interrupt:hover, .field-password .pw-toggle:hover { background: var(--muted); color: var(--foreground); }
/* destructive (soft) */
.btn-danger { background: var(--destructive-soft); color: var(--destructive-foreground); }
.btn-danger:hover:not(:disabled) { background: var(--destructive-line); }
.btn[disabled], .btn:disabled, .btn[aria-disabled="true"], .select-trigger:disabled, .round-btn:disabled, .agent-interrupt:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn.btn-complete:disabled { border-color: var(--success-line); background: var(--success-soft); color: var(--success); opacity: 1; }
.pick-menu[data-busy] > .pick-trigger { cursor: wait; opacity: .55; pointer-events: none; }
.btn:focus-visible, .round-btn:focus-visible, .select-trigger:focus-visible, .composer-control:focus-visible, .tab:focus-visible, .chrome-action:focus-visible, .device-toggle button:focus-visible,
.zoom-control button:focus-visible, .preview-target-switch button:focus-visible, .pick-menu > .pick-trigger:focus-visible, .chip:focus-visible, .agent-interrupt:focus-visible,
.field-password .pw-toggle:focus-visible, .pick-option:focus-visible, .menu-option:focus-visible { outline: none; border-color: var(--ring); box-shadow: var(--ring-focus); }
.btn:active:not(:disabled), .round-btn:active:not(:disabled) { transform: translateY(1px); }
.plan-actions .btn, .platform-user-form .btn { font-size: var(--control-fs); }

/* Dropdown triggers (custom select, preview page picker, composer menus): outline buttons with the label on the left and the chevron on the right. */
.select-trigger, .pick-menu > .pick-trigger, .composer-control { min-width: 0; justify-content: space-between; text-align: left; }
.pick-menu > .pick-trigger { max-width: 210px; }
.select-trigger { max-width: 100%; }
.select-value, .pick-menu > .pick-trigger > span { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer-control code { width: 16px; height: 16px; display: grid; place-items: center; border-radius: 4px; background: var(--muted); color: var(--foreground); font-size: 10px; }
.attach-btn { align-self: flex-end; }
.attach-btn[hidden] { display: none; }
.field-password .pw-toggle { position: absolute; right: 0; top: 0; min-width: 52px; padding: 0 8px; }
.chip { font-weight: 500; }

/* Segmented controls (tabs, preview target, device, zoom): shadcn Tabs list, equally high triggers on a muted track. */
.tabs, .preview-target-switch, .device-toggle, .zoom-control { display: inline-flex; flex: none; align-items: center; gap: 2px; padding: 2px; border-radius: var(--radius-lg); background: var(--muted); }
.tab, .preview-target-switch button, .device-toggle button, .zoom-control button { color: var(--muted-foreground); }
.tab:hover:not(.active), .preview-target-switch button:hover:not(.active), .device-toggle button:hover:not(.active), .zoom-control button:hover:not(:disabled) { color: var(--foreground); }
.tab.active, .device-toggle button.active, .preview-target-switch button.active { border-color: var(--border); background: var(--background); color: var(--foreground); box-shadow: var(--shadow-xs); }
.device-toggle button, .zoom-control button { width: var(--control-h); min-width: var(--control-h); padding: 0; }
.preview-target-switch button { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.zoom-control .zoom-value { width: 52px; min-width: 52px; font-variant-numeric: tabular-nums; }
.zoom-control button:disabled, .preview-target-switch button:disabled { cursor: not-allowed; opacity: .5; }
.right-col .pane-header-actions { margin-left: auto; }

/* ---------- cards ---------- */
.card { padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); color: var(--card-foreground); }
.card + .card { margin-top: 12px; }
.card-danger { border-color: var(--destructive-line); }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-title { margin: 0 0 4px; font-size: 14px; font-weight: 500; line-height: 1.25; letter-spacing: 0; }
.card-subtitle { max-width: 560px; margin: 0; color: var(--muted-foreground); font-size: 12px; line-height: 1.625; }
.card-divider { height: 1px; margin: 16px 0; background: var(--border); }

/* ---------- forms ---------- */
.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field label, .field-label { display: block; margin-bottom: 6px; color: var(--foreground); font-size: 12px; font-weight: 500; line-height: 1; }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="url"], .field input[type="number"],
.platform-repo-filter, .platform-repo-id, .platform-repo-project-name, .claude-auth-code-row input, .plan-feedback-input, .permission-form input {
  width: 100%; height: var(--control-h); min-height: var(--control-h); padding: 0 8px; outline: none; border: 1px solid var(--input); border-radius: var(--control-radius); background-color: var(--field); color: var(--foreground);
  font-size: var(--control-fs); line-height: 1.2; transition: border-color .15s ease, box-shadow .15s ease;
}
.field textarea { width: 100%; min-height: 72px; padding: 6px 8px; outline: none; border: 1px solid var(--input); border-radius: var(--control-radius); background: var(--field); color: var(--foreground); font-family: var(--mono); font-size: 12px; line-height: 1.625; resize: vertical; }
.field input::placeholder, .field textarea::placeholder, .chat-input-row textarea::placeholder { color: var(--muted-foreground); opacity: 1; }
.field input:hover, .field textarea:hover { border-color: var(--ring); }
.field input:focus, .field textarea:focus, .platform-repo-filter:focus, .platform-repo-id:focus, .platform-repo-project-name:focus,
.claude-auth-code-row input:focus, .plan-feedback-input:focus, .permission-form input:focus { border-color: var(--ring); box-shadow: var(--ring-focus); }
.helper { margin-top: 6px; color: var(--muted-foreground); font-size: 12px; line-height: 1.5; }
.helper a { font-weight: 500; text-underline-offset: 2px; }
.field-password { position: relative; }
.field-password input { padding-right: 60px !important; }
.field-password .pw-toggle { top: auto; bottom: 0; }
.compact-field { margin-bottom: 8px; }
.compact-field label { margin-bottom: 6px; font-size: 12px; }
fieldset { margin: 0; padding: 0; border: 0; }
.radio-group { display: grid; gap: 6px; margin-top: 6px; }
.radio-row { min-height: 36px; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--background); font-size: 12px; }
.radio-row:has(input:checked) { border-color: var(--foreground); background: var(--muted); }
.radio-row:has(input:disabled) { opacity: .5; }
.radio-row input { width: 14px; height: 14px; margin: 0; accent-color: var(--primary); }
.radio-row label { min-width: 0; margin: 0; cursor: pointer; overflow-wrap: anywhere; }
.form-grid { display: grid; grid-template-columns: 1fr 140px; gap: 12px; }
details.adv { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
details.adv summary { display: flex; align-items: center; gap: 6px; color: var(--muted-foreground); cursor: pointer; font-size: 12px; font-weight: 500; list-style: none; }
details.adv summary::-webkit-details-marker { display: none; }
details.adv summary::before { content: "+"; font-size: 14px; font-weight: 400; }
details.adv[open] summary::before { content: "−"; }
details.adv .adv-body { padding-top: 12px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }
.popover-divider { height: 1px; margin: 12px -12px; background: var(--border); }
.popover-section-label { margin-bottom: 6px; color: var(--muted-foreground); font-size: 10px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }

/* ---------- badges ---------- */
.badge { max-width: 100%; height: 20px; display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--background); color: var(--foreground); font-size: 11px; font-weight: 500; line-height: 1; white-space: nowrap; }
.badge code { font-family: var(--mono); font-size: 11px; }
.badge-neutral { background: var(--background); color: var(--foreground); }
.badge-accent { border-color: transparent; background: var(--secondary); color: var(--secondary-foreground); }
.badge-success { border-color: var(--success-line); background: var(--success-soft); color: var(--success); }
.badge-warning { border-color: var(--warning-line); background: var(--warning-soft); color: var(--warning); }
.badge-danger { border-color: var(--destructive-line); background: var(--destructive-soft); color: var(--destructive-foreground); }
.badge-count { min-width: 16px; padding: 0 4px; border-radius: 999px; background: var(--muted); color: inherit; font-size: 10px; text-align: center; }
.badge-dot { width: 6px; height: 6px; display: inline-block; flex: none; border-radius: 50%; background: currentColor; }
.pulse { animation: gh-pulse 1.8s ease-in-out infinite; }
@keyframes gh-pulse { 50% { opacity: .38; } }
.inline-error, .inline-feedback { margin: 6px 0 0; color: var(--destructive-foreground); font-size: 12px; line-height: 1.5; }
.inline-feedback { color: var(--success); }
.inline-feedback.error { color: var(--destructive-foreground); }

.claude-auth-flow { width: 100%; display: grid; gap: 8px; }
.claude-auth-step { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 8px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--background); }
.claude-auth-number { width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: var(--muted); color: var(--foreground); font-size: 10px; font-weight: 500; }
.claude-auth-step strong, .claude-auth-step label { display: block; margin: 0 0 2px; color: var(--foreground); font-size: 12px; font-weight: 500; }
.claude-auth-step p { margin: 0 0 6px; color: var(--muted-foreground); font-size: 12px; line-height: 1.5; }
.claude-auth-link-row { min-width: 0; display: flex; align-items: center; gap: 6px; }
.claude-auth-link { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.claude-auth-code-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.claude-auth-code-row input { min-width: 0; font-family: var(--mono); font-size: 12px; }
/* The "Connect Claude" state in the chat area; it stays at the top of the chat while the history scrolls. */
.chat-empty.claude-connect { width: 100%; max-width: none; min-width: 0; flex: 1; align-content: center; justify-items: center; gap: 10px; padding: 24px clamp(16px, 8%, 96px); }
.claude-connect > strong { font-size: 18px; }
.claude-connect > p { max-width: 560px; font-size: 13px; }
.claude-connect .btn-primary { margin-top: 4px; }
.claude-connect .claude-auth-step { text-align: left; padding: 12px; }
.claude-connect .claude-auth-flow { width: 100%; min-width: 0; max-width: 960px; margin-top: 8px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.claude-connect-status { margin: 0; color: var(--muted-foreground); font-size: 12px; }
.claude-connect .inline-error { margin: 0; overflow-wrap: anywhere; }
/* While the sign-in is shown it is the chat column: the history stays loaded but steps back. */
.chat-scroll.chat-connect-active { padding: 0; }
.chat-scroll.chat-connect-active > :not([data-claude-connect]) { display: none; }
.preview-wait-spinner { width: 20px; height: 20px; display: block; border: 2px solid var(--border); border-top-color: var(--foreground); border-radius: 50%; animation: task-spin .9s linear infinite; }

/* ---------- login ---------- */
.welcome-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.welcome-shell { width: min(100%, 420px); display: block; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); }
.welcome-copy { display: flex; flex-direction: column; gap: 0; }
.welcome-copy h1 { margin-bottom: 8px; font-size: 24px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.welcome-copy > p { margin-bottom: 16px; color: var(--muted-foreground); font-size: 14px; line-height: 1.5; }
.welcome-copy > .eyebrow { margin-bottom: 12px; }
.welcome-actions { display: grid; gap: 12px; margin-top: 8px; }
.welcome-actions .btn { width: 100%; }
.login-error { margin: 0; padding: 8px 10px; border: 1px solid var(--destructive-line); border-radius: var(--radius-lg); background: var(--destructive-soft); color: var(--destructive-foreground); font-size: 13px; line-height: 1.5; }
.login-error[hidden] { display: none; }
.welcome-actions .badge { justify-self: center; }
.welcome-byline { margin: 16px 0 0 !important; color: var(--muted-foreground) !important; font-size: 12px !important; text-align: center; }

/* ---------- workspace ---------- */
body[data-page="workspace"] { height: 100vh; height: 100dvh; overflow: hidden; }
.workspace-page { width: 100%; margin: 0; padding: 8px; }
.workspace-grid { height: calc(100vh - 16px); height: calc(100dvh - 16px); min-height: 520px; display: grid; grid-template-columns: minmax(330px, .8fr) minmax(0, 1.45fr); gap: 8px; position: relative; }
.workspace-splitter { width: 12px; position: absolute; z-index: 12; top: 0; bottom: 0; left: 0; padding: 0; border: 0; outline: none; background: transparent; cursor: col-resize; touch-action: none; transform: translateX(-50%); }
.workspace-splitter::before { width: 4px; height: 32px; position: absolute; top: 50%; left: 50%; border: 1px solid var(--border); border-radius: 999px; background: var(--background); content: ""; transform: translate(-50%, -50%); transition: height .15s ease, border-color .15s ease; }
.workspace-splitter:hover::before, .workspace-splitter:focus-visible::before, .workspace-splitter.dragging::before { height: 44px; border-color: var(--ring); background: var(--muted); }
body.workspace-resizing, body.workspace-resizing * { cursor: col-resize !important; user-select: none !important; }
.pane { min-width: 0; min-height: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); }
.pane-header { height: var(--pane-header-h); min-height: var(--pane-header-h); flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; position: relative; padding: 0 12px; border-bottom: 1px solid var(--border); background: var(--card); }
.pane-title { min-width: 0; flex: 1 1 auto; }
.pane-title strong { display: block; font-size: 14px; font-weight: 500; line-height: 1.25; }
.pane-title span { display: block; margin-top: 2px; color: var(--muted-foreground); font-size: 12px; }
.pane-header-actions { min-width: 0; display: flex; align-items: center; gap: 8px; }
.publish-button { max-width: 210px; white-space: nowrap; }
.publish-button svg { flex: none; }
.publish-button[data-state="published"] { border-color: var(--success-line); background: var(--success-soft); color: var(--success); }
.publish-button[hidden] { display: none; }
.connection-inline { width: 6px; height: 6px; display: inline-block !important; margin: 0 3px 1px 0 !important; border-radius: 50%; background: var(--success); }
.connection-inline.offline { background: var(--muted-foreground); }
.chat-col { position: relative; display: flex; flex-direction: column; container-type: inline-size; }

/* Notices: shadcn Alert (bordered, card background, 12px text). */
.workspace-notice { margin: 8px 8px 0; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); color: var(--muted-foreground); font-size: 12px; line-height: 1.625; text-align: left; }
.workspace-notice.progress { color: var(--foreground); }
.workspace-notice.warning { border-color: var(--warning-line); background: var(--warning-soft); color: var(--warning); }
.workspace-notice.danger { border-color: var(--destructive-line); background: var(--destructive-soft); color: var(--destructive-foreground); }
.workspace-notice .notice-action { color: inherit; font-weight: 600; text-decoration: underline; }
.chat-scroll { min-height: 0; display: flex; flex: 1; flex-direction: column; gap: 12px; overflow-y: auto; overscroll-behavior: contain; padding: 16px 12px; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.chat-empty { max-width: 320px; display: grid; place-items: center; gap: 4px; margin: auto; color: var(--muted-foreground); text-align: center; }
.chat-empty strong { color: var(--foreground); font-size: 14px; font-weight: 500; }
.chat-empty p { margin: 0; font-size: 12px; line-height: 1.625; }

/* Chat: the agent writes plain text, the user speaks in a muted bubble. */
.msg { display: flex; }
.msg-assistant { justify-content: flex-start; }
.msg-user { justify-content: flex-end; }
.msg-bubble { max-width: 88%; padding: 0; font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.msg-assistant .msg-bubble { max-width: 100%; }
.msg-user .msg-bubble { padding: 6px 10px; border-radius: var(--radius-lg); background: var(--muted); color: var(--foreground); }
.msg-queue-state { display: block; margin-top: 4px; color: var(--muted-foreground); font-size: 10px; font-weight: 500; }
.msg-queue-state.failed { color: var(--destructive-foreground); }
.msg-resend { padding: 0; border: 0; background: none; color: var(--foreground); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.msg-resend:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.agent-working { max-width: 100%; display: flex; align-items: center; gap: 8px; padding: 2px; color: var(--muted-foreground); }
.agent-working .task-spinner { width: 14px; height: 14px; flex: none; }
.agent-working-copy { min-width: 0; flex: 1; }
.agent-working-copy strong, .agent-working-copy small { display: block; }
.agent-working-copy strong { color: var(--foreground); font-size: 12px; font-weight: 500; }
.agent-working-copy small { margin-top: 1px; color: var(--muted-foreground); font-size: 11px; line-height: 1.4; }
.agent-thinking { max-width: 100%; color: var(--muted-foreground); font-size: 12px; }
.agent-thinking > summary { width: fit-content; display: flex; align-items: center; gap: 6px; padding: 2px; color: var(--muted-foreground); cursor: pointer; font-size: 12px; font-weight: 500; list-style: none; }
.agent-thinking > summary::-webkit-details-marker { display: none; }
.thinking-spark { color: var(--foreground); }
.agent-thinking-body { margin-top: 4px; padding: 8px; border-radius: var(--radius-md); background: var(--muted); color: var(--muted-foreground); font-size: 12px; }
.msg-plan { width: 100%; }
.msg-plan .plan-message { width: min(100%, 560px); max-width: 100%; padding: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); }
.plan-message-header { min-height: 40px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.plan-message-title { display: inline-flex; align-items: center; gap: 8px; color: var(--foreground); }
.plan-message-title strong { font-size: 12px; font-weight: 500; }
.plan-message-icon { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; background: var(--primary); color: var(--primary-foreground); font-size: 10px; font-weight: 600; }
.plan-message-state { color: var(--muted-foreground); font-size: 10px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; }
.plan-message-body { padding: 12px; color: var(--foreground); }
.plan-message-body ol, .plan-message-body ul { margin-top: 8px; }
.plan-message-body li::marker { color: var(--muted-foreground); font-weight: 500; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }
.markdown-body h2, .markdown-body h3, .markdown-body h4 { margin: 14px 0 6px; font-size: 14px; }
.markdown-body p { margin: 0 0 8px; }
.markdown-body ul, .markdown-body ol { margin: 6px 0 10px; padding-left: 20px; }
.markdown-body li { margin: 2px 0; }
.markdown-body pre { max-width: 100%; overflow-x: auto; margin: 8px 0; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--muted); color: var(--foreground); font-size: 12px; line-height: 1.55; }
.markdown-body :not(pre) > code { padding: 1px 4px; border-radius: 4px; background: var(--muted); }
.markdown-body a { font-weight: 500; text-underline-offset: 2px; }
.chat-system { display: grid; gap: 2px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); color: var(--muted-foreground); font-size: 12px; line-height: 1.5; }
.chat-system strong { color: var(--foreground); font-size: 12px; font-weight: 500; }
.chat-system > span { white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-system.success { border-color: var(--success-line); background: var(--success-soft); color: var(--success); }
.chat-system.warning { border-color: var(--warning-line); background: var(--warning-soft); color: var(--warning); }
.chat-system.danger { border-color: var(--destructive-line); background: var(--destructive-soft); color: var(--destructive-foreground); }
.chat-system.success strong, .chat-system.warning strong, .chat-system.danger strong { color: inherit; }
.msg-filechip { max-width: 100%; display: inline-flex; align-items: center; gap: 6px; margin: 6px 4px 1px 0; padding: 2px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--background); color: var(--foreground); font-family: var(--mono); font-size: 11px; overflow-wrap: anywhere; }
.msg-filechip::before { color: var(--muted-foreground); content: "↳"; font-family: var(--font); }
.chat-suggestions { padding: 8px 12px; border-top: 1px solid var(--border); background: var(--background); }
.chat-suggestions .label { margin-bottom: 6px; color: var(--muted-foreground); font-size: 10px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
.chip-row { display: flex; flex-wrap: wrap; gap: 4px; }

/* Composer: a bordered, rounded input with its controls and a toolbar below. */
.chat-composer { position: relative; z-index: 4; padding: 8px 12px 10px; border-top: 1px solid var(--border); background: var(--card); }
.chat-input-row { display: flex; align-items: flex-end; gap: 4px; padding: 4px; border: 1px solid var(--input); border-radius: var(--radius-lg); background: var(--background); transition: border-color .15s ease, box-shadow .15s ease; }
.chat-input-row:focus-within { border-color: var(--ring); box-shadow: var(--ring-focus); }
.chat-input-row textarea { min-width: 0; min-height: var(--control-h); max-height: 144px; flex: 1; resize: none; overflow-y: auto; padding: 5px 4px; outline: none; border: 0; background: transparent; color: var(--foreground); font: inherit; font-size: 13px; line-height: 1.5; }
.composer-hint { margin: 6px 4px 0; color: var(--muted-foreground); font-size: 11px; }
.composer-toolbar { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; row-gap: 2px; margin-top: 6px; padding: 0; }
.composer-controls { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.composer-toolbar .composer-hint { flex: none; margin: 0; white-space: nowrap; }
.mode-symbol { color: var(--foreground); }
.working-dot { width: 6px; height: 6px; display: inline-block; border-radius: 50%; background: var(--foreground); box-shadow: 0 0 0 0 rgba(0, 0, 0, .28); animation: working-pulse 1.5s ease-out infinite; }
@keyframes working-pulse { 70%, 100% { box-shadow: 0 0 0 6px rgba(0, 0, 0, 0); } }

/* Menus and popovers: shadcn DropdownMenu / Popover (card background, 1px border, shadow-md, 4px padding, 28px items). */
.workspace-menu { position: relative; }
.workspace-menu > summary { list-style: none; }
.workspace-menu > summary::-webkit-details-marker { display: none; }
.workspace-menu[open] > summary .menu-chevron { transform: rotate(180deg); }
.composer-menu { position: static; }
.composer-popover, .pick-popover { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--popover); color: var(--popover-foreground); box-shadow: var(--shadow-md); }
.usage-list { display: grid; gap: 8px; }
.usage-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 12px; }
.usage-row strong, .usage-row span { display: block; }
.usage-row strong { font-size: 12px; font-weight: 500; }
.usage-row span { color: var(--muted-foreground); font-size: 11px; }
.usage-row em { align-self: center; color: var(--muted-foreground); font-family: var(--mono); font-size: 11px; font-style: normal; }
.usage-track { width: 100%; height: 4px; grid-column: 1 / -1; margin-top: 4px; overflow: hidden; border: 0; border-radius: 99px; background: var(--muted); appearance: none; }
.usage-track::-webkit-progress-bar { border-radius: inherit; background: var(--muted); }
.usage-track::-webkit-progress-value { border-radius: inherit; background: var(--primary); }
.usage-track::-moz-progress-bar { border-radius: inherit; background: var(--primary); }
.task-spinner { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--foreground); border-radius: 50%; animation: task-spin .9s linear infinite; }
@keyframes task-spin { to { transform: rotate(360deg); } }
.popover-empty { margin: 6px 4px; color: var(--muted-foreground); font-size: 12px; line-height: 1.5; }

.composer-popover { width: auto; max-height: min(430px, calc(100dvh - 210px)); position: absolute; right: 12px; bottom: calc(100% - 2px); left: 12px; z-index: 60; overflow-y: auto; padding: 4px; }
.command-popover { width: auto; }
.menu-title { padding: 6px 8px 8px; }
.menu-title strong, .menu-title span { display: block; }
.menu-title strong { font-size: 12px; font-weight: 500; }
.menu-title span { margin-top: 2px; color: var(--muted-foreground); font-size: 11px; }
.menu-option { width: 100%; min-width: 0; min-height: 28px; display: grid; grid-template-columns: 20px minmax(0, 1fr) 14px; align-items: center; gap: 8px; padding: 4px 8px; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--foreground); cursor: pointer; text-align: left; }
.menu-option:hover, .menu-option.active { background: var(--accent); }
.menu-option-icon { width: 20px; height: 20px; display: grid; place-items: center; border-radius: var(--radius-sm); background: var(--muted); color: var(--muted-foreground); font-family: var(--mono); font-size: 10px; font-weight: 500; }
.menu-option.active .menu-option-icon { background: var(--background); color: var(--foreground); }
.menu-option strong, .menu-option small { display: block; }
.menu-option strong { font-size: 12px; font-weight: 500; }
.menu-option small { margin-top: 1px; color: var(--muted-foreground); font-size: 11px; line-height: 1.4; }
.menu-option > i { color: var(--foreground); font-size: 12px; font-style: normal; font-weight: 600; }
.command-option { width: 100%; min-width: 0; min-height: 28px; display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 8px; padding: 4px 8px; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--foreground); cursor: pointer; text-align: left; }
.command-option:hover { background: var(--accent); }
.command-option code { color: var(--foreground); font-size: 11px; font-weight: 500; }
.command-option span { color: var(--muted-foreground); font-size: 11px; }
.command-footer { margin: 4px -4px -4px; padding: 6px 12px; border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-lg) var(--radius-lg); background: var(--muted); color: var(--muted-foreground); font-size: 11px; }

.pick-popover { width: max-content; min-width: 100%; max-width: 280px; max-height: min(320px, 55dvh); position: absolute; top: calc(100% + 4px); left: 0; z-index: 60; overflow-y: auto; padding: 4px; }
.pick-option { width: 100%; min-width: 0; min-height: 28px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 8px; border: 0; border-radius: var(--radius-md); background: transparent; color: var(--foreground); cursor: pointer; font-size: 12px; font-weight: 400; text-align: left; white-space: nowrap; }
.pick-option > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pick-option:hover, .pick-option.active { background: var(--accent); }
.pick-option > i { width: 12px; flex: none; color: var(--foreground); font-size: 12px; font-style: normal; font-weight: 600; }
.pick-option:disabled { cursor: wait; opacity: .5; }
.pick-menu .menu-chevron { flex: none; }

/* Plan and permission cards in the chat. */
.plan-card { width: min(100%, 540px); max-width: 100%; padding: 12px; border: 1px solid var(--border) !important; border-radius: var(--radius-lg) !important; background: var(--card) !important; }
.plan-card > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.plan-status { display: inline-flex; align-items: center; gap: 6px; color: var(--foreground); font-size: 12px; font-weight: 500; }
.plan-status i { width: 16px; height: 16px; display: grid; place-items: center; border-radius: 50%; background: var(--primary); color: var(--primary-foreground); font-size: 9px; font-style: normal; }
.plan-mode-note { color: var(--muted-foreground); font-size: 11px; }
.plan-card h3 { margin: 0 0 6px; font-size: 14px; }
.plan-card p { margin: 0 0 8px; color: var(--muted-foreground); font-size: 12px; }
.plan-card ol { margin: 0 0 10px; padding-left: 18px; color: var(--muted-foreground); font-size: 12px; }
.plan-card li { margin: 4px 0; padding-left: 2px; }
.plan-card li::marker { color: var(--muted-foreground); font-weight: 500; }
.plan-files { display: grid; gap: 3px; margin-bottom: 10px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--muted); }
.plan-files span { color: var(--muted-foreground); font-size: 10px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
.plan-files code { color: var(--foreground); font-size: 11px; }
.plan-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.plan-card.plan-approved .plan-actions { display: none; }
.plan-card.plan-approved .plan-status { color: var(--success); }
.plan-card.plan-approved .plan-status i { background: var(--success); }
.permission-card { width: min(100%, 540px); min-width: 0; overflow-wrap: anywhere; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); }
.permission-card > header { margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.permission-card > p { margin-bottom: 10px; color: var(--muted-foreground); }
.plan-feedback-input, .permission-form input { margin: 4px 0 8px; }
.permission-form { display: grid; gap: 8px; min-width: 0; }
.permission-question { display: grid; gap: 4px; min-width: 0; color: var(--foreground); font-size: 12px; font-weight: 500; }
.permission-question input { margin: 0; font-weight: 400; }
.question-options { display: grid; gap: 6px; min-width: 0; }
.btn.question-option { display: grid; width: 100%; min-width: 0; white-space: normal; overflow-wrap: anywhere; justify-items: start; gap: 1px; height: auto; min-height: var(--control-h); padding: 5px 10px; border: 1px solid var(--border); text-align: left; font-weight: 500; }
.btn.question-option small { color: var(--muted-foreground); font-size: 11px; font-weight: 400; }
.btn.question-option[aria-pressed="true"] { border-color: var(--primary); background: var(--muted); }
.permission-answer { margin-top: 8px; color: var(--foreground); font-size: 12px; font-weight: 500; }

/* ---------- right pane: preview and activity ---------- */
.right-col { min-width: 0; min-height: 0; display: flex; flex-direction: column; container-type: inline-size; }
.tab-panel { display: none; }
.tab-panel.active { display: flex; }
.right-panels { min-height: 0; flex: 1; }
.preview-picks { min-width: 0; display: flex; flex: 0 1 auto; align-items: center; gap: 12px; }
.pick { min-width: 0; display: flex; align-items: center; gap: 6px; }
.pick-label { flex: none; color: var(--muted-foreground); font-size: var(--control-fs); font-weight: var(--control-fw); line-height: 1; }
.preview-shell { min-width: 0; min-height: 0; height: 100%; flex-direction: column; background: var(--card); }
.preview-stage { min-width: 0; min-height: 0; display: flex; flex: 1; align-items: flex-start; justify-content: flex-start; overflow: auto; overscroll-behavior: contain; }
.browser-chrome { width: 100%; height: 100%; max-width: none; min-width: 0; display: flex; flex: none; flex-direction: column; margin-inline: auto; overflow: hidden; background: var(--card); }
.chrome-bar { min-width: 0; min-height: 44px; display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--muted); }
.chrome-url { min-width: 64px; min-height: var(--control-h); display: flex; flex: 1; align-items: center; justify-content: center; overflow: hidden; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--control-radius); background: var(--background); color: var(--muted-foreground); font-family: var(--mono); font-size: 11px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.preview-empty { min-height: 0; display: grid; place-items: center; align-content: center; gap: 6px; flex: 1; padding: 20px; color: var(--muted-foreground); text-align: center; }
.preview-empty strong { color: var(--foreground); font-size: 14px; font-weight: 500; }
.preview-empty p { max-width: 320px; margin: 0; font-size: 12px; line-height: 1.625; }
.preview-frame { width: 100%; min-height: 0; flex: 1; border: 0; background: #fff; }
.preview-frame-wrap { min-height: 0; position: relative; flex: 1; overflow: hidden; }
.preview-frame-wrap:has(.preview-frame[hidden]) { display: none; }
/* Desktop: the frame element fills the area and draws nothing. */
.device-frame { position: absolute; inset: 0; }
.device-frame > .preview-frame { position: absolute; top: 0; left: 0; width: 100%; height: 100%; transform-origin: 0 0; }
.device-camera, .device-island, .device-home { display: none; }
/* Framed devices (tablet, mobile): a black bezel drawn in CSS around an iframe that keeps the real device viewport; the whole frame is scaled to fit. */
.browser-chrome:not(.w-desktop) .preview-frame-wrap { background: var(--muted); }
.browser-chrome:not(.w-desktop) .device-frame {
  --device-scale: 1;
  width: calc(var(--device-w) + 2 * var(--device-bezel)); height: calc(var(--device-h) + 2 * var(--device-bezel)); inset: auto; top: 50%; left: 50%; padding: var(--device-bezel);
  border-radius: var(--device-radius); background: #0a0a0a; box-shadow: inset 0 0 0 1px #404040, 0 0 0 1px #171717, var(--shadow-md); transform: translate(-50%, -50%) scale(var(--device-scale)); transform-origin: center;
}
.browser-chrome:not(.w-desktop) .device-frame > .preview-frame { position: relative; display: block; width: var(--device-w); height: var(--device-h); border-radius: calc(var(--device-radius) - var(--device-bezel)); }
.device-island, .device-camera, .device-home { position: absolute; z-index: 1; pointer-events: none; }
.w-mobile .device-island { width: 126px; height: 37px; display: block; top: calc(var(--device-bezel) + 11px); left: 50%; border-radius: 999px; background: #0a0a0a; transform: translateX(-50%); }
.w-mobile .device-home { width: 134px; height: 5px; display: block; bottom: calc(var(--device-bezel) + 8px); left: 50%; border-radius: 999px; background: rgba(10, 10, 10, .85); transform: translateX(-50%); }
.w-tablet .device-camera { width: 8px; height: 8px; display: block; top: calc(var(--device-bezel) / 2 - 4px); left: 50%; border-radius: 50%; background: #262626; box-shadow: inset 0 0 0 1px #404040; transform: translateX(-50%); }
/* Landscape: the island moves to the left screen edge, the camera to the left bezel; no notch is left at the top. */
.w-mobile.is-landscape .device-island { width: 37px; height: 126px; top: 50%; left: calc(var(--device-bezel) + 11px); transform: translateY(-50%); }
.w-tablet.is-landscape .device-camera { top: 50%; left: calc(var(--device-bezel) / 2 - 4px); transform: translateY(-50%); }
body.preview-fullscreen { height: 100dvh; overflow: hidden; }
body.preview-fullscreen .workspace-splitter { display: none; }
body.preview-fullscreen .right-col { width: 100%; height: 100dvh; position: fixed; inset: 0; z-index: 1000; border: 0; border-radius: 0; box-shadow: none; }
body.preview-fullscreen .right-col > .pane-header { display: none; }
body.preview-fullscreen .right-col .tabs { display: none; }
body.preview-fullscreen .right-panels { min-height: 0; }
body.preview-fullscreen #tab-preview { display: flex !important; }
body.preview-fullscreen #tab-changes { display: none !important; }
body.preview-fullscreen .preview-shell { height: 100%; }
body.preview-fullscreen .preview-stage { align-items: flex-start; justify-content: center; }
body.preview-fullscreen .browser-chrome.w-desktop { width: 100%; height: 100%; }
.changes-panel { width: 100%; height: 100%; flex-direction: column; overflow-y: auto; background: var(--card); }
.changes-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border-bottom: 1px solid var(--border); }
.changes-summary strong { font-size: 14px; font-weight: 500; }
.changes-summary p { margin: 2px 0 0; color: var(--muted-foreground); font-size: 12px; }
.changes-list { min-width: 0; }
.change-row { min-width: 0; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); transition: background-color .15s ease; }
.change-row:hover { background: rgba(245, 245, 245, .5); }
.change-row:last-child { border-bottom: 0; }
.change-row .cr-icon { width: 24px; height: 24px; display: grid; place-items: center; flex: none; border-radius: var(--radius-sm); background: var(--muted); color: var(--muted-foreground); font-family: var(--mono); font-size: 10px; font-weight: 500; }
.change-row .cr-icon.added { background: var(--success-soft); color: var(--success); }
.change-row .cr-main { min-width: 0; flex: 1; }
.change-row .cr-file { overflow: hidden; color: var(--foreground); font-family: var(--mono); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.change-row .cr-desc { margin-top: 2px; overflow: hidden; color: var(--muted-foreground); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.change-row a { flex: none; font-size: 12px; font-weight: 500; text-decoration: none; }
.activity-empty { padding: 32px 16px; color: var(--muted-foreground); font-size: 12px; text-align: center; }

@container (max-width: 640px) {
  .pick-label { display: none; }
}
@container (max-width: 720px) {
  .publish-button { width: var(--control-h); min-width: var(--control-h); justify-content: center; padding-inline: 0; }
  .publish-button [data-publish-label] { display: none; }
}
@container (max-width: 500px) {
  .composer-toolbar .composer-hint { display: none; }
}
@container (max-width: 380px) {
  .attach-chip.pdf { max-width: 150px; }
}

/* ---------- settings ---------- */
.settings-top { width: min(100%, 1024px); display: flex; align-items: center; gap: 8px; margin: 0 auto; padding: 12px 20px 0; }
.settings-top .btn { margin-left: -8px; }
.settings-repository { min-width: 0; overflow: hidden; color: var(--muted-foreground); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.settings-page { width: min(100%, 1024px); margin: 0 auto; padding: 12px 20px 56px; }
.settings-heading { margin-bottom: 16px; }
.settings-heading h1 { margin-bottom: 4px; font-size: 24px; }
.settings-heading p { margin-bottom: 0; color: var(--muted-foreground); }
.settings-heading .eyebrow { margin-bottom: 6px; }
.settings-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; align-items: start; }
.settings-nav { position: sticky; top: 16px; display: grid; gap: 2px; }
.settings-nav a { min-height: var(--control-h); display: flex; align-items: center; padding: 0 8px; border-radius: var(--radius-md); color: var(--muted-foreground); font-size: 12px; font-weight: 500; text-decoration: none; }
.settings-nav a:hover { background: var(--muted); color: var(--foreground); }
.settings-nav a.active { background: var(--muted); color: var(--foreground); }
.settings-content { min-width: 0; }
.settings-content .card { scroll-margin-top: 16px; }
.settings-row { min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-bottom: 1px solid var(--border); transition: background-color .15s ease; }
.settings-row:hover { background: rgba(245, 245, 245, .5); }
.settings-row:last-child { border-bottom: 0; }
.settings-row .sr-icon { width: 32px; height: 32px; display: grid; place-items: center; flex: none; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--muted); color: var(--muted-foreground); font-family: var(--mono); font-size: 10px; font-weight: 500; }
.settings-row .sr-main { min-width: 0; flex: 1; }
.settings-row .sr-title { overflow: hidden; font-size: 12px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.settings-row .sr-sub { margin-top: 2px; color: var(--muted-foreground); font-size: 12px; overflow-wrap: anywhere; }
.settings-row .sr-actions { display: flex; flex: none; gap: 6px; }
.settings-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.settings-fields .field-wide { grid-column: 1 / -1; }
.platform-user-form { display: grid; grid-template-columns: minmax(0, 1fr) 140px auto; gap: 8px; align-items: end; margin-bottom: 8px; }
.platform-user-form .field { margin: 0; }
.platform-user-list { margin-top: 12px; border-top: 1px solid var(--border); }
.platform-user-list:empty::after { content: 'No platform users found.'; display: block; padding: 16px 8px 2px; color: var(--muted-foreground); font-size: 12px; }
.platform-user-list .settings-row.is-disabled { opacity: .6; }
.platform-user-list .sr-actions { flex-wrap: wrap; justify-content: flex-end; }
.platform-user-list .settings-row { flex-wrap: wrap; }
.platform-user-repos { flex: 1 0 100%; min-width: 0; display: grid; gap: 8px; margin-top: 4px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--muted); }
.platform-user-repos .helper { margin: 0; }
.platform-repo-options { max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--background); }
.platform-repo-option { display: flex; align-items: flex-start; gap: 8px; padding: 6px 8px; border-bottom: 1px solid var(--border); cursor: pointer; }
.platform-repo-option:last-child { border-bottom: 0; }
.platform-repo-option:hover { background: var(--muted); }
.platform-repo-text { min-width: 0; display: grid; gap: 2px; }
.platform-repo-name { font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
.platform-repo-meta { color: var(--muted-foreground); font-size: 12px; }
.platform-repo-options > .helper { padding: 8px; }
.platform-repo-manual { display: flex; gap: 8px; }
.platform-repo-manual .platform-repo-id { flex: 1; min-width: 0; }
.platform-repo-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.platform-repo-status { margin-right: auto; }
.platform-repo-status.error { color: var(--destructive-foreground); }
.log-list { margin: 8px 0 0; padding: 0; list-style: none; }
.log-list li { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--border); color: var(--muted-foreground); font-size: 12px; }
.log-list li:last-child { border-bottom: 0; }
.log-list time { flex: none; color: var(--muted-foreground); }
.danger-title { color: var(--destructive-foreground); }
.danger-copy { margin-bottom: 12px; color: var(--muted-foreground); font-size: 12px; }
#security .btn + .btn { margin-left: 4px; }

/* ---------- standalone document pages (concept.html, state-machines.html) ---------- */
.states-page { width: min(100%, 1120px); margin: 0 auto; padding: 32px 20px 56px; }
.states-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.states-heading h1 { margin-bottom: 8px; font-size: 28px; }
.states-heading p { max-width: 690px; margin-bottom: 0; color: var(--muted-foreground); }

/* ---------- repository dialog (shadcn Dialog) ---------- */
.app-dialog { width: min(560px, calc(100vw - 32px)); max-height: min(640px, calc(100dvh - 32px)); padding: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--popover); color: var(--popover-foreground); box-shadow: 0 10px 15px -3px rgba(0, 0, 0, .1), 0 4px 6px -4px rgba(0, 0, 0, .1); }
.app-dialog[open] { display: block; }
.app-dialog::backdrop { background: rgba(0, 0, 0, .5); }
.app-dialog-panel { max-height: inherit; display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.app-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.app-dialog-header h2 { margin: 0 0 4px; font-size: 14px; font-weight: 500; letter-spacing: 0; line-height: 1.25; }
.app-dialog-header p { margin: 0; color: var(--muted-foreground); font-size: 12px; line-height: 1.625; }
.app-dialog-header .btn { flex: none; margin: -4px -4px 0 0; }
.agent-dialog { width: min(420px, calc(100vw - 32px)); }
.dialog-section { display: grid; gap: 6px; }
.dialog-section .popover-section-label { margin-bottom: 0; }
.dialog-value { margin: 0; font-size: var(--control-fs); line-height: 1.5; }
.agent-dialog .compact-field { margin-bottom: 0; }
.agent-dialog .usage-track { margin-top: 0; }
.repo-dialog-search input { width: 100%; height: var(--control-h); padding: 0 8px; outline: none; border: 1px solid var(--input); border-radius: var(--control-radius); background: var(--field); color: var(--foreground); font-size: var(--control-fs); }
.repo-dialog-search input:focus { border-color: var(--ring); box-shadow: var(--ring-focus); }
.repo-list { min-height: 0; display: grid; gap: 4px; overflow-y: auto; margin: 0 -4px; padding: 0 4px 2px; scrollbar-width: thin; }
.repo-row { min-width: 0; display: flex; align-items: flex-start; gap: 4px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); transition: background-color .15s ease, border-color .15s ease; }
.repo-row:hover { background: rgba(245, 245, 245, .6); }
.repo-row:has([aria-checked="true"]) { border-color: var(--foreground); }
.repo-row:has(.repo-choice:focus-visible) { border-color: var(--foreground); box-shadow: 0 0 0 3px rgba(0, 0, 0, .15); }
.repo-choice { min-width: 0; display: grid; flex: 1; gap: 4px; padding: 8px 8px 8px 12px; border: 0; border-radius: var(--radius-lg); background: transparent; color: inherit; cursor: pointer; font: inherit; text-align: left; }
.repo-choice:focus-visible { outline: none; }
.repo-name { min-width: 0; display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; line-height: 1.5; }
.repo-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.repo-where { min-width: 0; display: flex; align-items: baseline; gap: 4px; color: var(--muted-foreground); font-size: 12px; line-height: 1.5; }
.repo-path { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.repo-branch { flex: none; font-family: var(--mono); font-size: 12px; }
.repo-description { display: -webkit-box; overflow: hidden; color: var(--muted-foreground); font-size: 12px; line-height: 1.5; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere; }
.repo-description.empty { font-style: italic; }
.repo-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.repo-link { flex: none; margin: 4px 4px 0 0; color: var(--muted-foreground); }
.repo-empty { margin: 0; padding: 16px 0; color: var(--muted-foreground); font-size: 12px; text-align: center; }

/* ---------- chat attachments ---------- */
.attach-note { margin: 0 0 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); color: var(--muted-foreground); font-size: 12px; }
.attach-tray { display: flex; gap: 8px; margin: 0 0 8px; padding: 2px 2px 4px; overflow-x: auto; scrollbar-width: thin; }
.attach-chip { position: relative; height: 56px; display: flex; flex: none; align-items: center; gap: 8px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); }
.attach-chip:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }
.attach-chip.image { width: 56px; }
.attach-chip.image img { width: 100%; height: 100%; display: block; object-fit: cover; }
.attach-chip.pdf { max-width: 190px; padding-right: 30px; }
.attach-file-icon { width: 56px; height: 100%; display: grid; flex: none; place-items: center; background: var(--muted); color: var(--muted-foreground); font-size: 11px; font-weight: 500; letter-spacing: .04em; }
.attach-chip-name { min-width: 0; overflow: hidden; color: var(--foreground); font-size: 12px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip-remove { width: 20px; height: 20px; position: absolute; top: 3px; right: 3px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: rgba(10, 10, 10, .72); color: #fff; cursor: pointer; font-size: 14px; line-height: 1; }
.attach-chip-remove:hover { background: rgba(10, 10, 10, .92); }
.attach-chip[data-state="uploading"] img, .attach-chip[data-state="uploading"] .attach-file-icon { opacity: .45; }
.attach-chip[data-state="error"] { border-color: var(--destructive-line); background: var(--destructive-soft); }
.attach-chip[data-state="error"] .attach-chip-name { color: var(--destructive-foreground); }
.attach-spinner { width: 20px; height: 20px; position: absolute; top: 50%; left: 28px; margin: -10px 0 0 -10px; border: 2px solid rgba(0, 0, 0, .2); border-top-color: var(--foreground); border-radius: 50%; animation: task-spin .8s linear infinite; }
.attach-chip-error { width: 56px; height: 100%; position: absolute; inset: 0 auto 0 0; display: grid; place-items: center; background: rgba(254, 242, 242, .86); color: var(--destructive-foreground); font-weight: 600; }
.attach-chip-retry { width: 20px; height: 20px; position: absolute; right: 3px; bottom: 3px; display: grid; place-items: center; padding: 0; border: 1px solid var(--destructive-line); border-radius: 50%; background: var(--background); color: var(--destructive-foreground); cursor: pointer; font-size: 13px; line-height: 1; }
.attach-drop { position: absolute; inset: 6px; z-index: 30; display: grid; place-items: center; border: 2px dashed var(--ring); border-radius: var(--radius-lg); background: rgba(255, 255, 255, .9); color: var(--foreground); font-size: 12px; font-weight: 500; pointer-events: none; }
.attach-drop[hidden] { display: none; }
.msg-attachments { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; margin-bottom: 6px; }
.msg-attachments:last-child { margin-bottom: 0; }
.msg-thumb { aspect-ratio: 4 / 3; display: block; overflow: hidden; padding: 0; border: 0; border-radius: var(--radius-md); background: var(--background); cursor: zoom-in; }
.msg-thumb img { width: 100%; height: 100%; display: block; object-fit: cover; }
.msg-file { min-width: 0; display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--background); color: inherit; font-size: 12px; text-decoration: none; }
.msg-file:hover { background: var(--accent); }
.msg-file-icon { flex: none; font-size: 10px; font-weight: 600; letter-spacing: .05em; opacity: .85; }
.msg-file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the dialog hugs the picture so the close button sits on its corner */
.image-viewer { width: fit-content; max-width: 96vw; max-height: 94dvh; padding: 0; overflow: visible; border: 0; background: transparent; }
.image-viewer::backdrop { background: rgba(10, 10, 10, .76); }
.image-viewer img { max-width: 96vw; max-height: 88dvh; display: block; border-radius: var(--radius-lg); background: #fff; }
.image-viewer-close { width: var(--control-h); height: var(--control-h); position: absolute; top: -12px; right: -12px; z-index: 2; display: grid; place-items: center; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: var(--background); box-shadow: var(--shadow-md); cursor: pointer; font-size: 18px; line-height: 1; }

/* Resuming a session that was auto-paused while the tab stayed open */
.paused-banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 8px; padding: 4px 4px 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); color: var(--foreground); font-size: 12px; line-height: 1.5; }
.paused-banner[hidden] { display: none; }
.paused-banner span { min-width: 0; }
.paused-banner .btn { flex: none; }
.paused-banner.error { border-color: var(--destructive-line); background: var(--destructive-soft); color: var(--destructive-foreground); }
.paused-banner.error .btn-secondary { border-color: var(--destructive-line); color: var(--destructive-foreground); }
.paused-banner.resuming .working-dot { margin-right: 1px; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .composer-toolbar .composer-hint { display: none; }
}
@media (max-width: 800px) {
  .settings-layout { grid-template-columns: 1fr; gap: 12px; }
  .settings-nav { position: static; display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-nav a { flex: none; border: 1px solid var(--border); background: var(--background); }
  .settings-nav a.active { border-color: var(--border); background: var(--muted); }
}
@media (max-width: 680px) {
  /* Stacked panes: a header with more controls than fit one row wraps; the rule is the shared one, not a per-pane override. */
  .pane-header { height: auto; flex-wrap: wrap; padding-block: 10px; row-gap: 8px; }
  body[data-page="workspace"] { height: auto; min-height: 100dvh; overflow: auto; }
  .page, .page-narrow { padding: 24px 16px 56px; }
  .workspace-page { padding: 8px; }
  .workspace-grid { height: auto; min-height: 0; grid-template-columns: 1fr; }
  .workspace-splitter { display: none; }
  .chat-col { height: calc(100dvh - 16px); min-height: 480px; }
  .right-col { height: 590px; }
  .plan-actions { flex-wrap: wrap; }
  .composer-toolbar { align-items: flex-start; }
  .settings-page { padding: 20px 16px 56px; }
  .settings-fields { grid-template-columns: 1fr; }
  .settings-fields .field-wide { grid-column: auto; }
  .platform-user-form { grid-template-columns: 1fr; align-items: stretch; }
  .settings-row { align-items: flex-start; flex-wrap: wrap; }
  .settings-row .sr-main { flex-basis: calc(100% - 44px); }
  .settings-row .sr-actions { width: 100%; padding-left: 44px; }
  .states-page { padding: 24px 16px 56px; }
  .states-heading { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 480px) {
  .form-grid { grid-template-columns: 1fr; gap: 0; }
  .claude-auth-link-row, .claude-auth-code-row { grid-template-columns: 1fr; align-items: stretch; }
  .claude-auth-link-row { display: grid; }
  .claude-auth-link-row .btn, .claude-auth-code-row .btn { width: 100%; }
  .welcome-page { padding: 16px; }
  .welcome-shell { padding: 20px; }
  .change-row { align-items: flex-start; }
  .plan-card > header { align-items: flex-start; flex-direction: column; gap: 4px; }
  .plan-actions { justify-content: stretch; }
  .changes-summary { align-items: flex-start; flex-direction: column; }
  .log-list li { flex-direction: column; gap: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* admin repository editor: name, branch and error line of one granted repository */
.platform-repo-option { flex-wrap: wrap; align-items: center; row-gap: 6px; }
.platform-repo-pick { min-width: 0; flex: 1 1 200px; display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.platform-repo-pick input { flex: none; margin: 3px 0 0; }
.platform-repo-project-name { width: 200px; flex: none; }
.platform-repo-name-error { flex-basis: 100%; margin: 0; color: var(--destructive-foreground); }
.platform-repo-project-name[aria-invalid="true"] { border-color: var(--destructive-foreground); }
