:root {
  --bg: #0c0c0c;
  --fg: #f4f1ea;
  --muted: #8a847a;
  --accent: #d24c2e;
  --card: #161513;
  --line: #2a2823;
  --good: #6dbf73;
  --warn: #d9a441;
  --bad: #d24c2e;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  /* prevent rubber-band overscroll showing the page background through the chrome */
  overscroll-behavior-y: contain;
}

body {
  /* iOS Safari pull-to-refresh interferes with our swipe gestures */
  touch-action: pan-y;
}

main#app {
  max-width: 720px;
  margin: 0 auto;
  padding:
    max(env(safe-area-inset-top), 16px)
    max(env(safe-area-inset-right), 16px)
    max(env(safe-area-inset-bottom), 16px)
    max(env(safe-area-inset-left), 16px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.topbar h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0;
}

.status-pill {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
}

.status-pill.ok { color: var(--good); border-color: var(--good); }
.status-pill.warn { color: var(--warn); border-color: var(--warn); }
.status-pill.bad { color: var(--bad); border-color: var(--bad); }

#login-pane form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 320px;
  margin: 64px auto 0;
}

#login-pane label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

#login-pane input[type="password"] {
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 18px;
  letter-spacing: 0.4em;
  text-align: center;
}

#login-pane input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
}

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  /* iOS Safari: stop double-tap zoom delay on form controls */
  -webkit-appearance: none;
  appearance: none;
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

button:disabled { opacity: 0.6; cursor: not-allowed; }

a, [role="button"], .tab-btn, .live-unpublish, .rewrite-btn,
.carousel-regenerate, .swipe-undo-btn {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* iOS Safari renders form inputs at 16px+ to prevent zoom on focus.
   Anything smaller triggers an auto-zoom. */
input, textarea, [contenteditable] {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

.error {
  color: var(--bad);
  font-size: 14px;
  margin: 0;
  text-align: center;
}

.queue-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}

.tabbar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 12px 16px;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 6px;
  cursor: pointer;
  min-height: 44px;
}

.tab-btn:hover { color: var(--fg); }
.tab-btn.active {
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--line);
}

.tabbar #logout-btn { margin-left: auto; }

#live-list { display: flex; flex-direction: column; gap: 10px; }

.live-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}

.live-actions button {
  padding: 11px 14px;
  font-size: 12px;
  min-height: 44px;
}

.live-card .card-photo.no-photo {
  font-size: 26px;
  opacity: 0.4;
}

/* Photo carousel — horizontal scroll-snap, dots indicator, full-width slots. */
.photo-carousel {
  margin: 16px -16px;
  position: relative;
}
.carousel-track {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  outline: none;
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-slot {
  flex: 0 0 100%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-sizing: border-box;
}
.carousel-image {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #1f1d1a;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.carousel-slot img,
.carousel-image img {
  aspect-ratio: 16 / 9;
  object-fit: cover;
  width: 100%;
  height: 100%;
  display: block;
}
.carousel-slot.status-skipped .carousel-image,
.carousel-slot.status-error .carousel-image {
  border-style: dashed;
  background: transparent;
}
.carousel-placeholder {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.6;
  text-align: center;
  padding: 0 16px;
  /* Q4 — explicitly defeat any browser default that would render a glyph
     (broken-image "?") on top of the placeholder text. */
  background: transparent;
}
.carousel-slot.kind-owner_library .carousel-placeholder {
  /* Owner-library slots always speak in editorial language even when empty. */
  letter-spacing: 0.04em;
  font-style: italic;
}

/* U3 — Gradient cover slot (slot 8). Client-rendered: no <img>, just a
   linear-gradient on the .carousel-image container with a centered headline.
   Defeats the dashed-border treatment that .status-skipped applies to other
   placeholder slots since this slot ALWAYS has content. */
.carousel-slot.kind-gradient_card .carousel-image {
  border: 1px solid var(--line);
  background: #1f1d1a;
}
.carousel-image.gradient-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 22px;
  text-align: center;
}
.carousel-image.gradient-card::after {
  /* Subtle vignette so the title pops on lighter palette stops. */
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 120% at 50% 100%, rgba(0,0,0,0) 35%, rgba(0,0,0,0.35) 100%);
  pointer-events: none;
}
.gradient-card-title {
  position: relative;
  z-index: 1;
  margin: 0;
  color: #fff;
  font-size: clamp(20px, 4.2vw, 30px);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-wrap: balance;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
  word-break: break-word;
}
.carousel-regenerate {
  position: absolute;
  bottom: 10px;
  right: 10px;
  padding: 8px 14px;
  background: rgba(12, 12, 12, 0.78);
  color: var(--fg);
  border: 1px solid rgba(210, 76, 46, 0.7);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  min-height: 36px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  z-index: 2;
}
.carousel-regenerate:hover { background: rgba(210, 76, 46, 0.18); }
.carousel-regenerate:disabled { opacity: 0.7; cursor: wait; }

