/* PosterMu — posterfy-inspired dark UI */

:root {
  --bg: #0a0a0d;
  --bg-2: #101014;
  --panel: #141419;
  --panel-2: #1c1c23;
  --border: #26262e;
  --border-soft: #1e1e26;
  --text: #f2f2f4;
  --muted: #9b9ba6;
  --accent: #1db954;
  --accent-2: #23d162;
  --accent-dim: rgba(29, 185, 84, 0.14);
  --error: #ff5c5c;
  --radius: 16px;
  --radius-sm: 10px;

  /* Global UI scale. The whole interface is drawn 1.2x so it doesn't read as
     "zoomed out" at 100% browser zoom. `zoom` scales px/rem exactly like the
     browser's own zoom does, but it does NOT compensate viewport units — a
     100vh box renders 1.2x the viewport — so every vh/vw value below goes
     through --vh/--vw instead. Same reason app.js divides window.innerHeight
     by --ui-scale (clientWidth/offsetWidth are already in scaled units, only
     the window.* viewport reads are raw). @media breakpoints can't read a var,
     so those are written pre-multiplied with the raw value in a comment. */
  --ui-scale: 1.2;
  --vh: calc(1vh / var(--ui-scale));
  --vw: calc(1vw / var(--ui-scale));
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  color-scheme: dark;
  zoom: var(--ui-scale);
}

body {
  background:
    radial-gradient(900px 480px at 50% -140px, rgba(29, 185, 84, 0.13), transparent 65%),
    var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  min-height: calc(100 * var(--vh));
}

button { font-family: inherit; }
::selection { background: var(--accent-dim); }

/* ------------------------------------------------ nav */

nav {
  display: flex;
  align-items: center;
  padding: 20px 32px;
  max-width: 1500px;
  margin: 0 auto;
  /* the links and the account group are separate elements (so a phone can
     collapse only the first); margin-left:auto on .nav-right keeps the pair
     hard right, exactly where space-between used to put the single group. */
  gap: 10px;
}
.logo {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 2.5px;
  cursor: pointer;
  user-select: none;
}
.logo span { color: var(--accent); }
.icon-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  font-size: 0.88rem;
  transition: border-color .15s, background .15s;
}
.icon-btn:hover { border-color: var(--accent); }

/* ------------------------------------------------ hero */

#hero {
  max-width: 860px;
  margin: 0 auto;
  padding: 44px 24px 60px;
  text-align: center;
}
#hero h1 {
  font-size: clamp(2.6rem, calc(7 * var(--vw)), 4.6rem);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -1px;
  text-transform: uppercase;
}
#hero h1 em { font-style: normal; color: var(--accent); }
#hero .sub {
  color: var(--muted);
  margin: 18px auto 34px;
  font-size: 1.02rem;
  max-width: 560px;
  line-height: 1.6;
}

.type-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 26px;
}
.chip {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.86rem;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: #3a3a44; }
.chip.selected {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-2);
  font-weight: 600;
}

.search-row {
  display: flex;
  gap: 10px;
  max-width: 640px;
  margin: 0 auto;
}
.search-row input {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 15px 24px;
  color: var(--text);
  font-size: 0.98rem;
  transition: border-color .15s, box-shadow .15s;
}
.search-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.cta {
  background: var(--accent);
  color: #06130a;
  border: none;
  border-radius: 999px;
  padding: 15px 30px;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.cta:hover:not(:disabled) { background: var(--accent-2); transform: translateY(-1px); }
.cta:disabled { opacity: 0.45; cursor: not-allowed; }

.hint { color: var(--muted); font-size: 0.84rem; margin-top: 12px; min-height: 1.2em; }
/* The hint doubles as the validation message: every type takes a link and
   only a link, so the box says which one as soon as the text can't be it. */
.hint.bad { color: var(--error); }
.hint.bad .hint-link { color: var(--error); }

/* ------------------------------------------------ status bar */

.status {
  display: none;
  align-items: center;
  gap: 12px;
  max-width: 640px;
  margin: 22px auto 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  font-size: 0.9rem;
  text-align: left;
}
.status.visible { display: flex; }
.status.error { color: var(--error); border-color: rgba(255, 92, 92, .4); }
.status.done { color: var(--accent-2); border-color: rgba(29, 185, 84, .4); }
.spinner {
  width: 16px; height: 16px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------ studio */

#studio {
  display: none;
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 24px 48px;
}
#studio.open { display: block; }

.studio-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 4px 18px;
  flex-wrap: wrap;
}
.studio-head img {
  width: 46px; height: 46px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--panel-2);
}
.studio-head .t { font-weight: 700; font-size: 1.05rem; }
.studio-head .s { color: var(--muted); font-size: 0.86rem; margin-top: 2px; }
.studio-head .back {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.86rem;
}
.studio-head .back:hover { color: var(--text); }

.studio-grid {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}
/* 1080px x --ui-scale */
@media (max-width: 1296px) {
  .studio-grid { grid-template-columns: 1fr; }
}

/* templates rail */
.rail {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
  max-height: calc(100 * var(--vh) - 150px);
  overflow-y: auto;
}
.rail h3, .panel h3 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: var(--muted);
  margin-bottom: 12px;
}
.tcard {
  width: 100%;
  background: var(--panel-2);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .15s;
  text-align: left;
  color: var(--text);
  padding: 0;
  display: block;
}
.tcard:hover { border-color: #3a3a44; }
.tcard.selected { border-color: var(--accent); }
.tcard .ph {
  width: 100%;
  aspect-ratio: 2 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 900;
  color: #3c3c46;
  background: repeating-linear-gradient(45deg, #17171d, #17171d 12px, #191920 12px, #191920 24px);
}
.tcard img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; display: block; }
/* landscape templates are 3:2 — match the card to the art instead of
   cropping the middle out of it (see tagLandscapeThumbs in app.js) */
.tcard img.is-landscape,
.pcard .pthumb.is-landscape { aspect-ratio: 3 / 2; }
.tcard .cap {
  padding: 8px 10px;
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.tcard .cap .badge {
  font-size: 0.66rem;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
}
.tcard .cap .badge.ready { color: var(--accent-2); border-color: rgba(29,185,84,.4); }
.tcard.parsing .cap .badge { color: #eabb5a; border-color: rgba(234,187,90,.4); }
.upload-card {
  width: 100%;
  border: 1.5px dashed var(--border);
  background: none;
  border-radius: var(--radius-sm);
  color: var(--muted);
  padding: 16px 10px;
  cursor: pointer;
  font-size: 0.82rem;
  transition: all .15s;
}
.upload-card:hover { border-color: var(--accent); color: var(--accent-2); }
.upload-card .uc-sub {
  display: block;
  margin-top: 3px;
  font-size: 0.72rem;
  opacity: 0.72;
}

/* canvas stage */
.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-height: 400px;
  justify-content: center;
}
#poster-canvas {
  max-width: 100%;
  border-radius: 6px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .55);
  background: #0f0f13;
  touch-action: none; /* finger-drag moves text, not the page */
  /* no drag-to-desktop, no long-press "Save image" sheet on mobile */
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}
.stage-note {
  color: var(--muted);
  font-size: 0.84rem;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: center;
  max-width: 460px;
  line-height: 1.55;
}

/* controls panel */
.panel {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  max-height: calc(100 * var(--vh) - 150px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-soft);
}
.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  padding: 14px 4px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-2); border-bottom-color: var(--accent); }
.panel-body { overflow-y: auto; padding: 16px; flex: 1; }

.lgroup {
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
}
/* per-box reset, sits at the right end of a group header */
.reset-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 6px;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.reset-btn:hover { color: var(--text); background: var(--bg-2); }

/* Reset button sits above the first group box, right-aligned */
.reset-row {
  margin-top: 0;
  margin-bottom: 10px;
  justify-content: flex-end;
}

/* scope switcher inside a group box (Design tab's TEXT box) */
.subtabs {
  display: flex;
  gap: 4px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  margin-bottom: 10px;
}
.subtab {
  flex: 1;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--muted);
  padding: 6px 4px;
  font-size: 0.76rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.subtab:hover { color: var(--text); }
.subtab.active { color: var(--text); background: var(--panel-2); }

