:root {
  --bg: #0b0d10;
  --card: #14181d;
  --border: #222831;
  --text: #e6e9ef;
  --muted: #8a92a3;
  --primary: #5eead4;
  --primary-ink: #042f2e;
  --accent: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3 { margin: 0 0 0.4em; }

/* Disable smooth-scroll for users who've asked for reduced motion. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .btn:hover, .btn:active,
  .top nav #new-site-link:hover, .top nav #new-site-link:active { transform: none; }
}

/* Visible keyboard focus rings — important for accessibility and only kick in
   for keyboard users (not mouse clicks). */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Touch hint: removes the 300ms tap delay on iOS for buttons/links. */
.btn, .tab, summary { touch-action: manipulation; }

.top {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 8px 16px;
  background: rgba(11, 13, 16, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.top .brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.1rem; letter-spacing: -0.015em;
  color: var(--text);
}
.brand-mark {
  flex: 0 0 auto;
  width: 20px; height: 20px; border-radius: 6px;
  background: linear-gradient(135deg, #5eead4, #818cf8 55%, #6366f1);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}
.top nav { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px; }
.top nav a:not(.btn) { color: var(--muted); }
.top nav a:not(.btn):hover { color: var(--text); }
/* Promote the "New site" action to an outlined button so the primary
   create-a-site action reads as an action, not a peer of Sign out / Manage
   plan. Styled by id so every page sharing the nav shell stays consistent
   without touching each page's markup. Compact to fit the topbar. */
.top nav #new-site-link {
  padding: 7px 14px; min-height: 0;
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-weight: 600;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease,
              transform 0.12s ease, box-shadow 0.18s ease;
}
.top nav #new-site-link:hover {
  color: var(--text);
  border-color: var(--primary);
  /* Darker gradient fill on hover, matching the button language. */
  background: linear-gradient(180deg, #1c212a 0%, #10141a 100%);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -12px rgba(94, 234, 212, 0.5);
}
.top nav #new-site-link:active { transform: translateY(0); }

/* ---- Account dropdown (topbar email → menu) ----------------------------- */
.account-menu { position: relative; display: inline-flex; }
.account-menu__trigger {
  display: inline-flex; align-items: center; gap: 7px;
  max-width: 240px;
  padding: 7px 10px 7px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--muted); font: inherit; cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.account-menu__trigger:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.account-menu__trigger[aria-expanded="true"] {
  color: var(--text); border-color: var(--primary);
  background: rgba(94, 234, 212, 0.08);
}
.account-menu__email {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* A small chevron that flips when the menu is open. */
.account-menu__caret {
  flex: 0 0 auto; width: 0; height: 0;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  transition: transform 0.15s ease;
}
.account-menu__trigger[aria-expanded="true"] .account-menu__caret { transform: rotate(180deg); }

/* The panel is position: fixed and appended to <body> (top/right are set
   inline by the JS from the trigger's rect) so no page overflow container
   can clip it. */
.account-menu__panel {
  position: fixed; z-index: 200;
  min-width: 180px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
  animation: account-menu-in 0.12s ease-out;
}
.account-menu__panel[hidden] { display: none; }
@keyframes account-menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
.account-menu__item {
  display: block; width: 100%;
  padding: 9px 12px; border-radius: 7px;
  color: var(--text); font: inherit; font-weight: 500; text-align: left;
  background: transparent; border: 0; cursor: pointer; text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}
.account-menu__item:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
/* Optional middle slot for page-specific context (e.g. the site editor's
   site-name + status). Sits between brand and nav, takes remaining width,
   truncates gracefully so a long site name can't push the nav offscreen. */
.top__context {
  display: flex; align-items: center; gap: 10px;
  flex: 1 1 auto; min-width: 0;
  color: var(--muted);
}
.top__context > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top__context__name { font-weight: 600; color: var(--text); }

.container { max-width: 960px; margin: 40px auto; padding: 0 24px; }
.hero { padding: 80px 24px; text-align: center; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); letter-spacing: -0.03em; }
.hero p { color: var(--muted); max-width: 640px; margin: 0 auto 24px; }

.btn {
  display: inline-block; padding: 12px 18px; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer; font: inherit; font-weight: 600;
  min-height: 44px; line-height: 1.2;
  text-align: center;
  transition: background-color 0.15s ease, border-color 0.15s ease,
              color 0.15s ease, box-shadow 0.15s ease, transform 0.08s ease;
}
/* Lift on hover, press on active — physical feedback for every button. */
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); transition-duration: 0.05s; }

/* Filled buttons carry a subtle vertical gradient and shift to a slightly
   DARKER gradient on hover — a tactile "press into the colour" feel, applied
   the same way on the dashboard and the chat page (Send, Clear, Attach…). */
.btn--primary {
  background: linear-gradient(180deg, #63ecd7 0%, #4cdcc9 100%);
  color: var(--primary-ink);
  box-shadow: 0 2px 10px -6px rgba(94, 234, 212, 0.5);
}
.btn--primary:hover {
  background: linear-gradient(180deg, #4cdcc9 0%, #33c1b1 100%);
  box-shadow: 0 6px 18px -8px rgba(94, 234, 212, 0.6);
}
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn--ghost:hover {
  /* Outlined buttons fill with a gradient a touch darker than the surface. */
  background: linear-gradient(180deg, #1c212a 0%, #10141a 100%);
  border-color: var(--muted);
}
.btn--danger {
  background: linear-gradient(180deg, #f15a5a 0%, #e23b3b 100%); color: white;
}
.btn--danger:hover {
  background: linear-gradient(180deg, #e23b3b 0%, #c22b2b 100%);
  box-shadow: 0 6px 18px -8px rgba(239, 68, 68, 0.6);
}

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
/* Long URLs (pages.dev, custom domains) inside cards should wrap rather than
   overflow on narrow screens. */
.card a { overflow-wrap: anywhere; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

[hidden] { display: none !important; }
.form { display: grid; gap: 14px; max-width: 520px; }
.form label { display: grid; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.form input, .form textarea, .form select {
  background: #0e1116; color: var(--text); border: 1px solid var(--border);
  padding: 12px 12px; border-radius: var(--radius); font: inherit;
  /* >=16px prevents iOS Safari from auto-zooming on focus. */
  font-size: max(1rem, 16px);
  width: 100%;
}
.form input[type="checkbox"], .form input[type="radio"] {
  width: auto; padding: 0;
}
.form textarea { resize: vertical; min-height: 96px; }
.form .row { display: flex; gap: 12px; flex-wrap: wrap; }
.form .row > * { flex: 1 1 200px; }

.tabs {
  display: flex; gap: 8px; margin-bottom: 16px; border-bottom: 1px solid var(--border);
  /* On narrow screens, let long tab labels scroll horizontally instead of
     wrapping or overflowing the viewport. */
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 12px 14px; border: 1px solid transparent; border-bottom: none;
  background: transparent; color: var(--muted); cursor: pointer; border-radius: 10px 10px 0 0;
  white-space: nowrap; font: inherit; min-height: 44px;
}
.tab.is-active { color: var(--text); border-color: var(--border); background: var(--card); }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.78rem; background: #1e242c; border: 1px solid var(--border); color: var(--muted);
}
.tag.ok { color: #5eead4; border-color: #115e59; background: #042f2e; }
.tag.warn { color: #fbbf24; border-color: #92400e; background: #1c1303; }
.tag.err { color: #f87171; border-color: #7f1d1d; background: #1a0606; }

.site-list { display: grid; gap: 14px; }
.site-row {
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap;
}
.site-row > * { min-width: 0; }
.site-row h3 { margin: 0; word-break: break-word; font-size: 1.05rem; }
.site-row a { word-break: break-word; overflow-wrap: anywhere; }

/* Site thumbnail: a scaled-down live preview iframe. The iframe is
   loaded at 1280×800 (a typical desktop viewport) so the customer's
   layout renders the way they designed it, then transform: scale()
   shrinks it into a small card. pointer-events:none + tabindex=-1 on
   the iframe make the thumb non-interactive — clicks fall through. */
.site-thumb {
  flex: 0 0 auto;
  width: 160px; height: 100px;
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: rgba(10, 12, 16, 0.6);
  position: relative;
}
.site-thumb__inner { width: 100%; height: 100%; }
.site-thumb iframe {
  /* Absolutely positioned so its fixed 1280px width never drives the
     thumbnail's intrinsic (min-content) size. A fixed-px thumb clips it
     fine either way, but a percentage-width thumb (the full-bleed mobile
     banner) would otherwise inherit the iframe's 1280px and blow out the
     row. Clipped by .site-thumb's overflow: hidden. */
  position: absolute; top: 0; left: 0;
  width: 1280px; height: 800px;
  border: 0;
  transform: scale(0.125);
  transform-origin: 0 0;
  pointer-events: none;
  background: #fff;
}
.site-thumb__placeholder {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  color: var(--muted); font-size: 0.78rem;
  font-family: var(--mono); letter-spacing: 0.08em; text-transform: uppercase;
}

.site-row__meta { flex: 1 1 auto; }
.site-row__head {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.site-row__actions {
  display: flex; gap: 8px; align-items: center;
  flex: 0 0 auto;
}
/* Icon-only delete by default — sits as a small square next to Open
   so it doesn't compete with the primary CTA. Two-click safety: the
   first click expands the button into a "Click again to delete" label
   with a louder armed state until the customer either clicks again or
   the 5s auto-disarm timer fires. */
.site-row__delete {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; padding: 0;
  background: transparent;
  /* Muted by default so a destructive control doesn't visually compete with
     the primary "Open" CTA. Hover/focus reveals the danger red below. */
  color: var(--muted);
  border: 1px solid var(--border);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.site-row__delete:hover:not(:disabled) {
  background: #b91c1c;
  color: #fff;
  border-color: #b91c1c;
}
.site-row__delete:focus-visible {
  outline: 2px solid #b91c1c;
  outline-offset: 2px;
}
/* Armed + busy states carry a text label, so the button needs to grow
   beyond the icon-only square footprint. */
.site-row__delete--text {
  width: auto;
  padding: 12px 14px;
}
.site-row__delete--armed {
  background: #991b1b;
  color: #fff;
  border-color: #991b1b;
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.35);
}
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.88rem; word-break: break-all; }

.toast {
  position: fixed; bottom: 24px; right: 24px; left: 24px; padding: 12px 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  max-width: 380px; margin-left: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  z-index: 1000;
}
.toast.err { border-color: #7f1d1d; color: #fecaca; }

/* ---- Mobile / narrow-screen overrides ----------------------------------- */
@media (max-width: 640px) {
  /* Topbar: drop the brand onto its own line and let the nav sit beneath
     it as one tidy, tappable row instead of a ragged multi-line wrap.
     The signed-in email is the first thing to go — it's the longest item
     and the least actionable, so it crowds out the real nav links. */
  .top { padding: 10px 16px; }
  .top .brand { font-size: 1.05rem; }
  .top nav { width: 100%; justify-content: flex-start; gap: 6px 16px; }
  /* The account menu (email + Sign out) has to stay reachable on mobile —
     it's the only way to sign out now — but cap the email so it doesn't
     dominate the wrapped nav row. */
  .top nav .account-menu__trigger { max-width: 58vw; }
  /* Bigger touch targets for the text links now that they're the row. */
  .top nav a:not(.btn) { padding: 6px 0; }
  .container { margin: 24px auto; padding: 0 16px; }
  .card { padding: 16px; }
  .site-row { flex-direction: column; align-items: stretch; }
  /* Action containers inside site-row use inline `display:flex` to keep tag +
     button(s) on one line. Force them to wrap on mobile so full-width buttons
     don't overflow. */
  .site-row > div { flex-wrap: wrap; }
  .site-row .btn { width: 100%; }
  /* Icon-only delete stays a compact square next to the full-width Open;
     when armed it grows to fit the "Click again to delete" label inline. */
  .site-row__actions { flex-wrap: nowrap; }
  .site-row__delete:not(.site-row__delete--text) { width: 44px; flex: 0 0 auto; }
  .site-row__delete--text { flex: 0 0 auto; width: auto; }
  .form .row > * { flex-basis: 100%; }
  .form .row .btn { width: 100%; }
}

/* ---- Editor (chat-left, iframe-right) ----------------------------------- */
.editor-body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; background: #0a0c10; }
/* Editor's .top sits in a flex column with the editor body below; lock
   it to its intrinsic height so the iframe gets every remaining pixel. */
.editor-body .top { flex: 0 0 auto; }
.editor {
  flex: 1 1 auto; min-height: 0;
  display: grid;
  grid-template-columns: minmax(340px, 440px) 1fr;
  gap: 0;
}
.editor__chat {
  display: flex; flex-direction: column; min-height: 0;
  /* Clip any child that tries to grow past the chat column's grid track.
     Without `min-width: 0` the column would refuse to shrink below
     content min-size; with `overflow: hidden` long target labels and
     pasted URLs can't visually leak under the preview pane. */
  min-width: 0; overflow: hidden;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, #0d1015 0%, #0a0c10 100%);
}
.chat-scroll {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  padding: 22px 22px 16px;
  display: flex; flex-direction: column; gap: 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.chat-scroll::-webkit-scrollbar { width: 8px; }
.chat-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.chat-input {
  flex: 0 0 auto;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--border);
  background: rgba(20, 24, 29, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid; gap: 10px;
  /* Grid children default to min-width: auto, refusing to shrink below
     their content width. Override here so a long target-badge label or a
     pasted URL in the title input can't push the chat column wider. */
  min-width: 0;
}
.chat-input > * { min-width: 0; }
.chat-input__row > * { min-width: 0; }
.chat-input textarea {
  background: #0e1116; color: var(--text); border: 1px solid var(--border);
  padding: 12px 14px; border-radius: 12px; font: inherit;
  font-size: max(0.95rem, 16px); resize: vertical; min-height: 72px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.chat-input textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.12);
}
/* Row = a shrinkable tools cluster + the always-visible Send button. The
   tools cluster wraps internally (growing taller) when the column is narrow,
   so Send can never be pushed off the right edge. */
.chat-input__row { display: flex; gap: 8px; align-items: flex-end; }
.chat-input__row input {
  flex: 1 1 auto; min-width: 0;
  background: #0e1116; color: var(--text); border: 1px solid var(--border);
  padding: 10px 14px; border-radius: 10px; font: inherit;
  font-size: max(0.9rem, 16px);
  transition: border-color 0.15s ease;
}
.chat-input__row input:focus { outline: none; border-color: var(--primary); }
.chat-input__row .btn { flex: 0 0 auto; min-height: 40px; padding: 8px 18px; }
.chat-input__tools {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.chat-input__row .btn--primary { flex: 0 0 auto; }

/* Toolbar controls (attach, clear, effort) share one quiet "input" surface
   so they read as a cohesive cluster beneath the textarea rather than a row
   of mismatched boxes. */
.chat-input__tools .btn--ghost {
  background: #0e1116; border-color: var(--border); color: var(--muted);
  font-weight: 500;
}
.chat-input__tools .btn--ghost:hover {
  background: #161b22; border-color: var(--muted); color: var(--text);
}
/* Icon-only buttons (e.g. 📎) stay square instead of stretching wide. */
.chat-input__row .btn--icon {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0; width: 40px; font-size: 1.05rem; line-height: 1;
}

/* Effort = a single bordered field: an uppercase prefix label + a select
   with a custom chevron and no inner border, so the two read as one pill. */
.cr-effort {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 10px 0 12px;
  background: #0e1116; border: 1px solid var(--border); border-radius: 10px;
  color: var(--muted);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.cr-effort:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.12);
}
.cr-effort__label {
  white-space: nowrap; font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.cr-effort select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background: transparent; border: none; color: var(--text); cursor: pointer;
  margin: 0; padding: 8px 18px 8px 0; min-height: 38px;
  font: inherit; font-size: max(0.85rem, 16px); font-weight: 600;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a92a3' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right center; background-size: 12px;
}
.cr-effort select:focus { outline: none; }
.cr-effort select option { background: #14181d; color: var(--text); font-weight: 500; }

/* While a message is in flight, dim the inputs and show progress on the
   submit button so a second click is both visibly blocked and inert. */
.chat-input.is-sending textarea,
.chat-input.is-sending input { opacity: 0.55; pointer-events: none; }
.chat-input.is-sending .btn { cursor: progress; }
.btn--loading {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  opacity: 0.85;
}
.btn--loading::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin 0.7s linear infinite;
  display: inline-block; flex: 0 0 auto;
}

.btn--sm { padding: 6px 12px; min-height: 32px; font-size: 0.85rem; border-radius: 8px; }

/* ============================================================ *
 * Agent activity stream.
 *
 * Replaces the old SMS-style chat bubbles with a Replit Agent-flavored
 * console: user turns are compact right-aligned command pills, assistant
 * turns are activity rows along a vertical timeline rail with geometric
 * status nodes. The whole thing is borderless by default — visual
 * containment comes from the rail + the uppercase mono label, not from
 * a card chrome around every message.
 *
 * Keep the outer wrappers (.msg, .msg--user, .msg--assistant, .msg--system)
 * because the JS morph reconciler keys off them; the new vocabulary
 * (.user-turn, .activity, .status-node, .activity__rail, …) lives inside.
 * ============================================================ */

.msg {
  display: block;
  max-width: 100%;
  font-size: 0.92rem; line-height: 1.55;
  color: var(--text);
  /* Fade newly-arrived bubbles in once; the morph helper keeps existing
     nodes in place so this animation only fires when a bubble is actually
     inserted into the DOM — quiet by design. */
  animation: agent-row-in 280ms ease-out both;
}
@keyframes agent-row-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
/* Set by the morph reconciler on bubbles that already existed in the DOM,
   so polling re-renders don't keep re-animating the same row. Fresh
   inserts skip this class and animate once. */
.msg.msg--no-anim { animation: none; }

/* "Clear context" archive — when the customer clears context, everything
   before the boundary collapses into this one toggle so the thread reads as
   a fresh, empty start. They can expand it to re-read the earlier
   conversation; the AI still only sees what comes after it. */
.msg--history { padding: 4px 0; }
.ctx-history__summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  color: var(--muted, #8a93a0);
  font-size: 0.78rem; letter-spacing: 0.02em;
}
.ctx-history__summary::-webkit-details-marker { display: none; }
.ctx-history__line { flex: 1 1 auto; height: 1px; background: var(--border); }
/* The clickable pill that reveals / hides the archive. */
.ctx-history__action {
  flex: 0 1 auto; min-width: 0;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 11px; border-radius: 999px;
  border: 1px solid var(--border); background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.ctx-history__action::before {
  content: "▸"; flex: 0 0 auto; font-size: 0.7rem;
  transition: transform 0.15s ease;
}
.msg--history[open] .ctx-history__action::before { transform: rotate(90deg); }
/* "Show" when collapsed, "Hide" when open — text comes from CSS so the
   markup stays state-agnostic. */
.ctx-history__verb { font-weight: 600; color: var(--text); }
.ctx-history__verb::after { content: "Show"; }
.msg--history[open] .ctx-history__verb::after { content: "Hide"; }
.ctx-history__summary:hover .ctx-history__action {
  border-color: var(--muted); color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}
/* The revealed archive: spaced like the live thread but dimmed and rail-
   inset so it reads as out-of-context history. */
.ctx-history__body {
  display: flex; flex-direction: column; gap: 18px;
  margin: 16px 0 6px;
  padding-left: 14px;
  border-left: 2px solid var(--border);
  opacity: 0.72;
}
/* Static history — don't replay the per-bubble entry animation on expand. */
.ctx-history__body .msg { animation: none; }

/* User turn — small right-aligned command pill. Reads like the prompt
   line in a terminal: the "you ›" label cues the speaker, the body
   sits in a subtly tinted slab. */
.msg--user {
  display: flex;
  justify-content: flex-end;
}
.user-turn {
  max-width: 78%;
  display: grid; gap: 4px;
  padding: 10px 14px 11px;
  background:
    linear-gradient(180deg, rgba(94, 234, 212, 0.08) 0%, rgba(94, 234, 212, 0.04) 100%);
  border: 1px solid rgba(94, 234, 212, 0.22);
  border-radius: 12px 12px 4px 12px;
  color: var(--text);
}
.user-turn__label {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
  opacity: 0.85;
}
.user-turn__label::after { content: " ›"; opacity: 0.55; }
.user-turn__body { word-wrap: break-word; white-space: pre-wrap; }
.user-turn__title {
  font-weight: 600;
  letter-spacing: -0.005em;
}

/* Assistant / system turn — activity row.
   A 1px rail on the left, a status node anchored at the top of it, and
   the main column to the right. No card chrome around the body. */
.msg--assistant,
.msg--system {
  display: block;
}
.activity {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 12px;
  padding: 2px 0 0;
}
.activity__rail {
  position: relative;
  display: flex; justify-content: center;
}
/* The vertical line: thin, recedes into the background. The node sits
   on top via the marker's own background. */
.activity__rail::before {
  content: "";
  position: absolute;
  top: 14px; bottom: -16px; left: 50%;
  width: 1px;
  background: linear-gradient(180deg, var(--border) 0%, rgba(34, 40, 49, 0) 100%);
  transform: translateX(-0.5px);
}
/* When the activity is the last bubble in the stream, fade the trailing
   tail of the rail to nothing so the timeline doesn't dangle. */
.msg:last-child .activity__rail::before {
  background: linear-gradient(180deg, var(--border) 0%, rgba(34, 40, 49, 0) 70%);
}

/* Status node — a rotated square that reads as a diamond, varied by
   phase. CSS-only, no SVG. */
.status-node {
  position: relative;
  width: 9px; height: 9px;
  margin-top: 9px;
  transform: rotate(45deg);
  background: var(--bg);
  border: 1px solid var(--muted);
  /* Anchor above the rail so the line passes behind it. */
  z-index: 1;
  box-shadow: 0 0 0 3px var(--bg);
  transition: background-color 200ms ease, border-color 200ms ease, box-shadow 200ms ease;
}
.status-node--queued {
  background: var(--bg);
  border-color: var(--muted);
}
.status-node--running {
  background: var(--primary);
  border-color: var(--primary);
  animation: status-pulse 1.6s ease-in-out infinite;
}
.status-node--done {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--bg), 0 0 8px rgba(94, 234, 212, 0.35);
}
.status-node--failed {
  background: transparent;
  border-color: var(--danger);
  transform: rotate(0deg);
}
.status-node--failed::before,
.status-node--failed::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 9px; height: 1px;
  background: var(--danger);
  transform-origin: center;
}
.status-node--failed::before { transform: translate(-50%, -50%) rotate(45deg); }
.status-node--failed::after  { transform: translate(-50%, -50%) rotate(-45deg); }
.status-node--rejected,
.status-node--neutral {
  background: transparent;
  border-color: var(--border);
}
@keyframes status-pulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--bg), 0 0 0 0 rgba(94, 234, 212, 0.5); }
  50%      { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px rgba(94, 234, 212, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .status-node--running { animation: none; }
  .msg { animation: none; }
}

/* The right-hand column of an activity row. */
.activity__main { min-width: 0; display: grid; gap: 6px; }
.activity__head {
  display: flex; align-items: baseline; gap: 10px;
  min-width: 0; padding-top: 2px;
}
.activity__label {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text);
  opacity: 0.92;
  white-space: nowrap;
}
.activity__status {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.activity__status--queued  { color: var(--muted); }
.activity__status--running { color: var(--primary); }
.activity__status--done    { color: var(--primary); }
.activity__status--failed  { color: var(--danger); }
/* Animated dot prefix on the status word while running — reinforces the
   "happening right now" beat without adding another rotating spinner. */
.activity__status--running::before {
  content: "●";
  margin-right: 6px;
  color: var(--primary);
  animation: status-dot 1.2s ease-in-out infinite;
}
@keyframes status-dot {
  0%, 100% { opacity: 0.35; }
  50%      { opacity: 1; }
}

.activity__time {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  opacity: 0.7;
  white-space: nowrap;
}

.activity__body {
  word-wrap: break-word;
  color: var(--text);
}
.activity__body p { margin: 0; }
.activity__body--muted { color: var(--muted); }

/* The single-line log tail shown while the agent is mid-task. Reads
   like a tail -f peek; not behind a button. */
.activity__log-tail {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
  opacity: 0.78;
  /* Show the freshest line; older context is in the expandable log. */
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.activity__log-tail::before {
  content: "▸ ";
  color: var(--primary);
  opacity: 0.7;
}

/* Expandable full log — inline, no card framing. The summary doubles
   as a slim toggle styled like the action buttons. */
.activity__log {
  margin: 2px 0 0;
}
.activity__log > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 3px 0;
  user-select: none;
}
.activity__log > summary::-webkit-details-marker { display: none; }
.activity__log > summary::before {
  content: "▸";
  font-size: 0.7rem;
  transition: transform 160ms ease;
  display: inline-block;
}
.activity__log[open] > summary::before { transform: rotate(90deg); }
.activity__log > summary:hover { color: var(--text); }
.activity__log-body {
  margin: 8px 0 2px;
  padding: 10px 12px 10px 14px;
  border-left: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
  white-space: pre-wrap; word-break: break-word;
  max-height: 280px; overflow-y: auto;
  background: linear-gradient(90deg, rgba(94, 234, 212, 0.02) 0%, transparent 40%);
}

/* "Technical details" inline disclosure on a failed CR — same vocabulary
   as the log expand. */
.activity__log--mini > summary {
  font-size: 0.66rem;
  color: var(--muted);
}

/* Action strip — slim outlined buttons, mono micro-labels with optional
   glyph prefix. Sits flush under the activity body. */
.activity__actions {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 4px;
}
.activity__actions .btn--sm {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  padding: 5px 11px;
  min-height: 28px;
  border-radius: 6px;
}

/* Resync takeover — a blocking full-page overlay so the customer waits for
   the pull to finish (and doesn't navigate away mid-sync). */
.sync-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.sync-overlay__card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 30px 34px;
  max-width: 380px; width: calc(100% - 48px);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.sync-overlay__spinner {
  width: 44px; height: 44px; margin: 0 auto 18px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: sync-spin 0.8s linear infinite;
}
@keyframes sync-spin { to { transform: rotate(360deg); } }
.sync-overlay__check {
  width: 44px; height: 44px; margin: 0 auto 18px;
  border-radius: 50%;
  background: #16a34a; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; line-height: 1;
}
.sync-overlay__title {
  font-size: 1.05rem; font-weight: 600; margin: 0 0 6px;
  color: var(--text);
}
.sync-overlay__msg {
  color: var(--muted);
  font-size: 0.9rem; line-height: 1.45; margin: 0;
}

/* Multiple-choice options on a `choices` turn — stacked, tappable, each a
   complete request. */
.activity__choices {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 8px;
}
.activity__choice {
  text-align: left;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.35;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.activity__choice:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.05);
}
/* Past (non-interactive) options. Don't dim with opacity — near-white text
   at low opacity on the dark card reads as unreadable grey-on-grey. Instead
   render unpicked history as quiet, flat, muted-but-legible list items. */
.activity__choice:disabled { cursor: default; }
.activity__choice:disabled:not(.activity__choice--picked) {
  color: var(--muted);
  background: transparent;
  border-color: var(--border);
}
.activity__choice--picked {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.12);
  color: var(--text);
  font-weight: 600;
}
.activity__actions .btn--ghost {
  background: rgba(255, 255, 255, 0.015);
  border-color: var(--border);
  color: var(--text);
  opacity: 0.88;
}
.activity__actions .btn--ghost:hover {
  border-color: var(--muted);
  opacity: 1;
}
.activity__actions .btn--primary {
  box-shadow: 0 0 0 1px rgba(94, 234, 212, 0.6) inset, 0 0 18px -6px rgba(94, 234, 212, 0.45);
}

.activity__error-link { color: var(--primary); }

/* Older selectors that other code still emits (we keep the names for
   compatibility with anything outside renderChat that may pass them in). */
.msg__body { word-wrap: break-word; }
.msg__log {
  margin: 0; font-family: var(--mono); font-size: 0.78rem;
  color: var(--muted); white-space: pre-wrap; word-break: break-word;
  background: rgba(10, 12, 16, 0.4); border-left: 1px solid var(--border);
  padding: 8px 10px; max-height: 220px; overflow-y: auto;
}
.msg__log--full { max-height: 320px; }
.msg__details summary { cursor: pointer; color: var(--muted); font-size: 0.8rem; }
.msg__details summary:hover { color: var(--text); }
.msg__actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.link {
  background: none; border: none; color: var(--primary); cursor: pointer;
  padding: 0; font: inherit; text-decoration: underline;
}

/* Browser-chrome preview pane: rounded "window" with traffic-light dots and
   a centered URL pill. Sits inside a darker stage so the white iframe pops. */
.editor__preview {
  display: flex; flex-direction: column; min-height: 0;
  background: #0a0c10;
  padding: 16px 16px 0;
  gap: 12px;
}
.preview-window {
  flex: 1 1 auto; min-height: 0;
  position: relative;
  display: flex; flex-direction: column;
  border-radius: 14px;
  overflow: hidden;
  background: #161a20;
  border: 1px solid var(--border);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255,255,255,0.02) inset;
}
.preview-bar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #1a1f26 0%, #161a20 100%);
  border-bottom: 1px solid var(--border);
}
.preview-bar__dots { display: flex; gap: 6px; }
.preview-bar__dots span {
  width: 11px; height: 11px; border-radius: 50%;
  display: inline-block;
}
.preview-bar__dots span:nth-child(1) { background: #ff5f57; }
.preview-bar__dots span:nth-child(2) { background: #febc2e; }
.preview-bar__dots span:nth-child(3) { background: #28c840; }
.preview-bar__url {
  flex: 1 1 auto; min-width: 0;
  text-align: center;
  font: 0.82rem var(--mono);
  color: var(--muted);
  background: #0e1116;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.preview-bar__url > span:last-child { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.preview-bar__badge {
  flex: 0 0 auto;
  font-size: 0.62rem; letter-spacing: 0.08em; font-weight: 700;
  padding: 2px 6px; border-radius: 4px;
  background: var(--primary); color: var(--primary-ink);
}
.preview-bar__open,
.preview-bar__action {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 6px; color: var(--muted);
  background: transparent; border: 1px solid var(--border);
  text-decoration: none; font-size: 0.95rem;
  cursor: pointer; padding: 0; font: inherit;
}
.preview-bar__open:hover,
.preview-bar__action:hover { color: var(--text); border-color: var(--muted); }
.preview-bar__action.is-active {
  color: var(--primary-ink); background: var(--primary); border-color: var(--primary);
}
/* Attention dot on a preview-bar action (e.g. ⚙ when a resync is pending). */
.preview-bar__action { position: relative; }
.preview-bar__action__alert {
  position: absolute; top: -3px; right: -3px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); border: 2px solid #0b0e12; box-sizing: content-box;
}

/* Publish button + unpublished-changes count badge. The count is rendered
   inline as a small pill that scales naturally with the button label. */
#publish-btn {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
}
.publish-btn__count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.25em; padding: 0 5px; height: 1.25em;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.75rem; font-weight: 700;
}

.viewport-toggle {
  flex: 0 0 auto;
  display: flex; gap: 0;
  background: #0e1116; border: 1px solid var(--border); border-radius: 7px; padding: 2px;
}
.viewport-toggle__btn {
  background: transparent; border: 0; cursor: pointer; padding: 0;
  width: 26px; height: 22px; line-height: 1;
  color: var(--muted); border-radius: 5px;
  font: 0.8rem var(--mono);
}
.viewport-toggle__btn:hover { color: var(--text); }
.viewport-toggle__btn.is-active {
  background: var(--card); color: var(--text);
}

.preview-frame {
  flex: 1 1 auto; min-height: 0; position: relative;
  background: #fff;
  display: flex; align-items: stretch; justify-content: center;
  overflow: auto;
}
.preview-frame[data-viewport="tablet"] { background: #0a0c10; padding: 16px 0; }
.preview-frame[data-viewport="tablet"] iframe {
  max-width: 768px; width: 100%; height: 100%;
  border: 1px solid var(--border); border-radius: 12px; background: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.preview-frame[data-viewport="mobile"] { background: #0a0c10; padding: 16px 0; }
.preview-frame[data-viewport="mobile"] iframe {
  max-width: 390px; width: 100%; height: 100%;
  border: 1px solid var(--border); border-radius: 22px; background: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}

.target-badge {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: rgba(94, 234, 212, 0.08);
  border: 1px solid rgba(94, 234, 212, 0.4);
  border-radius: 8px;
  font-size: 0.82rem; color: var(--text);
  min-width: 0; max-width: 100%;
}

/* ---- Change-request rate badge + scheduled queue ------------------- */
.rate-panel {
  display: grid; gap: 8px;
  font-size: 0.82rem;
}
.rate-panel__row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.rate-panel__row--limited {
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.35);
}
.rate-panel__count { color: var(--text); font-variant-numeric: tabular-nums; }
.rate-panel__sep { color: var(--muted); }
.rate-panel__toggle {
  margin-left: auto;
  border: 0; background: transparent; color: var(--muted);
  font: inherit; cursor: pointer; padding: 0;
}
.rate-panel__toggle:hover { color: var(--text); }
.rate-panel__list {
  display: grid; gap: 6px;
  max-height: 200px; overflow-y: auto;
  padding: 4px 0;
}
.rate-panel__item {
  display: grid; gap: 4px;
  padding: 8px 10px;
  background: #0e1116;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.rate-panel__item-head {
  display: flex; align-items: center; gap: 8px; min-width: 0;
}
.rate-panel__item-title {
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
}
.rate-panel__item-when { color: var(--muted); font-variant-numeric: tabular-nums; }
.rate-panel__item-desc {
  color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rate-panel__item-actions {
  display: flex; gap: 6px; justify-content: flex-end;
}
.rate-panel__edit textarea, .rate-panel__edit input {
  width: 100%;
  background: #0a0c10; color: var(--text); border: 1px solid var(--border);
  padding: 6px 8px; border-radius: 6px; font: inherit; font-size: 0.85rem;
  resize: vertical;
}
.rate-panel__edit { display: grid; gap: 6px; }
.target-badge__clear {
  border: 0; background: transparent; color: var(--muted);
  font-size: 1.1rem; line-height: 1; cursor: pointer; padding: 0 4px;
}
.target-badge__clear:hover { color: var(--text); }

.preview-frame {
  flex: 1 1 auto; min-height: 0; position: relative;
  background: #fff;
}
.preview-frame iframe {
  width: 100%; height: 100%; border: 0; display: block;
}
.preview-overlay {
  position: absolute; inset: 0;
  background: rgba(11, 13, 16, 0.72); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
}
.preview-overlay__inner {
  display: flex; gap: 12px; align-items: center;
  padding: 14px 20px; background: var(--card);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.preview-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  text-align: center; padding: 24px; color: var(--muted); background: var(--bg);
}
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--primary);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Settings takeover -------------------------------------------------
   The ⚙ button in the preview bar drops the settings panel over the whole
   preview window (it used to be a cramped tab in the bottom stage). Scoped
   absolute inside .preview-window so it covers the card edge-to-edge — past
   the bar included — and scrolls on its own. */
.settings-takeover {
  position: absolute; inset: 0; z-index: 6;
  background: #0e1116;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  animation: settings-in 0.14s ease-out;
}
.settings-takeover[hidden] { display: none; }
.settings-takeover::-webkit-scrollbar { width: 8px; }
.settings-takeover::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.settings-takeover .panel--takeover {
  padding: 22px 26px 32px;
  max-width: 1100px; margin: 0 auto;
}
@keyframes settings-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
/* Header variant: title block left, close (×) right, on one row. Needs the
   doubled class so it outranks the base `.panel__head` rule (defined later in
   this file at equal single-class specificity, which would otherwise win on
   source order and force flex-direction back to column). */
.panel__head.panel__head--row {
  flex-direction: row; align-items: flex-start; justify-content: space-between;
  gap: 16px;
}
.settings-takeover__close {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; cursor: pointer; padding: 0;
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); font-size: 1.3rem; line-height: 1;
}
.settings-takeover__close:hover {
  color: var(--text); border-color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

/* Bottom panel system — a single-active-tab strip + an expandable
   content stage below it. Replaces the old accordion grid: collapsed
   state is one ~36px tab row (no panels open = no wasted space); when
   a tab is active, the stage opens BELOW the tabs with full width for
   the panel body. No reflow of other tabs when switching. */
.panel-tabs {
  flex: 0 0 auto;
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  background: rgba(20, 24, 29, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.panel-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: transparent; color: var(--muted);
  border: 1px solid transparent; border-radius: 6px;
  font: inherit; font-size: 0.82rem; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  min-height: 32px;
}
.panel-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.panel-tab.is-active {
  color: var(--text);
  background: var(--card);
  border-color: var(--border);
}
.panel-tab .tag { margin-left: 2px; }
.panel-tab--close {
  margin-left: auto;
  color: var(--muted); font-size: 1.1rem; line-height: 1;
  padding: 6px 10px;
}

.panel-stage {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  background: rgba(14, 17, 22, 0.85);
  padding: 16px 20px;
  max-height: 55vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.panel-stage::-webkit-scrollbar { width: 8px; }
.panel-stage::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.panel { min-width: 0; }
.panel[hidden] { display: none; }
.panel__head {
  margin: 0 0 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.panel__head h3 {
  margin: 0; font-size: 1rem; font-weight: 600; color: var(--text);
  letter-spacing: -0.01em;
}
.panel__head p {
  margin: 0; font-size: 0.85rem; color: var(--muted);
  max-width: 70ch;
}
.panel__toolbar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 14px;
}

/* Site-settings sub-blocks: side-by-side cards on wide screens, stacked
   on narrow. Keeps the four settings (domain / preview / backup / fonts)
   readable without one huge scroll. */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.settings-block {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(20, 24, 29, 0.5);
}
.settings-block h4 {
  margin: 0 0 6px; font-size: 0.92rem; font-weight: 600;
}
.settings-block p { margin: 0 0 10px; font-size: 0.85rem; }
.settings-block .form { margin-top: 4px; }
/* Warning-styled settings block — e.g. a pending resync that needs attention. */
.settings-block--warn { border-color: #92400e; background: #1c1303; }
.settings-block--warn h4 { color: #fbbf24; }

.suggestion__cat {
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  font-size: 0.68rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 3px;
  color: var(--muted);
}

/* ---- Link health panel -------------------------------------------------
   Findings are grouped by status (broken / skipped / ok); each finding is
   a collapsible row showing the target URL plus the pages that reference it. */
.link-group { margin-bottom: 8px; }
.link-group > summary {
  display: flex; align-items: center; gap: 8px;
  list-style: none; cursor: pointer;
  padding: 6px 0; color: var(--text);
}
.link-group > summary::-webkit-details-marker { display: none; }
.link-group > summary::before { content: "▸ "; opacity: 0.6; margin-right: 2px; }
.link-group[open] > summary::before { content: "▾ "; }
.link-group__body { display: grid; gap: 6px; padding: 4px 0 8px; }

.link-finding {
  background: rgba(10, 12, 16, 0.6);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
}
.link-finding[data-status="broken"], .link-finding[data-status="unreachable"] {
  border-color: rgba(239, 68, 68, 0.3);
}
.link-finding > summary {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  list-style: none; cursor: pointer;
  padding: 8px 10px;
  min-width: 0;
}
.link-finding > summary::-webkit-details-marker { display: none; }
.link-finding > summary > .btn { flex: 0 0 auto; margin-left: auto; }
.link-finding__target {
  flex: 1 1 220px; min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
}
.link-finding__body {
  padding: 0 12px 10px;
  border-top: 1px dashed var(--border);
}
.link-refs {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 4px;
  max-height: 220px; overflow-y: auto;
}
.link-ref {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 4px 6px; border-radius: 4px;
  background: rgba(255, 255, 255, 0.02);
}
.link-ref .mono { color: var(--text); }

/* The "Did you mean: /about" affordance — high contrast so it's
   obviously the recommended action. */
.link-suggestion {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 10px; margin: 0 0 10px;
  border: 1px solid rgba(94, 234, 212, 0.25);
  background: rgba(94, 234, 212, 0.05);
  border-radius: 6px;
  font-size: 0.86rem;
}
.link-suggestion code {
  background: rgba(0,0,0,0.3); padding: 2px 6px; border-radius: 3px;
  color: var(--primary);
  overflow-wrap: anywhere;
}
.link-suggestion .btn { margin-left: auto; flex: 0 0 auto; }

/* Per-host rollup row — compact, so 20 hosts don't chew up screen. */
.host-rollup {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px;
  background: rgba(10, 12, 16, 0.6);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.86rem;
}

.inquiry-list { display: grid; gap: 8px; }
.inquiry {
  background: rgba(10, 12, 16, 0.5);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.inquiry.is-unread { border-color: var(--primary); background: rgba(94, 234, 212, 0.06); }
.inquiry > summary {
  list-style: none; cursor: pointer;
  padding: 10px 12px; font-size: 0.88rem;
}
.inquiry > summary::-webkit-details-marker { display: none; }
.inquiry__head {
  display: flex; gap: 8px; align-items: center; min-width: 0;
}
.inquiry__snip {
  font-size: 0.8rem; margin-top: 4px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.inquiry__body {
  padding: 0 12px 12px; border-top: 1px solid var(--border);
}
.kv-row {
  display: grid; grid-template-columns: minmax(80px, 1fr) 3fr; gap: 12px;
  padding: 6px 0; border-bottom: 1px dashed var(--border);
  font-size: 0.85rem;
}
.kv-row:last-child { border-bottom: 0; }
.kv-key {
  color: var(--muted); font-family: var(--mono); font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.04em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kv-val { white-space: pre-wrap; word-break: break-word; }

.analytics-install {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin-bottom: 12px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 8px;
}
.analytics-install > div { flex: 1; min-width: 0; }
.analytics-install .btn { flex: 0 0 auto; }

.analytics-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin: 4px 0 12px;
}
.analytics-stats > div {
  padding: 10px 12px;
  background: rgba(10, 12, 16, 0.5);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.analytics-num { font-size: 1.5rem; font-weight: 700; line-height: 1; }

.sparkline {
  display: flex; align-items: flex-end; gap: 2px;
  height: 48px; padding: 4px;
  background: rgba(10, 12, 16, 0.5);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
}
.sparkline__bar {
  flex: 1 1 0;
  min-height: 2px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
  opacity: 0.85;
}

.analytics-cols {
  display: grid; gap: 12px;
  grid-template-columns: 1fr;
}
@media (min-width: 480px) { .analytics-cols { grid-template-columns: 1fr 1fr; } }
.analytics-h {
  margin: 0 0 6px; font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted);
}
.analytics-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 4px;
  font-size: 0.85rem;
}
.analytics-list li {
  display: flex; justify-content: space-between; gap: 8px;
  overflow: hidden;
}
.analytics-list .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.gbp-card {
  padding: 12px;
  background: rgba(10, 12, 16, 0.5);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.gbp-candidate {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px;
  background: rgba(10, 12, 16, 0.4);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
}
.gbp-candidate > div { min-width: 0; }
.gbp-candidate .btn { flex: 0 0 auto; }

.history-list { display: grid; gap: 8px; }
.history-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: rgba(10, 12, 16, 0.4);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.history-row > div { min-width: 0; }
.history-row .btn { flex: 0 0 auto; }

@media (max-width: 900px) {
  /* Stack: chat on top, preview below. Each scrolls itself. */
  .editor-body { height: auto; overflow: visible; }
  .editor {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(360px, 60vh) minmax(360px, 60vh);
  }
  .editor__chat { border-right: 0; border-bottom: 1px solid var(--border); }
  .editor__preview { padding: 12px 12px 0; }
}
