/* Board · create mode, page status, reordering. */

/* Queue explanation under the progress bars (create mode). */
.queue-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin: 2px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-2);
}
.queue-line .mini-spin {
  width: 10px;
  height: 10px;
}
.queue-line.tone-warn {
  color: var(--warn);
}
.queue-line.tone-warn .icon {
  flex: none;
}
.queue-line .link-btn {
  font-size: 12.5px;
}

/* Page cards: compact status words and the per-page actions menu. */
.page-foot .chips-row {
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}
.page-foot .stage-chip.has-word {
  gap: 4px;
  font-size: 11px;
}
.page-more {
  flex: none;
  margin: -4px -4px -4px 0;
  opacity: 0.6;
}
.page-more:hover,
.page-more:focus-visible,
.page-more[aria-expanded="true"],
.page-card:hover .page-more {
  opacity: 1;
}
@media (hover: none) {
  .page-more {
    opacity: 1;
  }
}

/* Settings save failure stays visible until retried. */
.save-state .save-failed {
  color: var(--danger);
  font-weight: 600;
}
.save-state .link-btn {
  font-size: 12px;
}

/* Jobs waiting for credits (hosted mode). */
.stage-chip.is-blocked {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
}

/* Library: browser-storage notice, usage and backup actions. */
.storage-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 0 0 14px;
  padding: 8px 10px 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--text-2);
}
.storage-bar > .icon {
  color: var(--ok);
  flex: none;
}
.storage-bar strong {
  color: var(--text);
  font-weight: 600;
}
.storage-usage {
  color: var(--text-3);
}
.storage-bar .spacer {
  flex: 1;
}
@media (max-width: 640px) {
  .storage-bar .spacer {
    display: none;
  }
  .storage-bar .btn {
    flex: 1 1 auto;
  }
}

/* ───── Library: first run, skeletons, errors, cards ───── */
.section-head {
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.section-count {
  color: var(--text-3);
  font-weight: 500;
}
.section-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
/* Once projects exist the hero shrinks to a slim header so projects are above the fold. */
.hero.is-compact {
  padding-top: 20px;
  padding-bottom: 20px;
}
.hero.is-compact .hero-steps,
.hero.is-compact .lede,
.hero.is-compact .hero-actions {
  display: none;
}
.hero.is-compact h1 {
  font-size: clamp(22px, 3vw, 30px);
  margin-bottom: 0;
}
.storage-bar.is-due {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--line));
  background: color-mix(in srgb, var(--warn) 7%, var(--surface));
}
.storage-nudge {
  color: var(--warn);
  font-weight: 600;
}
.project-grid.is-empty {
  display: block;
}
.first-run {
  display: grid;
  gap: 12px;
}
.first-run-paths {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.path-card {
  display: grid;
  justify-items: start;
  gap: 6px;
  padding: 20px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition:
    border-color var(--t) var(--ease),
    box-shadow var(--t) var(--ease-out),
    transform var(--t) var(--ease-out);
}
.path-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.path-card:active {
  transform: none;
  box-shadow: var(--shadow-sm);
}
.path-card:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.path-card strong {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.path-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 4px;
  transition: background-color var(--t) var(--ease), color var(--t) var(--ease), transform var(--t) var(--ease-out);
}
.path-card:nth-child(3n + 2) .path-icon {
  background: var(--accent-2-soft);
  color: var(--accent-2);
}
.path-card:nth-child(3n + 3) .path-icon {
  background: var(--accent-3-soft);
  color: var(--warn);
}
.path-card:hover .path-icon {
  transform: scale(1.06);
}
.path-go {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
}
.first-run-note {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  margin: 0;
  font-size: 12.5px;
  color: var(--text-2);
}
.first-run-note > .icon {
  color: var(--ok);
  flex: none;
}
.first-run-note.tone-warn,
.first-run-note.tone-warn > .icon {
  color: var(--warn);
}
.library-error {
  display: grid;
  justify-items: start;
  gap: 8px;
  padding: 20px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line));
  border-radius: var(--radius-lg);
  background: var(--danger-soft);
  max-width: 640px;
}
.library-error > .icon {
  color: var(--danger);
}
.library-error h3 {
  font-size: 15px;
}
.library-error p {
  margin: 0;
  color: var(--text-2);
  font-size: 13px;
}
.project-card.skeleton {
  pointer-events: none;
}
.project-card.skeleton .cover {
  border-bottom-color: transparent;
}
.project-card.skeleton .card-body span {
  display: block;
  height: 10px;
  border-radius: 0;
  background: var(--surface-2);
}
.project-card.skeleton .cover {
  background: var(--surface-2);
}
.project-card.skeleton .card-body span:nth-child(1) {
  width: 70%;
  height: 12px;
}
.project-card.skeleton .card-body span:nth-child(2) {
  width: 45%;
  margin-top: 6px;
}
.project-card.skeleton .card-body span:nth-child(3) {
  width: 90%;
  height: 4px;
  margin-top: 10px;
}
.project-card.skeleton .cover,
.project-card.skeleton .card-body span {
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}
@keyframes skeleton-pulse {
  50% {
    opacity: 0.55;
  }
}
/* Cards: the cover carries the type badge; titles get two lines. */
.cover .type-badge.on-cover {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}
.cover-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-3);
}
.project-card .card-title {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
}
.project-card .card-body {
  gap: 4px;
}
.project-card .meter-label.muted {
  margin-top: 6px;
}
.project-card:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.card-more {
  top: 8px;
  right: 8px;
  bottom: auto;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

/* ───── Board ───── */
.settings-jump {
  display: none;
}
@media (max-width: 960px) {
  .settings-jump {
    display: inline-flex;
  }
}
/* Selection checkbox: light chip instead of a heavy dark square on white pages. */
.page-select {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}
/* Card footer: number, status chips, actions; created pages show their direction below. */
.page-foot {
  min-height: 36px;
}
.page-foot .chips-row {
  margin-left: auto;
  flex-wrap: nowrap;
}
.page-card.is-create .page-name {
  display: none;
}
.page-card .page-prompt {
  /* Margin, not padding: overflow clips at the padding box, which would show a third line. */
  margin: 0 8px 9px;
  padding: 0;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  max-height: calc(2 * 1.4em);
  overflow: hidden;
}
.page-card .page-prompt[hidden] {
  display: none;
}
.page-card .thumb:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}
/* Composer is the primary action in create mode. */
.composer-slot {
  margin-top: 4px;
}
/* Progress rows: keep the count beside the bar on phones too. */
@media (max-width: 640px) {
  .pb-row {
    grid-template-columns: 82px minmax(0, 1fr) auto;
  }
  .pb-count {
    grid-column: auto;
    font-size: 11.5px;
  }
  .pb-count em {
    display: none;
  }
  .board-actions {
    flex-wrap: wrap;
  }
  .section-actions {
    width: 100%;
  }
  .section-actions .btn {
    flex: 1 1 auto;
  }
}