.lgroup .lhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.lgroup .lname {
  font-size: 0.72rem;
  letter-spacing: 1.2px;
  color: var(--muted);
  font-weight: 700;
}
.lgroup textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.88rem;
  font-family: inherit;
  padding: 9px 11px;
  resize: vertical;
  min-height: 38px;
  line-height: 1.45;
}
.lgroup textarea:focus { outline: none; border-color: var(--accent); }
.lrow {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.lrow label { font-size: 0.72rem; color: var(--muted); }
.lrow input[type="number"] {
  width: 68px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 8px;
  font-size: 0.82rem;
}
.lrow select {
  flex: 1;
  min-width: 90px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 8px;
  font-size: 0.8rem;
}
.eye {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  opacity: 0.9;
}
.eye.off { opacity: 0.3; }

/* range sliders (image adjustments, fade position) */
.srow { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.srow label {
  font-size: 0.72rem;
  color: var(--muted);
  width: 52px;
  flex-shrink: 0;
}
.srow input[type="range"] { flex: 1; accent-color: var(--accent); min-width: 0; }
.srow .sval {
  font-size: 0.72rem;
  color: var(--muted);
  width: 44px;
  text-align: right;
  flex-shrink: 0;
}

/* palette swatches */
.swatch {
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 0;
  transition: transform .1s, border-color .1s;
  flex-shrink: 0;
}
.swatch:hover { transform: scale(1.15); border-color: rgba(255, 255, 255, .45); }
.color-row { flex-wrap: wrap; gap: 6px; }

/* ---------------------------------------------------- color picker (cpick)
   One pill per color: the current color on the left, its own eyedropper on
   the right, sharing a single border so it reads as one control. Clicking the
   color opens .cpop — our own picker, so there's no native OS colour window
   and the dropper can live inside it (Firefox's dialog has no dropper). */
.cpick {
  display: inline-flex;
  align-items: stretch;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg-2);
  overflow: hidden;
  flex-shrink: 0;
}
.cpick:hover, .cpick.open { border-color: var(--accent); }
.cpick button {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  cursor: pointer;
}
.cpick .cpick-swatch {
  width: 32px;
  display: flex;
  padding: 3px;
}
.cpick-chip {
  flex: 1;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .4);
}
.cpick .cpick-eye {
  width: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid var(--border);
  color: var(--muted);
}
.cpick .cpick-eye:hover { color: var(--accent); background: rgba(29, 185, 84, .16); }
/* armed = waiting for a click on the poster */
.cpick.armed { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(29, 185, 84, .3); }
.cpick.armed .cpick-eye { color: var(--accent); background: rgba(29, 185, 84, .22); }

.cpop {
  position: fixed;
  z-index: 200;              /* over the studio panel + modals, under .toast */
  width: 236px;
  padding: 11px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, .6);
}
.cpop-sv {
  position: relative;
  height: 130px;
  border-radius: 8px;
  cursor: crosshair;
  touch-action: none;        /* so a drag picks a color instead of scrolling */
  outline: none;
}
.cpop-sv:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.cpop-knob {
  position: absolute;
  width: 14px; height: 14px;
  margin: -7px 0 0 -7px;     /* centred on its %, without a transform */
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .65);
  pointer-events: none;
}
.cpop-hue {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 14px;
  margin: 0;
  border-radius: 7px;
  touch-action: none;
  background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%,
    #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
}
.cpop-hue::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 18px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .55);
  cursor: pointer;
}
.cpop-hue::-moz-range-track { height: 14px; background: transparent; border: none; }
.cpop-hue::-moz-range-thumb {
  width: 10px; height: 18px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .55);
  cursor: pointer;
}
.cpop-hue:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cpop-row { display: flex; gap: 6px; align-items: center; }
.cpop-eye {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font: inherit;
  font-size: 0.7rem;
  cursor: pointer;
}
.cpop-eye:hover { border-color: var(--accent); color: var(--accent); }
.cpop-hex {
  width: 82px;
  padding: 6px 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-size: 0.78rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.cpop-hex:focus { outline: none; border-color: var(--accent); }
.cpop-lab {
  font-size: 0.6rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 2px;
}
.cpop-sw { display: flex; flex-wrap: wrap; gap: 6px; }
.cpop-sw .swatch { width: 20px; height: 20px; }

/* narrow screens: the popover becomes a bottom sheet with bigger targets */
@media (max-width: 620px) {
  .cpick { height: 34px; }
  .cpick .cpick-swatch { width: 38px; }
  .cpick .cpick-eye { width: 30px; }
  .cpop.sheet {
    left: 10px;
    right: 10px;
    bottom: 10px;
    top: auto;
    width: auto;
    padding: 14px;
  }
  .cpop.sheet .cpop-sv { height: 170px; }
  .cpop.sheet .cpop-hue { height: 20px; border-radius: 10px; }
  .cpop.sheet .cpop-sw .swatch { width: 26px; height: 26px; }
}
.lgroup.selected { border-color: var(--accent); }

/* per-layer extras */
.fit-badge {
  font-size: 0.64rem;
  color: #eabb5a;
  margin-left: auto;
  margin-right: 8px;
  white-space: nowrap;
}
.gear {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  opacity: 0.55;
  margin-right: 2px;
}
.gear:hover { opacity: 1; }
.adv {
  display: none;
  border-top: 1px dashed var(--border-soft);
  margin-top: 10px;
  padding-top: 2px;
}
.lgroup.adv-open .adv { display: block; }
.lrow input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }
.lrow input[type="text"] {
  flex: 1;
  min-width: 80px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 8px;
  font-size: 0.82rem;
}
.lrow input[type="text"]:focus { outline: none; border-color: var(--accent); }

/* toggles */
.checkrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.82rem;
  cursor: pointer;
  flex-wrap: wrap;
}
.checkrow input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }
.checkrow .sub { color: var(--muted); font-size: 0.72rem; }

/* tracklist editor */
.trackrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 6px 9px;
}
.trackrow .handle {
  cursor: grab;
  color: var(--muted);
  font-size: 0.9rem;
  user-select: none;
  flex-shrink: 0;
}
.trackrow .tracknum {
  color: var(--muted);
  font-size: 0.76rem;
  min-width: 20px;
  text-align: right;
  flex-shrink: 0;
}
.trackrow input {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.85rem;
}
.trackrow input:focus { outline: none; }
.trackrow .del {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.trackrow .del:hover { color: var(--error); }
.trackrow.dragover { border-color: var(--accent); }
.trackrow.dragging { opacity: 0.4; }
.trackrow.add { border-style: dashed; }

/* segmented pickers (export format / size) */
.seg { display: flex; gap: 6px; margin: 8px 0 12px; flex-wrap: wrap; }
.seg button {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 8px 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all .15s;
}
.seg button:hover { color: var(--text); }
.seg button.active {
  border-color: var(--accent);
  color: var(--accent-2);
  background: var(--accent-dim);
  font-weight: 600;
}

.img-slot { display: flex; gap: 12px; align-items: center; }
.img-slot img {
  width: 62px; height: 62px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
}
/* transparent slots (e.g. the Spotify code) look wrong boxed — show them bare */
.img-slot img.bare {
  object-fit: contain;
  background: none;
  border: none;
}
.img-slot .meta { flex: 1; min-width: 0; }
.small-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color .15s;
}
.small-btn:hover { border-color: var(--accent); }

.export-block { margin-bottom: 18px; }
.export-block p { color: var(--muted); font-size: 0.82rem; line-height: 1.55; margin: 8px 0 12px; }
.big-btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all .15s;
}
.big-btn.primary { background: var(--accent); color: #06130a; }
.big-btn.primary:hover:not(:disabled) { background: var(--accent-2); }
.big-btn.ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
}
.big-btn.ghost:hover:not(:disabled) { border-color: var(--accent); }
.big-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.export-status { font-size: 0.8rem; color: var(--muted); margin-top: 10px; word-break: break-all; line-height: 1.5; }
.export-status.error { color: var(--error); }
.export-status.done { color: var(--accent-2); }

.empty-note {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.65;
  padding: 8px 2px;
}
.empty-note code {
  background: var(--panel-2);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.78rem;
}

/* ------------------------------------------------ modal */

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  backdrop-filter: blur(3px);
  justify-content: center;
  align-items: center;
  z-index: 40;
}
.overlay.open { display: flex; }
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: min(540px, calc(92 * var(--vw)));
  max-height: calc(88 * var(--vh));
  overflow-y: auto;
}
.modal h2 { font-size: 1.1rem; margin-bottom: 20px; }
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 5px; }
.field input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 13px;
  color: var(--text);
  font-size: 0.9rem;
}
.field input:focus { outline: none; border-color: var(--accent); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

footer {
  text-align: center;
  color: #55555f;
  font-size: 0.78rem;
  padding: 30px 20px 40px;
}
footer .credit { margin-top: 5px; }

/* "find it on X ↗" under the search box, and "get a key ↗" in Settings —
   quiet by default, only picking up color on hover */
.hint-link, .key-link {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}
.hint-link:hover, .key-link:hover { color: var(--accent-2); }
.key-link {
  font-size: 0.72rem;
  font-weight: 400;
  text-decoration: none;
  margin-left: 4px;
}
.key-link:hover { text-decoration: underline; }

/* ------------------------------------------------ account / nav */

.nav-right { display: flex; gap: 10px; align-items: center; margin-left: auto; }
.nav-account { display: flex; gap: 10px; align-items: center; }
.nav-signup { padding: 9px 18px; font-size: 0.88rem; }

/* Both only exist for the phone drawer — see the mobile section at the end. */
.nav-toggle { display: none; }
.nav-menu-login { display: none; }
.nav-scrim { display: none; }
.avatar-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  transition: transform .1s, box-shadow .15s;
  flex-shrink: 0;
}
.avatar-btn:hover { transform: scale(1.06); box-shadow: 0 0 0 3px var(--accent-dim); }

/* ------------------------------------------------ profile */

#profile {
  display: none;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 24px 60px;
}
#profile.open { display: block; }

