/* ================================================================
   chat.css — Mochi Chat shell (3-column at desktop, stacked on mobile)
   Inherits design tokens from /static/shared.css.
   ================================================================ */

/* ── Layout root ── */
html, body { height: 100%; }
body.chat-shell {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  grid-template-areas: "side main stack";
  overflow: hidden;
  /* v6.30 — mobile browsers (Samsung Internet, mobile Safari, mobile Chrome)
     compute 100vh including the URL/nav bar area, pushing the input bar
     below the visible viewport. 100dvh = visible-only viewport height
     (Samsung Internet 21+, Safari 15.4+, Chrome 108+, Firefox 101+).
     Falls back to 100vh on legacy browsers via the @supports gate. */
  height: 100vh;
  height: 100dvh;
}

@media (max-width: 1100px) {
  body.chat-shell { grid-template-columns: 280px 1fr; grid-template-areas: "side main"; }
  .cs-stack { position: fixed; right: -340px; top: 0; height: 100%; width: 320px; transition: right .25s var(--ease-smooth); z-index: 200; box-shadow: -16px 0 32px -12px rgba(0,0,0,.18); }
  .cs-stack.open { right: 0; }
}
@media (max-width: 760px) {
  body.chat-shell { grid-template-columns: 1fr; grid-template-areas: "main"; }
  /* v6.12 mobile — sidebar fills more of the viewport so content doesn't
     feel cramped on a 360-px phone. Slide-in keeps the same right-hand
     visual cue. */
  .cs-sidebar { position: fixed; left: -100%; top: 0; height: 100%; width: min(86vw, 320px); transition: left .25s var(--ease-smooth); z-index: 250; box-shadow: 16px 0 32px -12px rgba(0,0,0,.18); }
  .cs-sidebar.open { left: 0; }
  .cs-side-close { display: inline-flex !important; }

  /* Mobile audit fix — cookie banner overlay reflow.
     The grid fills the viewport. When the cookie banner is visible
     (position:fixed bottom:0), it overlays the bottom rows. Shrink the
     grid container's height by the banner's measured height so the
     input bar is always above it. (v6.30 — also dvh-aware.) */
  body.cs-cookie-visible.chat-shell { height: calc(100vh - var(--cs-cookie-h, 0)); height: calc(100dvh - var(--cs-cookie-h, 0)); }
  /* v6.30 — input bar honours the iOS / Samsung edge-display safe area
     so the send button doesn't overlap the home indicator. The padding
     is added on top of the existing 10/12 padding tokens. */
  .cs-input-bar { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }

  /* Touch targets: bring under-44 buttons up to 44 (Apple HIG).
     v6.30 — body.chat-shell prefix bumps specificity so these mobile rules
     win against the later-in-file desktop defaults at the same media query. */
  body.chat-shell .cs-icon-btn { width: 44px; height: 44px; }
  body.chat-shell .cs-side-close,
  body.chat-shell .cs-stack-close { width: 36px; height: 36px; padding: 8px; }
  body.chat-shell .cs-stack-mini-btn { min-height: 36px; padding: 8px 10px; }
  body.chat-shell .cs-side-mini { min-height: 32px; padding: 6px 10px; }

  /* Chips: ensure tap target large enough on mobile */
  body.chat-shell .cs-chip { min-height: 44px; padding: 10px 14px; }

  /* v6.12 mobile — topbar density. Status pill demoted to a small label
     beside the brand; stack-toggle lights up with a counted dot when
     non-empty so users see "3 items" at a glance without opening it. */
  .cs-topbar { padding: 10px 12px; }
  .cs-topbar-status { font-size: 10px; padding: 2px 6px; }
  .cs-topbar-name { font-size: 13px; }
  .cs-stack-count { background: var(--accent); color: white; }

  /* Compose bar — bigger tap targets, slightly tighter padding */
  body.chat-shell .cs-input-bar { padding: 10px 12px; gap: 6px; }
  body.chat-shell .cs-attach-btn,
  body.chat-shell .cs-send-btn,
  body.chat-shell .cs-mic-btn {
    width: 44px; height: 44px;
    flex: 0 0 44px;  /* v6.30 — don't shrink: keep tap target Apple-HIG-compliant */
    border-radius: 12px;
  }
  body.chat-shell .cs-text-input {
    height: 44px;
    min-width: 0;     /* allow shrinking when buttons take full 44 */
    font-size: 16px;  /* prevents iOS zoom-on-focus */
  }

  /* v6.12 mobile — Settings drawer fills the viewport so the option
     grid never crops. Sheet has its own scroll. */
  .cs-settings { padding: 0; align-items: stretch; justify-content: stretch; }
  .cs-settings-box { width: 100%; max-height: 100dvh; border-radius: 0; height: 100dvh; }

  /* Same for cheatsheet + preset modal — full-bleed feels native on phones */
  .cs-ksheet, .cs-psheet { padding: 0; align-items: stretch; }
  .cs-ksheet-box, .cs-psheet-box { width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; }

  /* Sidebar foot — Pro CTA + Settings stacked, both full-width on mobile */
  .cs-side-pro { padding: 12px; }
  .cs-side-settings { padding: 11px 12px; }

  /* Result card density */
  .cs-result-foot { flex-wrap: wrap; gap: 6px; }
  .cs-action-primary { flex: 1; min-width: 140px; justify-content: center; }

  /* v6.12 mobile — compact hint. Desktop shows the full kbd legend;
     phones get just the privacy line. Specificity bumped via
     body.chat-shell because the generic .cs-input-hint rule lives
     later in the cascade and would otherwise win at equal specificity. */
  body.chat-shell .cs-input-hint {
    font-size: 0;
    padding: 6px 12px 8px;
    text-align: center;
    color: var(--text-muted);
  }
  /* Hide every original child (kbd pills bring their own font-size and
     would still render). Only the ::after pseudo line shows. */
  body.chat-shell .cs-input-hint kbd,
  body.chat-shell .cs-input-hint > * { display: none; }
  body.chat-shell .cs-input-hint::after {
    content: '🔒  Files stay on your device';
    font-size: 10.5px;
    letter-spacing: 0.02em;
  }
}
@media (min-width: 761px) {
  .cs-side-close, .cs-stack-close { display: none; }
}
@media (min-width: 1101px) {
  .cs-icon-btn#csStackOpen { display: none; }
  .cs-icon-btn#csSideOpen { display: none; }
}

/* Skip link */
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 8px; top: 8px; padding: 6px 12px; background: var(--accent); color: white; border-radius: 6px; z-index: 9999; }

/* ───────────── v6.8 — State-driven density ─────────────
   body[data-intent] is the global UI mode hook. Each step of the flow
   reveals only the controls relevant to that step; everything else dims.
   Customer impact: less screen noise during the part of the flow that
   needs focus (typing, executing, viewing the result). */
body.cs-typing .cs-bubble:not(.is-latest) .cs-chips,
body.cs-typing .cs-bubble:not(.is-latest) .cs-chips-label {
  opacity: 0.5;
}
body[data-intent="executing"] .cs-bubble:not(.is-latest) .cs-chips,
body[data-intent="executing"] .cs-bubble:not(.is-latest) .cs-onboard,
body[data-intent="executing"] .cs-bubble:not(.is-latest) .cs-next-row,
body[data-intent="executing"] .cs-bubble:not(.is-latest) .cs-tweak-row,
body[data-intent="executing"] .cs-bubble:not(.is-latest) .cs-feedback-row,
body[data-intent="executing"] .cs-bubble:not(.is-latest) .cs-alts-row {
  opacity: 0.3;
  pointer-events: none;
}
body[data-intent="executing"] .cs-input-hint { opacity: 0.5; }
body[data-intent="executing"] .cs-send-btn { opacity: 0.65; }
body[data-intent="result-shown"] .cs-bubble:not(.is-latest) .cs-chips,
body[data-intent="result-shown"] .cs-bubble:not(.is-latest) .cs-feedback-row,
body[data-intent="result-shown"] .cs-bubble:not(.is-latest) .cs-tweak-row,
body[data-intent="result-shown"] .cs-bubble:not(.is-latest) .cs-next-row {
  opacity: 0.4;
}
body[data-intent="result-shown"] .cs-bubble.is-latest .cs-result {
  box-shadow: var(--shadow-soft);
}
/* All bubbles transition smoothly when their state changes */
.cs-bubble .cs-chips,
.cs-bubble .cs-feedback-row,
.cs-bubble .cs-tweak-row,
.cs-bubble .cs-next-row,
.cs-bubble .cs-onboard,
.cs-bubble .cs-alts-row,
.cs-bubble .cs-result,
.cs-input-hint,
.cs-send-btn {
  transition: opacity .25s var(--ease-smooth), box-shadow .35s var(--ease-smooth);
}

