/* Next-round flow (refine.js) and round grouping (app.js). Uses the site tokens with the old review-page
   colors as fallbacks, so it reads right before and after the redesign lands. */
.refine, .refine-tray {
  --r-bg: var(--bg, var(--color-paper, #f3f2ed));
  --r-surface: var(--surface, var(--color-image, #fff));
  --r-surface-2: var(--surface-2, var(--color-paper-deep, #e8e7e0));
  --r-ink: var(--ink, var(--color-ink, #252a26));
  --r-muted: var(--muted, var(--color-muted, #62675f));
  --r-line: var(--line, var(--color-rule, #d3d5cc));
  --r-accent: var(--accent, var(--color-accent, #276743));
  --r-accent-ink: var(--accent-ink, #fff);
  --r-danger: var(--danger, var(--color-error, #8b3d30));
  --r-radius: var(--radius, 4px);
  --r-radius-lg: var(--radius-lg, 10px);
}

/* Tray: pinned to the bottom while there's something to do. */
.refine-tray {
  position: fixed; z-index: 20; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: min(640px, calc(100% - 32px)); display: flex; align-items: center; gap: 16px; justify-content: space-between;
  padding: 10px 10px 10px 18px; border: 1px solid var(--r-line); border-radius: var(--r-radius-lg);
  background: var(--r-surface); color: var(--r-ink); box-shadow: 0 10px 30px rgba(0, 0, 0, .12);
}
.refine-tray[hidden] { display: none; }
.refine-tray-text { font-size: 14px; min-width: 0; }
.refine-tray-actions { display: flex; gap: 8px; flex: none; }
.refine-tray-actions [hidden] { display: none; }
body.has-refine-tray .colophon { padding-bottom: 96px; }
.refine-tray .btn-primary, .refine .btn-primary {
  background: var(--r-accent); color: var(--r-accent-ink); border-color: var(--r-accent); border-radius: var(--r-radius);
}

/* Dialog */
.refine { width: min(760px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--r-line);
  border-radius: var(--r-radius-lg); background: var(--r-bg); color: var(--r-ink); }
.refine::backdrop { background: rgba(20, 22, 20, .55); }
.refine-header { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 20px; background: var(--r-bg); border-bottom: 1px solid var(--r-line); }
.refine-header h2 { font: 400 24px/1.2 var(--font-display, Georgia, serif); }
.refine-body { padding: 20px; display: grid; gap: 18px; }
.refine-body[hidden] { display: none; }
.refine-lede { color: var(--r-muted); max-width: 60ch; font-size: 15px; }

.refine-picks { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.refine-pick { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px; padding: 10px; border: 1px solid var(--r-line);
  border-radius: var(--r-radius); background: var(--r-surface); }
.refine-thumb { aspect-ratio: 1; overflow: hidden; border-radius: var(--r-radius); background: var(--r-surface-2); display: grid; place-items: center; }
.refine-thumb img { width: 100%; height: 100%; object-fit: contain; }
.refine-thumb .image-missing { font-size: 11px; padding: 6px; text-align: center; }
.refine-pick-body { display: grid; gap: 6px; align-content: start; min-width: 0; }
.refine-pick-head { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.refine-id { font: 12px/1.4 var(--font-mono, monospace); color: var(--r-muted); }
.refine-title { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.refine-pick-head .text-button { margin-left: auto; min-height: 32px; padding: 0; }
.refine textarea { width: 100%; resize: vertical; font: inherit; font-size: 15px; padding: 9px 11px; border: 1px solid var(--r-line);
  border-radius: var(--r-radius); background: var(--r-surface); color: var(--r-ink); }
.refine-final-pick { display: block; padding: 0; }
.refine-final-pick.selected { border-color: var(--r-accent); box-shadow: 0 0 0 2px var(--r-accent); }
.refine-final-option { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px; padding: 10px; cursor: pointer; align-items: center; }
.refine-final-option input { width: 18px; height: 18px; accent-color: var(--r-accent); flex: none; }
.refine-direction { display: grid; gap: 8px; font-weight: 600; font-size: 16px; }
.refine-note { font-size: 13px; color: var(--r-muted); padding: 10px 12px; border-radius: var(--r-radius); background: var(--r-surface-2); }
.refine-error { color: var(--r-danger); font-size: 14px; }
.refine-error[hidden], .refine-note[hidden] { display: none; }
.refine-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

.refine-waiting { display: flex; align-items: center; gap: 12px; color: var(--r-muted); padding: 24px 0; }
.refine-waiting[hidden] { display: none; }
.refine-spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--r-line); border-top-color: var(--r-accent);
  animation: refine-spin .9s linear infinite; flex: none; }
@keyframes refine-spin { to { transform: rotate(360deg); } }
.refine-lines { margin: 0; padding: 0 0 0 18px; display: grid; gap: 10px; font-size: 16px; line-height: 1.5; }
.refine-lines li:last-child { list-style: none; margin-left: -18px; color: var(--r-muted); font-size: 14px; }

/* Round tabs, at the top under the project name (app.js). */
.round-tabs { margin: 0 var(--page-gutter, 24px); padding: 18px 0 0; display: flex; gap: 0; overflow-x: auto;
  border-bottom: 2px solid var(--line, #d3d5cc); scrollbar-width: thin; }
.round-tabs[hidden] { display: none; }
.round-tab { display: grid; gap: 2px; text-align: left; padding: 10px 22px 12px; margin-bottom: -2px; border: 0;
  border-bottom: 4px solid transparent; background: none; color: var(--muted, #62675f); cursor: pointer; flex: none; font: inherit; }
.round-tab:hover { color: var(--ink, #252a26); }
.round-tab:focus-visible { outline: 3px solid var(--focus, var(--accent, #276743)); outline-offset: -3px; }
.round-tab-name { font: 800 22px/1.15 var(--font-display, Georgia, serif); letter-spacing: -0.02em; }
.round-tab-meta { font: 12px/1.4 var(--font-mono, monospace); }
.round-tab.making .round-tab-meta::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%;
  background: var(--accent, #276743); animation: round-pulse 1.4s ease-in-out infinite; vertical-align: 1px; }
@keyframes round-pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .round-tab.making .round-tab-meta::before { animation: none; } }
.round-tab.selected { color: var(--ink, #252a26); border-bottom-color: var(--accent, #276743); }

/* Owner bar: shown only where the private link is remembered (refine.js). */
.owner-bar { margin: 12px var(--page-gutter, 24px) 0; display: flex; align-items: center; justify-content: space-between; gap: 12px 20px;
  flex-wrap: wrap; padding: 10px 14px; border: 1px solid var(--line, #d3d5cc); border-radius: var(--radius, 4px);
  background: var(--surface, #fff); font-size: 14px; color: var(--muted, #62675f); }
.owner-bar[hidden] { display: none; }
.owner-bar p { max-width: 80ch; }
.owner-bar .text-button { font-weight: 700; color: var(--ink, #252a26); text-decoration: underline; min-height: 32px; padding: 0; }
.owner-bar.is-visitor { border-style: dashed; }
.upsell { border-style: dashed; color: var(--ink, #252a26); }
.upsell-actions { display: flex; align-items: center; gap: 14px; }
.upsell .btn-primary { background: var(--accent, #276743); color: var(--accent-ink, #fff); border-color: var(--accent, #276743); border-radius: var(--radius, 4px); }
body.visitor-preview #detail-final { display: none; }
.group-heading { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding-top: 18px;
  border-top: 1px solid var(--line, var(--color-rule, #d3d5cc)); }
.group-heading:first-child { padding-top: 0; border-top: 0; }
.group-anchor { width: 72px; height: 72px; padding: 0; border: 1px solid var(--line, var(--color-rule, #d3d5cc)); background: #fff; overflow: hidden; flex: none; }
.group-anchor img { width: 100%; height: 100%; object-fit: contain; }
.like-button[aria-pressed="true"] { color: var(--accent, var(--color-accent, #276743)); }

@media (max-width: 560px) {
  .refine-tray { bottom: 10px; padding-left: 14px; gap: 10px; }
  .refine-tray-text { font-size: 13px; }
  .refine-tray { flex-wrap: wrap; }
  .refine-tray-actions { width: 100%; justify-content: flex-end; }
  .round-tab { padding: 8px 14px 10px; }
  .round-tab-name { font-size: 18px; }
  .refine-pick { grid-template-columns: 64px minmax(0, 1fr); }
  .refine-body { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { .refine-spinner { animation: none; } }

/* Steps 6 and 7: the final pick and its logo kit (app.js renderFinal, final.js). */
.final-panel {
  --r-surface: var(--surface, #fff); --r-line: var(--line, #d3d5cc); --r-muted: var(--muted, #62675f);
  --r-accent: var(--accent, #276743); --r-accent-ink: var(--accent-ink, #fff); --r-radius: var(--radius, 4px); --r-radius-lg: var(--radius-lg, 10px);
  margin: 0 0 24px; padding: 18px; border: 1px solid var(--r-line); border-radius: var(--r-radius-lg); background: var(--r-surface);
}
.final-panel[hidden] { display: none; }
.final-head { display: grid; grid-template-columns: 96px 1fr auto; gap: 16px; align-items: center; }
.final-thumb { width: 96px; aspect-ratio: 1; border-radius: var(--r-radius); overflow: hidden; background: #fff; }
.final-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.final-head h2 { margin: 2px 0 4px; font: 600 22px/1.2 var(--font-display, Georgia, serif); }
.final-code { font: 12px/1.4 var(--font-mono, monospace); color: var(--r-muted); margin: 0 0 6px; }
.final-status { color: var(--r-muted); max-width: 62ch; margin: 0; }
.final-panel .btn-primary { background: var(--r-accent); color: var(--r-accent-ink); border-color: var(--r-accent); border-radius: var(--r-radius); }
.final-previews { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.final-previews:empty { display: none; }
.final-preview { display: grid; gap: 6px; padding: 8px; font-size: 12px; color: var(--r-muted); }
.final-preview img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border-radius: var(--r-radius); }
.final-guide { margin-top: 18px; display: grid; gap: 14px; }
.final-guide[hidden] { display: none; }
.final-hero { background: #fff; border: 1px solid var(--r-line); border-radius: var(--r-radius); display: flex; align-items: center; justify-content: center; padding: clamp(20px, 5vw, 48px); min-height: 200px; }
.final-hero img { width: min(560px, 100%); max-height: 260px; object-fit: contain; display: block; }
.final-swatches { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.final-swatch { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border: 1px solid var(--r-line); border-radius: 999px; background: #fff; }
.final-chip { width: 26px; height: 26px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); flex: none; }
.final-swatch-text { display: flex; flex-direction: column; line-height: 1.15; font-size: 12px; color: #26262c; }
.final-swatch-text code { font-size: 11px; color: #62626a; }
.final-marks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.final-mark { display: grid; gap: 6px; font-size: 12px; color: var(--r-muted); }
.final-mark img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #fff; border: 1px solid var(--r-line); border-radius: var(--r-radius); padding: 14px; box-sizing: border-box; }
.final-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.final-icons { list-style: none; margin: 0; padding: 0; display: flex; align-items: flex-end; gap: 18px; }
.final-icon { display: flex; align-items: flex-end; gap: 8px; }
.final-icon img { display: block; image-rendering: auto; }
.final-icon code { font-size: 11px; color: var(--r-muted); }
.final-links { display: flex; flex-wrap: wrap; gap: 10px; }
.final-links .button[hidden] { display: none; }
#detail-final.confirming { background: var(--accent, #276743); color: var(--accent-ink, #fff); border-color: var(--accent, #276743); }
@media (max-width: 640px) {
  .final-head { grid-template-columns: 64px 1fr; }
  .final-thumb { width: 64px; }
  .final-head .btn-primary { grid-column: 1 / -1; justify-self: start; }
}

/* Logo kit tab (app.js): the kit replaces the gallery while it's open. */
#intro[hidden], #brief[hidden], #catalogue[hidden] { display: none; }
body:has(.kit-tab.selected) .final-panel { margin-top: 24px; }
.kit-tab .round-tab-name::before { content: "★ "; color: var(--accent, #276743); }