.profile-head {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 10px 0 28px;
}
.pfp {
  width: 88px; height: 88px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  font-weight: 800;
  color: #fff;
  background: var(--accent);
  flex-shrink: 0;
  user-select: none;
  background-size: cover;
  background-position: center;
}
.pfp.editable { cursor: pointer; transition: box-shadow 0.15s ease; }
.pfp.editable:hover { box-shadow: 0 0 0 3px var(--accent-dim); }
.pname { font-size: 1.65rem; font-weight: 800; }
.phandle { color: var(--muted); margin-top: 2px; font-size: 0.95rem; }
.pactions { margin-left: auto; display: flex; gap: 10px; }

.ptabs {
  display: flex;
  gap: 26px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 18px;
}
.ptab {
  background: none;
  border: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 12px 2px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s;
}
.ptab:hover { color: var(--text); }
.ptab.active { color: var(--accent-2); border-bottom-color: var(--accent); }

.pfilters { display: none; gap: 8px; margin-bottom: 20px; }
.pfilters.visible { display: flex; }

.pgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}
.pcard {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.pcard .pthumb {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
  cursor: pointer;
  background: repeating-linear-gradient(45deg, #17171d, #17171d 12px, #191920 12px, #191920 24px);
  border: none;
  padding: 0;
}
.pcard .pbody { padding: 10px 12px 12px; }
.pcard .pt {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pcard .pm { color: var(--muted); font-size: 0.74rem; margin-top: 3px; }
.pcard .prow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.vis-badge {
  font-size: 0.66rem;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}
.vis-badge.public { color: var(--accent-2); border-color: rgba(29, 185, 84, .4); }
.heart-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.86rem;
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 0;
}
.heart-btn:hover { color: var(--text); }
.heart-btn.faved { color: #ff5c8a; }
.pcard .mini {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 0;
  margin-left: auto;
}
.pcard .mini + .mini { margin-left: 0; }
.pcard .mini:hover { color: var(--text); }
.pcard .mini.danger:hover { color: var(--error); }

.profile-empty {
  text-align: center;
  color: var(--muted);
  padding: 70px 20px;
  font-size: 0.95rem;
  line-height: 1.7;
}
.profile-empty .big { font-size: 2.8rem; margin-bottom: 12px; }
.profile-empty a { color: var(--accent-2); cursor: pointer; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}
.stat-tile {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 18px;
}
.stat-tile .v { font-size: 1.9rem; font-weight: 600; }
.stat-tile .l { color: var(--muted); font-size: 0.78rem; margin-top: 4px; }
.stat-tile .h { color: var(--muted); font-size: 0.7rem; margin-top: 6px; opacity: .7; }

/* export-format breakdown under the poster stats */
.fmt-bars { margin: 14px 0 4px; display: flex; flex-direction: column; gap: 8px; }
.fmt-bar { display: flex; align-items: center; gap: 10px; font-size: 0.76rem; }
.fmt-bar .fb-name { width: 44px; color: var(--muted); font-weight: 600; }
.fmt-bar .fb-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--border-soft);
  overflow: hidden;
}
.fmt-bar .fb-fill { display: block; height: 100%; background: var(--accent); }
.fmt-bar .fb-n { width: 34px; text-align: right; color: var(--muted); }

.stat-foot { color: var(--muted); font-size: 0.8rem; margin-top: 22px; }
.stat-foot b { color: var(--text); font-weight: 600; }

/* divides the visibility chips from the format chips in one filter row */
.chip-sep {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  margin: 2px 6px;
}
.pfilters.visible { display: flex; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------ gallery */

#gallery {
  display: none;
  max-width: 1300px;
  margin: 0 auto;
  padding: 16px 24px 60px;
}
#gallery.open { display: block; }

.gallery-head {
  position: relative;
  text-align: center;
  padding: 10px 0 26px;
}
.gallery-head h2 { font-size: 1.8rem; font-weight: 800; }
.gallery-head .sub { color: var(--muted); margin-top: 8px; font-size: 0.95rem; }
.gallery-head .back {
  position: absolute;
  left: 0;
  top: 14px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.86rem;
}
.gallery-head .back:hover { color: var(--text); }

/* "by @user" attribution on gallery cards */
.pcard .pbody .by {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
}
.dm-by { color: var(--muted); font-size: 0.82rem; margin-top: 4px; }
.dm-by b { color: var(--text); }

.browse-link { margin-top: 16px; font-size: 0.86rem; }
.browse-link a { color: var(--muted); cursor: pointer; }
.browse-link a:hover { color: var(--accent-2); }

.design-card {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--border-soft);
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.design-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.design-card .pthumb.ph-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #3c3c46;
  background: repeating-linear-gradient(45deg, #17171d, #17171d 12px, #191920 12px, #191920 24px);
  text-align: center;
  padding: 10px;
}

/* ------------------------------------------------ pricing */

#pricing {
  display: none;
  max-width: 880px;
  margin: 0 auto;
  padding: 16px 24px 60px;
}
#pricing.open { display: block; }

.plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 22px;
  align-items: stretch;
  margin-top: 8px;
}
.plan-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 26px 24px 22px;
  display: flex;
  flex-direction: column;
}
.plan-card.featured {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(29, 185, 84, 0.09), transparent 55%), var(--panel);
}
.plan-badge {
  position: absolute;
  top: -11px;
  right: 18px;
  background: var(--accent);
  color: #06130a;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  border-radius: 999px;
  padding: 4px 12px;
}
.plan-name { font-weight: 700; font-size: 1.02rem; }
.plan-price { font-size: 2.6rem; font-weight: 800; margin: 6px 0 2px; }
.plan-price span { font-size: 0.9rem; color: var(--muted); font-weight: 500; }
.plan-tag { color: var(--muted); font-size: 0.84rem; margin-bottom: 16px; }
.plan-feat { list-style: none; margin: 0 0 22px; flex: 1; }
.plan-feat li {
  padding: 7px 0 7px 26px;
  position: relative;
  font-size: 0.88rem;
  border-top: 1px solid var(--border-soft);
}
.plan-feat li:first-child { border-top: none; }
.plan-feat li::before {
  content: "✓";
  position: absolute;
  left: 2px;
  color: var(--accent-2);
  font-weight: 700;
}
.plan-fine { color: var(--muted); font-size: 0.74rem; text-align: center; margin-top: 10px; }
.pay-banner {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.88rem;
  margin-bottom: 18px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
}
.pay-banner.error {
  background: rgba(255, 92, 92, 0.08);
  border-color: var(--error);
  color: var(--error);
}
#pricing .auth-note { margin-bottom: 18px; }
.pemail .pro { color: var(--accent-2); font-weight: 600; }
.locked-note { color: var(--muted); font-size: 0.8rem; margin-top: 8px; }
.locked-note a { color: var(--accent-2); cursor: pointer; }
/* the use limit under the Download button — quieter than the balance line
   above it, but on the same panel that produces the file */
.use-limit {
  border-top: 1px solid var(--border-soft);
  padding-top: 8px;
  font-size: 0.74rem;
  line-height: 1.5;
}

/* ------------------------------------------------ terms & data sources

   One boxed style for "here's a limit you should know about", used in the
   settings modal, on the pricing page and at the top of the terms page. */
.notice {
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--muted);
}
.notice b { color: var(--text); font-weight: 700; }
.notice a { color: var(--accent-2); cursor: pointer; }
.notice-legal {
  border-color: rgba(255, 176, 74, 0.32);
  background: rgba(255, 176, 74, 0.07);
}
.notice-ok {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--text);
}
#pricing .notice-legal { margin-top: 22px; text-align: left; }

/* the agreement checkbox: signup, settings, and the gate modal */
.terms-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 14px 0 4px;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--muted);
  cursor: pointer;
}
.terms-check input {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
}
/* Keep "Read the terms →" whole: the arrow belongs to the phrase, and a line
   break before it leaves a stray → on its own line. Wraps before the link
   instead. Same for the hero note's link below. */
.terms-check a { color: var(--accent-2); cursor: pointer; white-space: nowrap; }

.terms-modal { max-width: 620px; }
.terms-rules {
  list-style: none;
  margin: 12px 0 0;
  display: grid;
  gap: 8px;
}
.terms-rules li {
  position: relative;
  padding-left: 22px;
  font-size: 0.85rem;
  line-height: 1.6;
}
.terms-rules li::before {
  content: "✔";
  position: absolute;
  left: 2px;
  color: var(--accent-2);
  font-weight: 700;
}
.terms-sources {
  margin-top: 14px;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--muted);
}
.terms-sources b { color: var(--text); }
.terms-sources a { color: var(--accent-2); cursor: pointer; }