/* ───────────── v6.8 — Smooth transitions ─────────────
   Bubble entry, recipe-card reveal, result-image reveal — all use the
   same cubic-bezier (--ease-smooth) tuned for "snappy not bouncy".
   Respects prefers-reduced-motion. */
@keyframes cs-bubble-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cs-bubble.is-latest {
  animation: cs-bubble-in .28s var(--ease-smooth) both;
}
@keyframes cs-card-reveal {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}
.cs-recipe-card.cs-card-live {
  animation: cs-card-reveal .32s var(--ease-spring) both;
}
@keyframes cs-result-reveal {
  from { opacity: 0; transform: scale(0.985); filter: blur(2px); }
  to   { opacity: 1; transform: scale(1);     filter: blur(0); }
}
.cs-result {
  animation: cs-result-reveal .42s var(--ease-smooth) both;
}
/* v6.12 — Mochi micro-interactions. Idle wiggle every ~6s on the topbar
   mascot when status is idle/ready (skipped while busy). Hovering the
   topbar Mochi tile gently lifts her so users see she's a clickable —
   though clicking is still a no-op for now (reserved for a future
   "talk to Mochi" affordance). All respect reduced motion. */
@keyframes cs-mochi-idle-wiggle {
  0%, 92%, 100% { transform: rotate(0deg); }
  94% { transform: rotate(-6deg); }
  96% { transform: rotate(5deg); }
  98% { transform: rotate(-3deg); }
}
.cs-topbar-mochi {
  cursor: default;
  transition: transform .25s var(--ease-spring);
}
.cs-topbar-mochi img {
  animation: cs-mochi-idle-wiggle 8s ease-in-out infinite;
  transform-origin: 50% 70%;
}
.cs-topbar-mochi:hover { transform: scale(1.06); }
body[data-intent="executing"] .cs-topbar-mochi img {
  animation: none;
}

@media (prefers-reduced-motion: reduce) {
  .cs-bubble.is-latest,
  .cs-recipe-card.cs-card-live,
  .cs-result,
  .cs-topbar-mochi img {
    animation: none !important;
  }
  .cs-topbar-mochi { transition: none !important; }
  .cs-bubble .cs-chips,
  .cs-bubble .cs-feedback-row,
  .cs-bubble .cs-tweak-row,
  .cs-bubble .cs-next-row {
    transition: none !important;
  }
}

/* ────────────────── SIDEBAR ────────────────── */
.cs-sidebar {
  grid-area: side;
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.cs-side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; padding: 4px 6px; }
.cs-brand { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-family: var(--heading); font-weight: 800; font-size: 16px; letter-spacing: -0.01em; }
.cs-brand-mark { display: block; }
.cs-side-close { background: transparent; border: 0; color: var(--text-dim); padding: 4px; border-radius: 6px; cursor: pointer; }
.cs-side-close:hover { background: var(--surface-3); color: var(--text); }

.cs-new-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font: 600 13.5px var(--sans); cursor: pointer;
  transition: border-color .15s, background .15s, transform .1s;
}
.cs-new-btn:hover { border-color: var(--accent); background: var(--accent-bg); }
.cs-new-btn:active { transform: scale(0.98); }

.cs-side-section { margin-top: 20px; }
.cs-side-grow { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.cs-side-grow .cs-recent-list { flex: 1; min-height: 0; overflow-y: auto; }

.cs-side-label {
  font: 600 11px var(--sans);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 0 8px 8px;
}
.cs-cat-list, .cs-recent-list {
  display: flex; flex-direction: column; gap: 1px;
}
.cs-cat-item, .cs-recent-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  font: 500 13.5px var(--sans);
  color: var(--text);
  cursor: pointer;
  border: 0; background: transparent; text-align: left; width: 100%;
  text-decoration: none;
  transition: background .12s;
}
.cs-cat-item:hover, .cs-recent-item:hover { background: var(--surface-3); }
.cs-cat-item.active { background: var(--accent-bg); color: var(--accent-text); font-weight: 700; }
.cs-cat-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--mono);
}
/* v6.10 — recent row gets a relative-time mono caption on the right.
   The title may truncate with ellipsis so the time pill always shows. */
.cs-recent-item {
  justify-content: space-between;
}
.cs-recent-title {
  flex: 1;
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cs-recent-time {
  flex-shrink: 0;
  font: 500 10.5px var(--mono);
  color: var(--text-muted);
  letter-spacing: 0.02em;
  margin-left: 6px;
}
.cs-recent-empty {
  text-align: left;
  padding: 10px 10px 14px;
  font-style: normal;
}
.cs-recent-empty > div:first-child {
  font: 600 12.5px var(--sans);
  color: var(--text-dim);
  margin-bottom: 3px;
}
.cs-recent-empty .cs-empty-sub {
  font: 400 11.5px var(--sans);
  color: var(--text-muted);
  line-height: 1.45;
  font-style: normal;
}
.cs-recent-more {
  display: block;
  margin-top: 4px;
  padding: 6px 10px;
  font: 500 11.5px var(--mono);
  color: var(--accent-text);
  text-decoration: none;
  border-radius: 6px;
}
.cs-recent-more:hover { background: var(--accent-bg); }

/* v6.12 — categories collapsed under "All recipes" so the sidebar reads
   as a tight 2-line summary at rest. Caret rotates on open. */
.cs-cat-all {
  font-weight: 600;
  background: var(--accent-bg);
  color: var(--accent-text);
}
.cs-cat-all:hover { background: var(--surface-3); }
.cs-cat-collapse {
  margin-top: 4px;
}
.cs-cat-collapse-summary {
  list-style: none;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 10px;
  font: 500 11.5px var(--mono);
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-radius: 6px;
  user-select: none;
}
.cs-cat-collapse-summary::-webkit-details-marker { display: none; }
.cs-cat-collapse-summary:hover { color: var(--text-dim); background: var(--surface-3); }
.cs-cat-collapse-caret {
  display: inline-block;
  font-size: 9px;
  transition: transform .15s var(--ease-smooth);
}
.cs-cat-collapse:not([open]) .cs-cat-collapse-caret { transform: rotate(-90deg); }
.cs-cat-collapse[open] .cs-cat-collapse-summary { color: var(--text-dim); }
.cs-empty {
  font-size: 12.5px;
  color: var(--text-muted);
  padding: 8px 10px;
  font-style: italic;
}
.cs-side-foot {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 6px;
}
.cs-side-link {
  display: block; padding: 6px 10px; border-radius: 8px;
  text-decoration: none; color: var(--accent-text);
  font: 600 13px var(--sans);
  background: transparent;
  transition: background .12s;
}
.cs-side-link:hover { background: var(--accent-bg); }

/* v6.12 — Pro upsell as the foot's sole CTA */
.cs-side-pro {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255, 126, 179, 0.10), rgba(196, 161, 255, 0.07));
  border: 1px solid rgba(255, 126, 179, 0.30);
  color: var(--text);
  text-decoration: none;
  font: 600 13px var(--sans);
  transition: filter .12s, transform .12s, border-color .12s;
}
.cs-side-pro:hover {
  filter: brightness(1.02);
  transform: translateY(-1px);
  border-color: rgba(255, 126, 179, 0.55);
}
.cs-side-pro-mark {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--lavender));
  color: #fff;
  border-radius: 50%;
  font-size: 13px;
  flex-shrink: 0;
}
.cs-side-pro-text { flex: 1; min-width: 0; }
.cs-side-pro-text small { font-weight: 500; color: var(--text-dim); }
.cs-side-pro-arrow { color: var(--accent-text); font-weight: 700; }

/* v6.12 — Settings: single foot button replacing the 8-button toolbar */
.cs-side-settings {
  display: flex; align-items: center; gap: 8px;
  margin-top: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font: 600 12.5px var(--sans);
  cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
  width: 100%;
}
.cs-side-settings:hover { border-color: var(--accent); color: var(--text); background: var(--accent-bg); }
.cs-side-settings:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cs-side-settings svg { color: currentColor; }

/* Meta links shown ONLY inside the Settings drawer now (kept for any
   page that re-introduces them) */