.first-run-note {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
}
.first-run-note > .icon {
  margin-top: 2px;
}
.first-run-note > :not(.icon) {
  grid-column: 2;
}
@media (max-width: 640px) {
  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .project-card .card-body {
    padding: 8px 10px 10px;
  }
  /* The feature list repeats what the first-run cards say; keep phones short. */
  .view-library .hero-steps {
    display: none;
  }
  .path-card {
    padding: 16px;
  }
}

/* ───── URL import: dialog ───── */
.import-dialog .import-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: inherit;
  flex: 1;
}
.import-dialog .dialog-body {
  flex: 1;
  min-height: 0;
}
.imp-foot {
  margin: 0;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.imp-detect {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--accent-2-line);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  background: var(--accent-2-soft);
  font-size: 12.5px;
}
.imp-detect > span {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.imp-detect code {
  font-family: var(--font-mono);
  color: var(--text-2);
}
.imp-detect mark {
  padding: 0 2px;
  border-radius: var(--radius-sm);
  background: var(--accent-3);
  color: var(--on-accent-3);
  font-family: var(--font-mono);
}
.imp-preview {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
  font-size: 12px;
}
.imp-preview:empty {
  display: none;
}
.imp-preview li {
  display: flex;
  gap: 8px;
  min-width: 0;
}
.imp-preview .imp-gap {
  color: var(--text-3);
  padding-left: 4px;
}
.imp-n {
  flex: none;
  min-width: 3.2em;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.imp-url {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  color: var(--text-2);
}
.imp-error {
  margin: 0;
  color: var(--danger);
  font-size: 12.5px;
  font-weight: 550;
}
.imp-fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  min-width: 0;
}
.imp-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px;
}
.imp-choice {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.imp-choice:hover {
  border-color: var(--text-3);
}
.imp-choice:has(input:checked) {
  border-color: var(--accent-2);
  background: var(--accent-2-soft);
}
.imp-choice:focus-within {
  box-shadow: 0 0 0 3px var(--accent-2-soft);
}
.imp-choice input {
  margin-top: 3px;
  accent-color: var(--accent-2);
}
.imp-choice > span {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.imp-choice strong {
  font-size: 13px;
}
.imp-choice small {
  color: var(--text-3);
  font-size: 11.5px;
  line-height: 1.35;
}
.imp-into {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 0;
}
.imp-advanced {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: grid;
  gap: 12px;
}
.imp-advanced[open] {
  padding-bottom: 12px;
}
.imp-advanced summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.imp-rights {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 0;
  color: var(--text-3);
  font-size: 12px;
}
.hero-more {
  color: var(--text-3);
}

/* ───── URL import: progress dock ───── */
.import-dock {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 40;
  width: min(380px, calc(100vw - 32px));
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop-in var(--t-slow) var(--ease-out);
}
.imp-dock-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px 4px 4px;
  border-bottom: 1px solid var(--line);
}
.imp-dock-toggle {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.imp-dock-toggle:hover {
  background: var(--tone);
}
.imp-dock-toggle:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}
.imp-dock-count {
  margin-left: auto;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.imp-chevron {
  transform: rotate(180deg);
  transition: transform 0.15s var(--ease);
}
.imp-chevron.open {
  transform: none;
}
.imp-dock-body {
  display: grid;
  gap: 8px;
  padding: 10px 12px 12px;
  overflow-y: auto;
  min-height: 0;
}
.imp-dock-body[hidden] {
  display: none;
}
.imp-template {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.imp-bar {
  height: 6px;
  border-radius: 0;
  background: var(--tone);
  overflow: hidden;
}
.imp-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent-2);
  transition: width 0.3s var(--ease);
}
.import-dock[data-state="done"] .imp-bar > span {
  background: var(--ok);
}
.imp-stats {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-2);
}
.imp-reason {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  margin: 0;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--text);
  font-size: 12.5px;
}
.imp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.imp-actions:empty {
  display: none;
}
.imp-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}
.imp-rows:empty {
  display: none;
}
.imp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.imp-row:hover {
  background: var(--tone);
}
.imp-row-main {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.imp-row-main a {
  color: var(--text);
}
.imp-chip {
  flex: none;
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  background: var(--tone);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
}
.imp-row.s-done .imp-chip {
  color: var(--ok);
}
.imp-row.s-fetching .imp-chip,
.imp-row.s-downloaded .imp-chip {
  color: var(--accent-2);
}
.imp-row.s-error .imp-chip,
.imp-row.s-empty .imp-chip,
.imp-row.s-missing .imp-chip {
  color: var(--danger);
  background: var(--danger-soft);
}
.imp-dock-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.imp-dock-foot:empty {
  display: none;
}
.imp-more {
  font-size: 12px;
}
@media (max-width: 640px) {
  .import-dock {
    right: 8px;
    left: 8px;
    bottom: 8px;
    width: auto;
    max-height: 60vh;
  }
}
@media (prefers-reduced-motion: reduce) {
  .imp-bar > span,
  .imp-chevron {
    transition: none;
  }
}
.imp-msg {
  color: var(--text-2);
}

/* Merge projects dialog */
.merge-form { display: flex; flex-direction: column; min-height: 0; max-height: inherit; }
.merge-form .dialog-body { min-height: 0; }
.merge-list { list-style: none; margin: 0; padding: 0; max-height: min(46vh, 420px); overflow-y: auto;
  border: 1px solid var(--line); border-radius: var(--radius-sm); }
.merge-list li + li { border-top: 1px solid var(--line); }
.merge-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; }
.merge-row:hover { background: var(--tone); }
.merge-row input { flex: none; }
.merge-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.merge-row small { color: var(--text-3); flex: none; }

/* ───── Watermark settings ───── */
.wm-section summary { display: flex; align-items: center; gap: 8px; }
.wm-badge { margin-left: auto; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: var(--radius-sm);
  background: var(--tone); color: var(--text-3); }