#legal {
  display: none;
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 24px 60px;
}
#legal.open { display: block; }
#legal .notice { margin-bottom: 22px; }
.legal-block { margin-bottom: 30px; }
.legal-block h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 10px; }
.legal-block p {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.7;
  margin-bottom: 10px;
}
.legal-block b { color: var(--text); }
.legal-block .terms-rules { margin-bottom: 12px; }
.legal-fine { font-size: 0.78rem !important; color: #6f6f7a !important; }

/* The provider list: one scannable row per source, our summary behind a
   disclosure. This replaced a 3-column table — the table needed a 620px
   min-width and so scrolled sideways on a phone; a flex row just wraps. */
.src-list { border-top: 1px solid var(--border-soft); margin-bottom: 14px; }
.src-item { border-bottom: 1px solid var(--border-soft); }
.src-item > summary {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px 10px;
  padding: 11px 6px;
  font-size: 0.82rem;
  cursor: pointer;
  list-style: none;                 /* our own chevron, below */
}
.src-item > summary::-webkit-details-marker { display: none; }
.src-item > summary::before {
  content: "▸";
  width: 9px;
  color: var(--muted);
  font-size: 0.66rem;
}
.src-item[open] > summary::before { content: "▾"; }
.src-item > summary:hover { background: var(--panel-2); }
.src-name { color: var(--text); font-weight: 700; }
/* takes the slack so the provider's terms link lands on the right edge */
.src-types { color: var(--muted); font-size: 0.76rem; flex: 1 1 110px; }
.src-key {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  font-size: 0.68rem;
}
.src-link { font-size: 0.76rem; white-space: nowrap; }
.src-body {
  padding: 0 6px 14px 25px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.65;
}
/* required attributions — small, but always on screen */
.src-credits {
  columns: 2;
  column-gap: 26px;
  /* the global reset zeroes list padding, so the discs need it back */
  padding-left: 20px;
  margin: 0 0 4px;
  color: #6f6f7a;
  font-size: 0.74rem;
  line-height: 1.55;
}
.src-credits li { break-inside: avoid; margin-bottom: 4px; }
@media (max-width: 640px) { .src-credits { columns: 1; } }
#legal .notice-legal,
#legal .notice-ok {
  border-color: var(--border);
  background: var(--panel);
  color: var(--muted);
}
#legal .notice-ok b, #legal .notice-legal b { color: var(--text); }
#legal .terms-rules li::before { color: var(--muted); font-weight: 600; }

/* the one-liner under the hero search box, and the footer's legal row */
.use-note {
  margin-top: 16px;
  color: #6f6f7a;
  font-size: 0.76rem;
  line-height: 1.6;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
}
.use-note a {
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
}
.use-note a:hover { color: var(--accent-2); }
.foot-legal { margin-top: 8px; }
.foot-legal a { color: #7b7b86; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.foot-legal a:hover { color: var(--accent-2); }
.foot-legal .dot { margin: 0 6px; }

/* pricing: multi-plan additions */
.plan-badge.alt { background: var(--accent-2); color: #06130a; }
.plan-card .big-btn { margin-top: auto; }
.pack-btns { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.pack-btns .big-btn { margin-top: 0; }
.pack-btns .per { color: var(--muted); font-weight: 500; font-size: 0.8em; }
.account-billing {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 18px;
  font-size: 0.88rem;
}
.account-billing .ab-lines { display: flex; flex-direction: column; gap: 3px; }
.account-billing .ab-lines div:not(:first-child) { color: var(--muted); font-size: 0.82rem; }

/* ------------------------------------------------ auth modal */

.auth-modal { width: min(420px, calc(92 * var(--vw))); }
.auth-error { color: var(--error); font-size: 0.82rem; min-height: 1.2em; margin-top: 2px; }
.auth-error.ok { color: var(--accent-2); }
.auth-switch {
  text-align: center;
  color: var(--muted);
  font-size: 0.84rem;
  margin-top: 18px;
}
.auth-switch a { color: var(--accent-2); cursor: pointer; }
.auth-row { text-align: right; margin: -6px 0 4px; }
.auth-row a { color: var(--muted); font-size: 0.78rem; cursor: pointer; }
.auth-row a:hover { color: var(--accent-2); }
.auth-note {
  background: var(--panel-2);
  border: 1px solid rgba(234, 187, 90, .4);
  color: #eabb5a;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.82rem;
  line-height: 1.5;
  margin-bottom: 14px;
}
.auth-note code { font-size: 0.76rem; }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.76rem;
  margin: 16px 0 12px;
}
.auth-divider::before, .auth-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border-soft);
}
.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.pemail { color: var(--muted); font-size: 0.8rem; margin-top: 4px; }
.pemail .ok { color: var(--accent-2); }
.verify-note {
  background: var(--panel);
  border: 1px solid rgba(234, 187, 90, .4);
  color: #eabb5a;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.86rem;
  margin: -8px 0 22px;
  line-height: 1.6;
}
.verify-note a { color: var(--accent-2); cursor: pointer; }
.verify-note b { color: inherit; }

/* ---------------------------------------------- design preview modal */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.66);
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: calc(90 * var(--vh));
  overflow-y: auto;
  width: 100%;
}
.design-modal { max-width: 880px; padding: 20px 22px 24px; }

.dm-head { display: flex; align-items: flex-start; gap: 14px; }
.dm-title { flex: 1; min-width: 0; }
.dm-title h3 { font-size: 1.15rem; }
.dm-sub { color: var(--muted); font-size: 0.82rem; margin-top: 3px; }
.dm-rate { margin-top: 8px; font-size: 0.9rem; color: var(--text); }
.dm-rate .rc, .rate .rc { color: var(--muted); font-weight: 400; }

.dm-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  margin-top: 16px;
}
/* 720px x --ui-scale */
@media (max-width: 864px) { .dm-main { grid-template-columns: 1fr; } }

.dm-preview {
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dm-preview img { max-width: 100%; max-height: calc(58 * var(--vh)); border-radius: 4px; display: block; }

.dm-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.primary-btn {
  background: var(--accent);
  border: none;
  color: #06210f;
  font-weight: 700;
  font-size: 0.9rem;
  font-family: inherit;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
}
.primary-btn:hover { background: var(--accent-2); }

.dm-rv-head {
  font-size: 0.72rem;
  letter-spacing: 1.2px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.dm-reviews { min-width: 0; }
.dm-review {
  border-top: 1px solid var(--border-soft);
  padding: 10px 0;
}
.dm-review.mine { border-left: 2px solid var(--accent); padding-left: 10px; }
.dm-rv-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.dm-rv-who { font-size: 0.85rem; font-weight: 600; }
.dm-rv-stars { color: var(--accent-2); font-size: 0.85rem; white-space: nowrap; }
.dm-rv-body { color: var(--muted); font-size: 0.85rem; line-height: 1.5; margin-top: 4px; }
.dm-rv-date { color: var(--muted); font-size: 0.72rem; margin-top: 4px; }

.dm-write { margin-top: 16px; border-top: 1px solid var(--border-soft); padding-top: 14px; }
.dm-write textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.86rem;
  padding: 9px 11px;
  resize: vertical;
  margin-bottom: 8px;
}
.dm-write textarea:focus { outline: none; border-color: var(--accent); }
.dm-stars { display: flex; gap: 2px; margin-bottom: 8px; }
.dm-star {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.dm-star.on, .dm-star:hover { color: var(--accent-2); }
.dm-msg { color: var(--muted); font-size: 0.78rem; }

/* rating line on the gallery cards */
.rate { color: var(--accent-2); }
.rate.none { color: var(--muted); }

/* =========================================================================
   MARKETPLACE — gallery toolbar, listing cards, creator pages, publishing
   ========================================================================= */

/* ------------------------------------------------ gallery toolbar */

/* Browse / My designs. The underline runs the full content width — the card
   grid and type chips, not the narrower .market-bar column. */
.gtabs { margin-bottom: 18px; }

.market-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  max-width: 1180px;
  margin: 0 auto 16px;
  padding: 0 40px;
}

.market-bar input[type="search"] {
  flex: 1;
  min-width: 220px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  padding: 10px 16px;
  font-size: 0.88rem;
  font-family: inherit;
}
.market-bar input[type="search"]:focus { outline: none; border-color: var(--accent); }

.market-bar select {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  padding: 10px 14px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
}
.market-bar select:focus { outline: none; border-color: var(--accent); }

.market-bar .market-submit { padding: 10px 18px; font-size: 0.85rem; }

.seg {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.on { background: var(--accent-dim); color: var(--accent-2); }

.market-count {
  max-width: 1180px;
  margin: 0 auto 10px;
  padding: 0 40px;
  color: var(--muted);
  font-size: 0.78rem;
}

/* ------------------------------------------------ listing cards */

.pcard .pthumb-wrap { position: relative; display: block; }

.dbadge {
  display: inline-block;
  font-size: 0.64rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(10, 10, 13, 0.82);
  color: var(--muted);
  backdrop-filter: blur(4px);
}
.pthumb-wrap .dbadge { position: absolute; top: 8px; left: 8px; }
/* the export format sits opposite the marketplace badge, so both can show */
.pthumb-wrap .dbadge.fmt { left: auto; right: 8px; color: var(--text); }
.pthumb-wrap .dbadge.fmt.none {
  border-style: dashed;
  color: var(--muted);
  text-transform: none;
  font-weight: 600;
}
.dbadge.community { color: var(--accent-2); border-color: rgba(29, 185, 84, 0.4); }
.dbadge.official { color: #8fb4ff; border-color: rgba(79, 140, 255, 0.35); }
.dbadge.pending { color: #ffcc66; border-color: rgba(255, 204, 102, 0.35); }
.dbadge.review { color: #8fb4ff; border-color: rgba(143, 180, 255, 0.4); }
.dbadge.broken { color: var(--error); border-color: rgba(255, 92, 92, 0.4); }

.pcard .psub { color: var(--muted); font-size: 0.72rem; margin-top: 2px; }
.dstats { display: flex; gap: 10px; margin-top: 5px; }
.dstat { color: var(--muted); font-size: 0.72rem; }

/* ------------------------------------------------ listing modal */

.dm-tagline { color: var(--text); font-size: 0.92rem; margin-top: 5px; opacity: 0.9; }
.dm-title .dbadge { margin-bottom: 8px; }
.dm-label {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 6px;
}

.dm-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dm-actions .small-btn { text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }
.like-btn.on { color: #ff6b8a; border-color: rgba(255, 107, 138, 0.45); }

.dm-creator {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--panel);
}
.dm-bio { color: var(--muted); font-size: 0.8rem; line-height: 1.5; margin-top: 8px; }

.creator-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: var(--text);
  text-align: left;
}
.creator-chip:hover .cc-name b { color: var(--accent-2); }
.cc-av {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #08080a;
  flex-shrink: 0;
}
.cc-av.tiny { width: 18px; height: 18px; font-size: 0.62rem; display: inline-grid; vertical-align: middle; }
.cc-name { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.cc-name b { font-size: 0.88rem; }
.cc-name span { color: var(--muted); font-size: 0.74rem; }

.dm-numbers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 8px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  background: var(--panel);
}
.dm-numbers div { text-align: center; }
.dm-numbers b { display: block; font-size: 1.15rem; font-weight: 700; }
.dm-numbers span { color: var(--muted); font-size: 0.68rem; }

.dm-desc { color: var(--muted); font-size: 0.86rem; line-height: 1.6; white-space: pre-wrap; }
.dm-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.dtag {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.72rem;
  cursor: pointer;
}
.dtag:hover { color: var(--accent-2); border-color: var(--accent); }
.dm-license { color: var(--muted); font-size: 0.78rem; }
.dm-rv-who { display: inline-flex; align-items: center; gap: 6px; }
.dm-rv-who a { color: inherit; cursor: pointer; }
.dm-rv-who a:hover { color: var(--accent-2); }

/* ------------------------------------------------ create page */

#create {
  display: none;
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px 40px 90px;
}
#create.open { display: block; }

.ctabs { margin-bottom: 24px; }

.how-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.how-step {
  display: flex;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
}
.how-step > b {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent-2);
  display: grid;
  place-items: center;
  font-size: 0.82rem;
  flex-shrink: 0;
}
.how-step h4 { font-size: 0.92rem; margin-bottom: 4px; }
.how-step p { color: var(--muted); font-size: 0.82rem; line-height: 1.5; }

.rules-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 30px;
}
.rules-card h4 { font-size: 0.95rem; margin-bottom: 10px; }
.rules-card ul { margin: 0; padding-left: 18px; }
.rules-card li { color: var(--muted); font-size: 0.84rem; line-height: 1.65; }
.rules-card code, .empty-note code {
  background: var(--panel-2);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.85em;
  color: var(--text);
}

.kits-head { margin-bottom: 14px; }
.kits-head h3 { font-size: 1.15rem; }
.kits-head .sub { color: var(--muted); font-size: 0.85rem; margin-top: 4px; }

.kits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}
.kit-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
}
.kit-card.open { border-color: var(--border); }
.kit-top { display: flex; gap: 14px; }
.kit-thumb {
  width: 74px;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: center;
  padding: 4px;
}
.kit-thumb img { width: 100%; height: 100%; object-fit: cover; }
.kit-info { min-width: 0; flex: 1; }
.kit-info h4 { font-size: 1rem; }
.kit-meta { color: var(--muted); font-size: 0.74rem; margin-top: 3px; word-break: break-all; }
.kit-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.small-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06210f;
  font-weight: 600;
  text-decoration: none;
}
.small-btn.primary:hover { background: var(--accent-2); }
.small-btn.danger:hover { border-color: var(--error); color: var(--error); }