.cs-side-mini {
  font: 500 11.5px var(--sans);
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 6px;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.cs-side-mini:hover { color: var(--text); background: var(--surface-3); }

/* v6.12 — Settings drawer (modal sheet). Sections grouped by intent. */
.cs-settings {
  position: fixed; inset: 0;
  background: rgba(8, 8, 14, 0.55);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: cs-lb-fade-in 0.18s var(--ease-smooth);
}
.cs-settings-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: min(440px, 100%);
  max-height: calc(100vh - 80px);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: cs-card-reveal .35s var(--ease-spring) both;
}
.cs-settings-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.cs-settings-title { margin: 0; font: 700 16px var(--heading); color: var(--text); }
.cs-settings-close {
  width: 32px; height: 32px;
  border: none; background: transparent;
  font-size: 22px; line-height: 1; color: var(--text-dim);
  border-radius: 6px; cursor: pointer;
}
.cs-settings-close:hover { color: var(--text); background: var(--surface-2); }
.cs-settings-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cs-settings-section {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.cs-settings-section:last-child { border-bottom: 0; }
.cs-settings-label {
  font: 600 11px var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.cs-settings-themes { display: flex; gap: 6px; }
.cs-settings-theme {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font: 500 12.5px var(--sans);
  cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
}
.cs-settings-theme:hover { border-color: var(--accent); color: var(--text); }
.cs-settings-theme.is-active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
}
.cs-settings-rows { display: flex; flex-direction: column; gap: 6px; }
.cs-settings-rows-2 { flex-direction: row; gap: 8px; }
.cs-settings-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .1s;
  text-align: left;
  width: 100%;
}
.cs-settings-row:hover { border-color: var(--accent); background: var(--accent-bg); }
.cs-settings-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cs-settings-row-half { flex: 1; }
.cs-settings-row-icon {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent-text);
  font-size: 14px;
  flex-shrink: 0;
}
.cs-settings-row-body { flex: 1; min-width: 0; }
.cs-settings-row-body strong { display: block; font: 600 13px var(--sans); color: var(--text); }
.cs-settings-row-body small { display: block; font: 500 11px var(--mono); color: var(--text-muted); margin-top: 2px; }
.cs-settings-row-arrow { color: var(--text-muted); font-weight: 600; flex-shrink: 0; }
.cs-settings-links { display: flex; flex-wrap: wrap; gap: 12px; }
.cs-settings-link {
  font: 500 12.5px var(--sans);
  color: var(--accent-text);
  text-decoration: none;
  padding: 4px 0;
}
.cs-settings-link:hover { text-decoration: underline; }

/* ────────────────── MAIN (chat) ────────────────── */
.cs-main {
  grid-area: main;
  display: flex; flex-direction: column;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

.cs-topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  z-index: 10;
}
.cs-topbar-title { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.cs-topbar-mochi { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; background: var(--accent-bg); border-radius: 8px; }
.cs-topbar-name { font: 700 14px var(--heading); }
.cs-topbar-status { font: 500 11px var(--mono); color: var(--text-muted); padding: 2px 8px; background: var(--surface-2); border-radius: 999px; }
.cs-topbar-status.busy { color: var(--accent-text); background: var(--accent-bg); }
.cs-topbar-status.error { color: var(--danger); background: rgba(239,68,68,0.1); }

.cs-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border: 0; background: transparent; color: var(--text-dim);
  border-radius: 8px; cursor: pointer; position: relative;
  transition: background .12s, color .12s;
}
.cs-icon-btn:hover { background: var(--surface-2); color: var(--text); }
.cs-stack-count {
  position: absolute; top: 2px; right: 2px;
  background: var(--accent); color: white;
  font: 700 10px var(--mono);
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; display: inline-flex;
  align-items: center; justify-content: center;
}

/* ── Conversation area ── */
.cs-conversation {
  flex: 1;
  overflow-y: auto;
  padding: 24px 4vw 12px;
  scroll-behavior: smooth;
  background: var(--bg);
}
@media (min-width: 760px) { .cs-conversation { padding: 28px 56px 16px; } }
@media (min-width: 1280px) { .cs-conversation { padding: 32px 80px 20px; } }

.cs-bubble {
  display: flex;
  gap: 12px;
  margin-bottom: 22px;
  max-width: 760px;
  animation: bubbleIn .25s var(--ease-smooth);
}
@keyframes bubbleIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.cs-bubble.user { flex-direction: row-reverse; margin-left: auto; }
.cs-bubble-avatar {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--accent-bg);
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.cs-bubble-avatar img { display: block; width: 28px; height: 28px; }
.cs-bubble.user .cs-bubble-avatar { background: var(--surface-3); color: var(--text); font: 700 13px var(--mono); }
.cs-bubble-content { min-width: 0; flex: 1; }
.cs-bubble.user .cs-bubble-content { text-align: right; }
.cs-text {
  display: inline-block;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  font: 400 14.5px/1.55 var(--sans);
  color: var(--text);
  max-width: 100%;
  word-wrap: break-word;
}
.cs-bubble.user .cs-text { background: var(--accent); border-color: var(--accent); color: white; border-bottom-right-radius: 6px; }
.cs-bubble.bot .cs-text { border-bottom-left-radius: 6px; }
.cs-text strong { font-weight: 700; color: var(--accent-text); }
.cs-bubble.user .cs-text strong { color: white; }
.cs-text code { font-family: var(--mono); font-size: 92%; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; color: var(--accent-text); }

.cs-meta {
  font: 500 11px var(--mono);
  color: var(--text-muted);
  margin-top: 4px;
  padding-left: 4px;
}

/* Recipe-card response inside a bubble */
.cs-recipe-card {
  margin-top: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 12px 14px;
}
.cs-recipe-card-head {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px;
}
.cs-recipe-title { font: 700 14px var(--heading); color: var(--text); }
.cs-recipe-tier {
  font: 700 9.5px var(--mono); padding: 2px 6px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.cs-tier-auto    { background: rgba(92,201,167,.15); color: #2A8E6A; }
.cs-tier-confirm { background: rgba(255,176,136,.18); color: #B5651E; }
.cs-tier-suggest { background: rgba(196,161,255,.18); color: #6B43AC; }
.cs-tier-reject  { background: rgba(239,68,68,.13);  color: #B7282A; }
.cs-recipe-sub { font: 500 12.5px var(--sans); color: var(--text-dim); margin-bottom: 8px; }
.cs-recipe-steps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); }
.cs-recipe-step { padding: 2px 8px; background: var(--surface-2); border-radius: 4px; }
.cs-recipe-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
/* v6.11 — disclosure for tier badge + step list + preset link.
   Collapsed by default to keep the recipe card visually quiet. */
.cs-recipe-details {
  margin-top: 10px;
  border-top: 1px dashed var(--border);
  padding-top: 6px;
}
.cs-recipe-details-summary {
  display: inline-flex; align-items: center; gap: 4px;
  cursor: pointer;
  font: 500 11px var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  list-style: none;
  user-select: none;
  padding: 2px 0;
}
.cs-recipe-details-summary::-webkit-details-marker { display: none; }
.cs-recipe-details-caret {
  display: inline-block; font-size: 10px;
  transition: transform .15s var(--ease-smooth);
}
.cs-recipe-details:not([open]) .cs-recipe-details-caret { transform: rotate(-90deg); }
.cs-recipe-details-inner {
  margin-top: 6px;
  display: flex; flex-direction: column; gap: 6px;
}
.cs-recipe-details-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.cs-recipe-details-link {
  font: 500 11.5px var(--sans);
  color: var(--accent-text);
  text-decoration: none;
}
.cs-recipe-details-link:hover { text-decoration: underline; }

/* Action button (run / open / chip) */
.cs-action {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--accent);
  background: var(--accent); color: white;
  font: 600 13px var(--sans); cursor: pointer; text-decoration: none;
  transition: filter .12s, transform .1s;
}
.cs-action:hover { filter: brightness(1.05); }
.cs-action:active { transform: scale(0.98); }
.cs-action.ghost { background: transparent; color: var(--accent-text); border-color: var(--border); }
.cs-action.ghost:hover { background: var(--accent-bg); border-color: var(--accent); }
.cs-action[disabled] { opacity: .55; cursor: not-allowed; pointer-events: none; }

/* Chips for top-K suggestions */
.cs-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cs-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); border: 1px solid transparent;
  font: 500 12.5px var(--sans); cursor: pointer;
  transition: border-color .12s, background .12s;
}
.cs-chip:hover { border-color: var(--accent); background: var(--accent-bg); }
.cs-chip-emoji { font-size: 14px; }
/* v6.3 — personal-frecency chip variant. Subtle accent so users can see
   "this is what I keep using" at a glance without the row competing
   visually with the action area below. */