/* Wave 3: slot 10 (custom_upload) — empty-state upload button + Replace
   overlay. Mirrors the .carousel-regenerate position/sizing so AI and
   upload affordances feel consistent. */
.carousel-image.carousel-upload-empty {
  display: flex;
  align-items: center;
  justify-content: center;
}
.carousel-upload-add {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 22px;
  background: rgba(12, 12, 12, 0.55);
  color: var(--fg);
  border: 1px dashed rgba(210, 76, 46, 0.7);
  border-radius: 10px;
  cursor: pointer;
  min-height: 88px;
  min-width: 200px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.carousel-upload-plus {
  font-size: 28px;
  line-height: 1;
  font-weight: 300;
  color: var(--accent);
}
.carousel-upload-cta {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
}
.carousel-upload-add:disabled {
  opacity: 0.7;
  cursor: wait;
}
/* Wave 3.5: position Replace button as an overlay in the bottom-right of
   the photo, mirroring .carousel-regenerate. -webkit-tap-highlight-color
   suppresses the iOS Safari grey flash on tap. */
.carousel-upload-replace {
  position: absolute;
  bottom: 10px;
  right: 10px;
  padding: 8px 14px;
  background: rgba(12, 12, 12, 0.78);
  color: var(--fg);
  border: 1px solid rgba(210, 76, 46, 0.7);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  min-height: 36px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  z-index: 2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.carousel-upload-replace:hover { background: rgba(210, 76, 46, 0.18); }
.carousel-upload-replace:disabled { opacity: 0.7; cursor: wait; }

.carousel-caption {
  font-size: 12.5px;
  color: var(--muted);
  padding: 0 4px;
  line-height: 1.4;
}
.carousel-label {
  color: var(--fg);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.carousel-credit {
  font-size: 12px;
  color: var(--fg);
  margin-top: 4px;
  word-break: break-word;
}
.carousel-credit a { color: var(--accent); text-decoration: none; }
.carousel-credit a:hover { text-decoration: underline; }
.carousel-notes {
  font-size: 11.5px;
  margin-top: 4px;
  font-style: italic;
  color: var(--muted);
  word-break: break-word;
}

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 12px 0 4px;
  padding: 0 16px;
}
.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: var(--line);
  padding: 0;
  cursor: pointer;
  min-height: 0;
  transition: background 120ms ease, transform 120ms ease;
  -webkit-tap-highlight-color: transparent;
}
.carousel-dot.active {
  background: var(--accent);
  transform: scale(1.3);
}

/* Custom regenerate prompt modal — single-click cancel and backdrop close. */
.regen-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1300;
  padding: 16px;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.regen-modal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}
.regen-modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
}
.regen-modal-sub {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.regen-modal-input {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  font-size: 16px;
  font-family: inherit;
  resize: vertical;
  width: 100%;
  min-height: 96px;
  outline: none;
}
.regen-modal-input:focus { border-color: var(--accent); }
.regen-modal-input.error { border-color: var(--bad); }
.regen-modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.regen-modal-actions button { padding: 10px 16px; font-size: 13px; }

#queue-list { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 12px;
  padding: 10px;
  align-items: stretch;
  transition: border-color 120ms ease;
}

.card:active { border-color: var(--muted); }
.card.spotlight { border-color: var(--accent); }
.card.spotlight .card-photo { box-shadow: inset 0 0 0 2px var(--accent); }