.kit-slots:not(:empty) {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
}
.slot-block + .slot-block { margin-top: 10px; }
.slot-row { display: flex; flex-wrap: wrap; gap: 5px; }
.slot-row i { color: var(--muted); font-size: 0.78rem; }
code.slot {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.7rem;
  color: var(--muted);
}
code.slot.img { color: var(--accent-2); border-color: rgba(29, 185, 84, 0.3); }
.kit-size { color: var(--muted); font-size: 0.72rem; margin-top: 10px; }

/* ------------------------------------------------ publish form */

.publish-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 22px;
  align-items: start;
}
.publish-form {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px;
}
.publish-form h3 { font-size: 1.1rem; margin-bottom: 16px; }
.publish-form .field textarea,
.publish-form .field select,
.acct-card .field textarea,
.modal .field textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.88rem;
  font-family: inherit;
  resize: vertical;
}
.publish-form .field textarea:focus,
.publish-form .field select:focus,
.acct-card .field textarea:focus,
.modal .field textarea:focus { outline: none; border-color: var(--accent); }

.pub-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.lbl-hint { color: var(--muted); font-weight: 400; text-transform: none; opacity: 0.8; }
.checkfield label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 0.85rem;
  margin-top: 22px;
  cursor: pointer;
}
.checkfield input { width: auto; accent-color: var(--accent); }
.checkfield .lbl-hint { display: block; font-size: 0.74rem; margin-top: 5px; }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 18px;
  transition: border-color 0.15s, background 0.15s;
}
.drop-zone:hover, .drop-zone.over { border-color: var(--accent); background: var(--accent-dim); }
.dz-inner { display: flex; align-items: center; justify-content: center; gap: 14px; }
.dz-icon { font-size: 1.7rem; }
.dz-text { display: flex; flex-direction: column; text-align: left; }
.dz-text b { font-size: 0.92rem; }
.dz-text span { color: var(--muted); font-size: 0.78rem; margin-top: 2px; }

/* Drag & drop, shared by every upload on the site — see dropTarget() in app.js.
   `.dnd` marks a thing that takes a dropped file, `.dnd-over` is on while one is
   over it, and `.dnd-bad` flashes when the file is the wrong kind. The highlight
   is an inset outline rather than a border so nothing on the page shifts when it
   appears mid-drag, which would move the target out from under the cursor. */
.dnd { transition: background 0.15s, outline-color 0.15s; }
.dnd-over {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
  background: var(--accent-dim);
}
.dnd-bad {
  outline: 2px dashed var(--error);
  outline-offset: -2px;
}
/* the publish zone is already a dashed box, so it lights up the way it always
   did instead of growing a second outline inside the first */
.drop-zone.dnd-over {
  outline: none;
  border-color: var(--accent);
  background: var(--accent-dim);
}

.pub-status { margin-top: 16px; font-size: 0.85rem; color: var(--muted); min-height: 20px; }
.pub-status.error { color: var(--error); }
.pub-status.ok { color: var(--accent-2); }
.pub-status .small-btn { margin: 8px 6px 0 0; }
.spinner.small { width: 13px; height: 13px; border-width: 2px; display: inline-block; vertical-align: -2px; }
.pub-actions { margin-top: 18px; }

/* step 2 only opens by uploading a psd, so its tab is dead until then */
.ctabs .ptab.locked {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}
.ctabs .ptab.locked::after { content: " 🔒"; font-size: 0.72em; }

/* step 1's hand-off: drop the finished psd here and step 2 opens */
.upload-card {
  margin-top: 26px;
  margin-bottom: 26px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  transition: border-color 0.3s, box-shadow 0.3s;
}
.upload-card.flash {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.upload-card .kits-head { margin-bottom: 14px; }
.upload-card .drop-zone { margin-bottom: 0; }
.drop-zone.big { padding: 52px 28px; }

.pub-lead { color: var(--muted); font-size: 0.84rem; margin: -8px 0 16px; }
.pub-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}
.pub-nav .icon-btn { margin-right: auto; }

.pub-file-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 18px;
  font-size: 0.83rem;
}
.pub-file-chip:empty { display: none; }
.pfc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pfc-size { color: var(--muted); font-size: 0.76rem; margin-left: auto; flex: none; }

.publish-side {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
  position: sticky;
  top: 20px;
}
.publish-side h4 { font-size: 0.9rem; margin-bottom: 10px; }
.publish-side ul { margin: 0; padding-left: 18px; }
.publish-side li { color: var(--muted); font-size: 0.8rem; line-height: 1.6; margin-bottom: 6px; }
.side-note {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 0.78rem;
}

/* ------------------------------------------------ my designs */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-card b { display: block; font-size: 1.6rem; font-weight: 700; }
.stat-card span { color: var(--muted); font-size: 0.74rem; }

.mine-row {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
}
.mine-row.broken { border-color: rgba(255, 92, 92, 0.3); }
.mine-thumb {
  width: 58px;
  aspect-ratio: 2 / 3;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.62rem;
  flex-shrink: 0;
}
.mine-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mine-thumb.round {
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  font-size: 1.15rem;
  font-weight: 700;
  color: #08080a;
}
.mine-body { flex: 1; min-width: 0; }
.mine-title { font-weight: 600; font-size: 0.95rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mine-sub { color: var(--muted); font-size: 0.74rem; margin-top: 3px; }
.mine-tag { color: var(--muted); font-size: 0.8rem; margin-top: 5px; }
.mine-stats { font-size: 0.78rem; color: var(--muted); margin-top: 6px; }
.mine-error { color: var(--error); font-size: 0.78rem; margin-top: 6px; line-height: 1.5; }
.mine-note { color: #8fb4ff; font-size: 0.78rem; margin-top: 6px; line-height: 1.5; }
.mine-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.mine-foot { margin-top: 18px; }

/* ------------------------------------------------ creator page */

#creator {
  display: none;
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px 40px 90px;
}
#creator.open { display: block; }

/* ------------------------------------------------ account centre */

#account {
  display: none;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 24px 80px;
}
#account.open { display: block; }