.wm-badge.on { background: var(--accent-2-soft); color: var(--accent-2); }
.wm-body { display: grid; gap: 14px; margin-top: 10px; }
.wm-body.is-off > :not(.wm-figure):not(.wm-defaults) { opacity: 0.55; }
.wm-logo-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wm-logo-thumb { width: 44px; height: 44px; object-fit: contain; border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: repeating-conic-gradient(var(--tone) 0% 25%, transparent 0% 50%) 50% / 12px 12px; }
.wm-positions { display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: 6px; align-items: stretch; max-width: 280px; }
.wm-pos { position: relative; display: grid; place-items: center; min-height: 34px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--surface); cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease); }
.wm-pos:hover { border-color: var(--text-3); }
.wm-pos input { position: absolute; opacity: 0; pointer-events: none; }
.wm-pos:has(input:checked) { border-color: var(--accent-2); background: var(--accent-2-soft); }
.wm-pos:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.wm-pos-tile { grid-column: 4; grid-row: 1 / span 2; padding: 0 12px; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.wm-dot { width: 22px; height: 16px; border: 1.5px solid var(--text-3); border-radius: var(--radius-sm); position: relative; }
.wm-dot::after { content: ""; position: absolute; width: 6px; height: 4px; background: var(--accent); border-radius: 1px; }
.wm-top-left::after { top: 2px; left: 2px; }
.wm-top-right::after { top: 2px; right: 2px; }
.wm-center::after { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.wm-bottom-left::after { bottom: 2px; left: 2px; }
.wm-bottom-center::after { bottom: 2px; left: 50%; transform: translateX(-50%); }
.wm-bottom-right::after { bottom: 2px; right: 2px; }
.wm-slider .field-label { display: flex; justify-content: space-between; }
.wm-slider output { font-variant-numeric: tabular-nums; color: var(--text-3); font-weight: 500; }
.wm-slider input { width: 100%; accent-color: var(--accent-2); }
.wm-color-row { display: flex; align-items: center; gap: 8px; }
.wm-color-row input[type="color"] { width: 40px; height: 32px; padding: 2px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface); }
.wm-color-row input[type="color"]:disabled { opacity: 0.4; }
.wm-checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.wm-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.wm-check input { accent-color: var(--accent-2); }
.wm-figure { margin: 0; display: grid; gap: 6px; justify-items: start; }
.wm-preview { width: 240px; max-width: 100%; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--stage); box-shadow: var(--shadow-sm); }
.wm-defaults { display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
@media (max-width: 420px) {
  .wm-positions { max-width: none; }
  .wm-preview { width: 100%; }
}
/* Beat the global `input:not(...) { width: 100% }` rule for the color swatch. */
.wm-section .wm-color-row input.wm-color[type="color"] { width: 44px; min-width: 44px; height: 32px; flex: none; padding: 2px; cursor: pointer; }

/* ───── "What happens next?" dialog ───── */
.continue-dialog .dialog-body { min-height: 0; }
.cont-optional { font-weight: 450; color: var(--text-3); }
.cont-hint-row { display: flex; justify-content: space-between; gap: 8px; }
.cont-counter { font-variant-numeric: tabular-nums; flex: none; }
.cont-count { max-width: 280px; }
.cont-strip { list-style: none; margin: 0; padding: 0; display: flex; gap: 10px; align-items: flex-end; min-width: 0;
  transition: opacity 0.15s var(--ease); }
.cont-strip.is-off > li:not(.cont-next) { opacity: 0.4; }
.cont-strip > li { display: grid; gap: 4px; justify-items: center; flex: 0 1 76px; min-width: 0; }
.cont-thumb { display: grid; place-items: center; width: 100%; aspect-ratio: 2 / 3; overflow: hidden;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--stage); box-shadow: var(--shadow-sm); }
.cont-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cont-thumb.is-missing img { display: none; }
.cont-thumb.is-missing::after { content: ""; width: 40%; height: 2px; background: var(--line-strong); }
.cont-next .cont-thumb { border-style: dashed; border-color: var(--accent-line); background: var(--accent-soft);
  color: var(--accent); box-shadow: none; }
.cont-num { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.cont-next .cont-num { color: var(--accent); font-weight: 600; }
/* Created pages with no direction: the writer imagines them from the pages before. */
.page-card .page-prompt.is-auto { font-style: italic; color: var(--text-3); }
@media (max-width: 420px) {
  .cont-count { max-width: none; }
}

/* ───── AI images: composer, references, variations ───── */
.type-badge.images {
  color: var(--accent-2);
  border-color: var(--accent-2-line);
  background: var(--accent-2-soft);
}
.img-composer .img-options {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 10px 16px;
  min-width: 0;
}
.img-opt {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.img-opt-wide {
  flex: 1 1 100%;
}
.img-opt-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.img-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.img-chips label {
  position: relative;
  cursor: pointer;
}
.img-chips input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.img-chips label > span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.img-chips label:hover > span {
  color: var(--text);
  border-color: var(--text-3);
}
.img-chips input:checked + span {
  color: var(--accent-2);
  border-color: var(--accent-2);
  background: var(--accent-2-soft);
}
.img-chips input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.img-shape {
  width: 260px;
  max-width: 100%;
}
.img-count {
  width: 140px;
}
.img-composer input.img-seed {
  width: 120px;
  min-height: 38px;
}
.img-opt-refs {
  flex: 1 1 180px;
}
.img-ref-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}
.img-refs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 8px;
}
.img-refs[hidden] {
  display: none;
}
.img-ref {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--stage, var(--surface-2));
  overflow: hidden;
  flex: none;
}
.img-ref img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.img-ref-x {
  position: absolute;
  top: 2px;
  right: 2px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
}
.img-ref-x:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.img-composer .composer-actions {
  align-items: center;
}
.img-cost[hidden] {
  display: none;
}
@media (max-width: 640px) {
  .img-composer .img-options {
    grid-column: 1;
  }
  .img-shape,
  .img-opt-refs {
    flex: 1 1 100%;
    width: auto;
  }
}
/* Pick a reference / switch variation dialogs */
.img-pick-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
.img-pick {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--stage, var(--surface-2));
  overflow: hidden;
  transition: border-color var(--t-fast) var(--ease);
}
.img-pick:hover {
  border-color: var(--text-3);
}
.img-pick:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.img-pick.current {
  border-color: var(--accent-2);
}
.img-pick img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
}
.img-pick > span,
.img-pick > em {
  position: absolute;
  bottom: 4px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  font-style: normal;
  font-weight: 600;
}
.img-pick > span {
  left: 4px;
}
.img-pick > em {
  right: 4px;
  background: var(--accent-2);
  color: var(--on-accent-2);
}
.img-var-prompt {
  margin: 0;
  overflow-wrap: anywhere;
}
/* Editor: Image tab */
.ed-img-prompt {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.ed-img-refs .img-ref {
  width: 64px;
  height: 64px;
}
/* Translation "coming soon": a small badge on disabled controls and settings */
.soon-badge {
  display: inline-flex;
  align-items: center;
  flex: none;
  height: 17px;
  padding: 0 5px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-3-line);
  background: var(--accent-3-soft);
  color: var(--text);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
}
.btn.is-soon:disabled {
  opacity: 0.7;
}
.panel-section summary .soon-badge {
  margin-left: 2px;
}
.hero-steps li.is-soon {
  border-style: dashed;
  background: transparent;
}
.hero-steps li.is-soon > .icon {
  color: var(--text-3);
}
.hero-steps strong .soon-badge {
  margin-left: 4px;
  font-size: 10px;
  vertical-align: 1px;
}
.pr-soon th,
.pr-soon td {
  color: var(--text-3);
}
.pr-soon td {
  font-weight: 500;
  white-space: nowrap;
}
.pr-soon th .soon-badge {
  margin-left: 8px;
  vertical-align: 1px;
}
.pr-costs tbody .pr-soon th .icon {
  color: var(--text-3);
}