.card-photo {
  width: 84px;
  height: 84px;
  border-radius: 8px;
  overflow: hidden;
  background: #1f1d1a;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-photo.no-photo {
  color: var(--muted);
  font-size: 22px;
  opacity: 0.5;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.card-meta .writer { color: var(--fg); font-weight: 600; }
.card-meta .cat { color: var(--muted); }
.card-meta .total {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}
.card-meta .star { color: var(--accent); margin-left: 2px; }
/* Wave 2: small inline badge when the routine flagged unsupported claims. */
.card-meta .fc-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
  padding: 1px 6px;
  border: 1px solid #d93025;
  background: #fdecea;
  color: #5b1a14;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  cursor: help;
}
/* Bug F: orange-outlined cards now carry an italic "Spotlight" label
   so the visual treatment is self-explanatory. Tooltip on hover/tap
   carries the longer copy. */
.card-meta .spotlight-label {
  color: var(--accent);
  font-style: italic;
  font-size: 11px;
  letter-spacing: 0.04em;
  margin-left: 4px;
  text-transform: uppercase;
  cursor: help;
}

.card-title {
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.32;
  margin: 2px 0;
  color: var(--fg);
  overflow-wrap: break-word;
}

.card-scores {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.card-scores .chip {
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 5px 2px 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.card-scores .chip b {
  font-weight: 600;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}

.card-rationale {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--muted);
  margin: 4px 0 0;
  font-style: italic;
}

.muted { color: var(--muted); font-size: 12px; }

@media (max-width: 380px) {
  .card { grid-template-columns: 64px 1fr; gap: 10px; }
  .card-photo { width: 64px; height: 64px; }
  .card-title { font-size: 14.5px; }
}

/* Inline AI rewrite — Day 8 */
.rewrite-toolbar {
  position: absolute;
  display: flex;
  gap: 0;
  background: #1a1816;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  z-index: 1000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}

.rewrite-btn {
  background: transparent;
  border: none;
  color: var(--fg);
  padding: 12px 14px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  min-height: 44px;
}

.rewrite-btn + .rewrite-btn { margin-left: 2px; }
.rewrite-btn:hover { background: var(--line); }
.rewrite-btn:disabled { opacity: 0.5; cursor: wait; }

.rewrite-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 16px;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.rewrite-modal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: 100%;
  max-width: 720px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rewrite-modal header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.rewrite-modal-title { font-size: 14px; font-weight: 600; }
.rewrite-modal-meta { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; }

.rewrite-modal-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  overflow: auto;
  flex: 1;
}

.rewrite-pane {
  padding: 14px 16px;
  overflow: auto;
}

.rewrite-pane + .rewrite-pane { border-left: 1px solid var(--line); }
.rewrite-pane h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 8px;
}