.cs-chip-personal {
  background: linear-gradient(135deg, rgba(255, 126, 179, 0.12), rgba(255, 126, 179, 0.04));
  border-color: rgba(255, 126, 179, 0.35);
}
.cs-chip-personal:hover {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(255, 126, 179, 0.18), rgba(255, 126, 179, 0.08));
}
.cs-chips-label {
  margin-top: 12px;
  font: 600 11px var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.cs-chips-label-sub { margin-top: 14px; opacity: 0.7; }

/* Run progress / step list */
.cs-run-progress { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
/* Mockup #1 — collapsed multi-step group */
.cs-run-progress-group { margin-top: 10px; }
.cs-run-progress-group > .cs-run-progress { margin-top: 8px; }
.cs-run-progress-summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 6px;
  background: var(--surface-2); font: 500 12px var(--mono); color: var(--text-dim);
  user-select: none;
}
.cs-run-progress-summary::-webkit-details-marker { display: none; }
.cs-run-progress-summary strong { color: var(--text); font-weight: 600; }
.cs-run-progress-summary .cs-run-progress-caret {
  display: inline-block; transition: transform .15s; font-size: 11px; opacity: .7;
}
.cs-run-progress-group[open] .cs-run-progress-caret { transform: rotate(180deg); }
.cs-run-progress-summary .cs-run-progress-tot { margin-left: auto; opacity: .65; font-size: 11px; }
.cs-run-progress-group:not([open]) > .cs-run-progress { display: none; }
.cs-run-step {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 6px;
  background: var(--surface-2); font: 500 12px var(--mono); color: var(--text-dim);
  transition: background .15s;
}
.cs-run-step.done { background: rgba(92,201,167,.13); color: #2A8E6A; }
.cs-run-step.active { background: var(--accent-bg); color: var(--accent-text); }
.cs-run-step.fail { background: rgba(239,68,68,.13); color: #B7282A; }
/* AI model first-load status — inline indicator next to spin */
.cs-run-step-status {
  margin-left: auto;
  font: 500 11px var(--mono);
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.cs-run-step.active .cs-run-step-status { color: var(--accent-text); }
.cs-run-spin {
  display: inline-block; width: 10px; height: 10px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.cs-run-check { width: 12px; height: 12px; }

/* Result preview */
.cs-result {
  margin-top: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
/* Single-image result (no comparator) */
.cs-result > img {
  display: block;
  width: 100%;
  max-height: 70vh;
  min-height: 280px;
  object-fit: contain;
  background:
    repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface) 0% 50%) 50% / 16px 16px;
}
.cs-result-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-top: 1px solid var(--border);
  font: 500 12px var(--mono); color: var(--text-dim);
}
.cs-result-foot .cs-result-name { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-result-foot .cs-result-size { flex-shrink: 0; }
/* Mockup #4 — primary + ⋯ secondary actions */
.cs-result-foot .cs-action-primary {
  margin-left: auto;
  background: var(--accent); color: #fff; border-color: transparent;
  font-weight: 600;
}
.cs-result-foot .cs-action-primary:hover { filter: brightness(0.95); }
.cs-result-foot .cs-action-more {
  width: 30px; padding: 0; font-size: 14px; line-height: 1; color: var(--text-dim);
  background: transparent; border: 1px solid var(--border);
}
.cs-result-foot .cs-action-more:hover { background: var(--surface-2); color: var(--text); }
.cs-result-more-pop {
  margin: 0 12px 12px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  display: flex; flex-direction: column; gap: 2px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.cs-result-more-pop button {
  text-align: left; padding: 8px 12px; border: 0; background: transparent;
  font: 400 12px/1.3 var(--font); color: var(--text); border-radius: 6px;
  cursor: pointer;
}
.cs-result-more-pop button:hover { background: var(--surface-2); }
/* v6.11 — visual divider in ⋯ popover separates "actions" from
   "clipboard utilities" (the two functional groups). */
.cs-result-more-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 6px;
}

/* UX audit Fix A — onboarding banner: tighter, dismissable inline */
.cs-onboard {
  position: relative;
  padding-right: 28px;
  font-size: 12.5px;
  line-height: 1.55;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 32px 10px 12px;
  color: var(--text-dim);
}
.cs-onboard strong { color: var(--text); }
.cs-onboard-close {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 50%;
  color: var(--text-muted); cursor: pointer; font-size: 14px; line-height: 1;
}
.cs-onboard-close:hover { background: var(--surface-3); color: var(--text); }

/* v6.32 — compact onboarding for mobile (single-line, action-oriented) */
.cs-onboard-compact {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 32px 8px 12px;
  font-size: 13px;
}
.cs-onboard-compact span { flex: 1; }
.cs-onboard-readmore { color: var(--accent); text-decoration: none; }

/* UX audit Fix B — recipe action link variant (smaller, no button-chrome) */
.cs-action-link {
  font: 500 12px var(--sans);
  color: var(--accent-text);
  text-decoration: none;
  padding: 6px 4px;
  margin-left: 4px;
  border-radius: 6px;
}
.cs-action-link:hover { text-decoration: underline; opacity: 0.8; }

/* UX audit Fix C — "Next?" hint row under result card */
.cs-next-row {
  display: flex; flex-wrap: wrap; gap: 6px;
  align-items: center;
  margin-top: 12px; padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 12px; color: var(--text-muted);
}
/* v6.8 — deferred reveal so the user can read the result first.
   Initial state: invisible + collapsed; .is-revealed slides into view. */
.cs-next-row-deferred {
  opacity: 0;
  max-height: 0;
  margin-top: 0;
  padding-top: 0;
  border-top-color: transparent;
  pointer-events: none;
  overflow: hidden;
  transition: opacity .35s var(--ease-smooth), max-height .35s var(--ease-smooth), margin-top .35s var(--ease-smooth), padding-top .35s var(--ease-smooth);
}
.cs-next-row-deferred.is-revealed {
  opacity: 1;
  max-height: 120px;
  margin-top: 12px;
  padding-top: 10px;
  border-top-color: var(--border);
  pointer-events: auto;
}
.cs-next-label { font: 500 11px var(--mono); color: var(--text-muted); margin-right: 4px; }
.cs-chip-next {
  font: 500 12px var(--sans);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.cs-chip-next:hover { background: var(--accent-bg); color: var(--accent-text); border-color: var(--accent); }
.cs-chip-next.cs-chip-done { margin-left: auto; opacity: .7; }
.cs-chip-next.cs-chip-done:hover { opacity: 1; }

/* Chain preview card — explicit confirmation for multi-recipe chains */
.cs-chain-card {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(255, 126, 179, 0.06), transparent 70%);
}
.cs-badge-chain {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.cs-recipe-conf {
  display: inline-block;
  font: 500 10px var(--mono);
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--surface-2);
  color: var(--text-dim);
  margin-left: 6px;
  vertical-align: middle;
}

/* ── Context strip — sits above the input bar, shows current pendingFile/pendingRecipe. ── */
.cs-ctx-strip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 16px; padding: 6px 10px;
  background: var(--accent-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px; color: var(--text);
  animation: csStripIn 200ms ease-out;
}
@keyframes csStripIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@media (min-width: 760px)  { .cs-ctx-strip { margin: 0 56px; } }
@media (min-width: 1280px) { .cs-ctx-strip { margin: 0 80px; } }
.cs-ctx-strip[hidden] { display: none !important; }
.cs-ctx-file       { font-weight: 600; color: var(--text); }
.cs-ctx-meta       { font-family: var(--mono); font-size: 11px; color: var(--text-dim); }
.cs-ctx-recipe     { font-weight: 600; color: var(--accent-text); }
.cs-ctx-recipe-mini{ color: var(--text-dim); font-size: 11.5px; }
.cs-ctx-arrow      { color: var(--text-dim); font-size: 11px; font-style: italic; }
.cs-ctx-clear {
  margin-left: auto;
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 999px; width: 22px; height: 22px; line-height: 1; cursor: pointer;
  font-size: 11px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
  transition: border-color 150ms, color 150ms;
}
.cs-ctx-clear:hover { border-color: var(--accent); color: var(--accent-text); }

/* ── Recipe card — live vs muted ── */
/* Live = the freshest CTA. Muted = a previous card whose call to action was
   superseded by a new state transition. Visually dimmed, not interactive. */
.cs-recipe-card.cs-card-muted {
  opacity: 0.55;
  filter: saturate(0.85);
  pointer-events: none;
  position: relative;
}
.cs-recipe-card.cs-card-muted::after {
  content: 'superseded';
  position: absolute; top: 6px; right: 10px;
  font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-dim); font-weight: 600;
}

/* ── Trust line — micro reminder of "browser-only" differentiation, on every result. ── */
.cs-trust-line {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-dim); opacity: 0.72;
  margin: 4px 12px 8px;
}
.cs-trust-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
}

/* ── Alts row under a result (mockup #2 confirm collapse escape hatch). ── */
.cs-alts-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
  margin: 6px 12px 4px;
  padding-top: 8px; border-top: 1px dashed var(--border);
}
.cs-alts-label {
  font-size: 11.5px; color: var(--text-dim); margin-right: 6px;
}
.cs-chip.cs-chip-muted {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
  font-size: 11.5px;
  padding: 4px 11px;
}
.cs-chip.cs-chip-muted:hover { border-color: var(--accent); color: var(--accent-text); }