#admin {
  display: none;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 24px 80px;
}
#admin.open { display: block; }

.admin-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.admin-search { flex: 1; min-width: 220px; margin-top: 0 !important; }
.admin-search input { border-radius: 999px; }
.admin-pager { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 8px; }
.admin-detail {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
  font-size: 0.82rem;
}
.admin-mini-title { color: var(--muted); font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.05em; margin: 10px 0 4px; }
.admin-mini-list { list-style: none; padding: 0; margin: 0; color: var(--text); line-height: 1.7; }
.admin-mini-list li { border-bottom: 1px dashed var(--border-soft); padding: 3px 0; }
.admin-mini-list li:last-child { border-bottom: none; }

/* --- staff console: roles, log, settings --- */

.role-select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.76rem;
  font-family: inherit;
  cursor: pointer;
}
.role-select:hover { border-color: var(--accent); }

/* A reverted entry stays in the list but stops competing for attention — the
   log is append-only, so it must remain readable without looking current. */
.log-row.reverted { opacity: 0.62; }
.log-row.reverted .mine-title { text-decoration: line-through; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; margin-top: 6px; }
.admin-table th {
  text-align: left;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  padding: 6px 8px 6px 0;
  border-bottom: 1px solid var(--border);
}
.admin-table td { padding: 7px 8px 7px 0; border-bottom: 1px dashed var(--border-soft); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table td:not(:first-child) { width: 1%; white-space: nowrap; }

.set-row { margin-top: 16px; }
.set-row:first-child { margin-top: 4px; }

/* --- charts ---
   Every chart in the console is a single series, so there is no legend and no
   categorical palette: one accent hue, recessive axes, and the figures live in
   the header and the per-column tooltip rather than on top of the bars. */

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin: 16px 0;
}
.chart {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px 10px;
  min-width: 0;
}
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.chart-head h4 { font-size: 0.8rem; font-weight: 600; }
.chart-sum { text-align: right; font-size: 0.78rem; }
.chart-sum b { font-size: 1.05rem; }
.chart-sum .rc { display: block; font-size: 0.68rem; }

.chart-bars {
  display: flex;
  align-items: flex-end;      /* bars grow from the baseline, never centred */
  gap: 2px;                   /* the 2px surface gap between adjacent marks */
  height: 76px;
  margin: 12px 0 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
}
.cbar {
  flex: 1 1 0;
  min-width: 0;
  height: var(--h, 0%);
  background: var(--accent);
  border-radius: 4px 4px 0 0;  /* rounded data-end, square at the baseline */
  transition: background 0.12s;
}
.cbar:hover { background: var(--accent-2); }
.cbar.zero { background: var(--border); }
.chart-axis {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.66rem;
}

/* The distribution rows reuse .fmt-bars, but their labels are words rather
   than the 3-letter file extensions that sizing was written for. */
.fmt-bar .fb-label {
  width: 108px;
  color: var(--muted);
  font-weight: 600;
  flex: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- site-wide banner + toast --- */

.site-banner {
  background: var(--accent-dim);
  border-bottom: 1px solid rgba(29, 185, 84, 0.3);
  color: var(--text);
  text-align: center;
  padding: 9px 20px;
  font-size: 0.82rem;
}
.site-banner.warn {
  background: rgba(255, 204, 102, 0.12);
  border-bottom-color: rgba(255, 204, 102, 0.35);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(14px);
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 11px 22px;
  font-size: 0.84rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 300;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.acct-wrap {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.acct-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 18px;
}
.acct-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 11px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.acct-tab:hover { color: var(--text); background: var(--panel); }
.acct-tab.active {
  color: var(--text);
  background: var(--panel);
  border-left-color: var(--accent);
}
.at-icon { font-size: 1rem; width: 18px; text-align: center; }

.acct-h { font-size: 1.5rem; font-weight: 800; }
.acct-sub { color: var(--muted); margin: 6px 0 22px; max-width: 62ch; line-height: 1.5; }

.acct-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.acct-card.danger { border-color: rgba(255, 92, 92, 0.35); }
.ac-head { display: flex; align-items: center; gap: 10px; }
.ac-head h3 { font-size: 1.02rem; font-weight: 700; }
.ac-note { color: var(--muted); font-size: 0.88rem; line-height: 1.55; margin: 7px 0 0; max-width: 68ch; }
.acct-card .field { margin-top: 14px; }
.acct-card .field label { font-size: 0.85rem; }

.ac-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 13px 0;
  border-bottom: 1px solid var(--border-soft);
}
.ac-row:last-child { border-bottom: none; padding-bottom: 0; }
.ac-val { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; font-size: 0.95rem; }
.ac-val.big { font-size: 1.2rem; font-weight: 700; }
.ac-row-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.ac-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* profile picture card: the face, then its controls beside it */
.ac-avatar { display: flex; align-items: center; gap: 18px; margin-top: 16px; flex-wrap: wrap; }
.ac-avatar .av-preview {
  width: 96px; height: 96px;
  font-size: 2.6rem;
  border: 1px solid var(--border-soft);
}
.av-side { flex: 1; min-width: 210px; }
.av-side .ac-actions { margin-top: 0; }
.av-side .lbl-hint { font-size: 0.82rem; margin-top: 9px; line-height: 1.5; }
.av-side button[disabled] { opacity: 0.45; cursor: default; }
.ac-sub-form { border-top: 1px solid var(--border-soft); margin-top: 6px; padding-top: 4px; }
.ac-loading { color: var(--muted); padding: 10px 0; }

.ac-list { color: var(--muted); font-size: 0.9rem; line-height: 1.7; margin: 10px 0 0 18px; }
.ac-list li { padding-left: 2px; }
.ac-list a { color: var(--accent-2); cursor: pointer; }

.ac-status { font-size: 0.87rem; margin-top: 12px; min-height: 1.1em; color: var(--muted); }
.ac-status.ok { color: var(--accent-2); }
.ac-status.error { color: var(--error); }

.ac-warn {
  background: rgba(255, 176, 32, 0.09);
  border: 1px solid rgba(255, 176, 32, 0.3);
  color: #ffc86b;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.89rem;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pill {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: .3px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.pill.ok { background: var(--accent-dim); color: var(--accent-2); border-color: transparent; }
.pill.warn { background: rgba(255, 176, 32, 0.14); color: #ffc86b; border-color: transparent; }
.ac-head .pill { margin-left: auto; }

.input-prefix { display: flex; align-items: center; }
.input-prefix > span {
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  padding: 10px 4px 10px 12px;
}
.input-prefix > input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* password strength */
.pw-meter { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.pw-bar {
  flex: 1;
  height: 4px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
}
.pw-bar > i { display: block; height: 100%; width: 0; background: var(--error); transition: width .2s, background .2s; }
.pw-meter > span { font-size: 0.78rem; color: var(--muted); min-width: 72px; }
.pw-meter.s3 .pw-bar > i, .pw-meter.s4 .pw-bar > i { background: #ffb020; }
.pw-meter.s5 .pw-bar > i { background: var(--accent); }

/* activity log */
.act-list { margin-top: 6px; }
.act-row { padding: 11px 0; border-bottom: 1px solid var(--border-soft); }
.act-row:last-child { border-bottom: none; padding-bottom: 0; }
.act-what { font-size: 0.93rem; font-weight: 600; display: flex; gap: 8px; align-items: baseline; }
.act-meta { color: var(--muted); font-size: 0.79rem; margin-top: 3px; }

/* orders */
.ord-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 0.9rem; }
.ord-table th {
  text-align: left;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: .6px;
  text-transform: uppercase;
  font-weight: 700;
  padding: 0 10px 10px 0;
  border-bottom: 1px solid var(--border-soft);
}
.ord-table td { padding: 12px 10px 12px 0; border-bottom: 1px solid var(--border-soft); }
.ord-table .num { text-align: right; padding-right: 0; }
.ord-table .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--muted); }
.ord-table tfoot td { border-bottom: none; font-weight: 700; color: var(--muted); }
.ord-table tfoot td.num { color: var(--text); }

/* destructive buttons + the confirm-identity modal */
.cta.danger { background: var(--error); }
.cta.danger:disabled { opacity: .45; cursor: not-allowed; }
.small-btn.danger { color: var(--error); border-color: rgba(255, 92, 92, 0.4); }
.reauth-why { color: var(--muted); font-size: 0.9rem; line-height: 1.55; margin-bottom: 4px; }
.modal-note { color: var(--muted); font-size: 0.85rem; line-height: 1.55; margin: -4px 0 6px; }
.modal-note a { color: var(--accent-2); cursor: pointer; }

/* 820px x --ui-scale */
@media (max-width: 984px) {
  .acct-wrap { grid-template-columns: 1fr; gap: 14px; }
  /* grid items default to min-width:auto, so the five nowrap tabs below would
     stretch this track to their full 719px instead of scrolling inside it */
  .acct-wrap > * { min-width: 0; }
  .acct-nav {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 2px;
    /* .acct-nav is a <nav>, so it also picks up the site header's `margin:
       0 auto`. An auto inline margin on a grid item suppresses stretch and
       sizes it to FIT-CONTENT — the five nowrap tabs came out 719px wide in a
       358px track and scrolled the whole page sideways. min-width:0 above
       can't help while the margin is auto; this is the rule that fixes it. */
    margin: 0;
  }
  .acct-tab {
    border-left: none;
    border-bottom: 2px solid transparent;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    white-space: nowrap;
  }
  .acct-tab.active { border-left: none; border-bottom-color: var(--accent); }
  .ac-row-actions { margin-left: 0; }
}
.creator-back {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.85rem;
  margin-bottom: 18px;
  font-family: inherit;
}
.creator-back:hover { color: var(--text); }

.creator-head {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 22px;
}
.creator-av {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 700;
  color: #08080a;
  flex-shrink: 0;
}
.creator-id { flex: 1; min-width: 0; }
.creator-id h2 { font-size: 1.5rem; font-weight: 800; }
.chandle { color: var(--muted); font-size: 0.88rem; margin-top: 2px; }
.cbio { color: var(--muted); font-size: 0.88rem; line-height: 1.6; margin-top: 10px; max-width: 62ch; }
.cmeta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.78rem;
}
.cmeta a { color: var(--accent-2); text-decoration: none; }
.cmeta a:hover { text-decoration: underline; }
.cactions { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.cactions .cta { padding: 9px 16px; font-size: 0.82rem; }
.csec { font-size: 1.1rem; margin: 26px 0 12px; }

.browse-link .dot { color: var(--muted); margin: 0 8px; }

/* 900px x --ui-scale */
@media (max-width: 1080px) {
  .publish-wrap { grid-template-columns: 1fr; }
  .publish-side { position: static; }
  .pub-row { grid-template-columns: 1fr; }
  .market-bar, .market-count, #create, #creator { padding-left: 20px; padding-right: 20px; }
  .creator-head { flex-direction: column; }
  .mine-row { flex-wrap: wrap; }
}

/* ------------------------------------------------ leaderboard (home) */

/* Deliberately NOT a panel. This sits inside #hero, and a filled bordered card
   here read as one big bubble competing with the hero above it — worse, its
   rows are cards too, so it was a bubble full of bubbles. A hairline rule and
   the section spacing are enough to say "new section"; the rows below carry
   the only fills on the whole board. */
.lb {
  max-width: 720px;
  margin: 46px auto 0;
  padding: 28px 0 0;
  border-top: 1px solid var(--border-soft);
  text-align: left;
}
.lb-head { text-align: center; margin-bottom: 14px; }
.lb-head h2 {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.lb-sub { color: var(--muted); font-size: 0.82rem; margin-top: 6px; opacity: 0.85; }
.lb-boards { margin-bottom: 12px; }
.lb-boards .chip { font-size: 0.8rem; padding: 7px 14px; }

.lb-periods {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 14px;
}
.lb-periods button {
  background: none;
  border: none;
  border-bottom: 1px solid transparent;
  color: var(--muted);
  font-size: 0.76rem;
  padding: 2px 0;
  cursor: pointer;
}
.lb-periods button:hover { color: var(--text); }
.lb-periods button.on { color: var(--accent-2); border-bottom-color: var(--accent); }

.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 2px;
  padding: 9px 14px 9px 8px;
  /* flat until you point at one: ten filled cards in a row was the "bubbles
     inside a bubble" look. The podium wash and your own row still fill. */
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: all .15s;
}
.lb-row:hover { background: var(--bg-2); border-color: var(--border-soft); }
/* The podium used to get a wash of accent fading out across the row. That
   worked when rows were filled cards — over a flat row the gradient's endpoint
   is a visible vertical cut, so the top three read as tinted blocks floating
   on a plain list. The medals and the accent-coloured score mark the podium
   well enough; only your own row still gets a fill, and there's just one. */
.lb-row.mine { border-color: var(--accent); background: var(--accent-dim); }

.lb-rank {
  flex: none;
  width: 30px;
  text-align: center;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--muted);
}
.lb-row.top .lb-rank { font-size: 1.1rem; }
.lb-av {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.92rem;
  color: #08080a;
}
.lb-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lb-who b {
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-handle { color: var(--muted); font-size: 0.72rem; }
.lb-you {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--accent-2);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 1px 6px;
}
.lb-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px 10px;
  max-width: 40%;
  color: var(--muted);
  font-size: 0.71rem;
}
.lb-score {
  flex: none;
  min-width: 76px;
  display: flex;
  flex-direction: column;
  text-align: right;
  line-height: 1.15;
}
.lb-score b { font-size: 1.05rem; color: var(--accent-2); }
.lb-score span { font-size: 0.65rem; color: var(--muted); }

