/* Open Runde — served via jsDelivr from github.com/lauridskern/open-runde */
@font-face { font-family: 'Open Runde'; font-weight: 400; font-style: normal; font-display: swap;
  src: url('https://cdn.jsdelivr.net/gh/lauridskern/open-runde@main/src/web/OpenRunde-Regular.woff2') format('woff2'),
       url('https://cdn.jsdelivr.net/gh/lauridskern/open-runde@main/src/web/OpenRunde-Regular.woff') format('woff'); }
@font-face { font-family: 'Open Runde'; font-weight: 500; font-style: normal; font-display: swap;
  src: url('https://cdn.jsdelivr.net/gh/lauridskern/open-runde@main/src/web/OpenRunde-Medium.woff2') format('woff2'),
       url('https://cdn.jsdelivr.net/gh/lauridskern/open-runde@main/src/web/OpenRunde-Medium.woff') format('woff'); }
@font-face { font-family: 'Open Runde'; font-weight: 600; font-style: normal; font-display: swap;
  src: url('https://cdn.jsdelivr.net/gh/lauridskern/open-runde@main/src/web/OpenRunde-Semibold.woff2') format('woff2'),
       url('https://cdn.jsdelivr.net/gh/lauridskern/open-runde@main/src/web/OpenRunde-Semibold.woff') format('woff'); }
@font-face { font-family: 'Open Runde'; font-weight: 700; font-style: normal; font-display: swap;
  src: url('https://cdn.jsdelivr.net/gh/lauridskern/open-runde@main/src/web/OpenRunde-Bold.woff2') format('woff2'),
       url('https://cdn.jsdelivr.net/gh/lauridskern/open-runde@main/src/web/OpenRunde-Bold.woff') format('woff'); }

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* Notebook paper canvas */
  --bg: #f9f8f6;
  --surface: #ffffff;
  --surface2: #f4f3f1;
  --surface3: #eceae8;
  --border: rgba(175, 170, 162, 0.25);
  --border-light: rgba(175, 170, 162, 0.15);
  --text: #302e2b;
  --text-dim: #524f4b;
  --text-muted: #847e78;
  --accent: #8b6f47;
  --accent-hover: #9a7d54;
  --accent-dim: rgba(139, 111, 71, 0.1);
  --accent-contrast: #ffffff;
  --link-color: #2563eb;
  --green: #10b981;
  --green-dim: rgba(16, 185, 129, 0.12);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.1);
  --warn-amber: #b8531a;
  --red: #FF2D55;
  --red-hover: #e0264a;
  --red-dim: rgba(255, 45, 85, 0.1);
  --purple: #7c3aed;
  /* Channels only, so the selection layer injected into the draft iframe can
     build its own alpha values from the same token this file uses. */
  --purple-rgb: 124, 58, 237;
  --purple-dim: rgba(124, 58, 237, 0.08);
  --cyan: #0ea5e9;
  --radius: 16px;
  --radius-sm: 10px;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  --sans: 'Open Runde', 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --pane-split: 38%;
  /* Semantic tokens */
  --card-bg: #ffffff;
  --bubble-bg: #ffffff;
  --bubble-border: rgba(180, 170, 150, 0.2);
  --bubble-shadow: 0px 1px 3px rgba(60, 50, 40, 0.06);
  --code-color: var(--code-color);
  --input-bg: #fffdf6;
  --presence-bg: rgba(255, 255, 255, 0.95);
  --presence-shadow: 0 2px 8px rgba(60, 50, 40, 0.08);
  --preview-bg: #ffffff;
  --logo-filter: none;
  --fade-gradient: #ffffff;
  /* Warm brown shadows instead of black */
  --shadow-sm: 0 1px 3px rgba(60, 50, 40, 0.06);
  --shadow-md: 2px 3px 12px rgba(60, 50, 40, 0.08);
  --shadow-lg: 4px 6px 24px rgba(60, 50, 40, 0.1);
  /* Highlighter colors */
  --hl-yellow: rgba(250, 220, 50, 0.35);
  --hl-pink: rgba(255, 140, 180, 0.3);
  --hl-green: rgba(100, 220, 120, 0.3);
  --hl-blue: rgba(100, 180, 255, 0.25);
  /* Tape / physical elements */
  --tape: rgba(255, 252, 235, 0.55);
  --tape-shadow: rgba(60, 50, 40, 0.06);
  --cream: #fffdf6;
  --sticky: #fff8c5;
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  /* --hand already resolves: Kalam is loaded in production (public/index.html:10)
     for the dashboard letter. No new font request needed. */
  --hand: 'Kalam', cursive;
  /* The note is a different sheet from the composer pad, so it gets its own
     stock — a shade deeper than --cream. The card behind it is deeper again,
     which is what reads as a second sheet rather than a drop shadow. */
  --note-stock: #faf9f4; --note-stock-back: #f2f1ea;
  /* VERIFIED MISSING FROM PROD 2026-07-31: styles.css defines --spring but not
     --ease. Every transition below references var(--ease); with the token
     undefined the whole declaration is invalid at computed-value time and the
     card snaps open with no animation at all. This value already appears in
     prod as a literal — it just never got a name. */
  --ease: cubic-bezier(0.22,1,0.36,1);
  /* Sidebar — cooler/lighter than canvas */
  --sidebar-width: 240px;
  --sidebar-collapsed: 56px;
  --sidebar-bg: #f6f5f4;
  --sidebar-border: rgba(170, 168, 165, 0.18);
  --sidebar-hover: rgba(60, 56, 52, 0.05);
  --sidebar-active: rgba(139, 111, 71, 0.08);
  --sidebar-active-text: var(--text);
  /* Manila folder tones — warm kraft objects on the desk (Pages folders) */
  --manila: #e7d6b0;
  --manila-edge: #d8c399;
  --manila-open: #f4ecd8;
  --manila-text: #6f6048;
  /* Page thumbnail placeholder palette — muted earth/sage family (one brand reads
     as a calm set, not a rainbow). JS picks a token by slug hash; values live here
     per the theme-token contract. Keep the count in sync with _thumbColor. */
  --thumb-1: #5f8a6e;
  --thumb-2: #6b8f6a;
  --thumb-3: #52806a;
  --thumb-4: #778f5e;
  --thumb-5: #8a8f5c;
  --thumb-6: #9a8a5c;
  --thumb-7: #8f7d54;
  --thumb-8: #638a76;
  --thumb-9: #5a8568;
  --thumb-10: #728c64;
  --thumb-11: #6d9472;
  --thumb-12: #7a9568;
  /* Notebook line colors — visible, not hidden */
  --notebook-rule: rgba(165, 190, 215, 0.38);
  --notebook-margin: rgba(220, 130, 130, 0.35);
}

/* ---- Custom tooltip (replaces native title) ---- */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: #302e2b; color: #fff;
  font-family: var(--sans); font-size: 11px; font-weight: 500;
  padding: 5px 10px; border-radius: 6px; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s;
  z-index: 1000;
}
[data-tooltip]:hover::after { opacity: 1; }

/* Dark mode removed — one world, done well. */

body {
  font-family: var(--sans);
  font-size: 15px;
  background-color: var(--bg);
  background-image:
    linear-gradient(to right, transparent 59px, var(--notebook-margin) 59px, var(--notebook-margin) 60px, transparent 60px),
    repeating-linear-gradient(to bottom, transparent, transparent 31px, var(--notebook-rule) 31px, var(--notebook-rule) 32px);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

/* Paper fiber texture overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='paper'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.0' numOctaves='5' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23paper)' opacity='0.035'/%3E%3C/svg%3E");
  pointer-events: none;
  mix-blend-mode: overlay;
  z-index: 10000;
}

/* Main content area — right of sidebar */
.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
}

/* ---- TOP BAR — frosted glass shelf, notebook lines show through ---- */
.topbar {
  height: 36px;
  background: rgba(250, 249, 247, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(180, 170, 150, 0.18);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  flex-shrink: 0;
  z-index: 10;
  box-shadow: 0 1px 0 rgba(160, 155, 150, 0.10);
}
/* On non-chat pages the bar holds nothing, so collapse the empty strip. Desktop
   only — on mobile (≤768px) the bar still hosts the hamburger menu. Toggled by
   updateTopbar() in router.js. */
@media (min-width: 769px) {
  .topbar.topbar-empty { display: none; }
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.topbar .logo {
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
  color: var(--text-dim);
}

.topbar .logo img { height: 22px; width: auto; filter: var(--logo-filter); }

.topbar .model-badge {
  font-size: 11px; padding: 3px 10px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text-dim); font-family: var(--mono);
}

.topbar .lock-badge {
  font-size: 11px; padding: 3px 8px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 12px; color: var(--accent); font-family: var(--mono);
  cursor: help;
}

.persona-badge {
  font-size: 12px; padding: 2px 8px 2px 3px;
  background: none; border: none;
  border-radius: 0; color: var(--text-dim); font-weight: 500;
  font-family: var(--serif);
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.persona-badge .persona-thumb {
  width: 20px; height: 20px; border-radius: 2px; object-fit: cover; flex-shrink: 0;
}

/* Photo upload in settings */
.photo-upload-area {
  display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
}
.photo-preview {
  width: 56px; height: 56px; border-radius: 4px; overflow: hidden;
  background: #fffdf6; border: 3px solid white;
  box-shadow: 1px 2px 6px rgba(60, 50, 40, 0.12);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; cursor: pointer; transition: all 0.2s;
  position: relative; transform: rotate(-1.5deg);
}
.photo-preview:hover { transform: rotate(0deg) translateY(-2px); box-shadow: 2px 4px 12px rgba(60, 50, 40, 0.15); }
.photo-preview img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 2px;
}
.photo-preview .photo-placeholder {
  color: var(--text-muted); font-size: 10px; text-align: center; line-height: 1.3;
}
.photo-preview .photo-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.2s; border-radius: 2px;
}
.photo-preview:hover .photo-overlay { opacity: 1; }
.photo-preview .photo-overlay svg { width: 18px; height: 18px; color: white; }
.photo-actions {
  display: flex; flex-direction: column; gap: 4px;
}
.photo-actions button {
  padding: 4px 10px; background: var(--surface3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-dim); font-size: 11px;
  cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.photo-actions button:hover { background: var(--surface2); color: var(--text); }
.photo-actions .remove-photo { border-color: rgba(255,45,85,0.3); color: var(--red); }
.photo-actions .remove-photo:hover { background: var(--red-dim); }

.topbar-right { display: flex; align-items: center; gap: 8px; }

.cost-display {
  font-size: 12px; font-family: var(--mono); color: var(--green);
  background: var(--green-dim); padding: 4px 10px; border-radius: 12px; font-weight: 600;
}

.topbar-btn {
  padding: 6px 12px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-dim); font-size: 12px;
  cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 6px;
}

.topbar-btn:hover { background: var(--surface3); color: var(--text); border-color: var(--border-light); }
.topbar-btn.active { background: var(--accent); border-color: var(--accent); color: white; }

/* Theme toggle */
.theme-toggle { padding: 6px 8px; display: flex; align-items: center; }
.theme-toggle.hidden { display: none !important; }
.logo .logo-dark { display: none; }

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 60;
  flex-shrink: 0;
  transition: width 0.2s ease;
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); cursor: pointer; }

.sidebar-header {
  height: 36px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  gap: 10px;
  overflow: hidden;
}
.sidebar-header .logo {
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-header .logo img { height: 22px; width: auto; }
.sidebar-header .logo .logo-icon { display: none; }
.sidebar.collapsed .sidebar-header .logo .logo-full { display: none; }
.sidebar.collapsed .sidebar-header .logo .logo-icon { display: block; }

/* ---- Team Switcher ---- */
.team-switcher { padding: 8px 10px 0; position: relative; }

.team-switcher-btn {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg);
  color: var(--text); font-size: 13px; font-weight: 500;
  font-family: inherit; cursor: pointer; transition: all 0.15s; text-align: left;
}
.team-switcher-btn:hover { border-color: var(--accent); background: var(--surface2); }
.team-switcher-btn.open { border-color: var(--accent); }
.team-switcher-icon { flex-shrink: 0; color: var(--text-muted); }
.team-switcher-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-switcher-chevron { flex-shrink: 0; color: var(--text-muted); transition: transform 0.2s; }
.team-switcher-btn.open .team-switcher-chevron { transform: rotate(180deg); }

.team-switcher-dropdown {
  display: none; position: absolute; left: 10px; right: 10px; top: calc(100% + 4px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1); z-index: 80; padding: 4px;
  max-height: 200px; overflow-y: auto;
}
.team-switcher-dropdown.open { display: block; }

.team-switcher-option {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border: none; background: none; border-radius: 6px;
  font-size: 13px; font-weight: 500; font-family: inherit;
  color: var(--text-dim); cursor: pointer; transition: all 0.1s; text-align: left;
}
.team-switcher-option:hover { background: var(--sidebar-hover); color: var(--text); }
.team-switcher-option.active { background: var(--sidebar-active); color: var(--sidebar-active-text); font-weight: 600; }
.team-switcher-option .team-check { width: 16px; display: flex; justify-content: center; flex-shrink: 0; color: var(--accent); }

.sidebar.collapsed .team-switcher { display: none !important; }

.sidebar-nav {
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.sidebar-spacer { flex: 1; min-height: 0; }
/* The blank middle of the rail collapses it (see initSidebar), so it says so —
   with the same double-chevron the collapse button draws, at the same 2px
   stroke. One action, one mark: the gesture and the button are the same thing,
   so pointing at them should look the same. White halo underneath keeps it
   legible against the rail; `pointer` catches a browser that refuses the image.
   `w-resize` was the other candidate and promises a drag we don't support.
   Expanded only: collapsed, the rail already carries `pointer` for the opposite
   action, and a ‹‹ over a click that expands would point the wrong way.
   The advertised region is narrower than the click region on purpose — the gaps
   between nav items also collapse, but nobody aims at a 2px gap. */
.sidebar:not(.collapsed) .sidebar-spacer {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'><g stroke='white' stroke-width='4.5' stroke-linecap='round' stroke-linejoin='round' opacity='0.92'><polyline points='11 17 6 12 11 7'/><polyline points='18 17 13 12 18 7'/></g><g stroke='%23302e2b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='11 17 6 12 11 7'/><polyline points='18 17 13 12 18 7'/></g></svg>") 12 12, pointer;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.1px;
  line-height: 20px;
  font-family: var(--sans);
  white-space: nowrap;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.sidebar-nav-item:hover { background: var(--sidebar-hover); color: var(--text); }
.sidebar-nav-item.active { background: rgba(139, 111, 71, 0.08); color: var(--text); font-weight: 600; }
.sidebar-nav-item svg { width: 20px; height: 20px; flex-shrink: 0; transition: color 0.1s; }
/* Duotone on touch. At rest the nav is one tone — plain outlines, nothing
   competing with the content for attention. The mass only fills in when a row is
   hovered or is where you are, so the fill is a STATE rather than decoration: it
   answers "am I on this" instead of just sitting there.
   Warm duotone (prototype column B) kept the mass on permanently. It read well,
   but six filled icons at rest is a lot of furniture for a rail you are mostly
   not looking at — and it spent the fill, so hover and active had only opacity
   steps left to distinguish themselves with.
   The mass is the brown accent, not currentColor: hover and active take the row
   colour to --text, and a near-black fill lands as a cold grey slab on a warm
   surface. The stroke stays neutral and keeps following the row, so the two
   layers carry different jobs — mass is warmth, stroke is legibility.
   Active fills deeper than hover, which is the only place the nav says "you are
   here" without the label (the collapsed 56px rail has no label to read). */
.sidebar-nav-item svg .duo-mass {
  fill: var(--accent);
  fill-opacity: 0;
  transition: fill-opacity 0.1s;
}
.sidebar-nav-item:hover svg .duo-mass { fill-opacity: 0.28; }
.sidebar-nav-item.active svg .duo-mass { fill-opacity: 0.36; }
.sidebar-nav-item .nav-label { overflow: hidden; text-overflow: ellipsis; }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .sidebar-nav-item { justify-content: center; padding: 10px; }

/* Start fresh — warm green, inviting. It carries the same .duo-mass/.duo-line
   layers as the rest of the nav so the markup is one pattern, but its mass stays
   SOLID: it is the only primary action here, and a 30% wash would demote it to
   just another destination. The plus is white on the filled blob rather than
   currentColor, which at full green would be invisible.
   The ID beats the shared hover/active opacity steps, so the blob holds its
   weight in every state. */
#nav-chat { color: var(--green); }
#nav-chat svg .duo-mass { fill: var(--green); fill-opacity: 1; }
#nav-chat svg .duo-line { stroke: #fff; }
#nav-chat:hover { background: var(--sidebar-hover); }
#nav-chat.active { color: var(--green); background: rgba(16, 185, 129, 0.08); }

.sidebar-section-header {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  padding: 20px 12px 6px;
  white-space: nowrap;
}
.sidebar.collapsed .sidebar-section-header { display: none; }

/* ---- Ongoing Chat card ---- */
.ongoing-chat {
  margin: 4px 8px 0;
  padding: 12px 14px;
  background: var(--card-bg);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s;
}
.ongoing-chat:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.ongoing-chat-header {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 6px;
}
.ongoing-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px var(--green), 0 0 12px rgba(16, 185, 129, 0.3);
  animation: ongoingPulse 2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes ongoingPulse {
  0%, 100% { box-shadow: 0 0 6px var(--green), 0 0 12px rgba(16, 185, 129, 0.3); }
  50% { box-shadow: 0 0 8px var(--green), 0 0 20px rgba(16, 185, 129, 0.4); }
}
.ongoing-label {
  font-size: 12px; font-weight: 500; color: var(--green);
  letter-spacing: -0.1px; flex: 1;
}
.ongoing-edit-icon {
  color: var(--text-muted); opacity: 0.5;
  transition: opacity 0.15s; cursor: pointer;
}
.ongoing-chat:hover .ongoing-edit-icon { opacity: 1; }
.ongoing-edit-icon:hover { color: var(--accent) !important; }
.ongoing-share-icon {
  width: 24px; height: 24px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 6px; background: transparent;
  color: var(--text-muted); cursor: pointer; opacity: 0.5;
  transition: opacity 0.15s, transform 0.3s var(--spring), box-shadow 0.3s;
}
.ongoing-chat:hover .ongoing-share-icon,
.ongoing-chat.is-shared .ongoing-share-icon,
.ongoing-share-icon:focus-visible { opacity: 1; }
.ongoing-share-icon:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.ongoing-shared-badge {
  display: inline-flex;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.ongoing-share-icon[hidden],
.ongoing-shared-badge[hidden] { display: none; }
.ongoing-chat-title {
  font-size: 14px; font-weight: 600; color: var(--text);
  line-height: 1.3; overflow: hidden;
  display: -webkit-box; line-clamp: 2; -webkit-box-orient: vertical;
}
.sidebar.collapsed .ongoing-chat { display: none !important; }

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

.sidebar-collapse-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text-muted); font-size: 12px;
  background: none; border: none; width: 100%; font-family: inherit;
  transition: background 0.1s;
}
.sidebar-collapse-btn:hover { background: var(--sidebar-hover); color: var(--text-dim); }
.sidebar-collapse-btn svg {
  width: 18px; height: 18px; flex-shrink: 0;
  stroke: currentColor; fill: none; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  transition: transform 0.2s;
}
.sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }
.sidebar.collapsed .sidebar-collapse-btn .nav-label { display: none; }
.sidebar.collapsed .sidebar-collapse-btn { justify-content: center; padding: 10px; }

/* ---- PAGE CONTAINERS ---- */
.page { display: none; flex: 1; overflow: hidden; }
.page.active { display: flex; }
/* FOUC prevention — data-init-page set synchronously by inline <head> script before first paint */
html[data-init-page="history"] #page-chat,
html[data-init-page="knowledge"] #page-chat,
html[data-init-page="pages"] #page-chat,
html[data-init-page="console"] #page-chat,
html[data-init-page="meta-ads"] #page-chat { display: none; }
html[data-init-page="history"] #page-history,
html[data-init-page="knowledge"] #page-knowledge,
html[data-init-page="pages"] #page-pages,
html[data-init-page="console"] #page-console,
html[data-init-page="meta-ads"] #page-meta-ads { display: flex; }
.page-chat { flex-direction: column; position: relative; }
.chat-panes { display: flex; flex-direction: row; flex: 1; overflow: hidden; position: relative; }
.page-history { flex-direction: column; background: var(--bg); }
.page-knowledge { flex-direction: column; background: var(--bg); overflow-y: auto; }
/* Pages view = flat workspace panel matched to the side panel (--sidebar-bg),
   not the ruled notebook desk. */
.page-pages { flex-direction: column; background: var(--sidebar-bg); overflow-y: auto; }
/* The pages view renders its own header/controls, so the shared topbar is empty
   there. Hide it on desktop to reclaim the dead band above "Your Pages". On mobile
   the topbar still carries the hamburger (sidebar toggle), so only suppress it at
   desktop widths. */
@media (min-width: 769px) {
  #main-container:has(> #page-pages.active) > #topbar { display: none; }
}

/* ---- SHOPIFY CONNECTION (Console) ---- */
.shopify-console-panel { max-width: 820px; }
.shopify-console-header { align-items: flex-start; margin-bottom: 18px; }
.shopify-console-header .console-section-desc { margin: 5px 0 0; max-width: 680px; }
.connection-card { display: grid; grid-template-columns: 58px 1fr; gap: 18px; padding: 26px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-md); }
.connection-card-brand { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 14px; background: var(--green); color: var(--surface); font-family: var(--serif); font-size: 30px; font-weight: 700; }
.connection-card-main { min-width: 0; }
.connection-card-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.connection-card-title-row h2 { color: var(--text); font-size: 20px; margin-bottom: 4px; }
.connection-card-title-row p { color: var(--text-muted); font-size: 14px; line-height: 1.45; }
.connection-badge { flex-shrink: 0; padding: 5px 9px; border-radius: 999px; background: var(--surface2); color: var(--text-muted); font-size: 11px; font-weight: 700; }
.connection-badge[data-state="connected"] { background: var(--green-dim); color: var(--green); }
.connection-badge[data-state="warning"] { background: var(--amber-dim); color: var(--warn-amber); }
.connection-details { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 22px; }
.connection-details[hidden], .connection-form[hidden], .connection-actions[hidden] { display: none; }
.connection-details > div { min-width: 0; padding: 12px; background: var(--surface2); border-radius: var(--radius-sm); }
.connection-details span { display: block; color: var(--text-muted); font-size: 11px; margin-bottom: 4px; }
.connection-details strong { display: block; color: var(--text); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connection-form { margin-top: 22px; }
.connection-form > label { display: block; color: var(--text); font-size: 13px; font-weight: 700; margin-bottom: 7px; }
.connection-form-row { display: flex; gap: 8px; }
.connection-form-row input { flex: 1; min-width: 0; height: 44px; padding: 0 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--input-bg); color: var(--text); font: inherit; }
.connection-form-row input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.connection-primary-btn, .connection-secondary-btn, .connection-danger-btn { min-height: 44px; padding: 0 16px; border-radius: var(--radius-sm); font: 700 13px var(--sans); cursor: pointer; transition: transform 150ms ease-out, opacity 150ms ease-out; }
.connection-primary-btn { border: 0; background: var(--text); color: var(--surface); }
.connection-secondary-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.connection-danger-btn { border: 1px solid var(--red); background: var(--surface); color: var(--red); }
.connection-primary-btn:active, .connection-secondary-btn:active, .connection-danger-btn:active { transform: scale(.97); }
@media (hover: hover) and (pointer: fine) {
  .connection-primary-btn:hover, .connection-secondary-btn:hover, .connection-danger-btn:hover { transform: translateY(-1px); }
}
.connection-primary-btn:disabled, .connection-secondary-btn:disabled, .connection-danger-btn:disabled { cursor: wait; opacity: .55; transform: none; }
.connection-help { color: var(--text-muted); font-size: 12px; line-height: 1.45; margin-top: 8px; }
.connection-permission-note { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface2); }
.connection-actions { display: flex; gap: 8px; margin-top: 20px; }
.shopify-safety-note { display: flex; gap: 8px; margin: 18px 8px 0; color: var(--text-muted); font-size: 12px; line-height: 1.55; }
.shopify-safety-note strong { flex-shrink: 0; color: var(--text-dim); }
@media (max-width: 620px) {
  .connection-card { grid-template-columns: 44px 1fr; padding: 18px; gap: 12px; }
  .connection-card-brand { width: 44px; height: 44px; border-radius: 11px; font-size: 24px; }
  .connection-card-title-row { flex-direction: column; gap: 10px; }
  .connection-details { grid-template-columns: 1fr; }
  .connection-form-row { flex-direction: column; }
  .shopify-safety-note { align-items: flex-start; flex-direction: column; }
}

/* ---- HISTORY PAGE ---- */
/* ---- History toolbar: filters + search ---- */
.history-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 24px 0; flex-shrink: 0;
  max-width: 760px; margin-left: auto; margin-right: auto; width: 100%;
  box-sizing: content-box;
}
.history-filters { display: flex; gap: 4px; flex-wrap: wrap; }
.history-filter {
  padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-dim); font-size: 13px;
  font-weight: 500; font-family: inherit; cursor: pointer; transition: all 0.15s;
}
.history-filter:hover { border-color: rgba(139, 111, 71, 0.3); color: var(--text); }
.history-filter.active {
  background: #8b6f47; color: white; border-color: #8b6f47;
}
.history-search-bar {
  display: flex; align-items: center; gap: 8px; position: relative;
}
.history-search-icon {
  position: absolute; left: 12px; color: var(--text-muted); pointer-events: none;
}
.history-search-input {
  padding: 7px 14px 7px 36px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13px;
  font-family: inherit; outline: none; transition: border-color 0.15s;
  width: 200px;
}
.history-search-input::placeholder { color: var(--text-muted); }
.history-search-input:focus { border-color: var(--accent); width: 260px; }

.history-toolbar-right { display: flex; align-items: center; gap: 6px; }
.history-action-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s; padding: 0; flex-shrink: 0;
}
.history-action-btn:hover { color: var(--text); border-color: var(--text-muted); }
.history-action-btn.history-action-danger:hover { color: var(--error, #ef4444); border-color: var(--error, #ef4444); }

/* ---- History cards ---- */
.history-page-body { flex: 1; overflow-y: auto; padding: 12px 24px 24px; }
.history-page-body-inner { max-width: 760px; margin: 0 auto; width: 100%; }

.history-card {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-radius: 0;
  border: none; position: relative;
  background: transparent;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light, var(--border));
}

/* Animated warm bar — grows from nub to full height */
.history-card::before {
  content: ''; position: absolute; left: 0; top: 50%;
  width: 3px; height: 8px; border-radius: 0 3px 3px 0;
  background: rgba(139, 111, 71, 0.5); opacity: 0;
  transform: translateY(-50%);
  transition: height 0.2s ease-out, opacity 0.15s ease-out;
}
.history-card:hover::before { height: 100%; opacity: 1; }

/* Left icon — subtle, no circle */
.hc-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: transform 0.3s ease-out;
}
.history-card:hover .hc-icon { transform: translateX(4px); }
.hc-icon-doc { color: #8b6f47; opacity: 0.7; }
.hc-icon-chat { color: var(--text-muted); opacity: 0.7; }

.history-card .hc-body {
  flex: 1; min-width: 0;
  transition: transform 0.3s ease-out;
}
.history-card:hover .hc-body { transform: translateX(4px); }

.history-card .hc-title {
  font-size: 14px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 2px;
}
.hc-shared-badge {
  display: inline-flex;
  margin-left: 7px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  vertical-align: 1px;
}
.history-card .hc-subtitle {
  font-size: 12px; color: var(--text-muted); margin-bottom: 2px;
}
.hc-byline { color: var(--text-dim); }

/* Attachment indicator (inline with subtitle) */
.hc-attachments {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 12px; color: var(--text-muted);
}
.hc-attachments svg { flex-shrink: 0; opacity: 0.6; position: relative; top: 1px; }

/* Delete action button — fades in on hover */
.hc-actions {
  opacity: 0; transition: opacity 0.15s ease-out;
  margin-left: auto; flex-shrink: 0;
  display: flex; align-items: center; gap: 4px;
}
.history-card:hover .hc-actions { opacity: 1; }
.hc-action-btn {
  width: 28px; height: 28px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s;
}
.hc-action-btn:hover { color: var(--text); border-color: var(--text-muted); }
.hc-action-btn.hc-share:hover {
  transform: translateY(-2px);
  color: var(--text-muted);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.hc-action-btn.hc-share.is-shared { color: var(--accent); }
.hc-action-btn.hc-share:disabled {
  cursor: wait;
  opacity: 0.6;
  transform: none;
}

/* One durable owner-facing sharing surface, anchored from chat or History. */
.chat-share-panel {
  position: fixed;
  z-index: 15000;
  width: min(380px, calc(100vw - 24px));
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--cream);
  box-shadow: var(--shadow-lg);
}
.chat-share-panel[hidden] { display: none; }
.chat-share-heading {
  margin: 0 0 5px;
  color: var(--text);
  font: 600 19px/1.25 var(--serif);
}
.chat-share-summary,
.chat-share-consequence {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}
.chat-share-consequence {
  margin-top: 16px;
  color: var(--text-dim);
}
.chat-share-consequence[hidden] { display: none; }
.chat-share-link-row {
  display: flex;
  gap: 8px;
  margin-top: 17px;
}
.chat-share-link-row[hidden] { display: none; }
.chat-share-link {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-dim);
  font: 12px var(--mono);
}
.chat-share-link:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.chat-share-copy,
.chat-share-primary {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-contrast);
  font: 600 13px var(--sans);
  cursor: pointer;
  transition: transform 0.3s var(--spring), box-shadow 0.3s, opacity 0.15s;
}
.chat-share-copy { padding: 0 14px; }
.chat-share-primary {
  min-height: 40px;
  margin-top: 18px;
  padding: 0 16px;
}
.chat-share-copy:hover,
.chat-share-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.chat-share-copy:disabled,
.chat-share-primary:disabled,
.chat-share-stop:disabled {
  cursor: wait;
  opacity: 0.55;
  transform: none;
}
.chat-share-stop {
  margin-top: 17px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: 500 13px var(--sans);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.chat-share-stop[hidden] { display: none; }
.chat-share-stop:hover { color: var(--text); }
.chat-share-copy-status {
  min-height: 17px;
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 11px;
}
.hc-action-btn.hc-rename:hover { color: #8b6f47; border-color: rgba(139, 111, 71, 0.4); }
.hc-action-btn.hc-delete:hover { color: var(--error, #ef4444); border-color: var(--error, #ef4444); }

/* Inline rename input (history cards + ongoing chat) */
.hc-title-input {
  font-family: inherit; font-size: 14px; font-weight: 600; color: var(--text);
  background: var(--input-bg); border: 1px solid var(--accent);
  border-radius: 6px; padding: 2px 8px; width: 100%;
  outline: none; line-height: 1.4;
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.08);
}

/* Admin-only metadata (hidden unless admin mode) */
.hc-admin-meta {
  display: none; margin-top: 4px;
  font-size: 11px; font-family: var(--mono); color: var(--text-muted);
}
body.admin-mode .hc-admin-meta { display: block; }

.history-empty {
  text-align: center; color: var(--text-muted); font-size: 14px;
  padding: 64px 32px;
}

.history-load-error {
  display: grid;
  justify-items: center;
  gap: 12px;
}

.history-retry,
.board-recents-retry {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 7px 12px;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--border);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.history-retry:hover,
.board-recents-retry:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 0 var(--border);
}

.history-retry:disabled,
.board-recents-retry:disabled {
  cursor: wait;
  opacity: 0.65;
}

/* ---- KNOWLEDGE BASE PAGE ---- */
/* Edge to edge, like .pages-page-body and .gallery-inner. This was the only one
   of the three file surfaces with a 1200px cap, which cost the column view a
   whole column's worth of width on a 27" display and made Your Files look like
   a different application from Pages and Gallery. Padding matches theirs too,
   so the title, the cards and the column heads all share one left edge. */
.knowledge-page-body { padding: 20px 12px 24px 16px; width: 100%; }

/* Page header: no rules of its own. It wears .pages-page-header /
   .pages-page-title / .pages-view-toggle, so "Your Files" is the same 19px on
   the same 16/14 padding over the same --sidebar-bg as "Pages" and "Gallery",
   and the view pills are the same 34x28 with the same white cap when selected.
   These used to be a private set of .kb-* rules that had quietly drifted to
   18px, a 16px-radius bordered strip, and 36x32 pills — no decision, just age.
   `.kb-page-header` and `.kb-view-toggle` remain as JS hooks and carry nothing.

   The upload CTA wears .btn-build, the same hero button as "New page" and
   "Create an asset" — gradient, inset highlight, and the lift-off-the-desk
   hover the design philosophy asks for. `.kb-upload-btn` survives as the JS
   hook only; it carries no styling of its own, so the three CTAs cannot drift
   apart the way they did when this one was a flat --accent rectangle with an
   opacity hover. */

/* Upload modal */
.kb-upload-modal {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.2s;
}
.kb-upload-modal.visible { opacity: 1; }
.kb-upload-modal-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,0.4);
}
.kb-upload-modal-content {
  position: relative; background: var(--surface);
  border-radius: var(--radius-lg, 12px); padding: 28px;
  width: 90%; max-width: 600px; box-shadow: 0 12px 40px rgba(0,0,0,0.15);
  transform: translateY(8px); transition: transform 0.2s;
}
.kb-upload-modal.visible .kb-upload-modal-content { transform: translateY(0); }
.kb-upload-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.kb-upload-modal-header h3 {
  font-size: 16px; font-weight: 600; color: var(--text); margin: 0;
}
.kb-upload-modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 4px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.kb-upload-modal-close:hover { background: var(--surface2); }

/* Upload zone (now inside modal) */
.kb-upload-zone {
  border: 2px dashed var(--border-light); border-radius: var(--radius);
  padding: 80px 32px; text-align: center; cursor: pointer;
  transition: all 0.15s; background: var(--surface);
}
.kb-upload-zone:hover, .kb-upload-zone.drag-over {
  border-color: var(--accent); background: var(--surface2);
}
.kb-upload-zone.drag-over { border-style: solid; box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1); }
.kb-upload-inner svg { color: var(--text-muted); margin-bottom: 8px; }
.kb-upload-inner p { color: var(--text-dim); font-size: 14px; margin: 4px 0; }
.kb-upload-hint { font-size: 12px !important; color: var(--text-muted) !important; }

/* Forms inside upload modal */
.kb-upload-modal-forms .kb-desc-form,
.kb-upload-modal-forms .kb-paste-form {
  margin-top: 16px;
}

/* PDF parsing state */
.kb-upload-parsing {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
}
.kb-upload-parsing strong { color: var(--text); }
.kb-upload-parsing-spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}

/* Fade-in animation for new cards */
.kb-fade-in {
  animation: kbFadeIn 0.4s ease-out;
}
@keyframes kbFadeIn {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

.kb-section { margin-bottom: 24px; }
.kb-section-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 10px;
}

/* ---- Category sections ---- */
.kb-category-section { margin-bottom: 28px; }
.kb-category-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
  cursor: pointer; user-select: none; border-radius: 6px;
  padding: 4px 6px; margin-left: -6px; margin-right: -6px;
  transition: background 0.15s;
}
.kb-category-header:hover { background: var(--surface2); }
.kb-category-chevron {
  margin-left: auto; color: var(--text-muted);
  transition: transform 0.2s ease;
}
.kb-category-section.collapsed .kb-category-chevron {
  transform: rotate(-90deg);
}
.kb-category-collapse {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.25s ease;
}
.kb-category-section.collapsed .kb-category-collapse {
  grid-template-rows: 0fr;
}
.kb-category-collapse-inner {
  overflow: hidden;
}
.kb-category-icon { font-size: 18px; line-height: 1; }
.kb-category-label {
  font-size: 14px; font-weight: 600; color: var(--text);
}
.kb-category-count {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  background: var(--surface2); padding: 1px 8px;
  border-radius: 10px; min-width: 20px; text-align: center;
}
.kb-category-hint {
  font-size: 12px; color: var(--text-muted); margin: 0 0 12px 0;
  line-height: 1.4;
}

/* ---- Card grid (visual workspace) ---- */
.kb-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.kb-card {
  display: flex; flex-direction: column;
  padding: 18px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; transition: all 0.2s; position: relative;
  min-height: 100px;
}
.kb-card:hover {
  border-color: var(--accent); background: var(--surface2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

/* Category accent borders on hover */
.kb-card-brand:hover { border-color: #8b5cf6; }
.kb-card-product:hover { border-color: #10b981; }
.kb-card-audience:hover { border-color: #3b82f6; }
.kb-card-content:hover { border-color: #ec4899; }
.kb-card-playbook:hover { border-color: #f59e0b; }

.kb-card-icon { font-size: 24px; line-height: 1; margin-bottom: 10px; }
.kb-card-icon-emoji { font-size: 24px; }
.kb-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.kb-card-name {
  font-size: 14px; font-weight: 600; color: var(--text);
  line-height: 1.3; margin-bottom: 6px;
}
.kb-card-desc {
  font-size: 12px; color: var(--text-dim); line-height: 1.4;
  display: -webkit-box; line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 10px;
}
.kb-card-tags {
  display: flex; flex-wrap: nowrap; gap: 4px;
  overflow: hidden; position: relative; margin-bottom: 12px;
  -webkit-mask-image: linear-gradient(to right, black calc(100% - 32px), transparent);
  mask-image: linear-gradient(to right, black calc(100% - 32px), transparent);
}
.kb-card-tags .kb-tag { flex-shrink: 0; }
.kb-tag {
  font-size: 10px; font-weight: 500; color: var(--text-muted);
  background: var(--surface2); padding: 2px 8px;
  border-radius: 8px; letter-spacing: 0.02em;
}
.kb-card-meta {
  font-size: 11px; color: var(--text-muted); margin-top: auto;
  display: flex; align-items: center; gap: 6px;
  padding-top: 8px;
}
.kb-meta-memorized {
  color: var(--accent-orange, #c75900);
  font-weight: 600;
}
.kb-badge-team,
.kb-badge-personal,
.kb-badge-new {
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 600; padding: 1px 7px;
  border-radius: 10px; letter-spacing: 0.02em;
}
.kb-badge-team { color: var(--accent); background: var(--sidebar-active); }
.kb-badge-personal { color: var(--text-muted); background: var(--surface2); }
.kb-badge-new { color: #16a34a; background: #dcfce7; }

.kb-card-delete {
  position: absolute; top: 8px; right: 8px;
  background: none; border: none; color: var(--text-muted);
  font-size: 16px; cursor: pointer; padding: 4px 6px;
  border-radius: 4px; transition: all 0.15s; line-height: 1;
  opacity: 0;
}
.kb-card:hover .kb-card-delete { opacity: 1; }
.kb-card-delete:hover { color: var(--red); background: var(--red-dim); }

/* Refinement form (post-upload review panel) */
.kb-refine-form {
  padding: 18px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--surface);
}
.kb-refine-header { margin-bottom: 14px; }
.kb-refine-header h4 {
  margin: 0 0 4px 0; font-size: 14px; font-weight: 600;
}
.kb-refine-hint {
  margin: 0; font-size: 12px; color: var(--text-muted);
  line-height: 1.4;
}
.kb-refine-rows {
  display: flex; flex-direction: column; gap: 12px;
  margin-bottom: 16px;
  max-height: 340px; overflow-y: auto;
}
.kb-refine-row {
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface2);
}
.kb-refine-filename {
  font-size: 12px; font-weight: 600; color: var(--text);
  margin-bottom: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.kb-refine-field {
  display: flex; flex-direction: column; gap: 4px;
  margin-bottom: 10px;
}
.kb-refine-label-text {
  font-size: 11px; font-weight: 500; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.kb-refine-desc {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text);
  font-size: 13px; font-family: inherit;
  box-sizing: border-box;
  resize: vertical; min-height: 44px; line-height: 1.4;
}
.kb-refine-desc:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--sidebar-active);
}
.kb-refine-error, .console-refine-error, .console-paste-error {
  margin: 10px 0;
  padding: 8px 12px;
  font-size: 12.5px;
  color: #a04040;
  background: #fdf2f2;
  border: 1px solid #f2c4c4;
  border-radius: 6px;
}
.kb-refine-pin {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  cursor: pointer; user-select: none;
  font-size: 13px;
}
.kb-refine-pin input[type="checkbox"] {
  margin: 0; cursor: pointer;
}
.kb-refine-pin-label { font-weight: 500; }
.kb-refine-pin-hint {
  font-size: 11px; color: var(--text-muted);
  flex-basis: 100%; margin-left: 22px;
}

/* ---- List view overrides ---- */
.kb-list-view .kb-card-grid {
  display: grid;
  /* icon | name | desc | tags | meta | delete */
  grid-template-columns: 28px minmax(140px, 200px) 1fr minmax(100px, 180px) auto 28px;
  column-gap: 16px; row-gap: 0;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg, 12px);
  overflow: hidden;
}
.kb-list-view .kb-card {
  display: grid; grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: center;
  padding: 10px 14px; min-height: auto;
  border-radius: 0; border: none;
  border-bottom: 1px solid var(--border-light);
}
.kb-list-view .kb-card:last-child { border-bottom: none; }
.kb-list-view .kb-card:hover {
  transform: none; border-color: var(--border-light);
  background: var(--surface2); box-shadow: none;
}
.kb-list-view .kb-card-icon {
  font-size: 16px; margin-bottom: 0; line-height: 1;
}
.kb-list-view .kb-card-icon-emoji { font-size: 16px; }
.kb-list-view .kb-card-body {
  display: contents;
}
.kb-list-view .kb-card-name {
  font-size: 13px; margin-bottom: 0; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.kb-list-view .kb-card-desc {
  font-size: 12px; margin-bottom: 0;
  line-clamp: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kb-list-view .kb-card-tags {
  margin-bottom: 0; max-width: 180px;
}
.kb-list-view .kb-card-meta {
  margin-top: 0; padding-top: 0; white-space: nowrap;
  font-size: 11px;
}
.kb-list-view .kb-card-delete {
  position: static; opacity: 0;
  padding: 2px 4px; justify-self: end;
}
.kb-list-view .kb-card:hover .kb-card-delete { opacity: 1; }
.kb-list-view .kb-card-rename-icon { display: none; }

/* Hide accent borders in list view — rows use bottom border */
.kb-list-view .kb-card-brand:hover,
.kb-list-view .kb-card-product:hover,
.kb-list-view .kb-card-audience:hover,
.kb-list-view .kb-card-content:hover,
.kb-list-view .kb-card-playbook:hover { border-color: var(--border-light); }

/* Preview modal enhancements */
.kb-preview-meta {
  font-size: 12px; color: var(--text-muted); margin-top: 8px;
}
.kb-preview-tags {
  display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px;
  align-items: center;
}
.kb-tags-overflow { display: none; }
.kb-tags-overflow .kb-tag { margin: 0; }
.kb-tags-toggle {
  background: none; border: none; color: var(--accent);
  font-size: 11px; font-weight: 500; cursor: pointer;
  padding: 2px 6px;
}
.kb-tags-toggle:hover { text-decoration: underline; }

@media (max-width: 600px) {
  .kb-card-grid {
    grid-template-columns: 1fr;
  }
}

/* Paste button in upload zone */
.kb-paste-btn {
  background: none; border: none; color: var(--accent); font-size: 13px;
  cursor: pointer; padding: 4px 8px; margin-top: 4px;
  text-decoration: underline; text-underline-offset: 2px;
}
.kb-paste-btn:hover { opacity: 0.8; }

/* Paste form */
.kb-paste-form {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.kb-paste-textarea {
  width: 100%; padding: 10px 12px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text); resize: vertical;
  outline: none; transition: border-color 0.15s; min-height: 120px;
  margin-bottom: 4px;
}
.kb-paste-textarea:focus { border-color: var(--accent); }
.kb-paste-form .kb-desc-label { margin-top: 12px; }
.kb-paste-form .kb-desc-label:first-child { margin-top: 0; }
.kb-input-error { border-color: var(--red) !important; }

/* Rename icon on cards */
.kb-card-rename-icon {
  font-size: 12px; margin-left: 6px; opacity: 0; cursor: pointer;
  transition: opacity 0.15s;
}
.kb-card:hover .kb-card-rename-icon { opacity: 0.5; }
.kb-card-rename-icon:hover { opacity: 1 !important; }

/* Rename inline input */
.kb-card-rename-input {
  width: 100%; padding: 2px 6px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--accent); border-radius: 4px;
  background: var(--bg); color: var(--text); outline: none;
  font-family: inherit;
}

.kb-desc-form {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
}
.kb-desc-form-header { margin-bottom: 8px; }
.kb-desc-form-files {
  font-size: 13px; font-weight: 500; color: var(--text);
}
.kb-desc-label {
  display: block; font-size: 13px; color: var(--text-muted);
  margin-bottom: 6px;
}
.kb-desc-input {
  width: 100%; padding: 8px 12px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text);
  outline: none; transition: border-color 0.15s;
}
.kb-desc-input:focus { border-color: var(--accent); }
.kb-desc-actions {
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px;
}
.kb-desc-skip, .kb-desc-upload {
  padding: 6px 16px; border-radius: 6px; font-size: 13px;
  font-weight: 500; cursor: pointer; border: none; transition: all 0.15s;
}
.kb-desc-skip {
  background: none; color: var(--text-muted);
}
.kb-desc-skip:hover { color: var(--text); }
.kb-desc-upload {
  background: var(--accent); color: white;
}
.kb-desc-upload:hover { opacity: 0.9; }

.kb-empty { text-align: center; color: var(--text-muted); padding: 48px 24px; }
.kb-empty p { margin: 4px 0; font-size: 14px; }
.kb-empty-hint { font-size: 13px !important; max-width: 360px; margin: 8px auto 0 !important; line-height: 1.5; }

.kb-loading { text-align: center; color: var(--text-muted); padding: 48px; font-size: 14px; }

.kb-preview-modal {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.kb-preview-modal.visible { opacity: 1; pointer-events: auto; }
.kb-preview-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.4); }
.kb-preview-content {
  position: relative; background: var(--surface);
  border-radius: var(--radius); max-width: 700px; width: 90%;
  max-height: 80vh; display: flex; flex-direction: column;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}
.kb-preview-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 20px 16px; gap: 16px;
}
.kb-preview-header h3 { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.kb-preview-close {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: none; font-size: 12px; font-weight: 500;
  color: var(--text-muted); cursor: pointer; padding: 5px 10px;
  border-radius: 6px; flex-shrink: 0; white-space: nowrap;
}
.kb-preview-close svg { flex-shrink: 0; }
.kb-preview-close:hover { color: var(--text); background: var(--bg-offset, rgba(0,0,0,0.05)); }
.kb-preview-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 20px; border-bottom: 1px solid var(--border);
}
.kb-preview-copy {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  cursor: pointer; padding: 5px 12px; border-radius: 6px;
  font-size: 12px; font-weight: 500;
}
.kb-preview-copy svg { flex-shrink: 0; }
.kb-preview-copy:hover { color: var(--text); background: var(--bg-offset, rgba(0,0,0,0.05)); }
.kb-preview-share {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  cursor: pointer; padding: 5px 12px; border-radius: 6px;
  font-size: 12px; font-weight: 500;
}
.kb-preview-share svg { flex-shrink: 0; }
.kb-preview-share:hover:not(:disabled) { color: var(--text); background: var(--bg-offset, rgba(0,0,0,0.05)); }
.kb-preview-share:disabled { opacity: 0.6; cursor: not-allowed; }
.kb-preview-pill {
  display: inline-flex; background: var(--bg-offset, #f0ebe3);
  border-radius: 8px; padding: 3px; gap: 2px;
}
.kb-preview-tab {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: none; border-radius: 6px;
  padding: 5px 12px; font-size: 12px; font-weight: 500;
  color: var(--text-muted); cursor: pointer; transition: all 0.15s;
}
.kb-preview-tab svg { flex-shrink: 0; }
.kb-preview-tab:hover { color: var(--text); }
.kb-preview-tab.active {
  background: var(--surface, #fff); color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.kb-preview-body {
  padding: 20px; overflow-y: auto; flex: 1;
  font-size: 13px; line-height: 1.6; color: var(--text);
}
.kb-preview-body pre {
  white-space: pre-wrap; word-wrap: break-word;
  font-family: var(--mono); margin: 0;
}
/* Skeleton loading */
.kb-skeleton-line {
  height: 12px; border-radius: 6px;
  background: var(--border-light, #e8e0d6);
  animation: kb-pulse 1.2s ease-in-out infinite;
}
.kb-skeleton-line + .kb-skeleton-line { margin-top: 10px; }
.kb-skeleton-line:nth-child(2) { width: 85%; animation-delay: 0.1s; }
.kb-skeleton-line:nth-child(3) { width: 70%; animation-delay: 0.2s; }
.kb-skeleton-line:nth-child(4) { width: 90%; animation-delay: 0.3s; }
.kb-skeleton-line:nth-child(5) { width: 60%; animation-delay: 0.4s; }
.kb-skeleton-line:nth-child(6) { width: 80%; animation-delay: 0.5s; }
.kb-skeleton-line:nth-child(7) { width: 50%; animation-delay: 0.6s; }
.kb-skeleton-heading {
  height: 18px; width: 45%; border-radius: 6px; margin-bottom: 16px;
  background: var(--border-light, #e8e0d6);
  animation: kb-pulse 1.2s ease-in-out infinite;
}
.kb-skeleton-block + .kb-skeleton-block { margin-top: 24px; }
@keyframes kb-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

/* Page-level skeleton */
.kb-skeleton-header-row {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 16px; margin-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}
.kb-skeleton-section { margin-bottom: 28px; }
.kb-skeleton-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px;
}
.kb-skeleton-card {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px; border-radius: var(--radius);
  border: 1px solid var(--border-light);
}

/* Topbar title for non-chat pages */
.topbar-title { font-size: 14px; font-weight: 600; color: var(--text); }

/* Mobile menu button (hidden on desktop) */
.mobile-menu-btn { display: none !important; }

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.3); z-index: 59;
}
.sidebar-overlay.visible { display: block; }

/* ---- RESPONSIVE ---- */
@media (min-width: 769px) {
  .main-container {
    margin-left: var(--sidebar-width);
    transition: margin-left 0.2s ease;
  }
  body.sidebar-collapsed .main-container {
    margin-left: var(--sidebar-collapsed);
  }
}
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    transform: translateX(-100%);
    z-index: 200;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-container { margin-left: 0 !important; }
  .mobile-menu-btn { display: flex !important; }
}

/* ---- LAYOUT ---- */

.pane-agent {
  width: var(--pane-split); display: flex; flex-direction: column;
  min-width: 300px; border-right: none;
}

/* Transparent container — notebook canvas peeks through around the floating page */
.pane-output {
  flex: 1; display: flex; flex-direction: column;
  min-width: 320px;
  background: transparent;
  position: relative;
  border-radius: 0;
  box-shadow: none;
  border: none;
  padding: 12px 20px 16px 8px;
  margin: 0;
}
/* Dog-ear moved to .artifact-page — pane-output no longer has one */
.pane-output::after { display: none; }

/* THE PAGE — one unified floating element with shadow + dog-ear */
.artifact-page {
  background: #ffffff;
  border: 1px solid rgba(180, 170, 150, 0.2);
  border-radius: 0 12px 12px 12px;
  box-shadow: 4px 6px 24px rgba(60, 50, 40, 0.08), 0 1px 3px rgba(60, 50, 40, 0.04);
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* Dog-ear fold — canvas peeks through the corner */
.artifact-page::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 28px; height: 28px;
  background: linear-gradient(225deg, var(--bg) 50%, rgba(180, 170, 150, 0.15) 50%);
  border-radius: 0 12px 0 0;
  z-index: 10;
  pointer-events: none;
}

/* Strip paper styling when retro monitor is active */
.artifact-page.retro-active {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}
.artifact-page.retro-active::after {
  display: none;
}

/* ---- RESIZER — subtle warm divider ---- */
.pane-resizer {
  width: 4px; cursor: col-resize; background: transparent;
  position: relative; flex-shrink: 0; z-index: 5;
  transition: background 0.15s;
}

.pane-resizer:hover, .pane-resizer.dragging {
  background: rgba(139, 111, 71, 0.15);
}

.pane-resizer::after {
  content: ''; position: absolute;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 3px; height: 32px;
  background: var(--text-muted); border-radius: 2px;
  opacity: 0.18; transition: opacity 0.15s;
}

.pane-resizer:hover::after, .pane-resizer.dragging::after { opacity: 0.45; }

/* ---- PHASE LAYOUT ---- */
/* Dashboard: full-width, no output pane */
.phase-dashboard .pane-resizer,
.phase-dashboard .pane-output { display: none; }
.phase-dashboard .pane-agent { width: 100%; }
.phase-dashboard .chat-log {
  display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start; padding-top: 40px;
}
.phase-dashboard .chat-log {
  -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 48px), transparent);
  mask-image: linear-gradient(to bottom, black calc(100% - 48px), transparent);
}
.phase-dashboard .pane-agent.scrolled-bottom .chat-log {
  -webkit-mask-image: none;
  mask-image: none;
}

.phase-dashboard .input-area {
  max-width: 680px; margin: 0 auto; width: 100%;
  /* +8 to clear the pad's shadow throw, same reason as .input-area */
  border-top: none; background: transparent; padding: 0 20px 32px;
}
.phase-dashboard .input-wrap textarea {
  background: transparent; border: none;
}

/* Chat: full-width, no output pane, input at bottom */
.phase-chat .pane-resizer,
.phase-chat .pane-output { display: none; }
.phase-chat .pane-agent { width: 100%; }

/* Chat+Output: split pane with slide-in animation */
.phase-chat-output .pane-agent {
  transition: width 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.phase-chat-output .pane-resizer {
  animation: fadeIn 0.3s ease 0.2s both;
}
.phase-chat-output .pane-output {
  animation: slideInFromRight 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes slideInFromRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.pane-header {
  height: 44px; padding: 0 28px;
  border: none; border-bottom: 1px solid rgba(180, 170, 150, 0.1);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; background: transparent;
  gap: 12px; min-width: 0;
}

.pane-header h3 {
  font-size: 14px; font-weight: 600;
  font-family: var(--serif); font-style: normal;
  letter-spacing: 0; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0; flex: 1;
}

.pane-header-left {
  display: flex; align-items: center; gap: 10px;
  min-width: 0; flex: 1; overflow: visible;
}
.pane-header-left h3 { flex: unset; }

.pane-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; position: relative; }

/* ---- Header word count ---- */
.header-word-count {
  font-family: var(--sans); font-size: 11px; color: #b0a694;
  white-space: nowrap;
}

/* ---- Draft / Saved status labels ---- */
.file-status-draft {
  color: var(--text-muted);
  font-style: italic;
}
.file-status-saved {
  color: var(--green);
}

/* ---- Filed toast ---- */
.filed-toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%) translateY(-12px);
  background: var(--card-bg, #fffdf8); color: var(--text);
  font-family: var(--sans); font-size: 13px;
  padding: 10px 18px; border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  border: 1px solid rgba(180, 170, 150, 0.2);
  opacity: 0; transition: opacity 0.3s, transform 0.3s;
  z-index: 1000; pointer-events: auto;
}
.filed-toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.filed-toast-link {
  color: var(--accent); cursor: pointer; text-decoration: underline;
  text-underline-offset: 2px;
}
.filed-toast-link:hover { text-decoration-thickness: 2px; }

/* ---- Version indicator & dropdown ---- */
.version-indicator { position: relative; flex-shrink: 0; }

.version-trigger {
  display: flex; align-items: center; gap: 4px;
  font-family: var(--sans); font-size: 11px; font-weight: 500;
  color: #8a7e70; background: rgba(180, 170, 150, 0.1);
  border: 1px solid rgba(180, 170, 150, 0.15); border-radius: 6px;
  padding: 3px 8px; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.version-trigger:hover {
  background: rgba(180, 170, 150, 0.18); border-color: rgba(180, 170, 150, 0.3);
}
.version-trigger svg { opacity: 0.5; }

.version-dropdown {
  display: none; position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 240px; max-width: 320px; max-height: 320px;
  background: var(--card-bg, #fffdf8); border: 1px solid rgba(180, 170, 150, 0.2);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 100; overflow: hidden;
  animation: versionDropIn 0.15s ease-out;
}
.version-dropdown.open { display: flex; flex-direction: column; }

@keyframes versionDropIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.version-dropdown-header {
  font-family: var(--sans); font-size: 11px; font-weight: 600;
  color: #8a7e70; padding: 10px 14px 6px; text-transform: uppercase;
  letter-spacing: 0.5px;
}

.version-list {
  overflow-y: auto; max-height: 220px; padding: 0 6px 6px;
}

.version-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 6px; cursor: pointer;
  font-family: var(--sans); font-size: 12px; color: var(--text);
  transition: background 0.1s;
}
.version-item:hover { background: rgba(180, 170, 150, 0.1); }
.version-item--active { background: rgba(180, 170, 150, 0.15); font-weight: 600; }

.version-item-num {
  font-weight: 600; color: #8a7e70; min-width: 24px; font-size: 11px;
}
.version-item-label {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text); font-size: 12px;
}
.version-item-label--edit {
  font-style: italic; color: var(--text-muted);
}
.version-item-label .restored-note {
  font-size: 10px; color: #a09080; font-style: italic;
}
.version-item-time {
  font-size: 10px; color: #a09080; white-space: nowrap; flex-shrink: 0;
}

/* ---- Version banner (historical view) ---- */
.version-banner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 28px; gap: 12px;
  background: rgba(180, 170, 150, 0.08);
  border-bottom: 1px solid rgba(180, 170, 150, 0.12);
  font-family: var(--sans); font-size: 12px; color: #8a7e70;
  animation: versionBannerIn 0.2s ease-out;
}
@keyframes versionBannerIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.version-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }
.version-banner-btn {
  font-family: var(--sans); font-size: 11px; font-weight: 500;
  color: #8a7e70; background: rgba(180, 170, 150, 0.1);
  border: 1px solid rgba(180, 170, 150, 0.15); border-radius: 6px;
  padding: 4px 10px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.version-banner-btn:hover { background: rgba(180, 170, 150, 0.2); }
.version-banner-btn-primary {
  color: var(--accent); border-color: var(--accent);
  background: rgba(var(--accent-rgb, 139, 90, 43), 0.08);
}
.version-banner-btn-primary:hover {
  background: rgba(var(--accent-rgb, 139, 90, 43), 0.15);
}

/* ---- Stale page draft banner (a teammate deployed since your last edit) ---- */
.page-stale-banner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 28px; gap: 12px;
  background: rgba(214, 158, 46, 0.30);
  border-left: 3px solid rgba(214, 158, 46, 0.85);
  border-bottom: 1px solid rgba(214, 158, 46, 0.45);
  font-family: var(--sans); font-size: 13px; font-weight: 500; color: #6b5210;
  animation: versionBannerIn 0.2s ease-out;
}
.page-stale-text { display: flex; align-items: center; gap: 8px; }
.page-stale-text::before { content: "⚠"; font-size: 14px; }
.page-stale-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Shake + glow when the user tries to chat without resolving the banner.
   One-shot per banner appearance (JS toggles the class for ~600ms then removes). */
@keyframes staleBannerPulse {
  0%, 100% { transform: translateX(0); background: rgba(214, 158, 46, 0.30); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); background: rgba(214, 158, 46, 0.55); }
  20%, 40%, 60%, 80% { transform: translateX(4px); background: rgba(214, 158, 46, 0.55); }
}
.page-stale-banner.pulsing { animation: staleBannerPulse 0.6s ease-in-out; }

/* Inline tip above the chat input — fires on the first send attempt while a
   stale banner is showing, then auto-hides. Quiet visual partner to the banner. */
@keyframes chatStaleTipIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-stale-tip {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 8px;
  padding: 6px 10px;
  background: rgba(214, 158, 46, 0.15);
  border-left: 2px solid rgba(214, 158, 46, 0.85);
  border-radius: 4px;
  font-family: var(--sans); font-size: 12px; color: #6b5210;
  animation: chatStaleTipIn 0.2s ease-out;
}
.chat-stale-tip-arrow { font-size: 13px; }

/* ---- Side-by-side diff ---- */
.output-rendered.diff-view { max-width: none; }
.diff-side-by-side { width: 100%; }
.diff-pair { display: flex; gap: 12px; margin-bottom: 4px; }
.diff-pair-header {
  margin-bottom: 8px; border-bottom: 1px solid rgba(0,0,0,0.08); padding-bottom: 8px;
}
.diff-cell { flex: 1; min-width: 0; padding: 4px 8px; border-radius: 3px; }
.diff-col-header {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-dim);
}
.diff-cell-del {
  background: rgba(220, 53, 69, 0.08);
  border-left: 3px solid rgba(220, 53, 69, 0.35);
  text-decoration: line-through; color: #b44; opacity: 0.7;
}
.diff-cell-add {
  background: rgba(34, 139, 34, 0.08);
  border-left: 3px solid rgba(34, 139, 34, 0.4);
}
.diff-cell-changed {
  background: rgba(180, 170, 150, 0.06);
  border-left: 3px solid rgba(180, 170, 150, 0.3);
}
/* Inline word-level diff classes */
.diff-del {
  background: rgba(220, 53, 69, 0.12); text-decoration: line-through;
  color: #b44; border-radius: 2px; padding: 0 2px;
}
.diff-add {
  background: rgba(34, 139, 34, 0.15);
  border-radius: 2px; padding: 0 2px;
}

/* Historical view dims the content slightly */
.artifact-page--historical .output-content { opacity: 0.85; }

/* Header copy button — hidden (copy lives in the footer status bar) */
.copy-btn { display: none !important; }

/* "File this away" button in header — plain text, physical-object style */
.save-to-kb-btn {
  font-family: var(--sans); font-size: 11px;
  color: #8a7e70; padding: 5px 10px; border-radius: 6px;
  border: 1px solid rgba(180, 170, 150, 0.15); background: transparent;
  cursor: pointer; transition: all 0.15s;
}
.save-to-kb-btn:hover { color: var(--text); background: rgba(180, 170, 150, 0.08); border-color: rgba(180, 170, 150, 0.25); }
.save-to-kb-btn.copied { color: var(--green); border-color: var(--green); }

/* Inline "File this away" form — replaces window.prompt */
.kb-inline-form {
  position: absolute; top: 100%; right: 0; z-index: 50;
  background: var(--card-bg); border: 1px solid rgba(180, 170, 150, 0.25);
  border-radius: 6px; padding: 10px; margin-top: 4px;
  box-shadow: var(--shadow-md); min-width: 260px;
  animation: chipSlideIn 0.15s ease;
}
.kb-inline-input {
  width: 100%; padding: 6px 10px; font-size: 13px; font-family: inherit;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface); color: var(--text); outline: none;
}
.kb-inline-input:focus { border-color: #8b6f47; box-shadow: 0 0 0 2px rgba(139, 111, 71, 0.1); }
.kb-inline-actions { display: flex; gap: 6px; margin-top: 8px; }
.kb-inline-save {
  padding: 5px 12px; font-size: 12px; font-family: inherit;
  background: #8b6f47; color: white; border: none; border-radius: 4px;
  cursor: pointer; font-weight: 500;
}
.kb-inline-save:hover { background: #9a7d54; }
.kb-inline-cancel {
  padding: 5px 12px; font-size: 12px; font-family: inherit;
  background: none; color: var(--text-muted); border: 1px solid var(--border);
  border-radius: 4px; cursor: pointer;
}
.kb-inline-cancel:hover { color: var(--text); background: var(--surface2); }
.kb-inline-error { font-size: 11px; color: var(--red); margin-top: 6px; }

/* ---- SETTINGS DRAWER ---- */
.settings-drawer {
  position: fixed; top: 36px; right: 0; bottom: 0; width: 400px;
  background: var(--surface); border-left: 1px solid var(--border);
  z-index: 60; transform: translateX(100%); transition: transform 0.25s ease;
  display: flex; flex-direction: column;
}
.settings-drawer.open { transform: translateX(0); }

.settings-backdrop {
  position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,0.25);
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.settings-backdrop.visible { opacity: 1; pointer-events: auto; }

.drawer-close {
  background: none; border: none; font-size: 22px; color: var(--text-dim);
  cursor: pointer; padding: 4px 8px; line-height: 1; border-radius: var(--radius-sm);
}
.drawer-close:hover { background: var(--surface2); color: var(--text); }

.settings-drawer-save {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 10px; margin-top: 8px;
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: background 0.15s;
}
.settings-drawer-save:hover { background: var(--accent-hover); }
.settings-drawer-save:disabled { opacity: 0.5; cursor: not-allowed; }
.settings-drawer-save.saved { background: var(--green); }

/* Gear icon — hidden by default, shown in admin mode on chat page */
.settings-gear-btn { display: none; }
body.admin-mode .settings-gear-btn.gear-visible { display: flex; }

/* Layout swap */
.chat-panes.layout-swapped { flex-direction: row-reverse; }

/* Layout toggle group — hidden by default, shown on chat page */
.layout-toggle-group { display: none; align-items: center; gap: 2px; }
.layout-toggle-group.layout-toggle-visible { display: flex; }

.layout-toggle-btn {
  display: flex; align-items: center; justify-content: center;
  padding: 5px 6px; background: none; border: none;
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text-muted); transition: all 0.15s;
}
.layout-toggle-btn:hover { background: var(--surface2); color: var(--text); }
.layout-toggle-btn.active { background: var(--surface3); color: var(--text); }

.settings-drawer .drawer-header {
  padding: 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.settings-drawer .drawer-header h3 { font-size: 14px; font-weight: 600; }
.settings-drawer .drawer-body { flex: 1; overflow-y: auto; padding: 16px; }

.setting-group { margin-bottom: 20px; }

/* Sub-group divider inside a settings card (e.g. Tools → Integrations) so a
   capability toggle reads as separate from the tool allowlist above it. */
.setting-group.cs-integrations { border-top: 1px solid var(--border); padding-top: 16px; }

.setting-group label {
  display: block; font-size: 12px; font-weight: 600; color: var(--text-dim);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.04em;
}

.setting-group select,
.setting-group input[type="number"],
.setting-group input[type="text"] {
  width: 100%; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 13px;
  font-family: var(--mono); outline: none; transition: border-color 0.15s;
}

.setting-group select:focus,
.setting-group input:focus { border-color: var(--accent); }
.setting-group select option { background: var(--surface); }

.setting-group textarea {
  width: 100%; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 12px;
  font-family: var(--mono); line-height: 1.5; resize: vertical;
  min-height: 120px; outline: none; transition: border-color 0.15s;
}

.setting-group textarea:focus { border-color: var(--accent); }

.setting-group .pricing-hint {
  font-size: 11px; color: var(--text-muted); margin-top: 4px; font-family: var(--mono);
}

.setting-group .hint {
  font-size: 11px; color: var(--text-muted); margin-top: 4px; line-height: 1.4;
}

/* Inline toggle label (checkbox + text on one line) */
.setting-group .setting-toggle-label {
  display: inline-flex; align-items: center; gap: 8px;
  cursor: pointer; font-weight: 500; user-select: none;
  margin-bottom: 0;
}
.setting-group .setting-toggle-label input[type="checkbox"] {
  margin: 0; width: auto; cursor: pointer;
}

/* Disabled slider/number when Use Thinking is off */
.setting-group input[type="range"]:disabled,
.setting-group input[type="number"]:disabled {
  opacity: 0.45; cursor: not-allowed;
}

.setting-divider {
  margin: 24px 0 20px;
  border: none; border-top: 1px solid var(--border);
}

.setting-section-title {
  font-size: 11px; font-weight: 700; color: var(--purple);
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}

.setting-section-title::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.tool-toggles { display: flex; flex-direction: column; gap: 6px; }

.tool-toggle {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px;
  border-radius: var(--radius-sm); cursor: pointer; transition: background 0.1s;
}

.tool-toggle:hover { background: var(--surface2); }
.tool-toggle input[type="checkbox"] { accent-color: var(--accent); }
.tool-toggle .tool-label { font-size: 13px; font-family: var(--mono); }
.tool-toggle .tool-desc { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ---- Skills list (settings drawer) ---- */
.sd-skills-list { display: flex; flex-direction: column; gap: 8px; }
.sd-skill-category-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 2px; }
.sd-skill-row { padding: 3px 0 3px 8px; font-size: 13px; }
.sd-skill-name { font-family: var(--mono); font-weight: 600; }
.sd-skill-desc { color: var(--text-muted); margin-left: 6px; }

/* ---- CHAT LOG ---- */
.chat-log {
  flex: 1; overflow-y: auto; padding: 24px 24px 32px;
  display: flex; flex-direction: column; gap: 20px;
}
.chat-log > .msg,
.chat-log > .chat-admin-banner,
.chat-log > .turn-divider,
.chat-log > .study-card,
.chat-log > .narration-ticker,
.chat-log > .run-bundle,
.chat-log > .tool-group,
.chat-log > .completion-card,
.chat-log > .error-card,
.chat-log > .turn-save-notice,
.chat-log > .page-building-card,
.chat-log > .page-deployed-card,
.chat-log > .brand-swatch-card,
.chat-log > .page-headsup-wrap,
.chat-log > .work-slip,
.chat-log > .research-board { max-width: 768px; width: 100%; margin-inline: auto; }

.chat-admin-banner {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.chat-log::-webkit-scrollbar { width: 5px; }
.chat-log::-webkit-scrollbar-track { background: transparent; }
.chat-log::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ---- DASHBOARD: Proactive Creative Board ---- */
.dashboard {
  width: 100%; max-width: 680px; margin: 0 auto; padding: 0 20px 32px;
}

/* === Highlighter marks === */
mark.hl {
  background: none;
  color: inherit;
  padding: 1px 4px;
  margin: 0 -2px;
  border-radius: 3px 4px 2px 5px;
}
mark.hl.yellow { background: var(--hl-yellow); }
mark.hl.pink { background: var(--hl-pink); }
mark.hl.green { background: var(--hl-green); }
mark.hl.blue { background: var(--hl-blue); }

/* === Tape strip === */
.tape-strip {
  position: absolute;
  background: var(--tape);
  box-shadow: 0 1px 2px var(--tape-shadow);
  z-index: 5;
  pointer-events: none;
  border-top: 1px solid rgba(255, 255, 255, 0.4);
  border-bottom: 1px solid rgba(200, 190, 170, 0.15);
}
.tape-strip.top-center {
  width: 60px; height: 18px;
  top: -8px; left: 50%; margin-left: -30px;
  transform: rotate(-1deg);
}
.tape-strip.top-left {
  width: 50px; height: 16px;
  top: -6px; left: 10px;
  transform: rotate(-8deg);
}
.tape-strip.top-right {
  width: 50px; height: 16px;
  top: -6px; right: 10px;
  transform: rotate(6deg);
}
.tape-strip.cross-left {
  width: 55px; height: 16px;
  top: 8px; left: -8px;
  transform: rotate(-35deg);
}
.tape-strip.cross-right {
  width: 55px; height: 16px;
  top: 8px; right: -8px;
  transform: rotate(35deg);
}

/* === Paper clip === */
.paper-clip {
  position: absolute;
  top: -8px; right: 16px;
  width: 16px; height: 40px;
  z-index: 6;
}
.paper-clip::before {
  content: '';
  position: absolute;
  top: 0; left: 3px;
  width: 10px; height: 36px;
  border: 2px solid #a0a0a0;
  border-radius: 0 0 6px 6px;
  border-top: none;
}
.paper-clip::after {
  content: '';
  position: absolute;
  top: -4px; left: 1px;
  width: 14px; height: 24px;
  border: 2px solid #b0b0b0;
  border-radius: 8px 8px 0 0;
  border-bottom: none;
}

/* === Pushpin === */
.pushpin {
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3), inset 0 -1px 2px rgba(0,0,0,0.2);
  z-index: 6;
}
.pushpin.red { background: radial-gradient(circle at 40% 35%, #f55, #d44); }
.pushpin.green { background: radial-gradient(circle at 40% 35%, #5a5, #3a7); }
.pushpin.blue { background: radial-gradient(circle at 40% 35%, #58f, #36c); }
.pushpin.yellow { background: radial-gradient(circle at 40% 35%, #fc5, #da3); }

/* Blu-tack — small irregular adhesive blob peeking from BEHIND objects */
/* Physics: blu-tack goes on the wall, object sits on top. You see small bits
   peeking from corners/edges. z-index: -1 so it sits behind the parent. */
.blu-tack {
  position: absolute;
  width: 14px; height: 10px;
  background: #9ab8cc;
  border-radius: 60% 50% 45% 55% / 55% 60% 45% 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12), inset 0 1px 1px rgba(255,255,255,0.25);
  z-index: -1;
  opacity: 0.82;
}
/* Slight squish variations — real tack isn't uniform */
.blu-tack.squish-1 { border-radius: 55% 45% 50% 60% / 50% 55% 60% 45%; width: 14px; height: 10px; }
.blu-tack.squish-2 { border-radius: 50% 60% 55% 45% / 60% 45% 50% 55%; width: 16px; height: 12px; }
.blu-tack.squish-3 { border-radius: 45% 55% 60% 50% / 55% 50% 45% 60%; width: 15px; height: 11px; }

/* === Silver thumbtack — kindergarten callback, informational/general pinning === */
.thumbtack {
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  z-index: 6;
}
.thumbtack.silver {
  background: radial-gradient(circle at 40% 30%, #e8e8e8, #b0b0b0 60%, #888 100%);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3), inset 0 1px 2px rgba(255,255,255,0.5), inset 0 -1px 2px rgba(0,0,0,0.15);
}

/* === Staple — electric stapler wire, for permanent/completed items === */
.staple {
  position: absolute;
  width: 16px; height: 6px;
  z-index: 6;
}
/* Bridge (top bar visible) */
.staple::before {
  content: '';
  position: absolute;
  top: 0; left: 1px; right: 1px;
  height: 2px;
  background: linear-gradient(180deg, #d4d4d4, #a8a8a8);
  border-radius: 0.5px;
  box-shadow: 0 0.5px 1px rgba(0,0,0,0.2);
}
/* Two legs (entry points, slightly darker) */
.staple::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 2px; height: 3px;
  background: #999;
  border-radius: 0 0 0.5px 0.5px;
  box-shadow: 10px 0 0 #999; /* second leg */
}

/* === Agent letter — personalized note on the desk === */
.dash-letter {
  position: relative;
  background: var(--surface);
  padding: 20px 22px 24px;
  border-radius: 2px;
  box-shadow: var(--shadow-md);
  transform: rotate(-0.3deg);
  transition: all 0.3s var(--spring);
  margin-bottom: 24px;
}
.dash-letter:hover {
  transform: rotate(0deg) translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Polaroid photo — taped to top-right of letter like a real note */
.letter-polaroid {
  position: absolute;
  top: -8px; right: 16px;
  width: 56px;
  padding: 4px 4px 14px;
  background: #fff;
  box-shadow: 1px 2px 8px rgba(60, 50, 40, 0.18);
  transform: rotate(3deg);
  z-index: 2;
}
.letter-polaroid img {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: block;
}
/* No extra fastening on polaroid — letter's tape holds everything (one fastening per object rule) */
.letter-polaroid-fallback {
  display: flex; align-items: center; justify-content: center;
  width: 100%; aspect-ratio: 1;
  background: linear-gradient(135deg, #e8d5c4, #d4bfa8);
  font-size: 22px; font-weight: 700; color: var(--text-dim);
  font-family: var(--serif);
}
.letter-date {
  font-family: 'Kalam', cursive;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.letter-body {
  font-family: 'Kalam', cursive;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  padding-right: 60px; /* keep text from overlapping polaroid */
}
.letter-cta {
  font-family: 'Kalam', cursive;
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  margin-top: 2px;
  cursor: pointer;
  display: inline-block;
  transition: all 0.2s var(--spring);
  border-bottom: 2px solid transparent;
}
.letter-cta:hover {
  transform: translateY(-1px);
  border-bottom-color: var(--accent);
}
.letter-signoff {
  font-family: 'Kalam', cursive;
  font-size: 16px;
  color: var(--text-dim);
  margin-top: 6px;
}

/* === Cork board — suggestion cards === */
.dash-board {
  border-radius: 8px;
  padding: 22px 20px 20px;
  position: relative;
  overflow: hidden;
  background-color: #c4a47a;
  background-image:
    radial-gradient(ellipse at 15% 25%, rgba(210,175,130,0.5) 0%, transparent 45%),
    radial-gradient(ellipse at 85% 75%, rgba(180,145,100,0.4) 0%, transparent 40%),
    radial-gradient(ellipse at 50% 10%, rgba(220,185,140,0.3) 0%, transparent 35%),
    radial-gradient(circle at 25% 80%, rgba(170,135,90,0.35) 0%, transparent 25%),
    radial-gradient(circle at 75% 30%, rgba(190,155,110,0.25) 0%, transparent 30%),
    linear-gradient(160deg, #cbb08a 0%, #b89468 50%, #c4a47a 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.12),
    inset 0 -1px 0 rgba(0,0,0,0.05),
    0 2px 4px rgba(60, 50, 40, 0.12),
    0 6px 16px rgba(60, 50, 40, 0.14),
    0 12px 40px rgba(60, 50, 40, 0.1);
  margin-bottom: 20px;
}
.dash-board::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 8px;
  border: 3px solid rgba(80, 60, 40, 0.25);
  pointer-events: none;
  z-index: 0;
}

/* Board grid */
.board-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  position: relative;
  z-index: 1;
}

/* Suggestion card on board — isolation trick for blu-tack peek-behind effect.
   Card background lives on ::before so blu-tack at z-index:-1 sits behind the
   card face but peeks from edges that extend beyond the card bounds. */
.s-card {
  background: transparent;
  padding: 16px 14px 12px;
  border-radius: 2px;
  box-shadow: 1px 2px 10px rgba(60, 50, 40, 0.18), 0 0 0 1px rgba(60, 50, 40, 0.03);
  position: relative;
  cursor: pointer;
  transition: all 0.25s var(--spring);
  isolation: isolate;
}
.s-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--cream);
  border-radius: inherit;
  z-index: 0;
  pointer-events: none;
}
.s-card > .badge, .s-card > .title, .s-card > .desc, .s-card > .meta {
  position: relative;
  z-index: 1;
}
.s-card > .blu-tack { z-index: -1; }
.s-card:nth-child(1) { transform: rotate(-0.7deg); }
.s-card:nth-child(2) { transform: rotate(0.4deg); }
.s-card:nth-child(3) { transform: rotate(0.5deg); }
.s-card:nth-child(4) { transform: rotate(-0.3deg); }
.s-card:nth-child(5) { transform: rotate(0.6deg); }
.s-card:nth-child(6) { transform: rotate(-0.4deg); }
.s-card:hover {
  transform: rotate(0deg) translateY(-4px);
  box-shadow: 2px 6px 20px rgba(60, 50, 40, 0.22);
  z-index: 10;
}

.s-card .badge {
  display: inline-block;
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--accent);
  margin-bottom: 6px;
}
.s-card .title {
  font-family: var(--serif);
  font-size: 14px; font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.3;
}
.s-card .desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.45;
}
.s-card .meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  font-style: italic;
}

.s-card.urgent::before { background: var(--sticky); }
.s-card.urgent .badge { color: #b45309; }
.s-card.idea::before { background: #fff5f5; }

/* Stagger entry animation for cards */
@keyframes cardStagger {
  from { opacity: 0; transform: translateY(12px) rotate(0deg); }
  to { opacity: 1; }
}
.s-card.entering {
  animation: cardStagger 0.4s var(--spring) both;
}
.s-card.entering:nth-child(1) { animation-delay: 0ms; }
.s-card.entering:nth-child(2) { animation-delay: 100ms; }
.s-card.entering:nth-child(3) { animation-delay: 200ms; }
.s-card.entering:nth-child(4) { animation-delay: 300ms; }
.s-card.entering:nth-child(5) { animation-delay: 400ms; }
.s-card.entering:nth-child(6) { animation-delay: 500ms; }

/* Letter sections — "This month" recap and "Suggested" CTA inside the letter */
.letter-section {
  border-top: 1px dashed rgba(160, 140, 120, 0.3);
  margin-top: 14px;
  padding-top: 12px;
}
.letter-section-label {
  font-family: 'Kalam', cursive;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}
.letter-section-body {
  font-family: 'Kalam', cursive;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
}
.letter-section-body strong { font-weight: 400; color: var(--text-muted); }
.letter-section-body mark.hl { background: var(--hl-green); padding: 0 2px; border-radius: 2px; }

/* Mini polaroid recents on board */
.board-recents {
  margin-top: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  position: relative;
  z-index: 1;
}
.board-resume {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-radius: 8px;
  background: var(--card-bg);
  box-shadow: 0 1px 3px rgba(60, 50, 40, 0.12);
  color: var(--text);
  font-family: var(--sans);
  text-align: left;
  cursor: pointer;
  transition:
    transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.18s ease;
}
.board-resume:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(60, 50, 40, 0.18);
}
.board-resume:disabled {
  cursor: wait;
  opacity: 0.7;
}
.board-recents-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  color: var(--text-muted);
  font-size: 12px;
}
.board-resume-label {
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.board-resume-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
}
.board-resume-meta {
  color: var(--text-muted);
  font-size: 12px;
}
.board-recents-label {
  font-family: 'Kalam', cursive;
  font-size: 14px;
  color: rgba(255,255,255,0.6);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  letter-spacing: 1px;
}
.mini-pol {
  background: #fff;
  padding: 5px;
  box-shadow: 1px 2px 8px rgba(60, 50, 40, 0.15);
  cursor: pointer;
  transition: all 0.25s var(--spring);
  position: relative;
  width: 82px;
  flex-shrink: 0;
}
.mini-pol:nth-child(2) { transform: rotate(-2deg); }
.mini-pol:nth-child(3) { transform: rotate(1.5deg); }
.mini-pol:nth-child(4) { transform: rotate(-0.5deg); }
.mini-pol:hover {
  transform: rotate(0deg) translateY(-4px);
  box-shadow: 2px 4px 16px rgba(60, 50, 40, 0.2);
  z-index: 10;
}
.mini-pol .mp-icon {
  width: 100%; height: 44px;
  background: linear-gradient(135deg, #eae8e5, #dbd9d6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.mini-pol-doc .mp-icon {
  background: linear-gradient(135deg, #fef3e2, #fde8c8);
}
.mini-pol-chat .mp-icon {
  background: linear-gradient(135deg, #e8f0fe, #d4e4fc);
}
.mini-pol .mp-type {
  font-family: var(--sans);
  font-size: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 3px;
}
.mini-pol .mp-label {
  font-family: 'Open Runde', sans-serif;
  font-size: 10px;
  line-height: 1.3;
  color: var(--text-dim);
  margin-top: 4px;
  padding: 0 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* === Skeleton shimmer (loading state) === */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg,
    var(--surface2) 25%, var(--surface3) 50%, var(--surface2) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
  border-radius: 4px;
}
/* Skeleton line — shimmer bar for text placeholders */
.skeleton-line {
  height: 12px; width: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg,
    rgba(200,185,165,0.3) 25%, rgba(220,200,175,0.5) 50%, rgba(200,185,165,0.3) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
}
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }
.skeleton-line.xshort { width: 25%; }

/* Skeleton polaroid — square block inside the real polaroid frame */
.skeleton-polaroid {
  display: block;
  width: 100%; aspect-ratio: 1;
}

/* Skeleton card — ghost card on the board, matches real .s-card sizing */
.skeleton-card { pointer-events: none; padding: 16px 14px 12px; }
.skeleton-card::before {
  background-image: linear-gradient(90deg,
    var(--cream) 20%, rgba(200,185,160,0.5) 50%, var(--cream) 80%
  ) !important;
  background-size: 200% 100% !important;
  background-position: -200% 0;
  animation: shimmer 1.8s ease infinite !important;
}
.skeleton-card .skeleton-line {
  background: linear-gradient(90deg,
    rgba(180,160,130,0.25) 25%, rgba(200,180,150,0.4) 50%, rgba(180,160,130,0.25) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
}

/* Skeleton mini-polaroid */
.skeleton-pol { pointer-events: none; opacity: 0.6; }

/* Skeleton history card */
.skeleton-history-card { pointer-events: none; display: flex; align-items: center; gap: 12px; }

/* Skeleton knowledge page */
.kb-skeleton-wrap { padding: 32px 40px; max-width: 900px; margin: 0 auto; }
.kb-skeleton-section { margin-bottom: 32px; }
.kb-skeleton-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* === Dashboard responsive === */
@media (max-width: 640px) {
  .board-grid { grid-template-columns: 1fr; }
  .board-recents { flex-wrap: wrap; }
  .board-recents-label { writing-mode: horizontal-tb; transform: none; }
}

.msg { display: flex; gap: 12px; animation: fadeIn 0.15s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 32px; height: 32px; border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0; margin-top: 2px;
}

/* User avatar — hidden. The index card IS the user. */
.msg-user .msg-avatar { display: none; }
.msg-user .msg-sender { display: none; }

/* Agent avatar — Polaroid photo: square, white border, slight rotation */
.msg-assistant .msg-avatar {
  background: #fffdf6; border-radius: 2px;
  border: 3px solid white;
  box-shadow: 1px 2px 6px rgba(60, 50, 40, 0.12);
  transform: rotate(-1.5deg);
  color: var(--text-dim); font-family: var(--serif);
}
.msg-assistant .msg-avatar.has-photo {
  background: none; padding: 0; overflow: hidden;
  border: 3px solid white;
}
.msg-assistant .msg-avatar.has-photo img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 2px;
}
.msg-body { flex: 1; min-width: 0; }
/* Agent sender — handwritten label under the Polaroid */
.msg-sender { font-size: 13px; font-weight: 500; margin-bottom: 4px; color: var(--text); }
.msg-assistant .msg-sender {
  font-family: var(--serif); font-style: italic;
  font-size: 12px; color: var(--text-muted);
}
.msg-content { font-size: 15px; line-height: 1.5; color: var(--text); }

/* The founder's own words sit on the right, so who said what is legible without
   reading a word of it. Capped at 72% and sized to content, or a two-word reply
   would stretch a card the full width of the pane and lose that at a glance. */
.msg-user { justify-content: flex-end; }
.msg-user .msg-body { flex: 0 1 auto; max-width: 72%; }

/* User messages — index card, taped at the corner.
   The pink margin rule is gone: the desk is already ruled paper, so the card's
   own margin was a second paper metaphor in the same frame. Lifted further off
   the desk than a resting card — agent card, user card, input pad now read as
   one ladder of heights rather than three unrelated shadows.
   22px on the right, not 18: that is the gutter the corner tape needs, and at
   18px a full first line came within 1.7px of the tape's inner edge. */
.msg-user .msg-content {
  background: #fffdf6;
  border: none;
  border-radius: 6px;
  padding: 14px 22px 14px 18px;
  box-shadow: 3px 5px 16px rgba(60, 50, 40, 0.12), 0 1px 2px rgba(60, 50, 40, 0.06);
  position: relative;
}
/* A torn strip of tape across the top-right corner, replacing a literal 📌
   emoji — which rendered as a different object on every platform and was the
   one mark here not drawn by us.
   The geometry is measured, not eyeballed. With the origin at the card's
   top-right corner and x running negative into the card, a 45° strip occupies
   the band |y − x − d| ≤ h/2·√2, where d is how far from the corner its axis
   crosses each edge. The text box begins 14px down and 22px in, so its corner
   sits at y − x = 36 and staying off it needs d + h/2·√2 ≤ 36. At h=16 and
   d=19 that leaves 5.7px of clearance, both torn tips clear the edges by 3.6px,
   and 79% of the tape lies on the card. It rises 7.7px into .chat-log's 20px
   gap and reaches 8.7px into its 24px padding, so it collides with neither the
   message above nor the scroll container. Changing the size or the padding
   means redoing this — the three numbers are linked. */
.msg-user .msg-content::before {
  content: '';
  position: absolute; top: 2px; right: -8px;
  width: 34px; height: 16px;
  transform: rotate(45deg);
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.20) 0 3px, transparent 3px 7px),
    linear-gradient(180deg, rgba(214, 198, 166, 0.72), rgba(196, 178, 144, 0.72));
  clip-path: polygon(5% 0, 9% 21%, 3% 47%, 8% 73%, 2% 100%, 97% 100%, 92% 75%, 98% 49%, 93% 23%, 96% 0);
  filter: drop-shadow(0 1px 1.5px rgba(60, 50, 40, 0.13));
  z-index: 1;
}

/* Assistant messages — card bubble */
.msg-assistant .msg-content {
  background: #fff;
  border: 1px solid rgba(180, 170, 150, 0.2);
  border-radius: 12px;
  box-shadow: rgba(60, 50, 40, 0.08) 4px 6px 24px,
              rgba(60, 50, 40, 0.04) 0px 1px 3px;
  padding: 18px 22px 18px 18px;
  width: fit-content;
  max-width: 100%;
}
/* When the bubble has a thinking disclosure, promote the white bubble up to
   .msg-body so thinking + text live inside the same bubble. */
.msg-assistant.msg-mind .msg-body {
  background: #fff;
  border: 1px solid rgba(180, 170, 150, 0.2);
  border-radius: 12px;
  box-shadow: rgba(60, 50, 40, 0.08) 4px 6px 24px,
              rgba(60, 50, 40, 0.04) 0px 1px 3px;
  padding: 14px 18px;
  flex: 0 1 auto;
  max-width: 100%;
}
.msg-assistant.msg-mind .msg-content {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  width: auto;
  max-width: 100%;
}
.msg-assistant.msg-mind .msg-sender { margin-bottom: 4px; }

.msg-content p { margin-bottom: 8px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content strong { font-weight: 600; }
.msg-content code {
  background: var(--surface3); padding: 2px 6px; border-radius: 4px;
  font-size: 13px; font-family: var(--mono); color: var(--code-color);
}
.msg-content pre {
  background: var(--surface2); padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow-x: auto; margin: 8px 0; font-size: 12px; font-family: var(--mono); line-height: 1.5;
}

/* Codeblock — proper rendering of triple-backtick fences. Header bar with
   language label + copy button; monospace body. Replaces the bare
   <pre><code> styling above for markdown-rendered output. */
.codeblock {
  position: relative;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 10px 0;
  overflow: hidden;
  font-size: 13px;
}
.codeblock-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 5px;
  cursor: pointer;
  z-index: 1;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease, transform 120ms cubic-bezier(0.215, 0.61, 0.355, 1);
}
.codeblock-copy:hover { background: var(--accent); color: #fff; border-color: var(--accent); transform: translateY(-1px); }
.codeblock-copy:active { transform: translateY(0); }
.codeblock-copy.copied {
  background: var(--green, #10b981);
  color: #fff;
  border-color: var(--green, #10b981);
}
.codeblock pre {
  margin: 0;
  padding: 12px 56px 12px 14px;  /* right padding reserves space for Copy */
  background: transparent;
  border: none;
  border-radius: 0;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
}
.codeblock code { font-family: inherit; background: transparent; padding: 0; }

/* ---- TOOL CARDS (humanized) ---- */
.tool-group { padding-left: 44px; display: flex; flex-direction: column; gap: 4px; }

.tool-card {
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 8px; overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
}

.tool-card:hover { border-color: var(--border-light); }

.tool-card-header {
  padding: 8px 12px; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  list-style: none; user-select: none;
}

.tool-card-header::-webkit-details-marker { display: none; }

.tool-card-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}

.tool-card-icon.file-read { background: rgba(0, 122, 255, 0.1); color: var(--accent); }
.tool-card-icon.file-write { background: var(--green-dim); color: var(--green); }
.tool-card-icon.file-edit { background: var(--amber-dim); color: var(--amber); }
.tool-card-icon.file-search { background: var(--purple-dim); color: var(--purple); }
.tool-card-icon.file-list { background: rgba(34, 211, 238, 0.12); color: var(--cyan); }
.tool-card-icon.web-search { background: rgba(168, 85, 247, 0.12); color: var(--purple); }
.tool-card-icon.web-fetch { background: rgba(59, 130, 246, 0.12); color: var(--accent); }

.tool-card-info { flex: 1; min-width: 0; }

.tool-card-action {
  font-size: 12px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.tool-card-detail {
  font-size: 11px; color: var(--text-dim); margin-top: 1px;
  font-family: var(--mono); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

/* Display-only spend chip on a tool card (e.g. search_x). Admin-mode only via
   the .tool-group gate. */
.tool-card-cost {
  font-size: 11px; color: var(--green); margin-top: 2px;
  font-family: var(--mono); font-weight: 600;
}

.tool-card-status {
  flex-shrink: 0; width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
}

.tool-card-spinner {
  width: 14px; height: 14px; border: 2px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.tool-card-check { color: var(--green); font-size: 14px; font-weight: 700; }
.tool-card-chev { color: var(--text-muted); font-size: 9px; transition: transform 0.15s; }
.tool-card[open] .tool-card-chev { transform: rotate(90deg); }

.tool-card-result {
  padding: 8px 12px; border-top: 1px solid var(--border);
  font-size: 11px; font-family: var(--mono); color: var(--text-dim);
  max-height: 200px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
  background: var(--bg);
}
.tool-card-result.web-search-results {
  font-family: var(--sans); display: flex; flex-direction: column; gap: 6px;
  white-space: normal;
}
.web-search-result {
  display: flex; flex-direction: column; gap: 1px;
}
.web-search-result-title {
  font-size: 11px; font-weight: 500; color: var(--text);
}
.web-search-result-url {
  font-size: 10px; color: var(--text-muted);
}

/* User-facing skill note — quiet paper chip in the message flow, all users */
/* padding-left matches .tool-group (44px) so the pill aligns with the tool cards. */
/* ---- SKILL SHELF — playbooks the agent pulled for this stretch of work ----
   One shelf accumulates sideways instead of one full-width pill stacking per
   skill. The label owns its own row so it can't be stranded mid-line when the
   books wrap. */
.skill-shelf-row { max-width: 768px; width: 100%; margin-inline: auto; padding-left: 44px; box-sizing: border-box; }

.skill-shelf {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  margin: 10px 0;
}

.skill-shelf-lead {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.skill-shelf-lead svg { width: 14px; height: 14px; color: var(--accent); flex: none; }

.skill-shelf-books { display: flex; flex-wrap: wrap; gap: 11px 13px; }

/* A closed booklet seen cover-on. Three cues carry it: a flat spine down the
   left, a page block offset behind the cover (two solid box-shadows, no extra
   elements), and a faint debossed frame inset in the cover.
   Deliberately no :hover lift — nothing here is clickable, and a lift on a
   non-interactive element reads as a broken affordance. */
.skill-book {
  position: relative;
  display: flex;
  align-items: center;
  width: 112px;
  min-height: 62px;
  padding: 10px 11px 10px 17px;
  background: var(--cream);
  border: 1px solid rgba(150, 128, 96, 0.38);
  border-radius: 1px 4px 4px 1px;
  font-family: var(--serif);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.28;
  color: #33291c;
  box-shadow:
    2px 2px 0 -0.5px #f4ecda,
    3.5px 3.5px 0 -0.5px #e9dfc6,
    4px 6px 10px rgba(60, 50, 40, 0.17);
  animation: skillBookIn 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  /* A long unbroken slug shouldn't stretch or overflow the cover */
  overflow: hidden;
  overflow-wrap: anywhere;
}

.skill-book::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 7px;
  border-radius: 1px 0 0 1px;
  background: var(--spine, var(--accent));
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.13);
}

.skill-book::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 5px;
  top: 5px;
  bottom: 5px;
  border: 1px solid rgba(90, 70, 40, 0.07);
  border-radius: 1px;
  pointer-events: none;
}

@keyframes skillBookIn {
  from { opacity: 0; transform: translateY(-7px) rotate(-2.5deg); }
}

@media (prefers-reduced-motion: reduce) {
  .skill-book { animation: none; }
}

/* Skill injection card — super admin visibility */
.skill-card .skill-icon { font-size: 1rem; }
.skill-card-preview { max-height: 200px; overflow-y: auto; font-size: 0.8rem; opacity: 0.8; }
.skill-card-section { padding: 6px 12px 8px; border-top: 1px solid var(--border); }
.skill-card-section-title { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); margin-bottom: 4px; }
.skill-card-ref { font-size: 0.78rem; color: var(--text-dim); font-family: monospace; padding: 1px 0; }

.tool-card.pending .tool-card-icon { animation: pulseGlow 1.5s infinite; }

/* Super-admin subagent trace inspector. Server authorization controls whether
   these events exist; the admin-mode selector is only a visual backstop. */
.subagent-trace-group {
  display: none; width: calc(100% - 44px); margin: 5px 0 8px 44px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  overflow: hidden; flex-shrink: 0;
}
body.admin-mode .subagent-trace-group { display: block; }

/* Founder work slip — one warm desk note per assistant turn. The grouped
   line-items make parallel work legible without exposing the machinery. */
.chat-log > .work-slip {
  position: relative; width: 100%; max-width: 720px; margin: 4px auto 7px;
  padding: 0; border: 1px solid var(--bubble-border); background: var(--cream);
  color: var(--text); box-shadow: var(--shadow-sm);
  clip-path: polygon(0 0, 100% 0, 100% 96%, 96% 98%, 91% 96%, 86% 99%, 80% 96%, 74% 98%, 68% 96%, 61% 99%, 54% 96%, 47% 98%, 40% 96%, 33% 99%, 26% 96%, 19% 98%, 12% 96%, 6% 99%, 0 96%);
  transform-origin: top left;
}
.work-slip[open] { padding-bottom: 10px; }
.work-slip.is-settled { animation: workSlipSettle 360ms var(--spring) both; }
.work-slip.is-replay { animation: none; }
.work-slip-summary {
  display: flex; align-items: center; gap: 11px; min-height: 50px;
  padding: 9px 17px 8px 23px; list-style: none; cursor: pointer;
  color: var(--text);
}
.work-slip-summary::after {
  content: "›"; flex: 0 0 auto; margin-left: auto; color: var(--text-muted);
  font: 600 18px/1 var(--sans); transform: rotate(0); transition: transform 160ms ease-out;
}
.work-slip[open] > .work-slip-summary::after { transform: rotate(90deg); }
.work-slip-summary::-webkit-details-marker { display: none; }
.work-slip-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.work-slip-clip {
  position: absolute; top: 4px; left: 16px; width: 13px; height: 31px;
  border: 2px solid var(--text-dim); border-radius: 9px;
  border-bottom-color: var(--border); transform: rotate(7deg); pointer-events: none;
}
.work-slip-clip::after {
  content: ""; position: absolute; top: 4px; left: 2px; width: 5px; height: 20px;
  border: 2px solid var(--text-muted); border-top: 0; border-radius: 0 0 5px 5px;
}
.work-slip-summary-copy { display: grid; min-width: 0; gap: 1px; padding-left: 10px; }
.work-slip-summary-text { font: 650 14px/1.3 var(--sans); overflow-wrap: anywhere; }
.work-slip-summary-info { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 8px; min-width: 0; }
.work-slip-summary-meta,
.work-slip-summary-elapsed { color: var(--text-muted); font: 600 10.5px/1.3 var(--sans); }
.work-slip-summary-elapsed { white-space: nowrap; font-variant-numeric: tabular-nums; }
.work-slip-summary-meta:not(:empty) + .work-slip-summary-elapsed:not(:empty) {
  padding-left: 8px; border-left: 1px solid var(--border);
}
.work-slip-summary-meta:empty { display: none; }
.work-slip-summary-elapsed:empty { display: none; }
.work-slip-body { padding: 0 14px 7px 16px; }
.work-slip-rows { display: flex; flex-direction: column; gap: 5px; }
.work-slip-row {
  display: grid; grid-template-columns: 19px minmax(0, 1fr); gap: 8px;
  align-items: start; padding: 7px 9px 6px 7px;
  border: 1px solid transparent; border-bottom-color: var(--border); border-radius: 5px;
  animation: workSlipRowIn 220ms ease-out both;
}
.work-slip-row.is-static { animation: none; }
.work-slip.is-replay .work-slip-row { animation: none; }
.work-slip.is-replay .work-slip-row.just-finished .work-slip-check,
.work-slip.is-replay .work-slip-row.is-working .work-slip-check { animation: none; }
.work-slip-row.is-working {
  border-color: var(--accent); background: var(--accent-dim);
}
.work-slip-row.is-done { opacity: 0.72; }
.work-slip-row.is-hiccup { border-color: var(--warn-amber); }
.work-slip-check {
  position: relative; width: 17px; height: 17px; display: grid; place-items: center; margin-top: 1px;
  border: 1.5px solid var(--text-muted); border-radius: 50%;
  color: var(--accent); font: 700 12px/1 var(--sans);
}
.work-slip-row.is-working .work-slip-check {
  width: 10px; height: 10px; margin: 5px 3px; border: 0; border-radius: 50%;
  background: var(--accent); animation: presenceBreathe 3s ease-in-out infinite;
}
.work-slip-row.is-working .work-slip-check::after {
  content: ""; position: absolute; inset: -4px; border: 1px solid var(--accent); border-radius: 50%;
  animation: workSlipPulse 1.8s ease-out infinite;
}
.work-slip-row.is-done .work-slip-check { border-color: var(--accent); background: var(--accent-dim); }
.work-slip-row.just-finished .work-slip-check { animation: workSlipTick 240ms var(--spring) both; }
.work-slip-row.is-hiccup .work-slip-check { border-color: var(--warn-amber); color: var(--warn-amber); }
.work-slip-row-copy { min-width: 0; }
.work-slip-row-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.work-slip-label { min-width: 0; font: 600 12.5px/1.35 var(--sans); overflow-wrap: anywhere; }
.work-slip-row-state {
  flex: 0 0 auto; color: var(--text-muted); font: 600 9.5px/1.3 var(--sans);
  text-transform: uppercase; letter-spacing: 0.055em;
}
.work-slip-row.is-working .work-slip-row-state { color: var(--accent); }
.work-slip-row.is-hiccup .work-slip-row-state { color: var(--warn-amber); }
.work-slip-row-details { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 4px; }
.work-slip-subline { color: var(--text-muted); font: 10.5px/1.3 var(--sans); overflow-wrap: anywhere; }
.work-slip-sources { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.work-slip-sources::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); opacity: 0.7;
}
.work-slip-files { display: flex; flex-wrap: wrap; gap: 3px 10px; min-width: 0; }
.work-slip-file {
  display: inline; max-width: 100%; color: var(--text-muted);
  font: 500 9.75px/1.3 var(--mono); overflow-wrap: anywhere;
}
.work-slip-hiccup { color: var(--warn-amber); }
.work-slip-overflow,
.work-slip-expectation { margin: 7px 3px 0 27px; color: var(--text-muted); font: 11px/1.35 var(--sans); }
.work-slip-overflow:empty { display: none; }
.work-slip-expectation { opacity: 0; transform: translateY(3px); transition: opacity 180ms ease-out, transform 180ms ease-out; }
.work-slip-expectation.is-visible { opacity: 1; transform: translateY(0); }
.work-slip.is-settled .work-slip-expectation,
.work-slip.is-stopped .work-slip-expectation { display: none; }
.work-slip.is-settled .work-slip-summary { min-height: 46px; color: var(--text); }
.work-slip.is-settled .work-slip-summary-text { font-size: 13px; }
.work-slip.is-stopped .work-slip-summary { color: var(--text-muted); }

@keyframes workSlipRowIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes workSlipSettle {
  0% { transform: rotate(0) scale(1); }
  55% { transform: rotate(-0.4deg) scale(0.985); }
  100% { transform: rotate(0) scale(1); }
}
@keyframes workSlipTick {
  0% { transform: scale(0.75); opacity: 0.4; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes workSlipPulse {
  0% { opacity: 0.65; transform: scale(0.75); }
  75%, 100% { opacity: 0; transform: scale(1.55); }
}

@media (max-width: 640px) {
  .chat-log > .work-slip { max-width: none; }
  .work-slip-summary { min-height: 48px; padding: 8px 11px 8px 19px; }
  .work-slip-body { padding: 0 9px 7px 11px; }
  .work-slip-row { padding-right: 7px; }
  .work-slip-row-heading { align-items: flex-start; }
  .work-slip-row-state { padding-top: 2px; }
  .work-slip-clip { left: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .work-slip,
  .work-slip.is-settled,
  .work-slip-row,
  .work-slip-row.just-finished .work-slip-check,
  .work-slip-row.is-working .work-slip-check,
  .work-slip-row.is-working .work-slip-check::after { animation: none; }
  .work-slip-summary::after { transition: none; }
  .work-slip-expectation { transition: opacity 180ms ease-out; transform: none; }
}
.subagent-trace-group > summary {
  min-height: 38px; display: grid; grid-template-columns: 24px auto minmax(100px, 1fr) 12px;
  align-items: center; gap: 8px; padding: 7px 11px; cursor: pointer; list-style: none;
}
.subagent-trace-group > summary::-webkit-details-marker,
.subagent-trace-child > summary::-webkit-details-marker { display: none; }
.subagent-trace-group[open] > summary .tool-card-chev,
.subagent-trace-child[open] > summary .tool-card-chev { transform: rotate(90deg); }
.subagent-trace-icon { display: inline-flex; color: var(--accent); }
.subagent-trace-title { font-size: 12px; font-weight: 600; color: var(--text); }
.subagent-trace-summary { justify-self: end; color: var(--text-muted); font: 10px/1.3 var(--mono); }
.subagent-trace-children { border-top: 1px solid var(--border); }
.subagent-file-coordination {
  border-top: 1px solid var(--border); padding: 10px 14px 12px;
  background: var(--surface2); color: var(--text-dim);
}
.subagent-file-coordination h4 {
  margin-bottom: 7px; color: var(--text); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.subagent-file-coordination-events { display: grid; gap: 6px; }
.subagent-file-coordination-event {
  padding: 7px 9px; border: 1px solid var(--border-light); border-left: 3px solid var(--accent);
  border-radius: 5px; background: var(--surface); font-size: 10px;
}
.subagent-file-coordination-event.is-warning { border-left-color: var(--warn-amber); }
.subagent-file-coordination-event.is-error { border-left-color: var(--red); }
.subagent-file-coordination-event.is-success { border-left-color: var(--green); }
.subagent-file-coordination-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.subagent-file-coordination-heading strong { color: var(--text); font-size: 11px; }
.subagent-file-coordination-heading code { min-width: 0; color: var(--text-dim); overflow-wrap: anywhere; }
.subagent-file-coordination-event p { margin: 3px 0 0; line-height: 1.4; }
.subagent-file-coordination-event .subagent-file-coordination-meta { color: var(--text-muted); font-family: var(--mono); }
.subagent-parent-result {
  border-top: 1px solid var(--border); padding: 11px 14px 14px;
  background: var(--surface2); color: var(--text-dim);
}
.subagent-parent-result.is-error { border-left: 3px solid var(--red); }
.subagent-parent-result h4 {
  margin-bottom: 6px; color: var(--text); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.subagent-parent-result pre {
  max-height: 240px; overflow: auto; padding: 9px; border: 1px solid var(--border-light);
  border-radius: 6px; background: var(--surface); color: var(--text-dim);
  white-space: pre-wrap; overflow-wrap: anywhere; font: 10px/1.5 var(--mono);
}
.subagent-parent-result .subagent-trace-muted { padding: 0; }
.subagent-trace-child { border-bottom: 1px solid var(--border); }
.subagent-trace-child:last-child { border-bottom: 0; }
.subagent-trace-child-summary {
  min-height: 36px; display: grid;
  grid-template-columns: 9px minmax(90px, 1.3fr) minmax(130px, 1.6fr) 62px 58px 70px 72px auto 12px;
  align-items: center; gap: 7px; padding: 7px 11px; cursor: pointer; list-style: none;
  color: var(--text-muted); font: 10px/1.25 var(--mono);
}
.subagent-trace-child-summary strong { color: var(--text); font: 600 11px/1.25 var(--sans); overflow: hidden; text-overflow: ellipsis; }
.subagent-trace-child-summary span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subagent-trace-child-summary em { color: var(--warn-amber); font-style: normal; }
.subagent-trace-status { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.subagent-trace-status.is-running { background: var(--amber); animation: presenceBreathe 3s ease-in-out infinite; }
.subagent-trace-status.is-complete { background: var(--green); }
.subagent-trace-status.is-error { background: var(--red); }
@media (prefers-reduced-motion: reduce) {
  .subagent-trace-status.is-running { animation: none; }
}
.subagent-trace-tabs { display: flex; gap: 2px; padding: 8px 11px 0; border-top: 1px solid var(--border-light); }
.subagent-trace-tabs button {
  border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--text-muted);
  padding: 5px 8px; cursor: pointer; font-size: 10px;
}
.subagent-trace-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.subagent-trace-panel { max-height: 390px; overflow: auto; padding: 10px 14px 14px; font-size: 11px; color: var(--text-dim); }
.subagent-trace-kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 16px; }
.subagent-trace-kv div { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 6px; }
.subagent-trace-kv dt { color: var(--text-muted); }
.subagent-trace-kv dd { min-width: 0; overflow-wrap: anywhere; }
.subagent-trace-kv code { font-size: 10px; }
.subagent-trace-panel section { margin-top: 12px; }
.subagent-trace-panel h4 { margin-bottom: 4px; color: var(--text); font-size: 10px; text-transform: uppercase; }
.subagent-trace-panel pre {
  padding: 8px; border-radius: 6px; background: var(--surface2); color: var(--text-dim);
  white-space: pre-wrap; overflow-wrap: anywhere; font: 10px/1.5 var(--mono);
}
.subagent-trace-muted { color: var(--text-muted); padding: 10px 0; }
.subagent-cache-table-wrap { overflow-x: auto; }
.subagent-cache-table { width: 100%; border-collapse: collapse; font: 10px/1.3 var(--mono); }
.subagent-cache-table th, .subagent-cache-table td { padding: 5px 7px; text-align: right; border-bottom: 1px solid var(--border-light); white-space: nowrap; }
.subagent-cache-table th:first-child, .subagent-cache-table td:first-child,
.subagent-cache-table th:last-child, .subagent-cache-table td:last-child { text-align: left; }
.subagent-trace-fingerprints { margin-top: 10px; }

@media (max-width: 760px) {
  .subagent-trace-group { width: 100%; margin-left: 0; }
  .subagent-trace-child-summary { grid-template-columns: 9px minmax(80px, 1fr) minmax(100px, 1.5fr) 52px 12px; }
  .subagent-trace-child-summary > span:nth-of-type(n+4),
  .subagent-trace-child-summary > em { display: none; }
  .subagent-trace-kv { grid-template-columns: 1fr; }
}

@keyframes pulseGlow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Retrieved chunks panel (admin-only) ── */
.chunks-card { display: none; flex-shrink: 0; }
body.admin-mode .chunks-card { display: block; }

.chunks-card-body { max-height: 400px; }

.chunk-item {
  padding: 4px 0;
  border-bottom: 1px solid var(--border-light);
}
.chunk-item:last-child { border-bottom: none; }

.chunk-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  padding: 2px 0;
}
.chunk-summary::-webkit-details-marker { display: none; }
.chunk-item[open] > .chunk-summary .tool-card-chev { transform: rotate(90deg); }

.chunk-section {
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  background: var(--surface-alt, var(--surface));
  padding: 1px 6px;
  border-radius: 3px;
}

.chunk-match {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chunk-match--hybrid { background: var(--cyan-dim, #e0f7fa); color: var(--cyan, #00838f); }
.chunk-match--semantic { background: var(--purple-dim, #f3e5f5); color: var(--purple, #7b1fa2); }
.chunk-match--keyword { background: var(--orange-dim, #fff3e0); color: var(--orange, #e65100); }
.chunk-match--personal { background: var(--purple-dim, #f3e5f5); color: var(--purple, #7b1fa2); }
.chunk-match--team { background: var(--orange-dim, #fff3e0); color: var(--orange, #e65100); }

.chunk-score {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-left: auto;
}

.chunk-full-content {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 6px 8px 6px 20px;
  background: var(--bg);
  border-radius: 4px;
  margin-top: 4px;
  max-height: 300px;
  overflow-y: auto;
}

.turn-marker {
  font-size: 10px; color: var(--text-muted); padding: 2px 0;
}

.turn-marker summary {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; list-style: none;
}

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

.turn-marker summary::before, .turn-marker summary::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.turn-marker-details { text-align: center; padding-top: 5px; }

.telemetry-chev { display: inline-block; font-size: 8px; transition: transform 0.15s ease; }
details[open] > summary .telemetry-chev { transform: rotate(90deg); }

.turn-pill {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
  letter-spacing: 0.02em;
}
.turn-pill.warn { color: var(--warn-amber); opacity: 1; }
.turn-pill.start {
  font-weight: 500;
  opacity: 0.85;
}

.completion-card {
  color: var(--text-dim); font-size: 11px; margin-bottom: 8px;
  background: var(--green-dim);
  border: 1px solid color-mix(in srgb, var(--green) 32%, var(--border));
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  overflow: hidden; flex-shrink: 0;
}

.completion-summary {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  color: var(--green); font-size: 11px; font-weight: 600;
  cursor: pointer; list-style: none;
}
.completion-summary::-webkit-details-marker { display: none; }
.completion-summary::marker { content: ''; }
.completion-card[open] .completion-summary {
  border-bottom: 1px solid color-mix(in srgb, var(--green) 24%, var(--border-light));
}

.completion-stats {
  display: flex; gap: 20px; flex-wrap: wrap;
  margin: 10px; padding: 12px 14px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--green) 20%, var(--border));
  border-radius: calc(var(--radius-sm) - 2px);
  box-shadow: inset 0 1px 0 var(--border-light);
}
.completion-stats .stat { font-size: 11px; }
.completion-stats .stat .label {
  color: var(--text-dim); display: block; margin-bottom: 2px; font-weight: 600;
}
.completion-stats .stat .value {
  color: var(--text); font-weight: 700; font-size: 15px; font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.error-card {
  background: var(--red-dim); border: 1px solid rgba(255,45,85,0.2);
  border-radius: var(--radius); padding: 10px 14px; font-size: 12px; color: var(--red);
}

.turn-save-notice {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.turn-save-notice strong {
  color: inherit;
  font-weight: 600;
}

/* ---- Developer elements: hidden for normal users, visible in admin mode ---- */
.persona-badge { display: none; }
.topbar .model-badge { display: none; }
.topbar .cost-display { display: none; }
.lock-badge { display: none; }
.turn-marker { display: none; }
.tool-group { display: none; }
.completion-card { display: none; }
body.admin-mode .persona-badge { display: flex; }
body.admin-mode .topbar .model-badge { display: inline-block; }
body.admin-mode .topbar .cost-display { display: inline-block; }
body.admin-mode .lock-badge { display: inline-block; }
body.admin-mode .turn-marker { display: block; }
body.admin-mode .tool-group { display: flex; flex-direction: column; }
body.admin-mode .completion-card { display: block; }

/* ---- MONOLOGUE (unified: thinking + writing narration) ---- */
.msg-monologue {
  animation: monoSlideIn 0.25s ease-out;
  --mono-accent: var(--purple);
}
.msg-monologue.mono-green { --mono-accent: var(--green); }
@keyframes monoSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg-monologue .msg-avatar { display: none; }
.msg-monologue .msg-body { max-width: 85%; }

/* --- Sender label --- */
.msg-monologue .msg-sender {
  color: var(--mono-accent); opacity: 0.55;
  font-size: 10.5px; margin-bottom: 2px;
}
.mono-icon {
  font-size: 13px; margin-right: 3px; opacity: 0.9;
  font-style: normal; display: inline-block;
}
.mono-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px;
  opacity: 0.6; font-weight: 500; font-style: normal;
}

/* --- Streaming — sticky note (active) --- */
.msg-monologue .msg-content {
  font-size: 13px; color: var(--text-dim); line-height: 1.55;
  background: #fff8c5;
  border: none;
  border-radius: 2px;
  padding: 12px 14px; position: relative;
  box-shadow: 2px 3px 8px rgba(60, 50, 40, 0.1);
  transform: rotate(-0.6deg);
  cursor: default;
  transition: background 0.3s, border-color 0.3s, border-radius 0.3s, padding 0.3s,
              opacity 0.3s, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.3s ease;
}
/* Sticky note lifts and straightens on hover — feels alive */
.msg-monologue:not(.finalized) .msg-content:hover {
  transform: rotate(0deg) scale(1.04) translateY(-4px);
  box-shadow: 4px 8px 24px rgba(60, 50, 40, 0.15);
  z-index: 20;
}
.msg-monologue.mono-green .msg-content {
  background: #e8f5e9;
}
.msg-monologue .msg-content p { margin: 0 0 4px 0; }
.msg-monologue .msg-content p:last-child { margin-bottom: 0; }
.msg-monologue .msg-content strong { color: var(--text); font-weight: 600; }
.msg-monologue .msg-content em { font-style: italic; opacity: 0.9; }
.msg-monologue .msg-content code {
  font-size: 11.5px; padding: 1px 5px; border-radius: 4px;
  background: rgba(60, 50, 40, 0.08);
}

/* Icon bob while streaming */
.msg-monologue:not(.finalized) .mono-icon {
  animation: monoBob 2s ease-in-out infinite;
}
@keyframes monoBob {
  0%, 100% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-2px) scale(1.12); }
  60% { transform: translateY(-1px) scale(1.06); }
}

/* Streaming — subtle glow on sticky note */
.msg-monologue .msg-content.streaming {
  box-shadow: 2px 3px 8px rgba(60, 50, 40, 0.1),
              0 0 12px rgba(245, 200, 50, 0.15);
}

/* Blinking cursor that follows the text */
.msg-monologue .msg-content.streaming::after {
  content: '\25CD'; color: var(--mono-accent); opacity: 0.5;
  animation: monoCursor 0.8s ease-in-out infinite;
  font-weight: 300; font-size: 14px; margin-left: 1px;
}
@keyframes monoCursor {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.1; }
}

/* --- Finalized — sticky note folds away --- */
.msg-monologue.finalized .msg-content {
  background: transparent; border-color: transparent;
  border-radius: 0; padding: 0;
  animation: none; box-shadow: none;
  transform: rotate(0deg);
}
.msg-monologue.finalized .msg-content::after { display: none; }

/* --- Collapsed — single inline trace --- */
.msg-monologue.finalized.collapsed { cursor: pointer; }
.msg-monologue.finalized.collapsed .msg-body {
  display: flex; align-items: baseline; gap: 6px;
}
.msg-monologue.finalized.collapsed .msg-sender {
  flex-shrink: 0; margin-bottom: 0;
}
.msg-monologue.finalized.collapsed .msg-content {
  opacity: 0.3; font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-height: 1.6em; flex: 1; min-width: 0;
}
.msg-monologue.finalized.collapsed .msg-content p {
  display: inline; margin: 0;
}
.msg-monologue.finalized.collapsed .msg-content p + p::before {
  content: ' ';
}
.msg-monologue.finalized.collapsed:hover .msg-content { opacity: 0.5; }
.msg-monologue.finalized.collapsed:hover .mono-chevron { opacity: 0.7; }

/* Chevron affordance */
.mono-chevron {
  display: none; font-size: 10px; color: var(--text-dim);
  opacity: 0.5; transition: transform 0.2s, opacity 0.2s;
  flex-shrink: 0; user-select: none;
}
.msg-monologue.finalized.collapsed .mono-chevron { display: inline-block; }

/* --- Expanded — full text, still no bubble --- */
.msg-monologue.finalized.collapsed.expanded .msg-body { display: block; }
.msg-monologue.finalized.collapsed.expanded .msg-content {
  white-space: normal; overflow: visible; max-height: none;
  text-overflow: unset; opacity: 0.4; margin-top: 4px; font-size: 13px;
}
.msg-monologue.finalized.collapsed.expanded .msg-content p {
  display: block; margin: 0 0 4px 0;
}
.msg-monologue.finalized.collapsed.expanded .msg-content p + p::before {
  content: none;
}
.msg-monologue.finalized.collapsed.expanded .mono-chevron {
  transform: rotate(90deg);
}

/* ==================================================================
 * NATIVE THINKING — raw model cognition (tester-mode observability)
 * Distinct from Haiku monologue (which is a yellow sticky note).
 * This is a cooler "lab notebook" card — muted gray, monospace font,
 * collapsible. Meant to feel like a developer trace, not personality.
 * ================================================================== */
.msg-native-thinking {
  animation: monoSlideIn 0.25s ease-out;
  margin: 6px 0;
}
.msg-native-thinking .msg-body {
  max-width: 85%;
  background: rgba(90, 100, 110, 0.06);
  border-left: 2px solid rgba(90, 100, 110, 0.35);
  border-radius: 3px;
  padding: 8px 12px;
  transition: background 0.3s, opacity 0.3s;
}
.msg-native-thinking .native-think-sender {
  display: flex; align-items: center; gap: 6px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.7px;
  color: rgba(90, 100, 110, 0.85);
  margin-bottom: 4px;
}
.native-think-icon { font-size: 12px; filter: grayscale(0.3); }
.native-think-label { font-weight: 500; }

/* Animated dots while streaming */
.native-think-dots {
  display: inline-flex; gap: 3px; margin-left: 4px;
}
.native-think-dots span {
  width: 3px; height: 3px; border-radius: 50%;
  background: rgba(90, 100, 110, 0.5);
  animation: nativeThinkDot 1.2s ease-in-out infinite;
}
.native-think-dots span:nth-child(2) { animation-delay: 0.15s; }
.native-think-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes nativeThinkDot {
  0%, 60%, 100% { opacity: 0.25; transform: scale(1); }
  30% { opacity: 1; transform: scale(1.4); }
}
.msg-native-thinking.finalized .native-think-dots { display: none; }

/* Content — monospace, preserves line breaks */
.native-think-content {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11.5px; line-height: 1.5;
  color: rgba(60, 70, 80, 0.85);
  white-space: pre-wrap; word-break: break-word;
}
.native-think-content.streaming::after {
  content: '▌'; opacity: 0.4; margin-left: 1px;
  animation: monoCursor 0.8s ease-in-out infinite;
}

/* Finalized — fade a touch so it recedes visually */
.msg-native-thinking.finalized .msg-body {
  background: rgba(90, 100, 110, 0.03);
  border-left-color: rgba(90, 100, 110, 0.2);
}

/* Collapsed — single-line preview with chevron */
.msg-native-thinking.finalized.collapsed { cursor: pointer; }
.msg-native-thinking.finalized.collapsed .msg-body {
  display: flex; align-items: baseline; gap: 8px;
  padding: 4px 10px;
}
.msg-native-thinking.finalized.collapsed .native-think-sender {
  margin-bottom: 0; flex-shrink: 0;
}
.msg-native-thinking.finalized.collapsed .native-think-content {
  opacity: 0.4; font-size: 11px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.msg-native-thinking.finalized.collapsed:hover .native-think-content { opacity: 0.7; }
.msg-native-thinking.finalized.collapsed:hover .native-think-chevron { opacity: 0.7; }

.native-think-chevron {
  display: none; font-size: 10px; opacity: 0.4;
  color: rgba(90, 100, 110, 0.7);
  transition: transform 0.2s, opacity 0.2s;
  flex-shrink: 0;
}
.msg-native-thinking.finalized.collapsed .native-think-chevron { display: inline-block; }

/* Expanded — show full text */
.msg-native-thinking.finalized.collapsed.expanded .msg-body {
  display: block; padding: 8px 12px;
}
.msg-native-thinking.finalized.collapsed.expanded .native-think-sender {
  margin-bottom: 4px;
}
.msg-native-thinking.finalized.collapsed.expanded .native-think-content {
  white-space: pre-wrap; overflow: visible;
  text-overflow: unset; opacity: 0.75; font-size: 11.5px;
}
.msg-native-thinking.finalized.collapsed.expanded .native-think-chevron {
  transform: rotate(90deg);
}

/* ---- MIND WRAPPER — consolidated thinking + reasoning per agent turn ----
   Replaces stacking Haiku sticky notes. Native reasoning renders as an entry
   inside instead of a separate chip. Easing + motion tuned per
   docs/solutions/thinking-consolidation-prototype.html (web-animation-design skill):
     - Enter/exit:  ease-out-cubic   (0.215, 0.61, 0.355, 1)
     - Morph:       ease-in-out-cubic (0.645, 0.045, 0.355, 1)
     - Hover:       ease (default)
   Only transform + opacity animate (GPU path). */
/* .msg-mind is a marker class on .msg.msg-assistant — no standalone bubble
   styling. The nested .bubble-thinking below is the collapsible disclosure. */
.bubble-thinking {
  margin-bottom: 0;
  transition: margin-bottom 220ms cubic-bezier(0.645, 0.045, 0.355, 1);
}
.bubble-thinking.expanded { margin-bottom: 8px; }
.bubble-thinking.expanded + .msg-content {
  border-top: 1px dashed var(--border-light);
  padding-top: 8px;
}
@keyframes mindEnter {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.mind-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  cursor: pointer;
  user-select: none;
  border-radius: 4px;
  transition: background 120ms ease;
}
.mind-header:hover { background: rgba(120, 85, 40, 0.04); }
.mind-header .mind-icon { font-size: 14px; }
.mind-header .mind-label {
  font-variant: small-caps;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--accent);
  font-size: 12px;
}
.mind-header .mind-status-text {
  font-weight: 600;
  color: var(--accent);
  font-size: 12px;
  white-space: nowrap;
}
.bubble-thinking:not(.finalized) .mind-status-text {
  animation: mindStatusPulse 1.6s ease-in-out infinite;
  will-change: opacity;
}
.bubble-thinking:not(.finalized) .mind-status-text::after {
  content: "";
  display: inline-block;
  animation: mindStatusDots 1.4s steps(4, end) infinite;
  white-space: pre;
}
@keyframes mindStatusPulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}
@keyframes mindStatusDots {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
  100% { content: ""; }
}
.mind-header .mind-count {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  white-space: nowrap;
  margin-left: auto;
}
.mind-header .mind-count:empty { display: none; }
.mind-header .mind-count:empty + .mind-chev { margin-left: auto; }
.mind-header .mind-chev {
  transition: transform 220ms cubic-bezier(0.215, 0.61, 0.355, 1);
  color: var(--text-muted);
  font-size: 13px;
  display: inline-block;
  will-change: transform;
}
.bubble-thinking.expanded .mind-header .mind-chev { transform: rotate(90deg); }

.mind-timeline-wrap {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 280ms cubic-bezier(0.645, 0.045, 0.355, 1);
}
.bubble-thinking.expanded .mind-timeline-wrap { grid-template-rows: 1fr; }
.mind-timeline {
  overflow: hidden;
  min-height: 0;
  padding: 0 16px;
  border-top: 1px solid transparent;
  opacity: 0;
  transition:
    padding-top 280ms cubic-bezier(0.645, 0.045, 0.355, 1),
    padding-bottom 280ms cubic-bezier(0.645, 0.045, 0.355, 1),
    border-top-color 280ms cubic-bezier(0.645, 0.045, 0.355, 1),
    opacity 200ms cubic-bezier(0.215, 0.61, 0.355, 1) 40ms;
}
.bubble-thinking.expanded .mind-timeline {
  padding: 4px 16px 14px 16px;
  border-top-color: var(--border-light);
  opacity: 1;
}
.mind-entry {
  padding: 10px 0;
  border-bottom: 1px dashed var(--border-light);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  animation: mindEntryIn 220ms cubic-bezier(0.215, 0.61, 0.355, 1) both;
  will-change: transform, opacity;
}
@keyframes mindEntryIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.mind-entry:last-child { border-bottom: none; }
.mind-entry .entry-tag {
  font-size: 10px;
  font-variant: small-caps;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-right: 8px;
  padding: 2px 6px;
  border-radius: 3px;
}
.mind-entry[data-kind="haiku"] .entry-tag  { background: #fff2b8; color: #7a5a1c; }
.mind-entry[data-kind="native"] .entry-tag { background: #efe5f2; color: #5a3e70; }
.mind-entry[data-kind="native"] .entry-text {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: #4a3360;
  white-space: pre-wrap;
}

.mind-dot {
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  animation: mindDotPulse 1.2s ease-in-out infinite;
  transition:
    opacity 240ms cubic-bezier(0.215, 0.61, 0.355, 1),
    transform 240ms cubic-bezier(0.215, 0.61, 0.355, 1);
  will-change: opacity, transform;
}
@keyframes mindDotPulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}
.bubble-thinking.finalized .mind-dot {
  opacity: 0;
  transform: scale(0.5);
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  .msg-mind,
  .mind-entry,
  .mind-dot,
  .mind-header,
  .mind-header .mind-chev,
  .mind-timeline-wrap,
  .mind-timeline {
    animation: none;
    transition: none;
  }
}

/* ---- CHAT MARKDOWN (left pane) ---- */
.msg-content h1, .msg-content h2, .msg-content h3,
.msg-content h4, .msg-content h5, .msg-content h6 {
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 6px;
}
.msg-content h1 { font-size: 22px; margin-top: 22px; }
.msg-content h2 { font-size: 19px; margin-top: 20px; }
.msg-content h3 { font-size: 17px; margin-top: 18px; font-weight: 600; }
.msg-content h4 { font-size: 15px; margin-top: 14px; font-weight: 600; }
.msg-content h5 { font-size: 14px; margin-top: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); }
.msg-content h6 { font-size: 13px; margin-top: 10px; font-weight: 600; color: var(--text-dim); }
/* First heading in a bubble shouldn't push down from the top padding */
.msg-content > h1:first-child,
.msg-content > h2:first-child,
.msg-content > h3:first-child,
.msg-content > h4:first-child,
.msg-content > h5:first-child,
.msg-content > h6:first-child { margin-top: 0; }

.msg-content table { border-collapse: collapse; margin: 8px 0; width: 100%; font-size: 12px; }
.msg-content th, .msg-content td {
  border: 1px solid var(--border); padding: 5px 8px; text-align: left;
}
.msg-content th { background: var(--surface); font-weight: 600; font-size: 11px; }
.msg-content tr:nth-child(even) { background: var(--surface); }

.msg-content ul, .msg-content ol { margin: 8px 0 10px 22px; }
.msg-content li { margin-bottom: 4px; }
.msg-content li > ul, .msg-content li > ol { margin-top: 4px; margin-bottom: 4px; }

.msg-content blockquote {
  border-left: 3px solid var(--accent);
  margin: 12px 0;
  padding: 4px 0 4px 16px;
  background: transparent;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.55;
  font-style: italic;
}
.msg-content blockquote p { margin: 0; }
.msg-content blockquote p + p { margin-top: 8px; }

.msg-content hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

.msg-content a { color: var(--link-color); text-decoration: none; }
.msg-content a:hover { text-decoration: underline; }

.msg-content img { max-width: 100%; border-radius: var(--radius-sm); }

/* Image generating indicator (spinner + text in chat bubble) */
.generating-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-style: italic;
  color: var(--text-muted);
  animation: pulse-gen 2s ease-in-out infinite;
}
@keyframes pulse-gen {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
.generating-spinner {
  animation: spin-gen 1.2s linear infinite;
  stroke: var(--accent);
  flex-shrink: 0;
}
.generating-phase {
  transition: opacity 0.2s ease;
}
.generating-timer {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  opacity: 0.5;
}
@keyframes spin-gen {
  to { transform: rotate(360deg); }
}

/* Download button overlay on generated images */
.generated-image-wrapper {
  position: relative;
  display: inline-block;
}
.generated-image-wrapper .generated-image-download {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #1a1a1a;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  text-decoration: none;
}
.generated-image-wrapper:hover .generated-image-download {
  opacity: 1;
}
.generated-image-wrapper .generated-image-download:hover {
  background: #f0f0f0;
  transform: translateY(-1px) rotate(-3deg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Glowing inline typing cursor while Sarah is talking */
.streaming-cursor {
  display: inline-block;
  width: 3px;
  height: 1.1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  border-radius: 1.5px;
  box-shadow: 0 0 6px rgba(0, 122, 255, 0.5);
  animation: chatCursorPulse 0.8s ease-in-out infinite;
}
@keyframes chatCursorPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ---- TYPING INDICATOR ---- */
.typing-dots span {
  display: inline-block;
  font-size: 24px; line-height: 1;
  color: var(--text-muted);
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ---- DRAFT COLLAPSE (after file is saved) ---- */
.msg-draft-collapsed .msg-content {
  max-height: 120px;
  overflow: hidden;
  opacity: 0.6;
  position: relative;
}
.msg-draft-collapsed .msg-content::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40px;
  background: linear-gradient(transparent, var(--fade-gradient));
  pointer-events: none;
}
.msg-draft-collapsed .draft-toggle {
  display: block;
  padding: 4px 0;
  font-size: 11px;
  color: var(--accent);
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}
.msg-draft-collapsed .draft-toggle:hover { text-decoration: underline; }
.msg-draft-collapsed.expanded .msg-content {
  max-height: none;
  opacity: 0.75;
}
.msg-draft-collapsed.expanded .msg-content::after { display: none; }

/* ---- WRITING NARRATION TICKER (fixed-height, zero bounce) ---- */
.narration-ticker {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.3s ease, opacity 0.3s ease;
  margin: 0;
}
.narration-ticker > .narration-ticker-inner {
  overflow: hidden;
}
.narration-ticker.visible {
  grid-template-rows: 1fr;
  opacity: 1;
}
.narration-ticker-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px;
  font-size: 12.5px;
  color: var(--green);
  opacity: 0.65;
}
.narration-ticker-icon {
  flex-shrink: 0;
  font-size: 13px;
  animation: monoBob 2s ease-in-out infinite;
}
.narration-ticker-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
  opacity: 0.7;
  flex-shrink: 0;
}
.narration-ticker-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-style: italic;
  color: var(--text-dim);
  transition: opacity 0.3s ease;
}
.narration-ticker-text.cross-fade {
  opacity: 0;
}
/* Finalized — collapse to trace */
.narration-ticker.finalized {
  opacity: 0.4;
  cursor: pointer;
  transition: grid-template-rows 0.3s ease, opacity 0.3s ease;
}
.narration-ticker.finalized .narration-ticker-inner {
  max-height: 20px;
  gap: 6px;
}
.narration-ticker.finalized .narration-ticker-icon {
  animation: none;
  font-size: 11px;
}
.narration-ticker.finalized:hover {
  opacity: 0.6;
}
/* Removing — shrink to nothing */
.narration-ticker.removing {
  grid-template-rows: 0fr;
  opacity: 0;
  margin: 0;
}

/* ---- LIVE FILE STREAMING ---- */
.output-source.streaming,
.output-rendered.streaming {
  position: relative;
}

/* Inline streaming cursor — avatar pill that follows the text */
.stream-cursor {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  vertical-align: baseline;
  margin-left: 4px;
  padding: 2px 8px 2px 2px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(99, 102, 241, 0.12));
  border: 1.5px solid rgba(16, 185, 129, 0.35);
  animation: cursorPulse 2s ease-in-out infinite;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  position: relative;
  top: -1px;
}
/* Streaming cursor avatar — Polaroid style */
.stream-cursor-avatar {
  width: 18px; height: 18px; border-radius: 2px;
  overflow: hidden; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid white;
  background: var(--purple);
  color: white; font-size: 10px; font-weight: 700;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}
.stream-cursor-avatar img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 2px;
}
.stream-cursor-label {
  color: var(--green);
  font-weight: 600;
  letter-spacing: 0.02em;
}
@keyframes cursorPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.3); }
  50% { opacity: 0.7; box-shadow: 0 0 8px 2px rgba(16, 185, 129, 0.15); }
}

/* Fade-out when streaming ends */
.stream-cursor.fade-out {
  animation: cursorFadeOut 0.5s ease forwards;
}
@keyframes cursorFadeOut {
  to { opacity: 0; transform: scale(0.8); }
}

/* Glow effect on the output pane while streaming */
.output-content.streaming-active {
  box-shadow: inset 0 0 30px rgba(16, 185, 129, 0.05);
  border-left: 2px solid rgba(16, 185, 129, 0.3);
}

.file-tab.writing {
  color: var(--green) !important;
  position: relative;
}

.file-tab.writing::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--green), var(--accent), var(--green));
  background-size: 200% 100%;
  animation: writeShimmer 1.5s linear infinite;
}

@keyframes writeShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* output-header-status removed — presence indicator replaces it */
.output-header-status-legacy {
  display: none; /* kept as no-op for safety */
  animation: fadeIn 0.3s ease;
}

.output-header-status .status-dot {
  width: 6px; height: 6px; background: var(--green); border-radius: 50%;
  animation: pulse 1s infinite;
}

.output-header-status .status-bar {
  width: 60px; height: 3px; background: var(--border); border-radius: 2px;
  overflow: hidden;
}

.output-header-status .status-bar-fill {
  height: 100%; background: var(--green); border-radius: 2px;
  transition: width 0.3s ease;
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Scrollbar lights up green during streaming */
.output-content.streaming-active::-webkit-scrollbar-thumb {
  background: rgba(16, 185, 129, 0.4);
}

/* Edit highlight — source mode (phase 1: shown for 2s) */
.edit-highlight {
  background: rgba(16, 185, 129, 0.2);
  border-left: 3px solid var(--green);
  margin-left: -3px;
  padding-left: 3px;
  animation: editFlashSource 2s ease-in-out infinite;
}
@keyframes editFlashSource {
  0%, 100% { background: rgba(16, 185, 129, 0.2); }
  50% { background: rgba(16, 185, 129, 0.35); }
}

/* Edit highlight — rendered WYSIWYG view (phase 2: persistent green glow) */
.edit-highlight-rendered {
  background: rgba(16, 185, 129, 0.12);
  border-left: 3px solid var(--green);
  padding: 8px 12px 8px 16px;
  margin: 4px 0 4px -3px;
  border-radius: 4px;
  transition: background 1.8s ease-out, border-color 1.8s ease-out;
  animation: editPulseRendered 2.5s ease-in-out 2;
}
.edit-highlight-rendered > *:first-child { margin-top: 0; }
.edit-highlight-rendered > *:last-child { margin-bottom: 0; }
@keyframes editPulseRendered {
  0%, 100% { background: rgba(16, 185, 129, 0.12); }
  50% { background: rgba(16, 185, 129, 0.25); }
}
.edit-highlight-rendered.fade {
  background: transparent;
  border-left-color: transparent;
}

/* Append highlight — shows newly appended content in preview */
.append-highlight {
  border-left: 3px solid var(--green);
  background: rgba(16, 185, 129, 0.08);
  margin-top: 8px;
  padding-top: 16px;
  transition: background 1.5s ease, border-color 1.5s ease;
}
.append-highlight.fade {
  background: transparent;
  border-left-color: transparent;
}

/* ---- OUTPUT STATUS BAR (footer inside the page) ---- */
.output-status {
  padding: 0 28px;
  border: none;
  border-top: 1px solid rgba(180, 170, 150, 0.1);
  background: transparent;
  flex-shrink: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 11px; color: #b0a694;
  transition: height 0.35s ease, opacity 0.35s ease, padding 0.35s ease;
}
.output-status.visible {
  height: 40px;
  opacity: 1;
}

/* Status bar layout */
.status-left {
  display: flex; align-items: center; gap: 6px;
  font-family: var(--sans);
}
.status-right {
  display: flex; align-items: center; gap: 6px;
  margin-left: auto;
}

/* Footer buttons — physical-object style */
.status-btn {
  font-family: var(--sans); font-size: 11px;
  padding: 5px 14px; border-radius: 8px;
  cursor: pointer; transition: all 0.15s;
  color: #5a5248; background: rgba(180, 170, 150, 0.08);
  border: 1px solid rgba(180, 170, 150, 0.15);
}
.status-btn:hover { background: rgba(180, 170, 150, 0.15); color: var(--text); }
.status-btn-primary {
  color: white; background: #3a3530; border: none;
}
.status-btn-primary:hover { background: #4a4540; }

/* ---- PRESENCE INDICATOR (inside status bar) ---- */
.presence-indicator {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  transition: opacity 0.4s ease;
}
.presence-avatar {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: white;
  overflow: hidden; flex-shrink: 0;
}
/* Polaroid-style for agent presence */
.presence-avatar.agent {
  background: #fffdf6; border-radius: 2px;
  border: 2px solid white;
  box-shadow: 1px 1px 4px rgba(60, 50, 40, 0.1);
  color: var(--text-dim); font-family: var(--serif);
}
.presence-avatar.user { background: var(--accent); }
.presence-avatar img {
  width: 100%; height: 100%; object-fit: cover; border-radius: 2px;
}
.presence-name { color: var(--text-dim); white-space: nowrap; font-size: 12px; }
.presence-action {
  color: var(--green); font-size: 11px;
  animation: presenceBreathe 3s ease-in-out infinite;
}
@keyframes presenceBreathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Editable source view */
.output-source.editable {
  outline: none; cursor: text;
  border: 1px solid transparent;
  transition: border-color 0.2s;
  min-height: 200px;
}
.output-source.editable:focus {
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: inset 0 0 20px rgba(99, 102, 241, 0.03);
}
.output-source.editable::selection {
  background: rgba(99, 102, 241, 0.3);
}

/* WYSIWYG editable area — inherits the serif document style */
.output-rendered.editable {
  outline: none; cursor: text;
  border: 1px solid transparent;
  transition: border-color 0.2s;
  min-height: 200px;
  padding: 24px 32px;
  overflow-y: auto;
  line-height: 1.75;
  color: var(--text);
  font-family: var(--serif);
  font-size: 14.5px;
}
.output-rendered.editable:focus {
  border-color: transparent;
}
.output-rendered.editable::selection {
  background: rgba(139, 111, 71, 0.2);
}
.output-rendered.editable h1 { font-size: 24px; margin: 0 0 16px; padding-bottom: 8px; border-bottom: 1px solid rgba(180, 170, 150, 0.1); }
.output-rendered.editable h2 { font-size: 20px; margin: 24px 0 10px; padding-bottom: 6px; border-bottom: 1px solid rgba(180, 170, 150, 0.08); }
.output-rendered.editable h3 { font-size: 17px; margin: 20px 0 8px; }
.output-rendered.editable p { margin: 0 0 12px; }
.output-rendered.editable blockquote {
  border-left: 3px solid rgba(139, 111, 71, 0.3); padding-left: 12px;
  margin: 12px 0; color: var(--text-dim); background: rgba(250, 248, 241, 0.5);
}
.output-rendered.editable hr {
  border: none; border-top: 1px solid rgba(180, 170, 150, 0.1); margin: 24px 0;
}
.output-rendered.editable ul, .output-rendered.editable ol { padding-left: 24px; margin: 8px 0 12px; }
.output-rendered.editable code { background: var(--surface3); padding: 1px 4px; border-radius: 3px; font-size: 0.9em; }
/* Pre in editable mode — prose, not code (matches non-editable) */
.output-rendered.editable pre {
  background: transparent; border: none; border-radius: 0;
  padding: 0; margin: 0; overflow-x: visible;
  font-family: var(--serif); font-size: 14.5px; line-height: 1.75;
  white-space: pre-wrap; word-wrap: break-word;
}

/* Formatting toolbar — icon buttons */
.toolbar-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  background: transparent; border: 1px solid transparent;
  border-radius: 6px; color: var(--text-dim);
  cursor: pointer; position: relative;
  transition: background 0.12s, color 0.12s;
}
.toolbar-btn:hover { background: var(--surface3); color: var(--text); }
.toolbar-btn:active { transform: scale(0.95); }
.toolbar-btn.active {
  background: rgba(0, 122, 255, 0.1); color: var(--accent);
}
.toolbar-btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.toolbar-divider {
  width: 1px; height: 18px; background: var(--border);
  margin: 0 4px; flex-shrink: 0;
}

/* Toolbar tooltips (CSS-only) */
.toolbar-btn[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute; top: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px; background: var(--text); color: var(--bg);
  font-size: 11px; font-family: inherit; font-weight: 500;
  white-space: nowrap; border-radius: 5px;
  pointer-events: none; opacity: 0; z-index: 100;
  transition: opacity 0.15s ease 0.4s;
}
.toolbar-btn[data-tooltip]:hover::after { opacity: 1; }

/* Link popover */
.link-popover {
  position: absolute; top: calc(100% + 4px); left: 0;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 8px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
  z-index: 200; opacity: 0; pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.link-popover.visible {
  opacity: 1; pointer-events: auto; transform: translateY(0);
}
.link-popover input {
  width: 220px; padding: 5px 8px; font-size: 12px;
  font-family: inherit; border: 1px solid var(--border);
  border-radius: 5px; background: var(--bg); color: var(--text);
  outline: none; transition: border-color 0.15s;
}
.link-popover input:focus { border-color: var(--accent); }
.link-popover input::placeholder { color: var(--text-muted); }
.link-popover-apply {
  padding: 5px 10px; font-size: 12px; font-weight: 500;
  font-family: inherit; background: var(--accent); color: white;
  border: none; border-radius: 5px; cursor: pointer;
  transition: opacity 0.12s;
}
.link-popover-apply:hover { opacity: 0.85; }
.link-popover-remove {
  padding: 5px; background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px; transition: color 0.12s, background 0.12s;
}
.link-popover-remove:hover { color: var(--danger, #ef4444); background: rgba(239, 68, 68, 0.08); }

/* Source toggle button — hidden (developer tool, not for founders) */
.source-btn { display: none !important; }

/* Inline edit toolbar — appears on content focus */
.inline-edit-toolbar {
  display: flex; align-items: center; gap: 2px;
  padding: 4px 10px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  flex-shrink: 0; overflow: visible;
  opacity: 0; max-height: 0;
  transition: opacity 0.2s ease, max-height 0.2s ease;
}
.inline-edit-toolbar.visible {
  opacity: 1; max-height: 44px;
}

/* ---- MAGIC WAND FLOATING BUTTON ---- */
.magic-wand-btn {
  position: absolute; z-index: 300;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.10);
  cursor: pointer;
  opacity: 0; pointer-events: none;
  transform: scale(0.8);
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.12s;
}
.magic-wand-btn.visible {
  opacity: 1; pointer-events: auto; transform: scale(1);
}
.magic-wand-btn:hover {
  background: var(--purple-dim); border-color: var(--purple);
}
.magic-wand-btn:active { transform: scale(0.92); }
.magic-wand-btn svg { width: 16px; height: 16px; color: var(--purple); }
.magic-wand-btn.rewriting { pointer-events: none; opacity: 0.5; }

/* ---- QUEUED PAGE SELECTIONS — the staged work slip ----
   Same paper object as the run slip in the chat log; the paper rule itself is
   scoped to `.chat-log > .work-slip`, so the staged copy re-declares it here.
   Before send it's on your desk, above the composer; after send the same slip
   animates into the conversation. Which side of the desk the paper is on IS
   the state, and no label competes with that. */
.selection-context {
  position: relative; max-width: 768px; width: 100%; margin: 0 auto 8px;
  padding: 0; border: 1px solid var(--bubble-border); background: var(--cream);
  color: var(--text); box-shadow: var(--shadow-sm);
  clip-path: polygon(0 0, 100% 0, 100% 96%, 96% 98%, 91% 96%, 86% 99%, 80% 96%, 74% 98%, 68% 96%, 61% 99%, 54% 96%, 47% 98%, 40% 96%, 33% 99%, 26% 96%, 19% 98%, 12% 96%, 6% 99%, 0 96%);
  transform-origin: top left;
}
.selection-context[hidden] { display: none; }
.selection-context .work-slip-row {
  grid-template-columns: 17px minmax(0, 1fr) 22px;
  padding: 4px 7px 3px;
  animation: none;
}
.selection-context .work-slip-row.is-pulsing {
  border-color: var(--purple); box-shadow: 0 0 0 3px var(--purple-dim);
}
/* The purple thread: outline, widen chevron, in-page marker, and this badge.
   One colour connects a row to its element — which is what makes a separate
   row of chips unnecessary. The slip's paper, text and clip stay warm. */
.selection-context .work-slip-check {
  width: 15px; height: 15px;
  border: 1.5px solid var(--purple); background: var(--purple);
  color: #fff; font: 700 11px/1 var(--sans);
}
.selection-context .work-slip-row.is-working .work-slip-check {
  width: 10px; height: 10px; margin: 5px 3px; border: 0; background: var(--purple);
}
.selection-context .work-slip-row.is-working .work-slip-check::after { border-color: var(--purple); }
.selection-context .work-slip-row.is-working { border-color: var(--purple); background: var(--purple-dim); }
.selection-context .work-slip-row.is-done { opacity: 0.62; }
/* Stale shows in the border and the summary line, never in the number. The
   number is identity — it says which element this row points at, and it has to
   keep matching the marker in the page even when the row has gone stale. */
.selection-context .work-slip-row.is-stale {
  border-color: var(--warn-amber); border-style: dashed;
}
/* One line each, so a row is 37px and six rows are a number we can budget.
   The chat pane is ~408px wide in the split view, where the prototype's 768px
   let long quoted labels sit on one line by luck — here they wrap to two and
   the 388px full stack becomes 500px+. The founder already has the element
   outlined and numbered in the page; the row label is an identifier, not the
   content, so it truncates rather than growing the pile. */
.selection-context .work-slip-label,
.selection-context .work-slip-subline {
  overflow-wrap: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.selection-context .work-slip-label { font: 600 12.5px/1.15 var(--sans); }
.selection-context .work-slip-subline { margin-top: 2px; font: 10.5px/1.15 var(--sans); }
.selection-context .work-slip-overflow { margin: 0 3px 0 27px; }
.selection-context .work-slip-dismiss {
  width: 22px; height: 22px; display: grid; place-items: center; margin-top: -2px;
  padding: 0; border: 0; border-radius: 50%; background: transparent;
  color: var(--text-muted); cursor: pointer; font: 16px/1 var(--sans);
}
.selection-context .work-slip-dismiss:hover { background: var(--accent-dim); color: var(--accent); }
.selection-context .work-slip-dismiss:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* The cap message lives INSIDE the slip, not as a fourth stacked element above
   the composer — the stack is already three siblings deep. */
.selection-context .work-slip-cap {
  margin: 4px 3px 0 27px; color: var(--warn-amber); font: 11px/1.35 var(--mono);
}

/* ---- SELECTION CHIP (above chat input) — warm paper scrap ---- */
.selection-chip {
  display: none; align-items: center; gap: 8px;
  padding: 6px 10px 6px 12px; margin-bottom: 8px;
  background: var(--card-bg);
  border: 1px solid rgba(180, 170, 150, 0.25);
  border-radius: 3px;
  font-size: 12px; color: var(--text-dim);
  box-shadow: var(--shadow-sm);
  animation: chipSlideIn 0.15s ease;
}
.selection-chip.visible { display: flex; }
.selection-chip-icon {
  flex-shrink: 0; width: 14px; height: 14px; opacity: 0.7;
}
.selection-chip-text {
  flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--mono); font-size: 11px;
  max-width: 260px;
}
.selection-chip-dismiss {
  flex-shrink: 0; width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--purple);
  border-radius: 50%; cursor: pointer; font-size: 14px; line-height: 1;
  opacity: 0.5; transition: opacity 0.12s, background 0.12s;
  padding: 0;
}
.selection-chip-dismiss:hover { opacity: 1; background: rgba(124, 58, 237, 0.12); }
@keyframes chipSlideIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes chipDismiss {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.75) translateY(6px); }
}
/* ---- ATTACHMENT CHIPS — Stacked paper cards ---- */

/* ── Container ── */
.attachment-chips:not(:empty) {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-bottom: 6px;
  padding-left: 16px;
  max-width: 768px;
  margin-inline: auto;
  align-items: flex-end;
  padding-bottom: 4px;
}

/* ── Each chip: square paper card ── */
.attachment-chip {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 4px;
  width: 104px;
  height: 112px;
  padding: 10px 10px 10px;
  background: transparent;
  border: none;
  border-radius: 0;
  font-family: var(--sans);
  color: var(--text-dim);
  filter: drop-shadow(0 3px 5px rgba(80, 60, 30, 0.09)) drop-shadow(0 7px 14px rgba(80, 60, 30, 0.06));
  margin-right: -20px;
  transition: transform 0.35s cubic-bezier(.34,1.56,.64,1), filter 0.3s ease;
  cursor: pointer;
  z-index: 1;
  transform-origin: bottom center;
  overflow: visible;
  text-align: left;
  animation: chipSlideIn 0.15s ease;
}
.attachment-chip.chip-dismissing {
  animation: chipDismiss 0.2s ease-out forwards;
  pointer-events: none;
}

/* ── Inner background with clip-path for paper shape ── */
.paper-bg {
  position: absolute;
  inset: 0;
  background: #fffefa;
  border: 1px solid rgba(180, 170, 150, 0.32);
  border-radius: 4px;
  border-top-right-radius: 0;
  clip-path: polygon(0 0, calc(100% - 20px) 0, 100% 20px, 100% 100%, 0 100%);
  box-shadow: none;
  z-index: -1;
  pointer-events: none;
  transition: box-shadow 0.35s ease, background 0.3s ease, border-color 0.3s ease;
}

/* ── Folded corner flap ── */
.paper-fold {
  position: absolute;
  top: 0;
  right: 0;
  width: 22px;
  height: 22px;
  overflow: visible;
  pointer-events: none;
  z-index: 30;
  filter: drop-shadow(-1px 1px 2px rgba(60, 50, 30, 0.18));
}
.paper-fold::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 22px 0 0 22px;
  border-color: transparent transparent transparent #e4dfd6;
  z-index: 31;
}

/* ── Hide the file icon ── */
.attachment-chip-file-icon {
  display: none;
}

/* ── Alternating rotations (natural paper scatter) ── */
.attachment-chip:nth-child(1) { transform: rotate(-3.2deg) translateY(-1px); z-index: 2; }
.attachment-chip:nth-child(2) { transform: rotate(2.5deg) translateY(1px); z-index: 3; }
.attachment-chip:nth-child(3) { transform: rotate(-2deg) translateY(-2px); z-index: 4; }
.attachment-chip:nth-child(4) { transform: rotate(3.8deg) translateY(0px); z-index: 5; }
.attachment-chip:nth-child(5) { transform: rotate(-1.5deg) translateY(-1px); z-index: 6; }
.attachment-chip:last-child { margin-right: 0; }

/* ── Hover: lift & straighten ── */
.attachment-chip:hover {
  transform: rotate(0deg) translateY(-6px) scale(1.03);
  z-index: 20;
}
.attachment-chip:hover .paper-bg {
  box-shadow:
    0 8px 20px rgba(80, 60, 30, 0.14),
    0 3px 6px rgba(80, 60, 30, 0.07);
  border-color: rgba(139, 111, 71, 0.35);
  background: #ffffff;
}

/* ── File name ── */
.attachment-chip-name {
  font-weight: 600;
  color: var(--text, #302e2b);
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 10.5px;
  letter-spacing: -0.01em;
  line-height: 1.3;
  max-width: 88px;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: normal;
  text-align: left;
  word-break: break-word;
  position: relative;
  z-index: 2;
}

/* ── File size ── */
.attachment-chip-size {
  font-size: 9px;
  color: var(--text-muted, #847e78);
  opacity: 0.55;
  white-space: nowrap;
  font-weight: 400;
  line-height: 1;
  position: relative;
  z-index: 2;
  margin-top: auto;
}

/* ── Dismiss button (top-left, hover-reveal) ── */
.attachment-chip-dismiss {
  position: absolute;
  top: -7px;
  left: -7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(180, 170, 150, 0.45);
  background: #fefcf7;
  color: var(--text-muted, #847e78);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.25s cubic-bezier(.34,1.56,.64,1), transform 0.25s cubic-bezier(.34,1.56,.64,1), background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  z-index: 25;
  padding: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.attachment-chip:hover .attachment-chip-dismiss {
  opacity: 1;
  transform: scale(1);
}
.attachment-chip-dismiss:hover {
  background: rgba(255, 45, 85, 0.08);
  border-color: rgba(255, 45, 85, 0.5);
  color: #FF2D55;
}

/* ── Image chip: thumbnail inside the paper card ── */
.attachment-chip.image-chip { padding-left: 10px; height: 136px; }
.attachment-chip-thumb {
  width: 80px;
  height: 44px;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid rgba(180, 170, 150, 0.25);
  position: relative;
  z-index: 2;
}

/* ── Text chip: taller card with preview ── */
.attachment-chip.text-chip {
  width: 160px;
  height: 112px;
  cursor: pointer;
  padding: 10px;
}
.text-chip-body {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  height: 100%;
}
.text-chip-header {
  display: flex;
  align-items: center;
  gap: 4px;
}
.text-chip-header .attachment-chip-icon {
  font-size: 12px;
  flex-shrink: 0;
  display: inline;
  margin-left: 0;
}
.text-chip-header .attachment-chip-size {
  flex: 1;
  font-size: 9px;
  color: var(--text-muted);
  opacity: 0.55;
}
.text-chip-header .attachment-chip-dismiss { display: none; }
.text-chip-preview {
  font-size: 9px;
  line-height: 1.35;
  color: var(--text-dim);
  display: -webkit-box;
  line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  opacity: 0.65;
}

/* ── Misc chip icon (clipboard etc.) ── */
.attachment-chip-icon {
  font-size: 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

/* ── PDF loading state ── */
.file-chip--loading { animation: chip-pulse 1.5s ease-in-out infinite; }
@keyframes chip-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.attachment-chip-loading {
  font-size: 9px;
  color: var(--text-muted);
  font-style: italic;
  position: relative;
  z-index: 2;
}
.attachment-chip-warning {
  font-size: 11px;
  cursor: help;
  position: relative;
  z-index: 2;
}

/* ── Error toast for attachment failures ── */
/* Top-anchored, matching .filed-toast — see the note on .kb-error-toast below. */
.attach-error-toast {
  position: fixed; top: 24px; left: 50%; z-index: 9999;
  transform: translateX(-50%) translateY(-12px);
  background: #c0392b; color: #fff;
  padding: 10px 20px; border-radius: 8px; font-size: 13px;
  opacity: 0; transition: opacity 0.3s, transform 0.3s;
  pointer-events: none; white-space: nowrap;
}
.attach-error-toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Inline error for KB upload/paste forms ── */
.kb-paste-error {
  margin: 8px 0 0; padding: 8px 12px;
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
  border-radius: 6px; font-size: 13px; line-height: 1.4;
}

/* ── Error toast for KB upload failures ── */
/* All four toasts anchor top: .filed-toast always has, and the other three sat at
   the bottom, so the same click could confirm at the top and fail at the bottom.
   They enter downward from -12px — sliding up into a top anchor reads backwards. */
.kb-error-toast {
  position: fixed; top: 24px; left: 50%; z-index: 9999;
  transform: translateX(-50%) translateY(-12px);
  background: #c0392b; color: #fff;
  padding: 10px 20px; border-radius: 8px; font-size: 13px;
  opacity: 0; transition: opacity 0.3s, transform 0.3s;
  pointer-events: none; white-space: nowrap;
}
.kb-error-toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }

.kb-success-toast {
  position: fixed; top: 24px; left: 50%; z-index: 9999;
  transform: translateX(-50%) translateY(-12px);
  background: var(--accent, #8b6f47); color: #fff;
  padding: 10px 20px; border-radius: 8px; font-size: 13px;
  opacity: 0; transition: opacity 0.3s, transform 0.3s;
  pointer-events: none; white-space: nowrap;
}
.kb-success-toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* showToast() names the class it wants and builds `${cls}--visible` from it, so
   a class with no rule here is not a styling slip — it is an invisible toast.
   Eight call sites asked for `toast-error` and none of them ever appeared,
   including the one that says a queued selection was dropped. These two wrap
   rather than `nowrap`: they carry sentences, not single words. */
.toast-error, .toast-warn {
  position: fixed; top: 24px; left: 50%; z-index: 9999;
  transform: translateX(-50%) translateY(-12px);
  color: #fff; max-width: min(520px, calc(100vw - 48px));
  padding: 10px 20px; border-radius: 8px; font-size: 13px; line-height: 1.45;
  opacity: 0; transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}
.toast-error { background: #c0392b; }
.toast-warn { background: var(--warn-amber, #b8531a); }
.toast-error--visible, .toast-warn--visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Preview popover — shows full pasted text */
.text-preview-popover {
  position: absolute; bottom: calc(100% + 6px); left: 0; right: 0;
  min-width: 300px; max-width: 460px;
  background: var(--card-bg); border: 1px solid var(--border-light);
  border-radius: 6px; box-shadow: var(--shadow-lg);
  z-index: 100; animation: chipSlideIn 0.12s ease;
}
.text-preview-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-bottom: 1px solid var(--border-light);
  font-size: 12px; color: var(--text-muted);
}
.text-preview-close {
  border: none; background: transparent; color: var(--text-muted);
  cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px;
}
.text-preview-close:hover { color: var(--text); }
.text-preview-content {
  padding: 10px 12px; margin: 0;
  max-height: 280px; overflow: auto;
  font-size: 12px; line-height: 1.5; color: var(--text);
  font-family: inherit; white-space: pre-wrap; word-break: break-word;
}

/* Image preview popover */
.image-preview-popover {
  position: absolute; bottom: calc(100% + 6px); left: 50%;
  transform: translateX(-50%);
  min-width: 200px; max-width: 400px;
  background: var(--card-bg); border: 1px solid var(--border-light);
  border-radius: 6px; box-shadow: var(--shadow-lg);
  z-index: 100; animation: chipSlideIn 0.12s ease;
}
.image-preview-body {
  padding: 8px;
}
.image-preview-body img {
  display: block; width: 100%; max-height: 300px;
  object-fit: contain; border-radius: 4px;
}

/* Drag-over state for input area */
/* Restates the pad's own four shadows before adding the ring: box-shadow
   replaces rather than augments, so listing only the ring would flatten the pad
   to a plain sheet for as long as a file is held over it. */
.input-area.drag-over .input-wrap {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.85) inset,
    0 2px 0 #f3ecda,
    0 4px 0 #e8dcc1,
    0 8px 18px rgba(60, 50, 40, 0.14),
    0 0 0 2px rgba(0, 122, 255, 0.3);
}

/* Attachment indicators in sent user messages — mini paper cards */
.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-top: 8px;
  align-items: flex-end;
}

/* ── Mini paper card in sent messages ── */
.msg-paper-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  width: 82px;
  height: 88px;
  padding: 8px 8px 8px;
  gap: 3px;
  background: transparent;
  border: none;
  margin-right: -14px;
  filter: drop-shadow(0 2px 4px rgba(80, 60, 30, 0.08)) drop-shadow(0 5px 10px rgba(80, 60, 30, 0.05));
  transition: transform 0.35s cubic-bezier(.34,1.56,.64,1), filter 0.3s ease;
  transform-origin: bottom center;
  overflow: visible;
  cursor: default;
}
.msg-paper-card:last-child { margin-right: 0; }

/* Reuse existing .paper-bg and .paper-fold from input chips */

/* Alternating rotations for sent cards */
.msg-paper-card:nth-child(1) { transform: rotate(-2.5deg) translateY(-1px); z-index: 2; }
.msg-paper-card:nth-child(2) { transform: rotate(2deg) translateY(0px); z-index: 3; }
.msg-paper-card:nth-child(3) { transform: rotate(-1.5deg) translateY(-1px); z-index: 4; }
.msg-paper-card:nth-child(4) { transform: rotate(3deg) translateY(1px); z-index: 5; }
.msg-paper-card:nth-child(5) { transform: rotate(-2deg) translateY(0px); z-index: 6; }

.msg-paper-card:hover {
  transform: rotate(0deg) translateY(-4px) scale(1.04);
  z-index: 20;
}
.msg-paper-card:hover .paper-bg {
  box-shadow:
    0 6px 16px rgba(80, 60, 30, 0.12),
    0 2px 5px rgba(80, 60, 30, 0.06);
  border-color: rgba(139, 111, 71, 0.3);
  background: #ffffff;
}

.msg-paper-name {
  font-weight: 600;
  color: var(--text, #302e2b);
  font-size: 9.5px;
  letter-spacing: -0.01em;
  line-height: 1.25;
  max-width: 68px;
  display: -webkit-box;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-word;
  position: relative;
  z-index: 2;
}

.msg-paper-size {
  font-size: 8px;
  color: var(--text-muted, #847e78);
  opacity: 0.5;
  white-space: nowrap;
  line-height: 1;
  position: relative;
  z-index: 2;
  margin-top: auto;
}

/* ── Image card in sent messages ── */
.msg-paper-card--image { height: 104px; }
.msg-paper-card .msg-attachment-thumb {
  width: 64px;
  height: 36px;
  border-radius: 2px;
  object-fit: cover;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid rgba(180, 170, 150, 0.2);
  position: relative;
  z-index: 2;
}

/* ---- PERSISTENT SELECTION HIGHLIGHT ---- */
.rewrite-selection-highlight {
  background: rgba(124, 58, 237, 0.15);
  border-radius: 2px;
  pointer-events: none;
  z-index: 1;
}

/* ---- REWRITE SHIMMER ---- */
@keyframes rewriteShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.rewrite-shimmer {
  background: linear-gradient(90deg, transparent 0%, var(--purple-dim) 40%, rgba(124, 58, 237, 0.15) 50%, var(--purple-dim) 60%, transparent 100%);
  background-size: 200% 100%;
  animation: rewriteShimmer 1.5s ease-in-out infinite;
  border-radius: 2px;
}

/* ---- REWRITE COST BADGE ---- */
.rewrite-cost-badge {
  position: absolute; z-index: 300;
  font-size: 10px; font-family: var(--mono);
  color: var(--green); background: var(--green-dim);
  padding: 2px 8px; border-radius: 10px;
  opacity: 1; transition: opacity 0.5s ease;
  pointer-events: none;
}
.rewrite-cost-badge.fading { opacity: 0; }

/* Content fade-in animation */
@keyframes contentFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.output-rendered.fade-in { animation: contentFadeIn 0.4s ease both; }

/* ---- STUDY CARD — papers fanning out on the desk ---- */
.study-card {
  /* The 768px column comes from `.chat-log > .study-card` above; this adds the 44px
     avatar gutter so the files row starts level with the playbooks shelf and the chat
     bubbles instead of hanging off to their left. */
  padding-left: 44px;
  box-sizing: border-box;
  margin-bottom: 14px;
  animation: studyCardIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.study-lead {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 9px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.study-lead svg { width: 14px; height: 14px; color: var(--accent); flex: none; }

/* Sheets wrap instead of fanning. The old deck absolutely positioned each paper
   at left: idx * 120 with a 150px width, so 30px always overlapped — and
   z-index: 10 - idx put each new paper BEHIND the last, dropping the previous
   card's edge onto the next card's filename. It also ran off the 768px column
   at the sixth file and could never respond to a narrow pane. */
.study-papers {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 13px;
  margin-left: 4px;
}

/* 116x150 is 0.7733; US Letter is 8.5/11 = 0.7727. Portrait, so it reads as a
   sheet of paper rather than a card. */
.study-paper {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 116px;
  height: 150px;
  padding: 12px 11px 9px;
  background: var(--cream);
  border: 1px solid rgba(150, 128, 96, 0.32);
  border-radius: 2px;
  box-shadow: 1.5px 2.5px 6px rgba(60, 50, 40, 0.14);
  cursor: default;
  animation: paperFan 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* A real tab on the sheet's top edge, not a nub floating on it */
.study-paper-tab {
  position: absolute;
  top: -4px;
  left: 11px;
  width: 26px;
  height: 5px;
  border-radius: 2px 2px 0 0;
  background: var(--tab-color, var(--border));
  transition: background 0.3s;
}

.study-paper.reading { --tab-color: #f5b43c; --study-glow: 245, 180, 60; }
.study-paper.done { --tab-color: #4ade80; }
.study-paper.search-paper { --tab-color: #a78bfa; }
.study-paper.search-paper.reading { --tab-color: #a78bfa; --study-glow: 167, 139, 250; }
.study-paper.search-paper.done { --tab-color: #4ade80; }

/* A light travelling the sheet's edge while it's being read. One conic gradient
   rotated behind the sheet, masked down to a ring: a constant faint glow with a
   brighter comet running round it, so the sheet still reads as active when the
   bright part is on the far side. --study-glow is the tab colour as raw
   channels, so a search in progress sweeps purple instead of amber. */
@property --study-sheen {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

.study-paper.reading::after {
  content: '';
  position: absolute;
  inset: -2px;
  padding: 2px;
  border-radius: 4px;
  pointer-events: none;
  background: conic-gradient(from var(--study-sheen),
    rgba(var(--study-glow), 0.22) 0turn,
    rgba(var(--study-glow), 0.22) 0.52turn,
    rgba(var(--study-glow), 0.55) 0.74turn,
    rgba(var(--study-glow), 1) 0.88turn,
    rgba(255, 255, 255, 0.95) 0.93turn,
    rgba(var(--study-glow), 0.6) 0.97turn,
    rgba(var(--study-glow), 0.22) 1turn);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  animation: studySheen 2.4s linear infinite;
}

@keyframes studySheen { to { --study-sheen: 360deg; } }

/* Without @property the angle can't interpolate — it would snap round at the
   halfway point. Pin the sweep and keep a plain ring instead. */
@supports not (background: conic-gradient(from var(--study-sheen), red, blue)) {
  .study-paper.reading::after { background: rgba(var(--study-glow), 0.5); animation: none; }
}

@media (prefers-reduced-motion: reduce) {
  .study-paper.reading::after { background: rgba(var(--study-glow), 0.5); animation: none; }
}

/* Bundling — sheets gather away before the paperclip snap. The old rule pulled
   the fan back to left: 0 with per-child delays hand-written up to :nth-child(7),
   which silently did nothing from the 8th sheet on. Uniform, so it can't run out. */
.study-card.bundling .study-paper {
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
  transform: scale(0.94);
  opacity: 0;
}

.study-paper-title {
  font-family: var(--serif);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.28;
  color: #33291c;
  /* Three lines then ellipsis. The old rule was nowrap on a card that got
     overlapped, so the filename was the first thing to become unreadable. */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

/* Body text on the page — enough to read as a document, not enough to read */
.study-paper-body {
  position: relative;
  flex: 1;
  margin-top: 8px;
  overflow: hidden;
  background: repeating-linear-gradient(to bottom,
    rgba(90, 70, 40, 0.13) 0 1px, transparent 1px 7px);
}

.study-paper-body::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: 0;
  width: 42%;
  height: 8px;
  background: var(--cream);
}

.study-paper-cat {
  font-size: 9.5px;
  color: #6d5f49;
  margin-top: 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes studyCardIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes paperFan {
  from { opacity: 0; transform: translateY(-12px) rotate(0deg) scale(0.95); }
}

/* ---- RESEARCH BOARD — cork pinboard for web research ----
   Header/meta colours are contrast-checked against the cork base (#c6a67c):
   title 6.9:1, meta + status 5.4:1. The old tan board ran the count at 2.6:1. */
.research-board {
  background-color: #c6a67c;
  background-image:
    radial-gradient(circle at 50% 50%, rgba(112,74,36,0.15) 0 1.3px, transparent 1.9px),
    radial-gradient(circle at 50% 50%, rgba(146,104,58,0.11) 0 2.1px, transparent 2.8px),
    radial-gradient(circle at 50% 50%, rgba(255,238,206,0.15) 0 1px, transparent 1.6px),
    radial-gradient(circle at 50% 50%, rgba(96,62,28,0.07) 0 2.4px, transparent 3.4px);
  background-size: 11px 9px, 29px 23px, 17px 19px, 43px 37px;
  background-position: 0 0, 7px 5px, 3px 9px, 21px 13px;
  border: 1px solid #9e7f56;
  border-radius: 7px;
  box-shadow:
    inset 0 1px 0 rgba(255,240,215,0.35),
    inset 0 -10px 18px -12px rgba(70,44,16,0.5),
    var(--shadow-md);
  padding: 13px 15px 16px;
  margin-bottom: 14px;
  animation: rbAppear 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  position: relative;
}

.rb-header {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.rb-pin-icon { width: 14px; height: 14px; color: #2e2011; flex: none; }

.rb-title {
  font-family: var(--serif);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #2e2011;
  text-shadow: 0 1px 0 rgba(255,240,214,0.28);
  flex: 1;
  min-width: 0;
}

.rb-count {
  font-size: 11px;
  color: #453118;
  flex: none;
}

.rb-toggle {
  font-size: 11px;
  color: #453118;
  transition: transform 0.3s;
  flex: none;
}

.research-board.collapsed .rb-toggle {
  transform: rotate(-90deg);
}

.rb-status {
  font-size: 11.5px;
  color: #453118;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  margin-bottom: 2px;
}

.rb-status::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #3d2b12;
  flex: none;
  animation: rbBlink 1.2s ease-in-out infinite;
}

.research-board.board-done .rb-status::before,
.research-board.board-error .rb-status::before { animation: none; }

@keyframes rbBlink { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }

/* Subtle pulse on border while searching */
.research-board.board-searching {
  animation: rbAppear 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both,
             rbPulse 2s ease-in-out infinite 0.5s;
}

/* Items container — collapsible.
   auto-fill (not a media query) because the agent pane is a resizable split:
   the pane can be narrow on a wide screen, so columns track the board, not the
   viewport. 182px min → 3 cols at full width, 2 in a narrow pane, 1 on mobile.
   (Above ~188px the narrow pane drops to 1 col; below ~176px the full-width
   board packs a 4th column and titles get cramped. Degrades either way, but
   keep it in that band if the board's padding ever changes.) */
.rb-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(182px, 1fr));
  gap: 11px 12px;
  margin-top: 11px;
  max-height: 1400px;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              margin-top 0.3s,
              opacity 0.3s;
}

.research-board.collapsed .rb-items {
  max-height: 0;
  margin-top: 0;
  opacity: 0;
}

.research-board.collapsed .rb-status {
  display: none;
}

/* Individual pin. The wrapper holds the pushpin and does NOT rotate — a real
   pin is fixed to the cork and the paper hangs at an angle under it. */
.rb-pin {
  position: relative;
  display: block;
  min-width: 0;
  padding-top: 5px;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.rb-pin.pinned { opacity: 1; }

.rb-pin-paper {
  display: block;
  background: var(--cream);
  border: 1px solid rgba(140, 115, 80, 0.28);
  border-radius: 2px;
  padding: 12px 11px 9px;
  box-shadow: 1.5px 2.5px 6px rgba(60, 40, 20, 0.22);
  transform: scale(0.9) rotate(var(--pin-rotate, 0deg));
  transform-origin: 50% 0;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.32s ease;
}

.rb-pin.pinned .rb-pin-paper { transform: scale(1) rotate(var(--pin-rotate, 0deg)); }

/* Hover lifts the paper off the board and straightens it (never a colour change) */
a.rb-pin:hover .rb-pin-paper {
  transform: rotate(0deg) translateY(-3px);
  box-shadow: 3px 7px 16px rgba(60, 40, 20, 0.26);
}

a.rb-pin:focus-visible { outline: none; }
a.rb-pin:focus-visible .rb-pin-paper {
  transform: rotate(0deg) translateY(-3px);
  box-shadow: 0 0 0 2px var(--accent), 3px 7px 16px rgba(60, 40, 20, 0.26);
}

/* Red pushpin head — stays upright while the paper rotates beneath it */
.rb-pin-head {
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #ff8f8f 0%, #e05252 42%, #a82f22 100%);
  box-shadow: 0 1.5px 0 rgba(120, 40, 30, 0.45), 0 3px 5px rgba(60, 30, 10, 0.35);
  pointer-events: none;
  z-index: 2;
}

.rb-pin-head::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2.5px;
  width: 4px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
}

/* Blue head = a search result we only listed. Red = a page read in full. */
.rb-pin.skimmed .rb-pin-head {
  background: radial-gradient(circle at 32% 28%, #8fb8ff 0%, #4a7fd0 42%, #2a4f8f 100%);
  box-shadow: 0 1.5px 0 rgba(30, 55, 105, 0.45), 0 3px 5px rgba(60, 30, 10, 0.35);
}

.rb-pin-title {
  font-family: var(--serif);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.32;
  color: #33291c;
  /* Two lines, then ellipsis — the old 40-char JS clamp cut titles at the exact
     point where they start to differ ("Gut Soothe & Glow — …"). */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.rb-pin-source {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: #6d5f49;
  margin-top: 6px;
  min-width: 0;
}

.rb-pin-source .rb-fav {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: #a8906c;
  flex: none;
}

/* Long hostnames (pubmed.ncbi.nlm.nih.gov) must ellipsis, never overflow the card */
.rb-pin-source .rb-dom {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Overflow pins past the first 6 — folded, not thrown away */
.rb-pin.rb-over { display: none; }
.research-board.rb-open .rb-pin.rb-over { display: block; }
.research-board.rb-open .rb-more { display: none; }

.rb-more {
  grid-column: 1 / -1;
  justify-self: start;
  margin-top: 2px;
  font-family: var(--sans);
  font-size: 11.5px;
  color: #3d2b12;
  background: rgba(255, 250, 238, 0.5);
  border: 1px dashed rgba(94, 69, 39, 0.4);
  border-radius: 5px;
  padding: 6px 11px;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rb-more:hover {
  background: rgba(255, 250, 238, 0.85);
  transform: translateY(-1px);
}

/* Board done — settled state */
.research-board.board-done {
  animation: none;
}

/* Board error */
.research-board.board-error {
  animation: none;
  border-color: #e8a0a0;
}

.research-board.board-error .rb-status {
  color: #c0392b;
}

/* Board fading during bundle snap */
.research-board.bundling {
  transition: opacity 0.4s, transform 0.4s;
  opacity: 0;
  transform: scale(0.95);
}

@keyframes rbAppear {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes rbPulse {
  0%, 100% { border-color: #9e7f56; }
  50% { border-color: #bb9a6e; }
}

/* ---- RESEARCH BUNDLE — expandable detail inside paperclip ---- */
.research-bundle .research-bundle-details {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              padding 0.3s;
  padding: 0;
}

.research-bundle.expanded .research-bundle-details {
  max-height: 300px;
  padding-top: 8px;
}

.bundle-detail-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--serif);
  color: var(--text);
  padding: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bundle-detail-line.muted {
  color: var(--text-muted);
  font-size: 10px;
}

.bundle-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.bundle-dot.green { background: #4ade80; }
.bundle-dot.purple { background: #a78bfa; }
.bundle-dot.cyan { background: #38bdf8; }

/* ---- PAPER CLIP BUNDLE — collapsed previous run ---- */
.run-bundle {
  position: relative;
  margin-bottom: 24px;
  cursor: pointer;
  max-width: 340px;
  transform: rotate(-0.7deg);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: bundleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.run-bundle:hover {
  transform: translateY(-3px) rotate(0deg);
}
.run-bundle:hover .run-bundle-body {
  box-shadow: 4px 8px 20px rgba(60, 50, 40, 0.12);
}

.run-bundle-body {
  background: var(--card-bg);
  border: 1px solid rgba(180, 170, 150, 0.2);
  border-radius: 6px;
  padding: 12px 16px 12px 42px;
  position: relative;
  overflow: visible;
  box-shadow: 2px 3px 10px rgba(60, 50, 40, 0.06);
  transition: box-shadow 0.3s ease;
}

/* Stacked papers peeking out behind — offset in different directions like real loose pages */
.run-bundle-body::before {
  content: '';
  position: absolute;
  top: 1px; left: -7px; right: 4px; bottom: -6px;
  background: #fffbf0;
  border: 1px solid rgba(170, 160, 140, 0.22);
  border-radius: 4px;
  z-index: -1;
  transform: rotate(1deg);
}
.run-bundle-body::after {
  content: '';
  position: absolute;
  top: 2px; left: 6px; right: -8px; bottom: -9px;
  background: #fff6e8;
  border: 1px solid rgba(170, 160, 140, 0.18);
  border-radius: 4px;
  z-index: -2;
  transform: rotate(-1.3deg);
}

.run-bundle-clip {
  position: absolute;
  top: -8px; left: 8px;
  width: 28px; height: 52px;
  z-index: 5;
  pointer-events: none;
  filter: drop-shadow(1px 1px 1px rgba(60, 50, 40, 0.1));
}

.run-bundle-title {
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.run-bundle-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.run-bundle-dots {
  display: flex;
  gap: 4px;
}
.run-bundle-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}

/* Expanded state — show original content */
.run-bundle-content {
  display: none;
  padding: 12px 0 0;
}
.run-bundle.expanded .run-bundle-content {
  display: block;
}
.run-bundle.expanded .run-bundle-body::before,
.run-bundle.expanded .run-bundle-body::after {
  display: none;
}

@keyframes bundleIn {
  from { opacity: 0; transform: translateY(-8px) rotate(0deg) scale(0.97); }
  60% { opacity: 1; transform: translateY(1px) rotate(-0.8deg) scale(1.005); }
  to { opacity: 1; transform: translateY(0) rotate(-0.7deg) scale(1); }
}

/* ---- INPUT — index card prompt area ---- */
/* The bottom gap is larger than the top on purpose. The pad's top edge is bare,
   but its bottom throws two hard walls plus a blurred cast shadow — roughly 12px
   of ink below the border, and the send key adds its own on top of that. Matching
   the 28px top numerically still reads tight, because most of that gap would be
   filled with shadow rather than desk. 30px leaves about the same *empty* desk
   below the shadow as there is above the pad. */
.input-area {
  padding: 28px 24px 30px;
  border-top: none;
  background: transparent;
  flex-shrink: 0;
  position: relative;
  z-index: 3;
  container-type: inline-size;
}
/* A pad of paper, not a field. The pink margin rule that used to sit down the
   left edge is gone: the desk underneath is already ruled paper, so the sheet's
   own margin was the second paper metaphor in one frame, and it read as a stray
   mark rather than as a card.
   What separates it from the desk now is depth, not colour. The two hard,
   unblurred offsets are edges rather than shadows — the eye reads them as the
   thickness of a stack — over a blurred cast shadow that ties the pad back down
   to the desk. Same trick the send key uses for its stem, in paper tones. */
.input-wrap {
  position: relative; z-index: 2;
  max-width: 768px; width: 100%; margin-inline: auto;
  display: flex; gap: 10px; align-items: flex-end;
  background: #fffdf6;
  border: 1px solid rgba(180, 170, 150, 0.2);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.85) inset,
    0 2px 0 #f3ecda,
    0 4px 0 #e8dcc1,
    0 8px 18px rgba(60, 50, 40, 0.14);
}

/* Paperclip — attach files to your note. Full row height so the clip centres on
   the line of text rather than hanging 5px below it, which is where flex-end
   left a 36px button on a 46px row. */
.attach-btn {
  width: 36px; height: 46px; border-radius: 6px; border: none;
  background: transparent; color: var(--text-muted);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: color 0.15s, transform 0.15s;
  padding: 0; position: relative;
}
.attach-btn:hover { color: var(--text); transform: translateY(-1px); }
.attach-btn:active { transform: translateY(0); }

/* The glyph rotates 45° into an ×. The button does not change shape, so the
   thing you press to open is the thing you press to close. */
.attach-btn svg { transition: transform 220ms var(--ease); }
.attach-btn[aria-expanded="true"] svg { transform: rotate(45deg); }

/* Floating tooltip — fixed so it escapes overflow:hidden ancestors */
.floating-tooltip {
  position: fixed; z-index: 9999;
  background: #1a1a1a; color: #fff;
  font-size: 12px; line-height: 1; white-space: nowrap;
  padding: 6px 10px; border-radius: 6px;
  pointer-events: none;
  opacity: 0; transform: translateY(4px);
  transition: opacity 0.15s, transform 0.15s;
}
.floating-tooltip.visible { opacity: 1; transform: translateY(0); }

.prompt-input-container {
  flex: 1; position: relative; min-width: 0;
  display: flex; flex-direction: column;
}
/* The field fills the row rather than sitting in it. The row is as tall as its
   tallest child — the 46px send key — and align-items: flex-end then dropped a
   38px field to the bottom, leaving all 8px of the slack above the text: 28px
   of pad over it and 19px under. Matching the key's height moves that slack
   inside the field, where the padding splits it evenly.
   22px line-height rather than 1.4 (21px) so 46 − 22 = 24 divides into two whole
   12s. An odd remainder leaves a 1px lean that is invisible alone and compounds
   with anything else off-centre. flex-end stays: once the field wraps to two
   lines the key should sit at the bottom of it, not float in the middle. */
.input-wrap textarea {
  width: 100%; background: transparent; border: none;
  color: var(--text); font-size: 15px;
  font-family: inherit; padding: 12px 8px; resize: none;
  min-height: 46px; max-height: 120px; line-height: 22px;
  outline: none;
}
.input-wrap textarea:focus { box-shadow: none; }
.input-wrap textarea::placeholder { color: transparent; }

/* Sits exactly where the real first line does — same 12px lift off the bottom
   and same 22px line box as the textarea, or the text jumps as you start typing. */
.prompt-placeholder {
  position: absolute; bottom: 12px; left: 8px; right: 0;
  color: var(--text-muted); font-size: 15px; line-height: 22px;
  font-family: inherit; pointer-events: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.prompt-placeholder.hidden { display: none; }

/* The ghost text fades and drifts 2px rather than sliding — a thought
   changing, not a carousel advancing. */
.prompt-placeholder { transition: opacity 130ms var(--ease), transform 130ms var(--ease); }
.prompt-placeholder.swapping { opacity: 0; transform: translateY(-2px); }
@media (prefers-reduced-motion: reduce) { .prompt-placeholder { transition: none; } }

/* ---- TOOL DISCOVERY — the note ---- */

/* .card-stack animates (translate only). .card-stack-tilt holds the static
   rotate. Keep them as two elements: a rotate inside an animated transform
   re-rasterises every glyph on the card each frame. */
.card-stack { --composer-bottom: 30px; --composer-reserve: 92px; position: absolute; z-index: 1; left: 50%; bottom: var(--composer-bottom); width: min(720px,calc(100vw - 32px)); transform: translate3d(-50%,calc(100% + 72px),0); visibility: hidden; pointer-events: none; transition: transform 180ms var(--ease),visibility 0s linear 180ms; }
.card-stack.animating{will-change:transform}
.card-stack-tilt{position:relative;transform:rotate(-.4deg);opacity:0;transition:opacity 130ms var(--ease)}
.card-stack-tilt::before { content:""; position: absolute; z-index: 0; inset: 2px -2px -2px 2px; background: var(--note-stock-back); border: 1px solid rgba(180,170,150,.24); border-radius: 5px; box-shadow: 0 2px 0 #e7e6df,var(--shadow-sm); transform: rotate(.75deg); }
.card-stack.open { transform: translate3d(-50%,0,0); visibility: visible; pointer-events: auto; transition: transform 290ms var(--spring),visibility 0s; }
.card-stack.open .card-stack-tilt { opacity: 1; transition: opacity 160ms var(--ease); }
.reference-card { position: relative; z-index: 1; padding: 24px 28px var(--composer-reserve); background: var(--note-stock); border: 1px solid rgba(180,170,150,.26); border-radius: 5px; box-shadow: 0 2px 0 #efeee7,var(--shadow-md); }
.card-heading { margin: 0 0 22px; color: var(--text-dim); font: 400 22px/1.3 var(--hand); -webkit-font-smoothing: antialiased; }
/* 1fr 1.16fr 0.98fr is MEASURED. Kalam runs wider than the sans it replaced;
   at even widths "why a page isn't converting" and "my brand, from a URL" both
   wrap. If the copy changes, re-measure — the check is that all 6 titles and
   all 6 explainers each hold a single line. */
.reference-groups { display: grid; grid-template-columns: 1fr 1.16fr 0.98fr; }
.reference-group { min-width: 0; }
.reference-group + .reference-group { padding-left: 20px; border-left: 1px solid var(--border-light); }
.reference-group:not(:last-child) { padding-right: 20px; }
.group-label { display: block; margin-bottom: 9px; color: var(--text-dim); font-size: 9px; font-weight: 600; letter-spacing: .11em; }
.reference-item,.attach-reference { display: grid; grid-template-columns: 16px minmax(0,1fr); align-items: start; gap: 8px; width: 100%; margin: 0; padding: 5px 0; border: 0; background: transparent; cursor: pointer; text-align: left; transition: transform 150ms var(--spring),text-shadow 150ms ease; }
.reference-item + .reference-item,.reference-item + .attach-reference { margin-top: 9px; }
.reference-item svg,.attach-reference svg { width: 16px; height: 16px; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; color: var(--text-muted); }
.reference-copy { min-width: 0; }
/* Kalam for the titles (the colleague speaking), sans for the explainers (the
   founder scanning). Kalam below ~14px turns to mush — titles were raised
   12px → 15px precisely for this. Do not collapse the split. */
.reference-item b { display: block; color: var(--text-dim); font: 500 15px/1.3 var(--hand); -webkit-font-smoothing: antialiased; }
.reference-item small { display: block; margin-top: 1px; color: var(--text-muted); font-size: 9.5px; line-height: 1.45; }
/* Optical, not structural: Kalam sits higher in its box than the sans, so a
   box-aligned icon reads as misaligned. */
.reference-item svg { margin-top: 3px; }
@media (hover:hover) and (pointer:fine) { .reference-item:hover,.attach-reference:hover { transform: translateY(-1px); text-shadow: 0 2px 5px rgba(60,50,40,.12); } }
/* Not italic — Kalam has no true italic and the synthesised slant looks cheap. */
.card-closing { margin: 18px 0 0; color: var(--text-muted); font: 400 14px/1.4 var(--hand); -webkit-font-smoothing: antialiased; }

.card-attach { margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--border-light); }
/* A manila chip — the same stock as the attachment chips the composer shows
   once a file IS attached. The control is made of what it produces, so it
   reads as a different KIND of thing from the handwritten list without
   having to shrink into the background to prove it. */
.attach-reference {
  display: inline-grid; grid-template-columns: 15px auto; align-items: center; gap: 8px;
  width: auto; margin: 0; padding: 7px 12px; cursor: pointer; text-align: left;
  color: var(--manila-text); background: var(--manila-open);
  border: 1px solid var(--manila-edge); border-radius: 4px;
  box-shadow: 1px 2px 0 rgba(60,50,40,.09);
  transform: rotate(-1.1deg);
  transition: transform 160ms var(--spring), box-shadow 160ms var(--ease);
}
.attach-reference svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.attach-reference b { display: block; font-family: var(--sans); font-size: 12px; font-weight: 500; letter-spacing: .01em; color: var(--manila-text); }
/* Picked up off the card: it straightens as it lifts. */
@media (hover:hover) and (pointer:fine) {
  .attach-reference:hover { transform: rotate(-.2deg) translateY(-2px); box-shadow: 1px 4px 8px rgba(60,50,40,.14); }
}
.attach-reference:active { transform: rotate(-1.1deg) translateY(0); box-shadow: 1px 1px 0 rgba(60,50,40,.09); }

@media (max-width:560px) {
  .card-stack { width: calc(100vw - 24px); }
  .reference-card { padding: 18px 18px var(--composer-reserve); }
  .card-heading { margin-bottom: 15px; font-size: 20px; }
  .reference-groups { grid-template-columns: 1fr; gap: 16px; }
  .reference-group:not(:last-child) { padding-right: 0; }
  .reference-group + .reference-group { padding: 16px 0 0; border-left: 0; border-top: 1px solid var(--border-light); }
  .reference-item + .reference-item,.reference-item + .attach-reference { margin-top: 6px; }
  .card-closing { margin-top: 14px; }
}
@media (prefers-reduced-motion:reduce) { .attach-btn,.attach-btn svg,.card-stack,.card-stack.open,.card-stack-tilt,.card-stack.open .card-stack-tilt,.reference-item,.attach-reference{transition:none}*{scroll-behavior:auto} }

/* Production uses a split, user-resizable agent pane. Keep the verbatim port
   above mechanically verifiable, then replace its viewport-centred geometry
   with insets against the composer's containing block. */
.card-stack {
  left: 24px;
  right: 24px;
  width: auto;
  max-width: 720px;
  margin-inline: auto;
  transform: translate3d(0,calc(100% + 72px),0);
}
.card-stack.open { transform: translate3d(0,0,0); }

/* Server-driven groups can disappear. The measured three-column proportions
   remain normative when all three groups survive; smaller sets divide the
   available card width without leaving an empty labelled column. */
.reference-groups[data-column-count="1"] { grid-template-columns: 1fr; }
.reference-groups[data-column-count="2"] { grid-template-columns: repeat(2,minmax(0,1fr)); }
.reference-groups[data-column-count="3"] { grid-template-columns: 1fr 1.16fr 0.98fr; }

/* The pane, not the viewport, determines when the note becomes a single
   column. At the 300px minimum pane width, 12px insets leave the card fully
   inside the agent side of the split. */
@container (max-width:560px) {
  .card-stack { left: 12px; right: 12px; width: auto; }
  .reference-card { padding: 18px 18px var(--composer-reserve); }
  .card-heading { margin-bottom: 15px; font-size: 20px; }
  .reference-groups,
  .reference-groups[data-column-count] { grid-template-columns: 1fr; gap: 16px; }
  .reference-group:not(:last-child) { padding-right: 0; }
  .reference-group + .reference-group { padding: 16px 0 0; border-left: 0; border-top: 1px solid var(--border-light); }
  .reference-item + .reference-item,.reference-item + .attach-reference { margin-top: 6px; }
  .card-closing { margin-top: 14px; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  /* clip is deprecated but still the only thing some older engines honour, so
     it stays under the modern clip-path rather than being replaced by it. */
  clip: rect(0,0,0,0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Send — the Enter key, not a send icon. Carrying the return arrow means the
   button also states the shortcut, which is one less thing to learn.
   Built as two elements, the way a cap is moulded: the button is the skirt,
   ::before is the raised top face, and the skirt left showing between them is
   what you can see of the sides.
   Seen from a low angle, which is why the bottom band is 11px against 3px at
   the top and 5px at the sides: from below the eye clears the near edge of the
   cap and looks straight at its front wall, while the back wall hides behind
   the face entirely. An even ring would be the view from directly overhead —
   flatter, and less like an object you could pick up.
   The front wall is shaded as a wall: the button's gradient holds one tone down
   to where the face ends, then turns and darkens over the last 11px. That turn
   is what stops the band reading as a slice cut across the button, which is
   exactly how it read when the same asymmetry was tried with a flat fill.
   It floats rather than standing on a wall. The near layer is tight and dark
   and the far ones are wide and faint — an object hovering above a surface
   throws a small hard shadow directly under itself and a large soft one around
   it. Three equally-blurred layers just read as haze, which is what the first
   pass at this did. The two outer layers carry negative spread so they pull in
   under the key instead of haloing it. */
.send-btn {
  position: relative;
  width: 72px; height: 46px; border-radius: 8px; padding: 0;
  /* The bottom border is darker than the other three on purpose. It is the one
     edge that sits against its own darkest gradient stop AND against the cast
     shadow, so at a single uniform alpha it dissolved into a soft ramp while
     the top and sides stayed crisp — the button looked like it was melting into
     the pad. This is also just true of a real object: the underside edge is the
     one in shade. */
  border: 1px solid rgba(120, 110, 95, 0.38);
  border-bottom-color: rgba(94, 84, 68, 0.5);
  /* Faceted, not shaded: each side of the skirt is a flat tone with a hard mitre
     between them, the way a chamfer joins. Top faces the light, left catches it,
     right is turned away, and the front wall (drawn by ::after) is darkest
     because it faces the desk.
     A mitre runs from an OUTER corner to the INNER corner beside it. Because the
     frame is 3px at the top, 5px at the sides and 11px at the front, those four
     lines are not concurrent — no single conic can draw all of them, which is
     why a centred 45° conic put its seams through open flat instead of through
     the corners. So the top two mitres come from a conic placed at the one point
     that satisfies both, and the front wall is cut as its own trapezoid.
     Centre: the ray through (0,0) must also pass through (5,3), so it lies on
     y = (3/5)x; at x = w/2 = 36 that is y = 21.6 — 46.96% down. From there the
     outer corners sit at 59.04° and 300.96°. Recompute all of this if the size
     or the insets change. */
  background:
    radial-gradient(14px 11px at 8px 6px, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0) 70%),
    conic-gradient(from 59.04deg at 50% 46.96%,
      #d9d1c4 0deg 120.96deg,
      #e9e3d9 120.96deg 241.93deg,
      #f3efe8 241.93deg 360deg);
  /* so the wall trapezoid takes the cap's rounded corners instead of squaring
     them off; outer box-shadow is unaffected by overflow */
  overflow: hidden;
  color: #37332e;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow:
    0 1px 1px rgba(60, 50, 40, 0.26),
    0 4px 6px -1px rgba(60, 50, 40, 0.18),
    0 10px 16px -4px rgba(60, 50, 40, 0.14),
    0 20px 30px -10px rgba(60, 50, 40, 0.12);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.15s;
}
/* The top face. Its depth is in its own gradients, not in a shadow cast around
   it — a dished cap is darker where the surface curves away at the rim and
   lightest where it faces you in the middle, so a rim vignette says "this is a
   bowl" where a drop shadow only says "this is a sticker sitting on something".
   Three layers: light landing on the crown, the vignette that turns the rim
   down, and the base tone falling off toward the front. The only shadow left is
   the 1px highlight along the very top edge, which is the lit lip. */
.send-btn::before {
  content: '';
  position: absolute; top: 3px; left: 5px; right: 5px; bottom: 11px;
  border-radius: 5px 5px 4px 4px;
  background:
    radial-gradient(150% 120% at 50% -25%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 62%),
    radial-gradient(118% 132% at 50% 44%, rgba(255, 255, 255, 0) 52%, rgba(146, 132, 110, 0.17) 100%),
    linear-gradient(to bottom, #fdfbf7 0%, #f7f3ec 58%, #efe9df 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.95) inset;
  pointer-events: none;
}
/* The front wall. Its top edge is exactly the face's bottom edge (5px in on each
   side, 11px up from the base) and its bottom edge is the full width of the cap,
   so the two diagonals ARE the mitres — they start where the face's corners are
   rather than near them. */
.send-btn::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0; height: 11px;
  background: linear-gradient(to bottom, #c9c0af 0%, #bbb2a0 100%);
  clip-path: polygon(0 100%, 5px 0, calc(100% - 5px) 0, 100% 100%);
  pointer-events: none;
}
/* The face spans 3px to 35px, so its centre is 19px down while the button's is
   23px. 8px of bottom margin lifts the glyph the 4px that closes the gap —
   centred on the face you are looking at, not on the box. */
.send-btn svg { position: relative; z-index: 1; display: block; margin-bottom: 8px; }

/* Rises off the desk rather than changing colour, which is the rule for every
   hover in this product. The face is a separate element, so its own bevel
   shadow rides along untouched — only the cast layers here. */
.send-btn:hover {
  transform: translateY(-1px);
  box-shadow:
    0 1px 1px rgba(60, 50, 40, 0.26),
    0 6px 8px -1px rgba(60, 50, 40, 0.19),
    0 14px 22px -4px rgba(60, 50, 40, 0.15),
    0 28px 40px -10px rgba(60, 50, 40, 0.13);
}
/* Pressed: the cap descends and the shadow tightens under it. Losing the wide
   ambient layer is what sells the drop — a floating object's shadow gets
   smaller and sharper as it approaches the surface, not darker. The underside
   shade deepens because less light reaches under a key that is nearly down. */
.send-btn:active,
.send-btn.is-pressed {
  transform: translateY(2px);
  box-shadow:
    0 1px 1px rgba(60, 50, 40, 0.28),
    0 2px 4px -1px rgba(60, 50, 40, 0.16);
}
/* Pressed, the dish deepens: the rim vignette tightens and darkens and the crown
   light retreats, which is what happens to a curved surface as it tips away from
   the light. The tell is in the gradient, same as at rest. */
.send-btn:active::before,
.send-btn.is-pressed::before {
  background:
    radial-gradient(150% 120% at 50% -25%, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 55%),
    radial-gradient(112% 124% at 50% 46%, rgba(255, 255, 255, 0) 42%, rgba(146, 132, 110, 0.25) 100%),
    linear-gradient(to bottom, #f9f6f1 0%, #f2eee6 58%, #e9e3d8 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
}
/* Signal 1 of the "not sent yet" stack: while page selections are queued the
   key names the pending work. When a founder wonders "what now?", the send
   button is where they look — a neutral arrow there is a tool that took their
   order and went quiet. The cap widens the way a real Enter key does; the whole
   keycap construction below (crown, face, bevel) is preserved in purple. */
.send-btn.has-selections {
  width: auto; min-width: 72px; padding: 0 15px;
  border-color: rgba(76, 29, 149, 0.55);
  border-bottom-color: rgba(59, 20, 120, 0.62);
  background:
    radial-gradient(14px 11px at 8px 6px, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 70%),
    conic-gradient(from 59.04deg at 50% 46.96%,
      #6b31d0 0deg 120.96deg,
      #7c3aed 120.96deg 241.93deg,
      #8f57f2 241.93deg 360deg);
  color: #fff;
}
.send-btn.has-selections::before {
  background:
    radial-gradient(150% 120% at 50% -25%, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 62%),
    radial-gradient(118% 132% at 50% 44%, rgba(255, 255, 255, 0) 52%, rgba(46, 16, 101, 0.22) 100%),
    linear-gradient(to bottom, #9366f7 0%, #7c3aed 58%, #6b2fd6 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.34) inset;
}
.send-btn.has-selections::after { background: linear-gradient(to bottom, #5b21b6 0%, #4c1d95 100%); }
.send-btn.has-selections:active::before,
.send-btn.has-selections.is-pressed::before {
  background:
    radial-gradient(150% 120% at 50% -25%, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0) 55%),
    radial-gradient(112% 124% at 50% 46%, rgba(255, 255, 255, 0) 42%, rgba(46, 16, 101, 0.3) 100%),
    linear-gradient(to bottom, #8a5cf0 0%, #7434e3 58%, #6127c8 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.28) inset;
}
.send-btn.has-selections svg { display: none; }
.send-btn-count {
  position: relative; z-index: 1; margin-bottom: 8px;
  font: 650 12.5px/1 var(--sans); white-space: nowrap; letter-spacing: 0.005em;
}
/* One bump when the pile grows — a single physical acknowledgment, never a
   loop. A pulsing send button reads as "working", which is the opposite of
   what this state means. */
.send-btn.is-bumped { animation: send-count-bump 320ms var(--spring); }
@keyframes send-count-bump {
  0% { transform: scale(1); }
  45% { transform: scale(1.07); }
  100% { transform: scale(1); }
}

/* Resting on the pad: nothing to travel, so nothing to float on. */
.send-btn:disabled {
  opacity: 0.35; cursor: not-allowed; transform: none;
  box-shadow: 0 1px 2px rgba(60, 50, 40, 0.10);
}
/* Pressing Enter sends, but :active only fires for the mouse — the key would
   stay still for the one input most people actually use. app.js stamps
   .is-pressed for the length of this transition so the cap answers the
   keyboard the same way it answers a click. */
@media (prefers-reduced-motion: reduce) {
  .send-btn, .stop-btn { transition: opacity 0.15s; }
  .send-btn:hover, .send-btn:active, .send-btn.is-pressed,
  .stop-btn:hover, .stop-btn:active { transform: none; }
}

/* ---- STOP BUTTON ---- */
/* The same cap, in red. It stands in for send the moment a run starts, so it
   takes send's exact box — 58x46, same radius, same face insets, same low angle
   — and only the colour ramp changes. A circle made the one control that appears
   mid-run the one control shaped unlike anything else on the pad, and it changed
   the field's width every time the agent began working.
   Red rather than another warm brown because stopping is the only destructive
   thing this pad can do; it should not read as send wearing a different hat. */
.stop-btn {
  position: relative;
  width: 72px; height: 46px; border-radius: 8px; padding: 0;
  border: 1px solid rgba(150, 14, 45, 0.42);
  border-bottom-color: rgba(112, 6, 32, 0.58);
  /* Same mitre geometry as send — same box, same insets, so the same angles.
     Built on --red (#FF2D55), the pink-red this product already uses for
     destructive actions, rather than a second red invented for one button. */
  background:
    radial-gradient(14px 11px at 8px 6px, rgba(255, 255, 255, 0.40), rgba(255, 255, 255, 0) 70%),
    conic-gradient(from 59.04deg at 50% 46.96%,
      #e02950 0deg 120.96deg,
      #fa4467 120.96deg 241.93deg,
      #ff6b85 241.93deg 360deg);
  overflow: hidden;
  color: #fff;
  cursor: pointer; display: none; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow:
    0 1px 1px rgba(120, 10, 36, 0.30),
    0 4px 6px -1px rgba(120, 10, 36, 0.22),
    0 10px 16px -4px rgba(120, 10, 36, 0.17),
    0 20px 30px -10px rgba(120, 10, 36, 0.13);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.15s;
  animation: fadeIn 0.2s ease;
}
/* Same dish as send's face, in red: crown light, rim vignette, base fall-off.
   The highlights are much weaker than the white cap's — on a saturated colour a
   0.95 white wash desaturates the face to pink froth, which is exactly what the
   first pass at this looked like. */
.stop-btn::before {
  content: '';
  position: absolute; top: 3px; left: 5px; right: 5px; bottom: 11px;
  border-radius: 5px 5px 4px 4px;
  background:
    radial-gradient(150% 120% at 50% -25%, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0) 62%),
    radial-gradient(118% 132% at 50% 44%, rgba(255, 255, 255, 0) 52%, rgba(122, 6, 32, 0.26) 100%),
    linear-gradient(to bottom, #ff5273 0%, #ff2d55 58%, #ee1f46 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset;
  pointer-events: none;
}
.stop-btn::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: 0; height: 11px;
  background: linear-gradient(to bottom, #c4173c 0%, #a80f31 100%);
  clip-path: polygon(0 100%, 5px 0, calc(100% - 5px) 0, 100% 100%);
  pointer-events: none;
}
.stop-btn svg { position: relative; z-index: 1; display: block; margin-bottom: 8px; }
.stop-btn:hover {
  transform: translateY(-1px);
  box-shadow:
    0 1px 1px rgba(120, 10, 36, 0.30),
    0 6px 8px -1px rgba(120, 10, 36, 0.23),
    0 14px 22px -4px rgba(120, 10, 36, 0.18),
    0 28px 40px -10px rgba(120, 10, 36, 0.14);
}
.stop-btn:active {
  transform: translateY(2px);
  box-shadow:
    0 1px 1px rgba(120, 10, 36, 0.32),
    0 2px 4px -1px rgba(120, 10, 36, 0.20);
}
.stop-btn:active::before {
  background:
    radial-gradient(150% 120% at 50% -25%, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 55%),
    radial-gradient(112% 124% at 50% 46%, rgba(255, 255, 255, 0) 42%, rgba(122, 6, 32, 0.34) 100%),
    linear-gradient(to bottom, #f74a6c 0%, #f0264e 58%, #df1a40 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.26) inset;
}
.stop-btn.visible { display: flex; }

/* ---- OUTPUT CONTENT — scrolls inside the artifact page ---- */
.output-content {
  flex: 1; overflow: auto; position: relative;
  background: transparent;
}

/* Dog-ear fold — sits on the output pane, not the scrollable content */

/* Page-settle animation when content first appears */
@keyframes pageSettle {
  0% { opacity: 0; transform: translateY(-8px) scale(1.01); box-shadow: 0 16px 50px rgba(60,50,40,0.18); }
  60% { opacity: 1; transform: translateY(1px) scale(0.998); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.output-content.page-settle { animation: pageSettle 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

.output-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; text-align: center; padding: 32px; gap: 8px;
}

.output-empty-icon {
  font-size: 32px;
  opacity: 0.4;
  animation: emptyPulse 4s ease-in-out infinite;
}

@keyframes emptyPulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.1); }
}

.output-empty p {
  max-width: 280px; line-height: 1.5;
  color: var(--text-dim); font-size: 15px; font-weight: 500;
  margin: 0;
}

.output-empty .output-empty-hint {
  font-size: 13px; font-weight: 400;
  color: var(--text-muted); margin-top: 2px;
}

/* ---- AMBIENT GLOW (agent working) ---- */
.pane-output.pane-glow::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  box-shadow:
    inset 0 0 60px rgba(16, 185, 129, 0.07),
    inset 0 0 120px rgba(16, 185, 129, 0.03);
  animation: ambientGlow 3s ease-in-out infinite;
  opacity: 1;
  transition: opacity 0.8s ease;
}
.pane-output.pane-glow-out::before {
  opacity: 0;
}
@keyframes ambientGlow {
  0%, 100% {
    box-shadow:
      inset 0 0 60px rgba(16, 185, 129, 0.07),
      inset 0 0 120px rgba(16, 185, 129, 0.03);
  }
  50% {
    box-shadow:
      inset 0 0 80px rgba(16, 185, 129, 0.12),
      inset 0 0 150px rgba(16, 185, 129, 0.05);
  }
}

/* Document dimming while agent prepares */
.output-content.output-dimmed {
  opacity: 0.4;
  transition: opacity 0.4s ease;
}

.output-source {
  padding: 16px; font-size: 12px; font-family: var(--mono);
  line-height: 1.6; white-space: pre-wrap; word-break: break-word; color: var(--text);
}

.output-preview { width: 100%; height: 100%; border: none; background: var(--preview-bg); }

/* ---- RENDERED MARKDOWN — serif document on white page ---- */
.output-rendered {
  padding: 24px 32px; font-size: 16px; line-height: 1.7;
  font-family: var(--serif); color: var(--text);
  max-width: 800px; overflow-wrap: break-word;
}

.output-rendered h1 { font-size: 30px; font-weight: 700; line-height: 1.2; margin: 0 0 18px; padding-bottom: 10px; border-bottom: 1px solid rgba(180, 170, 150, 0.15); }
.output-rendered h2 { font-size: 23px; font-weight: 700; line-height: 1.25; margin: 28px 0 10px; padding-bottom: 6px; border-bottom: 1px solid rgba(180, 170, 150, 0.1); }
.output-rendered h3 { font-size: 19px; font-weight: 600; line-height: 1.3; margin: 24px 0 8px; }
.output-rendered h4 { font-size: 16px; font-weight: 600; line-height: 1.4; margin: 20px 0 6px; }
.output-rendered h5 { font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; margin: 18px 0 4px; color: var(--text-dim); }
.output-rendered h6 { font-size: 14px; font-weight: 600; margin: 16px 0 4px; color: var(--text-dim); }

.output-rendered p { margin: 0 0 12px; }
.output-rendered p:last-child { margin-bottom: 0; }

.output-rendered strong { font-weight: 600; }
.output-rendered em { font-style: italic; }

.output-rendered code {
  background: var(--surface3); padding: 2px 6px; border-radius: 4px;
  font-size: 14.5px; font-family: var(--mono); color: var(--code-color);
}

/* Pre blocks — agent wraps content in code fences, so markdown renders as <pre><code>.
   In a content creation tool, this should look like a DOCUMENT, not source code. */
.output-rendered pre {
  background: transparent; border: none; border-radius: 0;
  padding: 0; margin: 0; overflow-x: visible;
  font-family: var(--serif); font-size: 16px; line-height: 1.7;
  white-space: pre-wrap; word-wrap: break-word;
}

.output-rendered pre code {
  background: none; padding: 0; border-radius: 0; color: var(--text);
  font-family: inherit; font-size: inherit; line-height: inherit;
}

.output-rendered ul, .output-rendered ol { margin: 12px 0 16px 28px; }
.output-rendered li { margin-bottom: 6px; }
.output-rendered li > ul, .output-rendered li > ol { margin-top: 6px; margin-bottom: 6px; }

.output-rendered blockquote {
  border-left: 3px solid var(--accent);
  margin: 16px 0; padding: 4px 0 4px 18px;
  background: transparent; color: var(--text-dim);
  font-size: 16px; line-height: 1.6; font-style: italic;
}

.output-rendered blockquote p { margin-bottom: 8px; }
.output-rendered blockquote p:last-child { margin-bottom: 0; }

.output-rendered hr {
  border: none; border-top: 1px solid rgba(180, 170, 150, 0.1); margin: 24px 0;
}

.output-rendered a { color: var(--link-color); text-decoration: none; }
.output-rendered a:hover { text-decoration: underline; }

.output-rendered table { border-collapse: collapse; margin: 16px 0; width: 100%; font-size: 15px; }
.output-rendered th, .output-rendered td {
  border: 1px solid var(--border); padding: 10px 14px; text-align: left;
}
.output-rendered th { background: rgba(250, 248, 241, 0.5); font-weight: 600; }
.output-rendered tr:nth-child(even) { background: rgba(250, 248, 241, 0.3); }

.output-rendered img { max-width: 100%; border-radius: var(--radius-sm); }

/* Manila folder tab bar — transparent, tabs float above the page */
.file-tabs-wrapper {
  display: flex; align-items: stretch; flex-shrink: 0;
  background: transparent; border-bottom: none;
  position: relative; padding: 0 0 0 8px;
  gap: 2px; z-index: 2;
}

.file-tabs-arrow {
  display: none; align-items: center; justify-content: center;
  width: 24px; flex-shrink: 0; background: transparent;
  border: none; color: var(--text-dim); cursor: pointer;
  font-size: 13px; padding: 0; z-index: 2;
  transition: color 0.1s, background 0.1s;
}
.file-tabs-arrow:hover { color: var(--text); }
.file-tabs-arrow.visible { display: flex; }

.file-tabs {
  display: flex; gap: 2px; overflow-x: auto; flex: 1; min-width: 0;
  scroll-behavior: smooth;
}

.file-tabs::-webkit-scrollbar { height: 0; }

/* Manila folder tabs — rounded tops, seamless with page */
.file-tab {
  padding: 7px 16px 6px; font-size: 12px; font-family: var(--sans);
  font-weight: 400;
  border: 1px solid rgba(180, 170, 150, 0.2);
  border-bottom: none; border-radius: 10px 10px 0 0;
  color: #8a7e70; cursor: pointer; white-space: nowrap;
  transition: transform 0.2s ease, background 0.2s ease, color 0.15s;
  max-width: 200px; position: relative; top: 1px;
  background: rgba(250, 248, 241, 0.7);
}

.file-tab { display: flex; align-items: center; gap: 6px; }
.file-tab span:first-child { overflow: hidden; text-overflow: ellipsis; }
/* Reaching for a folder — lift on hover */
.file-tab:not(.active):hover {
  color: #5a5248; background: rgba(255, 254, 250, 0.85);
  transform: translateY(-2px);
}
/* Active tab — pulled forward, seamless with page background */
.file-tab.active {
  color: #3a3530; background: #ffffff; font-weight: 500;
  border-bottom: 1px solid #ffffff;
  box-shadow: 0 -2px 8px rgba(60, 50, 40, 0.04);
  z-index: 3;
}

/* Hide tab delete × for cleaner look — visible on hover for multi-file */
.file-tab-delete {
  opacity: 0; font-size: 14px; line-height: 1; color: var(--text-dim);
  cursor: pointer; padding: 0 2px; border-radius: 3px; transition: opacity 0.15s, color 0.15s;
}
.file-tab:hover .file-tab-delete { opacity: 0.6; }
.file-tab-delete:hover { opacity: 1 !important; color: var(--red); }

.close-btn {
  width: 26px; height: 26px; border-radius: var(--radius-sm);
  border: none; background: var(--surface2); color: var(--text-dim);
  cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center;
}

.close-btn:hover { background: var(--border); color: var(--text); }

/* ---- HISTORY DRAWER ---- */
.history-drawer {
  position: fixed; top: 36px; left: 0; bottom: 0; width: 320px;
  background: var(--surface); border-right: 1px solid var(--border);
  z-index: 50; transform: translateX(-100%); transition: transform 0.25s ease;
  display: flex; flex-direction: column;
}

.history-drawer.open { transform: translateX(0); }

.history-drawer .drawer-header {
  padding: 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.history-drawer .drawer-header h3 { font-size: 14px; font-weight: 600; }

.history-drawer .drawer-body { flex: 1; overflow-y: auto; padding: 8px; }

.history-item {
  padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer;
  transition: background 0.1s; margin-bottom: 2px;
}

.history-item:hover { background: var(--surface2); }

.history-item .hi-prompt {
  font-size: 13px; color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px;
}

.history-item .hi-meta {
  display: flex; gap: 12px; font-size: 11px; color: var(--text-muted); font-family: var(--mono);
}

.history-item .hi-meta .hi-cost { color: var(--green); }

.history-actions {
  padding: 12px; border-top: 1px solid var(--border);
  display: flex; gap: 8px;
}

.history-actions button {
  flex: 1; padding: 8px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface2); color: var(--text-dim); font-size: 12px;
  cursor: pointer; transition: all 0.15s;
}

.history-actions button:hover { background: var(--surface3); color: var(--text); }
.history-actions button.danger { border-color: rgba(255,45,85,0.3); color: var(--red); }
.history-actions button.danger:hover { background: var(--red-dim); }

/* ---- NEW RUN BTN ---- */
.new-run-btn {
  padding: 6px 12px; background: var(--green-dim); border: 1px solid rgba(16,185,129,0.3);
  border-radius: var(--radius-sm); color: var(--green); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.15s; display: flex; align-items: center; gap: 5px;
}

.new-run-btn:hover { background: rgba(16,185,129,0.25); border-color: rgba(16,185,129,0.5); }

/* No-select during drag */
body.resizing { cursor: col-resize !important; user-select: none !important; }
body.resizing * { cursor: col-resize !important; user-select: none !important; }
body.resizing iframe { pointer-events: none; }

/* ============================================================
   AUTH OVERLAY — Login screen
   ============================================================ */

/* ---- Auth: Split-panel login (mirrors Companio layout) ---- */

.auth-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: row;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
  background: var(--card-bg);
  padding: 24px;
  gap: 0;
}
.auth-overlay.visible { opacity: 1; pointer-events: auto; }

/* Left: Brand panel + form */
.auth-brand {
  width: 380px; min-width: 320px; max-width: 420px;
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 24px 32px 32px;
  margin-right: 120px;
}

.auth-brand-content {
  display: flex; flex-direction: column; gap: 0;
}

.auth-brand-logo {
  width: 48px; height: 48px;
  margin-bottom: 0;
}

.auth-brand-text {
  margin-top: 48px;
}

.auth-brand-text h1 {
  font-size: 20px; font-weight: 500; line-height: 1.4;
  color: var(--text); margin: 0 0 8px;
  font-family: var(--serif);
}

.auth-tagline {
  font-size: 15px; color: var(--text-dim); line-height: 1.5;
  font-family: var(--serif); font-style: italic;
}

/* Form in left panel (like Companio — form at bottom) */
#auth-form,
#auth-forgot-form,
#setpw-form {
  display: flex; flex-direction: column;
  margin-top: auto;
  padding-bottom: 24px;
}
/* The ID `display: flex` above outranks the [hidden] attribute, so without
   this the sign-in and forgot-password forms would both show at once. */
#auth-form[hidden],
#auth-forgot-form[hidden] { display: none; }

.auth-form-fields {
  display: flex; flex-direction: column; gap: 16px;
}

.auth-field {
  display: flex; flex-direction: column; gap: 6px;
}

#auth-form label,
#auth-forgot-form label,
#setpw-form label {
  font-size: 12px; font-weight: 400;
  color: var(--text-dim);
}

#auth-form input,
#auth-forgot-form input,
#setpw-form input {
  padding: 8px 12px;
  border: 1px solid rgba(180, 170, 150, 0.3);
  border-radius: 8px;
  font-size: 13px; font-family: inherit;
  background: var(--card-bg);
  color: var(--text);
  outline: none; transition: border-color 0.15s;
  box-shadow: 0 1px 2px rgba(60,50,40,0.06);
}
#auth-form input:focus,
#auth-forgot-form input:focus,
#setpw-form input:focus {
  border-color: #8b6f47;
  box-shadow: 0 0 0 3px rgba(139,111,71,0.1);
}

/* Warm leather brown submit */
#auth-form button[type="submit"],
#auth-forgot-form button[type="submit"],
#setpw-form button[type="submit"] {
  padding: 8px 16px;
  background: #8b6f47; color: #fff;
  border: none; border-radius: 8px;
  font-size: 13px; font-weight: 500; font-family: inherit;
  cursor: pointer; transition: background 0.15s, transform 0.1s;
  margin-top: 20px;
  white-space: nowrap;
  width: fit-content;
  box-shadow: 0 1px 4px rgba(60,50,40,0.12);
}
#auth-form button[type="submit"]:hover,
#auth-forgot-form button[type="submit"]:hover,
#setpw-form button[type="submit"]:hover { background: #9a7d54; }
#auth-form button[type="submit"]:active,
#auth-forgot-form button[type="submit"]:active,
#setpw-form button[type="submit"]:active { transform: scale(0.98); }
#auth-form button[type="submit"]:disabled,
#auth-forgot-form button[type="submit"]:disabled,
#setpw-form button[type="submit"]:disabled { opacity: 0.5; cursor: wait; }

.auth-link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  padding: 6px 0 0;
  text-decoration: underline;
}

.auth-error {
  color: var(--red); font-size: 13px; min-height: 18px; margin-top: 8px;
}

/* Right: Decorative panel (light gray with icons) */
.auth-decor {
  flex: 1; min-width: 0;
  background: #f8fafc;
  border-radius: 16px;
  border: 1px solid #f1f5f9;
  display: flex; flex-direction: column;
  justify-content: space-between;
  padding: 36px;
  overflow: hidden;
}

.auth-decor-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: flex-end;
  align-items: flex-start;
  padding-top: 8px;
}

.auth-icon {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.06));
  opacity: 0.85;
  transition: opacity 0.2s;
}
.auth-icon:hover { opacity: 1; }

.auth-decor-footer {
  display: flex; gap: 8px; align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.auth-decor-footer a {
  font-size: 12px; color: var(--text-dim);
  text-decoration: none;
}
.auth-decor-footer a:hover {
  text-decoration: underline;
  text-decoration-color: #396AF7;
}
.auth-decor-footer span {
  font-size: 12px; color: var(--text-dim);
}

/* Responsive: stack on narrow screens */
@media (max-width: 768px) {
  .auth-overlay {
    flex-direction: column;
    padding: 16px;
  }
  .auth-brand {
    width: 100%; min-width: 0; max-width: none;
    margin-right: 0;
    padding: 16px 20px 24px;
  }
  .auth-brand-text { margin-top: 24px; }
  .auth-brand-text h1 { font-size: 18px; }
  .auth-brand-logo { width: 36px; height: 36px; }
  .auth-tagline { font-size: 13px; }
  .auth-decor { display: none; }
}

/* ---- Sidebar User Profile ---- */
.sidebar-user {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  position: relative; min-height: 44px;
}
.sidebar-user-info {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0; cursor: pointer;
  border-radius: var(--radius-sm); padding: 2px 4px;
  transition: background 0.1s;
}
.sidebar-user-info:hover { background: var(--sidebar-hover); }
.sidebar-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
  text-transform: uppercase;
}
.sidebar-user-name {
  font-size: 13px; font-weight: 500; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar.collapsed .sidebar-user-name { display: none; }
.sidebar.collapsed .sidebar-user { justify-content: center; padding: 8px 4px; }
.sidebar.collapsed .sidebar-user-info { padding: 2px; justify-content: center; }
.sidebar.collapsed .sidebar-user-menu-btn { display: none; }

.sidebar-user-menu-btn {
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; transition: all 0.1s; flex-shrink: 0;
  position: relative; /* anchors the unread dot */
}
.sidebar-user-menu-btn:hover { background: var(--sidebar-hover); color: var(--text); }

/* Dropdown menu (opens upward from user area) */
.sidebar-user-menu {
  display: none; position: absolute;
  bottom: calc(100% + 6px); left: 4px; right: 4px;
  background: var(--surface); border: 1px solid var(--border);
  /* Warm, not black. Every shadow in this product is rgba(60,50,40,·) — a
     black one under a cream menu reads grey against the desk. */
  border-radius: var(--radius-sm); box-shadow: 0 -4px 16px rgba(60, 50, 40, 0.12);
  padding: 4px; z-index: 100;
  min-width: 180px;
}
.sidebar-user-menu.open { display: block; }

/* ---- What's new (COM-213) ----
   A section in the menu, following the Team block's label-plus-list pattern
   rather than being a new component. */
.sidebar-menu-news { padding: 8px 12px 4px; }

/* The thread. Dots down the left joined by a hairline, so three entries read
   as one running list rather than three unrelated buttons. */
.news-list { position: relative; margin: 2px 0; }
.news-list::before {
  content: ''; position: absolute; left: 4px; top: 12px; bottom: 12px;
  width: 1px; border-left: 1px dotted rgba(175, 170, 162, .7);
}
.news-item {
  position: relative; display: block; width: 100%; text-align: left;
  font-size: 13px; line-height: 1.35; color: var(--text-dim); text-decoration: none;
  padding: 7px 8px 7px 20px; border-radius: 6px; margin-left: -8px;
  transition: background .1s, color .1s;
}
.news-item::before {
  content: ''; position: absolute; left: 9px; top: 12px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--surface3); box-shadow: 0 0 0 2px var(--surface);
}
.news-item:hover { background: var(--sidebar-hover); color: var(--text); }
/* These two and Full changelog are the only keyboard stops in the menu that
   are not buttons, so they need the treatment the rest of the menu gets. */
.news-item:focus-visible {
  background: var(--sidebar-hover); color: var(--text);
  outline: 2px solid var(--accent); outline-offset: -2px;
}
.news-item.unread { color: var(--text); font-weight: 500; }
.news-item.unread::before { background: var(--accent); }

.news-all {
  font-size: 12.5px; color: var(--text-muted); font-weight: 500;
  padding: 6px 8px; margin: 2px 0 0 -8px; border-radius: 6px;
  text-decoration: none;
  width: calc(100% + 8px); display: flex; align-items: center; gap: 6px;
  transition: background .1s, color .1s;
}
.news-all:hover { background: var(--sidebar-hover); color: var(--text); }
.news-all:focus-visible {
  background: var(--sidebar-hover); color: var(--text);
  outline: 2px solid var(--accent); outline-offset: -2px;
}
.news-all svg { width: 13px; height: 13px; opacity: .7; }

/* The only nag. One dot that says "there is something in here", gone the
   moment they look. A count would make this a chore list. */
.sidebar-user-menu-btn[data-unread="true"]::after {
  content: ''; position: absolute; top: 2px; right: 2px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 2px var(--sidebar-bg);
}

.sidebar-menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 12px; border-radius: 6px;
  font-size: 13px; font-weight: 500; color: var(--text-dim);
  background: none; border: none; cursor: pointer;
  transition: all 0.1s; font-family: inherit; text-align: left;
}
.sidebar-menu-item:hover { background: var(--sidebar-hover); color: var(--text); }
.sidebar-menu-item svg {
  width: 16px; height: 16px; flex-shrink: 0;
}
.sidebar-menu-item.menu-danger { color: var(--red); }
.sidebar-menu-item.menu-danger:hover { background: var(--red-dim); }

.sidebar-menu-divider {
  border: none; border-top: 1px solid var(--border);
  margin: 4px 8px;
}

/* Team display in user menu */
.sidebar-menu-team { padding: 8px 12px 4px; }
.sidebar-menu-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted); margin-bottom: 4px;
}
.sidebar-menu-team-name {
  font-size: 13px; font-weight: 500; color: var(--text);
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0;
}
.sidebar-menu-team-option {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 0; border: none; background: none; border-radius: 6px;
  font-size: 13px; color: var(--text-dim); cursor: default;
  font-family: inherit; text-align: left;
}
.sidebar-menu-team-option.clickable { cursor: pointer; padding: 6px 8px; transition: all 0.1s; }
.sidebar-menu-team-option.clickable:hover { background: var(--sidebar-hover); color: var(--text); }
.sidebar-menu-team-option.active { color: var(--text); font-weight: 600; }
.sidebar-menu-team-option .team-check {
  width: 16px; display: flex; justify-content: center; flex-shrink: 0; color: var(--accent);
}

/* Admin toggle indicator (pill/badge in menu item) */
.admin-toggle-indicator {
  margin-left: auto; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 2px 7px; border-radius: 10px;
  background: var(--surface3); color: var(--text-muted);
}
.admin-toggle-indicator::after { content: 'OFF'; }
body.admin-mode .admin-toggle-indicator {
  background: var(--green-dim); color: var(--green);
}
body.admin-mode .admin-toggle-indicator::after { content: 'ON'; }

/* Collapsed sidebar: click avatar opens menu */
.sidebar.collapsed .sidebar-user-menu {
  left: calc(var(--sidebar-collapsed) + 4px);
  right: auto; bottom: 0;
  min-width: 200px;
}

/* ---- Admin Quick-Access Toolbar ---- */
.admin-toolbar {
  display: none; align-items: center; gap: 16px;
  padding: 6px 16px; background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: 12px; flex-shrink: 0;
}
body.admin-mode .admin-toolbar { display: flex; }
.admin-toolbar-group {
  display: flex; align-items: center; gap: 6px;
}
.admin-toolbar-group label {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  white-space: nowrap;
}
.admin-toolbar-group select,
.admin-toolbar-group input {
  padding: 4px 8px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 12px; font-family: var(--mono);
  outline: none;
}
.admin-toolbar-group select { min-width: 180px; cursor: pointer; }
.admin-toolbar-group input[type="number"] { width: 80px; }
.admin-toolbar-group select:focus,
.admin-toolbar-group input:focus { border-color: var(--accent); }
.admin-toolbar-apply {
  padding: 4px 14px; border-radius: 6px;
  background: var(--accent); color: white; border: none;
  font-size: 11px; font-weight: 600; cursor: pointer;
  transition: background 0.15s; margin-left: auto;
}
.admin-toolbar-apply:hover { background: var(--accent-hover); }
.admin-toolbar-apply:disabled { opacity: 0.5; cursor: not-allowed; }
.admin-toolbar-set-default {
  padding: 4px 12px; border-radius: 6px;
  background: transparent; color: var(--accent); border: 1px solid var(--accent);
  font-size: 11px; font-weight: 600; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.admin-toolbar-set-default:hover { background: var(--accent); color: white; }
.admin-toolbar-set-default:disabled { opacity: 0.5; cursor: not-allowed; }
.admin-toolbar-toggle { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-dim); cursor: pointer; }
.admin-toolbar-toggle input[type="checkbox"] { margin: 0; cursor: pointer; }

/* ---- Super Admin effective-system-prompt viewer ---- */
.admin-toolbar-prompt {
  margin-left: auto; padding: 4px 12px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-dim);
  font-size: 11px; font-weight: 600; cursor: pointer;
  transition: transform 140ms ease-out, border-color 140ms ease-out, box-shadow 140ms ease-out;
}
.admin-toolbar-prompt + .admin-toolbar-apply { margin-left: 0; }
.admin-toolbar-prompt.is-ready { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.admin-toolbar-prompt:active { transform: scale(0.97); }

body.system-prompt-open { overflow: hidden; }
.system-prompt-modal {
  position: fixed; inset: 0; z-index: 12000;
  display: grid; place-items: center; padding: 3vh 3vw;
  background: var(--presence-bg);
}
.system-prompt-modal[hidden],
.system-prompt-empty[hidden],
.system-prompt-sections-view[hidden],
.system-prompt-raw-view[hidden] { display: none; }
.system-prompt-dialog {
  width: min(1440px, 94vw); height: min(920px, 94vh); min-height: 0;
  display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.system-prompt-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
  padding: 18px 22px 12px; border-bottom: 1px solid var(--border-light);
}
.system-prompt-header h2 { font-family: var(--serif); font-size: 22px; line-height: 1.2; }
.system-prompt-header p { margin-top: 4px; color: var(--text-muted); font-family: var(--mono); font-size: 11px; }
.system-prompt-close {
  width: 36px; height: 36px; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 50%;
  background: var(--surface2); color: var(--text); font-size: 24px; line-height: 1; cursor: pointer;
  transition: transform 140ms ease-out, box-shadow 140ms ease-out;
}
.system-prompt-close:active { transform: scale(0.96); }
.system-prompt-scope {
  padding: 10px 22px; border-bottom: 1px solid var(--border-light);
  color: var(--text-dim); font-size: 12px; line-height: 1.45;
}
.system-prompt-controls {
  display: flex; align-items: center; gap: 9px; padding: 10px 22px;
  border-bottom: 1px solid var(--border); background: var(--surface2);
}
.system-prompt-view-switch { display: inline-flex; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.system-prompt-view-switch button,
.system-prompt-copy-all,
.system-prompt-section-heading button,
.system-prompt-raw-block button {
  min-height: 32px; padding: 6px 11px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; color: var(--text-dim); font: 600 11px var(--sans); cursor: pointer;
  transition: transform 140ms ease-out, background 140ms ease-out, border-color 140ms ease-out;
}
.system-prompt-view-switch button[aria-pressed="true"] { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.system-prompt-view-switch button:active,
.system-prompt-copy-all:active,
.system-prompt-section-heading button:active,
.system-prompt-raw-block button:active { transform: scale(0.97); }
.system-prompt-copy-all,
.system-prompt-section-heading button,
.system-prompt-raw-block button { border-color: var(--border); background: var(--surface); }
.system-prompt-copy-all { margin-left: auto; }
.system-prompt-copy-all:disabled { opacity: 0.45; cursor: default; }
.system-prompt-search-label,
.system-prompt-selector-label { color: var(--text-dim); font-size: 11px; font-weight: 600; }
#system-prompt-search,
#system-prompt-section-select {
  min-height: 34px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); color: var(--text); padding: 6px 9px; font: 12px var(--sans); outline: none;
}
#system-prompt-search { width: min(300px, 24vw); }
#system-prompt-search:focus,
#system-prompt-section-select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-dim); }
.system-prompt-search-count { min-width: 62px; color: var(--text-muted); font: 11px var(--mono); }
.system-prompt-empty { align-self: center; justify-self: center; padding: 28px; color: var(--text-muted); text-align: center; }
.system-prompt-sections-view {
  min-height: 0; display: grid; grid-template-columns: minmax(270px, 32%) minmax(0, 1fr);
}
.system-prompt-tree {
  min-height: 0; overflow: auto; padding: 10px; border-right: 1px solid var(--border); background: var(--surface2);
}
.system-prompt-tree-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 8px 7px calc(8px + var(--prompt-tree-depth) * 14px); border: 1px solid transparent;
  border-radius: 6px; background: transparent; color: var(--text-dim); text-align: left; font: 12px var(--sans); cursor: pointer;
}
.system-prompt-tree-item > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.system-prompt-tree-item.is-selected { border-color: var(--accent); background: var(--accent-dim); color: var(--text); }
.system-prompt-owner {
  display: inline-flex; align-items: center; flex: 0 0 auto; padding: 2px 6px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--text-muted); font: 600 9px var(--sans); text-transform: uppercase; letter-spacing: 0.04em;
}
.system-prompt-owner.owner-admin { color: var(--purple); background: var(--purple-dim); }
.system-prompt-owner.owner-team { color: var(--accent); background: var(--accent-dim); }
.system-prompt-owner.owner-generated { color: var(--cyan); }
.system-prompt-owner.owner-knowledge { color: var(--green); background: var(--green-dim); }
.system-prompt-section-panel { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); padding: 16px 18px 18px; }
.system-prompt-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 12px; }
.system-prompt-section-heading h3 { font-size: 15px; line-height: 1.3; }
.system-prompt-provenance { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; margin-top: 6px; color: var(--text-muted); font-size: 11px; }
#system-prompt-section-text,
.system-prompt-raw-block pre {
  min-height: 0; margin: 0; padding: 16px; overflow: auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg);
  color: var(--text); font: 12px/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere;
}
#system-prompt-section-text mark,
.system-prompt-raw-block mark { background: var(--hl-yellow); color: inherit; }
.system-prompt-raw-view { min-height: 0; overflow: auto; padding: 14px 18px 20px; }
.system-prompt-raw-block header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 7px; }
.system-prompt-raw-block header div { display: flex; flex-direction: column; gap: 2px; }
.system-prompt-raw-block header strong { font-size: 12px; }
.system-prompt-raw-block header span { color: var(--text-muted); font: 10px var(--mono); }
.system-prompt-raw-block pre { max-height: 58vh; }
.system-prompt-block-delimiter { padding: 14px 0; color: var(--text-muted); text-align: center; font: 10px var(--mono); }
.system-prompt-copy-status { min-height: 28px; padding: 6px 22px; border-top: 1px solid var(--border-light); color: var(--text-muted); font-size: 11px; }
.system-prompt-selector-label,
#system-prompt-section-select { display: none; }

.system-prompt-modal button:focus-visible,
.system-prompt-modal input:focus-visible,
.system-prompt-modal select:focus-visible,
.system-prompt-modal pre:focus-visible,
.admin-toolbar-prompt:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (hover: hover) and (pointer: fine) {
  .admin-toolbar-prompt:hover,
  .system-prompt-close:hover,
  .system-prompt-copy-all:hover:not(:disabled),
  .system-prompt-section-heading button:hover,
  .system-prompt-raw-block button:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
  .system-prompt-tree-item:hover { background: var(--surface3); }
}

@media (max-width: 760px) {
  .system-prompt-modal { padding: 0; place-items: stretch; }
  .system-prompt-dialog { width: 100vw; height: 100vh; border: 0; border-radius: 0; }
  .system-prompt-header { padding: 13px 14px 9px; }
  .system-prompt-header h2 { font-size: 18px; }
  .system-prompt-scope { padding: 8px 14px; }
  .system-prompt-controls { padding: 8px 14px; flex-wrap: wrap; }
  .system-prompt-search-label { order: 3; }
  #system-prompt-search { order: 4; width: min(240px, 60vw); }
  .system-prompt-search-count { order: 5; }
  .system-prompt-sections-view { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); padding: 10px 12px 12px; }
  .system-prompt-tree { display: none; }
  .system-prompt-selector-label,
  #system-prompt-section-select { display: block; }
  #system-prompt-section-select { width: 100%; margin: 5px 0 10px; }
  .system-prompt-section-panel { padding: 0; }
  .system-prompt-section-heading { align-items: center; }
  .system-prompt-raw-view { padding: 10px 12px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .admin-toolbar-prompt,
  .system-prompt-close,
  .system-prompt-view-switch button,
  .system-prompt-copy-all,
  .system-prompt-section-heading button,
  .system-prompt-raw-block button { transition: none; }
}

/* Drawer model-section action buttons: Apply to this chat / Set as team default */
.model-action-row { display: flex; gap: 8px; margin-top: 8px; }
.model-action-btn {
  flex: 1; padding: 8px 12px; border-radius: 6px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background 0.15s, color 0.15s;
}
.model-action-btn.primary { background: var(--accent); color: white; border: 1px solid var(--accent); }
.model-action-btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.model-action-btn.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.model-action-btn.secondary:hover { background: var(--accent); color: white; }
.model-action-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Knowledge Base Memory Section ---- */
.kb-memory-section { margin-top: 16px; }
.kb-memory-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.kb-memory-hint {
  font-size: 13px; color: var(--text-muted); margin-bottom: 12px;
}
.kb-memory-preview {
  font-family: var(--mono); font-size: 12px; line-height: 1.6;
  color: var(--text-dim); background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; max-height: 200px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
  margin-bottom: 12px;
}
.kb-memory-preview.empty {
  color: var(--text-muted); font-style: italic; font-family: inherit;
}
.kb-memory-actions {
  display: flex; gap: 8px;
}
.kb-memory-btn {
  padding: 6px 14px; border-radius: 6px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.kb-memory-btn:hover { background: var(--surface3); color: var(--text); }
.kb-memory-danger { border-color: rgba(255, 45, 85, 0.3); color: var(--red); }
.kb-memory-danger:hover { background: var(--red-dim); color: var(--red); }

/* ==================================================================
   PAGES PAGE — Deployed pages management
   ================================================================== */

/* Edge to edge — no centred cap. A landing page is the widest thing this app
   shows, and a 1200px band was spending ~250px of a 1440px screen on margin
   that the column view's preview needs. The grid simply fits another card. */
/* Grid and column view share one inset (16px left / 12px right — the column
   view's, set by .pcol-head and the preview toolbar) so that toggling views
   moves nothing but the content itself. Two different insets meant the title,
   the tab strip and the New page button all slid sideways on every toggle. */
.pages-page-body { padding: 20px 12px 24px 16px; width: 100%; }

/* Page header: one sticky row. The title used to sit in a row of its own that
   scrolled away, which cost ~50px of height and put the page's name and its
   controls on separate lines for no reason — they read as one thing. Now the
   title leads the control bar: name, filter, search on the left; view toggle,
   gear and New page on the right. The column view spends the reclaimed height
   on the columns. */
.pages-page-header {
  display: flex; flex-direction: column;
  /* Matches .pcol-head (0 12px 0 16px) and .pages-page-body. "Pages" lands on
     the same vertical as "FOLDERS" / the first tab beneath it in both views,
     and nothing in the bar shifts when the view toggles. */
  padding: 16px 12px 14px 16px;
  width: 100%;
  /* z-index must beat a hovered card (.pages-card:hover { z-index: 10 }), else a
     card scrolling under the sticky bar punches through it on scroll. */
  position: sticky; top: 0; z-index: 20;
  background: var(--sidebar-bg);
}
.pages-page-title {
  font-size: 19px; font-weight: 700; color: var(--text); margin: 0;
  flex-shrink: 0;
}

.pages-control-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; flex-wrap: wrap; }
.pages-control-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* Everything actionable lives here, in reading order: search, filter, view,
   gear, New page. Wraps to its own line (aligned right) before it ever collides
   with the title. */
.pages-control-right { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
/* Hairline separating what you're looking at (search/filter) from how you're
   looking at it (view/gear/New page). */
.pages-head-divider { width: 1px; align-self: center; height: 22px; background: var(--border); margin: 0 4px; flex-shrink: 0; }

/* You/team creator filter — text pills. Mirrors the gallery filter; only
   rendered when the team's pages mix authors. */
.pages-filter { display: inline-flex; gap: 2px; padding: 2px; background: var(--surface2); border: 1px solid var(--border); border-radius: 9px; flex-shrink: 0; }
/* Pages omits the group entirely when there's no mix to filter; Gallery's header
   is static markup, so it toggles [hidden] instead — which the display above
   would otherwise win against. */
.pages-filter[hidden] { display: none; }
/* Status filter — one control, not a fifth and sixth pill. A second segmented
   strip beside the creator pills read as one long row of options, and its "All"
   looked like a third creator choice. This says only what is applied; the rest
   of the answer lives one click down. */
.pages-status-filter {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  font-family: var(--sans); font-size: 12.5px; font-weight: 500; color: var(--text-muted);
  background: var(--surface2); border: 1px solid var(--border); border-radius: 9px;
  padding: 6px 9px 6px 10px; cursor: pointer;
  transition: color .12s, background .12s, border-color .12s, box-shadow .12s;
}
.pages-status-filter:hover { color: var(--text-dim); }
.pages-status-filter svg { flex-shrink: 0; opacity: .7; }
.pages-status-filter .fib-caret { opacity: .45; }
/* Offline's dot is the base muted grey — the same one the rows use. Declared
   explicitly so it reads as chosen rather than as a class that does nothing. */
.pages-status-dot.is-offline { background: var(--text-muted); }
/* Set state earns the surface + weight of an active pill, so a filter left on
   is impossible to miss — an unnoticed filter is a page that looks empty for no
   reason. */
.pages-status-filter.is-set {
  background: var(--surface); color: var(--text); border-color: rgba(139,111,71,0.35);
  box-shadow: var(--shadow-sm);
}
.pages-status-filter.is-set svg { opacity: .8; }
.pages-status-filter[aria-expanded="true"] { background: var(--surface); color: var(--text); }
.pages-status-filter.is-hidden { display: none; }

.pages-status-menu { min-width: 190px; padding: 4px; }
.pages-status-menu .pages-menu-item { display: flex; align-items: center; gap: 9px; width: 100%; }
/* Keeps "Any status" hanging on the same left edge as the three that carry a
   dot — a ragged first column would undo the grouping the dots create. */
.psf-dot-slot { width: 7px; height: 7px; flex-shrink: 0; }
.psf-name { flex: 1; text-align: left; }
.pages-filter-pill { display: inline-flex; align-items: center; gap: 7px; font-family: var(--sans); font-size: 12.5px; font-weight: 500; color: var(--text-muted); background: none; border: none; padding: 5px 11px; border-radius: 7px; cursor: pointer; transition: color .12s, background .12s, box-shadow .12s; }
.pages-filter-pill:hover { color: var(--text-dim); }
.pages-filter-pill.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
/* Result count per pill. The whole point is comparing the two numbers, so they
   are tabular and sit a shade darker than their own label — the chip has to
   read as a separate object, not as more of the word. Zero shows: "Just mine 0"
   is the answer to the question the pill asks, and hiding it would be
   indistinguishable from a pill that never counted at all. */
.pf-count { font-size: 10.5px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-dim); background: rgba(111,96,72,0.13); border-radius: 20px; padding: 1px 6px; min-width: 19px; text-align: center; transition: background .12s, color .12s; }
.pages-filter-pill.is-active .pf-count { background: rgba(139,111,71,0.20); color: #5a4a30; }

/* Search box */
.pages-search {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 11px; border-radius: 9px;
  background: #fffefb; border: 1px solid var(--border);
  transition: border-color .15s, box-shadow .15s;
}
.pages-search:focus-within { border-color: rgba(139,111,71,0.45); box-shadow: 0 0 0 3px rgba(139,111,71,0.08); }
.pages-search svg { color: var(--text-muted); flex-shrink: 0; }
.pages-search input { border: none; outline: none; background: none; font-family: var(--sans); font-size: 13px; color: var(--text); width: 150px; }

/* The hero action — warm "leather button" */
.btn-build {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 10px; border: none;
  background: linear-gradient(to bottom, #9a7d54, #8b6f47);
  color: #fff5e6; font-family: var(--sans); font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  box-shadow: 0 1px 0 rgba(255,255,255,0.25) inset, 0 2px 5px rgba(60,50,40,0.22), 0 4px 12px rgba(139,111,71,0.18);
  transition: transform .18s var(--spring), box-shadow .18s, filter .15s;
}
.btn-build:hover { transform: translateY(-1.5px); box-shadow: 0 1px 0 rgba(255,255,255,0.3) inset, 0 4px 9px rgba(60,50,40,0.24), 0 8px 20px rgba(139,111,71,0.22); filter: brightness(1.03); }
.btn-build:active { transform: translateY(0); box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 1px 3px rgba(60,50,40,0.25); }
.btn-build svg { flex-shrink: 0; }

/* ---- Manila folder tab strip (scrollable, pinned All + New) ---- */
.folder-tabs-wrap { padding: 4px 12px 0 16px; width: 100%; }
.folder-tabs { display: flex; align-items: flex-end; gap: 4px; border-bottom: 2px solid var(--manila-edge); }
.folder-tabs > .folder-tab { flex-shrink: 0; }
.folder-tabs > .folder-add { flex-shrink: 0; margin-left: 2px; }
.folder-tabs-scroll {
  display: flex; align-items: flex-end; gap: 4px;
  flex: 1 1 auto; min-width: 0;
  overflow-x: auto; overflow-y: hidden;
  padding-top: 8px;
  /* No scrollbar, on any platform. macOS overlay bars cost no layout, so a
     reserved-but-transparent bar was free here and read as free everywhere.
     It is not: a classic scrollbar takes its height out of the content box, so
     on Windows every tab inside the scroller was seated ~11px above the sheet
     while pinned All/Templates still met it — the strip rendered as two rows.
     The edge fades already say "there is more this way"; folder-strip-scroll.js
     puts a plain vertical wheel back in reach of the far tabs. */
  scrollbar-width: none;
  --fade-l: 0px; --fade-r: 0px;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
          mask-image: linear-gradient(to right, transparent 0, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent 100%);
}
.folder-tabs-scroll::-webkit-scrollbar { display: none; }
.folder-tabs-scroll > .folder-tab { flex-shrink: 0; }
/* The 2px that seats a tab on the sheet has to move the scroller, not the tabs
   inside it. `overflow-x: auto` forces the computed overflow-y to hidden — the
   spec will not pair auto with visible — so a tab nudged 2px below its own
   container loses exactly that much off its bottom edge. Shifting the scroller
   reproduces the nudge with nothing overhanging to clip. */
.folder-tabs-scroll { position: relative; top: 2px; }
.folder-tabs-scroll > .folder-tab { top: 0; }

.folder-tab {
  position: relative; top: 2px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px 10px;
  border-radius: 11px 11px 0 0;
  background: linear-gradient(to bottom, #efe2c4, var(--manila));
  border: 1px solid var(--manila-edge); border-bottom: none;
  color: var(--manila-text);
  font-family: var(--sans); font-size: 12.5px; font-weight: 600;
  cursor: pointer; user-select: none; white-space: nowrap;
  box-shadow: 0 -1px 3px rgba(60,50,40,0.04);
  transition: background .15s, transform .18s var(--spring), box-shadow .18s, top .15s;
}
.folder-tab:hover { transform: translateY(-2px); }
.folder-tab .ft-name { overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.folder-tab .ft-count { font-size: 10.5px; font-weight: 600; color: var(--manila-text); background: rgba(111,96,72,0.14); border-radius: 20px; padding: 1px 7px; min-width: 20px; text-align: center; }
.folder-tab .ft-icon { opacity: .65; flex-shrink: 0; }
.folder-tab.is-active {
  background: linear-gradient(to bottom, #fbf6e9, var(--manila-open));
  color: #4a3f2c; box-shadow: 0 -2px 8px rgba(60,50,40,0.08); z-index: 3;
}
.folder-tab.is-active .ft-count { background: rgba(139,111,71,0.18); color: #5a4a30; }
/* Templates is pinned beside All, so it needs to read as a different kind of
   thing at a glance. The star is filled at rest — a folder you can't file into
   and can't rename, marked the same way its pages are. */
.folder-tab.is-templates .ft-icon { opacity: .8; fill: rgba(139,111,71,0.16); }
.folder-tab.is-templates.is-active .ft-icon { opacity: 1; fill: rgba(139,111,71,0.3); }
/* The All tab doubles as the folder browser: a caret signals the dropdown, and
   the tab takes the "open" look while the index is showing. Shared by Gallery
   and Pages (both render .folder-tab). */
.folder-tab .ft-caret { display: inline-flex; opacity: .5; margin-left: 1px; flex-shrink: 0; transition: transform .18s var(--spring), opacity .15s; }
.folder-tab:hover .ft-caret { opacity: .75; }
.folder-tab.is-open .ft-caret { transform: rotate(180deg); opacity: .85; }
.folder-tab.is-open {
  background: linear-gradient(to bottom, #fbf6e9, var(--manila-open));
  color: #4a3f2c; box-shadow: 0 -2px 8px rgba(60,50,40,0.08); z-index: 3;
}
/* Drop target while dragging a card — physical lift, not a colour flash */
.folder-tab.drag-over {
  transform: translateY(-5px);
  background: linear-gradient(to bottom, #fff8e6, #f7eccb);
  box-shadow: 0 6px 16px rgba(139,111,71,0.25), 0 0 0 2px rgba(139,111,71,0.45);
}

.folder-add {
  position: relative; top: 2px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 8px 12px; border-radius: 11px 11px 0 0;
  background: transparent; border: 1px dashed var(--manila-edge); border-bottom: none;
  color: var(--manila-text); cursor: pointer; white-space: nowrap;
  transition: background .15s, color .15s;
}
.folder-add:hover { background: rgba(231,214,176,0.4); color: #4a3f2c; }
.folder-add .fa-plus { font-size: 16px; font-weight: 600; line-height: 1; }
.folder-add .fa-label { font-size: 12px; font-weight: 600; }
.folder-new-input {
  position: relative; top: 2px; flex-shrink: 0;
  padding: 8px 12px; border-radius: 11px 11px 0 0;
  border: 1px solid var(--accent); border-bottom: none;
  background: var(--manila-open);
  font-family: var(--sans); font-size: 12.5px; font-weight: 600; color: #4a3f2c;
  outline: none; width: 150px;
}

/* Folder-tab options (rename / delete) — added with the management step */
.ft-menu-btn { opacity: 0; margin-left: 1px; padding: 0 3px; border: none; background: none; color: var(--manila-text); font-size: 13px; font-weight: 700; letter-spacing: 1px; line-height: 1; cursor: pointer; border-radius: 4px; transition: opacity .12s, background .12s; }
.folder-tab:hover .ft-menu-btn, .folder-tab.is-active .ft-menu-btn { opacity: .7; }
.ft-menu-btn:hover { opacity: 1; background: rgba(111,96,72,0.16); }
.ft-menu { position: fixed; z-index: 200; min-width: 152px; background: #fffcf5; border: 1px solid rgba(0,0,0,0.12); border-radius: 8px; padding: 4px; box-shadow: 0 8px 24px rgba(60,50,40,0.18), 0 2px 6px rgba(60,50,40,0.08); }
.ft-rename-input { width: 132px; font-family: var(--sans); font-size: 12.5px; font-weight: 600; color: #4a3f2c; background: #fff; border: 1px solid var(--accent); border-radius: 5px; padding: 2px 6px; outline: none; }

/* Card grid */
.pages-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
/* Gentle staggered entrance for grid cards on a tab visit. Opacity-only — NO
   transform: each card holds a live <iframe srcdoc> thumbnail, and translating
   a card while its iframe paints causes visible jank. Opacity is GPU-composited
   and stays smooth. _createPageCard adds .is-entering + an inline
   animation-delay; _rebuildBody strips the class on animationend so a later
   filter toggle (display:none → block) can't replay the stagger. */
@keyframes pagesCardIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.pages-card.is-entering {
  animation: pagesCardIn 0.3s ease both;
}
@media (prefers-reduced-motion: reduce) {
  .pages-card.is-entering { animation: none; }
}
/* Filtered-out cards/rows — kept in the DOM so thumbnail iframes persist */
.pages-card.is-hidden, .pages-row.is-hidden { display: none; }

/* Drag grip (refile handle) */
.pages-grip { color: #a89a84; cursor: grab; opacity: 0; transition: opacity .15s; flex-shrink: 0; padding: 0 2px; display: inline-flex; }
.pages-card:hover .pages-grip, .pages-row:hover .pages-grip { opacity: 1; }
.pages-card.dragging, .pages-row.dragging { opacity: .35; }
.pages-card.dragging .pages-grip { cursor: grabbing; }

/* Live preview thumbnail — ratio preserved, never stretched */
.pages-thumb { aspect-ratio: 4 / 3; border-radius: 5px; overflow: hidden; background: #f0ece6; margin-bottom: 11px; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05); position: relative; cursor: pointer; }
.pages-thumb iframe, .row-thumb iframe { border: 0; display: block; background: #fff; pointer-events: none; }
.thumb-ph { width: 100%; height: 100%; background: linear-gradient(to bottom, var(--ph, #8b6f47) 0 26%, #ffffff 26%); }
.pages-card.is-offline .pages-thumb { filter: saturate(0.4) opacity(0.72); }

/* Status reads via the dot; the label stays neutral for a calmer grid */
.pages-status { color: var(--text-muted); }

/* ---- List view (physical paper rows) ---- */
.pages-list { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }
.pages-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px;
  background: var(--surface); border: 1px solid rgba(60,50,40,0.09);
  border-radius: 10px; box-shadow: 0 1px 2px rgba(60,50,40,0.05), 0 4px 12px rgba(60,50,40,0.05);
  transition: transform .15s, box-shadow .15s, opacity .2s;
  position: relative;
}
.pages-row:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(60,50,40,0.08); z-index: 5; }
.pages-row .pages-status-dot { width: 8px; height: 8px; flex-shrink: 0; }
.row-thumb { width: 54px; height: 38px; border-radius: 5px; overflow: hidden; background: #f0ece6; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05); position: relative; }
.pages-row.is-offline .row-thumb { filter: saturate(0.4) opacity(0.72); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.row-title { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pages-row.is-offline .row-title { color: #9a9388; }
.row-url { font-size: 11px; color: var(--text-muted); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-url:hover { color: var(--accent); }
.row-folder-chip { font-size: 11px; font-weight: 600; color: var(--manila-text); background: linear-gradient(to bottom, #efe2c4, var(--manila)); border: 1px solid var(--manila-edge); border-radius: 20px; padding: 2px 10px; flex-shrink: 0; white-space: nowrap; }
.pages-list.folder-active .row-folder-chip { display: none; }
.row-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; white-space: nowrap; }
/* List rows: Edit + ⋯ are always visible (no hover-to-reveal) so actions are
   one click away when scanning a dense list. Grid cards keep the hover reveal. */
.pages-row .pages-action-btn { opacity: 1; flex-shrink: 0; }
.pages-row .pages-card-menu-btn { opacity: 1; }
.pages-row .pages-win-menu-wrap { flex-shrink: 0; }

/* Move-to-folder submenu (card ⋯ menu) */
.pages-menu-item.has-sub { position: relative; }
.pages-menu-item .chev { margin-left: auto; color: var(--text-muted); }
.pages-submenu { display: none; position: absolute; top: -5px; right: calc(100% + 2px); min-width: 168px; max-height: 240px; overflow-y: auto; background: #fffcf5; border: 1px solid rgba(0,0,0,0.12); border-radius: 8px; padding: 4px; box-shadow: 0 8px 24px rgba(60,50,40,0.15); z-index: 50; }
/* Open on hover (instant), and stay open while JS holds `.sub-open` — a short
   grace window so a diagonal path to a lower folder (crossing sibling rows like
   "Make it live") doesn't snap it shut. */
.pages-menu-item.has-sub:hover .pages-submenu,
.pages-menu-move.sub-open .pages-submenu { display: block; }
/* Invisible bridge across the gap to the parent row, so the cursor never lands in
   a dead zone between the row and the folder list. */
.pages-submenu::before { content: ''; position: absolute; top: 0; bottom: 0; right: -8px; width: 8px; }
.pages-submenu .sub-current { color: var(--accent); font-weight: 600; }

/* ---- Retro Monitor Cards (matches artifact pane monitor) ---- */

.pages-card {
  display: flex; flex-direction: column;
  background: linear-gradient(to bottom, #e8e2da, #ddd6cc 40%, #d9d1c6);
  border-radius: 12px;
  overflow: visible; position: relative;
  box-shadow:
    0 1px 4px rgba(60, 50, 40, 0.08),
    0 3px 12px rgba(60, 50, 40, 0.04);
  transition: transform 0.2s, box-shadow 0.2s;
}
.pages-card:hover {
  transform: translateY(-2px);
  box-shadow:
    0 3px 10px rgba(60, 50, 40, 0.1),
    0 6px 20px rgba(60, 50, 40, 0.05);
  z-index: 10;
}

/* ---- Title bar — dots + title ---- */
.pages-win-titlebar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  min-height: 28px;
}

/* Three window dots */
.pages-win-dots {
  display: flex; gap: 5px; flex-shrink: 0;
}
.pages-win-dots span {
  width: 9px; height: 9px; border-radius: 50%;
  border: 1px solid #c4baa8;
}
.pages-win-dots span:first-child {
  background: #c4baa8; cursor: pointer;
  transition: background 0.15s;
}
.pages-win-dots span:first-child:hover { background: #e25d5d; border-color: #c04040; }
.pages-win-dots span:nth-child(2),
.pages-win-dots span:nth-child(3) { background: transparent; }

/* The title used to live here too; it's now shown only in the card body. With it
   gone, push the drag grip + ⋯ menu to the right edge (dots stay left). */
.pages-win-titlebar .pages-grip { margin-left: auto; }

/* Ellipsis menu in title bar */
.pages-win-menu-wrap {
  position: relative; flex-shrink: 0; z-index: 5;
}
.pages-card-menu-btn {
  background: none; border: none;
  color: #8a7e70; font-size: 14px; font-weight: 700;
  cursor: pointer; padding: 2px 4px; line-height: 1;
  letter-spacing: 2px; border-radius: 4px;
  opacity: 0; transition: all 0.15s;
}
.pages-card:hover .pages-card-menu-btn { opacity: 1; }
.pages-card-menu-btn:hover { color: #5a5248; background: rgba(0,0,0,0.06); }

/* Dropdown menu */
.pages-card-menu {
  display: none; position: absolute; top: calc(100% + 4px); right: 0;
  min-width: 160px;
  background: #fffcf5; border: 1px solid rgba(0,0,0,0.12);
  border-radius: 8px; padding: 4px;
  box-shadow: 0 8px 24px rgba(60, 50, 40, 0.15), 0 2px 6px rgba(60, 50, 40, 0.08);
}
.pages-card-menu.is-open { display: block; }

.pages-menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 10px; border: none; background: none;
  font-family: var(--sans); font-size: 12px; color: var(--text-dim);
  cursor: pointer; border-radius: 5px; transition: all 0.1s; text-align: left;
}
.pages-menu-item:hover { background: var(--surface2); color: var(--text); }
.pages-menu-item svg { flex-shrink: 0; }
.pages-menu-delete:hover { color: var(--red); background: var(--red-dim); }
.pages-menu-divider {
  height: 1px; background: var(--border-light); margin: 3px 6px;
}

/* ---- Screen / content area (recessed) ---- */
.pages-win-body {
  margin: 0 6px 6px;
  padding: 14px;
  background: #fff;
  border-radius: 6px;
  display: flex; flex-direction: column; flex: 1;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.04);
}
.pages-win-content { flex: 1; display: flex; flex-direction: column; min-height: 160px; }

/* Body title + description */
.pages-body-title {
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  color: var(--text); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 10px;
}
/* Inline page rename (⋯ → Rename) — swaps the title for an input in place,
   matching the title's type so the card doesn't jump. */
.page-rename-input {
  width: 100%; box-sizing: border-box;
  font-family: var(--sans); font-size: 13px; font-weight: 600; color: var(--text);
  background: #fff; border: 1px solid var(--accent); border-radius: 5px;
  padding: 2px 6px; outline: none; margin-bottom: 10px;
}
.pages-row .page-rename-input { font-size: 14px; margin-bottom: 0; min-width: 0; }
/* Click-to-rename affordance: a caret cursor + a pencil that fades in on hover, so
   the page name reads as directly editable instead of hiding in the ⋯ menu. The
   pencil is an absolutely-positioned ::after (kept out of the line-clamp flow) in
   reserved right padding, tinted via mask so it follows the theme. */
.pages-body-title.is-editable,
.row-title.is-editable { cursor: text; }
.pages-body-title.is-editable { position: relative; padding-right: 18px; }
.row-title.is-editable { position: relative; padding-right: 16px; }
.pages-body-title.is-editable::after,
.row-title.is-editable::after {
  content: ""; position: absolute; top: 1px; right: 0;
  width: 12px; height: 12px; pointer-events: none;
  background-color: var(--text-muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z'/%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='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0; transition: opacity 140ms ease;
}
.pages-card:hover .pages-body-title.is-editable::after,
.pages-row:hover .row-title.is-editable::after { opacity: 0.55; }
.pages-body-desc {
  font-family: var(--sans); font-size: 12px; color: var(--text-dim);
  line-height: 1.4;
  display: -webkit-box; line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; margin-bottom: 10px;
}

/* Status */
.pages-status {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--sans); font-size: 12px;
  margin-bottom: 8px;
}
.pages-template-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 18px; padding: 2px 8px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text-muted);
  font-family: var(--sans); font-size: 11px; font-weight: 700;
  line-height: 1; white-space: nowrap;
}
.pages-template-badge.is-own {
  min-width: 22px; padding-inline: 6px;
  background: var(--sidebar-active); color: var(--accent);
  border-color: var(--border-light);
}

/* Trust marker on global starter cards/rows — signals these are conversion-built
   starters, not blank scaffolds. Warm accent tint (never blue), Lucide badge-check. */
.pages-cro-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px 3px 7px; border-radius: 999px;
  background: var(--sidebar-active); color: var(--accent);
  border: 1px solid var(--border-light);
  font-family: var(--sans); font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.01em; line-height: 1; white-space: nowrap;
}
.pages-cro-badge svg { width: 13px; height: 13px; flex: none; }
/* Card: badge sits on its own line above the title. */
.pages-win-content .pages-cro-badge { align-self: flex-start; margin-bottom: 9px; }
/* Row: badge trails the "Starter template" label, compact. */
.row-main .pages-cro-badge { margin-left: 8px; vertical-align: middle; }

/* MCP provenance — a page an outside assistant wrote. Deliberately quieter than
   the CRO badge (muted paper chip, no accent fill): it is a fact about who held
   the pen, not a recommendation. */
.pages-mcp-label {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px 3px 7px; border-radius: 999px;
  background: var(--surface2); color: var(--text-dim);
  border: 1px dashed var(--border-light);
  font-family: var(--sans); font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.01em; line-height: 1; white-space: nowrap;
}
.pages-mcp-label svg { width: 12px; height: 12px; flex: none; }
.pages-win-content .pages-mcp-label { align-self: flex-start; margin-bottom: 9px; }
.row-main .pages-mcp-label { margin-left: 8px; vertical-align: middle; }

/* URL */
.pages-meta-url {
  font-family: var(--sans); font-size: 11px; color: var(--text-muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-decoration: none; display: block; margin: -6px 0 10px; cursor: pointer;
}
/* Hover and keyboard focus reach the same control, so they get the same emphasis. */
.pages-meta-url:is(:hover, :focus-visible) { color: var(--accent); text-decoration: underline; }
/* Draft — the address is reserved, not yet reachable. Marked with a dotted rule
   rather than dimmed: opacity composites 11px text toward the page until it's
   unreadable (0.55 measured 1.97:1, well under the 4.5:1 floor), and an address
   you can't read fails at the one job this line has. Dotted reads "provisional"
   at full contrast, and escalates to the solid accent underline on hover. */
.pages-meta-url.is-reserved {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.pages-meta-url.is-reserved:is(:hover, :focus-visible) { text-decoration: underline solid; }
.pages-meta-url:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* Meta line — anchored to bottom: status · creator · last-edit time, one row */
.pages-meta-time {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-family: var(--sans); font-size: 12px; color: var(--text-muted);
  margin-top: auto; padding-top: 10px;
}
/* Status sheds its standalone badge spacing/size to sit inline with the meta. */
.pages-meta-time .pages-status { font-size: 12px; margin-bottom: 0; }
.pages-meta-sep, .pages-meta-when { color: var(--text-muted); }
.pages-card.is-offline .pages-body-title,
.pages-card.is-offline .pages-meta-url,
.pages-card.is-offline .pages-meta-time,
.pages-card.is-offline .pages-status {
  color: #b0a898;
}
/* The offline dimming above outranks `.pages-meta-url:hover`, which would leave
   the slug on an offline card with no hover colour — and offline is exactly when
   someone is checking an address. Restore it at matching specificity, for keyboard
   focus as well as hover: the two reach the same control and should look the same. */
.pages-card.is-offline .pages-meta-url:is(:hover, :focus-visible) { color: var(--accent); }
.pages-status.is-live { color: #059669; }
.pages-status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-muted); flex-shrink: 0;
}
.pages-status.is-live .pages-status-dot { background: #10b981; }
/* Draft (never promoted) — brown, matches the toolbar/chat Draft accent. */
.pages-status.is-preview { color: var(--accent); }
.pages-status.is-preview .pages-status-dot { background: var(--accent); }
.pages-status-dot.is-preview { background: var(--accent); }
.pages-status.is-template { color: var(--text-muted); }
/* Live page with unpublished draft edits — "· N to publish" marker. */
.pages-status-pending { color: var(--accent); font-weight: 600; margin-left: 2px; }
/* List rows put is-live directly on the dot (no .pages-status wrapper) — green
   when live, muted grey when offline, matching the grid card's status colour. */
.pages-status-dot.is-live { background: #10b981; }

/* ---- Action buttons ---- */
.pages-card-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border-light);
}
.pages-action-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface); color: var(--text-dim);
  font-family: var(--sans); font-size: 11px; font-weight: 500;
  cursor: pointer; transition: all 0.12s;
}
.pages-action-btn:hover {
  background: var(--surface2); color: var(--text);
  border-color: var(--accent);
}
.pages-action-btn svg { flex-shrink: 0; }
.pages-btn-use-template {
  flex: 1 1 auto; justify-content: center;
  background: var(--accent); border-color: var(--accent);
  color: var(--surface); font-weight: 700;
}
.pages-btn-use-template:hover {
  background: var(--accent-hover); border-color: var(--accent-hover);
  color: var(--surface);
}
.pages-win-dots.is-readonly span:first-child { cursor: default; }
.pages-win-dots.is-readonly span:first-child:hover {
  background: none; border-color: inherit;
}

/* Pinned clone action: the shared card supplies the monitor band and recessed body. */
.pages-clone-card {
  appearance: none;
  width: 100%;
  border: none;
  color: var(--text);
  font: inherit;
  text-align: center;
  cursor: pointer;
}
.pages-clone-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.pages-clone-body {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 14px;
}
.pages-clone-label {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  line-height: 1.2;
}
.pages-clone-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent);
  box-shadow: inset 0 0 0 3px var(--cream), inset 0 0 0 4px var(--border-light);
}
.pages-clone-plus svg { width: 17px; height: 17px; }

@media (max-width: 677px) {
  .pages-clone-card { min-height: calc((100vw - 64px) * 0.75 + 123px); }
}

@media (prefers-reduced-motion: reduce) {
  .pages-clone-card { transition: none; }
}
.pages-row.is-template .pages-template-badge { flex-shrink: 0; }
.row-template-label { color: var(--text-muted); }

/* Duplicate flow — subtle inline spinner in the "Duplicating…" toast. */
.pages-dup-spinner {
  display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px;
  border: 2px solid rgba(var(--accent-rgb, 139, 111, 71), 0.25);
  border-top-color: var(--accent, #8b6f47);
  border-radius: 50%;
  animation: pagesDupSpin 0.7s linear infinite;
}
@keyframes pagesDupSpin { to { transform: rotate(360deg); } }

/* Duplicate flow — brief "here I am" flash on the freshly-copied card when the
   done-toast's "Jump to the copy" CTA is clicked. A physical lift + a warm accent
   ring that settles, rather than a flat color wash (stays on the desk metaphor). */
@keyframes pagesCardFlash {
  0%   { transform: translateY(0);    box-shadow: 0 1px 4px rgba(60,50,40,0.08), 0 3px 12px rgba(60,50,40,0.04), 0 0 0 0 rgba(var(--accent-rgb, 139,111,71), 0); }
  18%  { transform: translateY(-5px); box-shadow: 0 8px 22px rgba(60,50,40,0.16), 0 3px 12px rgba(60,50,40,0.06), 0 0 0 3px rgba(var(--accent-rgb, 139,111,71), 0.55); }
  100% { transform: translateY(0);    box-shadow: 0 1px 4px rgba(60,50,40,0.08), 0 3px 12px rgba(60,50,40,0.04), 0 0 0 0 rgba(var(--accent-rgb, 139,111,71), 0); }
}
/* Specificity (0,2,0) to win over .pages-card.is-entering's entrance animation. */
.pages-card.pages-card--flash { animation: pagesCardFlash 1.8s cubic-bezier(0.34, 1.56, 0.64, 1); }
@media (prefers-reduced-motion: reduce) {
  .pages-dup-spinner { animation-duration: 1.4s; }
  .pages-card.pages-card--flash { animation: none; box-shadow: 0 1px 4px rgba(60,50,40,0.08), 0 3px 12px rgba(60,50,40,0.04), 0 0 0 3px rgba(var(--accent-rgb, 139,111,71), 0.55); }
}
/* Optimistic delete: the card fades + shrinks off the desk immediately, then the
   DOM node is removed on transitionend. A rejected delete slots the card back in. */
.pages-card.is-leaving, .pages-row.is-leaving {
  opacity: 0; transform: scale(0.96);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .pages-card.is-leaving, .pages-row.is-leaving { transition: opacity 120ms ease; transform: none; }
}

/* Page draft iframe — crosshair cursor for element targeting */
.page-draft-iframe {
  cursor: crosshair;
}

/* Floating command card over the artifact pane.
   This is the ONLY Companio element that floats over content we don't control.
   Everywhere else cream-on-cream works because we own both layers; over a
   founder's page — dark teal hero, white card, orange CTA — contrast has to be
   guaranteed. So the card is dark, with no border: separation from shadow only. */
.page-comment-input {
  position: absolute; z-index: 50;
  background: #1c1c1e; color: rgba(255,255,255,0.92);
  border-radius: 10px; padding: 10px 12px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.38), 0 2px 8px rgba(0,0,0,0.24);
  width: 300px; max-width: calc(100% - 16px);
  animation: commentSlideIn 0.2s ease-out;
}
@keyframes commentSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.page-comment-label {
  font-size: 11px; color: rgba(255,255,255,0.55); margin-bottom: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--mono, monospace);
}
.page-comment-field {
  flex: 1; padding: 7px 10px; border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.14); background: #2a2a2d;
  font-size: 13px; font-family: var(--sans);
  color: rgba(255,255,255,0.92); outline: none;
}
.page-comment-field:focus {
  border-color: rgba(124,58,237,0.7);
  box-shadow: 0 0 0 2px rgba(124,58,237,0.25);
}
.page-comment-field::placeholder { color: rgba(255,255,255,0.62); }
.page-comment-send {
  padding: 7px 14px; border-radius: 6px;
  background: var(--purple); color: #fff; border: none;
  font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: var(--sans); transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.page-comment-send:hover { background: #6d31d4; transform: translateY(-1px); box-shadow: 0 4px 10px rgba(60,50,40,0.18); }
.page-comment-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }

/* Editable text field (pre-filled with element text). A two-row textarea:
   typing wraps onto the second line instead of scrolling sideways, and past two
   rows the text scrolls inside the field rather than growing the card — the
   card is anchored to an element on the page, so it must keep its height.
   `rows="2"` does the sizing, so there is no magic pixel height to drift. */
.page-comment-text-edit {
  display: block; box-sizing: border-box;
  width: 100%; margin-bottom: 8px; padding: 7px 10px;
  border-radius: 6px; border: 1px solid rgba(255,255,255,0.14);
  background: #2a2a2d; font-size: 13px; font-family: var(--sans);
  line-height: 1.45; resize: none; overflow-y: auto;
  color: rgba(255,255,255,0.92); outline: none;
}
/* Dark card, so the default light scrollbar would flare against it. */
.page-comment-text-edit { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.28) transparent; }
.page-comment-text-edit::-webkit-scrollbar { width: 8px; }
.page-comment-text-edit::-webkit-scrollbar-track { background: transparent; }
.page-comment-text-edit::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.24); border-radius: 4px;
  border: 2px solid transparent; background-clip: content-box;
}
.page-comment-text-edit:focus {
  border-color: rgba(124,58,237,0.7);
  box-shadow: 0 0 0 2px rgba(124,58,237,0.25);
}

/* Action row: Add + Edit text */
.page-comment-actions {
  display: flex; gap: 8px; align-items: center;
}
.page-comment-ai-btn {
  padding: 7px 10px; border-radius: 6px;
  background: transparent; color: rgba(255,255,255,0.82); border: 1px solid rgba(255,255,255,0.22);
  font-size: 11px; font-weight: 500; cursor: pointer;
  font-family: var(--sans); transition: all 0.15s;
}
.page-comment-ai-btn:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.34); }

/* Image swap card (extends page-comment-input) */
.page-image-swap .page-comment-send {
  flex: 1;
}
.page-image-swap-thumb {
  width: 100%; max-height: 120px; object-fit: contain;
  border-radius: 6px; margin-bottom: 8px;
  background: #f5f0e8;
}
.page-image-swap-alt {
  font-size: 11px; color: rgba(255,255,255,0.55); margin-bottom: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.page-image-file-input {
  display: none;
}

/* Pulsing highlight overlay on element being edited */
.page-edit-highlight {
  position: absolute; z-index: 45;
  border: 2px solid rgba(139,111,71,0.5);
  border-radius: 4px;
  pointer-events: none;
  animation: editHighlightPulse 1.5s ease-in-out infinite;
}
@keyframes editHighlightPulse {
  0%, 100% { border-color: rgba(139,111,71,0.5); box-shadow: 0 0 0 0 rgba(139,111,71,0.15); }
  50% { border-color: rgba(139,111,71,0.8); box-shadow: 0 0 12px 2px rgba(139,111,71,0.2); }
}

/* Mini terminal ticker */
.page-edit-ticker {
  position: absolute; z-index: 50;
  background: #1a1208; color: #d4c4a8;
  font-family: 'DM Mono', 'SF Mono', 'Fira Code', monospace;
  font-size: 11px; line-height: 1.4;
  padding: 6px 10px; border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  white-space: nowrap; max-width: 280px; overflow: hidden;
  animation: tickerSlideIn 0.25s ease-out;
}
@keyframes tickerSlideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.ticker-prompt {
  color: #8b6f47; font-weight: 700;
}
.ticker-text {
  color: #d4c4a8;
}
.ticker-cursor {
  color: #8b6f47;
  animation: tickerBlink 0.8s step-end infinite;
  margin-left: 1px;
}
@keyframes tickerBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Deploy button in artifact toolbar */
.pages-deploy-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--sans); font-size: 11px; font-weight: 600;
  color: #fff; background: #8b6f47;
  padding: 5px 12px; border-radius: 6px; border: none;
  cursor: pointer; transition: all 0.15s;
}
.pages-deploy-btn:hover { background: #7a6240; }
.pages-deploy-btn:disabled { opacity: 0.6; cursor: default; }
.pages-deploy-btn svg { flex-shrink: 0; stroke: #fff; }
.deploy-edit-badge {
  font-size: 10px; font-weight: 600;
  background: rgba(255,255,255,0.25); color: #fff;
  padding: 1px 6px; border-radius: 8px;
  margin-left: 2px;
}

/* CRT boot animation — page edit loading state */
.crt-boot {
  position: absolute;
  inset: 0;
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Horizontal light line that expands from center */
.crt-scanline {
  width: 0;
  height: 2px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 20px 4px rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  animation: crt-expand 0.5s ease-out 0.15s forwards;
}

@keyframes crt-expand {
  0%   { width: 0; opacity: 0.5; }
  50%  { width: 80%; height: 2px; opacity: 1; }
  100% { width: 100%; height: 100%; opacity: 0; box-shadow: none; }
}

/* Page title fades in after the scanline expands */
.crt-label {
  position: absolute;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.35);
  text-transform: uppercase;
  opacity: 0;
  animation: crt-label-in 0.4s ease 0.6s forwards;
}

@keyframes crt-label-in {
  to { opacity: 1; }
}

/* Skeleton loading cards */
.pages-skeleton-card { pointer-events: none; }
.pages-skeleton-line {
  height: 12px; border-radius: 6px;
  background: var(--border-light, #e8e0d6);
  animation: kb-pulse 1.2s ease-in-out infinite;
}
.pages-skeleton-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--border-light, #e8e0d6);
  animation: kb-pulse 1.2s ease-in-out infinite 0.2s;
}
/* Empty state */
.pages-empty {
  text-align: center; padding: 64px 32px; color: var(--text-muted);
}
.pages-empty-icon {
  font-size: 48px; display: block; margin-bottom: 16px; opacity: 0.6;
}
.pages-empty p { margin: 0 0 4px; font-size: 15px; }
.pages-empty-hint { font-size: 13px; color: var(--text-muted); }

/* Artifact iframe (HTML preview in artifact pane) */
.artifact-iframe {
  width: 100%; height: 100%; border: none; display: block;
  background: #fff; border-radius: var(--radius);
}

/* Page-CRO heads-up sticky note — fires once on skill_injected for page-cro,
   sets the "this takes 2-3 min" expectation 5-15s into the run. Body stays
   warm/static ("grab a coffee"); status line below updates with each
   tool_call so the user sees real-time progression of the build. */
.page-headsup-wrap {
  /* Sits in the same lane as messages so the sticky-note aligns with the
     agent's bubble. Avatar+gap (32+12=44px) on the left of the lane is the
     agent's "indent" — match it so the sticky-note lines up with the bubble. */
  padding-left: 44px;
  box-sizing: border-box;
}
.page-headsup-stickynote {
  position: relative;
  background: var(--sticky);
  border-radius: 2px;
  padding: 14px 16px 14px 16px;
  margin: 0;
  width: min(300px, 100%);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  color: rgba(60, 50, 40, 0.88);
  transform: rotate(-1deg);
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.08),
    0 1px 2px rgba(0, 0, 0, 0.04);
  animation: pageHeadsupIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.page-headsup-body {
  font-family: var(--sans);
  transition: opacity 0.18s ease;
}
.page-headsup-stickynote.cross-fade .page-headsup-body { opacity: 0; }
.page-headsup-lead {
  font-weight: 500;
  color: rgba(60, 50, 40, 0.95);
  margin-bottom: 2px;
}
.page-headsup-stickynote[data-state="titled"] .page-headsup-lead {
  font-weight: 600;
}
.page-headsup-coffee-line {
  font-size: 12.5px;
  color: rgba(60, 50, 40, 0.78);
}
.page-headsup-status {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(60, 50, 40, 0.18);
  font-size: 11.5px;
  color: rgba(60, 50, 40, 0.65);
  font-style: italic;
  line-height: 1.4;
  transition: opacity 0.2s ease;
  min-height: 1.4em;
}
.page-headsup-status.cross-fade { opacity: 0; }
.page-headsup-status-icon {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(60, 50, 40, 0.45);
  margin-right: 6px;
  vertical-align: middle;
  animation: statusDotPulse 1.4s ease-in-out infinite;
}
@keyframes pageHeadsupIn {
  from { opacity: 0; transform: rotate(-1deg) translateY(-8px); }
  to { opacity: 1; transform: rotate(-1deg) translateY(0); }
}
@keyframes statusDotPulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.3); }
}

/* Page building card (shown while deploy_page tool executes) */
.page-building-card {
  background: #fff; border: 1px solid rgba(139, 111, 71, 0.18);
  border-radius: var(--radius); padding: 16px 18px;
  margin: 8px 0;
  animation: pageBuildIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.page-building-header {
  display: flex; align-items: center; gap: 12px;
}
.page-building-icon {
  color: var(--accent); flex-shrink: 0;
  animation: pageBuildSpin 1.2s linear infinite;
}
.page-building-title {
  font-family: var(--sans); font-weight: 600; font-size: 14px;
  color: var(--text); line-height: 1.3;
}
.page-building-phase {
  font-size: 12px; color: var(--muted); font-weight: 400;
  margin-top: 2px; opacity: 0.7;
  transition: opacity 0.2s ease;
}
.page-building-phase.cross-fade { opacity: 0; }
.page-building-timer {
  position: absolute; top: 14px; right: 16px;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 10px; color: var(--muted); opacity: 0.5;
}
.page-building-card.morphing {
  transform: scale(0.97); opacity: 0; transition: all 0.2s ease;
}
.page-headsup-stickynote.morphing {
  transform: rotate(-1deg) scale(0.97); opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
@keyframes pageBuildSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes pageBuildIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
/* pageBuildPulse and pageBuildProgress removed — replaced by pageBuildSpin */

/* Deployed card entrance (replacing building card) */
.page-deployed-card.page-deployed-entrance {
  animation: pageDeployedReveal 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pageDeployedReveal {
  from { opacity: 0; transform: translateY(-4px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Page deployed card (shown in chat stream) */
.page-deployed-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
  margin: 8px 0;
}
.page-deployed-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.page-deployed-icon { color: var(--accent); flex-shrink: 0; }
.page-deployed-title {
  font-family: var(--serif); font-weight: 600; font-size: 14px;
  color: var(--text); line-height: 1.2;
}
.page-deployed-subtitle { font-size: 12px; color: #059669; font-weight: 500; }
/* Draft variant — brown subtitle + a primary "Make it live" affordance. */
.page-deployed-card.is-preview .page-deployed-subtitle { color: var(--accent); }
.page-deployed-golive {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 6px;
  border: 1px solid var(--accent); background: var(--accent);
  color: #fff; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: background 0.15s, transform 0.12s ease-out;
}
.page-deployed-golive:hover { background: var(--accent-hover); }
.page-deployed-golive:active { transform: scale(0.97); }
.page-deployed-golive:disabled { opacity: 0.7; cursor: default; }
.page-deployed-golive svg { stroke: currentColor; fill: none; flex-shrink: 0; }
.page-deployed-url {
  display: block; font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px; color: var(--accent); text-decoration: none;
  margin-bottom: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.page-deployed-url:hover { text-decoration: underline; }
.page-deployed-actions { display: flex; align-items: center; gap: 12px; }
.page-deployed-copy {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: none;
  color: var(--text-dim); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
}
.page-deployed-copy:hover { background: var(--surface2); color: var(--text); }
.page-deployed-view {
  font-size: 12px; color: var(--text-muted); text-decoration: none;
}
.page-deployed-view:hover { color: var(--accent); text-decoration: underline; }
.page-deployed-audit {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--accent);
  background: rgba(var(--accent-rgb, 139, 111, 71), 0.08);
  color: var(--accent); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: background 0.15s, transform 0.12s ease-out;
}
.page-deployed-audit:hover { background: rgba(var(--accent-rgb, 139, 111, 71), 0.15); }
.page-deployed-audit:active { transform: scale(0.97); }
.page-deployed-audit:disabled { opacity: 0.55; cursor: default; }

/* Ad batch card warnings line */
.ad-batch-warnings {
  font-size: 12px; color: var(--amber); margin-bottom: 10px; font-weight: 500;
}

/* ==================================================================
   PAGES COLUMN VIEW — folders | pages | preview
   ==================================================================
   A Finder column browser. Flat rows on a shared surface: no card wrapper, no
   repeated hint text, hairlines instead of borders-on-boxes. Every measurement
   here comes from .claude/prototypes/pages-columns-v3.html, which is the
   signed-off visual contract — change it there first.
   ================================================================== */

/* The surface stops being one scrolling document: each column scrolls itself, so
   the folder list never scrolls away from the page list. */
.page-pages.is-columns { overflow: hidden; }
.page-pages.is-columns .folder-tabs-wrap { display: none; }
.page-pages.is-columns .pages-page-body {
  flex: 1; min-height: 0; padding: 0;
  display: flex; flex-direction: column;
}

.pages-columns {
  /* Live geometry — the splitters move these. */
  --w-folders: 248px;
  --w-pages: 324px;
  /* Small secondary text. --text-muted is only ~3.9:1 at these sizes on these
     surfaces — under the 4.5:1 floor — and drops to 3.4:1 on a selected row.
     This tone clears 4.5:1 in all four combinations. Hierarchy below the title
     is carried by size and weight, not by fading the text past legibility. */
  --pcol-muted: #6f6a64;
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: var(--w-folders) 1px var(--w-pages) 1px minmax(0, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border-light);
}

.pcol { min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.pcol-folders { background: #fbfaf8; }
.pcol-pages { background: #fdfcfa; }
.pcol-preview { background: var(--surface2); }

/* 1px hairline with a 9px grab zone, Finder-style — the seam you can actually hit. */
.pcol-splitter { position: relative; background: var(--border-light); cursor: col-resize; }
.pcol-splitter::after { content: ''; position: absolute; inset: 0 -4px; z-index: 4; }
.pcol-splitter:hover, .pcol-splitter.is-dragging { background: rgba(139, 111, 71, 0.45); }

/* Column headers — quiet, uppercase, one rhythm unit tall. */
.pcol-head {
  display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 12px 0 16px; flex-shrink: 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--pcol-muted); white-space: nowrap; overflow: hidden;
}
.pcol-head-label { overflow: hidden; text-overflow: ellipsis; }
.pcol-head-count {
  margin-left: auto; padding-left: 8px;
  font-size: 11px; font-weight: 600; letter-spacing: 0; text-transform: none;
  font-variant-numeric: tabular-nums; color: var(--pcol-muted); flex-shrink: 0;
}
.pcol-scroll { flex: 1; overflow-y: auto; padding: 6px; }

/* ---- Flat row, shared by folders and pages ---- */
.pcol-row {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px 7px 10px; border-radius: 8px;
  cursor: default; user-select: none;
  transition: background .12s, transform .18s var(--spring), box-shadow .18s;
}
.pcol-row:hover { background: rgba(60, 50, 40, 0.045); }
.pcol-row.is-selected { background: var(--accent-dim); }
.pcol-row.is-selected .pcol-row-name { color: var(--text); font-weight: 600; }
.pcol-row.is-selected .pcol-row-icon { color: var(--accent); opacity: 1; }
.pcol-row.is-offline { opacity: .72; }
.pcol-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.pcol-row-icon { color: var(--manila-text); opacity: .8; flex-shrink: 0; display: flex; }
/* Same filled star the grid's Templates tab uses — one mark for one idea. */
.pcol-row-folder.is-templates .pcol-row-icon svg { fill: rgba(139,111,71,0.16); }
.pcol-row-folder.is-templates.is-selected .pcol-row-icon svg { fill: rgba(139,111,71,0.28); }
.pcol-row-name {
  flex: 1; min-width: 0;
  font-size: 13px; font-weight: 500; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pcol-row-count {
  font-size: 11px; font-weight: 600; color: var(--pcol-muted);
  font-variant-numeric: tabular-nums; flex-shrink: 0; min-width: 18px; text-align: right;
  transition: opacity .13s;
  /* Load-bearing. The count occupies the same box as the hover controls that
     replace it; without this it silently swallows the ⋯ click while right-click
     still works, which reads exactly like a broken handler. */
  pointer-events: none;
}
.pcol-row:hover .pcol-row-count,
.pcol-row.menu-open .pcol-row-count { opacity: 0; }

/* The hover controls take the count's place rather than sitting beside it. As
   flex children they would reserve ~32px of every row forever and truncate the
   folder names even while invisible — so they are absolutely positioned.
   --pcol-row-rgb is the row's resolved background, per column and state, so the
   controls sit on solid colour with a soft fade a long name slides under. */
.pcol-folders .pcol-row { --pcol-row-rgb: 251 250 248; }
.pcol-folders .pcol-row:hover { --pcol-row-rgb: 242 241 239; }
.pcol-folders .pcol-row.is-selected,
.pcol-folders .pcol-row.is-selected:hover { --pcol-row-rgb: 240 236 230; }
.pcol-pages .pcol-row { --pcol-row-rgb: 253 252 250; }
.pcol-pages .pcol-row:hover { --pcol-row-rgb: 244 243 241; }
.pcol-pages .pcol-row.is-selected,
.pcol-pages .pcol-row.is-selected:hover { --pcol-row-rgb: 242 238 232; }

.pcol-row-actions {
  position: absolute; right: 4px; top: 1px; bottom: 1px; z-index: 3;
  display: flex; align-items: center; gap: 1px;
  padding-left: 20px; padding-right: 2px; border-radius: 0 7px 7px 0;
  background: linear-gradient(to right, rgb(var(--pcol-row-rgb) / 0) 0, rgb(var(--pcol-row-rgb)) 20px);
  opacity: 0; transition: opacity .13s;
}
.pcol-row:hover .pcol-row-actions,
.pcol-row.menu-open .pcol-row-actions,
.pcol-row-actions:focus-within { opacity: 1; }

.pcol-row-btn {
  width: 24px; height: 24px; padding: 0;
  display: grid; place-items: center;
  border: 1px solid transparent; background: none; border-radius: 6px;
  color: var(--text-muted); cursor: pointer;
  transition: background .13s, color .13s, box-shadow .13s, border-color .13s;
}
/* A physical key on hover — solid surface, hairline, lift. Never a grey wash. */
.pcol-row-btn:hover {
  background: var(--surface); border-color: var(--border);
  color: var(--text); box-shadow: 0 1px 2px rgba(60, 50, 40, 0.10);
}
.pcol-row-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pcol-row.menu-open .pcol-row-btn.is-menu { background: rgba(60, 50, 40, 0.08); color: var(--text); }

/* Drop target — physical lift plus an accent ring. Never a colour flash. */
.pcol-row.drag-over {
  transform: translateY(-1px);
  background: var(--manila-open);
  box-shadow: 0 0 0 1.5px rgba(139, 111, 71, 0.5), 0 3px 10px rgba(60, 50, 40, 0.10);
}
.pcol-row.dragging { opacity: .35; }

.pcol-rename-input {
  flex: 1; min-width: 0;
  font-family: var(--sans); font-size: 13px; font-weight: 500; color: var(--text);
  background: var(--surface);
  border: 1px solid rgba(139, 111, 71, 0.5); border-radius: 6px;
  padding: 3px 7px; outline: none; box-shadow: 0 0 0 3px rgba(139, 111, 71, 0.10);
}

/* ---- Page rows: thumbnail + three stacked facts ---- */
/* The pencil's width is reserved permanently in the padding — swapping it in on
   hover would reflow the title mid-hover, which reads as jitter. */
.pcol-row-page { padding: 9px 30px 9px 8px; gap: 10px; }
.pcol-thumb {
  width: 54px; height: 39px; flex-shrink: 0; align-self: center;
  border-radius: 4px; overflow: hidden; position: relative;
  background: #f6f2ea; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}
/* Stylised, not a live render: at 54px a real page is mush, and ten more iframes
   buy nothing. The band carries the page's own brand colour so rows stay
   distinguishable at a glance. */
.pcol-thumb-band { position: absolute; inset: 0 0 62% 0; background: var(--ph, var(--manila)); }
.pcol-thumb-lines { position: absolute; left: 4px; right: 4px; top: 45%; }
.pcol-thumb-lines i {
  display: block; height: 2px; border-radius: 1px;
  background: rgba(60, 50, 40, 0.16); margin-bottom: 2.5px;
}

/* Title and slug are one identity unit (tight); status is a different class of
   information, so it gets the wider gap. Rhythm: 3px inside, 5px between. */
.pcol-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pcol-row-title {
  font-size: 12.5px; font-weight: 600; line-height: 1.25; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Regular weight against the title's 600: the address is how you tell two
   similarly-named pages apart, not something to read first, and matching the
   title's weight made the two lines compete.
   Darker than the status line below it, and deliberately so: three lines at two
   tones read as a title plus one grey block. The ramp can only be built this way
   round — the status line is already 4.63:1 on a selected row, so it cannot be
   faded to make room. Weight and size keep the slug off the title (400/11px
   against 600/12.5px). Don't "simplify" either line to --text-muted; see the
   --pcol-muted note above. */
.pcol-row-slug {
  margin-top: 3px;
  font-size: 11px; font-weight: 400; line-height: 1.2; color: var(--text-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pcol-row-sub {
  margin-top: 5px;
  display: flex; align-items: center; gap: 5px;
  font-size: 10.5px; line-height: 1.2; color: var(--pcol-muted);
  white-space: nowrap; overflow: hidden;
}
/* The shared 7px dot is sized for the grid's 12px status text. Against this
   row's 10.5px it stands 92% of the cap height — a circle nearly as tall as the
   capitals reads as a bullet, not a state marker, and makes every sub-pixel of
   misalignment obvious. 6px restores the grid's dot-to-cap proportion.
   No `top` nudge: measured against the real cap-height midpoint (baseline via an
   off-flex strut replica, cap via canvas ink metrics), flex centring lands within
   0.12px on its own. The half-pixel that used to live here pushed it visibly high. */
.pcol-row-sub .pages-status-dot { width: 6px; height: 6px; }
/* Per the prototype the label stays muted and only the dot carries the state
   colour — a row of green words would shout louder than the page titles. */
.pcol-row-sub .pages-status {
  display: inline-flex; align-items: center; gap: 5px; min-width: 0;
  margin: 0; color: inherit; font-size: inherit;
}
/* "changes to publish" earns its width — a founder who thinks their edits are
   already live is the expensive mistake this line prevents. */
.pcol-row-sub .pages-status-pending { white-space: nowrap; }

/* ---- Preview column ---- */
.pcol-preview-head {
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 12px 0 16px; flex-shrink: 0;
  border-bottom: 1px solid var(--border-light); background: var(--surface);
}
/* The title is the page's identity and gives ground last. Everything to its
   right is secondary, so the status line truncates first — a clipped "changes
   to publish" still reads; a clipped page name doesn't tell you which page. */
.pcol-preview-title {
  flex: 0 1 auto; min-width: 140px;
  /* Capped so a long page name can't push the state and the actions off the
     toolbar. Past this the founder is reading the same words they just clicked
     in the column — the tooltip carries the rest. */
  max-width: 320px;
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Click-to-rename. A dotted underline on hover only — the title must not read as
   a button at rest, or the header stops looking like a header. Physical lift is
   wrong here: this text is set into the toolbar, not sitting on it. */
.pcol-preview-title.is-editable { cursor: text; border-radius: 4px; padding: 1px 4px; margin: -1px -4px; transition: background .12s, box-shadow .12s; }
.pcol-preview-title.is-editable:hover { background: rgba(139,111,71,0.07); text-decoration: underline dotted rgba(139,111,71,0.55); text-underline-offset: 3px; }
.pcol-preview-title.is-editable:focus-visible { outline: none; background: rgba(139,111,71,0.07); box-shadow: 0 0 0 2px rgba(139,111,71,0.45); }
/* The rename input inherits the title's cap so a long name can't blow the
   toolbar open mid-edit; it just scrolls inside the field. */
.pcol-title-input { flex: 0 1 auto; min-width: 140px; max-width: 320px; font-size: 13px; font-weight: 600; }
/* Never shrinks. It sheds whole pieces at the thresholds below instead, because
   half a word of state ("changes to pu…") is worse than no word: the founder
   can't tell what it said. The title absorbs the squeeze instead — it is the
   one thing here that still reads when clipped. */
.pcol-preview-status {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-muted);
  white-space: nowrap;
}
/* `.pages-status` carries `margin-bottom: 8px` for the grid card, where it sits
   in a stack. Here it is a flex item in a centred row, so that margin is part of
   the box being centred and lifted the state 4px above the title and the byline.
   Font size too, or "Draft" renders a size larger than the "· 1w ago" beside it. */
.pcol-preview-status .pages-status { margin: 0; font-size: inherit; }
/* Same story as the column row: the shared 7px dot is sized for 12px text. */
.pcol-preview-status .pages-status-dot { width: 6px; height: 6px; }
.pcol-preview-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.pcol-preview-actions .pages-action-btn { margin: 0; }
/* Square, so a bare icon sits centred instead of floating in a pill sized for
   text. Fixed width keeps the row from twitching when Copy URL flips to a check. */
.pages-action-btn.is-icon {
  gap: 0; padding: 4px; width: 27px; justify-content: center;
}
/* `scrollbar-gutter: stable`, not `overflow: auto` alone. macOS overlay bars cost
   no layout width, but a classic scrollbar appearing on a long page and vanishing
   on a short one changes the stage's client width — and the paper is sized from
   it, so every page change would resize the sheet. Reserve the gutter always. */
.pcol-preview-stage {
  flex: 1; overflow: auto; scrollbar-gutter: stable;
  background: var(--surface2); padding: 16px;
}

/* The page sits on paper: white, lifted, centred in whatever width is left. */
.pcol-paper {
  position: relative; margin: 0 auto;
  background: #fff; border-radius: 8px; overflow: hidden;
  box-shadow: var(--shadow-md);
}
/* pointer-events: none because this is a picture of the page, not the page. A
   srcdoc frame resolves relative URLs against THIS document, so clicking any
   `href="#"`, `href="/"` or in-page anchor navigated the frame to the Companio
   app itself — the preview pane filled with a dead copy of the app. Same guard
   the grid thumbs use (.pages-thumb iframe). Wheel events fall through to the
   stage, which is what scrolls, so the preview still scrolls normally. */
.pcol-paper iframe {
  border: 0; display: block; background: #fff;
  transform-origin: top left; pointer-events: none;
}

/* ---- Loading skeleton ---- */
/* Stands on the same paper, at the same width and scale, so the arriving page
   swaps its contents rather than changing its shape. The hero band carries the
   page's own colour — the same `--ph` the grid tile uses — so even the wait is
   this page and not a generic spinner. */
.pcol-paper-loading { overflow: hidden; }
.pcol-sk-hero {
  height: 26%; min-height: 90px;
  background: var(--ph, var(--accent));
  opacity: 0.5;
}
.pcol-sk-body { padding: 7% 9% 0; display: flex; flex-direction: column; gap: 14px; }
.pcol-sk-body i, .pcol-sk-cards b {
  display: block; border-radius: 6px; background: var(--border-light);
}
.pcol-sk-body i { height: 14px; }
.pcol-sk-cards { display: flex; gap: 3%; margin-top: 10px; }
.pcol-sk-cards b { flex: 1; height: 96px; border-radius: 10px; }
/* One breath across the whole sheet rather than a shimmer sweeping over it: the
   desk doesn't have things that glint. */
.pcol-paper-loading > * { animation: pcol-sk-breathe 1.6s ease-in-out infinite; }
@keyframes pcol-sk-breathe { 0%, 100% { opacity: 0.5; } 50% { opacity: 0.85; } }
@media (prefers-reduced-motion: reduce) {
  .pcol-paper-loading > * { animation: none; }
}

/* The default drag image is a snapshot of the row, which carries no background
   of its own — so the ghost let the desk and every row it passed show straight
   through it. This is the opaque copy handed to setDragImage instead. */
.pcol-row-ghost {
  position: fixed; top: -2000px; left: -2000px;
  pointer-events: none; opacity: 1;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow-md);
}

/* ---- Cold-load skeleton (the whole surface, before any data) ---- */
/* Same widths and same row heights as the real thing, so the tab settles into
   place instead of rearranging itself once the data lands. */
.pages-columns-skeleton .pcol-scroll { padding: 6px; }
.pcol-sk-row { display: flex; align-items: center; }
.pcol-sk-row-folder { height: 30px; gap: 8px; padding: 0 8px; }
.pcol-sk-row-page { height: 67px; gap: 10px; padding: 0 8px; }
.pcol-sk-row i {
  display: block; height: 9px; border-radius: 5px;
  background: var(--border-light);
}
.pcol-sk-thumb {
  width: 54px; height: 39px; flex-shrink: 0; border-radius: 4px;
  background: var(--border-light);
}
.pcol-sk-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.pages-columns-skeleton .pcol-sk-row { animation: pcol-sk-breathe 1.6s ease-in-out infinite; }
.pages-columns-skeleton .pcol-sk-row:nth-child(even) { animation-delay: 0.18s; }
@media (prefers-reduced-motion: reduce) {
  .pages-columns-skeleton .pcol-sk-row { animation: none; }
}


/* Says out loud that the preview is scaled, so nobody reads a shrunken hero as
   a layout bug. Tabular so it doesn't jitter while a splitter is dragged. */
.pcol-zoom {
  font-size: 10.5px; color: var(--text-muted); font-variant-numeric: tabular-nums;
  padding-right: 8px; border-right: 1px solid var(--border-light); white-space: nowrap;
}
.pcol-more {
  width: 28px; height: 26px; padding: 0;
  display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); color: var(--text-muted); cursor: pointer;
  transition: transform .15s var(--spring), box-shadow .15s;
}
.pcol-more:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }

/* Byline — metadata, so it sits with the title and status on the left, not among
   the actions on the right. It answers "who made this", which varies per page;
   "who can see this" is the same team on every page and says nothing. */
.pcol-byline {
  display: inline-flex; align-items: center; gap: 5px; margin-left: 3px;
  color: var(--text-muted); cursor: default; white-space: nowrap;
}
.pcol-byline::before { content: '·'; margin-right: 2px; color: var(--text-muted); }
.pcol-avatar {
  width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 9px; font-weight: 700; letter-spacing: .02em; color: #fff;
  background: var(--accent);
}
.pcol-avatar[data-tone="1"] { background: #5f8a6e; }
.pcol-avatar[data-tone="2"] { background: #7a6a92; }
.pcol-avatar[data-tone="3"] { background: #3d7a8c; }

/* The toolbar gives things up in priority order rather than shaving every item
   at once — a row of half-truncated labels reads as broken. Keyed to the
   preview column's own width, not the window's: dragging the splitter narrow
   should degrade it exactly like a small screen does. */
.pcol-preview { container-type: inline-size; container-name: pcolpreview; }
/* Each threshold is the width at which the piece below it would otherwise start
   to ellipsise, measured against the worst case: a long title, a live page with
   unpublished edits, and a teammate's byline. Re-measure if the toolbar gains a
   control — these are not round numbers by accident.
   The zoom readout goes first: it explains the preview, it isn't the preview. */
@container pcolpreview (max-width: 1023px) {
  .pcol-zoom { display: none; }
}
@container pcolpreview (max-width: 953px) {
  /* Goes before the byline, not after: the page's own row in the middle column
     carries "changes to publish" at every width, so nothing is lost here — while
     the creator appears nowhere but this toolbar. */
  .pcol-preview-status .pages-status-pending { display: none; }
}
@container pcolpreview (max-width: 808px) {
  /* The name goes, the avatar stays — it is tone-coded per teammate and the
     tooltip spells it out, so "who made this" survives all the way down. */
  .pcol-byline-name { display: none; }
}
@container pcolpreview (max-width: 583px) {
  /* Measured at 545 when the toolbar held four actions; the save-as-template
     star adds a rigid 27px + 6px gap at every width, so all four thresholds
     above shifted by exactly 33px. Down here the title and the five actions are
     all that survive. */
  .pcol-preview-status { display: none; }
}

/* ---- Shared bits ---- */
/* One quiet line, never a half-screen billboard. */
.pcol-empty {
  flex: 1; display: grid; place-items: center; padding: 24px;
  font-size: 12.5px; line-height: 1.6; color: var(--text-muted); text-align: center;
}
.pcol-add {
  display: flex; align-items: center; gap: 8px;
  width: calc(100% - 12px); margin: 2px 6px 6px;
  padding: 7px 10px; border-radius: 8px; border: none; background: none;
  font-family: var(--sans); font-size: 12.5px; font-weight: 500; color: var(--text-muted);
  cursor: pointer; transition: background .12s, color .12s;
}
.pcol-add:hover { background: rgba(60, 50, 40, 0.045); color: var(--text-dim); }

/* Delete confirm, rendered into the ⋯ menu in place of its items. */
.pcol-confirm { padding: 8px 10px 4px; }
.pcol-confirm p { margin: 0 0 10px; font-size: 12px; line-height: 1.5; color: var(--text-dim); }
.pcol-confirm-note { color: var(--text-muted); font-size: 11.5px; }
.pcol-confirm-btns { display: flex; gap: 6px; justify-content: flex-end; }
.pcol-confirm-btn {
  padding: 5px 11px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--sans); font-size: 11.5px; font-weight: 600; color: var(--text-dim);
  cursor: pointer; transition: transform .15s var(--spring), box-shadow .15s;
}
.pcol-confirm-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.pcol-confirm-btn.is-danger { background: var(--red); border-color: var(--red); color: #fff; }
.pcol-menu { min-width: 194px; }

/* ---- View toggle (control bar) ---- */
.pages-view-toggle {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 10px;
}
.pages-view-toggle button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 28px; border: none; background: none; border-radius: 7px;
  color: var(--text-muted); cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.pages-view-toggle button:hover { color: var(--text-dim); }
.pages-view-toggle button.is-active {
  background: var(--surface); color: var(--accent);
  box-shadow: 0 1px 2px rgba(60, 50, 40, 0.10);
}

/* ==================================================================
   BRAND SWATCH CARD — visual brand summary after extraction
   ================================================================== */

.brand-swatch-card {
  background: var(--surface); border: 1px solid rgba(139, 111, 71, 0.18);
  border-radius: 16px; overflow: clip;
  box-shadow: 2px 3px 12px rgba(60, 50, 40, 0.08);
  margin: 8px 0;
}
.brand-swatch-header {
  padding: 20px 24px; display: flex; align-items: center; gap: 14px;
  border-bottom: 1px solid var(--border-light, rgba(175, 170, 162, 0.12));
}
.brand-swatch-logo {
  width: 40px; height: 40px; border-radius: 8px; background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0; border: 1px solid var(--border-light, rgba(175, 170, 162, 0.15));
}
.brand-swatch-logo img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.brand-swatch-identity { flex: 1; min-width: 0; }
.brand-swatch-name {
  font-family: var(--serif); font-size: 18px; font-weight: 600;
  color: var(--text); overflow-wrap: break-word;
}
.brand-swatch-profile-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand-swatch-profile-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 2px;
}
.brand-swatch-tagline { font-size: 12px; color: var(--text-muted); }

.brand-swatch-colors { display: flex; }
.brand-swatch-chip {
  flex: 1; padding: 28px 16px 14px; display: flex; flex-direction: column;
  justify-content: flex-end; align-items: flex-start; min-height: 100px;
}
.brand-swatch-chip.light-text { color: #FAF7F2; }
.brand-swatch-chip.dark-text { color: #302e2b; }
.brand-swatch-chip-name {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  opacity: 0.7; margin-bottom: 2px;
}
.brand-swatch-chip-hex {
  font-size: 11px; font-family: 'SF Mono', 'Fira Code', monospace; opacity: 0.5;
}

.brand-swatch-assetstrip {
  padding: 16px 24px; display: flex; gap: 28px; flex-wrap: wrap;
  border-top: 1px solid var(--border-light, rgba(175, 170, 162, 0.12));
}
.brand-swatch-asset-group { display: flex; flex-direction: column; gap: 8px; }
.brand-swatch-asset-grouplabel {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted);
}
.brand-swatch-assets, .brand-swatch-stylerefs { display: flex; gap: 8px; align-items: flex-start; }
.brand-swatch-asset { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.brand-swatch-asset-thumb {
  width: 46px; height: 46px; border-radius: 8px; overflow: hidden; flex-shrink: 0;
  background: var(--surface2); border: 1px solid var(--border-light, rgba(175, 170, 162, 0.15));
}
.brand-swatch-asset-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-swatch-asset-thumb.is-logo img { object-fit: contain; padding: 4px; }
.brand-swatch-asset-role {
  font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
}
.brand-swatch-styleref {
  width: 46px; height: 46px; border-radius: 8px; overflow: hidden; flex-shrink: 0;
  background: var(--surface2); border: 1px solid var(--border-light, rgba(175, 170, 162, 0.15));
}
.brand-swatch-styleref img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-swatch-styleref-more {
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
}

.brand-swatch-footer {
  padding: 16px 24px; display: flex; justify-content: space-between; align-items: flex-start;
}
.brand-swatch-type-row { display: flex; gap: 24px; }
.brand-swatch-type-item { display: flex; flex-direction: column; gap: 4px; }
.brand-swatch-type-label {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted);
}
.brand-swatch-type-demo-heading {
  font-family: var(--serif); font-size: 16px; font-weight: 600; color: var(--text);
}
.brand-swatch-type-demo-body { font-family: var(--sans); font-size: 14px; color: var(--text-dim); }

.brand-swatch-mood-col { text-align: right; }
.brand-swatch-mood-label {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); margin-bottom: 6px;
}
.brand-swatch-mood-tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.brand-swatch-mood-tag {
  font-size: 11px; color: var(--text-dim); background: var(--surface2);
  padding: 3px 10px; border-radius: 16px;
}

.brand-swatch-source {
  padding: 10px 24px; background: var(--surface2);
  border-top: 1px solid var(--border-light, rgba(175, 170, 162, 0.1));
  font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 6px;
}
.brand-swatch-source svg { opacity: 0.5; }

.brand-swatch-card.brand-swatch-entrance {
  animation: pageDeployedReveal 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Ad-style override variant — same shape as brand swatch but with a label
   stating ad-only scope. The brand isn't really changing, just the ad style. */
.ad-style-override-card .ad-style-override-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.ad-style-override-source {
  font-style: italic;
}

/* ==================================================================
   CONSOLE PAGE — Workspace connections plus platform administration
   ================================================================== */

.page-console { flex-direction: column; background: var(--bg); }
.console-page-body { flex: 1; overflow-y: auto; padding: 32px 24px; }

.console-layout { max-width: 900px; margin: 0 auto; width: 100%; }

/* Console header */
.console-header {
  margin-bottom: 28px;
}
.console-header h1 {
  font-size: 26px; font-weight: 700; color: var(--text);
  letter-spacing: -0.02em;
}
.console-header p {
  font-size: 14px; color: var(--text-muted); margin-top: 4px;
}

/* Top-level tabs */
.console-tabs {
  display: flex; gap: 4px; margin-bottom: 28px;
  border-bottom: 1px solid var(--border); padding-bottom: 0;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
}
.console-tab {
  display: flex; align-items: center; gap: 7px;
  flex: 0 0 auto;
  padding: 10px 18px; font-size: 14px; font-weight: 500;
  color: var(--text-dim); background: none; border: none;
  border-bottom: 2px solid transparent; cursor: pointer;
  transition: all 0.15s; margin-bottom: -1px;
}
.console-tab svg { opacity: 0.5; transition: opacity 0.15s; }
.console-tab:hover { color: var(--text); }
.console-tab:hover svg { opacity: 0.8; }
.console-tab.active {
  color: var(--accent); border-bottom-color: var(--accent); font-weight: 600;
}
.console-tab.active svg { opacity: 1; stroke: var(--accent); }
/* A connection went quiet — the tab asks for attention on an ordinary visit,
   so nobody has to suspect something is wrong before looking. */
.console-tab-attention { position: relative; }
.console-tab-attention::after {
  content: ''; position: absolute; top: 8px; right: 9px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--amber);
}

/* Global subagent registry */
.subagent-template-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin: 4px 0 20px; color: var(--text-muted); font-size: 12px;
}
.subagent-settings-panel > .subagent-settings-summary {
  cursor: pointer; list-style: none; border-bottom: 0;
}
.subagent-settings-summary::-webkit-details-marker { display: none; }
.subagent-settings-summary::marker { content: ''; }
.subagent-settings-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.subagent-settings-summary-copy { flex: 1; min-width: 0; }
.subagent-settings-summary-copy h3 { margin: 0; }
.subagent-settings-summary-copy span {
  display: block; margin-top: 3px; color: var(--text-muted); font-size: 11px;
}
.subagent-settings-summary-action { color: var(--text-muted); font-size: 11px; }
.subagent-settings-chevron {
  width: 8px; height: 8px; flex: none;
  border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg);
  transition: transform 180ms cubic-bezier(0.23, 1, 0.32, 1);
}
.subagent-settings-panel[open] > .subagent-settings-summary { border-bottom: 1px solid var(--border); }
.subagent-settings-panel[open] > .subagent-settings-summary .subagent-settings-chevron { transform: rotate(45deg); }
.subagent-settings-panel > .subagent-settings-body { padding-block: 0; }
.subagent-settings-section { padding: 18px 0 20px; }
.subagent-settings-section + .subagent-settings-section { border-top: 1px solid var(--border); }
.subagent-settings-section-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin-bottom: 14px;
}
.subagent-settings-section-header h4 { margin: 0; color: var(--text); font-size: 13px; font-weight: 600; }
.subagent-settings-section-header p { margin: 3px 0 0; color: var(--text-muted); font-size: 11px; }
.subagent-settings-section .setting-group:last-child { margin-bottom: 0; }
.subagent-orchestration-state {
  display: inline-flex; align-items: center; padding: 3px 8px;
  border: 1px solid var(--border); border-radius: 999px; font-size: 10px;
}
.subagent-orchestration-state.is-default { color: var(--text-muted); background: var(--surface2); }
.subagent-orchestration-state.is-overridden { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
.subagent-policy-label-row { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.subagent-policy-label-row > label { margin: 0; }
.subagent-policy-help { position: relative; }
.subagent-policy-help > summary {
  width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 50%; color: var(--text-muted);
  background: var(--surface); cursor: help; font: 600 11px/1 var(--sans);
  list-style: none;
}
.subagent-policy-help > summary::-webkit-details-marker { display: none; }
.subagent-policy-help > summary::marker { content: ''; }
.subagent-policy-help > summary:hover,
.subagent-policy-help > summary:focus-visible,
.subagent-policy-help[open] > summary { color: var(--text); border-color: var(--text-muted); background: var(--surface2); }
.subagent-policy-help > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.subagent-policy-help-panel {
  position: absolute; z-index: 20; top: 26px; left: 0;
  width: min(560px, calc(100vw - 72px)); padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
}
.subagent-policy-help-panel h5 { margin: 0 0 10px; color: var(--text); font-size: 12px; }
.subagent-policy-help-panel ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.subagent-policy-help-panel li { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px; }
.subagent-policy-help-panel strong { color: var(--text); font-size: 11px; }
.subagent-policy-help-panel span,
.subagent-policy-help-panel p { color: var(--text-muted); font-size: 11px; line-height: 1.45; }
.subagent-policy-help-panel p { margin: 11px 0 0; padding-top: 10px; border-top: 1px solid var(--border); }
.subagent-prompt-structure {
  display: grid; gap: 6px;
  margin: 0 0 10px;
}
.subagent-prompt-section {
  min-width: 0; border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface2); overflow: hidden;
}
.subagent-prompt-section.is-editable { border-color: var(--accent); background: var(--accent-dim); }
.subagent-prompt-section > summary {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  min-width: 0; padding: 9px 32px 9px 10px; cursor: pointer; list-style: none;
  position: relative;
}
.subagent-prompt-section > summary::-webkit-details-marker { display: none; }
.subagent-prompt-section > summary::marker { content: ''; }
.subagent-prompt-section > summary::after {
  content: ''; position: absolute; top: 13px; right: 12px; width: 6px; height: 6px;
  border-right: 1.5px solid var(--text-muted); border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(45deg); transition: transform 0.15s ease;
}
.subagent-prompt-section[open] > summary::after { transform: rotate(225deg); top: 16px; }
.subagent-prompt-section > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.subagent-prompt-section > summary span { display: grid; gap: 2px; min-width: 0; }
.subagent-prompt-section > summary strong { color: var(--text); font-size: 11px; font-weight: 600; }
.subagent-prompt-section > summary small { color: var(--text-muted); font-size: 10px; line-height: 1.35; }
.subagent-prompt-section > summary em {
  flex: 0 0 auto; color: var(--text-muted); font-size: 9px; font-style: normal;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
.subagent-prompt-section.is-editable > summary em { color: var(--accent); }
.subagent-prompt-section-body { padding: 10px; border-top: 1px solid var(--border); background: var(--surface); }
.subagent-prompt-section-body > p { margin: 0 0 8px; color: var(--text-muted); font-size: 11px; line-height: 1.45; }
.subagent-prompt-section-body > p:last-child { margin-bottom: 0; }
.subagent-prompt-section-body pre {
  max-height: 320px; margin: 0; padding: 10px; overflow: auto; white-space: pre-wrap;
  overflow-wrap: anywhere; border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); background: var(--surface2); font: 11px/1.5 var(--mono);
}
.subagent-catalog-sources { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.subagent-catalog-sources li { display: grid; grid-template-columns: minmax(120px, 0.35fr) minmax(0, 1fr) auto; gap: 8px; align-items: start; }
.subagent-catalog-sources code { color: var(--text); font-size: 10px; overflow-wrap: anywhere; }
.subagent-catalog-sources span { color: var(--text-muted); font-size: 10px; line-height: 1.4; }
.subagent-catalog-sources em { color: var(--text-dim); font-size: 9px; font-style: normal; }
#subagent-orchestration-policy.is-default {
  color: var(--text-dim); background: var(--surface2); border-style: dashed;
}
#subagent-orchestration-policy.is-default:focus { color: var(--text); background: var(--surface); border-style: solid; }
.subagent-orchestration-source { font-weight: 500; }
.subagent-vetting-panel { margin-bottom: 18px; }
.subagent-vetting-panel > .subagent-vetting-summary {
  cursor: pointer; list-style: none; border-bottom: 0;
}
.subagent-vetting-summary::-webkit-details-marker { display: none; }
.subagent-vetting-summary::marker { content: ''; }
.subagent-vetting-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.subagent-vetting-summary > div { flex: 1; min-width: 0; }
.subagent-vetting-chevron {
  width: 8px; height: 8px; flex: none;
  border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg); transition: transform 180ms cubic-bezier(0.23, 1, 0.32, 1);
}
.subagent-vetting-panel[open] > .subagent-vetting-summary { border-bottom: 1px solid var(--border); }
.subagent-vetting-panel[open] > .subagent-vetting-summary .subagent-vetting-chevron { transform: rotate(45deg); }
.subagent-vetting-queue { display: block; margin-top: 3px; color: var(--text-muted); font-size: 10px; }
.subagent-vetting-warning { margin: 0 0 12px; color: var(--text-dim); font-size: 12px; line-height: 1.5; }
.subagent-vetting-status { min-height: 16px; margin: 0; color: var(--text-muted); font-size: 11px; }
.subagent-vetting-empty { margin: 0; color: var(--text-muted); font-size: 12px; }
.subagent-vetting-group { margin-top: 12px; }
.subagent-vetting-group h4 {
  margin: 0 0 6px; color: var(--text-muted); font-size: 10px; font-weight: 600;
  letter-spacing: 0.05em; text-transform: uppercase;
}
.subagent-vetting-group.is-review h4 { color: var(--warn-amber); }
.subagent-vetting-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px;
  align-items: center; padding: 9px 0; border-top: 1px solid var(--border);
}
.subagent-vetting-tool { min-width: 0; }
.subagent-vetting-tool > div:first-child { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.subagent-vetting-tool code { color: var(--text); font-size: 11px; overflow-wrap: anywhere; }
.subagent-vetting-tool small { display: block; margin-top: 3px; color: var(--text-muted); font-size: 10px; }
.subagent-safety-source { color: var(--text-muted); font-size: 10px; white-space: nowrap; }
.subagent-annotation-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.subagent-annotation-badge {
  display: inline-flex; padding: 2px 5px; border-radius: 999px;
  color: var(--accent); background: var(--accent-dim); font-size: 9px;
}
.subagent-safety-control { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.subagent-safety-control button {
  padding: 5px 7px; border: 0; border-left: 1px solid var(--border);
  color: var(--text-muted); background: var(--surface); font-size: 10px; cursor: pointer;
}
.subagent-safety-control button:first-child { border-left: 0; }
.subagent-safety-control button:hover { color: var(--text); background: var(--surface2); }
.subagent-safety-control button:disabled { cursor: wait; opacity: 0.55; }
.subagent-safety-control button.is-selected { color: var(--accent); background: var(--accent-dim); font-weight: 600; }
.subagent-vetting-row.is-action .subagent-safety-control button.is-selected { color: var(--red); background: var(--red-dim); }
.subagent-vetting-row.is-read_only .subagent-safety-control button.is-selected { color: var(--green); background: var(--green-dim); }
.subagent-vetting-unused { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.subagent-vetting-unused > summary { color: var(--text-muted); font-size: 11px; cursor: pointer; }
.subagent-table-wrap {
  border: 1px solid var(--border); border-radius: 8px; overflow-x: auto;
  background: var(--surface);
}
.subagent-table-wrap + .subagent-vetting-panel,
.console-empty + .subagent-vetting-panel { margin-top: 24px; }
.subagent-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.subagent-table th {
  padding: 9px 12px; text-align: left; color: var(--text-muted); font-size: 11px;
  font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.subagent-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.subagent-table tbody tr:last-child td { border-bottom: 0; }
.subagent-row { cursor: pointer; }
.subagent-row:hover, .subagent-row:focus { background: var(--surface2); outline: 0; }
.subagent-row td:first-child strong { display: block; color: var(--text); font-size: 13px; }
.subagent-row td:first-child code { display: block; margin-top: 2px; color: var(--text-muted); font-size: 11px; }
.subagent-state {
  display: inline-flex; padding: 2px 7px; border: 1px solid var(--border);
  border-radius: 999px; color: var(--text-muted); font-size: 11px;
}
.subagent-state.is-enabled { color: var(--green); border-color: var(--green); }
.subagent-team-count {
  display: block; width: max-content; margin-top: 5px; padding: 2px 7px;
  border-radius: 999px; background: var(--surface2); color: var(--text-muted); font-size: 10px;
}
.subagent-parallel-badge {
  display: block; width: max-content; margin-top: 5px; padding: 2px 7px;
  border: 1px solid var(--border); border-radius: 999px;
  color: var(--text-muted); background: var(--surface2); font-size: 10px;
}
.subagent-parallel-badge.is-action { color: var(--red); border-color: var(--red); background: var(--red-dim); }
.subagent-parallel-badge.is-unknown { color: var(--warn-amber); border-color: var(--amber); background: var(--amber-dim); }
.subagent-parallel-badge.is-parallel_files { color: var(--green); border-color: var(--green); background: var(--green-dim); }
.subagent-tools-cell { min-width: 170px; }
.subagent-tools-cell code {
  display: inline-block; margin: 2px 4px 2px 0; padding: 2px 5px;
  border-radius: 4px; background: var(--surface2); color: var(--text-dim); font-size: 10px;
}
.subagent-mcp-display { display: inline-flex; align-items: center; gap: 3px; margin: 2px 4px 2px 0; }
.subagent-mcp-display code { margin: 0; }
.subagent-mcp-display small,
.subagent-server-chip,
.subagent-tool-server {
  display: inline-flex; padding: 2px 5px; border: 1px solid var(--border);
  border-radius: 999px; color: var(--text-muted); background: var(--surface); font: 9px/1.2 var(--mono);
}
.subagent-status-cell { min-width: 180px; color: var(--text-dim); }
.console-icon-btn {
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
  color: var(--text-muted); cursor: pointer;
}
.console-icon-btn:hover { border-color: var(--border); color: var(--text); background: var(--surface2); }
.subagent-row-actions { display: flex; gap: 2px; }
.subagent-editor-header { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.subagent-editor-header h2 { margin: 0; font-size: 20px; }
.subagent-editor-header p { margin: 2px 0 0; color: var(--text-muted); font-family: var(--mono); font-size: 11px; }
.subagent-test-open { margin-left: auto; }
.subagent-editor { min-width: 0; }
.subagent-editor .setting-group { margin-bottom: 16px; }
.subagent-editor-section .console-form-card-header { padding-block: 12px; }
.subagent-editor-section .console-form-card-body > :last-child { margin-bottom: 0; }
.subagent-identity-fields,
.subagent-model-fields,
.subagent-founder-fields {
  display: grid; gap: 16px;
}
.subagent-identity-fields { grid-template-columns: minmax(0, 1.2fr) minmax(220px, 0.8fr); }
.subagent-model-fields { grid-template-columns: minmax(0, 1fr) minmax(220px, 0.55fr); max-width: 760px; }
.subagent-founder-fields { grid-template-columns: minmax(0, 1fr) minmax(230px, 0.55fr); align-items: end; }
.subagent-identity-fields input,
.subagent-model-fields input,
.subagent-founder-fields input[type="text"] { width: 100%; }
.subagent-founder-toggle {
  display: inline-flex; align-items: center; gap: 8px; align-self: center;
  color: var(--text-dim); font-size: 13px; cursor: pointer;
}
.subagent-founder-toggle input[type="checkbox"] { width: auto; margin: 0; cursor: pointer; }
.subagent-editor > .console-form-actions { justify-content: flex-end; margin-top: 14px; }
.subagent-field-hint { margin: 6px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.4; }
.subagent-segmented { display: inline-grid; grid-template-columns: repeat(2, minmax(100px, 1fr)); border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.subagent-segmented label { cursor: pointer; }
.subagent-segmented input { position: absolute; opacity: 0; pointer-events: none; }
.subagent-segmented span { display: block; padding: 7px 14px; text-align: center; color: var(--text-muted); font-size: 12px; }
.subagent-segmented input:checked + span { background: var(--accent); color: var(--accent-contrast); }
#subagent-model { width: 100%; max-width: 560px; }
#subagent-model optgroup { font-style: normal; font-weight: 600; color: var(--text-muted); }
.subagent-tool-options { display: flex; flex-direction: column; gap: 12px; }
.subagent-capability-summary {
  margin-bottom: 12px; color: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums;
}
.subagent-capability-group {
  padding: 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface);
}
.subagent-capability-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.subagent-capability-group h4 {
  margin: 0; color: var(--text-dim); font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.subagent-capability-count { color: var(--text-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.subagent-capability-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.subagent-tool-option {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
}
.subagent-tool-option:has(input:checked) { border-color: var(--accent); background: var(--accent-dim); }
.subagent-tool-option.is-mutating { border-color: var(--amber); background: var(--amber-dim); }
.subagent-tool-option.is-mutating:has(input:checked) { border-color: var(--warn-amber); background: var(--amber-dim); }
.subagent-tool-option.is-action { border-color: var(--red); background: var(--red-dim); }
.subagent-tool-option.is-action:has(input:checked) { border-color: var(--red); background: var(--red-dim); }
.subagent-tool-option.is-unknown { border-style: dashed; border-color: var(--amber); background: var(--surface); }
.subagent-tool-option.is-unknown:has(input:checked) { border-color: var(--warn-amber); background: var(--amber-dim); }
.subagent-tool-option code { font-size: 11px; }
.subagent-tool-server { margin-left: 5px; vertical-align: middle; }
.subagent-tool-option.has-description { align-items: flex-start; background: var(--surface); }
.subagent-tool-option.has-description input { margin-top: 2px; }
.subagent-tool-option.has-description span { min-width: 0; }
.subagent-tool-option.has-description small {
  display: block; margin-top: 3px; color: var(--text-muted); font-size: 11px; line-height: 1.35;
}
.subagent-tool-option em {
  display: block; margin-top: 3px; color: var(--warn-amber); font-size: 10px; font-style: normal; line-height: 1.35;
}
.subagent-tool-option[hidden] { display: none; }
.subagent-advanced-capabilities { display: flex; flex-direction: column; gap: 12px; }
.subagent-capability-more,
.subagent-browse-all {
  margin-top: 9px; padding: 2px 0; border: 0; background: transparent;
  color: var(--accent); font-size: 11px; font-weight: 600; cursor: pointer;
}
.subagent-capability-more:hover,
.subagent-browse-all:hover { color: var(--accent-hover); text-decoration: underline; }
.subagent-capability-more:focus-visible,
.subagent-browse-all:focus-visible,
.subagent-mcp-capabilities > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.subagent-browse-all { align-self: flex-start; margin-top: 0; }
.subagent-mcp-capabilities { border: 1px solid var(--border); border-radius: 7px; background: var(--surface); }
.subagent-mcp-capabilities > summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px; color: var(--text-dim); cursor: pointer; list-style: none;
}
.subagent-mcp-capabilities > summary::-webkit-details-marker { display: none; }
.subagent-mcp-capabilities > summary::before {
  content: '›'; color: var(--text-muted); font-size: 16px; line-height: 1; transition: transform 160ms ease-out;
}
.subagent-mcp-capabilities[open] > summary::before { transform: rotate(90deg); }
.subagent-mcp-capabilities > summary span {
  margin-right: auto; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
}
.subagent-mcp-capabilities > summary small { color: var(--text-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.subagent-mcp-capabilities[open] > summary { border-bottom: 1px solid var(--border); }
/* MCP picker forces its own full-width row below the built-in tool chips. */
.subagent-mcp-picker { width: 100%; padding: 12px; }
.subagent-mcp-filter {
  width: 100%; padding: 6px 8px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--input-bg); color: var(--text); font-size: 12px;
}
.subagent-mcp-filter:focus { outline: none; border-color: var(--accent); }
.subagent-mcp-groups { display: flex; flex-direction: column; gap: 10px; max-height: 240px; overflow-y: auto; }
.subagent-mcp-group { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.subagent-mcp-group[hidden] { display: none; }
.subagent-mcp-server {
  flex: 1 0 100%; font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-muted);
}
.subagent-mcp-empty { flex: 1 0 100%; margin: 4px 0 0; color: var(--text-muted); font-size: 12px; }
.subagent-mcp-error { margin: 7px 0 0; color: var(--red); font-size: 11px; line-height: 1.4; }
.subagent-team-mcp-browser, .subagent-mcp-patterns { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.subagent-team-mcp-browser > label, .subagent-mcp-patterns > label {
  display: block; margin-bottom: 6px; color: var(--text-dim); font-size: 11px; font-weight: 600;
}
#subagent-mcp-team { width: 100%; }
#subagent-team-mcp-results { display: flex; flex-direction: column; gap: 10px; margin-top: 9px; }
.subagent-mcp-pattern-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.subagent-mcp-pattern-row input { min-width: 0; }
.subagent-mcp-pattern-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.subagent-mcp-pattern-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 7px;
  border: 1px solid var(--amber); border-radius: 999px; background: var(--amber-dim);
}
.subagent-mcp-pattern-chip code { font-size: 10px; }
.subagent-mcp-pattern-chip button {
  padding: 0; border: 0; background: transparent; color: var(--text-muted); cursor: pointer; line-height: 1;
}
.subagent-parallel-indicator {
  margin-top: 10px; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-muted); background: var(--surface2);
  font-size: 12px; line-height: 1.5;
}
.subagent-parallel-indicator.is-action { color: var(--red); border-color: var(--red); background: var(--red-dim); }
.subagent-parallel-indicator.is-unknown { color: var(--warn-amber); border-color: var(--amber); background: var(--amber-dim); }
.subagent-parallel-indicator.is-parallel_files { color: var(--green); border-color: var(--green); background: var(--green-dim); }
.subagent-parallel-indicator code { font-size: 11px; }
.subagent-mutation-warning {
  margin-top: 10px; padding: 9px 11px; border-radius: 6px; font-size: 12px; line-height: 1.5;
  color: var(--warn-amber); background: var(--amber-dim); border: 1px solid var(--amber);
}
.subagent-prompt-hint { margin: 6px 0 0; color: var(--text-muted); font-size: 12px; line-height: 1.5; }
.subagent-status-preview { display: flex; align-items: center; gap: 8px; min-height: 26px; margin-top: 6px; color: var(--text-dim); font-size: 12px; }
.subagent-status-preview span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.subagent-form-error { min-height: 18px; color: var(--red); font-size: 12px; }
.subagent-test-panel .setting-group { margin-bottom: 12px; }
.subagent-test-availability { margin: 0 0 10px; color: var(--text-muted); font-size: 11px; line-height: 1.45; }
.subagent-test-intro { margin: 0 0 14px; color: var(--text-muted); font-size: 11px; line-height: 1.5; }
.subagent-test-envelope { margin: 0 0 12px; }
.subagent-test-envelope summary { color: var(--text-muted); font-size: 11px; cursor: pointer; }
.subagent-test-envelope pre {
  max-height: 180px; overflow: auto; margin: 6px 0 0; padding: 8px;
  border: 1px solid var(--border); border-radius: 5px; background: var(--surface2);
  font: 11px/1.5 var(--mono); color: var(--text-dim); white-space: pre-wrap;
}
.subagent-test-result { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.subagent-test-running { display: flex; align-items: center; gap: 7px; color: var(--text-muted); font: 11px/1.4 var(--mono); }
.subagent-test-result .subagent-trace-child {
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); overflow: hidden;
}
.subagent-test-note {
  margin-bottom: 8px; padding: 7px 9px; border-radius: 5px; font-size: 11px; line-height: 1.5;
  color: var(--accent-orange, #c75900);
  background: rgba(199, 89, 0, 0.08); border: 1px solid rgba(199, 89, 0, 0.25);
}
.subagent-test-wrote { margin-bottom: 8px; color: var(--text-muted); font: 10px/1.4 var(--mono); }
.subagent-team-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
.subagent-team-option {
  display: flex; align-items: flex-start; gap: 9px; padding: 9px 10px;
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
}
.subagent-team-option:has(input:checked) { border-color: var(--accent); background: var(--accent-dim); }
.subagent-team-option strong { display: block; font-size: 12px; }
.subagent-team-option span { display: block; margin-top: 2px; color: var(--text-muted); font-size: 11px; }
.subagent-team-warning { min-height: 18px; margin-top: 8px; color: var(--text-muted); font-size: 11px; }

@media (max-width: 760px) {
  .console-tabs { overflow-x: auto; }
  .console-tab { flex: 0 0 auto; padding-inline: 12px; }
  .subagent-vetting-row { grid-template-columns: 1fr; gap: 7px; }
  .subagent-safety-control { justify-self: start; }
  .subagent-capability-options { grid-template-columns: 1fr; }
  .subagent-team-options { grid-template-columns: 1fr; }
  .subagent-identity-fields,
  .subagent-model-fields,
  .subagent-founder-fields { grid-template-columns: 1fr; }
  .subagent-model-fields { max-width: none; }
  .subagent-editor > .console-form-actions { justify-content: flex-start; }
}

.console-content { min-height: 300px; }

/* Generic non-modal console drawer. The page behind stays interactive so admins
   can compare diagnostics with the form and edit it without closing the drawer. */
.console-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 60;
  width: min(720px, 92vw); display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.12);
  transform: translateX(calc(100% + 32px)); transition: transform 0.25s ease;
}
.console-drawer.open { transform: translateX(0); }
.console-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.console-drawer-header h3 { margin: 0; font-size: 14px; }
.console-drawer-close {
  display: flex; align-items: center; justify-content: center;
  padding: 4px; border: 0; border-radius: 6px; background: none;
  color: var(--text-muted); font-size: 22px; line-height: 1; cursor: pointer;
}
.console-drawer-close:hover { background: var(--surface2); color: var(--text); }
.console-drawer-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.console-drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px; }

/* Agent file ledger */
.agent-files-heading { align-items: flex-start; }
.agent-files-heading h2 { margin-bottom: 10px; }
.agent-files-heading .console-section-desc { margin: 0; }
.agent-files-header-actions { display: flex; gap: 8px; flex-shrink: 0; }
.agent-files-bulk:disabled { opacity: 0.45; cursor: not-allowed; }
.agent-files-check { width: 34px; text-align: center; }
.agent-files-check input { accent-color: var(--accent); cursor: pointer; }
.agent-files-check input:disabled { cursor: not-allowed; opacity: 0.4; }
.agent-files-summary {
  display: flex; align-items: stretch; gap: 10px; margin-bottom: 16px;
}
.agent-files-summary > div {
  min-width: 130px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
}
.agent-files-summary strong {
  display: block; color: var(--text); font-size: 20px; font-variant-numeric: tabular-nums;
}
.agent-files-summary span { display: block; margin-top: 2px; color: var(--text-muted); font-size: 11px; }
.agent-files-summary small { align-self: center; margin-left: auto; color: var(--text-muted); font-size: 11px; }
.agent-files-filters {
  display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)) minmax(180px, 1.5fr) auto;
  align-items: end; gap: 10px; margin-bottom: 8px;
}
.agent-files-filters label { color: var(--text-muted); font-size: 11px; font-weight: 600; }
.agent-files-filters select,
.agent-files-filters input {
  width: 100%; min-height: 38px; margin-top: 5px; padding: 7px 9px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--input-bg); color: var(--text); font: 12px var(--sans);
}
.agent-files-filters select:focus,
.agent-files-filters input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.agent-files-error { min-height: 18px; margin: 0 0 6px; color: var(--red); font-size: 12px; }
.agent-files-table-wrap {
  overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface);
}
.agent-files-table { width: 100%; min-width: 980px; border-collapse: collapse; font-size: 12px; }
.agent-files-table th {
  padding: 9px 10px; border-bottom: 1px solid var(--border); color: var(--text-muted);
  text-align: left; font-size: 10px; font-weight: 600; white-space: nowrap;
}
.agent-files-table td {
  max-width: 150px; padding: 10px; border-bottom: 1px solid var(--border);
  color: var(--text-dim); vertical-align: middle; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.agent-files-table tbody tr:last-child td { border-bottom: 0; }
.agent-files-row { cursor: pointer; }
.agent-files-row:hover,
.agent-files-row:focus-visible { background: var(--surface2); outline: 0; }
.agent-files-time,
.agent-files-size { color: var(--text-muted); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.agent-files-filename { color: var(--text); font-family: var(--mono); font-weight: 600; }
.agent-file-chip {
  display: inline-flex; margin: 1px 4px 1px 0; padding: 2px 7px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface3); color: var(--text-dim); font-size: 10px; font-weight: 600;
}
.agent-file-chip.is-parent,
.agent-file-chip.is-helper { background: var(--purple-dim); color: var(--purple); border-color: var(--purple); }
.agent-file-chip.is-test,
.agent-file-chip.is-temporary,
.agent-file-chip.is-sweep { color: var(--text-muted); }
.agent-file-chip.is-person,
.agent-file-chip.is-write { background: var(--green-dim); color: var(--green); border-color: var(--green); }
.agent-file-chip.is-delete { background: var(--red-dim); color: var(--red); border-color: var(--red); }
.agent-file-chip.is-cap-warning { align-self: center; color: var(--warn-amber); border-color: var(--warn-amber); }
.agent-files-sort { cursor: pointer; user-select: none; white-space: nowrap; }
.agent-files-sort:hover { text-decoration: underline; }
.agent-files-sort .sort-arrow { font-size: 0.75em; color: var(--accent); }
/* Dimmed non-deletable activity rows (delete events, temporary files) */
.agent-files-row.is-unselectable td:not(.agent-files-actions) { opacity: 0.5; }
.agent-files-dedup-note { display: block; color: var(--text-muted); font-size: 0.8em; margin-top: 0.25rem; }
/* Activity | Inventory view toggle */
.agent-files-view-toggle {
  display: inline-flex; margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.agent-files-view-btn {
  padding: 7px 18px; border: none; background: none;
  color: var(--text-muted); font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 0.15s;
}
.agent-files-view-btn + .agent-files-view-btn { border-left: 1px solid var(--border); }
.agent-files-view-btn:hover { background: var(--surface2); color: var(--text); }
.agent-files-view-btn.active { background: var(--surface2); color: var(--accent); }
.agent-file-history-none { color: var(--text-muted); }
.agent-files-table td.agent-files-actions { display: flex; gap: 5px; max-width: none; }
.agent-files-delete { color: var(--red); }
.agent-files-more-wrap { display: flex; justify-content: center; margin-top: 14px; }
.agent-file-detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0 0 16px; }
.agent-file-detail-grid div { min-width: 0; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.agent-file-detail-grid dt { color: var(--text-muted); font-size: 10px; font-weight: 600; text-transform: uppercase; }
.agent-file-detail-grid dd { margin: 4px 0 0; color: var(--text); font: 11px/1.5 var(--mono); overflow-wrap: anywhere; }
.agent-file-detail-actions { display: flex; gap: 8px; margin-bottom: 20px; }
.agent-file-drawer h4 { margin: 20px 0 8px; color: var(--text); font-size: 12px; }
.agent-file-history { margin: 0; padding: 0; list-style: none; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.agent-file-history li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 11px; }
.agent-file-history li:last-child { border-bottom: 0; }
.agent-file-history time { color: var(--text-muted); font-family: var(--mono); }
.agent-file-content {
  max-height: 48vh; overflow: auto; margin: 0; padding: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--text-dim); font: 11px/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .agent-files-heading { flex-direction: column; gap: 12px; }
  .agent-files-bulk { width: 100%; justify-content: center; min-height: 44px; }
  .agent-files-summary { flex-wrap: wrap; }
  .agent-files-summary > div { flex: 1; min-width: 120px; }
  .agent-files-summary small { flex-basis: 100%; margin-left: 0; }
  .agent-files-filters { grid-template-columns: 1fr; }
  .agent-files-filters .console-btn { min-height: 44px; justify-content: center; }
  .agent-file-detail-grid { grid-template-columns: 1fr; }
}

/* Loading state */
.console-loading {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  text-align: center; color: var(--text-muted); font-size: 14px; padding: 64px 32px;
}
.console-spinner {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2.5px solid var(--border); border-top-color: var(--accent);
  animation: consoleSpin 0.7s linear infinite;
}
@keyframes consoleSpin { to { transform: rotate(360deg); } }

/* Empty state */
.console-empty {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  text-align: center; color: var(--text-muted); font-size: 14px;
  padding: 48px 24px; line-height: 1.5;
}
.console-empty-icon { font-size: 32px; margin-bottom: 8px; opacity: 0.6; }
.console-empty p { margin: 0; }
.console-empty-hint { font-size: 13px; color: var(--text-muted); opacity: 0.7; }

/* Section header with title + action button */
.console-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.console-section-header h2 {
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; font-weight: 600; color: var(--text);
}
.console-section-header h3 {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 600; color: var(--text);
}
.console-section-desc {
  font-size: 13px; color: var(--text-muted); line-height: 1.5;
  margin: -8px 0 20px; max-width: 600px;
}

/* Count badge */
.console-count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 7px;
  font-size: 11px; font-weight: 600; border-radius: 11px;
  background: var(--surface3); color: var(--text-dim);
  font-family: inherit;
}

/* Buttons */
.console-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: all 0.15s; font-family: inherit;
  white-space: nowrap;
}
.console-btn:hover { background: var(--surface2); border-color: var(--text-muted); }
.console-btn.primary {
  background: var(--accent); color: white; border-color: var(--accent);
}
.console-btn.primary:hover {
  background: var(--accent-hover); border-color: var(--accent-hover);
}
.console-btn.primary.saved {
  background: var(--green); border-color: var(--green);
}
.console-btn.danger {
  background: none; color: var(--text-muted); border: none;
  padding: 4px 8px; font-size: 16px; line-height: 1;
}
.console-btn.danger:hover { color: var(--red); background: var(--red-dim); border-radius: 6px; }
.console-btn.small { padding: 5px 12px; font-size: 12px; }
.console-save-btn { margin-top: 8px; }

/* AI Keys panel */
.cs-ai-key-input {
  width: 100%; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 13px;
  font-family: var(--mono); outline: none; transition: border-color 0.15s;
}
.cs-ai-key-input:focus { border-color: var(--accent); }
.cs-key-status {
  margin-top: 5px; font-size: 11px; color: var(--text-muted); font-family: var(--mono);
}
.cs-key-hint { color: var(--text-dim); }
.cs-key-not-set { color: var(--text-muted); font-style: italic; }
.cs-key-optional { color: var(--text-muted); font-weight: 400; font-size: 0.85em; }
.cs-key-clear { color: var(--accent); margin-left: 0.4rem; cursor: pointer; font-size: 0.85em; }
.cs-share-toggle { margin-top: 0.5rem; font-size: 0.9em; color: var(--text-muted); }
.cs-keys-intro { color: var(--text-muted); font-size: 0.85em; margin: 0 0 0.75rem; }

/* Team cards grid */
.console-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.console-card {
  padding: 20px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; transition: all 0.2s;
}
.console-card:hover {
  border-color: var(--accent); background: var(--surface2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}
.console-card-title {
  font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 2px;
}
.console-card-meta {
  font-size: 12px; color: var(--text-muted); font-family: var(--mono);
}

/* Team card specific */
.team-card-header { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.team-card-avatar {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 700; color: white;
  flex-shrink: 0;
}
.team-card-avatar-sm { width: 36px; height: 36px; border-radius: 9px; font-size: 15px; }
.team-card-info { flex: 1; min-width: 0; }
.team-card-stats {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 12px; border-top: 1px solid var(--border);
}
.team-stat {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text-muted);
}
.team-stat svg { opacity: 0.5; }
.team-stat-date { font-size: 11px; color: var(--text-muted); opacity: 0.7; }

/* Team detail view */
.console-detail-header {
  display: flex; align-items: center; gap: 20px; margin-bottom: 24px;
}
.console-detail-header h2 {
  font-size: 22px; font-weight: 700; color: var(--text);
  letter-spacing: -0.01em;
}
.console-detail-title-row {
  display: flex; align-items: center; gap: 12px;
}
.console-detail-slug {
  font-size: 12px; color: var(--text-muted); font-family: var(--mono);
}
.console-back-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 7px 14px; font-size: 13px; font-weight: 500; color: var(--text-dim);
  background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.15s;
}
.console-back-btn:hover { color: var(--text); border-color: var(--text-muted); background: var(--surface2); }

/* Detail sub-tabs (Settings | Members | Files | Memory | Frameworks) */
.console-detail-tabs {
  display: flex; gap: 2px; margin-bottom: 24px;
  background: var(--surface3); border-radius: var(--radius-sm); padding: 3px;
}
.console-detail-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; font-size: 13px; font-weight: 500;
  color: var(--text-dim); background: none; border: none;
  border-radius: 6px; cursor: pointer; transition: all 0.15s;
}
.console-detail-tab svg { opacity: 0.4; transition: opacity 0.15s; }
.console-detail-tab:hover { color: var(--text); }
.console-detail-tab:hover svg { opacity: 0.7; }
.console-detail-tab.active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.console-detail-tab.active svg { opacity: 1; }

.console-detail-content { min-height: 200px; }

/* Settings form with card layout */
/* No max-width by default — fills the parent pane. Add .console-form-narrow
   for views that genuinely want the old 640px form-friendly cap. */
.console-form { }
.console-form-narrow { max-width: 640px; }
.console-form-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); margin-bottom: 16px;
  overflow: hidden;
}
.console-form-card-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: var(--surface2);
}
.console-form-card-header svg { color: var(--text-dim); flex-shrink: 0; }
.console-form-card-header h3 {
  font-size: 14px; font-weight: 600; color: var(--text);
  flex: 1;
}
.console-form-hint {
  font-size: 13px; color: var(--text-muted); line-height: 1.5;
  padding: 12px 20px 0; margin: 0;
}
.console-form-card-body { padding: 16px 20px 20px; }
.console-form-actions { display: flex; gap: 8px; margin-top: 8px; }
.console-form-actions .console-btn { flex: none; }

/* Console usage view */
.usage-subtitle {
  margin-top: 4px; color: var(--text-muted); font-size: 13px;
}
.usage-filters {
  display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
  gap: 12px; align-items: end; padding: 16px; margin-bottom: 16px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.usage-filters .setting-group { margin: 0; }
.usage-filter-actions { display: flex; gap: 8px; padding-bottom: 1px; }
.usage-summary-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.usage-summary-card {
  display: flex; flex-direction: column; gap: 6px; padding: 16px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.usage-summary-card span { color: var(--text-muted); font-size: 12px; }
.usage-summary-card strong { color: var(--text); font-size: 20px; font-variant-numeric: tabular-nums; }
.usage-warning {
  padding: 10px 12px; margin-bottom: 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface2); color: var(--text-dim); font-size: 12px;
}
.usage-table-wrap {
  overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.usage-table { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 13px; }
.usage-table th {
  padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface2);
  color: var(--text-muted); font-size: 11px; font-weight: 600; text-align: right;
}
.usage-table td {
  padding: 11px 12px; border-bottom: 1px solid var(--border); color: var(--text-dim);
  text-align: right; font-variant-numeric: tabular-nums;
}
.usage-table th:first-child, .usage-table td:first-child { text-align: left; }
.usage-table tbody tr:last-child td { border-bottom: 0; }
.usage-table .usage-empty-row { padding: 24px; color: var(--text-muted); text-align: center; }
.usage-ranking-title {
  margin: 24px 0 10px; color: var(--text); font-size: 14px; font-weight: 600;
}
.usage-rankings {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px;
}
.usage-rankings .usage-ranking-title { margin-top: 24px; }
.usage-ranking-table { min-width: 0; }
.usage-runs-table { min-width: 880px; }
.usage-run-row:hover td { background: var(--surface2); }
.usage-run-row--open td { background: var(--surface2); }
/* The toggle is the click target, not the row — a pointer cursor on the whole
   row would promise seven cells of affordance and deliver one. Deliberately not
   a .console-btn: the first column has to keep reading as a timestamp. */
.usage-run-toggle {
  display: inline-flex; align-items: center; padding: 0; border: 0; background: none; cursor: pointer;
  color: inherit; font: inherit; font-variant-numeric: tabular-nums;
}
.usage-run-toggle:hover { color: var(--text); text-decoration: underline; }
.usage-run-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.usage-run-chevron {
  display: inline-block; margin-right: 6px; color: var(--text-muted); line-height: 1;
  transform-origin: center; transition: color 0.15s, transform 0.15s;
}
.usage-run-toggle:hover .usage-run-chevron,
.usage-run-toggle[aria-expanded="true"] .usage-run-chevron { color: var(--text); }
.usage-run-toggle[aria-expanded="true"] .usage-run-chevron { transform: rotate(90deg); }
.usage-session-ranking { margin-top: 8px; }
/* Six columns and a button: this one scrolls in its wrap like the runs table
   rather than compressing, so .usage-ranking-table's min-width: 0 is undone. */
.usage-session-ranking .usage-ranking-table { min-width: 720px; }
/* Accent + standing dotted underline, not hover-only: the runs table taught
   the operator that ids in this column are plain text, so this one has to
   announce itself at rest. Same lesson as the run-expand chevron. */
.usage-session-filter {
  display: inline-flex; align-items: center; padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--accent); font: inherit;
  text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px;
}
.usage-session-filter:hover { text-decoration-style: solid; }
.usage-session-filter:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.usage-run-detail-row > td { padding: 0; background: var(--surface2); }
.usage-run-detail { padding: 16px; text-align: left; }
.usage-attribution-table { min-width: 0; }
.usage-detail-note { margin: 0 0 12px; color: var(--text-muted); font-size: 13px; }
.usage-detail-identity {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px; margin: 12px 0 0;
}
.usage-detail-identity dt { color: var(--text-muted); font-size: 11px; }
.usage-detail-identity dd {
  margin: 2px 0 0; color: var(--text-dim); font-size: 12px; word-break: break-all;
}
.usage-detail-actions { margin-top: 12px; }
.usage-chat-unavailable {
  display: inline-block; padding: 6px 10px; border: 1px dashed var(--border);
  border-radius: var(--radius-sm); color: var(--text-muted); font-size: 12px; cursor: not-allowed;
}
.usage-load-more-wrap { display: flex; justify-content: center; margin-top: 12px; }

@media (max-width: 1000px) {
  .usage-filters { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .usage-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .usage-rankings { grid-template-columns: minmax(0, 1fr); }
}

/* Setting row for multi-column layouts */
.setting-row { display: flex; gap: 12px; }
.setting-row.three-col > .setting-group { flex: 1; min-width: 0; }

/* Inbound Companio MCP pilot access, colocated with the BYOK controls. */
.mcp-access-mint {
  display: flex; align-items: flex-end; gap: 10px; margin-top: 14px;
}
.mcp-access-mint .setting-group { flex: 1; margin: 0; }
.mcp-access-scopes {
  min-width: 230px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.mcp-access-scopes legend {
  padding: 0 4px; color: var(--text-dim); font-size: 12px;
  font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
}
.mcp-access-scopes .setting-toggle-label {
  display: flex; margin-bottom: 6px; color: var(--text);
  font-size: 12px; letter-spacing: normal; text-transform: none;
}
.mcp-access-scopes .console-form-hint {
  margin: 8px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.4;
}
.mcp-access-reveal {
  display: flex; flex-direction: column; gap: 10px;
  margin: 12px 0; padding: 14px;
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--text);
}
.mcp-access-reveal code {
  padding: 9px 10px; border-radius: var(--radius-sm);
  background: var(--surface3); color: var(--text);
  overflow-wrap: anywhere; user-select: all;
}
.mcp-access-reveal pre {
  margin: 0; padding: 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text-dim); white-space: pre-wrap; overflow-wrap: anywhere;
}
.mcp-access-reveal-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mcp-access-token-list {
  display: flex; flex-direction: column; gap: 6px; margin-top: 16px;
}
.mcp-access-token-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface2);
}
.mcp-access-token-owner { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 2px; }
.mcp-access-token-owner strong {
  overflow: hidden; color: var(--text); font-size: 13px;
  text-overflow: ellipsis; white-space: nowrap;
}
.mcp-access-token-owner span { color: var(--text-muted); font-size: 11px; }
.mcp-access-empty { margin: 0; color: var(--text-muted); font-size: 13px; }
@media (max-width: 640px) {
  .mcp-access-mint { align-items: stretch; flex-direction: column; }
  .mcp-access-token-row { align-items: flex-start; }
}

/* Members list */
.console-member-list { display: flex; flex-direction: column; gap: 6px; }
.console-member-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  transition: background 0.15s;
}
.console-member-row:hover { background: var(--surface2); }
.console-member-avatar {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: white;
  background: var(--accent); flex-shrink: 0;
}
.console-member-info { flex: 1; min-width: 0; }
.console-member-email {
  font-size: 14px; color: var(--text);
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.console-member-joined {
  font-size: 12px; color: var(--text-muted); margin-top: 1px; display: block;
}
.console-role-badge {
  padding: 3px 10px; font-size: 11px; font-weight: 600;
  border-radius: 12px; flex-shrink: 0; text-transform: capitalize;
}
.console-role-badge.role-admin {
  background: var(--purple-dim); color: var(--purple);
}
.console-role-badge.role-member {
  background: var(--surface3); color: var(--text-dim);
}
.console-member-remove { flex-shrink: 0; }

/* Skill reference-file prompt-format badge (json / prose). Status is derived
   from file content on the fly in console-skills.js — never stored. */
.skill-prompt-badge {
  flex-shrink: 0; padding: 2px 8px; font-size: 10px; font-weight: 600;
  border-radius: 999px; text-transform: uppercase; letter-spacing: 0.04em;
}
.skill-prompt-badge.json { background: var(--green-dim); color: var(--green); }
.skill-prompt-badge.json-bad { background: var(--red-dim); color: var(--red); }
.skill-prompt-badge.prose { background: var(--surface3); color: var(--text-dim); }
/* Size + badge on one line, badge to the right of the file size. */
.skill-file-meta { display: flex; align-items: center; gap: 8px; margin-top: 1px; }

/* File list */
.console-file-list { display: flex; flex-direction: column; gap: 6px; }
.console-file-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  transition: background 0.15s;
}
.console-file-row { cursor: pointer; }
.console-file-row:hover { background: var(--surface2); }
.console-file-icon { font-size: 20px; flex-shrink: 0; line-height: 1; }
.console-file-info { flex: 1; min-width: 0; }
.console-file-name {
  font-size: 14px; font-weight: 500; color: var(--text);
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.console-file-desc {
  font-size: 12px; color: var(--text-muted); margin-top: 2px;
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.console-file-size {
  font-size: 12px; color: var(--text-muted); font-family: var(--mono);
  flex-shrink: 0;
}
.console-file-delete { flex-shrink: 0; }
.console-file-pin {
  flex-shrink: 0;
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer;
  padding: 4px 8px; border-radius: 4px;
  font-size: 13px; line-height: 1;
  filter: grayscale(1) opacity(0.7);
  transition: all 0.15s;
}
.console-file-pin:hover { filter: none; background: var(--surface2); }
.console-file-pin.active {
  filter: none; background: #fef3c7;
  border-color: #f59e0b; color: #92400e;
}
.console-file-pin.active:hover { background: #fde68a; }

/* Grouped subsections (pinned vs all) on the Files tab */
.console-file-subsection { margin-bottom: 18px; }
.console-file-subsection:last-child { margin-bottom: 0; }
.console-file-subheader {
  display: flex; align-items: baseline; gap: 10px;
  margin: 0 0 8px 2px;
}
.console-file-subheader-title {
  font-size: 12px; font-weight: 600; color: var(--text);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.console-file-subheader-hint {
  font-size: 12px; color: var(--text-muted);
}

/* File preview modal (console Files tab) */
.console-preview-modal {
  position: fixed; inset: 0; z-index: 1000;
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s;
}
.console-preview-modal.visible { opacity: 1; pointer-events: auto; }
.console-preview-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.35);
}
.console-preview-content {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(820px, 92vw); max-height: 82vh;
  display: flex; flex-direction: column;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.console-preview-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
}
.console-preview-header h3 {
  margin: 0; font-size: 14px; font-weight: 600;
  font-family: var(--mono, ui-monospace, monospace);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.console-preview-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 22px; line-height: 1; cursor: pointer;
  padding: 2px 8px; border-radius: 4px;
}
.console-preview-close:hover { color: var(--text); background: var(--surface2); }
.console-preview-body {
  flex: 1; overflow-y: auto;
  padding: 18px 24px;
}
.console-preview-loading {
  color: var(--text-muted); font-size: 13px;
  padding: 40px 0; text-align: center;
}
.console-preview-rendered { font-size: 14px; line-height: 1.6; }
.console-preview-rendered > :first-child { margin-top: 0; }
.console-preview-rendered > :last-child { margin-bottom: 0; }
.console-preview-source {
  margin: 0; font-size: 12px; line-height: 1.5;
  font-family: var(--mono, ui-monospace, monospace);
  white-space: pre-wrap; word-break: break-word;
  color: var(--text);
}

/* File editor modal (extends .console-preview-modal) */
.console-editor-modal .console-preview-content {
  width: min(900px, 94vw);
  height: min(82vh, 760px);
  max-height: 82vh;
}
.console-editor-body {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px 20px;
}
.console-editor-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  text-transform: uppercase; color: var(--text-muted);
}
.console-editor-desc {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text);
  font-size: 13px; font-family: inherit; box-sizing: border-box;
  resize: vertical; min-height: 44px; line-height: 1.4;
}
.console-editor-content-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 4px;
}
.console-editor-toggle {
  display: inline-flex; border: 1px solid var(--border);
  border-radius: 6px; overflow: hidden;
}
.console-editor-tab {
  background: var(--surface); color: var(--text-muted);
  border: none; padding: 4px 12px; font-size: 12px; cursor: pointer;
}
.console-editor-tab.active { background: var(--surface2); color: var(--text); }
.console-editor-content {
  flex: 1; min-height: 160px; width: 100%; box-sizing: border-box;
  padding: 12px 14px; resize: none;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 12px; line-height: 1.5;
}
.console-editor-preview {
  flex: 1; min-height: 160px; overflow-y: auto;
  padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface);
}
.console-editor-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 20px;
  border-top: 1px solid var(--border-light);
}
.console-editor-error { color: var(--red); font-size: 12px; }

/* Team file upload modal (drop-zone + refine flow) */
.console-upload-modal {
  position: fixed; inset: 0; z-index: 1000;
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s;
}
.console-upload-modal.visible { opacity: 1; pointer-events: auto; }
.console-upload-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.35);
}
.console-upload-content {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(680px, 92vw); max-height: 82vh;
  display: flex; flex-direction: column;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.console-upload-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
}
.console-upload-header h3 {
  margin: 0; font-size: 14px; font-weight: 600;
}
.console-upload-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 22px; line-height: 1; cursor: pointer;
  padding: 2px 8px; border-radius: 4px;
}
.console-upload-close:hover { color: var(--text); background: var(--surface2); }

.console-upload-zone {
  margin: 20px; padding: 40px 24px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md, 8px);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface);
}
.console-upload-zone:hover,
.console-upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--sidebar-active, var(--surface2));
}
.console-upload-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.console-upload-inner svg { color: var(--text-muted); }
.console-upload-inner p { margin: 0; font-size: 14px; color: var(--text); }
.console-upload-hint { font-size: 12px !important; color: var(--text-muted) !important; }
.console-upload-paste-btn {
  margin-top: 10px;
  background: none; border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 14px; border-radius: 6px;
  cursor: pointer; font-size: 12px;
}
.console-upload-paste-btn:hover { color: var(--text); border-color: var(--text-muted); }

.console-upload-forms:not(:empty) { padding: 0 20px 20px; }
.console-upload-parsing {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 40px 20px; color: var(--text-muted);
}
.console-upload-spinner {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: console-spin 0.7s linear infinite;
}
@keyframes console-spin { to { transform: rotate(360deg); } }
.console-upload-parsing p { margin: 0; font-size: 13px; }

.console-paste-form { display: flex; flex-direction: column; gap: 6px; }
.console-paste-form label {
  font-size: 11px; font-weight: 500; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-top: 6px;
}
.console-paste-form input,
.console-paste-form textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text);
  font-size: 13px; font-family: inherit; box-sizing: border-box;
}
.console-paste-form textarea { resize: vertical; font-family: var(--mono, ui-monospace, monospace); }
.console-paste-actions,
.console-refine-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 14px;
}

.console-refine-form { display: flex; flex-direction: column; gap: 12px; }
.console-refine-header h4 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.console-refine-header p { margin: 0; font-size: 12px; color: var(--text-muted); }
.console-refine-rows {
  display: flex; flex-direction: column; gap: 12px;
  max-height: 340px; overflow-y: auto;
}
.console-refine-row {
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface2);
}
.console-refine-filename {
  font-size: 12px; font-weight: 600; margin-bottom: 6px;
  font-family: var(--mono, ui-monospace, monospace);
}
.console-refine-row label {
  display: block;
  font-size: 11px; font-weight: 500; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.console-refine-desc {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text);
  font-size: 13px; font-family: inherit; box-sizing: border-box;
  resize: vertical; min-height: 44px; line-height: 1.4;
}

/* MCP server list */
.console-mcp-list { display: flex; flex-direction: column; gap: 6px; }
.console-mcp-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  transition: background 0.15s;
}
.console-mcp-row:hover { background: var(--surface2); }
.console-mcp-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface3); flex-shrink: 0;
  color: var(--text-muted);
}
.console-mcp-info { flex: 1; min-width: 0; }
.console-mcp-name {
  font-size: 14px; font-weight: 500; color: var(--text);
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.console-mcp-meta {
  font-size: 12px; color: var(--text-muted); margin-top: 1px; display: block;
}
.console-mcp-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* MCP expandable server groups */
.mcp-server-group { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.mcp-server-group + .mcp-server-group { margin-top: 6px; }
.mcp-server-group > summary { cursor: pointer; list-style: none; }
.mcp-server-group > summary::-webkit-details-marker { display: none; }
.mcp-server-group > summary .console-mcp-row { border: none; border-radius: 0; }
.mcp-server-group[open] > summary .console-mcp-row { border-bottom: 1px solid var(--border); }
.mcp-tool-list { padding: 8px 16px 8px 48px; background: var(--surface); }
.mcp-tool-item { padding: 4px 0; display: flex; flex-direction: column; gap: 1px; }
.mcp-tool-item + .mcp-tool-item { border-top: 1px solid var(--border); padding-top: 6px; margin-top: 2px; }
.mcp-tool-name { font-size: 13px; font-weight: 500; color: var(--text); font-family: var(--mono); }
.mcp-tool-desc { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Framework checkboxes (assignment tab) */
.console-fw-checkboxes { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.console-fw-checkbox {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; transition: all 0.15s;
}
.console-fw-checkbox:hover { border-color: var(--accent); background: var(--surface2); }
.console-fw-checkbox.is-checked {
  border-color: var(--accent); background: rgba(0, 122, 255, 0.04);
}
.console-fw-checkbox input[type="checkbox"] {
  margin: 0; accent-color: var(--accent); flex-shrink: 0;
  width: 16px; height: 16px;
}
.console-fw-label { flex: 1; min-width: 0; }
.console-fw-name {
  font-size: 14px; font-weight: 500; color: var(--text);
  display: block;
}
.console-fw-desc {
  font-size: 12px; color: var(--text-muted); margin-top: 2px;
  display: block;
}

/* Upload modal */
.console-modal-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; animation: fadeIn 0.15s ease;
}
.console-modal {
  background: var(--surface); border-radius: var(--radius);
  width: 90%; max-width: 560px; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}
.console-modal-header {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.console-modal-header svg { color: var(--text-dim); }
.console-modal-header h3 {
  font-size: 17px; font-weight: 600; color: var(--text); margin: 0;
}
.console-modal-body { padding: 20px 24px; }
.console-modal-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 16px 24px; border-top: 1px solid var(--border);
  background: var(--surface2);
}

/* Console responsive */
@media (max-width: 768px) {
  .console-page-body { padding: 16px; }
  .console-cards { grid-template-columns: 1fr; }
  .console-detail-header { flex-wrap: wrap; gap: 12px; }
  .console-detail-tabs { flex-wrap: wrap; }
  .console-detail-tab { font-size: 12px; padding: 6px 10px; }
  .console-detail-tab span { display: none; }
  .console-fw-desc { display: none; }
  .setting-row.three-col { flex-direction: column; }
  .console-form-card-body { padding: 12px 16px 16px; }
  .subagent-settings-panel > .subagent-settings-body { padding-block: 0; }
  .subagent-settings-summary-action { display: none; }
  .subagent-settings-section-header { flex-direction: column; gap: 6px; }
  .subagent-policy-help-panel li { grid-template-columns: 1fr; gap: 2px; }
  .subagent-catalog-sources li { grid-template-columns: 1fr; gap: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  .subagent-settings-chevron { transition: none; }
  .subagent-vetting-chevron { transition: none; }
}

/* ==================================================================
   RETRO MONITOR — Classic Mac wrapper for page drafts
   ================================================================== */

.retro-monitor {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  /* Monitor casing — light warm beige, like sun-aged Platinum plastic */
  background: linear-gradient(to bottom, #ece7dc, #e2dbcd 40%, #d9d1c1);
  border-radius: 12px 12px 10px 10px;
  margin: 8px;
  box-shadow:
    0 2px 12px rgba(0, 0, 0, 0.15),
    0 8px 32px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* Title bar — warm gray with horizontal stripes */
.retro-title-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  min-height: 28px;
  position: relative;
}

.retro-window-controls {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.retro-window-controls span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid #b0a898;
}

.retro-window-controls span:nth-child(1) { background: #b0a898; }
.retro-window-controls span:nth-child(2) { background: transparent; }
.retro-window-controls span:nth-child(3) { background: transparent; }

.retro-title-bar-stripes {
  flex: 1;
  height: 12px;
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 3px
  );
}

.retro-title-text {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6a6157;
  white-space: nowrap;
  pointer-events: none;
  background: #e4ded1;
  padding: 1px 10px;
}

/* Screen area — recessed CRT with inner bevel. The screen sits inset on all
   four sides so casing shows above and below it, which is what sells the tube
   as sunk into the shell rather than flush with it. */
.retro-screen {
  flex: 1;
  position: relative;
  background: #c8bfb2;
  margin: 5px 17px 8px;
  border-radius: 8px;
  overflow: hidden;
  /* Beveled lip — darker top/left, lighter bottom/right */
  border: 4px solid #a29484;
  border-top-color: #8d8172;
  border-left-color: #968a7b;
  border-bottom-color: #c4b8a9;
  border-right-color: #c4b8a9;
  /* Outer highlights ONLY. An element's inset shadows paint on its own
     background, UNDERNEATH its children — and .retro-viewport is opaque white
     covering the whole screen, so a recess shadow placed here renders behind
     the page and is invisible. It lives on the ::before overlay instead. */
  box-shadow:
    0 -1px 0 rgba(255, 255, 255, 0.14),
    0 1px 0 rgba(255, 255, 255, 0.55);
}

/* Overlay above the page: carries BOTH the recession and the CRT curve.
   Non-directional layers come first so the recess reaches the corners —
   a directional inset (inset 0 12px) contributes nothing where the edge turns,
   which is what makes a corner read as a hard cut instead of a curve.
   z-index 3 deliberately sits under the DRAFT accent ring (4), the ribbon (5)
   and the clone-status card (6) — those stay crisp; only the page curves. */
.retro-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(112% 98% at 50% 45%,
    rgba(0, 0, 0, 0) 44%,
    rgba(0, 0, 0, 0.04) 66%,
    rgba(0, 0, 0, 0.09) 82%,
    rgba(0, 0, 0, 0.16) 93%,
    rgba(0, 0, 0, 0.24) 100%);
  box-shadow:
    inset 0 0 26px 8px rgba(0, 0, 0, 0.16),
    inset 0 12px 26px -4px rgba(0, 0, 0, 0.34),
    inset 0 3px 7px rgba(0, 0, 0, 0.24),
    inset 0 -7px 14px -6px rgba(0, 0, 0, 0.14);
}
/* Black out the screen when CRT boot is active */
.retro-screen:has(.crt-boot) {
  background: #0a0a0a;
}

.retro-screen iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* Draft state — diagonal "DRAFT" corner ribbon + accent inset frame on the
   preview. Toggled by _updatePublishPanel whenever the preview isn't the
   live-and-current page (pure draft, or live with unpublished edits). */
.retro-screen.is-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 2px rgba(139, 111, 71, 0.45);
  pointer-events: none;
  z-index: 4;
}
.preview-ribbon {
  position: absolute;
  top: 10px;
  left: -32px;
  transform: rotate(-45deg);
  background: var(--accent);
  color: #fff;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 3px 38px;
  z-index: 5;
  box-shadow: 0 1px 3px rgba(60, 50, 40, 0.25);
  pointer-events: none;
}

/* Clone progress floats above the iframe so the real SSE-driven phases remain
   visible while the measured scaffold and finished draft replace each other. */
.clone-status {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 9px;
  width: max-content;
  max-width: min(300px, 70%);
  min-width: 0;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--cream);
  box-shadow: var(--shadow-md);
  color: var(--text-dim);
  font-family: var(--sans);
}

.clone-status.is-dismissed { display: none; }

.clone-status-close {
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 150ms ease, background-color 150ms ease;
}

.clone-status-close:hover {
  color: var(--text);
  background: var(--surface2);
}

.clone-status .status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-dim);
}

.clone-status .status-copy {
  min-width: 0;
  flex: 1;
}

.clone-status .status-main,
.clone-status .status-sub {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clone-status .status-main {
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.clone-status .status-sub {
  margin-top: 1px;
  color: var(--text-muted);
  font-size: 9px;
}

.clone-status .status-time {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.clone-status:not([data-phase="ready"]) .status-dot {
  animation: clone-status-pulse 1.6s ease-in-out infinite;
}

.clone-status[data-phase="ready"] {
  padding-right: 30px;
}

.clone-status[data-phase="ready"] .clone-status-close {
  display: flex;
}

@keyframes clone-status-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.82); }
}

@media (prefers-reduced-motion: reduce) {
  .clone-status .status-dot { animation: none; }
  .clone-status-close { transition: none; }
}

/* ==================================================================
   CLONE PROGRESSIVE DISCLOSURE (cps-*)
   Two synced surfaces: a checklist card streamed into the chat, and a
   skeleton page in the artifact pane that builds section-by-section.
   ================================================================== */

/* --- surface 1: the chat checklist card --- */
.cps-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--cream);
  box-shadow: var(--shadow-sm);
}
.cps-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.cps-kicker {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.cps-elapsed {
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
/* Scoped under .cps-card so the reset beats `.msg-content ol` (markdown-list
   styling adds margin-left:22px, which would otherwise indent the checklist
   away from the card heading). */
.cps-card .cps-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cps-step {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: start;
  gap: 10px;
  opacity: 0.5;
  transition: opacity 240ms ease;
}
.cps-step.is-active,
.cps-step.is-complete { opacity: 1; }

/* the round marker: pending ring -> spinning ring (active) -> check (complete) */
.cps-mark {
  position: relative;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  flex: 0 0 auto;
}
/* Pending step: static Lucide `circle` outline. */
.cps-circle {
  position: absolute;
  inset: 0;
  width: 18px;
  height: 18px;
  stroke-width: 2;
  color: var(--border);
}
/* Active step: hide the pending circle, show the spinning Lucide `loader`. */
.cps-step.is-active .cps-circle { display: none; }
.cps-spinner {
  position: absolute;
  inset: 0;
  width: 18px;
  height: 18px;
  stroke-width: 2.5;
  color: var(--accent);
  opacity: 0;
}
.cps-step.is-active .cps-spinner {
  opacity: 1;
  animation: cps-spin 0.8s linear infinite;
}
.cps-step.is-complete .cps-spinner { display: none; }
.cps-check {
  position: absolute;
  inset: 0;
  width: 18px;
  height: 18px;
  stroke-width: 3;
  color: #fff;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 200ms ease, transform 240ms var(--spring);
}
.cps-step.is-complete .cps-mark { background: var(--green); border-radius: 50%; }
.cps-step.is-complete .cps-circle { display: none; }
.cps-step.is-complete .cps-check { opacity: 1; transform: scale(1); }

.cps-copy { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.cps-line {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.35;
  color: var(--text);
}
.cps-step:not(.is-active):not(.is-complete) .cps-line { color: var(--text-muted); }
.cps-time {
  font-family: var(--mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  margin-top: 2px;
}

/* rebuild sub-detail: "section k / N" + a segmented progress bar */
.cps-detail { display: none; flex-direction: column; gap: 6px; }
.cps-step.is-active .cps-detail { display: flex; }
.cps-readout {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.cps-segments { display: flex; gap: 3px; }
.cps-seg {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--surface3);
  transition: background-color 260ms ease;
}
.cps-seg.is-filled { background: var(--accent); }

/* --- surface 2: the artifact-pane skeleton (brand-tinted) --- */
/* --sk-* are set inline from the selected brand profile's palette on clone_measured;
   the values here are warm fallbacks so it's never a grey wireframe. */
.cps-skeleton {
  --sk-bg: #ffffff;
  --sk-block: #cdd6cc;   /* sage image blocks */
  --sk-accent: #e2a982;  /* peach accent discs / CTAs */
  --sk-bar: color-mix(in srgb, var(--sk-accent) 18%, var(--sk-bg));  /* warm text bars */

  position: absolute;
  inset: 0;
  /* Below .retro-screen::before (3), which carries the recession and CRT curve.
     The skeleton is the page being built, not chrome — it has to sit under the
     same glass the finished page sits under, or the curve pops in at the moment
     the skeleton fades out. Still above .retro-viewport (auto), so it covers the
     iframe; now below the DRAFT ring (4) and ribbon (5), which is correct since
     those are chrome. */
  z-index: 2;
  display: flex;
  flex-direction: column;
  background: var(--sk-bg);
  opacity: 1;
  transition: opacity 620ms ease;
}
.cps-skeleton.is-done { opacity: 0; pointer-events: none; }

/* "reading the page" splash shown before section count is known */
.cps-reading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--sk-bg);
  transition: opacity 320ms ease;
}
.cps-skeleton:not(.is-reading) .cps-reading { opacity: 0; pointer-events: none; }
.cps-reading-shimmer {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: cps-spin 0.9s linear infinite;
}
.cps-reading-label {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text-muted);
}

.cps-blocks {
  flex: 1;
  min-height: 0;
  overflow: hidden auto;
  padding: 0;
  scroll-behavior: smooth;
  background: var(--sk-bg);
}
.cps-block {
  display: flex;
  border-bottom: 1px solid color-mix(in srgb, var(--sk-accent) 10%, transparent);
  transition: background-color 300ms ease;
}
.cps-block.dark { background: color-mix(in srgb, var(--sk-accent) 16%, #211d1a); }
.cps-content {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 26px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}
.cps-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: center; width: 100%; }
.cps-row2.flip { direction: rtl; }
.cps-row2.flip > * { direction: ltr; }
.cps-col { display: flex; flex-direction: column; gap: 9px; }
.cps-center { align-items: center; text-align: center; }
.cps-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; width: 100%; }
.cps-mini { display: flex; flex-direction: column; gap: 8px; }

/* skeleton primitives — brand-tinted bars/blocks (warm, not grey) */
.cps-h, .cps-l, .cps-btn, .cps-img, .cps-fill {
  border-radius: 5px;
  background: var(--sk-bar);
}
.cps-h { height: 16px; }
.cps-l { height: 9px; }
.cps-btn { height: 26px; width: 100px; border-radius: 8px; margin-top: 4px; background: color-mix(in srgb, var(--sk-accent) 58%, var(--sk-bg)); }
.cps-img { width: 100%; border-radius: 8px; background: var(--sk-block); position: relative; overflow: hidden; }
/* centred accent disc echoes a brand image/photo focal point */
.cps-img::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 22%; min-width: 20px; max-width: 60px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--sk-accent);
  opacity: 0.5;
}
/* text bars inside dark bands (announcement / footer) need a light warm tone */
.cps-block.dark .cps-fill { background: color-mix(in srgb, #fff 55%, var(--sk-accent)); }

/* --- build mode: the blueprint pass --- */
/* A clone paints the solid skeleton above because it measured a real page. A build has
   seen nothing yet, so painting solid blocks would be asserting a layout we haven't
   chosen. These frames say "planned, not built": graph paper, dashed rules, a name
   pencilled in the margin. Each one is REPLACED by its .cps-block sibling above the
   moment that section's HTML lands, so the pane converts top-down as the agent writes. */
.cps-skeleton.is-blueprint { --sk-bg: #fdfdfb; }
.cps-block.blueprint {
  position: relative;
  display: block;
  min-height: var(--bp-h, 200px);
  padding: 26px 34px;
  border-bottom: 1px dashed rgba(87, 130, 146, 0.25);
  background:
    linear-gradient(rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.72)),
    repeating-linear-gradient(0deg, transparent 0 23px, rgba(93, 132, 146, 0.08) 23px 24px);
  opacity: 0;
  animation: cps-bp-rise 420ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  animation-delay: var(--bp-stagger, 0ms);
}
/* the section's name, pencilled in the margin */
.cps-block.blueprint::after {
  content: attr(data-label);
  position: absolute;
  right: 16px;
  bottom: 10px;
  color: rgba(66, 111, 130, 0.58);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cps-frame {
  display: grid;
  width: 100%;
  height: calc(var(--bp-h, 200px) - 52px);
  padding: 18px;
  gap: 9px;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(6, 1fr);
  border: 1.5px dashed rgba(69, 117, 138, 0.48);
  /* uneven corners and a fraction of a degree off true — drawn, not printed */
  border-radius: 3px 8px 4px 6px;
  transform: rotate(var(--bp-tilt, 0deg));
}
.cps-frame > span {
  border: 1px dashed rgba(69, 117, 138, 0.36);
  background: rgba(105, 151, 168, 0.06);
}
.cps-frame > .line { height: 7px; align-self: center; border-width: 0 0 1px; }
.cps-frame > .circle { aspect-ratio: 1; align-self: center; border-radius: 50%; }

/* per-section plans — which cells the frame's parts occupy */
.p-hero .a { grid-area: 1 / 1 / 2 / 6; }
.p-hero .b { grid-area: 2 / 1 / 4 / 7; }
.p-hero .c { grid-area: 4 / 1 / 5 / 6; }
.p-hero .d { grid-area: 1 / 8 / 7 / 13; border-radius: 48%; }
.p-trust .cps-frame { grid-template-rows: 1fr; align-items: center; }
.p-trust .a { grid-column: 1 / 4; }
.p-trust .b { grid-column: 5 / 8; }
.p-trust .c { grid-column: 9 / 13; }
.p-problem .a { grid-area: 1 / 1 / 7 / 6; border-radius: 50%; }
.p-problem .b { grid-area: 1 / 7 / 2 / 13; }
.p-problem .c { grid-area: 2 / 7 / 4 / 13; }
.p-problem .d { grid-area: 4 / 7 / 6 / 12; }
.p-benefits .a { grid-area: 1 / 3 / 2 / 11; }
.p-benefits .b { grid-area: 2 / 1 / 7 / 5; }
.p-benefits .c { grid-area: 2 / 5 / 7 / 9; }
.p-benefits .d { grid-area: 2 / 9 / 7 / 13; }
.p-quote .a, .p-final .a { grid-area: 1 / 2 / 3 / 12; }
.p-quote .b, .p-final .b { grid-area: 4 / 4 / 5 / 10; }

/* a frame giving way to the written section */
.cps-block.lands { animation: cps-bp-land 380ms cubic-bezier(0.34, 1.56, 0.64, 1); }

@keyframes cps-bp-rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes cps-bp-land {
  from { opacity: 0.35; transform: scale(0.985); }
  to   { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .cps-block.blueprint { opacity: 1; animation: none; }
  .cps-block.lands { animation: none; }
}

/* build states: gentle pulse while building/current, solid once built */
.cps-block.building .cps-content,
.cps-block.current .cps-content { animation: cps-pulse 1.5s ease-in-out infinite; }
.cps-block.current { box-shadow: inset 3px 0 0 var(--sk-accent); }
.cps-block.built .cps-content { opacity: 1; animation: none; }

@keyframes cps-spin { to { transform: rotate(360deg); } }
@keyframes cps-pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 0.82; } }

@media (prefers-reduced-motion: reduce) {
  .cps-step.is-active .cps-spinner,
  .cps-reading-shimmer { animation: none; }
  .cps-block.building .cps-content,
  .cps-block.current .cps-content { animation: none; opacity: 0.7; }
}

/* Viewport wrapper — constrains iframe width for breakpoint preview */
.retro-viewport {
  position: relative;
  display: flex;
  flex-direction: column;
  align-self: stretch;
  height: 100%;
  width: 100%;
  min-width: 0;                  /* defensive: flex children default to min-content width */
  margin: 0 auto;
  transition: max-width 220ms ease;
}
.retro-viewport.bp-mobile  { max-width: 375px; }
.retro-viewport.bp-tablet  { max-width: 768px; }
.retro-viewport.bp-desktop { max-width: none; }

.retro-preview-error {
  position: relative;
  z-index: 2;
  width: min(360px, calc(100% - 32px));
  margin: auto;
  padding: 30px 28px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--cream);
  box-shadow: var(--shadow-md);
  text-align: center;
  transform: rotate(-0.35deg);
}
.retro-preview-error::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 50%;
  width: 70px;
  height: 18px;
  background: var(--tape);
  box-shadow: var(--shadow-sm);
  transform: translateX(-50%) rotate(1.5deg);
}
.retro-preview-error-title {
  display: block;
  color: var(--text);
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.2;
}
.retro-preview-error-copy {
  margin: 7px 0 18px;
  color: var(--text-muted);
  font-family: var(--sans);
  font-size: 13px;
}
.retro-preview-error-retry {
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  background: var(--accent);
  color: var(--accent-contrast);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
}
.retro-preview-error-retry:hover { background: var(--accent-hover); }
.retro-preview-error-retry:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* When the iframe is constrained, shrink the artifact pane to the iframe width
   + chrome. Chrome is 86px, measured, counting BOTH sides of everything:
     pane-output padding  2x14 = 28
     monitor margin       2x8  = 16
     screen margin        2x17 = 34
     screen border        2x4  =  8
   The previous value (66) counted the monitor margin on one side only, so the
   mobile preview rendered 367px wide while claiming 375px. If the screen's
   margin or border changes, this number moves with it or the constrained
   iframe gets squeezed below its breakpoint width.
   Chat pane grows to fill the freed space.
   Resizer is hidden — the panel is fixed by the breakpoint, not draggable.
   Scoped to .retro-active so the rule doesn't fire when the user leaves
   retro mode (the viewport's bp-* class lingers in the hidden DOM). */
.chat-panes:has(.artifact-page.retro-active .retro-viewport.bp-mobile) .pane-output { flex: 0 0 calc(375px + 86px); }
.chat-panes:has(.artifact-page.retro-active .retro-viewport.bp-tablet) .pane-output { flex: 0 0 calc(768px + 86px); }
.chat-panes:has(.artifact-page.retro-active .retro-viewport.bp-mobile) .pane-agent,
.chat-panes:has(.artifact-page.retro-active .retro-viewport.bp-tablet) .pane-agent {
  flex: 1 1 0;
  width: auto;
}
.chat-panes:has(.artifact-page.retro-active .retro-viewport.bp-mobile) .pane-resizer,
.chat-panes:has(.artifact-page.retro-active .retro-viewport.bp-tablet) .pane-resizer {
  display: none;
}
/* Animates the pane shrink/grow on breakpoint toggle. Only the bp rules
   above mutate flex-basis today — the resizer drags --pane-split / width.
   If a future change touches flex-basis on .pane-output during drag, scope
   this transition tighter to avoid sluggish drag. */
.pane-output { transition: flex-basis 220ms ease; }

/* Toolbar — monitor chin */
.retro-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  min-height: 44px;
}

.retro-btn {
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 11px;
  padding: 4px 12px;
  border: 1px solid #a89880;
  border-radius: 4px;
  background: linear-gradient(to bottom, #ddd5c8, #cec5b6);
  color: #5a5248;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: background 0.15s;
}

.retro-btn:hover:not(:disabled) {
  background: linear-gradient(to bottom, #d5cdc0, #c6bcac);
}

.retro-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.retro-spacer {
  flex: 1;
}

/* Breakpoint segmented control — sits next to undo/redo */
.retro-breakpoints {
  display: flex;
  flex: 0 0 auto;
  border: 1px solid #a89880;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.retro-bp-btn {
  width: 28px;
  height: 24px;
  flex: 0 0 28px;
  padding: 0;
  border: none;
  background: linear-gradient(to bottom, #ddd5c8, #cec5b6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.retro-bp-btn + .retro-bp-btn {
  border-left: 1px solid #a89880;
}
.retro-bp-btn:hover {
  background: linear-gradient(to bottom, #d5cdc0, #c6bcac);
}
.retro-bp-btn[aria-pressed="true"] {
  background: linear-gradient(to bottom, #c6bcac, #d5cdc0);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
}
.retro-bp-btn svg {
  stroke: #5a5248;
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
}

/* Publish button + dropdown wrapper */
.retro-publish-wrap {
  position: relative;
}

.retro-deploy-btn {
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 11px;
  padding: 4px 14px;
  border: 1px solid #6b5535;
  border-radius: 4px;
  background: linear-gradient(to bottom, #9a7d54, #7a6240);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: background 0.15s;
}

.retro-deploy-btn:hover {
  background: #9a7d54;
}

.retro-deploy-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Publish dropdown panel */
.retro-publish-panel {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  width: 280px;
  background: #fffcf5;
  border: 1px solid rgba(139, 111, 71, 0.2);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.06);
  z-index: 60;
}

.retro-publish-panel.is-open {
  display: block;
}

/* Always-on Tracking tool — left side of the toolbar (next to Duplicate), so
   the per-page tracking control is reachable in every state, not only at
   go-live. Reuses .retro-publish-panel chrome but opens left-aligned. */
.retro-track-wrap {
  position: relative;
  display: inline-flex;
}
.retro-track-pop.retro-publish-panel {
  left: 0;
  right: auto;
}

.retro-panel-url {
  display: block;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 11px;
  color: #5a5248;
  text-decoration: none;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 6px;
  margin-bottom: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.retro-panel-url:hover {
  background: rgba(0, 0, 0, 0.07);
  color: #3d342b;
}

.retro-panel-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 11px;
  color: #8a7e70;
  margin-bottom: 14px;
  padding: 0 2px;
}

.retro-panel-icon {
  font-size: 15px;
  vertical-align: -1px;
}

.retro-panel-edits {
  color: #5a5248;
}

.retro-panel-update {
  display: block;
  width: 100%;
  padding: 9px 14px;
  border: 1px solid #6b5535;
  border-radius: 4px;
  background: linear-gradient(to bottom, #9a7d54, #7a6240);
  color: #fff;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: background 0.15s;
  margin-top: 4px;
}

.retro-panel-update:hover {
  background: #9a7d54;
}

.retro-panel-update:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ===== Draft → Make it live toolbar ===== */
/* LEFT slot — Share draft (safe, beige) */
.retro-share-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 11px;
  color: #5a5248;
  background: linear-gradient(to bottom, #ece5d8, #ddd5c6);
  border: 1px solid #a89880;
  cursor: pointer;
  padding: 4px 11px;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: background 0.15s;
}
.retro-share-btn:hover { background: linear-gradient(to bottom, #e4dccd, #d3cabb); }
.retro-share-btn svg { stroke: currentColor; fill: none; flex-shrink: 0; }

/* RIGHT slot — Make it live / Publish changes (brown commit) */
.retro-commit-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 11px;
  padding: 4px 14px;
  border: 1px solid #6b5535;
  border-radius: 4px;
  background: linear-gradient(to bottom, #9a7d54, #7a6240);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: background 0.15s;
}
.retro-commit-btn:hover { background: #9a7d54; }
.retro-commit-btn.busy { opacity: 0.75; pointer-events: none; }
.retro-commit-btn svg { stroke: currentColor; fill: none; flex-shrink: 0; }

/* LIVE — solid green affordance that opens the live page */
.retro-live-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(to bottom, #13b67f, #0e9d6c);
  border: 1px solid #0a8259;
  box-shadow: 0 1px 2px rgba(10, 90, 60, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: background 0.15s;
}
.retro-live-btn:hover { background: linear-gradient(to bottom, #15c389, #0fa873); }
.retro-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
}
.retro-live-btn svg { stroke: currentColor; fill: none; flex-shrink: 0; opacity: 0.9; }

/* Share popover anchors left; confirm popover anchors right (the default). */
.retro-share-pop { left: 0; right: auto; width: 264px; }

/* Popover internals (share + confirm) */
.retro-pop-title {
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 11px;
  font-weight: 700;
  color: #5a5248;
  margin: 0 0 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.retro-pop-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.retro-pop-dot.brown { background: var(--accent); }
.retro-pop-dot.green { background: #10b981; }
.retro-pop-dot.red { background: var(--red); }
.retro-pop-sub { font-size: 11px; color: #8a7e70; margin: 0 0 10px; line-height: 1.45; }
.retro-pop-sub b { color: #6b5535; }
.retro-pop-row { display: flex; gap: 6px; }
.retro-pop-url {
  flex: 1;
  min-width: 0;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 11px;
  color: #5a5248;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.6;
}
.retro-pop-copy {
  flex-shrink: 0;
  width: 30px;
  border: 1px solid rgba(139, 111, 71, 0.22);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.03);
  color: #8a7e70;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.retro-pop-copy:hover { background: rgba(0, 0, 0, 0.06); color: #5a5248; }
.retro-pop-copy.copied { color: #059669; border-color: rgba(5, 150, 105, 0.4); }
.retro-pop-copy svg { stroke: currentColor; fill: none; }
.retro-confirm-url {
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 11px;
  color: var(--accent);
  padding: 6px 8px;
  background: rgba(139, 111, 71, 0.08);
  border-radius: 6px;
  margin: 0 0 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.retro-confirm-actions { display: flex; gap: 7px; margin-top: 12px; }
.retro-confirm-go {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #6b5535;
  border-radius: 6px;
  background: linear-gradient(to bottom, #a98744, #8a6a2f);
  color: #fff;
  font-family: var(--font-ui, 'Inter', sans-serif);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.retro-confirm-go:hover { background: #b1873f; }
.retro-confirm-cancel {
  padding: 8px 12px;
  border: 1px solid #c0b39c;
  border-radius: 6px;
  background: #fbf9f4;
  color: #6b5535;
  font-family: var(--font-ui, 'Inter', sans-serif);
  font-size: 12.5px;
  cursor: pointer;
}
.retro-confirm-cancel:hover { background: #f2ede3; }

/* Discard changes — the escape hatch on a live page with unpublished edits.
   Danger-styled (red) so it reads as "throw away", distinct from the brown
   commit button. Reuses .retro-btn chrome + .retro-publish-panel popover. */
/* Icon-only toolbar buttons (Undo, Redo, ⋯ More) — square, label lives in the
   data-tooltip. */
.retro-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  gap: 0;
  padding: 4px 8px;
  font-size: 14px;
  line-height: 1;
}
.retro-btn-icon svg { display: block; }

/* Undo / Redo — icon + visible text label. The toolbar's other utilities now live
   in the ⋯ More menu, so there's room to spell these two out instead of hiding the
   label in the tooltip. */
.retro-btn-labeled {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.retro-btn-labeled .retro-btn-ico {
  font-size: 13px;
  line-height: 1;
}

/* Toolbar tooltips open UPWARD (the toolbar sits at the bottom of the screen, so
   the default downward [data-tooltip] would clip off the monitor). */
.retro-toolbar [data-tooltip]::after { top: auto; bottom: calc(100% + 8px); }

/* ⋯ More menu — one home for the page's rare/utility actions. */
.retro-more-wrap { position: relative; display: inline-flex; }
.retro-more-wrap[hidden] { display: none; }
.retro-more-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 184px;
  background: #fffcf5;
  border: 1px solid rgba(139, 111, 71, 0.2);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 4px 16px rgba(60, 50, 40, 0.14), 0 1px 3px rgba(60, 50, 40, 0.08);
  z-index: 65;
}
.retro-more-menu.is-open { display: block; }
.retro-more-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: 6px;
  font-family: var(--sans);
  font-size: 12.5px;
  color: #4a4036;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}
.retro-more-item:hover { background: #f2ede3; }
.retro-more-item svg { flex-shrink: 0; opacity: 0.7; }
.retro-more-item-danger { color: var(--red); }
.retro-more-item-danger:hover { background: var(--red-dim); }
.retro-more-item-danger svg { opacity: 1; }

/* The Duplicate/Tracking/Discard flows keep their wraps for the close-on-outside
   logic, but render layout-transparent so their popovers anchor to .retro-more-wrap
   (i.e. open under the ⋯ button) instead of their old toolbar slots. */
.retro-more-wrap .retro-dup-wrap,
.retro-more-wrap .retro-track-wrap,
.retro-more-wrap .retro-discard-wrap { display: contents; }
.retro-more-wrap .retro-publish-panel,
.retro-more-wrap .retro-dup-pop { left: 0; right: auto; }
.retro-proxy-trigger { display: none; }
.retro-discard-go {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--red-hover);
  border-radius: 6px;
  background: var(--red);
  color: #fff;
  font-family: var(--font-ui, 'Inter', sans-serif);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.retro-discard-go:hover { background: var(--red-hover); }

/* Duplicate — inline toolbar button (beside Undo/Redo) + upward name popover */
.retro-dup-wrap {
  position: relative;
}
.retro-dup-pop {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 244px;
  background: #fffcf5;
  border: 1px solid rgba(139, 111, 71, 0.2);
  border-radius: 10px;
  padding: 13px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.06);
  z-index: 60;
}
.retro-dup-pop.is-open {
  display: block;
}
.retro-dup-title {
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 12px;
  font-weight: 600;
  color: #5a5248;
  margin: 0 0 3px;
}
.retro-dup-hint {
  font-size: 11px;
  color: #8a7e70;
  margin: 0 0 11px;
  line-height: 1.45;
}
.retro-dup-label {
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8a7e70;
  margin: 0 0 6px 2px;
}
.retro-dup-field {
  display: flex;
  align-items: center;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid rgba(139, 111, 71, 0.2);
  border-radius: 6px;
  margin-bottom: 10px;
  overflow: hidden;
}
.retro-dup-field:focus-within {
  border-color: #9a7d54;
  background: rgba(0, 0, 0, 0.02);
}
.retro-dup-prefix {
  padding: 7px 1px 7px 8px;
  color: #8a7e70;
  white-space: nowrap;
  user-select: none;
}
.retro-dup-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  font-family: inherit;
  font-size: 11px;
  color: #5a5248;
  padding: 7px 8px 7px 0;
}
.retro-dup-actions {
  display: flex;
  gap: 6px;
}
.retro-dup-go {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #6b5535;
  border-radius: 4px;
  background: linear-gradient(to bottom, #9a7d54, #7a6240);
  color: #fff;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: background 0.15s;
}
.retro-dup-go:hover {
  background: #9a7d54;
}
.retro-dup-go:disabled {
  opacity: 0.6;
  cursor: default;
}
.retro-dup-cancel {
  padding: 8px 12px;
  border: 1px solid #a89880;
  border-radius: 4px;
  background: linear-gradient(to bottom, #ddd5c8, #cec5b6);
  color: #5a5248;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 12px;
  cursor: pointer;
}
.retro-dup-done {
  display: none;
}
.retro-dup-done.show {
  display: block;
}
.retro-dup-done-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
  margin-bottom: 9px;
}

/* View Page — flat text button (no pill) beside Publish, live pages only */
.retro-view-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 11px;
  color: #6b5535;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.retro-view-btn:hover {
  background: rgba(139, 111, 71, 0.10);
  color: #4a3b22;
}
.retro-view-btn svg {
  stroke: currentColor;
  flex-shrink: 0;
}

/* ==================================================================
   CONFIRM MODAL — reusable destructive-action confirm
   ================================================================== */
.confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(60, 50, 40, 0.22);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.confirm-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.confirm-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 24px 24px 18px;
  width: min(420px, calc(100% - 40px));
  transform: translateY(12px) scale(0.96);
  opacity: 0;
  transition: transform 0.28s var(--spring), opacity 0.18s ease;
}
.confirm-backdrop.is-open .confirm-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.confirm-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0 0 8px;
  color: var(--text);
}
.confirm-body {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dim);
  margin: 0 0 22px;
}
.confirm-body strong {
  color: var(--text);
  font-weight: 600;
}

.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.confirm-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.15s var(--spring), box-shadow 0.15s ease, background 0.15s ease;
}
.confirm-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.confirm-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.confirm-btn-primary {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.confirm-btn-primary:hover {
  background: var(--red-hover);
  border-color: var(--red-hover);
}
.confirm-btn-primary.variant-accent {
  background: var(--accent);
  border-color: var(--accent);
}
.confirm-btn-primary.variant-accent:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

@media (prefers-reduced-motion: reduce) {
  .confirm-backdrop,
  .confirm-card,
  .confirm-btn { transition: none; }
}

/* ============================================================
   Image zoom lightbox — full-screen click-to-zoom for generated
   images. Wired via addDownloadButtons in chat.js.
   ============================================================ */
.image-zoom-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 12, 0.78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  cursor: zoom-out;
}
.image-zoom-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}
.image-zoom-image {
  max-width: calc(100vw - 80px);
  max-height: calc(100vh - 80px);
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  transform: scale(0.96);
  opacity: 0;
  transition: transform 0.24s var(--spring), opacity 0.18s ease;
  cursor: default;
}
.image-zoom-backdrop.is-open .image-zoom-image {
  transform: scale(1);
  opacity: 1;
}
.image-zoom-close,
.image-zoom-download {
  position: absolute;
  top: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s var(--spring);
}
.image-zoom-close { right: 16px; }
.image-zoom-download { right: 68px; }
.image-zoom-close:hover,
.image-zoom-download:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.05);
}
.image-zoom-close:focus-visible,
.image-zoom-download:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.image-zoom-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  font-family: var(--sans);
  letter-spacing: 0.02em;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .image-zoom-backdrop,
  .image-zoom-image,
  .image-zoom-close,
  .image-zoom-download { transition: none; }
}

/* ============================================================
   Ad-variants rail — apply_ad_template result bubble.
   Single chat bubble carrying N parallel image variants in a
   horizontal scroll rail at true aspect ratio (height 360px).
   ============================================================ */
.ad-variants-header {
  font-size: 13px;
  color: var(--color-text-secondary, #6b5c4b);
  margin-bottom: 10px;
  font-weight: 500;
}
.ad-variants-rail-wrap {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
}
.ad-variants-rail {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  scrollbar-width: none;           /* Firefox: hide scrollbar */
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
}
.ad-variants-rail::-webkit-scrollbar { display: none; } /* WebKit: hide scrollbar */
.ad-variants-rail .rail-item {
  flex: 0 0 auto;
  scroll-snap-align: start;
  overflow: hidden;
  border-radius: 8px;
  line-height: 0;
}
.ad-variants-rail .rail-item img {
  height: 360px;        /* fixed height; width auto = true aspect ratio */
  width: auto;
  display: block;
  /* Hard-override any global image treatment so 4:5 / 1:1 / 9:16 all read clean */
  border-radius: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  border: none !important;
  margin: 0 !important;
}
/* Skeleton placeholder shown for each pending variant while Gemini generates.
   Inline `aspect-ratio` (set in JS from template's aspect_ratio) drives width;
   height matches the eventual image at 360px so the rail doesn't reflow when
   the real image lands. Shimmer loops until the variant arrives or the run
   ends (whichever comes first — leftover skeletons are pruned in JS). */
.ad-variants-rail .rail-item-skeleton,
.ad-variants-rail .rail-photo-skeleton {
  height: 360px;
  background:
    linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.55) 50%, transparent 100%),
    linear-gradient(135deg, #f4ead9 0%, #ece0c8 100%);
  background-size: 200% 100%, 100% 100%;
  background-repeat: no-repeat;
  animation: ad-variants-skeleton-shimmer 1.6s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes ad-variants-skeleton-shimmer {
  0%   { background-position: 200% 0, 0 0; }
  100% { background-position: -100% 0, 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ad-variants-rail .rail-item-skeleton,
  .ad-variants-rail .rail-photo-skeleton { animation: none; }
}
/* Multi-template mode (cold-start exploration): each rail item is a 2-row
   stack — photo on top, agent's "why" caption beneath. Caption pre-renders
   immediately so the founder can read the reasoning while images generate. */
.ad-variants-rail .rail-item-multi {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: auto;          /* photo's natural width determines column width */
  max-width: 320px;     /* caption wraps within this width */
}
.ad-variants-rail .rail-photo {
  border-radius: 8px;
  overflow: hidden;
  line-height: 0;
}
.ad-variants-rail .rail-photo img {
  height: 360px;
  width: auto;
  display: block;
  border-radius: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  border: none !important;
  margin: 0 !important;
}
.ad-variants-rail .rail-caption {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-muted);
  font-style: italic;
  padding: 0 2px;
  /* Cap the caption block height so very long "why" strings don't unbalance
     the rail — clamp at ~3 lines, ellipsize after. */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Fade-right edge: hints at horizontal scrollability. Base colour matches the
   assistant bubble background (--bubble-bg / #fff) so the fade reads as the
   rail running into the bubble's edge, not into the page. */
.ad-variants-rail-wrap::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 28px;
  pointer-events: none;
  background: linear-gradient(to left, var(--bubble-bg, #fff) 0%, rgba(255, 255, 255, 0) 100%);
  border-radius: 0 8px 8px 0;
}
/* Suggestion pills row — three cross-category template alternatives
   above the same-template fallback. Server picks; client renders. */
.ad-variants-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.ad-variants-suggestion-pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 13px;
  background: #fffaf0;
  border: 1px solid #d8c4a3;
  border-radius: 999px;
  color: #5c4a30;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(120, 80, 30, 0.06);
  transition:
    transform 100ms ease-out,
    box-shadow 100ms ease-out,
    border-color 100ms ease-out,
    background-color 100ms ease-out;
}
.ad-variants-suggestion-pill:hover {
  background: #fff5e6;
  border-color: #b89870;
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(120, 80, 30, 0.12);
}
.ad-variants-suggestion-pill:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(120, 80, 30, 0.06);
}
.ad-variants-suggestion-pill.browse-all {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  font-weight: 500;
}
.ad-variants-suggestion-pill.browse-all:hover {
  background: #1a1612;
  border-color: #1a1612;
}
/* Footer CTA pill — same-template fallback, de-emphasized below the
   suggestion pills. Clicking fires a new /api/run with a fresh per-turn cap. */
.ad-variants-footer-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 8px 14px;
  background: transparent;
  border: 1px dashed #c7b89c;
  border-radius: 999px;
  color: #8a6a4a;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ad-variants-footer-cta:hover {
  background: rgba(255, 248, 235, 0.8);
  border-color: #8a6a4a;
  color: #6b4a2a;
  transform: translateY(-1px);
}
/* Fallback note when every variant failed — quiet error inside the bubble */
.ad-variants-failed-note {
  font-size: 13px;
  color: var(--color-text-secondary, #6b5c4b);
  margin-top: 10px;
  font-style: italic;
}
/* "Download all for Meta" — solid accent, the one-click run handoff (non-drafts) */
.ad-variants-download-all {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 9px 16px;
  background: linear-gradient(180deg, var(--accent-hover), var(--accent)); border: none; border-radius: 999px;
  color: #fff; font-size: 12.5px; font-weight: 600; font-family: inherit; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: transform 0.15s var(--spring), box-shadow 0.15s, filter 0.15s;
}
.ad-variants-download-all:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.ad-variants-download-all:disabled { filter: grayscale(0.5) brightness(1.1); opacity: 0.6; cursor: progress; }
/* Draft-run handoff note — drafts get a finalize nudge instead of download-all */
.ad-variants-draft-note {
  margin-top: 12px; font-size: 12.5px; color: var(--text-dim); line-height: 1.5;
  border-top: 1px solid var(--border); padding-top: 11px;
}
.ad-variants-draft-note b { font-weight: 700; color: var(--text); }
@media (prefers-reduced-motion: reduce) {
  .ad-variants-download-all { transition: none; }
  .ad-variants-download-all:hover:not(:disabled) { transform: none; }
}

/* ==================================================================
   PAGE TRACKING — gear popover, Publish-menu section, banner, card popover
   ================================================================== */

/* ---- Shared input field (used in popover + edit form) ---- */
.tracking-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tracking-field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.tracking-field-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.tracking-field-helper {
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 10px;
  color: var(--text-muted);
}
.tracking-input-wrap {
  position: relative;
}
.tracking-input {
  width: 100%;
  padding: 7px 28px 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 12px;
  background: var(--surface);
  color: var(--text);
  letter-spacing: 0.4px;
}
.tracking-input:focus {
  outline: none;
  border-color: var(--accent);
}
.tracking-input.is-valid { border-color: var(--green, #059669); }
.tracking-input.is-invalid { border-color: var(--red, #c44545); }
.tracking-state-icon {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}
.tracking-state-icon.valid { color: var(--green, #059669); }
.tracking-state-icon.invalid { color: var(--red, #c44545); }

.tracking-field-compact { gap: 3px; }
.tracking-field-compact + .tracking-field-compact { margin-top: 10px; }

/* ---- Gear icon (T8) ---- */
.tracking-gear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  /* Circle — rotates invisibly with the cog. */
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, transform 220ms var(--spring);
  outline: none;
}
.tracking-gear:hover {
  color: var(--accent);
  background: var(--accent-soft, rgba(139, 111, 71, 0.08));
  transform: rotate(20deg);
}
.tracking-gear.is-open {
  color: var(--accent);
  transform: rotate(40deg);
}
/* Background tint instead of a ring — a ring tracks the rotated bounding box
   and reads as a tilted hexagon around the cog. */
.tracking-gear:focus-visible {
  background: var(--accent-soft, rgba(139, 111, 71, 0.12));
}

/* ---- Gear popover (appended to body) ---- */
.tracking-popover {
  /* Must be fixed in CSS, not just JS — entering normal flow on append
     shifts body layout and skews the anchor measurement. */
  position: fixed;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg, 4px 6px 24px rgba(60, 50, 40, 0.1));
  padding: 14px;
  font-family: var(--sans, system-ui, sans-serif);
  z-index: 1000;
}
.tracking-popover-header {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
  min-width: 0;
}
.tracking-popover-title {
  font-family: var(--serif, Georgia, serif);
  font-weight: 500;
  font-size: 16px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tracking-popover-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 2px;
}
.tracking-popover-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}
.tracking-popover-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
}
.tracking-popover-hint {
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
  font-family: var(--serif, Georgia, serif);
}
.tracking-btn-primary {
  appearance: none;
  background: linear-gradient(180deg, var(--accent-hover, #9a7d54), var(--accent, #8b6f47));
  color: #fff;
  border: 1px solid var(--accent, #8b6f47);
  border-radius: 6px;
  padding: 6px 14px;
  font-family: var(--sans, system-ui, sans-serif);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(60, 50, 40, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: background 160ms ease, transform 120ms ease, box-shadow 160ms ease;
}
.tracking-btn-primary:hover {
  background: var(--accent-hover, #9a7d54);
  border-color: var(--accent-hover, #9a7d54);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(60, 50, 40, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.tracking-btn-primary:disabled { opacity: 0.6; cursor: default; transform: none; }

/* Custom domain lost its standalone header pill — it now lives inside the gear
   menu alongside Tracking scripts. Two settings, one control. */

/* ---- Custom domain settings overlay / modal ---- */
.domain-settings-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(40, 32, 24, 0.45);
  z-index: 1100;
  align-items: center;
  justify-content: center;
}
.domain-settings-overlay.is-open { display: flex; }
.domain-settings-modal {
  position: relative;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg, 4px 6px 24px rgba(60, 50, 40, 0.1));
  padding: 24px;
  width: 600px;
  max-width: calc(100vw - 32px);
  font-family: var(--sans, system-ui, sans-serif);
}
.domain-settings-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}
.domain-settings-close:hover { color: var(--text); }
.domain-settings-body h3 {
  font-family: var(--serif, Georgia, serif);
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
  margin: 0 0 8px;
}
.domain-settings-body p { font-size: 13px; color: var(--text-muted); margin: 0 0 12px; }
.domain-settings-body input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--sans, system-ui, sans-serif);
  color: var(--text);
  background: var(--input-bg, var(--surface));
  margin-bottom: 10px;
}
.domain-settings-body button {
  appearance: none;
  background: linear-gradient(180deg, var(--accent-hover, #9a7d54), var(--accent, #8b6f47));
  color: #fff;
  border: 1px solid var(--accent, #8b6f47);
  border-radius: 6px;
  padding: 7px 16px;
  font-family: var(--sans, system-ui, sans-serif);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms ease, transform 120ms ease;
}
.domain-settings-body button:hover { background: var(--accent-hover, #9a7d54); transform: translateY(-1px); }

/* Page-cloner modal uses the approved compact custom-domain modal construction. */
.pages-clone-modal { width: 440px; }
.pages-clone-modal .domain-settings-body h3 { margin-bottom: 14px; }
.pages-clone-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.pages-clone-controls input,
.pages-clone-controls textarea { margin-bottom: 0; }
.pages-clone-controls input:focus,
.pages-clone-controls textarea:focus {
  outline: 2px solid var(--border-light);
  border-color: var(--accent);
}
.pages-clone-modal-label {
  margin: 6px 0 -2px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.pages-clone-optional {
  font-weight: 400;
  opacity: 0.8;
}
.pages-clone-intent {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  font-family: var(--sans, system-ui, sans-serif);
  color: var(--text);
  background: var(--input-bg, var(--surface));
  resize: none;
  min-height: 76px;
  line-height: 1.45;
}
.pages-clone-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}
.pages-clone-modal .pages-clone-url.is-invalid { border-color: var(--red); }
.pages-clone-modal .pages-clone-error {
  grid-column: 1 / -1;
  color: var(--red);
  font-size: 12px;
  line-height: 1.4;
  margin: 0;
}
.pages-clone-error[hidden] { display: none; }

@media (max-width: 677px) {
  .pages-clone-controls { grid-template-columns: 1fr; }
}

/* ---- DNS record rows ---- */
.dns-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  background: var(--bg-subtle, #faf8f5);
  border: 1px solid var(--border-light, rgba(139, 111, 71, 0.15));
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  margin-bottom: 6px;
  color: var(--text);
}
.dns-row b { color: var(--text-muted); font-weight: 600; }
.dns-row code {
  font-family: var(--mono, monospace);
  font-size: 11px;
  background: var(--surface, #fff);
  border: 1px solid var(--border-light, rgba(139, 111, 71, 0.12));
  border-radius: 4px;
  padding: 1px 5px;
}
.dns-row button {
  margin-left: auto;
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 400;
  font-family: var(--sans, system-ui, sans-serif);
  transform: none;
}
.dns-row button:hover { color: var(--accent); border-color: var(--accent); transform: none; }

/* ---- Custom-domain modal inner components (cd-*) ---- */
/* Note: plan specified var(--error) which is not defined in :root; substituted var(--red) */
.cd-steps { margin: 0 0 1rem; padding-left: 1.2rem; color: var(--text-muted); font-size: .9rem; line-height: 1.6; }
.cd-record { border: 1px solid var(--border); border-radius: 10px; padding: .6rem .75rem; margin: .5rem 0; background: var(--surface); }
.cd-record-pending { border-style: dashed; background: transparent; opacity: .85; }
.cd-pending-note { color: var(--text-muted); font-size: .82rem; line-height: 1.4; }
.cd-field { display: flex; align-items: center; gap: .5rem; padding: .2rem 0; }
.cd-flabel { width: 3.2rem; color: var(--text-muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; }
.cd-field code { flex: 1; overflow-x: auto; white-space: nowrap; font-size: .82rem; }
.cd-copy { border: 1px solid var(--border); background: transparent; border-radius: 6px; padding: .15rem .5rem; font-size: .75rem; cursor: pointer; }
.cd-copy:hover { border-color: var(--accent); color: var(--accent); }
.cd-hint { color: var(--text-muted); font-size: .8rem; line-height: 1.5; margin: .6rem 0; }
.cd-status { color: var(--text-muted); font-size: .85rem; margin: .6rem 0; }
.cd-error { color: var(--red); font-size: .85rem; }
.cd-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }
.cd-primary { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: .5rem .9rem; cursor: pointer; }
.cd-secondary { background: transparent; color: inherit; border: 1px solid var(--border); border-radius: 8px; padding: .5rem .9rem; cursor: pointer; }
.cd-secondary:hover { border-color: var(--accent); }
.cd-danger-link { background: none; border: none; color: var(--red); font-size: .8rem; cursor: pointer; text-decoration: underline; padding: 0; }
.cd-livelink { color: var(--accent); font-weight: 600; text-decoration: none; }

/* ---- Tracking section in Publish menu + card popover ---- */
.publish-tracking {
  padding: 10px 0 4px;
  margin: 6px 0 10px;
  border-top: 1px solid rgba(139, 111, 71, 0.12);
}
/* Inside a popover body, the header already delineates the section. */
.tracking-popover-body > .publish-tracking {
  margin: 0;
  padding: 0;
  border-top: none;
}
.tracking-head-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 8px;
}
.tracking-label-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.tracking-edit-link {
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  font-style: italic;
  font-family: var(--serif, Georgia, serif);
  border-bottom: 1px dotted transparent;
  padding-bottom: 1px;
  transition: color 160ms ease, border-color 160ms ease;
}
.tracking-edit-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tracking-edit-link.is-hidden,
.tracking-edit-actions.is-hidden,
.tracking-status-wrap.is-hidden,
.tracking-form-wrap.is-hidden { display: none; }

.tracking-edit-actions {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
}
.tracking-action-link {
  font-size: 11px;
  cursor: pointer;
  font-style: italic;
  font-family: var(--serif, Georgia, serif);
  border-bottom: 1px dotted transparent;
  padding-bottom: 1px;
  transition: color 160ms ease, border-color 160ms ease;
}
.tracking-action-link.is-cancel { color: var(--text-muted); }
.tracking-action-link.is-cancel:hover {
  color: var(--text-dim);
  border-bottom-color: var(--text-dim);
}
.tracking-action-link.is-save {
  color: var(--accent);
  font-weight: 600;
}
.tracking-action-link.is-save:hover {
  color: var(--accent-hover, #9a7d54);
  border-bottom-color: var(--accent-hover, #9a7d54);
}

.tracking-toggle {
  margin-left: auto;
  position: relative;
  width: 32px;
  height: 18px;
  background: var(--surface2, #f4f3f1);
  border-radius: 999px;
  border: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  appearance: none;
  padding: 0;
  transition: background 160ms ease, border-color 160ms ease;
}
.tracking-toggle::after {
  content: '';
  position: absolute;
  top: 1px; left: 1px;
  width: 14px; height: 14px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: transform 200ms var(--spring, cubic-bezier(0.34, 1.56, 0.64, 1));
}
.tracking-toggle.is-on {
  background: var(--green, #059669);
  border-color: var(--green, #059669);
}
.tracking-toggle.is-on::after { transform: translateX(14px); }

.tracking-status-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 4px 8px;
  background: rgba(139, 111, 71, 0.04);
  border-radius: 6px;
}
.tracking-status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 4px;
  font-family: var(--mono, ui-monospace, Menlo, monospace);
}
.tracking-status-item + .tracking-status-item {
  border-top: 1px dashed var(--border-light, rgba(175, 170, 162, 0.18));
}
.tracking-status-name {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.3px;
}
.tracking-status-icon {
  font-size: 13px;
  font-weight: 700;
  width: 16px;
  text-align: center;
}
.tracking-status-icon.is-active { color: var(--text-dim); }
.tracking-status-icon.is-inactive { color: var(--red, #c44545); }
.tracking-status-empty {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  font-family: var(--serif, Georgia, serif);
  padding: 0 4px;
}

.tracking-edit-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px 4px 0;
}
.override-mini-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.override-mini-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.override-mini-input {
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 11px;
  background: var(--surface);
  letter-spacing: 0.4px;
}
.override-mini-input:focus { outline: none; border-color: var(--accent); }
.tracking-edit-hint {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
  font-family: var(--serif, Georgia, serif);
  padding-top: 4px;
}

/* ---- Custom-script textarea (team gear + per-page override) ---- */
.tracking-textarea {
  width: 100%;
  min-height: 92px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 11px;
  line-height: 1.5;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  letter-spacing: 0.2px;
}
.tracking-textarea:focus { outline: none; border-color: var(--accent); }
.tracking-textarea::placeholder {
  color: var(--text-muted);
  font-style: italic;
  font-family: var(--serif, Georgia, serif);
  letter-spacing: 0;
}
.override-mini-textarea {
  min-height: 76px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: var(--mono, ui-monospace, Menlo, monospace);
  font-size: 11px;
  line-height: 1.5;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  letter-spacing: 0.2px;
}
.override-mini-textarea:focus { outline: none; border-color: var(--accent); }
.override-mini-textarea::placeholder {
  color: var(--text-muted);
  font-style: italic;
  font-family: var(--serif, Georgia, serif);
  letter-spacing: 0;
}
.tracking-textarea-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-muted);
}
.tracking-textarea-meta .count {
  font-family: var(--mono, ui-monospace, Menlo, monospace);
}
.tracking-textarea-meta .count.is-over {
  color: var(--red, #c44545);
  font-weight: 600;
}
.tracking-textarea-meta .hint {
  font-family: var(--serif, Georgia, serif);
  font-style: italic;
}
/* Dashed divider above the custom field — visually marks it as the
   "everything else" bucket below the structured ID inputs. */
.tracking-field-divider {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

/* ---- Banner (Pages tab, after team settings change) ---- */
.tracking-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm, 0 1px 3px rgba(60, 50, 40, 0.06));
  margin-bottom: 16px;
}
.tracking-banner.is-hidden { display: none; }
.tracking-banner-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.tracking-banner-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.tracking-banner.state-stale .tracking-banner-icon {
  background: var(--amber-soft, rgba(184, 134, 43, 0.1));
  color: var(--amber, #b8862b);
}
.tracking-banner.state-progress .tracking-banner-icon {
  background: var(--accent-soft, rgba(139, 111, 71, 0.08));
  color: var(--accent);
  animation: tracking-spin 1.2s linear infinite;
}
.tracking-banner.state-done .tracking-banner-icon {
  background: var(--green-soft, rgba(5, 150, 105, 0.1));
  color: var(--green, #059669);
}
@keyframes tracking-spin {
  to { transform: rotate(360deg); }
}
.tracking-banner-text {
  font-size: 13px;
  color: var(--text);
}
.tracking-banner-text strong { font-weight: 600; }
.tracking-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.tracking-banner-action {
  appearance: none;
  background: var(--accent, #8b6f47);
  color: #fff;
  border: 1px solid var(--accent, #8b6f47);
  border-radius: 6px;
  padding: 5px 12px;
  font-family: var(--sans, system-ui, sans-serif);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms ease;
}
.tracking-banner-action:hover {
  background: var(--accent-hover, #9a7d54);
  border-color: var(--accent-hover, #9a7d54);
}
.tracking-banner-action.is-secondary {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border);
}
.tracking-banner-action.is-secondary:hover {
  background: var(--surface2, #f4f3f1);
  color: var(--text);
}
.tracking-banner-dismiss {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
}
.tracking-banner-dismiss:hover {
  background: var(--surface2, #f4f3f1);
  color: var(--text);
}

/* ---- Per-page card menu Tracking item ---- */
.pages-menu-tracking svg { color: var(--text-muted); }

/* ============================================================
   Template browser panel — slides in from the right when the
   "Browse all" chip is clicked in the ad-variants bubble.
   17 wireframe cards; hover overlay surfaces the "why effective".
   ============================================================ */
.tp-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 12, 0);
  pointer-events: none;
  transition: background 0.24s ease;
  z-index: 9998;
}
.tp-backdrop.is-open {
  background: rgba(20, 16, 12, 0.22);
  pointer-events: auto;
}
.tp-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 460px;
  max-width: 92vw;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.28s var(--spring);
  z-index: 9999;
  display: flex;
  flex-direction: column;
}
.tp-panel.is-open { transform: translateX(0); }
.tp-header {
  padding: 22px 24px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  background: var(--surface);
  flex: 0 0 auto;
}
.tp-title {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  margin: 0;
  line-height: 1.1;
  color: var(--text);
}
.tp-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0 0;
}
.tp-close {
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.tp-close:hover { background: var(--surface2); color: var(--text); }
.tp-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 24px;
}
.tp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.tp-loading,
.tp-error {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  padding: 32px 0;
}
.tp-error { color: var(--red); }

.tp-card {
  position: relative;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 12px 10px;
  cursor: pointer;
  transition: transform 0.18s var(--spring), box-shadow 0.18s ease;
  text-align: left;
  font-family: var(--sans);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  color: var(--text);
}
.tp-card:hover,
.tp-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
  outline: none;
}
.tp-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.tp-compliance {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 99px;
  letter-spacing: 0.04em;
  font-weight: 500;
  white-space: nowrap;
  background: var(--red-dim);
  color: var(--red);
}
.tp-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    to top,
    var(--cream) 0%,
    var(--cream) 75%,
    color-mix(in srgb, var(--cream) 96%, transparent) 92%,
    color-mix(in srgb, var(--cream) 0%, transparent) 100%
  );
  padding: 18px 14px 12px;
  transform: translateY(8px);
  opacity: 0;
  transition: transform 0.22s var(--spring), opacity 0.18s ease;
  pointer-events: none;
}
.tp-card:hover .tp-overlay,
.tp-card:focus-visible .tp-overlay {
  transform: translateY(0);
  opacity: 1;
}
.tp-why {
  font-family: var(--serif);
  font-size: 13px;
  font-style: italic;
  line-height: 1.35;
  color: var(--text);
  margin: 0 0 6px;
}
.tp-evidence {
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0;
}
.tp-evidence.is-restricted { color: var(--red); }

/* Wireframe skeleton blocks inside each card */
.tp-skel {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 5px;
  aspect-ratio: 4 / 5;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tp-block {
  background: var(--surface3);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 7.5px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-align: center;
  overflow: hidden;
  padding: 1px 2px;
}
.tp-photo {
  background: var(--surface3);
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;
}
.tp-photo.tp-vertical { aspect-ratio: 9 / 16; }
.tp-line {
  height: 5px;
  background: var(--surface3);
  border-radius: 2px;
  color: transparent;
}
.tp-line.short { width: 60%; }
.tp-line.shorter { width: 35%; }
.tp-pill {
  background: var(--accent);
  color: #fff;
  border-radius: 99px;
  padding: 2px 6px;
  align-self: center;
  font-size: 7px;
}
.tp-banner {
  background: var(--accent);
  color: #fff;
  font-size: 7px;
}
.tp-circle {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface3);
  flex: 0 0 auto;
}
.tp-numbered::before {
  content: attr(data-num);
  font-size: 9px;
  color: var(--accent);
  font-weight: 700;
  margin-right: 4px;
}
.tp-row {
  display: flex;
  gap: 4px;
  align-items: center;
}
.tp-col { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.tp-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; flex: 1; }
.tp-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 3px; flex: 1; }

@media (prefers-reduced-motion: reduce) {
  .tp-backdrop,
  .tp-panel,
  .tp-card,
  .tp-overlay { transition: none; }
}

/* ==================================================================
   Bulk Skill Import — drop zone + preview table
   ================================================================== */

.skill-import-dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 32px 16px;
  text-align: center;
  background: var(--bg);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.skill-import-dropzone.drag-over {
  border-color: var(--accent);
  background: rgba(139, 111, 71, 0.06); /* --accent at 6% */
}

.skill-import-dropzone p {
  margin: 4px 0;
  color: var(--text);
}

.skill-import-dropzone code {
  background: rgba(175, 170, 162, 0.15); /* --border-light tone */
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 12px;
  color: var(--text-dim);
}

.skill-import-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

/* Keep action-badge and folder cells on one line; the wider container
   gives them the room. Table-layout stays auto so other columns flex. */
.skill-import-table td:nth-child(3),
.skill-import-table td:nth-child(4) {
  white-space: nowrap;
}

.skill-import-table th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

.skill-import-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
  color: var(--text);
}

.skill-import-table tr:last-child td {
  border-bottom: none;
}

.skill-import-table code {
  font-size: 12px;
  background: rgba(175, 170, 162, 0.15);
  padding: 1px 4px;
  border-radius: 3px;
}

/* ==================================================================
   Skills admin — list toolbar, view toggle, select mode
   ================================================================== */

.skill-list-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.skill-view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.skill-view-btn {
  border: none;
  background: var(--bg);
  color: var(--text-dim);
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}

.skill-view-btn.active {
  background: var(--accent);
  color: #fff;
}

.skill-select-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.skill-select-cb {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  align-self: center;
  margin-right: 8px;
}

/* ==================================================================
   Skills bulk import — warnings panel (amber)
   ================================================================== */

.skill-warnings-panel {
  border: 1px solid rgba(180, 130, 30, 0.4);
  border-radius: 6px;
  margin-bottom: 16px;
  background: rgba(180, 130, 30, 0.06);
  overflow: hidden;
}

.skill-warnings-header {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.skill-warnings-header:hover {
  background: rgba(180, 130, 30, 0.10);
}

.skill-warnings-caret {
  font-size: 10px;
  color: var(--accent);
}

.skill-warnings-body {
  padding: 4px 12px 12px;
  border-top: 1px solid rgba(180, 130, 30, 0.2);
  font-size: 12px;
  color: var(--text);
}

.skill-warnings-section {
  margin-top: 8px;
}

.skill-warnings-section-title {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.skill-warnings-group {
  margin: 4px 0;
}

.skill-warnings-body ul {
  margin: 2px 0 6px 16px;
  padding: 0;
}

.skill-warnings-body li {
  margin: 2px 0;
}

.skill-warnings-body code {
  background: rgba(175, 170, 162, 0.15);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
}

/* ==================================================================
   Skills bulk import — row action badges
   ================================================================== */

.skill-badge-create,
.skill-badge-update,
.skill-badge-unchanged,
.skill-badge-reactivate,
.skill-badge-added,
.skill-badge-changed,
.skill-badge-removed {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  line-height: 1.4;
}

.skill-badge-create {
  background: rgba(76, 140, 76, 0.15);
  color: #2e6e2e;
}

.skill-badge-update {
  background: rgba(70, 110, 170, 0.15);
  color: #2c4d80;
}

.skill-badge-unchanged {
  background: rgba(175, 170, 162, 0.18);
  color: var(--text-muted);
}

.skill-badge-reactivate {
  background: rgba(180, 130, 30, 0.18);
  color: #7a5a18;
}

.skill-badge-added {
  background: rgba(76, 140, 76, 0.12);
  color: #2e6e2e;
  margin-left: 4px;
}

.skill-badge-changed {
  background: rgba(70, 110, 170, 0.12);
  color: #2c4d80;
  margin-left: 4px;
}

.skill-badge-removed,
.skill-badge-skipped {
  background: rgba(180, 130, 30, 0.12);
  color: #7a5a18;
  margin-left: 4px;
}

/* Per-skill shape rule for the new skipped pill (shared shape with the others) */
.skill-badge-skipped {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  line-height: 1.4;
}

/* ==================================================================
   Skills bulk import — post-commit result banner
   ================================================================== */

.skill-import-result-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.4;
}

.skill-import-result-success {
  background: rgba(76, 140, 76, 0.10);
  border: 1px solid rgba(76, 140, 76, 0.35);
  color: #2e6e2e;
}

.skill-import-result-mixed {
  background: rgba(180, 130, 30, 0.10);
  border: 1px solid rgba(180, 130, 30, 0.4);
  color: #7a5a18;
}

.skill-import-result-icon {
  font-size: 18px;
  line-height: 1;
}

/* ==================================================================
   GALLERY — day-grouped contact sheet of generated images.
   Design locked against .claude/prototypes/image-gallery.html
   (approved 2026-06-02). Namespaced `gallery-` to stay collision-safe
   in the shared stylesheet.
   ================================================================== */

/* This one page intentionally drops the ruled-paper desk — a photo grid
   over ruled lines is visual noise; the images are the decoration. Flat
   --sidebar-bg matches the sidebar; its right border gives the seam. */
.page-gallery {
  flex-direction: column;
  background: var(--sidebar-bg);
  overflow-y: auto;
}
/* The body under the sticky header. Same padding as .pages-page-body, and no
   centred max-width band: the header spans the surface, so the content has to
   hang on the same left edge or the two read as different pages. The sheet is an
   auto-fill grid, so the extra width simply becomes more thumbnails. */
.gallery-inner {
  width: 100%;
  padding: 20px 12px 24px 16px;
}

/* The header itself is .pages-page-header / .pages-control-bar / .pages-search /
   .pages-filter — shared with Pages, defined once around line 6380. Gallery adds
   nothing of its own up there on purpose. */

/* Search filtering hides non-matching cards (and fully-hidden day groups) in
   place — no re-render, so the entrance animation never replays on a keystroke. */
.gallery-photo.is-search-hidden, .gallery-day.is-search-hidden { display: none; }

/* Day group */
.gallery-day { margin-top: 34px; }
/* The first day sits under the folder strip, not under another day — 16px, the
   same gap .pages-card-grid leaves below the strip on Pages. */
.gallery-day:first-child { margin-top: 16px; }
.gallery-day-divider {
  display: flex; align-items: baseline; gap: 14px;
  margin-bottom: 16px;
}
.gallery-day-label {
  font-family: var(--serif); font-size: 16px; font-weight: 600;
  color: var(--text-dim); letter-spacing: -0.2px; white-space: nowrap;
}
.gallery-day-count { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.gallery-day-rule { flex: 1; height: 1px; background: var(--border); }

/* The contact sheet */
.gallery-sheet {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  gap: 22px;
}

/* Photo card — a print resting on the desk */
.gallery-photo {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 8px 0;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.3s var(--spring), box-shadow 0.3s var(--spring);
  display: flex; flex-direction: column;
  opacity: 0; animation: galleryCardIn 0.45s var(--spring) forwards;
}
/* Once the entrance has played, freeze it. The animation lives permanently on
   .gallery-photo, and CSS RESTARTS animations when an element flips from
   display:none → shown — so without this the leftover cards replay the entrance
   every time you re-open the gallery (a visible double-play). `entered` is
   stamped on animationend (gallery.js). */
.gallery-photo.entered { animation: none; opacity: 1; }
.gallery-photo:nth-child(odd)  { transform: rotate(-0.5deg); }
.gallery-photo:nth-child(even) { transform: rotate(0.5deg); }
.gallery-photo:hover {
  transform: translateY(-4px) rotate(0deg);
  box-shadow: var(--shadow-lg);
}
/* Keyboard focus ring — only on keyboard focus (:focus-visible), never on click */
.gallery-photo:focus { outline: none; }
.gallery-photo:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
@keyframes galleryCardIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; }
}

.gallery-photo-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface3);
}
.gallery-photo-frame img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
/* download button — appears on hover */
.gallery-dl-btn {
  position: absolute; top: 8px; right: 8px;
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(255,253,246,0.92);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); cursor: pointer;
  opacity: 0; transform: translateY(-2px);
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.gallery-photo:hover .gallery-dl-btn { opacity: 1; transform: translateY(0); }
.gallery-dl-btn:hover { background: #fff; color: var(--accent); }
.gallery-dl-btn:active { transform: scale(0.94); }

/* overflow (⋯) button — pairs with download at the top RIGHT. It used to own the
   top-left corner; the multi-select check took that, being where the eye starts
   and where every tool that does this puts it. Two small buttons together on one
   side is tidier than one in each corner anyway. */
.gallery-menu-btn {
  position: absolute; top: 8px; right: 46px;
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(255,253,246,0.92);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); cursor: pointer;
  opacity: 0; transform: translateY(-2px);
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease, color 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.gallery-photo:hover .gallery-menu-btn { opacity: 1; transform: translateY(0); }
.gallery-menu-btn:hover { background: #fff; color: var(--accent); }
.gallery-menu-btn:active { transform: scale(0.94); }

/* ==================================================================
   MULTI-SELECT — the check, the picked print, the tray
   ==================================================================
   No mode button. Hovering a picture reveals a circle; checking one reveals
   every other circle (.is-selecting on the page). The first check IS the mode
   entry — a "Select" button would be permanent chrome that does nothing until
   you also click an image.
   ================================================================== */

.gallery-check {
  position: absolute; top: 8px; left: 8px;
  width: 26px; height: 26px; border-radius: 50%; padding: 0;
  background: rgba(255,253,246,0.86);
  border: 1.5px solid rgba(120,110,95,0.5);
  display: flex; align-items: center; justify-content: center;
  color: #fff; cursor: pointer;
  opacity: 0; transform: scale(0.86);
  transition: opacity .14s ease, transform .18s var(--spring), background .14s ease, border-color .14s ease;
  box-shadow: 0 1px 3px rgba(60,50,40,0.14);
}
.gallery-check svg { opacity: 0; transition: opacity .12s ease; }
.gallery-photo:hover .gallery-check { opacity: 1; transform: scale(1); }
.gallery-check:hover { border-color: var(--accent); background: #fff; }
.gallery-check:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; opacity: 1; transform: scale(1); }
/* Once anything is checked every circle stands up — the selection is a mode you
   can see the edges of, not one you discover a card at a time. */
.page-gallery.is-selecting .gallery-check { opacity: 1; transform: scale(1); }

/* Picked: the print squares out of the pile. The tilt is the desk metaphor at
   rest; straightening it is "picked up", and the state never rests on colour. */
.gallery-photo.is-picked {
  transform: rotate(0deg) translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(139,111,71,0.45), var(--shadow-md);
}
.gallery-photo.is-picked:hover { transform: rotate(0deg) translateY(-4px); }
.gallery-photo.is-picked .gallery-check {
  background: var(--accent); border-color: var(--accent);
  opacity: 1; transform: scale(1);
}
.gallery-photo.is-picked .gallery-check svg { opacity: 1; }

/* Whose it is, shown only while selecting — the tray's "Remove 4 of 6" has to be
   checkable against the pictures without opening anything. */
.gallery-photo-who {
  position: absolute; left: 8px; bottom: 8px;
  font-size: 10.5px; font-weight: 600; color: var(--text-muted);
  background: rgba(255,253,246,0.92); border: 1px solid var(--border);
  border-radius: 20px; padding: 1px 7px;
  opacity: 0; transition: opacity .14s ease; pointer-events: none;
  max-width: calc(100% - 16px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.page-gallery.is-selecting .gallery-photo-who { opacity: 1; }

/* ---- The tray ---- */
/* Bottom centre, over the surface, in BOTH modes. Column three is arguably the
   natural home in column view, but two homes means two answers to "where did the
   actions go". Dark, because it is the one thing on the desk that is not paper —
   a tool you picked up, and it leaves when you put the selection down. */
.gallery-bulk-tray {
  position: fixed; left: 50%; bottom: 22px;
  transform: translate(-50%, 26px);
  display: flex; align-items: center; gap: 6px;
  padding: 8px 8px 8px 16px; border-radius: 14px;
  background: rgba(38,34,30,0.96); color: #f6f1e8;
  box-shadow: 0 10px 34px rgba(40,32,24,0.30), 0 2px 8px rgba(40,32,24,0.20);
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .26s var(--spring);
  z-index: 9500;   /* over the surface; under the lightbox (10000) and menus */
  max-width: calc(100vw - 32px);
}
.page-gallery.is-selecting .gallery-bulk-tray { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.gbt-count { font-size: 13px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.gbt-sep { width: 1px; height: 20px; background: rgba(246,241,232,0.22); margin: 0 6px; flex-shrink: 0; }
.gbt-btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--sans); font-size: 12.5px; font-weight: 500;
  color: #f6f1e8; background: none; border: none; border-radius: 8px;
  padding: 7px 11px; cursor: pointer; white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}
.gbt-btn:hover { background: rgba(246,241,232,0.13); }
.gbt-btn:focus-visible { outline: 2px solid rgba(246,241,232,0.7); outline-offset: -2px; }
.gbt-btn.danger:hover { background: rgba(255,45,85,0.20); color: #ffd7df; }
.gbt-btn[disabled] { opacity: .38; cursor: not-allowed; }
.gbt-btn[disabled]:hover { background: none; }
.gbt-x { width: 30px; height: 30px; padding: 0; justify-content: center; margin-left: 2px; }
.gbt-btn svg { flex-shrink: 0; }

/* A bulk run is sequential — 40 removes is 40 round trips — so the tray is on
   screen and clickable the whole time. While one is running the tray stops
   taking input: the JS guard is what makes it correct, this is what makes it
   legible, so a second click reads as "already working" and not as "ignored". */
.gallery-bulk-tray.is-busy { cursor: progress; }
.gallery-bulk-tray.is-busy .gbt-btn { opacity: .45; pointer-events: none; }

/* Phones: the tray is the only thing that matters while a selection is up, so it
   spans the width and sheds the labels it can afford to. */
@media (max-width: 768px) {
  .gallery-bulk-tray { left: 12px; right: 12px; bottom: 12px; transform: translateY(26px); padding: 8px; gap: 2px; }
  .page-gallery.is-selecting .gallery-bulk-tray { transform: translateY(0); }
  .gallery-bulk-tray .gbt-sep:last-of-type, .gallery-bulk-tray #gallery-bulk-all { display: none; }
  .gbt-btn { padding: 7px 8px; }
  .gbt-btn .gbt-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-check, .gallery-photo.is-picked, .gallery-bulk-tray { transition: opacity .12s ease; }
  .gallery-photo.is-picked, .gallery-photo.is-picked:hover { transform: rotate(0deg); }
}

.gallery-photo-caption {
  padding: 10px 4px 0;
  font-size: 12.5px; line-height: 1.4; color: var(--text-dim);
  display: -webkit-box; -webkit-box-orient: vertical;
  -webkit-line-clamp: 2; line-clamp: 2;
  overflow: hidden;
}
/* Prompt-fallback caption — an unnamed photo shows what the agent generated
   from, muted + italic so it never reads as a founder-given name. */
.gallery-photo-caption.is-prompt,
.gallery-lightbox-prompt.is-prompt { color: var(--text-muted); font-style: italic; }
/* Inline gallery rename (⋯ → Rename) — swaps the caption for an input in place. */
.gallery-rename-input {
  width: 100%; box-sizing: border-box; margin-top: 10px;
  font-family: var(--sans); font-size: 12.5px; color: var(--text);
  background: #fff; border: 1px solid var(--accent); border-radius: 5px;
  padding: 3px 6px; outline: none;
}
.gallery-rename-input::placeholder { color: var(--text-muted); font-style: italic; }
/* Same click-to-rename affordance as pages: caret cursor + a pencil fading in on
   hover over the caption (named or prompt-fallback), so naming a photo doesn't
   require the ⋯ menu. */
.gallery-photo-caption.is-editable { cursor: text; position: relative; padding-right: 18px; }
.gallery-photo-caption.is-editable::after {
  content: ""; position: absolute; top: 10px; right: 2px;
  width: 12px; height: 12px; pointer-events: none;
  background-color: var(--text-muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z'/%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='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0; transition: opacity 140ms ease;
}
.gallery-photo:hover .gallery-photo-caption.is-editable::after { opacity: 0.55; }
/* Card label stack: caption → time → provenance. All three share the same 4px
   inset so they line up on one left edge, and the gaps descend (10 → 8 → 4) so
   the state line reads as the tail of THIS card rather than drifting toward the
   next one. The 12px bottom padding belongs to whichever line ends the stack —
   it used to be stranded on .gallery-photo-time, from when time was last. */
.gallery-photo-time {
  margin-top: 8px;
  padding: 0 4px;
  font-size: 11px; color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.gallery-photo-provenance {
  margin-top: 4px;
  padding: 0 4px;
  font-size: 11px; line-height: 1.3; color: var(--text-muted);
}
.gallery-photo-time:last-child,
.gallery-photo-provenance:last-child { padding-bottom: 12px; }

/* Skeleton (first load only) — avoids an empty-state flash before data */
.gallery-photo-skeleton { opacity: 1; animation: none; cursor: default; pointer-events: none; }
.gallery-photo-skeleton .gallery-photo-frame {
  background: linear-gradient(90deg, var(--surface3) 25%, var(--surface2) 37%, var(--surface3) 63%);
  background-size: 400% 100%;
  animation: galleryShimmer 1.4s ease infinite;
}
@keyframes galleryShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

/* Empty state — yellow sticky note, on-brand */
.gallery-empty {
  display: flex;
  flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 90px 20px; gap: 14px;
}
.gallery-empty[hidden] { display: none; }
.gallery-empty-illo {
  width: 92px; height: 92px; border-radius: 16px;
  background: var(--sticky); transform: rotate(-3deg);
  border: 1px solid rgba(180,160,80,0.3);
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; justify-content: center;
  color: #9a7d2a;
}
.gallery-empty h2 { font-family: var(--serif); font-size: 24px; font-weight: 600; color: var(--text); }
.gallery-empty p { font-size: 14px; color: var(--text-muted); max-width: 360px; line-height: 1.5; text-wrap: pretty; }

/* Lightbox */
.gallery-lightbox {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(40, 34, 28, 0.82);
  /* No align/justify-center: a centered flex child taller than the viewport gets
     clipped at BOTH ends with no scroll. margin:auto on the inner centers it when
     it fits and top-anchors it when tall; overflow-y lets the whole modal scroll. */
  display: flex; overflow-y: auto;
  padding: 40px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.gallery-lightbox.open { opacity: 1; pointer-events: auto; }
.gallery-lightbox-inner {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  max-width: 90vw; margin: auto; transform: translateY(8px);
  transition: transform 0.2s ease;
}
.gallery-lightbox.open .gallery-lightbox-inner { transform: translateY(0); }
.gallery-lightbox img {
  max-width: 100%; max-height: 80vh; border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
  border: 6px solid #fff;
}
.gallery-lightbox-meta {
  background: var(--cream); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px;
  max-width: 560px; box-shadow: var(--shadow-md);
}
.gallery-lightbox-prompt {
  font-size: 13.5px; color: var(--text-dim); line-height: 1.45;
  /* Clamp long prompts (esp. ad-template ones) so the meta never overflows the
     viewport and gets cut. No text-wrap: pretty — it breaks -webkit-line-clamp. */
  display: -webkit-box; -webkit-box-orient: vertical;
  -webkit-line-clamp: 4; line-clamp: 4;
  overflow: hidden;
}
.gallery-lightbox-prompt:empty { display: none; }
/* Expanded via "See more" — drop the clamp and show the full prompt. The whole
   lightbox scrolls (see .gallery-lightbox), so no nested scrollbar here. */
.gallery-lightbox-prompt.expanded {
  display: block; -webkit-line-clamp: unset;
}
.gallery-lightbox-seemore {
  margin-top: 6px; padding: 0;
  font-family: var(--sans); font-size: 12.5px; font-weight: 500;
  color: var(--accent); background: none; border: none; cursor: pointer;
}
.gallery-lightbox-seemore:hover { color: var(--accent-hover); text-decoration: underline; }
.gallery-lightbox-seemore[hidden] { display: none; }
.gallery-lightbox-actions { display: flex; gap: 8px; margin-top: 10px; }
.gallery-lb-action {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  padding: 7px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-dim);
  transition: background 0.15s ease;
}
.gallery-lb-action:hover { background: var(--surface2); }
.gallery-lb-action.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.gallery-lb-action.primary:hover { background: var(--accent-hover); }
.gallery-lb-action:active { transform: scale(0.97); }
/* icon-only ⋯ at the end of the action row — secondary, never a main action */
.gallery-lb-more { padding: 7px 9px; color: var(--text-muted); }
.gallery-lb-more svg { display: block; }
/* override the inline-flex above so [hidden] actually hides it (own images only) */
.gallery-lb-more[hidden] { display: none; }

/* Shared overflow menu (card ⋯ + lightbox ⋯). Positioned in JS via fixed coords;
   z-index sits above the lightbox so it shows when opened from the zoom view. */
.gallery-menu {
  position: fixed; z-index: 10000; min-width: 190px;
  background: var(--card-bg, #fffdf8);
  border: 1px solid rgba(180, 170, 150, 0.2);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  padding: 6px;
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.gallery-menu.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.gallery-menu[hidden] { display: none; }
.gallery-menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border-radius: 6px; cursor: pointer; text-align: left;
  font-family: var(--sans); font-size: 13px; color: var(--text);
  background: none; border: none;
  transition: background 0.1s ease, color 0.1s ease;
}
.gallery-menu-item:hover { background: rgba(180, 170, 150, 0.1); }
.gallery-menu-item.danger { color: var(--text-dim); }
.gallery-menu-item.danger:hover { background: var(--red-dim, rgba(255,45,85,0.08)); color: var(--red); }
.gallery-lightbox-close {
  position: fixed; top: 22px; right: 26px;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255,255,255,0.9); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text); box-shadow: var(--shadow-md);
}
.gallery-lightbox-close:active { transform: scale(0.94); }

/* ---- Folder strip (gallery-folders.js) ----
   Reuses the manila .folder-tabs block shipped with Pages Folders (PR #81),
   in the same slot Pages puts it — between the sticky header and the body, as a
   direct child of the page — so it needs no gallery-specific rule at all. */

/* A photo mid-drag — lifted out of the sheet, en route to a folder tab */
.gallery-photo.dragging { opacity: 0.35; }

/* "Move to" flyout — a second .gallery-menu popover beside the main one,
   opened by hovering (or clicking) the Move item. Inherits the menu's chrome;
   sits one above it so the overlap edge never hides a folder name. */
.gallery-submenu { z-index: 10001; min-width: 170px; }
/* Invisible bridge toward the main menu (side set in JS per flip) so the diagonal
   path from "Move to folder" into the folder list keeps the pointer in-region. */
.gallery-submenu::before { content: ''; position: absolute; top: 0; bottom: 0; width: 12px; }
.gallery-submenu[data-bridge="left"]::before { left: -12px; }
.gallery-submenu[data-bridge="right"]::before { right: -12px; }
.gallery-menu-chev { margin-left: auto; color: var(--text-muted); }
.gallery-menu-divider { height: 1px; background: var(--border-light); margin: 4px 6px; }
.gallery-menu-folder-list { max-height: 240px; overflow-y: auto; }
.gallery-menu-item.is-current { color: var(--accent); font-weight: 600; }
.gallery-menu-item.is-current::after { content: '✓'; margin-left: auto; }
.gallery-menu-hint {
  padding: 8px 10px; font-size: 12px; color: var(--text-muted); line-height: 1.45;
  max-width: 220px;
}

/* Folder-index popover — the shared .gallery-menu, widened, with a .pages-search
   row on top and the existing .gallery-menu-folder-list below. Hung off the All
   tab (gallery-folders.js). */
.gallery-menu.folder-index { width: 290px; max-width: calc(100vw - 24px); }
.folder-index .pages-search { margin: 2px 2px 0; }
.folder-index .pages-search input { width: 100%; }
.folder-index .gallery-menu-folder-list { max-height: 304px; margin-top: 4px; }
.folder-index .gallery-menu-item .fi-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* count chip reuses the manila .ft-count look so it reads as the same object */
.folder-index .fi-count { margin-left: auto; font-size: 10.5px; font-weight: 600; color: var(--manila-text); background: rgba(111,96,72,0.13); border-radius: 20px; padding: 1px 7px; min-width: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.folder-index .gallery-menu-item.is-current .fi-count { background: rgba(139,111,71,0.18); color: #5a4a30; }
.folder-index .gallery-menu-item.is-current::after { content: none; }   /* ✓ shown via the leading icon instead */
.folder-index .gallery-menu-item.is-cursor { background: rgba(180,170,150,0.14); }
.folder-index .fi-empty { padding: 18px 12px; text-align: center; color: var(--text-muted); font-size: 12.5px; line-height: 1.5; }
.folder-index .fi-empty b { color: var(--text-dim); font-weight: 600; }
.folder-index .fi-new { color: var(--accent); font-weight: 600; }

/* Pages reuses the SAME folder-index, hung off its own .ft-menu popover. The
   .folder-index helpers above (search row, count chip, empty, new) are shared;
   these cover the Pages-specific row container + active/cursor states. */
.ft-menu.folder-index { width: 268px; max-width: calc(100vw - 24px); }
.folder-index .pages-folder-list { max-height: 300px; overflow-y: auto; margin-top: 6px; }
.folder-index .pages-menu-item .fi-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-index .pages-menu-item.is-current { color: var(--accent); font-weight: 600; }
.folder-index .pages-menu-item.is-current .fi-count { background: rgba(139,111,71,0.18); color: #5a4a30; }
.folder-index .pages-menu-item.is-cursor { background: rgba(180,170,150,0.14); }

/* Mobile — keep the grid usable on a phone (founders work on the go) */
@media (max-width: 768px) {
  .gallery-inner { padding: 14px 12px 84px; }
  .gallery-sheet { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 14px; }
  .gallery-lightbox { padding: 20px; }
  .gallery-lightbox-close { top: 14px; right: 16px; }
}

/* Respect reduced-motion — drop tilt, fade-in, shimmer, lift */
@media (prefers-reduced-motion: reduce) {
  .gallery-photo { animation: none; opacity: 1; transform: none; transition: box-shadow 0.2s ease; }
  .gallery-photo:nth-child(odd), .gallery-photo:nth-child(even) { transform: none; }
  .gallery-photo:hover { transform: none; }
  .gallery-photo-skeleton .gallery-photo-frame { animation: none; }
  .gallery-lightbox, .gallery-lightbox-inner { transition: none; }
}

/* ==================================================================
   AD BLUEPRINT — "Your brand" shelf overlay (brand.js)
   Namespaced (brand-*) so it can't collide with settings/history drawers.
   ================================================================== */
.brand-scrim {
  position: fixed; inset: 0; background: rgba(48, 40, 32, 0.28);
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease; z-index: 1400;
}
.brand-scrim.show { opacity: 1; pointer-events: auto; }
.brand-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 392px; max-width: 92vw;
  background: #fbf7ef; box-shadow: -8px 0 32px rgba(60, 50, 40, 0.16);
  transform: translateX(100%); transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 1401; display: flex; flex-direction: column;
}
.brand-drawer.show { transform: translateX(0); }
.brand-drawer-head {
  padding: 18px 20px 16px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
}
.brand-drawer-title { font-family: var(--serif); font-weight: 500; font-size: 19px; color: var(--text); }
.brand-drawer-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.brand-drawer-close {
  cursor: pointer; border: none; background: none; color: var(--text-muted);
  font-size: 22px; line-height: 1; padding: 0 4px; border-radius: 8px;
}
.brand-drawer-close:hover { color: var(--text); }
.brand-drawer-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.brand-drawer-foot { padding: 13px 20px; border-top: 1px solid var(--border); font-size: 11px; color: var(--text-muted); line-height: 1.5; }
.brand-files-h {
  font-size: 11px; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 14px;
}
.brand-files-h span { color: var(--text-muted); font-weight: 500; text-transform: none; letter-spacing: 0; }
.brand-kit-group { margin-bottom: 22px; }
.brand-kit-group h4 { font-size: 11px; font-weight: 600; color: var(--text-dim); margin-bottom: 11px; }
/* Brand asset tiles — same "print resting on the desk" card as the Gallery
   (.gallery-photo), sized 2-up for the 392px drawer. */
.brand-variants { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; align-items: start; }
.brand-variant {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 8px 11px;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
  transition: transform 0.3s var(--spring), box-shadow 0.3s var(--spring);
}
.brand-variant:nth-child(odd)  { transform: rotate(-0.5deg); }
.brand-variant:nth-child(even) { transform: rotate(0.5deg); }
.brand-variant:hover { transform: translateY(-4px) rotate(0deg); box-shadow: var(--shadow-lg); }
.brand-variant.def { border-color: var(--accent); }
.brand-vimg {
  position: relative; width: 100%; aspect-ratio: 1 / 1;
  border-radius: 6px; overflow: hidden; background: var(--surface3); cursor: pointer;
}
.brand-vimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-vstar {
  position: absolute; top: 7px; left: 7px;
  display: flex; align-items: center; gap: 3px;
  padding: 2px 7px 2px 6px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 600;
  box-shadow: var(--shadow-sm); letter-spacing: 0.02em;
}
.brand-vrm {
  position: absolute; top: 7px; right: 7px; width: 26px; height: 26px; border-radius: 8px;
  background: rgba(255,253,246,0.92); border: 1px solid var(--border); color: var(--text-dim);
  font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
  opacity: 0; transform: translateY(-2px);
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease, color 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.brand-variant:hover .brand-vrm { opacity: 1; transform: translateY(0); }
.brand-vrm:hover { background: #fff; color: var(--accent); }
.brand-vrm:active { transform: scale(0.94); }
.brand-vcap {
  padding: 9px 6px 0; font-size: 12px; line-height: 1.35; color: var(--text-dim);
  text-align: center; cursor: text; overflow-wrap: anywhere;
  /* Two-row clamp with ellipsis, cross-browser. NOTE: no padding-bottom here —
     -webkit-line-clamp leaks a 3rd line into the element's own bottom padding,
     so the card carries the bottom spacing instead. Standard `line-clamp` is
     omitted too (it flips Chromium to flow-root and re-introduces the leak). */
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden;
}
.brand-vcap:hover { color: var(--text); }
.brand-variant.def .brand-vcap { color: var(--accent); font-weight: 600; }
.brand-vcap-add { color: var(--text-muted); opacity: 0.75; font-style: italic; }
.brand-vcap:hover .brand-vcap-add { opacity: 1; }
.brand-vcap-input {
  width: 100%; font-size: 12px; text-align: center; margin: 6px 0 9px;
  border: 1px solid var(--accent); border-radius: 6px; padding: 4px 6px;
  background: var(--bg); color: var(--text); font-family: inherit;
}
.brand-vcap-input:focus { outline: none; }
.brand-vadd {
  width: 100%; aspect-ratio: 1 / 1; border-radius: var(--radius-sm);
  border: 1.5px dashed rgba(150, 130, 95, 0.5);
  background: rgba(255, 255, 255, 0.4); display: grid; place-items: center; cursor: pointer;
  color: var(--accent); font-size: 12px; font-weight: 600; text-align: center; line-height: 1.25;
  transition: border-color 0.15s, transform 0.3s var(--spring), background 0.15s; font-family: var(--sans);
}
.brand-vadd:hover { border-style: solid; transform: translateY(-3px); background: rgba(255, 255, 255, 0.7); }
.brand-kit-mode { font-size: 11.5px; color: var(--text-muted); margin-top: 11px; }
.brand-profile-group h4 { margin-bottom: 4px; }
.brand-profile-sub { font-size: 11.5px; color: var(--text-muted); margin-bottom: 12px; }
.brand-profile-list { display: flex; flex-direction: column; gap: 12px; }
.brand-profile-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px 12px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s var(--spring), box-shadow 0.3s var(--spring), opacity 0.2s ease;
}
.brand-profile-card:nth-child(odd) { transform: rotate(-0.4deg); }
.brand-profile-card:nth-child(even) { transform: rotate(0.4deg); }
.brand-profile-card:hover { transform: translateY(-3px) rotate(0deg); box-shadow: var(--shadow-lg); }
.brand-profile-card.removing { opacity: 0; transform: translateY(6px) scale(0.97); }
.brand-profile-top { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; padding-right: 24px; }
.brand-profile-logo {
  width: 36px; height: 36px; flex: 0 0 36px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface2);
  display: grid; place-items: center; overflow: hidden;
}
.brand-profile-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-profile-logo.mono { color: var(--surface); font-weight: 600; font-size: 16px; border: none; }
.brand-profile-name {
  font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.3;
  cursor: text; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden;
}
.brand-profile-name:hover { color: var(--accent); }
.brand-profile-name-input {
  width: 100%; font-size: 13px; font-weight: 600; font-family: inherit;
  border: 1px solid var(--accent); border-radius: 6px; padding: 3px 6px;
  background: var(--bg); color: var(--text);
}
.brand-profile-name-input:focus { outline: none; }
.brand-profile-chips {
  display: flex; height: 26px; border-radius: 6px; overflow: hidden;
  border: 1px solid var(--border);
}
.brand-profile-chips:empty { display: none; }
.brand-profile-chips i { flex-grow: 1; min-width: 6px; }
.brand-profile-assets { display: flex; gap: 6px; margin-top: 9px; }
.brand-profile-thumb {
  width: 48px; height: 48px; border-radius: 6px; overflow: hidden;
  border: 1px solid var(--border); background: var(--surface2); position: relative; flex: 0 0 48px;
}
.brand-profile-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-profile-thumb.more::after {
  content: attr(data-more); position: absolute; inset: 0;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--text) 55%, transparent);
  color: var(--surface); font-size: 12px; font-weight: 600;
}
.brand-profile-fonts {
  margin-top: 8px; font-size: 13px; color: var(--text-muted);
  display: flex; align-items: baseline; gap: 7px;
}
.brand-profile-fonts b { color: var(--text-dim); font-weight: 500; }
.brand-profile-fonts .dot { opacity: 0.6; font-size: 11px; }
.brand-profile-refine {
  margin-top: 10px; width: 100%;
  border: 1px dashed color-mix(in srgb, var(--accent) 50%, transparent); border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 40%, transparent); padding: 7px 10px;
  color: var(--accent); font-size: 12px; font-weight: 600; font-family: var(--sans);
  cursor: pointer; text-align: center;
  transition: border-color 0.15s, background 0.15s, transform 0.15s ease-out;
}
.brand-profile-refine:hover { border-style: solid; background: color-mix(in srgb, var(--surface) 75%, transparent); }
.brand-profile-refine:active { transform: scale(0.97); }
.brand-profile-rm {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 8px;
  background: color-mix(in srgb, var(--cream) 92%, transparent);
  border: 1px solid var(--border); color: var(--text-dim);
  font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0;
  opacity: 0; transform: translateY(-2px);
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease, color 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.brand-profile-card:hover .brand-profile-rm { opacity: 1; transform: translateY(0); }
.brand-profile-rm:hover { background: var(--surface); color: var(--accent); }
.brand-profile-rm:active { transform: scale(0.94); }
@media (prefers-reduced-motion: reduce) {
  .brand-drawer { transition: none; }
  .brand-variant, .brand-variant:nth-child(odd), .brand-variant:nth-child(even),
  .brand-variant:hover, .brand-vadd:hover,
  .brand-profile-card, .brand-profile-card:nth-child(odd), .brand-profile-card:nth-child(even),
  .brand-profile-card:hover { transform: none; transition: none; }
  .brand-import-hero:hover, .brand-import-pick:hover { transform: none; }
  .scanline { animation: none; }
}

/* ==================================================================
   BRAND IMPORT — "Import from your website" flow (brand-import.js)
   Paste a URL → review extracted brand DNA + products → save, all in
   the Your Brand drawer. Namespaced brand-import-*.
   ================================================================== */
/* Entry banner */
.brand-import-hero {
  width: 100%; text-align: left; cursor: pointer; margin-bottom: 20px; font-family: var(--sans);
  border: 1.5px solid rgba(139, 111, 71, 0.32);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.35));
  border-radius: var(--radius); padding: 14px 15px; display: flex; gap: 12px; align-items: center;
  box-shadow: var(--shadow-sm); transition: transform 0.3s var(--spring), box-shadow 0.2s ease, border-color 0.15s ease;
}
.brand-import-hero:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--accent); }
.brand-import-hero:active { transform: translateY(0) scale(0.99); }
.brand-import-hero-ic {
  width: 34px; height: 34px; flex-shrink: 0; border-radius: 9px; background: rgba(139, 111, 71, 0.12);
  display: grid; place-items: center; font-size: 17px;
}
.brand-import-hero-txt { display: flex; flex-direction: column; gap: 2px; }
.brand-import-hero-txt .tt { font-size: 13.5px; font-weight: 600; color: var(--accent); }
.brand-import-hero-txt .ss { font-size: 11.5px; color: var(--text-muted); line-height: 1.4; }

/* Flow panel (input / scan / review) */
.brand-import-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow-md); margin-bottom: 20px;
}
.brand-import-h { font-family: var(--serif); font-weight: 500; font-size: 16px; color: var(--text); margin-bottom: 4px; }
.brand-import-sub { font-size: 12px; color: var(--text-muted); line-height: 1.5; margin-bottom: 14px; }
.brand-import-err {
  font-size: 12px; color: var(--warn-amber); background: rgba(184, 83, 26, 0.08);
  border-radius: 8px; padding: 8px 10px; margin-bottom: 12px; line-height: 1.4;
}
.brand-import-urlrow { display: flex; gap: 8px; }
.brand-import-url {
  flex: 1; min-width: 0; font: inherit; font-size: 13px; padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--cream); color: var(--text);
}
.brand-import-url:focus { outline: none; border-color: var(--accent); }
.brand-import-go, .brand-import-save, .brand-import-overwrite {
  font: inherit; font-size: 13px; font-weight: 600; border: none; border-radius: 9px; padding: 10px 15px;
  cursor: pointer; background: var(--accent); color: #fff; white-space: nowrap;
  transition: background 0.15s ease, transform 0.15s ease;
}
.brand-import-go:hover, .brand-import-save:hover, .brand-import-overwrite:hover { background: var(--accent-hover); }
.brand-import-go:active, .brand-import-save:active, .brand-import-overwrite:active { transform: scale(0.97); }
.brand-import-save:disabled { opacity: 0.5; cursor: default; transform: none; }
.brand-import-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; gap: 10px; }
.brand-import-cancel {
  font: inherit; font-size: 12.5px; color: var(--text-muted); background: none; border: none;
  cursor: pointer; padding: 8px 4px; transition: color 0.15s ease;
}
.brand-import-cancel:hover { color: var(--text); }

/* Scan state */
.brand-import-scan { text-align: center; padding: 10px 0 6px; }
.brand-import-scanpage {
  position: relative; width: 128px; height: 92px; margin: 0 auto 16px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); background: var(--surface2); display: flex; gap: 8px; align-items: flex-end;
  padding: 12px;
}
.brand-import-scanpage i { flex: 1; height: 34px; border-radius: 4px; display: block; }
/* Decorative "page content" bars in the scan animation — colours live here, not in JS. */
.brand-import-scanpage i:nth-child(2) { background: var(--accent); }
.brand-import-scanpage i:nth-child(3) { background: #c9b79c; }
.brand-import-scanpage i:nth-child(4) { background: #6f8b74; }
.brand-import-scanpage .scanline {
  position: absolute; left: 0; right: 0; top: -22px; height: 22px;
  background: linear-gradient(rgba(139, 111, 71, 0), rgba(139, 111, 71, 0.22)); animation: brand-import-scan 1.5s linear infinite;
}
@keyframes brand-import-scan { 0% { top: -22px; } 100% { top: 92px; } }
.brand-import-scan-title { font-family: var(--serif); font-size: 15px; color: var(--text); }
.brand-import-scan-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.brand-import-dots::after { content: ""; animation: brand-import-dots 1.4s steps(4, end) infinite; }
@keyframes brand-import-dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* Review — sections */
.brand-import-sec { margin-bottom: 18px; }
.brand-import-label {
  font-size: 10.5px; font-weight: 700; color: var(--accent); text-transform: uppercase;
  letter-spacing: 0.05em; margin-bottom: 9px;
}
.brand-import-name {
  width: 100%; font: inherit; font-size: 14px; font-weight: 600; padding: 9px 11px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--cream); color: var(--text); margin-bottom: 9px;
}
.brand-import-name:focus { outline: none; border-color: var(--accent); }
.brand-import-exists { font-size: 11.5px; color: var(--warn-amber); margin-bottom: 10px; line-height: 1.4; }
.brand-import-exists[hidden] { display: none; }

/* Review — brand DNA swatch */
.brand-import-dna { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.brand-import-dna-colors { display: flex; }
.brand-import-chip {
  flex: 1; height: 60px; display: flex; align-items: flex-end; padding: 5px 6px; font-size: 8px;
  font-family: var(--mono, monospace); overflow: hidden; white-space: nowrap;
}
/* Contrast text over the dynamic swatch background — matches .brand-swatch-chip. */
.brand-import-chip.light-text { color: #FAF7F2; }
.brand-import-chip.dark-text { color: var(--text); }
.brand-import-dna-foot { padding: 10px 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.brand-import-dna-fonts .lbl { font-size: 8px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); margin-top: 5px; }
.brand-import-dna-fonts .lbl:first-child { margin-top: 0; }
.brand-import-dna-fonts .h { font-family: var(--serif); font-size: 15px; font-weight: 500; color: var(--text); }
.brand-import-dna-fonts .b { font-size: 13px; color: var(--text-dim); }
.brand-import-dna-mood { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; max-width: 170px; }
.brand-import-dna-mood span { font-size: 10px; color: var(--text-dim); background: var(--surface2); padding: 2px 8px; border-radius: 999px; }

/* Review — product pick grid */
.brand-import-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.brand-import-pick {
  position: relative; cursor: pointer; border-radius: 9px; overflow: hidden; border: 2px solid transparent;
  background: var(--surface3); aspect-ratio: 1 / 1; transition: transform 0.2s var(--spring);
}
.brand-import-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-import-pick:hover { transform: translateY(-2px); }
.brand-import-check {
  position: absolute; top: 6px; right: 6px; width: 21px; height: 21px; border-radius: 999px;
  background: rgba(255, 253, 246, 0.85); border: 1.5px solid var(--border); display: grid; place-items: center;
  color: transparent; font-size: 12px; font-weight: 700; transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.brand-import-pick:not(.sel) { opacity: 0.55; }
.brand-import-pick.sel { border-color: var(--accent); opacity: 1; }
.brand-import-pick.sel .brand-import-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.brand-import-cap { font-size: 11.5px; color: var(--text-muted); margin-top: 8px; }
.brand-import-cap b { color: var(--text-dim); font-weight: 600; }
.brand-import-cap .warn { color: var(--warn-amber); }
.brand-import-cap .warn b { color: var(--warn-amber); }
.brand-import-empty { font-size: 11.5px; color: var(--text-muted); margin-top: 8px; line-height: 1.4; }

/* Overwrite confirm (name collision) */
.brand-import-confirm { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.brand-import-confirm > span { font-size: 12.5px; color: var(--text-dim); line-height: 1.4; }
.brand-import-confirm > div { display: flex; justify-content: flex-end; gap: 8px; }

/* ==================================================================
   AD BLUEPRINT — in-chat asset checklist (ad-plan.js)
   The clipped "What this ad needs" card the gate shows instead of
   inventing a logo / product / face. Namespaced adplan-*.
   ================================================================== */
.adplan-card {
  position: relative; margin-top: 4px; background: var(--cream);
  border: 1px solid rgba(180, 170, 150, 0.30); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 18px 18px 16px; max-width: 440px;
}
.adplan-card.frozen { opacity: 0.6; }
.adplan-clip {
  position: absolute; top: -10px; left: 26px; width: 13px; height: 34px;
  border: 2.5px solid #bcb5a9; border-radius: 8px; border-bottom-color: rgba(188, 181, 169, 0.35); transform: rotate(8deg);
}
.adplan-clip::after {
  content: ''; position: absolute; top: 5px; left: 2.5px; width: 5px; height: 21px;
  border: 2px solid #d2cbbe; border-radius: 5px; border-top: none;
}
.adplan-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.adplan-title { font-family: var(--serif); font-weight: 500; font-size: 16px; color: var(--text); }
.adplan-chip {
  font-size: 10.5px; font-weight: 600; color: var(--text-muted); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
}
.adplan-sub { font-size: 12.5px; color: var(--text-muted); margin: 5px 0 14px; line-height: 1.45; }
.adplan-rows { display: flex; flex-direction: column; gap: 7px; }
.adplan-row {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border);
}
.adplan-row.checked { background: rgba(139, 111, 71, 0.05); border-color: rgba(139, 111, 71, 0.18); }
.adplan-row.gap { border-style: dashed; border-color: rgba(150, 130, 95, 0.45); }
.adplan-cbox {
  width: 21px; height: 21px; flex: none; border-radius: 6px; border: 1.5px solid var(--border);
  display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--accent);
}
.adplan-row.checked .adplan-cbox, .adplan-cbox.checked { border-color: var(--accent); background: rgba(139, 111, 71, 0.10); }
.adplan-row.gap .adplan-cbox { border-style: dashed; color: var(--text-muted); }
.adplan-row-thumb { width: 30px; height: 30px; border-radius: 6px; flex: none; overflow: hidden; box-shadow: var(--shadow-sm); }
.adplan-row-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.adplan-row-main { flex: 1; min-width: 0; }
.adplan-row-name { font-size: 13px; font-weight: 600; color: var(--text); }
.adplan-row-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.3; }
.adplan-row-meta .ok { color: var(--text-dim); font-weight: 600; }
.adplan-change, .adplan-skip, .adplan-undoskip, .adplan-save {
  color: var(--accent); cursor: pointer; font-weight: 600; border-bottom: 1px dashed rgba(139, 111, 71, 0.4);
}
.adplan-skip { color: var(--text-muted); border-bottom-color: rgba(138, 132, 126, 0.4); }
.adplan-tag {
  display: inline-block; margin-left: 6px; font-size: 9px; font-weight: 700; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-muted); border: 1.5px dashed var(--text-muted); padding: 1px 6px; border-radius: 4px;
}
.adplan-row-act {
  font-size: 11.5px; font-weight: 600; color: var(--accent); cursor: pointer; white-space: nowrap;
  border: 1px solid var(--border); background: var(--cream); padding: 7px 11px; border-radius: 8px;
  transition: transform 0.15s var(--spring), box-shadow 0.15s; flex: none; font-family: var(--sans);
}
.adplan-row-act:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.adplan-foot { margin-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.adplan-note { font-size: 11.5px; color: var(--text-muted); }
.adplan-note b { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.adplan-go {
  font-family: var(--sans); font-size: 13px; font-weight: 600; color: #fff;
  background: linear-gradient(180deg, var(--accent-hover), var(--accent)); border: none; border-radius: 10px;
  padding: 9px 16px; cursor: pointer; box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: transform 0.18s var(--spring), box-shadow 0.18s var(--spring), filter 0.15s; white-space: nowrap;
}
.adplan-go:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.adplan-go:disabled { filter: grayscale(0.7) brightness(1.2); opacity: 0.5; cursor: not-allowed; box-shadow: var(--shadow-sm); }
.adplan-locked { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-dim); }
.adplan-locked .adplan-cbox { width: 17px; height: 17px; font-size: 9px; border-color: var(--accent); background: rgba(139, 111, 71, 0.10); }
@media (prefers-reduced-motion: reduce) {
  .adplan-row-act, .adplan-go { transition: none; }
  .adplan-row-act:hover, .adplan-go:hover:not(:disabled) { transform: none; }
}

/* Pinned "Your brand" card on the Your-files page */
.kb-brand-pin {
  background: var(--cream); border: 1px solid rgba(180, 170, 150, 0.30); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 16px 18px; margin-bottom: 22px;
}
.kb-brand-pin-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.kb-brand-pin-title { font-family: var(--serif); font-weight: 500; font-size: 16px; color: var(--text); }
.kb-brand-pin-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.kb-brand-pin-manage {
  font-family: var(--sans); font-size: 12px; font-weight: 600; color: var(--accent); cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); padding: 7px 13px; border-radius: 9px;
  transition: transform 0.15s var(--spring), box-shadow 0.15s; white-space: nowrap; flex: none;
}
.kb-brand-pin-manage:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.kb-brand-pin-roles { display: flex; gap: 10px; flex-wrap: wrap; }
.kb-brand-role {
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start; flex: 1; min-width: 150px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 11px 13px; cursor: pointer; font-family: var(--sans);
  transition: transform 0.15s var(--spring), box-shadow 0.15s, border-color 0.15s;
}
.kb-brand-role:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); border-color: rgba(139, 111, 71, 0.28); }
.kb-brand-role-label { font-size: 11.5px; font-weight: 600; color: var(--text-dim); }
.kb-brand-role-thumbs { display: flex; align-items: center; gap: 6px; min-height: 30px; }
.kb-brand-thumb { width: 30px; height: 30px; border-radius: 6px; overflow: hidden; box-shadow: var(--shadow-sm); display: block; }
.kb-brand-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.kb-brand-more { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.kb-brand-empty { font-size: 11.5px; font-weight: 600; color: var(--accent); }
@media (prefers-reduced-motion: reduce) {
  .kb-brand-pin-manage, .kb-brand-role { transition: none; }
  .kb-brand-pin-manage:hover, .kb-brand-role:hover { transform: none; }
}

/* ==================================================================
   GALLERY COLUMN VIEW — folders | contact sheet | preview
   ==================================================================
   The Pages column browser, fitted to images. The shell, splitters, folder
   rows, headers and menus are the SAME .pcol-* rules the Pages surface uses —
   the two are meant to be one browser, and a fix to either should repair both.
   Only what is genuinely about pictures lives here.

   Never edit a .pcol-* rule for a gallery-only reason; add a .gcol- override.
   ================================================================== */

/* Column mode owns the viewport: the surface stops scrolling as one document
   and each column scrolls itself. The manila strip goes because folders ARE
   column one — a second folder control would be two truths. */
.page-gallery.is-columns { overflow: hidden; }
.page-gallery.is-columns .folder-tabs-wrap { display: none; }
/* Same shape as .page-pages.is-columns .pages-page-body: zero padding, so the
   browser runs edge to edge and its border-top hairline meets the sticky header
   exactly as it does on Pages. */
.page-gallery.is-columns .gallery-inner {
  flex: 1; min-height: 0; padding: 0;
  display: flex; flex-direction: column;
}
.page-gallery.is-columns #gallery-body { flex: 1; min-height: 0; display: flex; }
.page-gallery.is-columns .gallery-empty { display: none; }

/* Column two holds a grid, not rows, so it wants more of the width than the
   Pages list does — two thumbnails abreast at rest. */
.gcol-columns { --w-pages: 348px; }

/* ---- Sticky day subheaders ---- */
/* The contact sheet is organised by day, and "the one I made Tuesday" is how a
   founder actually locates an image — so the rhythm survives the move into a
   column. Sticky, because in a tall folder the day you are looking at is the
   one piece of context worth never losing. */
.gcol-day {
  position: sticky; top: -6px; z-index: 2;
  display: flex; align-items: center; gap: 8px;
  margin: 10px 2px 6px; padding: 4px 4px 5px;
  background: linear-gradient(to bottom, #fdfcfa 72%, rgba(253, 252, 250, 0));
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--pcol-muted);
}
.gcol-day:first-child { margin-top: 2px; }
.gcol-day-count {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0;
  font-variant-numeric: tabular-nums; color: var(--pcol-muted); opacity: .75;
}

/* ---- The tiles ---- */
/* auto-fill, not a fixed column count: the founder drags the splitter and the
   sheet re-flows 1-up → 2-up → 3-up on its own. 128px is the smallest a
   thumbnail can be and still be recognised at a glance. */
.gcol-sheet {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px; padding: 0 2px 4px;
}
.gcol-tile {
  display: flex; flex-direction: column; gap: 5px;
  padding: 5px; border-radius: 10px; cursor: pointer; user-select: none;
  transition: background .12s, transform .18s var(--spring), box-shadow .18s;
}
/* Hover lifts off the desk — never a colour change. */
.gcol-tile:hover { background: rgba(60, 50, 40, 0.045); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.gcol-tile.is-selected { background: var(--accent-dim); }
.gcol-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.gcol-tile.dragging { opacity: .45; }

.gcol-tile-frame {
  position: relative; aspect-ratio: 1; border-radius: 7px; overflow: hidden;
  background: var(--surface2); box-shadow: 0 1px 3px rgba(60, 50, 40, 0.14);
}
.gcol-tile-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* The selected tile gets a real frame rather than only a tinted bed, so the
   selection survives being read against a busy photograph. */
.gcol-tile.is-selected .gcol-tile-frame {
  box-shadow: 0 0 0 2px var(--accent), 0 2px 6px rgba(60, 50, 40, 0.18);
}
.gcol-tile-cap {
  font-size: 11.5px; line-height: 1.35; color: var(--text-dim); font-weight: 500;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
/* No founder-given name → this is the generation prompt. Muted and italic so it
   never reads as a name. Same rule as the grid card. */
.gcol-tile-cap.is-prompt { color: var(--pcol-muted); font-style: italic; font-weight: 400; }
.gcol-tile.is-selected .gcol-tile-cap { color: var(--text); font-weight: 600; font-style: normal; }

/* ---- Multi-select on a tile ---- */
/* The check is the SAME .gallery-check the grid card uses (the host builds it),
   scaled down for a 128px tile. A picked tile reads through the frame, because
   the tinted bed is already spoken for by the single "which one am I previewing"
   selection — the two states have to be tellable apart at a glance. */
.gcol-tile .gallery-check { width: 22px; height: 22px; top: 5px; left: 5px; }
.gcol-tile .gallery-check svg { width: 12px; height: 12px; }
.gcol-tile:hover .gallery-check { opacity: 1; transform: scale(1); }
.page-gallery.is-selecting .gcol-tile .gallery-check { opacity: 1; transform: scale(1); }
.gcol-tile.is-picked .gallery-check {
  background: var(--accent); border-color: var(--accent); opacity: 1; transform: scale(1);
}
.gcol-tile.is-picked .gallery-check svg { opacity: 1; }
.gcol-tile.is-picked .gcol-tile-frame {
  box-shadow: 0 0 0 2px var(--accent), 0 0 0 4px rgba(139,111,71,0.22), 0 2px 6px rgba(60,50,40,0.18);
}
.gcol-tile .gallery-photo-who { left: 5px; bottom: 5px; font-size: 9.5px; padding: 0 5px; }

/* ---- Preview stage ---- */
/* No paper here. A page is a document and sits on a white sheet; a photograph
   is the object itself, so it gets the surface and a shadow and nothing else. */
/* Flex, not grid. `max-height: 100%` on a grid item resolves against its grid
   AREA, which is auto-sized by the item itself — circular, so it constrains
   nothing and a tall photograph ran straight out of the pane. A flex container
   whose own height is definite (.pcol-preview-stage is flex: 1 inside a
   fixed-height .pcol) gives the percentage something real to resolve against.
   overflow: hidden rather than the inherited auto: once the image is bounded
   there is nothing to scroll, and a scrollbar here would only ever mean a bug. */
.gcol-stage {
  display: flex; align-items: center; justify-content: center;
  min-height: 0; padding: 22px; overflow: hidden;
}
.gcol-stage-img {
  max-width: 100%; max-height: 100%; width: auto; height: auto;
  object-fit: contain; border-radius: 8px; cursor: zoom-in;
  box-shadow: var(--shadow-md);
}
/* Pages gives its status `flex: 0 0 auto` on purpose — it sheds whole pieces at
   width thresholds, because half a word of publish state reads as nothing. The
   gallery's status ends in a folder NAME, which has no pieces to shed and no
   bound on its length, so here it must be allowed to shrink and ellipsize. Left
   as Pages had it, a long folder name pushed the ⋯ clean off the toolbar. */
.gcol-columns .pcol-preview-status {
  flex: 0 1 auto; min-width: 0;
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Inline, not inline-flex, so it participates in that ellipsis rather than
   becoming an unbreakable block inside it. */
.gcol-in-folder { display: inline; }
.gcol-in-folder svg { opacity: .7; vertical-align: -2px; margin-right: 2px; }
/* The preview title falls back to the prompt when the image was never named —
   muted, exactly as on the tile, so the two agree about what is a name. */
.pcol-preview-title.is-prompt { font-style: italic; color: var(--pcol-muted); font-weight: 500; }

/* ---- Toolbar under pressure ---- */
/* Keyed to the COLUMN, not the window. Pages sheds toolbar pieces at viewport
   thresholds, which is right when the layout is fixed — but here the founder
   drags a splitter and can make this column narrow at any window size, so the
   viewport is the wrong thing to ask. inline-size only: the stage's height still
   resolves normally, which .gcol-stage-img depends on. */
.gcol-columns .pcol-preview { container-type: inline-size; container-name: gcolpv; }
@container gcolpv (max-width: 470px) {
  .gcol-columns .gcol-btn-label { display: none; }
  /* Square, so the bare icon sits centred instead of floating in a pill that was
     sized for text. Matches .pages-action-btn.is-icon. */
  .gcol-columns .pcol-preview-actions .pages-action-btn { gap: 0; padding: 4px; width: 27px; justify-content: center; }
  /* The title gives more ground than its 140px floor once the column is this
     tight — a clipped name still reads, a toolbar with the ⋯ pushed off the end
     does not. */
  .gcol-columns .pcol-preview-title { min-width: 64px; }
}

/* The two left columns are fixed px, so on a smaller display they eat the
   preview rather than sharing the loss — at 1024 it collapsed to 138px. Narrow
   them at the window level instead. A splitter drag writes an inline style,
   which outranks this: an explicit choice beats a default, as it should. */
@media (max-width: 1280px) {
  .gcol-columns { --w-folders: 204px; --w-pages: 272px; }
}
@media (max-width: 1080px) {
  .gcol-columns { --w-folders: 176px; --w-pages: 224px; }
}
/* No container query support → keep the labels. Everything still works; the
   toolbar just wants a wider column. */

/* ---- Move-to-folder menu ---- */
.gcol-menu-label {
  padding: 6px 10px 4px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--pcol-muted);
}
.gcol-menu-empty { padding: 4px 10px 8px; font-size: 12px; color: var(--text-muted); }

/* ---- Cold-load skeleton ---- */
.gcol-sk-tile {
  aspect-ratio: 1; border-radius: 7px; background: var(--border-light);
  animation: pcol-sk-breathe 1.6s ease-in-out infinite;
}
.gcol-sk-tile:nth-child(even) { animation-delay: 0.18s; }

@media (prefers-reduced-motion: reduce) {
  .gcol-tile { transition: none; }
  .gcol-tile:hover { transform: none; }
  .gcol-sk-tile { animation: none; }
}

/* ==================================================================
   KNOWLEDGE — COLUMN VIEW (.kbcol-*)
   ==================================================================
   Third surface on the .pcol-* shell, after Pages and Gallery. Everything
   structural is inherited; only what a DOCUMENT needs lives here.

   The rule this file exists to serve: a markdown file looks like nothing
   until you open it, so column three is not a nicety — it is the column
   carrying the whole answer to "which of these is the one I want".
   ================================================================== */

.page-knowledge.is-columns { overflow: hidden; }
/* In column mode the page stops being one scrolling document: each column
   scrolls itself, so the shelf list never scrolls away from the file list.
   The pinned brand card and the sticky category sections belong to the grid
   and list views only. */
.page-knowledge.is-columns .knowledge-page-body {
  flex: 1; min-height: 0; padding: 0;
  display: flex; flex-direction: column;
}
.page-knowledge.is-columns .kb-brand-pin,
.page-knowledge.is-columns .kb-category-section,
.page-knowledge.is-columns .kb-empty { display: none; }

.kbcol-columns { border-top: 1px solid var(--border-light); }

/* ---- Column one: the taxonomy ---- */

/* The pinned brand shelf. A destination, not a category — it has its own
   artifact view — so it sits above the taxonomy behind a rule rather than
   being demoted into the list. Never a drop target: you cannot file a
   markdown document into a shelf of images. */
.kbcol-pin {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; margin-bottom: 6px; border-radius: 8px;
  font: inherit; text-align: left; cursor: pointer;
  background: rgba(139, 111, 71, 0.07);
  border: 1px solid rgba(139, 111, 71, 0.16);
  transition: background .13s, transform .18s var(--spring), box-shadow .18s;
}
.kbcol-pin:hover {
  background: rgba(139, 111, 71, 0.12);
  transform: translateY(-1px); box-shadow: 0 2px 6px rgba(60, 50, 40, 0.08);
}
.kbcol-pin:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.kbcol-pin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.kbcol-pin-name { font-size: 13px; font-weight: 600; color: var(--text); }
.kbcol-pin-sub {
  margin-top: 1px; font-size: 10.5px; color: var(--pcol-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kbcol-pin-count {
  font-size: 11px; font-weight: 600; color: var(--pcol-muted);
  font-variant-numeric: tabular-nums; flex-shrink: 0;
}
.kbcol-sep { height: 1px; background: var(--border-light); margin: 4px 6px 6px; }

/* Refused drop. The accent ring says "here"; this says "not here" without
   pretending a colour flash is an explanation — the row also never sets
   dropEffect to move, so the cursor agrees with the border. */
.pcol-row.no-drop {
  box-shadow: 0 0 0 1.5px rgba(255, 45, 85, 0.4);
  background: rgba(255, 45, 85, 0.06);
}

/* The taxonomy explained ONCE, at the foot of the column where Gallery puts
   "+ New folder". Says both halves: a machine sorted this, and dragging is
   how you disagree. Non-interactive — a caption, not a button. */
.kbcol-col-note {
  flex-shrink: 0; display: flex; align-items: flex-start; gap: 7px;
  padding: 9px 12px 10px 14px; border-top: 1px solid var(--border-light);
  font-size: 10.5px; line-height: 1.45; color: var(--pcol-muted);
}
.kbcol-col-note svg { flex-shrink: 0; margin-top: 1px; color: var(--accent); }

/* ---- Column two: file rows ---- */

/* Rows, not tiles — the Pages treatment rather than the Gallery one. A
   document's identity is its title; there is no thumbnail to make a contact
   sheet out of. align-items:flex-start because the description wraps to two
   lines and the icon should sit with the NAME, not float to the middle. */
.kbcol-file { align-items: flex-start; padding: 8px 10px; gap: 9px; }
.kbcol-file-icon {
  width: 15px; flex-shrink: 0; margin-top: 1px;
  font-size: 13px; line-height: 1.3; text-align: center;
}
.kbcol-file-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.kbcol-file-name {
  font-size: 12.5px; font-weight: 600; line-height: 1.3; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Two lines, clamped. The description is the line that actually tells you
   which of four brand docs this is, so it earns more room than a subtitle —
   but a five-line blurb would turn the shelf back into a wall. */
.kbcol-file-desc {
  margin-top: 2px;
  font-size: 11px; font-weight: 400; line-height: 1.35; color: var(--text-dim);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.kbcol-file-sub {
  margin-top: 5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 10.5px; line-height: 1.2; color: var(--pcol-muted);
}
.kbcol-file.is-selected .kbcol-file-name { color: var(--text); }
.kbcol-file.is-locked { cursor: not-allowed; }

.kbcol-badge {
  font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 1.5px 5px; border-radius: 4px; white-space: nowrap;
}
.kbcol-badge-team { background: rgba(139, 111, 71, 0.14); color: #6b5636; }
.kbcol-badge-mine { background: rgba(60, 50, 40, 0.07); color: var(--pcol-muted); }
.kbcol-badge-mem { background: rgba(16, 185, 129, 0.14); color: #0b7a5c; }

/* Yours / Shared. Hidden entirely until a team file exists — a filter with
   nothing on the other side of it is a control that can only disappoint. */
.kbcol-pills { margin-left: auto; display: flex; gap: 2px; flex-shrink: 0; }
.kbcol-pill {
  font: inherit; font-size: 10.5px; font-weight: 600; letter-spacing: 0;
  text-transform: none; padding: 2px 8px; border-radius: 999px;
  border: 1px solid transparent; background: none; color: var(--pcol-muted);
  cursor: pointer; transition: background .13s, border-color .13s, color .13s;
}
.kbcol-pill:hover { color: var(--text); }
.kbcol-pill.on { background: var(--surface); border-color: var(--border); color: var(--text); }
.kbcol-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---- Column three: the reader ---- */

/* container-type so what collapses is decided by THIS column's width, not the
   viewport — the splitter can make it narrow at any window size. */
.kbcol-columns .pcol-preview { container-type: inline-size; container-name: kbdoc; }

/* ONE row, 40px, the same bar Pages and Gallery ship. It was four rows in the
   modal because it printed things already on screen: the filename is the
   selected row in column two, the category is the highlighted shelf in column
   one. The duplicates went; what remains is only what this bar alone can say.
   Sequence: emoji+title · size · preview only · tags | copy/share · tabs */
.kbcol-doc-head {
  flex-shrink: 0; display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 14px; background: var(--surface);
  border-bottom: 1px solid var(--border-light);
}

/* Its own flex item so a long filename truncating can never eat it, and a
   real button so it carries a tooltip naming the category — an emoji alone
   announces as "artist palette", which tells a screen-reader user nothing
   about where the file is filed. */
.kbcol-doc-emoji {
  flex-shrink: 0; width: 22px; height: 22px; padding: 0;
  display: grid; place-items: center;
  font-size: 13px; line-height: 1;
  border: 1px solid transparent; background: none; border-radius: 6px;
  cursor: pointer; transition: background .13s, border-color .13s, box-shadow .13s;
}
.kbcol-doc-emoji:hover {
  background: var(--surface2); border-color: var(--border);
  box-shadow: 0 1px 2px rgba(60, 50, 40, 0.08);
}
.kbcol-doc-emoji:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Gives ground last, but still capped: past ~260px the founder is re-reading
   the name she just clicked while the actions fall off the end. */
.kbcol-doc-title {
  flex: 0 1 auto; min-width: 100px; max-width: 260px;
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kbcol-doc-meta {
  flex-shrink: 0; font-size: 11px; color: var(--pcol-muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
/* Attribution on shared files only. "by you" on a shelf that is all yours is
   noise, so personal files carry no byline at all. */
.kbcol-doc-by { flex-shrink: 0; font-size: 11px; color: var(--pcol-muted); white-space: nowrap; }

/* Stated, not implied. A founder who has watched the agent WRITE files has
   every reason to assume this pane is where she edits one. Muted because it
   is a fact about the surface, not a warning. */
.kbcol-readonly {
  display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
  font-size: 10.5px; font-weight: 500; color: var(--pcol-muted);
  white-space: nowrap; cursor: default;
}

/* flex-shrink:0, deliberately. Left shrinkable this container squeezed to 0px
   at 626px — the tags were not collapsing, they were being CLIPPED OUT OF
   EXISTENCE, which on screen is identical to a file with no tags. Folding is
   a decision the container queries below make on purpose; it must never
   happen by accident of layout. */
.kbcol-doc-tags { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.kbcol-doc-head .kb-tag {
  font-size: 10px; font-weight: 500; padding: 2px 7px; border-radius: 999px;
  background: var(--surface2); color: var(--text-dim);
  border: 1px solid var(--border-light); white-space: nowrap; flex-shrink: 0;
  /* One essay-length tag can't be allowed to push the actions off the bar. */
  max-width: 110px; overflow: hidden; text-overflow: ellipsis;
}
.kb-tag-more {
  font: inherit; font-size: 10px; font-weight: 600; padding: 2px 7px;
  border-radius: 999px; background: none; border: 1px dashed var(--border);
  color: var(--pcol-muted); cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: background .13s, color .13s, border-style .13s;
}
.kb-tag-more:hover { background: var(--surface2); color: var(--text); border-style: solid; }
.kb-tag-more:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Two faces: "+3" while the samples show, "5 tags" once they don't. With two
   or fewer tags it is absent at full width and reappears narrow, so the tags
   are never silently gone with no way back to them. */
.kb-tag-more-all { display: none; }
.kb-tag-more.no-overflow { display: none; }

.kbcol-doc-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
/* The ⋯ ends the one-shot buttons; the segmented control after it is a mode
   switch, not another button. At a 2px gap the five read as one run, so a
   hairline carries the seam — subtle enough to be felt rather than read. */
.kbcol-doc-sep { width: 1px; height: 16px; flex-shrink: 0; margin: 0 7px; background: var(--border); }

.kbcol-tabs {
  display: flex; gap: 2px; padding: 2px; border-radius: 7px;
  background: var(--surface2); flex-shrink: 0;
}
.kbcol-tab {
  font: inherit; font-size: 11.5px; font-weight: 600; padding: 3px 10px;
  border: none; background: none; border-radius: 5px;
  color: var(--text-muted); cursor: pointer; transition: background .13s, color .13s;
}
.kbcol-tab:hover { color: var(--text); }
.kbcol-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.kbcol-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---- The collapse ladder ----
   Measured, not guessed: every rung was set by sweeping the column in 10px
   steps and watching the row overflow. The fully-labelled state only fits
   past ~810px, so the compact state is the NORMAL one, not a degradation.
   Nothing here removes a capability — Copy, Share, the tag list and the
   Source toggle all live in the ⋯ at every width, so a rung that hides a
   button hides a shortcut. */

/* Copy's label first — two overlapping squares is understood everywhere. */
@container kbdoc (max-width: 810px) {
  .kbcol-doc-copy .kbcol-btn-label { display: none; }
  .kbcol-doc-copy { padding: 4px 6px; }
}
/* Share holds out one rung longer: it is the consequential button in this
   row, and an unlabelled up-arrow does not warn a founder she is about to
   hand the file to her whole team. */
@container kbdoc (max-width: 730px) {
  .kbcol-doc-share .kbcol-btn-label { display: none; }
  .kbcol-doc-share { padding: 4px 6px; }
}
/* Then "Preview only" drops to the bare lock. The LOCK survives every rung
   below, so the fact is never lost — only the wording. The tag chips outrank
   the wording because they are content and it is a caption. */
@container kbdoc (max-width: 660px) {
  .kbcol-readonly .kbcol-btn-label { display: none; }
}
/* Chips fold into the pill; the size goes with them. */
@container kbdoc (max-width: 580px) {
  .kbcol-doc-tags .kb-tag { display: none; }
  .kb-tag-more.no-overflow { display: inline-block; }
  .kb-tag-more-n { display: none; }
  .kb-tag-more-all { display: inline; }
  .kbcol-doc-meta, .kbcol-doc-by { display: none; }
}
/* Past here the toolbar stops trying. Five icons in a 400px row is a smudge,
   and the menu says the words out loud.
   `.no-overflow` is repeated here to out-specify the 580 rung that turns it
   back on. Without it a file with one tag keeps its pill all the way down
   while a file with five loses it here — the same header behaving two ways
   for a reason no founder could name. */
@container kbdoc (max-width: 475px) {
  .kbcol-doc-copy, .kbcol-doc-share, .kb-tag-more, .kb-tag-more.no-overflow { display: none; }
}
/* The floor: a name, a lock, and a ⋯. */
@container kbdoc (max-width: 380px) {
  .kbcol-tabs, .kbcol-doc-sep { display: none; }
}

/* ---- The document ---- */

/* Flex column so the page below can stretch rather than shrink-wrap. */
.kbcol-doc-scroll { display: flex; flex-direction: column; padding: 20px; }
.kbcol-doc-scroll.is-empty { display: block; padding: 0; }

/* `flex: 1 0 auto` is the whole trick: at least the height of the column, and
   taller when the document is. A six-line FAQ otherwise renders as a business
   card floating in grey, which reads as "this file is broken" rather than
   "this file is short". A sheet of paper is a sheet of paper whether or not
   you filled it. */
.kbcol-page {
  flex: 1 0 auto; width: 100%; max-width: 760px; margin: 0 auto;
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 12px; box-shadow: 0 1px 3px rgba(60, 50, 40, 0.05);
}
/* The shared reader type, unconstrained by .output-rendered's 800px cap —
   .kbcol-page already owns the measure, and two competing caps left the text
   off-centre inside its own page. */
.kbcol-page .output-rendered { max-width: none; }
.kbcol-src {
  padding: 20px 24px; font-family: var(--mono); font-size: 12.5px;
  line-height: 1.65; color: var(--text-dim);
  /* overflow-wrap, not the deprecated word-break: break-word (Stylelint
     declaration-property-value-keyword-no-deprecated). `anywhere` is the
     spelling that still breaks a 400-char minified line with no spaces. */
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.kbcol-src pre { margin: 0; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Binaries get a stated fallback, not an empty pane. */
.kbcol-binary-mark {
  display: grid; place-items: center; width: 42px; height: 42px; margin: 0 auto 12px;
  border-radius: 10px; background: var(--surface3); color: var(--pcol-muted);
}
.kbcol-binary-act { margin-top: 14px; }
.kbcol-binary-act .pages-action-btn {
  border-color: var(--border); background: var(--surface); box-shadow: var(--shadow-sm);
}

/* ---- Menus ---- */
.kbcol-menu { min-width: 208px; }
.kbcol-menu-head {
  padding: 6px 10px 4px; font-size: 10px; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase; color: var(--pcol-muted);
}
.kbcol-menu .pages-menu-item { gap: 8px; }
.kbcol-menu .kbmenu-emoji { flex-shrink: 0; width: 15px; text-align: center; }
.kbcol-menu .kbmenu-label {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Current reads as SELECTED, not disabled. Greying it would say "you can't
   have this one" when the point is "this is the one you already have". */
.kbcol-menu .pages-menu-item.is-current {
  background: var(--accent-dim); color: var(--text); font-weight: 600;
  cursor: default; pointer-events: none;
}
.kbmenu-current {
  display: inline-flex; align-items: center; gap: 3px; flex-shrink: 0;
  font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--accent);
}
.kbcol-tag-cloud {
  display: flex; flex-wrap: wrap; gap: 4px; padding: 3px 10px 6px; max-width: 250px;
}
.kbcol-tag-cloud .kb-tag {
  font-size: 10px; font-weight: 500; padding: 2px 7px; border-radius: 999px;
  background: var(--surface2); color: var(--text-dim); border: 1px solid var(--border-light);
}
/* The same sentence the header's footer carries, so wherever the founder
   opens the agent's work from, she is told it was the agent's. */
.kbcol-menu-note {
  display: flex; align-items: flex-start; gap: 6px; padding: 5px 10px 6px;
  max-width: 230px; font-size: 10.5px; line-height: 1.4; color: var(--pcol-muted);
}
.kbcol-menu-note svg { flex-shrink: 0; margin-top: 2px; color: var(--accent); }

/* ---- Cold-load skeleton ---- */
.kbcol-sk-file { height: 46px; }

@media (prefers-reduced-motion: reduce) {
  .kbcol-pin { transition: none; }
  .kbcol-pin:hover { transform: none; }
}

/* ==================================================================
   THE MISSION SHEET — V2 onboarding (COM-76)
   ------------------------------------------------------------------
   Ported verbatim from .claude/prototypes/onboarding-mission.html,
   which is the visual contract. Every number here was measured in a
   browser and several are load-bearing in ways a screenshot cannot
   show. If this disagrees with the prototype, this is the bug.
   Spec: .claude/specs/v2-onboarding-mission-sheet.md
   ================================================================== */

/* ---- the mission on the rail ----
   Sits after .sidebar-spacer and before .sidebar-footer: bottom of the rail,
   directly on top of the profile row. flex-shrink:0 because it follows a
   flex:1 spacer — without it a short viewport squeezes the sheet instead of
   the empty middle. */
.rail-mission { padding: 0 8px 10px; flex-shrink: 0; }

.sheet {
  position: relative; width: 100%;
  background: var(--cream);
  padding: 12px 11px 9px;
  border-radius: 2px;
  transform: rotate(-.5deg);
  box-shadow: 1px 3px 10px rgba(60,50,40,.12), 0 1px 1px rgba(60,50,40,.05);
}
.sheet-clip {
  position: absolute; top: -7px; left: 50%; margin-left: -10px;
  width: 20px; height: 31px;
  border: 2px solid #9c968a; border-radius: 10px;
  border-bottom-color: rgba(175,170,162,.5);
  background: none; transform: rotate(-3deg);
}
.sheet-clip::after {
  content: ''; position: absolute; top: 6px; left: 4px;
  width: 8px; height: 20px;
  border: 2px solid #b4aea1; border-top: 0; border-radius: 0 0 5px 5px;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-bottom: 6px; margin-bottom: 1px;
  border-bottom: 1px solid rgba(197,90,74,.22);
}
.sheet-head-stack { display: block; min-width: 0; }
.sheet-kicker { display: block; font-size: 9px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); margin-bottom: 2px; }
.sheet-title { font-family: var(--serif); font-size: 12px; font-weight: 600; line-height: 1.25; color: var(--text); }
.sheet-count { display: block; margin-top: 3px; font-family: var(--mono); font-size: 9px; letter-spacing: .06em; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.sheet-foot {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin-top: 6px; padding-top: 6px;
  border-top: 1px dashed rgba(175,170,162,.4);
  font-size: 10px; color: var(--text-muted); line-height: 1.4;
}
.sheet-hand { font-family: 'Kalam', cursive; font-size: 11px; color: var(--text-dim); }

/* ---- putting it away (D13) ----
   Job 05 needs an external ad account and live spend, so a founder who doesn't
   run Meta ads can never reach 5/5 — without this the sheet sits in the rail
   forever saying "you didn't finish", which is worse than the problem retiring
   was written to solve.
   Deliberately NOT in Mara's hand: muted sans against her Kalam, the same
   register as "Not now" in the demos. Her handwriting stays her voice; the way
   out is the product's. Low emphasis on purpose — it must be findable without
   ever competing with a loupe. */
.sheet-away {
  flex-shrink: 0; padding: 0; border: 0; background: none;
  font: 500 9.5px var(--sans); color: var(--text-muted);
  letter-spacing: .01em; cursor: pointer; white-space: nowrap;
  border-bottom: 1px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}
.sheet-away:hover { color: var(--text-dim); border-bottom-color: rgba(175,170,162,.5); }
.sheet-away:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The two answers replace the whole line rather than appearing beneath it: the
   sheet must not grow while the founder is deciding, or every loupe shifts
   under a cursor already moving toward one. */
.sheet-foot.is-asking { justify-content: flex-start; gap: 10px; }
/* 10.5px/1.4 puts this line box within 0.3px of .sheet-hand's, so the swap does
   not visibly resize the sheet. Matched by tuning the type rather than by
   pinning a height: a hard-coded min-height would silently stop matching the
   moment either font changes, and it would be wrong in a way nobody looks for. */
.sheet-away-answer {
  padding: 0; border: 0; background: none;
  font: 600 10.5px/1.4 var(--sans); color: var(--accent);
  cursor: pointer; white-space: nowrap;
  border-bottom: 1px solid rgba(139,111,71,.35);
  transition: color .15s ease, border-color .15s ease;
}
.sheet-away-answer:hover { color: var(--text); border-bottom-color: var(--accent); }
.sheet-away-answer:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* When the way out exists at all is canPutAway()'s decision, in the markup —
   0/5 is a fresh start rather than an unfinished task, and 5/5 has its stamp.
   Deliberately not duplicated as a CSS rule here: two places deciding whether a
   control exists is one place to forget. */

/* ---- 5 / 5: the stamp, and then it goes ----
   This mission is onboarding. It completes once and nothing sequences after it,
   so it needs an ending rather than a plateau — a finished sheet that lived in
   the rail forever would be 250px spent saying "done".
   A rubber stamp is the ending: you stamp a sheet when you are finished with
   it. It lands the moment the fifth box ticks, which the founder sees because
   the rail is in their peripheral vision while they work (D2), and the sheet
   retires on the next page load.
   Ink is #3d6b47 — the same deep green as the demo CTA, not a new colour, and
   not prod's cold --green which is already carrying the tick boxes. */
.sheet-stamp {
  position: absolute; z-index: 3; left: 50%; top: 56%;
  padding: 5px 9px 4px;
  border: 2px solid #3d6b47; border-radius: 3px;
  /* the inner rule: real stamps have a double frame, and one inset shadow is
     cheaper than a second element */
  box-shadow: inset 0 0 0 1px #3d6b47;
  color: #3d6b47; opacity: .82;
  font: 800 10px/1 var(--sans);
  letter-spacing: .13em; text-transform: uppercase; white-space: nowrap;
  /* it sits ON the rows, so it must never eat the loupes underneath */
  pointer-events: none;
  transform: translate(-50%,-50%) rotate(-7deg);
  animation: stamp-down .42s cubic-bezier(.2,1.5,.5,1) both;
}
/* the thump: down fast and slightly too far, then settle. No fade-in on the
   way down — ink does not fade in, it lands. */
@keyframes stamp-down {
  0%   { opacity: 0;   transform: translate(-50%,-50%) rotate(-14deg) scale(2.1); }
  55%  { opacity: .92; transform: translate(-50%,-50%) rotate(-7deg)  scale(.94); }
  100% { opacity: .82; transform: translate(-50%,-50%) rotate(-7deg)  scale(1); }
}
/* stamped rows step back so the stamp is the thing you read */
.sheet.is-complete .job-title { color: var(--text-muted); }
.sheet.is-complete .sheet-fold > div { opacity: .62; }
.sidebar.collapsed .sheet-stamp { display: none; }

/* ---- the row: three columns, one per party ----
   [ the agent's mark ] [ your objective ] [ your way in ]
   The tick box and the way in are different columns on purpose. */
.job {
  position: relative; display: grid;
  grid-template-columns: 13px minmax(0,1fr) auto;
  gap: 7px; align-items: center; width: 100%;
  border-bottom: 1px solid rgba(175,170,162,.22);
  padding: 5px 0;
}
.job:has(+ .sheet-foot) { border-bottom: 0; }

/* THE TICK BOX IS NOT A BUTTON. No cursor, no hover, no focus ring, and it
   never takes a click. It reports on the work; it does not control it. A
   founder who thinks these are theirs to tick has understood the product
   backwards — that is a chore list, and a chore list is cognitive load. */
.job-box {
  width: 13px; height: 13px; border-radius: 3px;
  border: 1.5px solid rgba(139,111,71,.45); background: var(--surface);
  display: grid; place-items: center;
  font: 700 9px/1 var(--sans); color: transparent;
  pointer-events: none;
}
.job.is-done .job-box { border-color: var(--green); background: var(--green); color: #fff; }
.job.is-next .job-box { border-color: var(--accent); border-width: 2px; background: rgba(139,111,71,.09); }
.job-title { display: block; font-size: 11.5px; font-weight: 600; color: var(--text); line-height: 1.3; }
.job.is-done .job-title { color: var(--text-dim); }

/* the way in — 22px is all that fits at 240px, which is why the rail picks the
   loupe over the labelled manila tab that works on a desk-width sheet */
.peek-loupe {
  width: 19px; height: 19px; display: grid; place-items: center;
  border: 1px solid rgba(139,111,71,.3); border-radius: 50%;
  background: var(--surface); color: var(--accent); cursor: pointer; padding: 0;
  transition: transform .24s var(--spring), box-shadow .24s ease;
}
.peek-loupe svg { width: 11px; height: 11px; }
.peek-loupe:hover, .peek-loupe:focus-visible { transform: translateY(-2px); box-shadow: 0 3px 9px rgba(60,50,40,.15); }
.peek-loupe:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- the fold ----
   0fr→1fr on a grid row animates to the content's real height without ever
   hard-coding one. Folded keeps the pips: a mission that lives on the rail
   permanently has to be something you can put down, but progress is the one
   thing that should never be foldable. */
.sheet-fold { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .32s var(--ease); }
.sheet-fold > div { overflow: hidden; min-height: 0; visibility: visible; transition: visibility 0s; }
.sheet.is-folded .sheet-fold { grid-template-rows: 0fr; }
/* A folded sheet has to leave the tab order with it. The rows collapse to 0fr
   and the box clips them, but the five loupes and the put-away keep their full
   size inside that clipped box and stay focusable — so a keyboard user folds the
   sheet, tabs into six controls they cannot see, and one of them opens a demo
   popup with no visible source. `visibility` is what removes them from the tab
   order; the delay lets the collapse finish before they vanish. */
.sheet.is-folded .sheet-fold > div { visibility: hidden; transition: visibility 0s linear .32s; }
.sheet-toggle {
  display: grid; place-items: center; flex-shrink: 0;
  width: 20px; height: 20px; padding: 0;
  background: none; border: 0; border-radius: 50%;
  color: var(--text-muted); cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.sheet-toggle:hover { background: rgba(175,170,162,.22); color: var(--text); }
.sheet-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sheet-toggle svg { width: 14px; height: 14px; transition: transform .32s var(--ease); }
.sheet.is-folded .sheet-toggle svg { transform: rotate(-90deg); }
.sheet-pips { display: none; gap: 4px; margin-top: 8px; }
.sheet.is-folded .sheet-pips { display: flex; }
.rail-pip { flex: 1; height: 5px; border-radius: 3px; background: rgba(139,111,71,.16); box-shadow: inset 0 1px 1px rgba(60,50,40,.1); }
.rail-pip.is-done { background: var(--green); box-shadow: none; }
.rail-pip.is-next { background: rgba(139,111,71,.4); box-shadow: inset 0 0 0 1.5px var(--accent); }

/* ---- the collapsed rail (56px) ----
   Not optional to solve: router.js treats anything but 'false' as collapsed.
   It now seeds the key expanded for a first-time founder (D3), so this is the
   path taken when localStorage is unavailable and that seed cannot be written
   — plus anyone who has collapsed the rail themselves. A sheet cannot survive that,
   so it becomes the count over a column of pips. */
.sidebar.collapsed .rail-mission { padding: 0 6px 10px; }
.sidebar.collapsed .sheet { padding: 8px 5px; transform: none; }
.sidebar.collapsed .sheet-clip,
.sidebar.collapsed .sheet-kicker,
.sidebar.collapsed .sheet-title,
.sidebar.collapsed .sheet-toggle,
.sidebar.collapsed .sheet-fold { display: none; }
.sidebar.collapsed .sheet-head { border-bottom: 0; padding: 0; margin: 0; justify-content: center; }
.sidebar.collapsed .sheet-count { margin: 0 0 6px; text-align: center; }
.sidebar.collapsed .sheet-pips { display: flex; flex-direction: column; gap: 3px; margin-top: 0; }
/* flex:none is load-bearing: .rail-pip carries flex:1 for the horizontal row,
   and turned on its side that resolves flex-basis against the HEIGHT and
   collapses every pip to 0px. */
.sidebar.collapsed .rail-pip { flex: none; height: 4px; }

/* ============================================================
   THE DEMO POPUP — one shell, an iframe of the real demo
   The demos live in onboarding-stop-demo.html and are pulled in with ?embed=N.
   ONE source of truth: fix a keyframe there and it changes here. Copying the
   markup across would fork ~600 lines of hand-tuned beats.
   ============================================================ */
.demo-scrim {
  position: fixed; inset: 0; z-index: 200;
  /* warm brown, never neutral black — the desk doesn't turn grey when you pick
     something up off it */
  background: rgba(60,50,40,.42); backdrop-filter: blur(1.5px);
  opacity: 0; transition: opacity .18s ease;
}
.demo-scrim.open { opacity: 1; }
.demo-scrim[hidden] { display: none; }
.pop-shell {
  position: fixed; z-index: 201; top: 50%;
  /* Centred on the WORK AREA, not the viewport. The composer, the letter and the
     cards all centre at (rail + main)/2 = 840 at 1440w; a viewport-centred popup
     lands at 720 and reads as 120px off even though it is "centred".
     One knob (--rail) so the collapsed state can't drift out of sync. */
  --rail: var(--sidebar-width);
  left: calc(50% + var(--rail) / 2);
  /* --pop-w must equal onboarding-stop-demo.html's (--stage-w + 44). It can't be
     shared across the iframe boundary, so it is duplicated on purpose.
     --embed-vw is the iframe's VIEWPORT width, which is what prod's media
     queries read — keep it past prod's widest breakpoint (1240px) or the demos
     silently render in the phone branch. overflow:hidden clips the extra width
     back to the popup, and clipped area takes no clicks, so backdrop-close
     still works either side of the card. */
  --pop-w: 720px;
  --embed-vw: 1400px;
  width: var(--pop-w); overflow: hidden;
  background: var(--cream); border-radius: 12px;
  box-shadow: 4px 8px 30px rgba(60,50,40,.22), 0 2px 6px rgba(60,50,40,.1);
  transform: translate(-50%,-50%) scale(.96) rotate(-.5deg);
  opacity: 0; transition: opacity .18s ease, transform .18s ease, left .28s var(--ease);
}
body.sidebar-collapsed .pop-shell { --rail: var(--sidebar-collapsed); }
.pop-shell.open { opacity: 1; transform: translate(-50%,-50%) scale(1) rotate(-.5deg); transition: opacity .2s ease, transform .45s var(--spring), left .28s var(--ease); }
.pop-shell[hidden] { display: none; }
/* height is a pre-measurement fallback only — the embed posts its real height up
   on load and on fonts.ready, and openStop() applies it. */
.pop-shell iframe {
  display: block; border: 0; background: transparent;
  width: var(--embed-vw);
  margin-left: calc((var(--pop-w) - var(--embed-vw)) / 2);
  height: 600px;
}
.demo-close {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 50%;
  color: var(--text-muted); cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.demo-close:hover { background: rgba(175,170,162,.22); color: var(--text); }
.demo-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* One quiet line to the help centre article for this job (COM-170). Chrome, not
   Mara: muted sans in .sheet-away's register, so her handwriting stays her voice.

   Left at 22px, on the green CTA's own axis. Centring reads as "footer" but adds
   a second alignment axis and pulls more attention than the least important
   control in the popup should get.

   No width: .pop-shell has no padding, so a block child is already --pop-w. The
   iframe next to it is deliberately 1400px with a negative margin and clipped by
   overflow:hidden, and that trick must never drag this row wide. */
.demo-more { display: flex; align-items: center; padding: 2px 0 18px 22px; }
.demo-more a {
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 11.5px/1.4 var(--sans); color: var(--text-muted);
  text-decoration: none; letter-spacing: .01em; padding-bottom: 1px;
  border-bottom: 1px solid transparent;
  transition: color .15s ease, border-color .15s ease, transform .15s ease;
}
/* Lifts off the desk. Colour moves too, but the lift carries the metaphor. */
.demo-more a:hover {
  color: var(--accent); border-bottom-color: rgba(139,111,71,.4);
  transform: translateY(-1px);
}
.demo-more a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
.demo-more svg { width: 13px; height: 13px; flex-shrink: 0; }

@media (prefers-reduced-motion: reduce) {
  .peek-loupe, .sheet-fold, .sheet-toggle svg, .pop-shell, .demo-scrim { transition: none !important; }
  /* Separate, and without !important: this rule already follows .demo-more a at
     equal specificity, so source order alone wins. */
  .demo-more a { transition: none; }
  .demo-more a:hover { transform: none; }
  /* the fold is instant here, so the controls must leave the tab order with it
     rather than lingering for the collapse animation that no longer runs. */
  .sheet.is-folded .sheet-fold > div { transition: none !important; }
  /* the stamp still has to LAND — kill the thump, keep the ink. Not just
     `animation: none`: with fill-mode:both a killed entrance would leave it at
     opacity 0 and scale 2.1, i.e. an invisible stamp twice the sheet's width. */
  .sheet-stamp {
    animation: none !important; opacity: .82 !important;
    transform: translate(-50%,-50%) rotate(-7deg) !important;
  }
}