/* ── Input bar ── */
.cs-input-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  position: relative;
}
@media (min-width: 760px) { .cs-input-bar { padding: 12px 56px; } }
@media (min-width: 1280px) { .cs-input-bar { padding: 14px 80px; } }
.cs-attach-btn, .cs-send-btn, .cs-mic-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border: 0; background: var(--surface-2); color: var(--text-dim);
  border-radius: 10px; cursor: pointer;
  transition: background .12s, color .12s, transform .12s;
}
.cs-attach-btn:hover, .cs-mic-btn:hover { background: var(--accent-bg); color: var(--accent-text); }
.cs-send-btn { background: var(--accent); color: white; }
.cs-send-btn:hover { filter: brightness(1.05); }
/* v6.6 — voice input button. Pulse animation when actively listening. */
.cs-mic-btn[hidden] { display: none; }
.cs-mic-btn.active {
  background: var(--accent);
  color: white;
  animation: cs-mic-pulse 1.4s ease-in-out infinite;
}
@keyframes cs-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 126, 179, 0.45); }
  50%      { box-shadow: 0 0 0 8px rgba(255, 126, 179, 0); }
}
.cs-mic-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.cs-text-input {
  flex: 1;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font: 400 14.5px var(--sans);
  color: var(--text);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.cs-text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.cs-input-hint {
  font: 500 11px var(--mono); color: var(--text-muted);
  text-align: center;
  padding: 0 16px 10px;
}
.cs-input-hint kbd {
  font-family: var(--mono); font-size: 10px;
  padding: 1px 5px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-dim);
}

/* ── Drop overlay ── */
.cs-drop-overlay {
  position: absolute; inset: 0;
  background: rgba(255, 248, 245, 0.88);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; opacity: 0;
  transition: opacity .15s;
  z-index: 50;
}
[data-theme="dark"] .cs-drop-overlay { background: rgba(26, 18, 22, 0.88); }
.cs-drop-overlay.active { opacity: 1; pointer-events: auto; }
.cs-drop-ring {
  padding: 36px 56px;
  border: 3px dashed var(--accent);
  border-radius: 24px;
  background: var(--surface);
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.cs-drop-msg { font: 600 15px var(--heading); color: var(--text); }

/* ────────────────── STACK PANEL ────────────────── */
.cs-stack {
  grid-area: stack;
  background: var(--surface-2);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0;
}
.cs-stack-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.cs-stack-title { font: 700 14px var(--heading); margin: 0; }
.cs-stack-close { background: transparent; border: 0; color: var(--text-dim); padding: 4px; border-radius: 6px; cursor: pointer; }
.cs-stack-close:hover { background: var(--surface-3); color: var(--text); }
.cs-stack-body { flex: 1; overflow-y: auto; padding: 12px; }
.cs-stack-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 36px 12px; font-style: normal; }
.cs-empty-sub { font-size: 11px; color: var(--text-muted); }
.cs-stack-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
  position: relative;
}
.cs-stack-item-head { display: flex; align-items: center; gap: 8px; font: 600 12px var(--mono); color: var(--text-muted); margin-bottom: 8px; }
.cs-stack-item-num { background: var(--accent-bg); color: var(--accent-text); padding: 1px 6px; border-radius: 4px; }
.cs-stack-item img { display: block; width: 100%; max-height: 100px; object-fit: contain; border-radius: 6px; background: var(--bg); }
.cs-stack-item-meta { font: 500 11px var(--mono); color: var(--text-muted); margin-top: 6px; }
.cs-stack-item-actions { display: flex; gap: 6px; margin-top: 8px; }
.cs-stack-mini-btn {
  flex: 1;
  font: 600 11px var(--sans); padding: 5px 8px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-dim);
  cursor: pointer;
}
.cs-stack-mini-btn:hover { background: var(--accent-bg); color: var(--accent-text); border-color: var(--accent); }

/* Mockup #5 — collapsed older-layers block. The 3 most recent stay expanded;
   anything past that hides under a single "Earlier N" toggle so long sessions
   don't drown the recent steps. */
.cs-stack-older {
  margin-bottom: 8px;
  border: 1px dashed var(--border); border-radius: 10px;
  background: transparent;
}
.cs-stack-older > .cs-stack-older-summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  font: 500 12px var(--mono); color: var(--text-muted);
}
.cs-stack-older-summary::-webkit-details-marker { display: none; }
.cs-stack-older-summary strong { color: var(--text); font-weight: 700; }
.cs-stack-older-caret { display: inline-block; transition: transform .15s; font-size: 11px; opacity: .6; }
.cs-stack-older[open] .cs-stack-older-caret { transform: rotate(180deg); }
.cs-stack-older-list { padding: 0 8px 8px; display: flex; flex-direction: column; gap: 8px; }
.cs-stack-older-list .cs-stack-item { margin-bottom: 0; opacity: 0.85; }

/* Branching UX — lineage indicator on each layer item */
.cs-stack-branch-from {
  margin-left: auto;
  font: 600 10px var(--mono);
  color: var(--accent-text);
  background: var(--accent-bg);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--accent);
}
/* Layer that's been branched FROM (has 2+ children) gets a left rail */
.cs-stack-item.cs-stack-item-branched {
  border-left: 3px solid var(--accent);
  padding-left: 8px;
}
.cs-stack-item.cs-stack-item-branched::before {
  content: 'BRANCH';
  position: absolute;
  top: -7px; left: 8px;
  font: 700 9px var(--mono);
  letter-spacing: 0.06em;
  background: var(--accent);
  color: #fff;
  padding: 1px 5px;
  border-radius: 3px;
}

/* v6.3 — Stack DAG mini-graph. Renders only when actual branching has
   occurred so linear sessions stay visually clean. */
.cs-stack-graph-toggle {
  margin: 8px 12px 12px;
  padding: 8px 10px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.cs-stack-graph-toggle > summary {
  cursor: pointer;
  font: 600 11.5px var(--mono);
  letter-spacing: 0.04em;
  color: var(--text);
  list-style: none;
  display: flex; align-items: center; gap: 6px;
  padding: 2px 0;
  user-select: none;
}
.cs-stack-graph-toggle > summary::-webkit-details-marker { display: none; }
.cs-stack-graph-caret {
  display: inline-block;
  font-size: 10px; opacity: .55;
  transition: transform .15s;
}
.cs-stack-graph-toggle[open] .cs-stack-graph-caret { transform: rotate(0deg); }
.cs-stack-graph-toggle:not([open]) .cs-stack-graph-caret { transform: rotate(-90deg); }
.cs-stack-graph-hint {
  margin-left: auto;
  font: 500 10.5px var(--mono);
  opacity: .55;
  text-transform: none;
  letter-spacing: 0;
}
.cs-stack-graph-scroll {
  margin-top: 6px;
  overflow-x: auto;
  max-height: 240px;
  overflow-y: auto;
}
.cs-stack-graph {
  display: block;
  /* Width is set inline; height grows with stack length */
}
.cs-stack-graph-edge {
  fill: none;
  stroke: var(--border-hover);
  stroke-width: 1.5;
}
.cs-stack-graph-edge-branch {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 3 2;
}
.cs-stack-graph-node circle {
  fill: var(--bg);
  stroke: var(--border-hover);
  stroke-width: 1.6;
  cursor: pointer;
  transition: fill .15s, stroke .15s, transform .15s;
  transform-origin: center;
  transform-box: fill-box;
}
.cs-stack-graph-node text {
  font: 700 9px var(--mono);
  fill: var(--text);
  pointer-events: none;
  user-select: none;
}
.cs-stack-graph-node:hover circle,
.cs-stack-graph-node:focus-visible circle {
  fill: var(--accent);
  stroke: var(--accent);
  transform: scale(1.18);
}
.cs-stack-graph-node:hover text,
.cs-stack-graph-node:focus-visible text { fill: #fff; }
.cs-stack-graph-node:focus { outline: none; }
.cs-stack-graph-node:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 50%;
}
.cs-stack-graph-node.is-branch circle {
  stroke: var(--accent);
  stroke-width: 2.5;
}
.cs-stack-graph-node.is-source circle {
  fill: var(--bg);
  stroke: var(--text-muted);
  stroke-dasharray: 2 2;
}
.cs-stack-item.cs-stack-item-focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  box-shadow: 0 0 0 4px rgba(255, 126, 179, 0.15);
  transition: box-shadow .25s, outline .25s;
}

/* EXIF privacy banner — proactive metadata strip prompt */
.cs-exif-banner {
  margin-top: 12px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(255, 126, 179, 0.10), rgba(255, 126, 179, 0.04));
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text);
}
.cs-exif-icon { font-size: 18px; flex-shrink: 0; }
.cs-exif-text { flex: 1; min-width: 0; }
.cs-exif-banner .cs-exif-strip { flex-shrink: 0; padding: 6px 12px; font-size: 12px; }
.cs-stack-foot { padding: 12px; border-top: 1px solid var(--border); }
.cs-stack-clear { width: 100%; padding: 8px; border-radius: 8px; border: 1px solid var(--border); background: transparent; color: var(--text-dim); font: 600 12px var(--sans); cursor: pointer; }
.cs-stack-clear:hover { color: var(--danger); border-color: var(--danger); }