.lb-gap { text-align: center; color: var(--muted); letter-spacing: 3px; margin: 2px 0 5px; }
.lb-note { text-align: center; color: var(--muted); font-size: 0.86rem; padding: 26px 10px; line-height: 1.6; }
.lb-foot { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.lb-more {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 0.78rem;
  cursor: pointer;
}
.lb-more:hover { border-color: #3a3a44; }

/* 620px x --ui-scale */
@media (max-width: 744px) {
  .lb-stats { display: none; }
  .lb { margin-top: 34px; padding: 22px 0 0; }
}

/* =========================================================================
   MOBILE — phones and small tablets
   =========================================================================

   Everything above this point is desktop-first, so this section is the last
   word and deliberately lives at the end of the file. Two breakpoints:

     <= 900px  "compact"  — one column everywhere, nav collapses to a drawer,
                            the studio turns into a sticky-preview editor.
     <= 600px  "phone"    — further tightening: smaller type, 2-up card grids,
                            modals become bottom sheets.

   The single most important rule is the --ui-scale reset below. Read the
   comment on it before touching any breakpoint number in this file.
   ========================================================================= */

/* The desktop UI is drawn at zoom:1.2 so it doesn't read as "zoomed out" on a
   large monitor. On a phone that is exactly backwards — `zoom` shrinks the
   LAYOUT viewport, so a 390px phone lays out as if it were 325px, and every
   breakpoint below fires 1.2x too early. Dropping the scale to 1 here gives
   phones their real width back. app.js's uiScale() reads this same variable
   (it parses --ui-scale off the root), so its window.innerHeight arithmetic
   follows automatically with no JS breakpoint to keep in sync.

   Consequence worth knowing: the pre-multiplied breakpoints above (1296/1080/
   984/864/744) were authored as "logical px x 1.2". Below 900 the scale is 1,
   so 864 and 744 now fire at their literal widths rather than 720 and 620.
   That is fine — they only ever collapsed columns — but it is why the mobile
   rules here are written against raw px and never re-derived from those. */
@media (max-width: 900px) {
  :root { --ui-scale: 1; }

  /* 100vh on a phone is the viewport WITHOUT the URL bar, so full-height
     panels get clipped as the bar hides. dvh tracks the visible area. */
  @supports (height: 1dvh) {
    :root { --vh: calc(1dvh / var(--ui-scale)); }
  }
}

@media (max-width: 900px) {

  /* ------------------------------------------------ page frame */

  body {
    /* viewport-fit=cover paints under the notch; put the gutter back */
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  /* Every full-page section carried desktop gutters of 24–40px, which on a
     360px screen is a fifth of the width. */
  #hero    { padding: 26px 16px 44px; }
  #studio  { padding: 0 12px 40px; }
  #gallery,
  #pricing,
  #profile,
  #account,
  #admin   { padding: 12px 16px 56px; }
  #create,
  #creator { padding: 18px 16px 64px; }
  .market-bar,
  .market-count { padding-left: 16px; padding-right: 16px; }
  footer { padding: 26px 16px calc(34px + env(safe-area-inset-bottom)); }

  /* ------------------------------------------------ nav drawer */

  nav {
    padding: 12px 14px;
    gap: 8px;
  }
  .nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    flex: none;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 12px;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
  }
  .nav-toggle:active { border-color: var(--accent); }

  /* No room for Log in AND Sign up AND the avatar AND ☰. Log in moves into
     the drawer (.nav-menu-login). !important because renderNavAccount() sets
     display as an inline style on this button. */
  #login-btn { display: none !important; }
  .nav-menu-login { display: block; }

  .nav-right {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 70;
    width: min(300px, 82vw);
    margin: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
    padding-top: max(16px, env(safe-area-inset-top));
    background: var(--bg-2);
    border-left: 1px solid var(--border);
    box-shadow: -20px 0 50px rgba(0, 0, 0, .5);
    overflow-y: auto;
    /* visibility (not just transform) so the off-screen panel can never add
       to the document's scroll width or swallow a tap at the right edge */
    visibility: hidden;
    transform: translateX(100%);
    transition: transform .22s ease, visibility .22s;
  }
  .nav-right.open { visibility: visible; transform: translateX(0); }
  .nav-right .icon-btn {
    text-align: left;
    border-radius: 12px;
    padding: 13px 16px;
    font-size: 0.95rem;
  }
  .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 69;
    background: rgba(0, 0, 0, .55);
    opacity: 0;
    visibility: hidden;
    transition: opacity .22s ease, visibility .22s;
  }
  .nav-scrim.open { opacity: 1; visibility: visible; }
  /* the drawer is its own scroll area; don't scroll the page behind it */
  body.nav-open { overflow: hidden; }

  /* ------------------------------------------------ typing / tap targets */

  /* iOS auto-zooms the page whenever you focus a control whose text is under
     16px, and never zooms back out. Every text-entry control gets 16px. */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="number"],
  input[type="url"],
  input[type="tel"],
  select,
  textarea { font-size: 16px; }

  /* those two sit in the dense editor panel and need the extra room back */
  .lrow input[type="number"] { width: 78px; }
  .lrow select { padding: 7px 8px; }

  /* icon-only buttons were 15–18px of tappable area */
  .eye, .gear, .trackrow .del, .reset-btn {
    min-width: 34px;
    min-height: 34px;
    padding: 4px;
  }
  .pcard .mini, .heart-btn { min-height: 32px; }
  .swatch { width: 28px; height: 28px; }
  input[type="range"] { height: 28px; }

  /* ------------------------------------------------ hero */

  #hero h1 { font-size: clamp(2.1rem, 11vw, 3.2rem); }
  #hero .sub { font-size: 0.95rem; margin: 14px auto 26px; }
  /* input above, full-width button below — side by side leaves ~150px for a
     URL, and the button's white-space:nowrap wins the fight for the rest */
  .search-row { flex-direction: column; gap: 10px; }
  .search-row input { width: 100%; padding: 14px 20px; }
  .search-row .cta { width: 100%; padding: 14px 20px; }
  .type-strip { gap: 6px; }
  .chip { padding: 8px 13px; font-size: 0.82rem; }

  /* ------------------------------------------------ studio */

  /* The desktop rail | stage | panel grid already collapses to one column at
     1296px, but in DOM order — a full-height template list, THEN the poster,
     THEN the controls, so the thing you are editing scrolls off screen the
     moment you touch a control.

     On a phone it becomes: poster pinned to the top of the viewport, a
     horizontal filmstrip of templates under it, then the controls. The stage
     is sticky so the preview stays visible while you scroll the panel, which
     is the whole point of a live editor. */
  .studio-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* the grid rule sets align-items:start, which as a FLEX value means
       "size to content on the cross axis" — the template filmstrip would
       stretch .rail to its full scroll width instead of scrolling inside it */
    align-items: stretch;
  }
  .studio-grid > * { min-width: 0; }
  .studio-head { padding: 4px 2px 12px; gap: 10px; }
  .studio-head .t { font-size: 0.95rem; }
  .studio-head .back { font-size: 0.82rem; }

  .stage {
    order: 1;
    position: sticky;
    top: 0;
    z-index: 5;
    /* full-bleed so the poster isn't framed by a 12px stripe of scrolling
       content sliding past underneath it */
    margin: 0 -12px;
    padding: 8px 12px 10px;
    background: var(--bg);
    border-bottom: 1px solid var(--border-soft);
    min-height: 0;
    gap: 8px;
  }
  .stage-note { font-size: 0.78rem; }
  #poster-canvas { box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }

  .rail {
    order: 2;
    max-height: none;
    overflow: visible;
    padding: 12px;
  }
  .rail h3 { margin-bottom: 8px; }
  #template-list {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
    scroll-snap-type: x proximity;
  }
  #template-list .tcard {
    flex: 0 0 116px;
    width: 116px;
    margin-bottom: 0;
    scroll-snap-align: start;
  }
  #template-list .tcard .cap { font-size: 0.7rem; padding: 6px 7px; }
  #template-list .tcard .cap .badge { font-size: 0.58rem; padding: 1px 5px; }
  /* the rail's upload button picks up the Create page's .upload-card rule
     (same class, defined later in the file) — undo it just for the strip */
  #template-list .upload-card {
    flex: 0 0 116px;
    margin: 0;
    padding: 10px 8px;
    background: none;
    border: 1.5px dashed var(--border);
    font-size: 0.74rem;
  }

  .panel {
    order: 3;
    /* the page is the scroller now; a nested one under a sticky preview means
       two things move under one finger */
    max-height: none;
    overflow: visible;
  }
  .panel-body { overflow: visible; padding: 14px; }
  .tab { padding: 13px 4px; font-size: 0.82rem; }

  /* ------------------------------------------------ cards & grids */

  .pgrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .stat-tile { padding: 14px; }
  .stat-tile .v { font-size: 1.5rem; }
  .stat-row { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 10px; }
  .kits-grid { grid-template-columns: 1fr; }
  .plans { grid-template-columns: 1fr; gap: 16px; }
  .plan-card { padding: 22px 18px 18px; }
  .plan-price { font-size: 2.2rem; }
  .how-row { grid-template-columns: 1fr; }

  /* the heading is centred on desktop with .back absolutely positioned in the
     left margin; there is no margin to put it in here, so the block goes
     left-aligned and .back becomes a normal first row */
  .gallery-head {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    padding: 4px 0 18px;
  }
  .gallery-head h2 { font-size: 1.4rem; }
  .gallery-head .sub { font-size: 0.88rem; }
  .gallery-head .back {
    position: static;
    order: -1;          /* it is last in the DOM, but reads first */
    margin-bottom: 10px;
    padding: 0;
  }

  .market-bar { gap: 8px; }
  .market-bar input[type="search"] { min-width: 0; flex: 1 1 100%; }
  .market-bar select { flex: 1 1 auto; }
  .market-bar .market-submit { flex: 1 1 auto; }
  .seg { flex-wrap: wrap; }

  /* tab rows that run past the edge scroll instead of wrapping mid-word */
  .ptabs {
    gap: 18px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  .ptabs::-webkit-scrollbar { display: none; }
  .ptab { white-space: nowrap; font-size: 0.88rem; }
  .pfilters.visible { gap: 6px; }

  /* ------------------------------------------------ profile / creator */

  .profile-head { gap: 14px; padding: 6px 0 20px; }
  .pfp { width: 66px; height: 66px; font-size: 1.8rem; }
  .pname { font-size: 1.3rem; }
  /* margin-left:auto pushed these onto their own cramped line */
  .pactions { margin-left: 0; width: 100%; }
  .pactions .icon-btn { flex: 1; }
  .creator-head { padding: 16px; gap: 14px; }
  .cactions { flex-direction: row; flex-wrap: wrap; width: 100%; }

  .mine-row { flex-wrap: wrap; gap: 12px; }
  .mine-actions { flex-direction: row; flex-wrap: wrap; width: 100%; }
  .account-billing { flex-direction: column; align-items: flex-start; }

  /* ------------------------------------------------ modals */

  .overlay { align-items: flex-end; }
  .modal {
    width: 100%;
    max-height: calc(92 * var(--vh));
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: none;
    padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  }
  .auth-modal { width: 100%; }
  .modal-actions { flex-direction: column-reverse; gap: 8px; }
  .modal-actions button { width: 100%; padding: 13px 20px !important; }

  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal-box {
    max-height: calc(94 * var(--vh));
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .design-modal { padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); }
  .dm-head { flex-wrap: wrap; }
  .dm-preview img { max-height: calc(44 * var(--vh)); }

  /* ------------------------------------------------ leaderboard */

  .lb-score { min-width: 62px; }
  .lb-score b { font-size: 0.95rem; }
  .lb-row { padding: 9px 8px; gap: 10px; }
}

