/* Owner page designer (web/page-design.js): the form with its theme gallery and colour swatches, the live preview frame;
   and the notices of the creator's page defaults (web/admin-links.js). Miniatures are the real page rendered 390 px wide
   (landing.css .is-thumb) and scaled down by --pd-s; nothing here relies on inline styles (the site's CSP forbids them). */

/* ---------- Layout: the form, then (from 900 px) the sticky preview beside it ---------- */
.page-design { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
.page-design-form { min-width: 0; }
.page-design-form > .editor-section:first-child { margin-top: 6px; }
.page-design-form > .row { margin-top: 18px; }
.page-design-thumb { width: 64px; height: 64px; display: block; margin: 10px 0 2px; border: 1px solid var(--line-2); border-radius: 18px; object-fit: cover; }
.page-design-link { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 12px; }
.page-design-preview { min-width: 0; }
.page-design-caption { margin: 0 0 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.phone-frame { max-width: 360px; margin: 0 auto; padding: 8px; border: 1px solid var(--line-2); border-radius: 30px; background: var(--bg-deep); }
/* A fixed screen: the page fills it (landing.css .is-preview has min-height 100%) and scrolls inside it. */
.phone-screen { height: min(620px, 72svh); overflow-y: auto; overscroll-behavior: contain; border-radius: 23px; background: var(--bg); }

/* ---------- Theme gallery: radio cards ----------
   Phones: one row that runs to the sheet's edges (the phone sheet's side padding is --gutter) and scrolls sideways
   inside itself, so the dialog never does. From 620 px: a grid. */
.pd-themes {
  --pd-s: .36;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc(390px * var(--pd-s));
  gap: 12px;
  margin: 12px calc(var(--gutter) * -1) 0;
  padding: 8px var(--gutter) 10px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--gutter);
  scrollbar-width: thin;
}
.pd-theme {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
  scroll-snap-align: start;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
/* The radio stays in the form and in the reading order; the card shows its state and its focus. */
.pd-theme input[type="radio"], .pd-swatch input[type="radio"] { position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: 0; opacity: 0; pointer-events: none; }
.pd-thumb {
  position: relative;
  display: block;
  width: calc(390px * var(--pd-s));
  height: calc(600px * var(--pd-s));
  overflow: hidden;
  border-radius: 14px;
  background: var(--bg-deep);
  box-shadow: 0 0 0 1px var(--line-2);
  transition: box-shadow .15s var(--ease);
}
.pd-thumb-page { position: absolute; top: 0; left: 0; display: block; width: 390px; transform: scale(var(--pd-s)); transform-origin: 0 0; pointer-events: none; }
.pd-theme-mark {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  width: 26px;
  height: 26px;
  display: none;
  place-items: center;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-ink);
  box-shadow: 0 2px 10px rgb(0 0 0 / .45);
}
.pd-theme-mark svg { width: 16px; height: 16px; }
.pd-theme-name { margin-top: 10px; color: var(--text); font-size: 14px; font-weight: 600; line-height: 1.3; }
.pd-theme-note { margin-top: 2px; color: var(--muted); font-size: 12.5px; font-weight: 400; line-height: 1.35; }
.pd-theme:hover .pd-thumb { box-shadow: 0 0 0 1px #6a6a72; }
.pd-theme:has(input:checked) .pd-thumb { box-shadow: 0 0 0 2px var(--primary); }
.pd-theme:has(input:checked) .pd-theme-mark { display: grid; }
.pd-theme:has(input:focus-visible) .pd-thumb { outline: 3px solid rgb(241 241 243 / .9); outline-offset: 4px; }
/* Locked by the platform: the creator's theme stays clear, the others step back. */
.pd-theme:has(input:disabled) { cursor: not-allowed; }
.pd-theme:has(input:disabled:not(:checked)) { opacity: .45; }

/* ---------- Colour swatches of the chosen theme ---------- */
/* A legend's own margin is not reliable inside its fieldset: the group carries the gap. */
.pd-accent-group { margin-top: 20px; }
.editor-section .pd-accent-group > legend { float: none; width: auto; margin: 0 0 10px; padding: 0; color: var(--text-2); font-size: 14px; font-weight: 500; }
.pd-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.pd-swatch {
  position: relative;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  padding: 6px 16px 6px 8px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--bg-deep);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s var(--ease);
}
.pd-swatch:hover { border-color: #6a6a72; }
.pd-swatch:has(input:checked) { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.pd-swatch:has(input:focus-visible) { outline: 3px solid rgb(241 241 243 / .9); outline-offset: 2px; }
.pd-swatch:has(input:disabled) { cursor: not-allowed; }
.pd-swatch:has(input:disabled:not(:checked)) { opacity: .45; }
.swatch { width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--panel-3); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .22), 0 0 0 1px rgb(0 0 0 / .35); }
.swatch[data-theme="neon"][data-accent="cyan"] { background: #3bd9ff; }
.swatch[data-theme="neon"][data-accent="violet"] { background: #a78bfa; }
.swatch[data-theme="neon"][data-accent="rose"] { background: #ff6fa3; }
.swatch[data-theme="neon"][data-accent="amber"] { background: #ffbe55; }
.swatch[data-theme="aurora"][data-accent="polar"] { background: #2dd4bf; }
.swatch[data-theme="aurora"][data-accent="dusk"] { background: #ff8fab; }
.swatch[data-theme="aurora"][data-accent="ocean"] { background: #38bdf8; }
.swatch[data-theme="studio"][data-accent="ink"] { background: #14233a; }
.swatch[data-theme="studio"][data-accent="crimson"] { background: #b4232c; }
.swatch[data-theme="studio"][data-accent="cobalt"] { background: #1d4ed8; }
.swatch[data-theme="poster"][data-accent="red"] { background: #e8462f; }
.swatch[data-theme="poster"][data-accent="cobalt"] { background: #2547f0; }
.swatch[data-theme="poster"][data-accent="sun"] { background: #f5c12e; }
.swatch[data-theme="poster"][data-accent="paper"] { background: #e7e7e4; }
.swatch[data-theme="terminal"][data-accent="amber"] { background: #ffb547; }
.swatch[data-theme="terminal"][data-accent="green"] { background: #7ff0a8; }
.swatch[data-theme="terminal"][data-accent="ice"] { background: #a5dcff; }
.swatch[data-theme="velvet"][data-accent="champagne"] { background: #e9cfa4; }
.swatch[data-theme="velvet"][data-accent="rose"] { background: #f2b5a7; }
.swatch[data-theme="velvet"][data-accent="pearl"] { background: #e6e2ee; }

/* ---------- Buttons nobody switches off here ---------- */
.pd-always { margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-deep); font-size: 14px; line-height: 1.5; }
.pd-always p { margin: 0; color: var(--text-2); }
.pd-always p + p { margin-top: 6px; color: var(--text); font-weight: 500; }

/* ---------- Creator page defaults (web/admin-links.js): warnings, platform buttons, reserve bots ---------- */
.pd-warnings { display: grid; gap: 8px; margin: 14px 0 6px; }
.pd-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 11px 14px;
  border: 1px solid rgb(228 174 79 / .45);
  border-radius: var(--radius-sm);
  background: rgb(228 174 79 / .08);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.pd-warning::before { content: ""; width: 8px; height: 8px; flex: none; margin-top: 7px; border-radius: 50%; background: var(--warn); }
.pd-warning.is-danger { border-color: rgb(242 122 111 / .5); background: rgb(242 122 111 / .09); }
.pd-warning.is-danger::before { background: var(--danger); }
dialog p.pd-warning { color: var(--text); }
.pd-support { margin: 12px 0 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg-deep); color: var(--text); font-size: 14px; line-height: 1.5; }
.pd-support strong { font-weight: 600; }
dialog p.pd-support { color: var(--text); }
.pd-extra { margin-top: 14px; }
.editor-section .pd-extra > legend { float: none; width: auto; margin: 0; color: var(--text); font-size: 14px; font-weight: 600; }
.pd-url { color: var(--text-2); font-family: var(--font-mono); font-size: 13px; overflow-wrap: anywhere; }
.pd-missing { color: var(--warn); }
.check-row small.pd-missing { color: var(--warn); }
.check-row small.pd-ok, .pd-ok { color: var(--ok); }
.check-row small.pd-down, .pd-down { color: var(--danger); }

@media (min-width: 620px) {
  dialog:has(.page-design) { width: min(1000px, calc(100vw - 24px)); }
  .page-design-link { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
  .pd-themes {
    --pd-s: .34;
    grid-auto-flow: row;
    grid-template-columns: repeat(auto-fill, calc(390px * var(--pd-s)));
    gap: 18px 12px;
    margin: 14px 0 0;
    padding: 0;
    overflow: visible;
    scroll-snap-type: none;
  }
}
@media (min-width: 900px) {
  .page-design { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  .page-design-preview { position: sticky; top: 0; }
}