/* ────────────────── COMMAND PALETTE (⌘K) ────────────────── */
.cs-palette {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.32);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
  z-index: 9500;
  opacity: 0; pointer-events: none;
  transition: opacity .15s var(--ease-smooth);
}
.cs-palette.open { opacity: 1; pointer-events: auto; }
.cs-palette-box {
  width: min(560px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 48px -16px rgba(0,0,0,.32);
  overflow: hidden;
  transform: translateY(-8px) scale(.98);
  transition: transform .18s var(--ease-smooth);
}
.cs-palette.open .cs-palette-box { transform: translateY(0) scale(1); }
.cs-palette-input {
  width: 100%;
  padding: 16px 18px;
  border: 0; outline: none;
  font: 500 16px var(--sans);
  background: var(--surface);
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.cs-palette-list {
  max-height: 50vh;
  overflow-y: auto;
}
.cs-palette-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .12s, border-color .12s;
}
.cs-palette-item:hover, .cs-palette-item.active {
  background: var(--accent-bg);
  border-left-color: var(--accent);
}
.cs-palette-icon { font-size: 18px; flex: 0 0 22px; }
.cs-palette-main { flex: 1; min-width: 0; }
.cs-palette-title { font: 600 14px var(--sans); color: var(--text); }
.cs-palette-sub { font: 500 11.5px var(--mono); color: var(--text-muted); margin-top: 1px; }
.cs-palette-kbd {
  font: 600 10px var(--mono);
  padding: 2px 5px; border-radius: 4px;
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border);
}
.cs-palette-foot {
  display: flex; gap: 14px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font: 500 11px var(--mono);
  color: var(--text-muted);
}
.cs-palette-empty {
  padding: 24px 16px;
  text-align: center;
  font: 500 13px var(--sans);
  color: var(--text-muted);
}

/* ────────────────── BEFORE/AFTER SLIDER ────────────────── */
/*
 * Layout principle: the .cs-compare element shrinks to fit the AFTER image's
 * displayed dimensions EXACTLY (no letterbox). The BEFORE image is then
 * positioned absolutely to fill that same box — both images cover identical
 * screen coordinates. clip-path on the BEFORE overlay reveals 0%→100% from
 * the left, controlled by --cmp-pct.
 *
 * Result: ONE image visually, divided by the handle. No size jumps, no
 * "appearing-from-the-side" feeling — both images are always rendered at
 * the same place, only the visible portion changes.
 */
.cs-compare-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  background:
    repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface) 0% 50%) 50% / 16px 16px;
  padding: 12px;
  min-height: 280px;
}
.cs-compare {
  position: relative;
  display: inline-block;             /* shrink to image's displayed size */
  max-width: 100%;
  max-height: 70vh;
  background: transparent;
  user-select: none;
  cursor: ew-resize;
  touch-action: none;
  --cmp-pct: 50%;
  --cmp-rinset: 50%;                  /* right inset for clip-path = 100% - cmp-pct */
  outline: none;
  border-radius: 6px;
  overflow: hidden;                  /* contains clip-path edges + handle */
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.cs-compare:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
/* Base (AFTER) image — defines container's exact displayed dimensions */
.cs-compare-img {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  width: auto;
  height: auto;
  pointer-events: none;
}
/* Overlay (BEFORE) — fills the container exactly, clipped from the right */
/* Overlay: a partial-width window (set inline by wireComparator) over the
   FULL-size BEFORE image. overflow:hidden clips it. Inner image is given
   the exact pixel width of the base image (also set inline) so the overlay
   acts as a window onto the always-correctly-sized BEFORE image. */
.cs-compare-after {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 50%;                          /* updated inline */
  overflow: hidden;
  pointer-events: none;
}
.cs-compare-after img {
  display: block;
  position: absolute;
  top: 0; left: 0;
  width: 100%;                         /* updated inline to base img's px width */
  height: 100%;
  pointer-events: none;
  max-width: none;
}
.cs-compare-handle {
  position: absolute; top: 0;
  left: var(--cmp-pct);
  height: 100%; width: 2px;
  background: var(--accent);
  transform: translateX(-50%);
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(255,255,255,.6), 0 2px 6px rgba(0,0,0,.18);
}
.cs-compare-handle::before {
  content: '';
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--accent);
  width: 40px; height: 40px;
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0,0,0,.22), 0 0 0 4px rgba(255,255,255,.85);
}
.cs-compare-handle::after {
  content: '◀▶';
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font: 700 12px var(--mono);
  letter-spacing: 0px;
  pointer-events: none;
}
.cs-compare-label {
  position: absolute; top: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font: 700 10px var(--mono);
  text-transform: uppercase;
  letter-spacing: .06em;
  pointer-events: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.cs-compare-label.before { left: 12px;  background: rgba(0,0,0,.55); color: white; }
.cs-compare-label.after  { right: 12px; background: var(--accent);    color: white; }

/* v6.8 onboarding-tour CSS moved to /static/_design/tour.js runtime
   stylesheet (IMTour). Kept here as a marker for future readers. */

/* v6.6 — keyboard shortcut cheatsheet modal. Triggered by `?` or the
   sidebar ⌨ button. Lists every shortcut in one place. */
.cs-ksheet {
  position: fixed; inset: 0;
  background: rgba(8, 8, 14, 0.55);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: cs-lb-fade-in 0.18s ease-out;
}
.cs-ksheet[hidden] { display: none; }
.cs-ksheet-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: min(480px, 100%);
  max-height: calc(100vh - 80px);
  display: flex; flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.25);
  overflow: hidden;
}
.cs-ksheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.cs-ksheet-title {
  margin: 0;
  font: 700 16px var(--sans);
  color: var(--text);
}
.cs-ksheet-close {
  width: 32px; height: 32px;
  border: none; background: transparent;
  font-size: 22px; line-height: 1; color: var(--text-dim);
  border-radius: 6px; cursor: pointer;
}
.cs-ksheet-close:hover { color: var(--text); background: rgba(0,0,0,0.05); }
.cs-ksheet-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.cs-ksheet-body {
  padding: 8px 18px 16px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.cs-ksheet-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
}
.cs-ksheet-row:hover { background: var(--surface-2); }
.cs-ksheet-keys {
  flex-shrink: 0;
  min-width: 110px;
  display: flex; align-items: center; gap: 4px;
}
.cs-ksheet-keys kbd {
  display: inline-block;
  min-width: 26px;
  padding: 2px 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  font: 600 11px var(--mono);
  text-align: center;
  color: var(--text);
}
.cs-ksheet-plus { font-size: 10px; color: var(--text-muted); }
.cs-ksheet-label {
  flex: 1;
  color: var(--text);
  font-size: 13px;
}
.cs-ksheet-foot {
  padding: 10px 18px 14px;
  border-top: 1px solid var(--border);
  font: 500 11.5px var(--mono);
  color: var(--text-dim);
  text-align: center;
}

/* v6.6 — user-saved presets in sidebar. Renders above built-in Recipes
   only when the user has saved at least one. Each row: starred chip +
   tiny ✕ delete. */