.rewrite-original, .rewrite-rewritten {
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.rewrite-rewritten { color: var(--fg); }

.rewrite-modal footer {
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.rewrite-modal footer button {
  padding: 8px 16px;
  font-size: 13px;
}

@media (max-width: 600px) {
  .rewrite-modal-body { grid-template-columns: 1fr; }
  .rewrite-pane + .rewrite-pane { border-left: none; border-top: 1px solid var(--line); }
}

/* Day 7 — swipe + undo + detail view */

.card.swipeable {
  user-select: none;
  -webkit-user-select: none;
  /* allow vertical scroll, our handler claims horizontal once locked */
  touch-action: pan-y;
  will-change: transform, opacity;
}
.card.swiping { transition: none; }
.card.swipe-right {
  border-color: var(--good);
  box-shadow: 0 0 0 2px var(--good) inset;
}
.card.swipe-left {
  border-color: var(--bad);
  box-shadow: 0 0 0 2px var(--bad) inset;
}

.undo-banner {
  position: fixed;
  left: 50%;
  bottom: max(env(safe-area-inset-bottom), 16px);
  transform: translateX(-50%) translateY(120%);
  background: #1a1816;
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 8px 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  z-index: 1200;
  transition: transform 200ms ease;
  max-width: calc(100vw - 32px);
}
.undo-banner.visible {
  transform: translateX(-50%) translateY(0);
}
.undo-banner .undo-text {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60vw;
}
.undo-banner .undo-btn {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  min-height: 36px;
  flex-shrink: 0;
}

/* 5-second undo countdown — width shrinks 100% → 0% via CSS keyframe.
   queue.v6.js restarts the animation each time the banner appears by
   nulling the inline `animation` then re-assigning it (force-reflow trick). */
.undo-banner {
  /* slot for the progress bar tucked under the rounded-pill border */
  padding-bottom: 14px;
}
.undo-banner .undo-progress {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 5px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
  transform-origin: left center;
  pointer-events: none;
  opacity: 0.85;
}
@keyframes undo-progress-shrink {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

#detail-pane {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: max(env(safe-area-inset-bottom), 24px);
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

#detail-back {
  padding: 8px 14px;
  font-size: 14px;
  min-height: 44px;
}

/* Autosave indicator: pinned top-right (owner preference, U2). Sits
   *below* the standard iOS status bar via safe-area-inset-top, *above*
   the back button row in the detail header. Hidden when empty. */
.detail-savestate {
  position: fixed;
  right: max(env(safe-area-inset-right), 16px);
  top: calc(max(env(safe-area-inset-top), 12px) + 12px);
  z-index: 1000;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: rgba(12, 12, 12, 0.86);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  pointer-events: none;
  transition: opacity 200ms ease;
}
.detail-savestate:empty { opacity: 0; visibility: hidden; }
.detail-savestate.ok { color: var(--good); border-color: var(--good); }
.detail-savestate.bad { color: var(--bad); border-color: var(--bad); }

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.detail-meta .writer { color: var(--fg); font-weight: 600; }
.detail-meta .total { font-variant-numeric: tabular-nums; color: var(--fg); }

.detail-title {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  margin: 0;
  color: var(--fg);
  outline: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  margin-left: -6px;
  margin-right: -6px;
}
.detail-title:focus { border-color: var(--line); background: rgba(255,255,255,0.02); }

.detail-excerpt {
  font-size: 15.5px;
  line-height: 1.45;
  color: var(--muted);
  font-style: italic;
  margin: 0;
  outline: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  margin-left: -6px;
  margin-right: -6px;
}
.detail-excerpt:focus { border-color: var(--line); background: rgba(255,255,255,0.02); }

.detail-body {
  font-size: 17px;
  line-height: 1.65;
  color: var(--fg);
  outline: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 10px;
  margin-left: -10px;
  margin-right: -10px;
  min-height: 200px;
  /* iOS Safari needs an explicit caret color on dark contenteditable */
  caret-color: var(--accent);
}
.detail-body:focus { border-color: var(--line); background: rgba(255,255,255,0.02); }
.detail-body p { margin: 0 0 1em; }
.detail-body p:last-child { margin-bottom: 0; }

.detail-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.detail-actions button { flex: 1; }
#detail-kill {
  color: var(--bad);
  border-color: rgba(210, 76, 46, 0.5);
}
#detail-approve { background: var(--good); }

/* Wave 3.9.3: explicit "Use this photo" selector. Every selectable slot
   shows a button. The currently-chosen slot replaces the button with a
   "✓ Currently chosen" badge in the same spot — the button OR the badge,
   never both, so the editor's mental model is unambiguous. The slot also
   gets a green outline so the chosen one stands out from the carousel. */
.carousel-slot.slot-chosen {
  outline: 3px solid #4caf50;
  outline-offset: -3px;
  border-radius: 6px;
  position: relative;
}
.carousel-select {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 12px;
  background: #1f5fbf;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.carousel-select:hover { background: #143f80; }
.carousel-select:disabled { opacity: 0.6; cursor: default; }
.carousel-chosen-badge {
  display: none;
  margin-top: 6px;
  padding: 6px 12px;
  background: #4caf50;
  color: #fff;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.carousel-slot.slot-chosen .carousel-select { display: none; }
.carousel-slot.slot-chosen .carousel-chosen-badge { display: inline-block; }

/* Wave 4 — New tab form */
.new-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  max-width: 560px;
  margin: 0 auto;
}
.new-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.new-label {
  font-weight: 600;
  font-size: 0.95rem;
}
.new-field input[type="url"], .new-field select {
  font-size: 16px;
  padding: 0.6rem 0.7rem;
  border: 1px solid #cdd2d8;
  border-radius: 6px;
  background: white;
}
.new-model {
  border: none;
  padding: 0;
  margin: 0;
}
.new-model label {
  display: block;
  padding: 0.4rem 0;
  font-size: 0.95rem;
}
.new-cost {
  font-size: 0.9rem;
  color: #4a4a4a;
  margin: 0.25rem 0;
}
.new-status {
  font-size: 0.95rem;
  margin: 0.5rem 0 0 0;
  min-height: 1.2em;
}
.new-status.error { color: #b00020; }
.new-status.busy::after {
  content: "";
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  margin-left: 0.4rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: new-spin 0.8s linear infinite;
  vertical-align: middle;
}
@keyframes new-spin {
  to { transform: rotate(360deg); }
}
#new-generate {
  align-self: flex-start;
  padding: 0.65rem 1.2rem;
  font-weight: 600;
}

/* Wave 5.4 — single New-tab form (mode toggle removed). Class names
   dropped the "-context-" segment because the form is no longer a
   context-only sub-mode. */
.new-optional { font-weight: 400; color: #6b6b6b; font-size: 0.85rem; }
.new-hint {
  font-size: 0.85rem;
  color: #6b6b6b;
  margin: 0.25rem 0;
}
.new-image-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-top: 0.5rem;
}
@media (max-width: 380px) {
  .new-image-grid { grid-template-columns: repeat(3, 1fr); }
}
.new-image-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  background: #eee;
}
.new-image-tile img {
  width: 100%; height: 100%; object-fit: cover;
}
.new-image-tile-remove {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%; background: rgba(0,0,0,0.7); color: white;
  font-size: 14px; line-height: 22px; text-align: center;
  border: none; cursor: pointer;
}
.new-image-tile-meta {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 2px 4px;
  background: rgba(0,0,0,0.6); color: white;
  font-size: 10px; line-height: 1.2;
  text-align: center;
}
textarea[name="instructions"] {
  font-size: 16px; padding: 0.6rem 0.7rem;
  border: 1px solid #cdd2d8; border-radius: 6px; background: white;
  font-family: inherit; resize: vertical;
}

/* Wave 5.5 — multi-URL list widget */
.new-urls-list { display: flex; flex-direction: column; gap: 0.4rem; }
.new-url-row { display: flex; gap: 0.4rem; align-items: center; }
.new-url-row input[type="url"] {
  flex: 1;
  font-size: 16px; padding: 0.6rem 0.7rem;
  border: 1px solid #cdd2d8; border-radius: 6px; background: white;
}
.new-url-remove {
  width: 28px; height: 28px; border-radius: 50%;
  background: #f4f4f4; border: 1px solid #cdd2d8; color: #6b6b6b;
  font-size: 16px; line-height: 1; cursor: pointer;
}
.new-add-url-btn {
  align-self: flex-start;
  padding: 0.4rem 0.7rem;
  background: transparent; border: 1px dashed #cdd2d8; color: #4a4a4a;
  font: inherit; font-size: 0.9rem; border-radius: 6px;
  cursor: pointer; margin-top: 0.4rem;
}
.new-add-url-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ----- Wave 8: Ideas tab ----- */
.ideas-header {
  display: flex; flex-direction: column; gap: 0.4rem;
  padding: 0.8rem 0.9rem 0.4rem;
}
.ideas-header h2 {
  font-size: 1.1rem; margin: 0; color: var(--fg);
}
.ideas-meta {
  margin: 0; color: var(--muted); font-size: 0.85rem;
}
.ideas-header .btn-primary { align-self: flex-start; margin-top: 0.3rem; }

.ideas-list {
  display: flex; flex-direction: column; gap: 0.7rem;
  padding: 0.4rem 0.9rem 1.2rem;
}

.idea-card {
  background: var(--card);
  border: 1px solid #2a2724; border-radius: 10px;
  padding: 0.85rem 0.95rem;
  display: flex; flex-direction: column; gap: 0.45rem;
  color: var(--fg);
}
.idea-card[hidden] { display: none; }
.idea-headline {
  margin: 0;
  font-size: 1.05rem; line-height: 1.3; font-weight: 700;
  color: var(--fg);
}
.idea-why {
  margin: 0; color: var(--fg);
  font-size: 0.92rem; line-height: 1.45; opacity: 0.85;
}
.idea-meta {
  margin: 0; font-size: 0.85rem; color: var(--muted);
}
.idea-meta b { color: var(--fg); font-weight: 600; }
.idea-leads-label {
  margin: 0.2rem 0 0; font-size: 0.85rem; color: var(--muted);
  font-weight: 600;
}
.idea-leads {
  margin: 0; padding-left: 1.1rem;
  font-size: 0.9rem; line-height: 1.45;
  color: var(--fg);
}
.idea-leads li { margin: 0.1rem 0; }
.idea-cost {
  margin: 0.2rem 0 0; font-size: 0.8rem; color: var(--muted);
}
.idea-actions {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin-top: 0.4rem;
}
.idea-actions .btn-primary,
.idea-actions .ghost {
  font-size: 0.9rem; padding: 0.45rem 0.8rem;
}
.idea-status { margin: 0.3rem 0 0; font-size: 0.85rem; color: var(--muted); }
.idea-status.busy { color: var(--accent); }
.idea-status.error { color: #c73a3a; }

.idea-brief-pane {
  margin-top: 0.6rem; padding: 0.7rem 0.9rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid #2a2724; border-radius: 8px;
  font-size: 0.92rem; line-height: 1.5; color: var(--fg);
}
.idea-brief-pane[hidden] { display: none; }
.idea-brief-pane h4 {
  margin: 0.7rem 0 0.25rem; font-size: 0.95rem; font-weight: 700;
  color: var(--fg);
}
.idea-brief-pane h4:first-child { margin-top: 0; }
.idea-brief-pane p { margin: 0.25rem 0; }
.idea-brief-pane ul { margin: 0.2rem 0 0.4rem 1.1rem; padding: 0; }
.idea-brief-pane li { margin: 0.1rem 0; }

.ideas-form {
  display: flex; flex-direction: column; gap: 0.6rem;
  padding: 0.6rem 0.9rem 1rem;
  background: rgba(255,255,255,0.02);
  border-top: 1px solid #2a2724;
}
.ideas-form select {
  font-size: 16px; padding: 0.5rem 0.6rem;
  border: 1px solid #cdd2d8; border-radius: 6px; background: white;
  color: #1a1a1a;
}
.ideas-status { margin: 0.3rem 0 0; font-size: 0.85rem; color: var(--muted); }
.ideas-status.busy { color: var(--accent); }
.ideas-status.error { color: #c73a3a; }

/* Wave 8.2 — brief CTA bar + hidden-recovery affordance */
.idea-brief-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #cdd2d8;
}
.idea-brief-cta .btn-primary,
.idea-brief-cta .ghost {
  flex: 1;
  min-width: 140px;
  padding: 10px 12px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  text-align: center;
}
.idea-brief-cta .btn-primary {
  background: #1f4a7a;
  color: white;
  border: 1px solid #1f4a7a;
  font-weight: 600;
}
.idea-brief-cta .ghost {
  background: #f4f4f4;
  color: #2a2a2a;
  border: 1px solid #cdd2d8;
}
.ideas-hidden-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  margin: 12px 0 0;
  background: #f7f7f7;
  border: 1px dashed #cdd2d8;
  border-radius: 6px;
  font-size: 13px;
  color: #6a6a6a;
}
.ideas-hidden-bar .ghost {
  background: transparent;
  border: 1px solid #cdd2d8;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: #2a2a2a;
}

/* ----- Wave 8.3: generated-from-idea indicator ----- */
.idea-generated-tag {
  margin: 0.1rem 0 0.3rem;
  font-size: 0.82rem;
  color: var(--accent, #c98e21);
  font-weight: 600;
}
.idea-generated-tag code {
  background: rgba(255,255,255,0.08);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  font-size: 0.78rem;
  color: var(--fg);
}