/* Watermark positions reserved for the platform watermark (PANEL_WATERMARK). */
.wm-section .wm-pos.wm-pos-blocked {
  opacity: 0.35;
  cursor: not-allowed;
}
.wm-section .wm-site-note {
  margin-top: 6px;
}

/* ═════ Minimal studio pass ═════ */

/* Library: one header row (title, ⋯, New project); quiet storage footer. */
.lib-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 18px;
}
.lib-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(24px, 3vw, 30px);
  font-weight: 600;
  line-height: 1.15;
}
.lib-title .section-count {
  font-family: var(--font);
  font-size: 0.6em;
}
.lib-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.view-library .storage-bar {
  margin: 20px 0 0;
  padding: 6px 4px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-size: 12px;
  color: var(--text-3);
}
.view-library .storage-bar.is-due {
  margin: 0 0 16px;
  padding: 8px 10px 8px 12px;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 7%, var(--surface));
  color: var(--text-2);
}
.view-library .storage-bar .btn-ghost {
  color: var(--text-2);
}
.storage-note {
  cursor: help;
}
.storage-usage::before {
  content: "·";
  margin-right: 8px;
  color: var(--text-3);
}
.storage-usage:empty::before {
  content: none;
}
.cover .type-badge.on-cover.icon-only {
  padding: 4px;
  gap: 0;
}
.project-card .card-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* First run: a title and three simple choices. */
.first-run {
  gap: 16px;
  max-width: 920px;
  margin: clamp(8px, 6vh, 64px) auto 0;
  text-align: center;
}
.first-run-title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: clamp(26px, 4vw, 36px);
  font-weight: 600;
}
.first-run-paths {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.first-run .path-card {
  justify-items: center;
  text-align: center;
  padding: 24px 18px;
  gap: 4px;
}
.first-run .path-card > span:last-child {
  font-size: 12.5px;
  color: var(--text-3);
}
.first-run .path-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
}
.first-run-more {
  margin: 0;
  font-size: 13px;
  color: var(--text-3);
}
.first-run-more .link-btn {
  font-size: 13px;
}
.first-run .first-run-note {
  justify-content: center;
  grid-template-columns: none;
  display: flex;
}
@media (max-width: 640px) {
  .first-run-paths {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .first-run .path-card {
    grid-template-columns: auto 1fr;
    justify-items: start;
    text-align: left;
    align-items: center;
    padding: 14px 16px;
    column-gap: 14px;
    row-gap: 0;
  }
  .first-run .path-card .path-icon {
    grid-row: 1 / span 2;
    margin: 0;
  }
  .view-library .storage-bar .btn {
    flex: 0 0 auto;
  }
}
.view-library .projects {
  margin-top: 0;
}

/* Board: one header row; settings is a panel you open, not a permanent column. */
.board.settings-closed {
  grid-template-columns: minmax(0, 1fr);
}
.settings-panel[hidden] {
  display: none;
}
.board-head {
  align-items: center;
  flex-wrap: nowrap;
}
.board-actions {
  align-items: center;
  flex-wrap: nowrap;
  flex: none;
}
.board-settings-btn.is-on {
  color: var(--accent-2);
  background: var(--accent-2-soft);
  border-color: var(--accent-2-line);
}
.settings-panel .panel-head {
  gap: 8px;
}
.settings-panel .panel-head h2 {
  margin-right: auto;
}
/* "Coming soon" translation: one quiet row, no section. */
.panel-soon {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 650;
  color: var(--text-3);
  cursor: help;
}
/* Nested "More options" inside a settings section. */
.panel-more {
  display: grid;
  gap: 14px;
}
.panel-more > summary {
  cursor: pointer;
  list-style: none;
  width: fit-content;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}
.panel-more > summary::-webkit-details-marker {
  display: none;
}
.panel-more > summary::before {
  content: "+ ";
  font-family: var(--font-mono);
  color: var(--text-3);
}
.panel-more[open] > summary::before {
  content: "− ";
}
.panel-more > summary:hover {
  color: var(--text);
}
.panel-more > summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
/* Color treatments: name only (the description is a tooltip). */
.settings-panel .style-card {
  padding: 6px;
  gap: 8px;
}
.settings-panel .style-card .swatch {
  width: 26px;
  height: 26px;
}
.wm-body.is-off > :not(.wm-defaults) {
  display: none;
}
.wm-body.is-off {
  margin-top: 0;
}
/* Quiet empty states under the composer (create / images). */
.board-empty.is-quiet {
  padding: 36px 24px;
  border-width: 1px;
}
.board-empty.is-quiet .icon {
  opacity: 0.6;
}
/* Selection bar: actions left, ⋯ and clear right. */
.selection-bar .icon-btn.sm {
  width: 30px;
  height: 30px;
}

/* Story composer: one line that grows; actions inline. */
.composer.story-composer {
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  padding: 8px 8px 8px 12px;
}
.story-composer .composer-input {
  min-height: 36px;
  resize: none;
  overflow-y: auto;
  line-height: 1.45;
}
.story-composer .composer-icon {
  margin-top: 8px;
}
.story-composer .composer-actions {
  grid-column: 3;
  grid-row: 1;
  align-items: center;
  align-self: start;
  gap: 4px;
}
.story-composer .composer-meta {
  grid-column: 2 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: center;
}
.story-composer .composer-meta:not(:has(> :not([hidden]))) {
  display: none;
}
.composer-meta .ready-warn {
  margin: 0;
}

/* AI images composer: prompt + one toolbar row. */
.img-toolbar {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.img-toolbar .spacer {
  flex: 1;
}
.img-tool {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.img-tool > .icon {
  position: absolute;
  left: 10px;
  color: var(--text-3);
  pointer-events: none;
}
.img-composer select.img-select {
  width: auto;
  min-width: 0;
  padding: 5px 28px 5px 30px;
  font-size: 13px;
  height: 32px;
}
.img-toolbar .img-count {
  width: auto;
}
.img-composer .img-count label > span {
  padding: 4px 9px;
  font-size: 12.5px;
}
.img-composer .img-toolbar input.img-seed {
  width: 84px;
  min-height: 0;
  height: 32px;
  padding: 4px 8px;
  font-size: 13px;
}
.img-toolbar .img-ref-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.img-toolbar .img-refs .img-ref {
  width: 32px;
  height: 32px;
}
.img-composer .composer-meta {
  grid-column: 1 / -1;
}
.img-composer .composer-meta:not(:has(> :not([hidden]))) {
  display: none;
}
@media (max-width: 960px) {
  .board-head {
    flex-wrap: wrap;
  }
}
@media (max-width: 640px) {
  .board-head {
    gap: 8px;
  }
  .board-title {
    flex-basis: 100%;
  }
  .board-actions {
    width: 100%;
    gap: 6px;
  }
  .board-actions .split {
    margin-left: auto;
  }
  .board-actions .btn-label {
    display: none;
  }
  .composer.story-composer {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .story-composer .composer-actions {
    grid-column: 2;
  }
  .story-composer .composer-meta {
    grid-column: 1 / -1;
  }
  .img-toolbar .spacer {
    display: none;
  }
  .img-toolbar .btn-primary {
    margin-left: auto;
  }
}

/* Dialogs: folded extras share one look. */
.create-more,
.import-dialog .imp-advanced {
  display: grid;
  gap: 12px;
  border: 0;
  padding: 0;
}
.import-dialog .imp-advanced[open] {
  padding: 0;
}
.import-dialog .imp-advanced > summary,
.create-more > summary {
  cursor: pointer;
  list-style: none;
  width: fit-content;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.import-dialog .imp-advanced > summary::-webkit-details-marker,
.create-more > summary::-webkit-details-marker {
  display: none;
}
.import-dialog .imp-advanced > summary::before,
.create-more > summary::before {
  content: "+ ";
  font-family: var(--font-mono);
  color: var(--text-3);
}
.import-dialog .imp-advanced[open] > summary::before,
.create-more[open] > summary::before {
  content: "− ";
}
.import-dialog .imp-advanced > summary:hover,
.create-more > summary:hover {
  color: var(--text);
}
.import-dialog .imp-advanced > summary:focus-visible,
.create-more > summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
#create-dialog .dialog-body {
  display: grid;
  gap: 14px;
}
/* Continue dialog: count on one row, thumbnails smaller. */
.cont-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.cont-row .cont-count {
  flex: 1 1 200px;
}
.continue-dialog .cont-strip > li {
  flex-basis: 56px;
}
.cont-strip[hidden] {
  display: none;
}
/* Compute: compact add choices (help is a tooltip and repeats in the form). */
.preset-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.preset-grid.compact .preset {
  padding: 10px 12px;
}
.compute-add {
  justify-self: start;
}
.import-dialog .two {
  grid-template-columns: 1fr 1fr;
}
.import-dialog .dialog-body > .hint:empty {
  display: none;
}
/* Settings panel rhythm: clear space between fields; nested "more" has no section chevron. */
.settings-panel .panel-section[open],
.settings-panel .panel-more[open] {
  gap: 14px;
}
.settings-panel .panel-more > summary {
  display: block;
  padding: 2px 0;
}
.settings-panel .panel-more > summary::after {
  content: none;
}
.settings-panel .field {
  gap: 6px;
}
.thumb-veil {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  background: color-mix(in srgb, var(--surface-2) 88%, transparent);
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
}
.thumb-veil[hidden] {
  display: none;
}
.thumb-veil .icon {
  width: 22px;
  height: 22px;
  opacity: 0.7;
}
.thumb-veil[data-state="error"] {
  color: var(--danger);
}
.thumb-veil[data-state="running"],
.thumb-veil[data-state="queued"] {
  color: var(--accent-2);
}
/* Header: actions line up with the title; breathing room before the composer and grid. */
.board-head {
  align-items: flex-start;
}
.board-actions {
  margin-top: 2px;
}
.board-main > .composer-slot {
  margin-top: 16px;
  margin-bottom: 0;
}
.board-main > .page-grid {
  margin-top: 18px;
}
.settings-panel .style-grid.compact {
  grid-template-columns: 1fr 1fr;
}
/* <details> doesn't lay its content out as grid/flex everywhere: space children with margins. */
.settings-panel .panel-section[open] > :not(summary),
.settings-panel .panel-more[open] > :not(summary),
.create-more[open] > :not(summary),
.import-dialog .imp-advanced[open] > :not(summary) {
  margin-top: 14px;
}
.settings-panel .panel-section > .panel-more[open] > :not(summary) {
  margin-top: 12px;
}
/* Phones and narrow windows: settings open as a bottom sheet over the board. */
@media (max-width: 960px) {
  .settings-panel:not([hidden]) {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 50;
    height: auto;
    max-height: min(82dvh, 760px);
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -12px 32px -16px rgba(0, 0, 0, 0.35);
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    animation: sheet-in var(--t-slow) var(--ease-out);
  }
  @keyframes sheet-in {
    from {
      transform: translateY(24px);
      opacity: 0;
    }
  }
  .settings-panel .panel-head {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bg-elev);
  }
}
.panel-sum {
  margin-left: auto;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
}
.panel-sum + .soon-badge,
.wm-section .panel-sum {
  margin-left: 0;
}

/* ───── Layout: views fill the window, so footers sit at its bottom on short pages ───── */
.view-library {
  display: flex;
  flex-direction: column;
  max-width: 1240px;
  padding-bottom: 12px;
}
.view-library .projects {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
}
.view-library .project-grid {
  margin-bottom: 24px;
}
/* The quiet storage footer goes to the bottom of the window (a due backup stays above the projects). */
.view-library .storage-bar:not(.is-due) {
  margin-top: auto;
}
/* First run: the three choices are centered in the window, not stuck to the top. */
.view-library .project-grid.is-empty {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-bottom: 6vh;
}
.view-library .project-grid.is-empty > .first-run {
  width: 100%;
  margin: 0 auto;
}
@media (min-width: 641px) {
  .view-library .project-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 18px;
  }
}

/* ───── Board: centered content; the composer is the hero, then a dock ───── */
.board-main {
  --board-pad: clamp(16px, 2.5vw, 32px);
  display: flex;
  flex-direction: column;
  padding: 20px var(--board-pad) 40px;
}
.board-main > :not(.composer-slot) {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
}
@media (min-width: 641px) {
  .page-grid {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
  }
}
/* Uploading boards with no pages: the drop zone sits in the middle of the window. */
.board-main > .board-empty {
  max-width: 720px;
  margin: auto;
  padding: 64px 24px;
}
/* Empty create / images board: heading, the prompt box and example prompts, centered. */
.board-main > .composer-slot.is-hero {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 0 calc(24px + 8vh);
}
.composer-slot.is-hero > .composer {
  width: 100%;
  padding: 14px 14px 12px;
  box-shadow: var(--shadow);
}
.composer-slot.is-hero > .composer:focus-within {
  box-shadow: var(--shadow-lg);
}
.composer-slot.is-hero .composer-input {
  min-height: 64px;
  font-size: 15px;
}
.composer-hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(26px, 3.4vw, 36px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  text-align: center;
}
.composer-examples {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.example-chip {
  max-width: 100%;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  transition:
    border-color var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease),
    transform var(--t-fast) var(--ease);
}
.example-chip:hover {
  border-color: var(--line-strong);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.example-chip:active {
  transform: none;
  box-shadow: none;
}
/* Board with pages: the composer docks at the bottom of the window; the grid scrolls above it.
   In flow (sticky), so the last row of cards is never hidden behind it. */
.board-main > .composer-slot.is-docked {
  position: sticky;
  bottom: 0;
  z-index: 20;
  margin: auto calc(-1 * var(--board-pad)) 0;
  padding: 28px var(--board-pad) max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--bg) 26px);
  pointer-events: none;
}
.composer-slot.is-docked > * {
  max-width: 820px;
  margin-inline: auto;
  pointer-events: auto;
}
.composer-slot.is-docked > .composer {
  box-shadow: var(--shadow);
}
.composer-slot.is-docked > .composer:focus-within {
  box-shadow: var(--shadow-lg);
}
.board.has-dock > .board-main {
  padding-bottom: 0;
}
/* AI images toolbar: compact enough for one row inside the hero box and the dock. */
@media (min-width: 641px) {
  .img-composer .img-toolbar {
    gap: 6px;
  }
  .img-composer select.img-select {
    padding: 5px 24px 5px 28px;
    font-size: 12.5px;
  }
  .img-tool > .icon {
    left: 9px;
  }
  .img-composer .img-count label > span {
    padding: 4px 7px;
  }
  .img-composer .img-toolbar input.img-seed {
    width: 66px;
  }
}
@media (max-width: 960px) {
  /* Toasts would cover the docked composer on narrow screens: show them above it. */
  body:has(.board.has-dock) .toasts {
    bottom: 176px;
  }
}
@media (max-width: 640px) {
  .board-main > .composer-slot.is-hero {
    padding: 20px 0 32px;
    gap: 14px;
  }
  .composer-examples {
    justify-content: flex-start;
  }
  /* Hero story box on a phone: the text gets the full width, the buttons sit under it. */
  .composer-slot.is-hero .composer.story-composer {
    grid-template-columns: minmax(0, 1fr);
  }
  .composer-slot.is-hero .story-composer .composer-actions {
    grid-column: 1;
    grid-row: auto;
    justify-content: flex-end;
  }
  .composer-slot.is-hero .story-composer .composer-meta {
    grid-column: 1;
  }
  .board-main > .composer-slot.is-docked {
    padding: 20px 12px max(12px, env(safe-area-inset-bottom));
  }
  /* Docked on a phone: the image options scroll sideways in one row; Generate stays pinned at the end. */
  .composer-slot.is-docked .img-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .composer-slot.is-docked .img-toolbar::-webkit-scrollbar {
    display: none;
  }
  .composer-slot.is-docked .img-toolbar > * {
    flex: none;
  }
  .composer-slot.is-docked .img-toolbar .btn-primary {
    position: sticky;
    right: 0;
    box-shadow: 0 0 0 4px var(--surface), -14px 0 10px 2px var(--surface);
  }
  .composer-slot.is-docked .img-composer .composer-input {
    min-height: 40px;
  }
  .board-main > .board-empty {
    padding: 44px 20px;
  }
}

/* ───── Image context: "Continue from previous", shot chips and the story-context hint (images composer) ───── */
.img-composer .ctx-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.ctx-shots {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}
.ctx-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 2px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.ctx-chip:hover {
  color: var(--text);
  border-color: var(--text-3);
}
.ctx-chip[aria-pressed="true"] {
  color: var(--accent-2);
  border-color: var(--accent-2);
  background: var(--accent-2-soft);
}
.ctx-chip:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.ctx-chip[hidden] {
  display: none;
}
.ctx-hint {
  margin-left: auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-3);
  font-size: 12px;
}
.ed-img-context {
  margin-top: 4px;
}
@media (max-width: 640px) {
  /* Phone: the shot chips scroll sideways next to "Continue"; the hint takes its own line. */
  .img-composer .ctx-row {
    gap: 4px 6px;
  }
  .ctx-follow {
    flex: none;
  }
  .ctx-shots {
    flex: 1 1 0;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .ctx-shots::-webkit-scrollbar {
    display: none;
  }
  .ctx-shots > .ctx-chip {
    flex: none;
  }
  .ctx-hint {
    flex-basis: 100%;
    margin-left: 2px;
  }
}

/* ───────────── Page composer (js/layout.js) ───────────── */
.cmp-dialog {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--bg);
  color: var(--text);
}
.cmp-dialog[open] {
  display: flex;
}
.cmp-dialog::backdrop {
  background: var(--scrim);
}
.cmp-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  height: 100%;
  min-height: 0;
}
.cmp-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}
.cmp-head h2 {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 15px;
  font-weight: 650;
}
.cmp-body {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr) 236px;
  min-height: 0;
}
.cmp-side {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 14px 16px 20px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--bg-elev);
}
.cmp-section h3 {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-2);
}
.cmp-options.panel-section {
  padding: 0 0 4px;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}