.cs-presets-list {
  display: flex; flex-direction: column;
  gap: 4px;
  padding: 0 2px;
}
.cs-preset-row {
  display: flex; align-items: stretch;
  gap: 4px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255, 126, 179, 0.06), transparent);
}
.cs-preset-row:hover {
  background: linear-gradient(135deg, rgba(255, 126, 179, 0.10), rgba(255, 126, 179, 0.02));
}
.cs-preset-item {
  flex: 1;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: transparent; border: 0;
  font: 500 13px var(--sans);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  border-radius: 6px;
  min-width: 0;
}
.cs-preset-item:hover { color: var(--accent); }
.cs-preset-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.cs-preset-title {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cs-preset-del,
.cs-preset-rename,
.cs-preset-info {
  width: 24px;
  border: 0; background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px; line-height: 1;
  border-radius: 6px;
  opacity: 0;
  transition: opacity .12s, color .12s, background .12s;
  flex-shrink: 0;
}
.cs-preset-del { font-size: 16px; }
.cs-preset-row:hover .cs-preset-del,
.cs-preset-row:hover .cs-preset-rename,
.cs-preset-row:hover .cs-preset-info,
.cs-preset-row:focus-within .cs-preset-del,
.cs-preset-row:focus-within .cs-preset-rename,
.cs-preset-row:focus-within .cs-preset-info { opacity: 1; }
.cs-preset-info:hover,
.cs-preset-rename:hover { color: var(--accent); background: var(--accent-bg); }
.cs-preset-del:hover { color: var(--danger); background: rgba(239, 68, 68, 0.10); }
.cs-preset-del:focus-visible,
.cs-preset-rename:focus-visible,
.cs-preset-info:focus-visible {
  opacity: 1;
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

/* v6.10 — preset step-list view modal (read-only) */
.cs-psheet {
  position: fixed; inset: 0;
  background: rgba(8, 8, 14, 0.55);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: cs-lb-fade-in 0.18s var(--ease-smooth);
}
.cs-psheet[hidden] { display: none; }
.cs-psheet-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: min(440px, 100%);
  max-height: calc(100vh - 80px);
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  animation: cs-card-reveal .35s var(--ease-spring) both;
}
.cs-psheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.cs-psheet-title {
  margin: 0;
  font: 700 16px var(--heading);
  color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.cs-psheet-close {
  width: 32px; height: 32px;
  border: none; background: transparent;
  font-size: 22px; line-height: 1; color: var(--text-dim);
  border-radius: 6px; cursor: pointer;
}
.cs-psheet-close:hover { color: var(--text); background: var(--surface-2); }
.cs-psheet-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cs-psheet-meta {
  padding: 10px 18px 6px;
  font: 500 11.5px var(--mono);
  color: var(--text-muted);
}
.cs-psheet-meta code {
  font: 500 11px var(--mono);
  color: var(--text-dim);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
}
.cs-psheet-body {
  padding: 4px 14px 14px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
}
.cs-psheet-step {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 10px;
}
.cs-psheet-step-num {
  flex-shrink: 0;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent-text);
  font: 700 11px var(--mono);
}
.cs-psheet-step-body { flex: 1; min-width: 0; }
.cs-psheet-step-name { font: 500 13px var(--sans); color: var(--text); }
.cs-psheet-step-params {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-word;
}
.cs-psheet-step-params code {
  font: 500 11px var(--mono);
  color: var(--text-dim);
  background: var(--surface);
  padding: 0 4px;
  border-radius: 3px;
}
.cs-psheet-foot {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
}
.cs-psheet-foot .cs-action { flex: 1; text-align: center; }
/* v6.8 — inline rename input replaces the title span on click */
.cs-preset-rename-input {
  flex: 1; min-width: 0;
  padding: 4px 8px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font: 500 13px var(--sans);
  outline: none;
}
.cs-preset-rename-input:focus {
  box-shadow: 0 0 0 3px var(--accent-bg);
}

/* v6.6 — bulk batch UI. Overall progress strip + per-file rows with
   inline download / retry chips + Download-all once batch completes. */
.cs-batch-overall {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 0 8px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.cs-batch-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.cs-batch-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--lavender));
  transition: width .3s ease;
}
.cs-batch-status {
  font: 600 11px var(--mono);
  color: var(--text);
  min-width: 64px;
  text-align: right;
  letter-spacing: 0.02em;
}
.cs-batch-cancel {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  font: 500 11px var(--sans);
  color: var(--text-dim);
  transition: border-color .12s, color .12s;
}
.cs-batch-cancel:hover { color: var(--danger); border-color: var(--danger); }
.cs-batch-cancel:disabled { opacity: 0.6; cursor: default; }
.cs-batch-cancel:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.cs-batch-download-all {
  padding: 5px 12px;
  font-size: 11.5px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.cs-batch-download-all:hover { filter: brightness(1.05); }
.cs-batch-download-all:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.cs-batch-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.cs-batch-row-meta {
  font-size: 10px;
  opacity: 0.7;
  white-space: nowrap;
}
.cs-batch-row-dl, .cs-batch-row-retry {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 5px;
  text-decoration: none;
  font: 600 13px var(--mono);
  color: var(--accent);
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
}
.cs-batch-row-dl:hover, .cs-batch-row-retry:hover {
  background: rgba(255, 126, 179, 0.10);
  border-color: rgba(255, 126, 179, 0.30);
}
.cs-batch-row.skip { opacity: 0.5; }
.cs-batch-row.fail { color: var(--danger); }

/* v6.5 — recipe tweak chips. Sibling-recipe row right after the result.
   v6.8: switched to single-line horizontal scroll so 4-8 sibling chips
   never wrap into a multi-row block (which dominated the result vertical
   space). The label stays sticky on the left while the chips scroll. */
.cs-tweak-row {
  display: flex; align-items: center; gap: 6px;
  margin-top: 10px;
  padding: 4px 0;
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.cs-tweak-row::-webkit-scrollbar { height: 4px; }
.cs-tweak-row::-webkit-scrollbar-track { background: transparent; }
.cs-tweak-row::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.cs-tweak-label {
  flex-shrink: 0;
  position: sticky; left: 0;
  font: 600 11px var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-right: 4px;
  background: var(--surface);
  padding-right: 4px;
  z-index: 1;
}
.cs-chip-tweak {
  flex-shrink: 0;
  background: var(--surface-2);
}
.cs-chip-tweak:hover {
  background: linear-gradient(135deg, rgba(255, 126, 179, 0.10), rgba(255, 126, 179, 0.04));
}

/* v6.5 — lightbox full-window preview. Triggered by stack thumb click;
   closes on backdrop click, ✕, or Esc. Body scroll lock while open. */
.cs-lightbox {
  position: fixed; inset: 0;
  background: rgba(8, 8, 14, 0.88);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: cs-lb-fade-in 0.18s ease-out;
}
.cs-lightbox[hidden] { display: none; }
@keyframes cs-lb-fade-in { from { opacity: 0; } to { opacity: 1; } }
.cs-lightbox-img {
  max-width: 100%; max-height: calc(100vh - 80px);
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  background: var(--text);
}
.cs-lightbox-caption {
  position: absolute; bottom: 18px; left: 50%;
  transform: translateX(-50%);
  color: white; font: 500 13px var(--mono);
  background: rgba(0,0,0,0.65);
  padding: 8px 14px; border-radius: 8px;
  white-space: nowrap;
  max-width: calc(100vw - 80px);
  overflow: hidden; text-overflow: ellipsis;
}
.cs-lightbox-close {
  position: absolute; top: 18px; right: 18px;
  width: 42px; height: 42px;
  border: none; border-radius: 999px;
  background: rgba(255,255,255,0.92); color: #111;
  font-size: 26px; line-height: 1; font-weight: 300;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, background .15s;
}
.cs-lightbox-close:hover { background: white; transform: scale(1.06); }
.cs-lightbox-close:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
@media (max-width: 640px) {
  .cs-lightbox { padding: 20px; }
  .cs-lightbox-img { max-height: calc(100vh - 60px); }
}

/* v6.5 — improved stack empty state explains what the stack IS, not just
   that it's empty. Three icon-tagged tips give the panel a clear purpose. */
.cs-stack-empty .cs-empty-title {
  font: 600 14px var(--sans);
  color: var(--text);
  margin-top: 8px;
}
.cs-stack-empty .cs-empty-sub {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.45;
  max-width: 280px;
  text-align: center;
}
.cs-empty-tips {
  list-style: none; margin: 16px 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  width: 100%;
  max-width: 280px;
}
.cs-empty-tips li {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--surface-2);
}
.cs-empty-tips li strong {
  color: var(--accent);
  font-size: 14px;
  font-family: var(--mono);
  width: 18px;
  text-align: center;
}

/* v6.5 — first-visit guide banner. One-line explainer that appears the
   first time the stack populates, then dismisses on click or next run. */
.cs-stack-guide {
  display: flex; align-items: center; gap: 8px;
  margin: 8px 12px 4px;
  padding: 8px 10px;
  background: linear-gradient(135deg, rgba(255, 126, 179, 0.10), rgba(255, 126, 179, 0.04));
  border: 1px solid rgba(255, 126, 179, 0.30);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
}
.cs-stack-guide-text { flex: 1; }
.cs-stack-guide-text strong {
  font-family: var(--mono);
  color: var(--accent);
}
.cs-stack-guide-close {
  border: none; background: transparent; cursor: pointer;
  color: var(--text-dim);
  font-size: 16px; line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.cs-stack-guide-close:hover { color: var(--text); background: rgba(0,0,0,0.05); }
.cs-stack-guide-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* v6.12 — result "More options" collapse. Hides tweak chips + feedback +
   next-row by default so the result reads as image + Download + ⋯.
   One click reveals every secondary path. */
.cs-result-more-group {
  margin-top: 10px;
  border-top: 1px dashed var(--border);
  padding-top: 6px;
}
.cs-result-more-summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  font: 500 11.5px var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 4px 0;
  user-select: none;
}
.cs-result-more-summary::-webkit-details-marker { display: none; }
.cs-result-more-summary:hover { color: var(--text-dim); }
.cs-result-more-caret {
  display: inline-block;
  font-size: 10px;
  transition: transform .15s var(--ease-smooth);
}
.cs-result-more-group:not([open]) .cs-result-more-caret { transform: rotate(-90deg); }
.cs-result-more-inner {
  margin-top: 6px;
  display: flex; flex-direction: column;
  gap: 6px;
}

/* v6.11 — Pro milestone nudge banner. Inline (in the result bubble),
   not modal. Capped at 3 lifetime appearances (10 / 30 / 100 AI runs)
   and individually dismissable. Soft conversion, not a paywall. */
.cs-pro-nudge {
  display: flex; align-items: center; gap: 10px;
  margin-top: 12px;
  padding: 10px 12px;
  background: linear-gradient(135deg, rgba(255, 126, 179, 0.08), rgba(196, 161, 255, 0.06));
  border: 1px solid rgba(255, 126, 179, 0.25);
  border-radius: 10px;
  font-size: 12.5px;
}
.cs-pro-nudge-mark {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--lavender));
  color: #fff;
  font-size: 14px;
}
.cs-pro-nudge-body { flex: 1; min-width: 0; }
.cs-pro-nudge-title {
  font: 600 13px var(--sans);
  color: var(--text);
}
.cs-pro-nudge-title strong { color: var(--accent-text); }
.cs-pro-nudge-meta {
  margin-top: 2px;
  font: 500 11px var(--mono);
  color: var(--text-muted);
}
.cs-pro-nudge-cta {
  flex-shrink: 0;
  padding: 6px 12px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font: 600 12px var(--sans);
  border-radius: 6px;
  transition: filter .12s;
}
.cs-pro-nudge-cta:hover { filter: brightness(1.05); }
.cs-pro-nudge-close {
  flex-shrink: 0;
  width: 24px; height: 24px;
  border: 0; background: transparent;
  color: var(--text-dim);
  font-size: 16px; line-height: 1;
  border-radius: 5px;
  cursor: pointer;
}
.cs-pro-nudge-close:hover { color: var(--text); background: rgba(0,0,0,0.05); }