/* ------------------------------------------------ phones proper */

@media (max-width: 600px) {
  #hero h1 { font-size: clamp(1.95rem, 10.5vw, 2.7rem); }
  .gallery-head h2 { font-size: 1.25rem; }

  /* two poster thumbs per row reads far better than one giant card */
  .pgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pcard .pbody { padding: 8px 9px 10px; }
  .pcard .pt { font-size: 0.82rem; }
  .pcard .pm, .pcard .psub { font-size: 0.68rem; }
  .dstats { gap: 7px; }

  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dm-numbers { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .kit-top { flex-direction: column; }
  .kit-thumb { width: 100%; aspect-ratio: 3 / 2; }
  .dz-inner { flex-direction: column; gap: 8px; text-align: center; }
  .dz-text { text-align: center; }
  .drop-zone.big { padding: 32px 18px; }

  .pub-nav { flex-wrap: wrap; }
  .pub-nav .icon-btn { margin-right: 0; }
  .pub-nav button { flex: 1 1 100%; }
}

/* Touch devices have no hover, and a sticky :hover after a tap leaves cards
   looking selected. Confine the lift/scale affordances to real pointers. */
@media (hover: none) {
  .design-card:hover { transform: none; }
  .swatch:hover { transform: none; }
  .avatar-btn:hover { transform: none; }
  .cta:hover:not(:disabled) { transform: none; }
}

/* Landscape phones: the sticky preview would eat the whole screen. */
@media (max-width: 900px) and (max-height: 500px) {
  .stage { position: static; margin: 0; border-bottom: none; }
}