.cmp-options[open] {
  gap: 14px;
}
.cmp-templates {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.cmp-tpl {
  position: relative;
  display: block;
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
}
.cmp-tpl:hover {
  border-color: var(--text-3);
}
.cmp-tpl input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.cmp-tpl-svg {
  display: block;
  width: 100%;
  height: auto;
}
.cmp-tpl-sheet {
  fill: var(--surface);
}
.cmp-tpl-cell {
  fill: var(--line-strong);
}
.cmp-tpl:has(input:checked) {
  border-color: var(--accent-2);
  background: var(--accent-2-soft);
}
.cmp-tpl input:checked + .cmp-tpl-svg .cmp-tpl-cell {
  fill: var(--accent-2);
}
.cmp-tpl:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.cmp-sliders {
  display: grid;
  gap: 10px;
}
.cmp-slider .field-label {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
.cmp-slider output {
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.cmp-dialog input[type="range"] {
  width: 100%;
  accent-color: var(--accent-2);
}
.cmp-panel {
  display: grid;
  gap: 10px;
  padding: 14px 0 4px;
  border-top: 1px solid var(--line);
}
.cmp-panel-title {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
}
.cmp-panel-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.cmp-chip {
  min-width: 30px;
  height: 28px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.cmp-chip.is-filled {
  border-style: solid;
  background: var(--surface);
  color: var(--text);
}
.cmp-chip[aria-pressed="true"] {
  border: 1px solid var(--accent-2);
  background: var(--accent-2-soft);
  color: var(--accent-2);
}
.cmp-chip:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
.cmp-panel-controls {
  display: grid;
  gap: 10px;
}
.cmp-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cmp-hint {
  margin: 0;
  font-size: 12px;
}
.cmp-stage {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--stage);
}
.cmp-canvas {
  display: block;
  border-radius: 2px;
  box-shadow: var(--shadow);
  touch-action: none;
  cursor: grab;
  outline: none;
}
.cmp-canvas:active {
  cursor: grabbing;
}
.cmp-canvas:focus-visible {
  outline: 2px solid var(--accent-2-line);
  outline-offset: 4px;
}
.cmp-tray {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 14px 14px 18px;
  overflow-y: auto;
  border-left: 1px solid var(--line);
  background: var(--bg-elev);
}
.cmp-tray-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.cmp-tray-head h3 {
  margin: 0;
}
.cmp-tray-count {
  color: var(--text-3);
  font-weight: 500;
}
.cmp-tray-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.cmp-tray-item {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: grab;
  touch-action: pan-y;
}
.cmp-tray-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.cmp-tray-item.is-used {
  border-color: var(--accent-2);
}
.cmp-tray-item:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.cmp-tray-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--accent-3);
  color: var(--on-accent-3);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}
.cmp-tray-kept {
  position: absolute;
  left: 4px;
  bottom: 4px;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--paper);
}
.cmp-tray-hint {
  margin: 0;
  font-size: 12px;
}
.cmp-ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 2px solid var(--accent-2);
  box-shadow: var(--shadow);
  opacity: 0.9;
  pointer-events: none;
  z-index: 10;
}
.cmp-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 16px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
}
.cmp-target-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-2);
}
.cmp-target-label span {
  white-space: nowrap;
}
.cmp-dialog select.cmp-target {
  width: auto;
  max-width: 260px;
}
.cmp-dialog input.cmp-name {
  width: 220px;
}
.cmp-msg {
  margin: 0;
  font-size: 12.5px;
  color: var(--danger);
}
.cmp-msg[data-tone="info"] {
  color: var(--text-2);
}
@media (max-width: 1100px) {
  .cmp-body {
    grid-template-columns: 260px minmax(0, 1fr) 196px;
  }
  .cmp-templates {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
/* Phone: one scrolling column — layouts strip, preview, panel tools, images strip, page options. */
@media (max-width: 760px) {
  .cmp-body {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
  }
  .cmp-side {
    display: contents;
  }
  .cmp-side > *,
  .cmp-tray {
    padding-left: 12px;
    padding-right: 12px;
  }
  .cmp-tpl-section {
    order: 1;
    padding-top: 10px;
  }
  .cmp-tpl-section h3 {
    display: none;
  }
  .cmp-templates {
    grid-auto-flow: column;
    grid-template-columns: none;
    grid-auto-columns: 48px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 2px 2px 6px;
  }
  .cmp-templates::-webkit-scrollbar {
    display: none;
  }
  .cmp-stage {
    order: 2;
    flex: none;
    height: min(58dvh, 560px);
  }
  .cmp-panel {
    order: 3;
    padding-top: 10px;
    border-top: 0;
  }
  .cmp-panel-controls {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: end;
  }
  .cmp-panel-actions {
    grid-column: 1 / -1;
  }
  .cmp-tray {
    order: 4;
    flex: none;
    overflow: visible;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .cmp-tray-list {
    grid-auto-flow: column;
    grid-template-columns: none;
    grid-auto-columns: 68px;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .cmp-tray-item {
    touch-action: pan-x;
  }
  .cmp-options {
    order: 5;
    border-top: 1px solid var(--line);
    border-bottom: 0;
    padding-bottom: 20px;
  }
  .cmp-sliders {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .cmp-foot {
    padding-left: 12px;
    padding-right: 12px;
    gap: 8px;
  }
  .cmp-target-label {
    flex: 1 1 100%;
  }
  .cmp-dialog select.cmp-target {
    flex: 1;
    max-width: none;
  }
  .cmp-dialog input.cmp-name {
    flex: 1 1 100%;
    width: 100%;
  }
  .cmp-msg {
    flex: 1 1 100%;
  }
}

/* ───── QA fixes ───── */
/* Toasts sit above the docked composer at every width, so they never cover its primary button.
   --dock-h is the dock's measured height (project.js); the slot's top padding is its fade. */
body:has(.board.has-dock) .toasts {
  bottom: calc(var(--dock-h, 188px) - 12px);
}
/* Composer focus: the same 2px accent ring as buttons while typing (other controls keep their own ring). */
.composer-slot.is-docked > .composer:has(.composer-input:focus),
.composer-slot.is-hero > .composer:has(.composer-input:focus) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
/* Library covers: every card's cover is the same 3:4 box; the image fills it. */
.cover {
  overflow: hidden;
}
.cover img {
  position: absolute;
  inset: 0;
}
/* Placeholder covers (page not drawn/generated yet) show whole and centered, not cropped at the edge. */
.cover.is-placeholder img {
  object-fit: contain;
  padding: 12px;
}
/* Example placeholders (Story settings, Create dialog) read as examples, not filled-in values. */
.panel-section [placeholder^="e.g."]::placeholder,
#create-dialog [placeholder^="e.g."]::placeholder {
  color: color-mix(in srgb, var(--text-3) 78%, transparent);
  font-style: italic;
}
/* Docked one-line story box: a long hint ends in "…" instead of wrapping into a clipped second line. */
.composer-slot.is-docked .story-composer .composer-input::placeholder {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 640px) {
  /* Docked AI-images composer on a phone: two wrapped rows, no hidden sideways scrolling.
     Row 1: Style + Shape; row 2: ×1–4, Reference, Seed and Generate. */
  .composer-slot.is-docked .img-toolbar {
    flex-wrap: wrap;
    overflow-x: visible;
    padding-bottom: 0;
    gap: 6px;
  }
  .composer-slot.is-docked .img-toolbar > .img-tool {
    flex: 1 1 calc(50% - 3px);
    min-width: 0;
  }
  .composer-slot.is-docked .img-toolbar > .img-tool select.img-select {
    width: 100%;
  }
  .composer-slot.is-docked .img-composer .img-count label > span {
    padding: 4px 6px;
  }
  /* Reference shows as its icon (the label stays the accessible name). */
  .composer-slot.is-docked .img-toolbar .img-ref-row > .btn {
    gap: 0;
    padding-inline: 8px;
    font-size: 0;
  }
  .composer-slot.is-docked .img-composer .img-toolbar input.img-seed {
    width: 58px;
  }
  .composer-slot.is-docked .img-toolbar .btn-primary {
    position: static;
    margin-left: auto;
    box-shadow: none;
  }
  /* Hosted cost ("≈ 3 credits") gets its own short line under Generate instead of pushing it to a third row. */
  .composer-slot.is-docked .img-toolbar .img-cost {
    order: 1;
    flex-basis: 100%;
    margin-top: -2px;
    text-align: right;
  }
}

/* Phones: context chips wrap instead of scrolling sideways (nothing hidden off-screen). */
@media (max-width: 640px) {
  .ctx-shots {
    flex-wrap: wrap;
    overflow-x: visible;
    row-gap: 6px;
  }
  .ctx-shots > .ctx-chip {
    flex: 0 0 auto;
  }
  .ctx-hint {
    white-space: normal;
  }
}

/* ───── Content filter: "Safe mode" switch (content.js), its "Safe" pill, the server-forced note
   and the hosted "Adults only" notice ───── */
.safe-pill {
  display: inline-flex;
  align-items: center;
  align-self: center;
  flex: none;
  height: 18px;
  padding: 0 7px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--ok) 50%, transparent);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  color: var(--ok);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1;
  white-space: nowrap;
}
.safe-pill[hidden] {
  display: none;
}
.panel-section summary .safe-pill,
.dialog-head h2 .safe-pill {
  margin-left: 4px;
}
.safe-row.is-disabled {
  cursor: default;
}
.safe-row.is-disabled .switch-text strong {
  color: var(--text-3);
}
.safe-row .switch:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.safe-note {
  font-style: italic;
}
.safe-scope {
  margin: 0;
  font-size: 12px;
}
.safe-dialog .dialog-body {
  display: grid;
  gap: 14px;
}
.safe-dialog .dialog-actions {
  margin-top: 4px;
}
.adult-notice h2 {
  display: flex;
  align-items: center;
  gap: 10px;
}
.adult-notice h2 .icon {
  color: var(--accent);
}
.adult-notice .adult-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
}
.adult-notice .adult-links a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.adult-notice .adult-links span {
  color: var(--text-3);
}
.adult-notice .dialog-actions {
  margin-top: 8px;
}

/* ───── Quality (model tier) picker: tiers.js ───── */
.tier-pick {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
}
.tier-pick[hidden],
.tier-row[hidden],
.tier-field[hidden] {
  display: none;
}
.tier-pick > .icon {
  position: absolute;
  left: 9px;
  color: var(--text-3);
  pointer-events: none;
}
select.tier-select {
  width: auto;
  max-width: 100%;
  height: 32px;
  padding: 4px 24px 4px 10px;
  font-size: 12.5px;
  font-weight: 500;
  text-overflow: ellipsis;
}
.tier-pick.has-icon select.tier-select {
  padding-left: 28px;
}
.st-actions .tier-pick {
  margin-left: auto;
}
/* Settings panel: one quiet row, like the "coming soon" translation row. */
.tier-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  font-weight: 650;
}
.tier-row > .tier-pick {
  margin-left: auto;
}
.pr-tiers {
  text-align: center;
}
.pr-tiers,
.cr-tiers {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-3);
}
.pr-tiers strong,
.cr-tiers strong {
  font-weight: 650;
  color: var(--text-2);
}
@media (max-width: 640px) {
  /* Story composer on a phone: the buttons sit under the text (docked too), the picker on their left
     without its icon, shrinking before anything overflows. */
  .composer-slot.is-docked .composer.story-composer {
    grid-template-columns: minmax(0, 1fr);
  }
  .composer-slot.is-docked .story-composer .composer-actions {
    grid-column: 1;
    grid-row: auto;
  }
  .story-composer .composer-actions .tier-pick {
    margin-right: auto;
  }
  .story-composer .tier-pick > .icon {
    display: none;
  }
  .story-composer .tier-pick.has-icon select.tier-select {
    padding-left: 8px;
  }
}
.st-actions .tier-pick + .st-more {
  margin-left: 0;
}

/* "uncensored" marker after a tier in price lists (provider's own model flag, shown for transparency). */
.tier-tag {
  margin-left: 4px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  font-size: 0.85em;
  color: var(--text-2);
  border: 1px solid var(--line);
}

/* ───── Restyle: one control height (32px) across the AI-images toolbar; tidy phone context row ───── */
.img-toolbar .segmented {
  padding: 2px;
}
.img-toolbar .segmented label > span {
  min-height: 26px;
}
.img-toolbar .btn-sm {
  height: 32px;
}
.img-composer .img-toolbar input.img-seed {
  height: 32px;
}
.img-cost {
  font-family: var(--font-mono);
  font-size: 11.5px;
}
@media (max-width: 640px) {
  /* "Continue from previous" on its own line, the shot chips below it: no ragged right column. */
  .img-composer .ctx-row .ctx-shots {
    flex: 1 1 100%;
  }
  .ctx-hint {
    margin-left: 0;
  }
}