/* v6.5 — result satisfaction feedback row. Inline (not modal) so it never
   blocks the user's flow; capped to first ~5 visible runs and dismissable. */
.cs-feedback-row {
  /* v6.8: compact one-line layout. Was 8/10 padding; now 6/8 with smaller
     chips so the row reads as a single quick prompt rather than a
     standalone bordered block competing with the result image. */
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 8px;
  padding: 6px 10px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 12px;
}
.cs-feedback-q {
  color: var(--text-dim);
  font-weight: 500;
  margin-right: 4px;
}
.cs-feedback-btn {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: 500 12px var(--sans);
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .08s;
}
.cs-feedback-btn:hover { border-color: var(--accent); }
.cs-feedback-btn:active { transform: scale(0.96); }
.cs-feedback-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.cs-feedback-yes:hover {
  background: linear-gradient(135deg, rgba(92, 201, 167, 0.12), rgba(92, 201, 167, 0.04));
  border-color: rgba(92, 201, 167, 0.45);
}
.cs-feedback-no:hover {
  background: linear-gradient(135deg, rgba(255, 126, 179, 0.10), rgba(255, 126, 179, 0.04));
  border-color: rgba(255, 126, 179, 0.45);
}
.cs-feedback-dismiss {
  margin-left: auto;
  padding: 2px 8px;
  border: none; background: transparent; cursor: pointer;
  color: var(--text-dim);
  font-size: 18px; line-height: 1;
  border-radius: 4px;
}
.cs-feedback-dismiss:hover { color: var(--text); background: rgba(0,0,0,0.05); }
.cs-feedback-dismiss:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.cs-feedback-thanks {
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
}

/* v6.4 — compare-to-any-step picker. Renders only for multi-step recipes;
   otherwise the slider is straight Source vs After as before. */
.cs-compare-pick {
  display: flex; gap: 6px; flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
  padding: 4px 0;
}
.cs-compare-pick-label {
  font: 600 11px var(--mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-right: 2px;
}
.cs-compare-pick-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font: 500 11.5px var(--sans);
  color: var(--text);
  transition: background .12s, border-color .12s, color .12s;
}
.cs-compare-pick-btn:hover { border-color: var(--accent); }
.cs-compare-pick-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.cs-compare-pick-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Mobile-only: backdrop when drawer open ── */
.cs-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  opacity: 0; pointer-events: none; transition: opacity .2s;
  z-index: 150;
}
.cs-backdrop.show { opacity: 1; pointer-events: auto; }
@media (min-width: 1101px) { .cs-backdrop { display: none; } }

/* (v6.20 — .cs-preset-essay styles extracted to /static/chat/preset-essay.css,
   loaded only on /p/{slug} preset pages, not on the main chat shell.) */

/* ════════════════════════════════════════════════════════════════
   v6.23 — Chip hover preview popover
   ──────────────────────────────────────────────────────────────
   Renders 160×160 result thumbnail above the hovered suggestion
   chip. Lazy-rendered via MochiAnalyzer.getPreviewDataUrl + LRU
   cache. Pointer-events:none so the hover doesn't grab focus.
   ════════════════════════════════════════════════════════════════ */
.cs-chip-preview {
    width: 180px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 12px 36px -8px rgba(45, 27, 20, 0.22), 0 4px 12px rgba(255, 126, 179, 0.18);
    pointer-events: none;
    z-index: 9000;
    animation: csChipPreviewIn 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.cs-chip-preview::after {
    /* tail / arrow */
    content: '';
    position: absolute;
    left: 50%; bottom: -6px;
    transform: translateX(-50%) rotate(45deg);
    width: 12px; height: 12px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
@keyframes csChipPreviewIn {
    from { opacity: 0; transform: translateX(-50%) translateY(6px) scale(0.94); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0)   scale(1); }
}
.cs-chip-preview-img {
    display: block;
    width: 164px; height: 164px;
    object-fit: contain;
    background:
        linear-gradient(45deg, var(--surface-2) 25%, transparent 25%) 0 0/16px 16px,
        linear-gradient(-45deg, var(--surface-2) 25%, transparent 25%) 0 8px/16px 16px,
        linear-gradient(45deg, transparent 75%, var(--surface-2) 75%) 8px -8px/16px 16px,
        linear-gradient(-45deg, transparent 75%, var(--surface-2) 75%) 8px 0/16px 16px,
        var(--surface);
    border-radius: 8px;
}
.cs-chip-preview-shimmer {
    width: 164px; height: 164px;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
    background-size: 200% 100%;
    animation: csChipPreviewShimmer 1.4s ease-in-out infinite;
}
@keyframes csChipPreviewShimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}
.cs-chip-preview-na {
    width: 164px; height: 164px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text-muted);
    font: 500 12px var(--mono);
    text-align: center;
}
.cs-chip-preview-cap {
    margin-top: 6px;
    font: 600 12px var(--sans);
    color: var(--text);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 4px;
}
@media (max-width: 760px) {
    /* v6.31 — mobile shows the same popover via long-press (500 ms touch
       hold). Keep visible but tighten width so it fits 360-px viewports. */
    .cs-chip-preview { width: 160px; }
    .cs-chip-preview-img,
    .cs-chip-preview-shimmer,
    .cs-chip-preview-na { width: 144px; height: 144px; }
}
@media (prefers-reduced-motion: reduce) {
    .cs-chip-preview { animation: none; }
    .cs-chip-preview-shimmer { animation: none; background: var(--surface-2); }
}

/* ════════════════════════════════════════════════════════════════
   v6.27 — "What if?" explorer grid
   ──────────────────────────────────────────────────────────────
   Renders 3-6 actual rendered thumbnails of the dropped image
   passed through different recipes. Replaces the chip row when
   ≥3 non-AI recipes are available and viewport ≥600 px wide.
   ════════════════════════════════════════════════════════════════ */
.cs-explore-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 6px 0 4px;
}
.cs-explore-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    cursor: pointer;
    text-align: center;
    font: inherit;
    color: var(--text);
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.cs-explore-tile:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 126, 179, 0.18);
}
.cs-explore-tile:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.cs-explore-thumb {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    background-color: var(--surface-2);
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-image:
        linear-gradient(45deg, var(--surface-2) 25%, transparent 25%),
        linear-gradient(-45deg, var(--surface-2) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--surface-2) 75%),
        linear-gradient(-45deg, transparent 75%, var(--surface-2) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, 8px 0;
}
.cs-explore-shimmer {
    background-image: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%) !important;
    background-size: 200% 100% !important;
    animation: csExploreShimmer 1.4s ease-in-out infinite;
}
@keyframes csExploreShimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}
.cs-explore-cap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font: 600 12px var(--sans);
    color: var(--text);
    line-height: 1.2;
}
.cs-explore-emoji { font-size: 14px; line-height: 1; }
.cs-explore-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
@media (max-width: 760px) {
    .cs-explore-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
    .cs-explore-tile { transition: none; }
    .cs-explore-shimmer { animation: none; }
}

/* v6.28 — Image quality issue hints */
.cs-quality-hint {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin: 6px 0;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left: 3px solid #FFB088;
    border-radius: 8px;
    font: 500 13.5px var(--sans);
    color: var(--text);
}
.cs-quality-icon { font-size: 16px; flex-shrink: 0; }
.cs-quality-text { flex: 1; line-height: 1.4; }
.cs-quality-cta {
    flex-shrink: 0;
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 6px;
    white-space: nowrap;
}
@media (max-width: 480px) {
    .cs-quality-hint { flex-wrap: wrap; }
    .cs-quality-cta { width: 100%; }
}
