/* ===================== UI: the proofing room =====================
   Neutral grey surround (like a print proofing booth) so the interface never tints how colours read;
   the posters are the only colour on screen. Left: a contact sheet with frame numbers and crop marks
   on the selected proof. Right: a numbered spec sheet. Hairlines, mono micro-labels, ink-black actions.
   Everything that moves animates transform/opacity only, so it stays on the compositor. */
:root {
  --bg: #E6E4DF;          /* ~N8.5 neutral, slightly warm */
  --paper: #F5F4F0;
  --field: #ECEAE5;
  --field-hi: #E2E0DA;
  --hair: rgba(30, 28, 24, .09);
  --hair-2: rgba(30, 28, 24, .17);
  --fg: #1A1917;
  --muted: #75716A;
  --faint: #A6A299;
  --ink: #1A1917; --on-ink: #F5F4F0;
  /* older names still used by the value / font / credit blocks below */
  --surface: var(--paper); --sunken: var(--field); --line: var(--hair-2);
  --accent: #B92726;      /* replaced at runtime by the poster's own accent */
  --on-accent: #FFFFFF;
  --ok: #2F7D4F; --mid: #9A6200; --far: #B3261E;
  --lift-0: 0 1px 1px rgba(0,0,0,.05), 0 10px 24px -16px rgba(0,0,0,.38);
  --lift-1: 0 2px 4px rgba(0,0,0,.06), 0 26px 40px -22px rgba(0,0,0,.5);
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2375716A' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --ease: cubic-bezier(.22, .8, .24, 1);
  --spring: cubic-bezier(.34, 1.45, .5, 1);
  --bar-h: 60px;
  --font-ui: 'DM Sans', 'PingFang SC', 'Hiragino Sans', 'Microsoft YaHei', system-ui, sans-serif;
  --font-display: 'Fraunces', 'Noto Serif SC', 'Songti SC', Georgia, serif;
  --font-mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #131312; --paper: #1B1B19; --field: #252522; --field-hi: #2E2E2A;
  --hair: rgba(255, 250, 240, .07); --hair-2: rgba(255, 250, 240, .14);
  --fg: #ECEAE4; --muted: #9C988F; --faint: #66635C; --ink: #ECEAE4; --on-ink: #131312;
  --ok: #6FCF97; --mid: #F2C14E; --far: #FF8A80;
  --lift-0: 0 1px 1px rgba(0,0,0,.4), 0 12px 26px -14px rgba(0,0,0,.8);
  --lift-1: 0 2px 4px rgba(0,0,0,.4), 0 28px 44px -20px rgba(0,0,0,.9);
  color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #131312; --paper: #1B1B19; --field: #252522; --field-hi: #2E2E2A;
  --hair: rgba(255, 250, 240, .07); --hair-2: rgba(255, 250, 240, .14);
  --fg: #ECEAE4; --muted: #9C988F; --faint: #66635C; --ink: #ECEAE4; --on-ink: #131312;
  --ok: #6FCF97; --mid: #F2C14E; --far: #FF8A80;
  --lift-0: 0 1px 1px rgba(0,0,0,.4), 0 12px 26px -14px rgba(0,0,0,.8);
  --lift-1: 0 2px 4px rgba(0,0,0,.4), 0 28px 44px -20px rgba(0,0,0,.9);
  color-scheme: dark; }

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 13px/1.5 var(--font-ui); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
::selection { background: color-mix(in srgb, var(--fg) 18%, transparent); }
button, select, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

/* ---- controls ---- */
button { background: var(--field); border: 1px solid transparent; border-radius: 7px; padding: 6px 12px; cursor: pointer; font-size: 12.5px; font-weight: 500; line-height: 1.4;
  transition: background-color .15s, border-color .15s, color .15s, transform .2s var(--ease); }
button:hover { background: var(--field-hi); }
button:active { transform: scale(.97); }
button:disabled { opacity: .5; cursor: progress; transform: none; }
button.primary { background: var(--ink); color: var(--on-ink); font-weight: 600; }
button.primary:hover { background: color-mix(in srgb, var(--ink) 84%, var(--bg)); }
button.ghost { background: transparent; }
button.ghost:hover { background: var(--field); }
input[type=text], input[type=password], select, textarea { background: var(--field); border: 1px solid transparent; border-radius: 7px; padding: 5px 9px; min-width: 0; min-height: 30px;
  transition: border-color .15s, background-color .15s; }
input[type=text]:hover, input[type=password]:hover, select:hover, textarea:hover { border-color: var(--hair-2); }
input[type=text]:focus, input[type=password]:focus, textarea:focus { background: var(--paper); border-color: var(--hair-2); outline: none; box-shadow: 0 0 0 3px var(--hair); }
::placeholder { color: var(--faint); }
select { appearance: none; -webkit-appearance: none; padding-right: 26px; cursor: pointer; background: var(--field) var(--chev) no-repeat right 9px center / 9px 6px; text-overflow: ellipsis; }
select:disabled, input:disabled { opacity: .45; cursor: not-allowed; }
textarea { width: 100%; resize: vertical; line-height: 1.5; }

/* range: hairline track, filled up to the thumb (--p set from JS) */
input[type=range] { -webkit-appearance: none; appearance: none; height: 20px; background: transparent; cursor: pointer; --p: 50%; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(var(--fg) 0 0) 0 / var(--p) 100% no-repeat, var(--hair-2); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5.5px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--fg);
  box-shadow: 0 1px 3px rgba(0,0,0,.18); transition: transform .2s var(--spring); }
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.12); }
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.28); }
input[type=range]::-moz-range-track { height: 3px; border-radius: 3px; background: var(--hair-2); }
input[type=range]::-moz-range-progress { height: 3px; border-radius: 3px; background: var(--fg); }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--fg); }

/* checkbox: small switch */
.row input[type=checkbox], .row label.inl input[type=checkbox] { -webkit-appearance: none; appearance: none; flex: none; width: 28px; height: 16px; margin: 0; border-radius: 99px; position: relative; cursor: pointer;
  background: var(--hair-2); transition: background-color .2s; }
.row input[type=checkbox]::before { content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--paper);
  box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .3s var(--spring); }
.row input[type=checkbox]:checked { background: var(--fg); }
.row input[type=checkbox]:checked::before { transform: translateX(12px); }

/* color input: a swatch */
.row input[type=color] { -webkit-appearance: none; appearance: none; width: 30px; height: 30px; padding: 0; border: 1px solid var(--hair-2); border-radius: 7px; background: none; cursor: pointer; flex: none; }
.row input[type=color]::-webkit-color-swatch-wrapper { padding: 2px; }
.row input[type=color]::-webkit-color-swatch { border: none; border-radius: 5px; }
.row input[type=color]::-moz-color-swatch { border: none; border-radius: 5px; }

/* ---- header ---- */
.bar { position: sticky; top: 0; z-index: 20; height: var(--bar-h); display: flex; align-items: center; gap: 18px; padding: 0 20px 0 22px;
  background: var(--bg); border-bottom: 1px solid var(--hair); }
.bar svg { width: 15px; height: 15px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.bar svg .fill { fill: currentColor; stroke: none; }
.brand { margin: 0; display: flex; align-items: center; gap: 10px; font: 600 19px/1 var(--font-display); letter-spacing: -.02em; white-space: nowrap; flex: none; }
/* logo: three fanned swatch chips in the current palette's dark / mid / light */
.mark { position: relative; width: 22px; height: 26px; flex: none; }
.mark i { position: absolute; left: 6px; bottom: 2px; width: 10px; height: 22px; border-radius: 2px; transform-origin: 50% 88%;
  box-shadow: 0 0 0 .5px rgba(0,0,0,.18), 0 1px 2px rgba(0,0,0,.12); transition: background-color .6s var(--ease), transform .5s var(--spring); }
.mark i:nth-child(1) { background: var(--m1, #2E3A6B); transform: rotate(-26deg); }
.mark i:nth-child(2) { background: var(--m2, #C77D72); transform: rotate(-5deg); }
.mark i:nth-child(3) { background: var(--m3, #F6C98F); transform: rotate(16deg); }
.brand:hover .mark i:nth-child(1) { transform: rotate(-40deg); }
.brand:hover .mark i:nth-child(3) { transform: rotate(30deg); }

/* live palette bar: widths follow each colour's share of the photo */
.strip { flex: 1 1 280px; max-width: 560px; height: 30px; display: flex; border-radius: 7px; overflow: hidden; box-shadow: 0 0 0 1px var(--hair); }
.seg { flex: 1 1 0; min-width: 0; padding: 0; border: 0; border-radius: 0; background: var(--c); color: var(--on); display: flex; align-items: flex-end; overflow: hidden;
  transition: flex-grow .7s var(--ease), background-color .7s var(--ease); }
.seg:hover { background: var(--c); }
.seg:active { transform: none; filter: brightness(.92); }
.seg span { font: 500 9.5px/1 var(--font-mono); letter-spacing: .04em; padding: 0 0 6px 7px; white-space: nowrap; opacity: 0; transform: translateY(3px);
  transition: opacity .2s, transform .3s var(--ease); }
.strip:hover .seg span, .seg:focus-visible span { opacity: .92; transform: none; }
.seg:focus-visible { outline-offset: -2px; outline-color: var(--on); }

.note { color: var(--muted); font: 11px var(--font-mono); letter-spacing: .02em; white-space: nowrap; }
.note[hidden] { display: none; }
.bar-acts { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: none; }
.bar-acts button { display: inline-flex; align-items: center; gap: 7px; height: 34px; }
.bar-acts button.icon { width: 34px; padding: 0; justify-content: center; }
.drop { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 12.5px;
  background: var(--ink); color: var(--on-ink); transition: transform .2s var(--ease), box-shadow .25s var(--ease), background-color .15s; }
.drop:hover { background: color-mix(in srgb, var(--ink) 84%, var(--bg)); }
.drop:active { transform: scale(.97); }
.drop span { font: 400 10.5px var(--font-mono); opacity: .6; margin-left: 2px; }
.drop.over { transform: scale(1.04); box-shadow: 0 0 0 5px color-mix(in srgb, var(--fg) 16%, transparent); }

/* ---- contact sheet ---- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 384px; align-items: start; }
#gallery { padding: 30px 34px 96px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 228px), 1fr)); gap: 30px 26px; align-content: start; min-width: 0; }
.tile { position: relative; min-width: 0; align-self: start; animation: tile-in .7s var(--ease) backwards; animation-delay: calc(min(var(--i, 0), 16) * 30ms); }
@keyframes tile-in { from { opacity: 0; transform: translateY(16px); } }
.tile .frame { width: 100%; max-width: 100%; aspect-ratio: 2/3; overflow: hidden; position: relative; background: var(--field); border-radius: 3px; cursor: pointer;
  box-shadow: var(--lift-0); transition: transform .5s var(--ease), box-shadow .5s var(--ease); }
.tile:hover .frame { transform: translateY(-4px); box-shadow: var(--lift-1); }
.tile .frame:focus-visible { outline-offset: 5px; }
.tile .frame .card { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
/* crop marks around the selected proof */
.tile::before { content: ''; position: absolute; z-index: 1; left: -10px; right: -10px; top: -10px; bottom: 30px; pointer-events: none;
  --k: var(--fg); --l: 14px; --w: 1.5px;
  background:
    linear-gradient(var(--k) 0 0) left top / var(--l) var(--w), linear-gradient(var(--k) 0 0) left top / var(--w) var(--l),
    linear-gradient(var(--k) 0 0) right top / var(--l) var(--w), linear-gradient(var(--k) 0 0) right top / var(--w) var(--l),
    linear-gradient(var(--k) 0 0) left bottom / var(--l) var(--w), linear-gradient(var(--k) 0 0) left bottom / var(--w) var(--l),
    linear-gradient(var(--k) 0 0) right bottom / var(--l) var(--w), linear-gradient(var(--k) 0 0) right bottom / var(--w) var(--l);
  background-repeat: no-repeat; opacity: 0; transform: scale(1.05); transition: opacity .3s var(--ease), transform .5s var(--ease); }
.tile.active::before { opacity: 1; transform: none; }
.tile .meta { height: 40px; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 1px; font-size: 12px; }
.tile .meta b { display: block; min-width: 0; font-weight: 500; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color .2s; }
.tile .meta .no { font: 500 10px var(--font-mono); letter-spacing: .06em; color: var(--faint); margin-right: 8px; }
.tile.active .meta b, .tile:hover .meta b { color: var(--fg); }
.tile.active .meta .no { color: var(--fg); }
.tile .meta .acts { display: flex; gap: 2px; flex: none; opacity: 0; transition: opacity .2s; }
.tile:hover .acts, .tile:focus-within .acts, .tile.active .acts { opacity: 1; }
.tile .meta button { padding: 3px 8px; font-size: 11.5px; background: transparent; color: var(--muted); }
.tile .meta button:hover { background: var(--field-hi); color: var(--fg); }
@media (hover: none) { .tile .meta .acts { opacity: 1; } }

/* ---- spec sheet (inspector) ---- */
.panel { position: sticky; top: var(--bar-h); height: calc(100vh - var(--bar-h)); height: calc(100dvh - var(--bar-h)); overflow-y: auto; overscroll-behavior: contain;
  background: var(--paper); border-left: 1px solid var(--hair); padding: 0 22px 56px; counter-reset: sec; scrollbar-width: thin; scrollbar-color: var(--hair-2) transparent; }
.panel::-webkit-scrollbar { width: 10px; }
.panel::-webkit-scrollbar-thumb { background: var(--hair-2); border-radius: 10px; border: 3px solid var(--paper); }
.block { padding: 18px 0 20px; border-bottom: 1px solid var(--hair); display: grid; gap: 10px; }
.block > h2 { margin: 0; display: flex; align-items: center; gap: 10px; font: 600 13px/1.2 var(--font-ui); color: var(--fg); }
.block:not(.head) > h2 { cursor: pointer; user-select: none; margin: -6px 0; padding: 6px 0; border-radius: 4px; }
.block:not(.head) > h2::before { counter-increment: sec; content: counter(sec, decimal-leading-zero); width: 18px; font: 500 10px/1 var(--font-mono); letter-spacing: .08em; color: var(--faint); }
.block:not(.head) > h2::after { content: ''; margin-left: auto; margin-right: 3px; width: 6px; height: 6px; border: solid var(--muted); border-width: 0 1.5px 1.5px 0;
  transform: translateY(-2px) rotate(45deg); transition: transform .35s var(--ease); }
.block.collapsed > h2::after { transform: rotate(-45deg); }
.block.collapsed { padding-bottom: 18px; }
.block.collapsed > :not(h2) { display: none; }
.block > :not(h2) { animation: unfold .4s var(--ease) backwards; }
@keyframes unfold { from { opacity: 0; transform: translateY(-4px); } }
.block.head { padding: 24px 0 20px; gap: 12px; }
.head h2 { font: 500 10px/1 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.style-name { margin: -4px 0 4px; font: 600 26px/1.12 var(--font-display); letter-spacing: -.02em; text-wrap: balance; }
.head .actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.head .actions .primary { grid-column: 1 / -1; height: 40px; font-size: 13px; }
.head .actions button { padding-inline: 4px; white-space: nowrap; }

.row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; min-height: 30px; }
.row.top { align-items: flex-start; }
.row.top > label { padding-top: 6px; }
.row > label { flex: 0 0 72px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.check > label { flex: 1; color: var(--fg); white-space: normal; line-height: 1.45; }
.row input[type=range] { flex: 1; min-width: 0; }
.row input[type=text], .row input[type=password], .row select, .row textarea { flex: 1; min-width: 0; }
.row .val { width: 38px; text-align: right; color: var(--muted); font: 11px var(--font-mono); font-variant-numeric: tabular-nums; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.hint { margin: 0; font-size: 11.5px; color: var(--muted); line-height: 1.6; }
.warn { margin: 0; font-size: 12px; color: var(--far); }

/* custom-style groups fold like the sections */
#controls { display: grid; }
.ctl-sec { display: grid; gap: 4px; padding-bottom: 10px; border-top: 1px solid var(--hair); }
.ctl-sec:first-child { border-top: 0; }
.ctl-sec.collapsed { padding-bottom: 0; }
.ctl-sec.collapsed > .row { display: none; }
.ctl-sec > .row { animation: unfold .35s var(--ease) backwards; }
#controls .ctl-group { margin: 0; padding: 11px 0 7px; border: 0; display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none;
  font: 500 11.5px/1 var(--font-ui); letter-spacing: .06em; color: var(--muted); transition: color .15s; }
#controls .ctl-group:hover { color: var(--fg); }
#controls .ctl-group::after { content: ''; width: 5px; height: 5px; margin-right: 4px; border: solid currentColor; border-width: 0 1.5px 1.5px 0;
  transform: translateY(-2px) rotate(45deg); transition: transform .35s var(--ease); }
#controls .ctl-sec.collapsed .ctl-group::after { transform: rotate(-45deg); }
#controls .row[hidden] { display: none; }

/* naming chips: swatch, editable name, ΔE pill */
.chips { display: grid; gap: 2px; margin-inline: -8px; }
.chip { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 12px; background: transparent; border: 0; border-radius: 9px; padding: 6px 8px;
  transition: background-color .15s; }
.chip:hover, .chip:focus-within { background: var(--field); }
.chip i { width: 34px; height: 34px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.chip-main { display: grid; min-width: 0; gap: 1px; }
.chip input { border: none; background: none; padding: 0; font-weight: 600; font-size: 13px; min-width: 0; width: 100%; border-radius: 3px; }
.chip input:focus { outline: none; box-shadow: 0 1.5px 0 var(--fg); }
.chip small { color: var(--muted); font: 10.5px var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q { font: 500 10px var(--font-mono); font-style: normal; padding: 3px 7px; border-radius: 999px; white-space: nowrap; background: color-mix(in srgb, currentColor 11%, transparent); }
.q-ok { color: var(--ok); } .q-mid { color: var(--mid); } .q-far { color: var(--far); } .q-ai, .q-edit { color: var(--muted); }
.credits { padding-top: 18px; font-size: 11px; line-height: 1.6; color: var(--muted); }

#toast { position: fixed; z-index: 50; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 22px); background: var(--ink); color: var(--on-ink);
  padding: 9px 16px; border-radius: 999px; font-size: 12.5px; font-weight: 500; box-shadow: 0 10px 30px -10px rgba(0,0,0,.45);
  opacity: 0; transform: translate(-50%, 14px) scale(.96); transition: opacity .25s var(--ease), transform .45s var(--spring); pointer-events: none; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#workbench { position: fixed; left: -100000px; top: 0; }

/* ---- focus view: one poster at full size over the contact sheet; the panel stays live ---- */
body.focusing { overflow: hidden; }
#focus { position: fixed; z-index: 15; top: var(--bar-h); left: 0; right: 384px; bottom: 0; display: flex; flex-direction: column;
  background: var(--bg); animation: focus-in .35s var(--ease); }
#focus[hidden] { display: none; }
@keyframes focus-in { from { opacity: 0; } }
#focusStage { position: relative; flex: 1; margin: 28px 40px 0; cursor: zoom-out; }
#focusStage > .card { position: absolute; left: 50%; top: 50%; transform-origin: 50% 50%; border-radius: 3px; cursor: default;
  box-shadow: 0 2px 6px rgba(0,0,0,.08), 0 40px 80px -40px rgba(0,0,0,.55); animation: focus-card .5s var(--ease); }
@keyframes focus-card { from { opacity: 0; translate: 0 18px; } }
.focus-bar { height: 64px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 24px 0 40px; }
#focusTitle { font: 500 12px var(--font-mono); letter-spacing: .04em; white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.focus-acts { display: flex; align-items: center; gap: 6px; flex: none; }
.focus-acts button { height: 34px; display: inline-flex; align-items: center; justify-content: center; }
.focus-acts button.icon { width: 34px; padding: 0; }
#focus svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* second tap for the share sheet when rendering outlived the first tap */
#shareReady { position: fixed; z-index: 60; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); transform: translateX(-50%);
  width: min(420px, calc(100vw - 24px)); display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 10px 10px 10px 10px; background: var(--paper); border: 1px solid var(--hair); border-radius: 14px; box-shadow: 0 18px 40px -16px rgba(0,0,0,.45);
  animation: sheet-in .45s var(--spring); }
#shareReady[hidden] { display: none; }
@keyframes sheet-in { from { opacity: 0; transform: translate(-50%, 16px) scale(.96); } }
#shareReady img { width: 44px; height: 56px; object-fit: cover; border-radius: 4px; box-shadow: 0 0 0 1px var(--hair); }
#shareReady div { display: grid; min-width: 0; font-size: 12.5px; }
#shareReady div span { color: var(--muted); font-size: 11.5px; }
#shareReady button { height: 38px; padding: 0 16px; }

/* corner mark on posters (logical px; size set inline from the canvas width) */
.card-mark { position: absolute; z-index: 6; padding: .42em .85em; border-radius: 999px; line-height: 1; white-space: nowrap; pointer-events: none;
  font-family: 'DM Mono', ui-monospace, monospace; letter-spacing: .06em; color: rgba(255,255,255,.92); background: rgba(0,0,0,.3); }

::view-transition-old(root), ::view-transition-new(root) { animation-duration: .38s; animation-timing-function: var(--ease); }

@media (max-width: 900px) {
  .bar { height: auto; flex-wrap: wrap; gap: 10px 12px; padding: 10px 14px; }
  .strip { order: 5; flex: 1 0 100%; max-width: none; height: 26px; }
  .note { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .panel { position: static; height: auto; border-left: none; border-top: 1px solid var(--hair); }
  #gallery { padding: 18px 16px 40px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 22px 16px; }
  #focus { top: 0; right: 0; z-index: 30; }
  #focusStage { margin: calc(env(safe-area-inset-top, 0px) + 16px) 16px 0; }
  .focus-bar { padding: 0 12px calc(env(safe-area-inset-bottom, 0px)); height: calc(64px + env(safe-area-inset-bottom, 0px)); }
  #focusTitle { display: none; }
  .focus-acts { flex: 1; justify-content: space-between; }
}
@media (max-width: 520px) { .drop span { display: none; } .bar-acts #reshuffle { font-size: 0; gap: 0; width: 34px; padding: 0; justify-content: center; } }
@media (prefers-reduced-motion: reduce) { *, ::before, ::after { animation: none !important; transition: none !important; } }

/* ===================== CARD (logical px, scaled in preview) ===================== */
.card { position: relative; overflow: hidden; background: #111; color: #fff; }
.card-photo, .card-tint, .card-vignette { position: absolute; inset: 0; }
.card-photo { background-size: cover; background-position: center; }
.card-vignette { background: radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,.85) 100%); }

.sw { display: flex; align-items: center; position: relative; }
.sw-labels { position: relative; width: 100%; }
.sw-name { line-height: 1.05; }
.sw-sub { margin-top: 2px; }
.sw-meta { display: flex; gap: 36px; margin-top: 6px; line-height: 1.2; }
.sw-meta-key { opacity: .7; font-size: .8em; letter-spacing: .08em; margin-bottom: 2px; }
.sw-index { position: absolute; right: 0; bottom: 0; }

.layout-stack, .layout-editorial { position: absolute; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; }
.layout-grid { position: absolute; left: 50%; transform: translateX(-50%); display: grid; }
.layout-strip { position: absolute; left: 0; right: 0; bottom: 0; display: flex; }
.strip-cell { flex: 1; display: flex; align-items: flex-end; padding: 16px 12px; }
.layout-rail { position: absolute; top: 0; bottom: 0; display: flex; flex-direction: column; }
.rail-cell { flex: 1; display: flex; align-items: center; padding: 0 22px; }
.layout-split { position: absolute; left: 0; right: 0; bottom: 0; padding: 36px 40px; display: flex; flex-direction: column; gap: 22px; }
.split-title { font-size: 20px; letter-spacing: .3em; }
.split-row { display: flex; gap: 14px; flex: 1; }
.split-cell { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.split-chip { flex: 1; min-height: 160px; }
.split-cell .sw-name { font-size: 13px !important; }
.split-cell .sw-meta { font-size: 12px !important; margin-top: 2px; }
.ed-row { display: flex; align-items: center; gap: 22px; }
.ed-dot { width: 44px; height: 44px; border-radius: 50%; flex: none; box-shadow: 0 4px 14px rgba(0,0,0,.4); }

.card-title { position: absolute; left: 0; right: 0; text-align: center; }
.card-title.top { top: 36px; }
.card-title.bottom { bottom: 40px; }
.ct-kicker { font-size: 15px; opacity: .85; letter-spacing: .04em; }
.ct-main { font-size: 26px; margin-top: 2px; }
.ct-footer { font-size: 22px; margin-top: 8px; }
.ct-dots { display: flex; justify-content: center; gap: 8px; }
.ct-dots span { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }


/* ---- round layouts (render-round.js) ---- */
.round-bg, .round-svg { position: absolute; inset: 0; }
.round-svg { width: 100%; height: 100%; overflow: visible; }
.disc { position: absolute; border-radius: 50%; }
.disc-ring { box-shadow: 0 0 0 6px rgba(255,255,255,.9), 0 12px 30px rgba(0,0,0,.3); }
.disc-label { display: flex; align-items: center; justify-content: center; text-align: center; padding: 8%; }
.disc-label .sw-meta, .overlap-label .sw-meta, .ring-label .sw-meta { justify-content: center; gap: 14px; }
.round-label { position: absolute; transform: translateY(-50%); }
.round-label.is-left { text-align: right; }
.round-label.is-left .sw-meta { justify-content: flex-end; }
.round-label .sw-meta { gap: 16px; }
.fan-ray { position: absolute; height: 0; transform-origin: 0 50%; }
.fan-label { position: absolute; top: 0; transform: translateY(-50%); white-space: nowrap; }
.fan-label.is-flip { text-align: right; }
.fan-label.is-flip .sw-meta { justify-content: flex-end; }
.fan-label .sw-meta { gap: 12px; margin-top: 2px; }
.overlap-wrap { position: absolute; inset: 0; isolation: isolate; }
.overlap-label { position: absolute; text-align: center; padding: 0 4px; }
.overlap-tick { width: 10px; height: 10px; border-radius: 50%; margin: 0 auto 8px; }
.ring-label { position: absolute; transform: translate(-50%, -50%); text-align: center; white-space: nowrap; }
.ring-label .sw-name { line-height: 1; }
.ring-label .sw-meta { margin-top: 2px; }
.dotband { position: absolute; left: 0; right: 0; bottom: 0; }
.dotband-title { position: absolute; left: 0; right: 0; text-align: center; font-size: 15px; letter-spacing: .32em; text-transform: uppercase; opacity: .7; }

/* ---- optional details (render-fx.js) ---- */
.sw.has-decor { overflow: hidden; }
.sw-fx { position: absolute; inset: 0; border-radius: inherit; pointer-events: none; }
.sw-stripe { inset: auto; }
.sw-wrap { position: relative; }
.sw-card { display: flex; flex-direction: column; padding: 0; align-items: stretch; overflow: hidden; }
.sw-color { position: relative; flex: none; width: auto; align-self: stretch; }
.sw-caption { position: relative; }
.sw-bar { height: 3px; width: 36px; margin: 8px 0 2px; }
.sw-divider { width: 100%; margin: 7px 0 5px; font-size: 12px; letter-spacing: .3em; }
.card-grain { position: absolute; inset: 0; pointer-events: none; }
.card-credit { position: absolute; font-size: 13px; letter-spacing: .08em; opacity: .75; }
.card-badge { position: absolute; font-size: 12px; letter-spacing: .14em; border: 1.5px solid; border-radius: 999px; padding: 6px 12px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-frame { position: absolute; inset: 0; border-style: solid; pointer-events: none; box-sizing: border-box; }
.card-frame-inner { position: absolute; border: 1px solid; pointer-events: none; }
.ct-rule { width: 48px; height: 1.5px; margin: 10px auto 0; opacity: .8; }

/* ---- value display (values.js) ----
   Arrangement of .sw-meta cells. Selectors carry .sw-meta so they win over the round-layout
   gap/justify rules above. Decoration (chip/box/invert) is applied to .sw-meta-val by render-fx.js. */
.sw-meta { font-variant-numeric: tabular-nums; }
.sw-meta.vs-columns { flex-wrap: wrap; row-gap: 6px; } /* many models wrap instead of overflowing; column gap keeps its original value */
.sw-meta.vs-inline { flex-wrap: wrap; gap: 3px 18px; }
.sw-meta.vs-inline .sw-meta-cell { display: flex; align-items: baseline; gap: .5em; }
.sw-meta.vs-inline .sw-meta-key { margin: 0; }
.sw-meta.vs-stack, .sw-meta.vs-hero { display: grid; grid-template-columns: max-content; gap: 3px; }
.sw-meta.vs-stack .sw-meta-cell { display: flex; align-items: baseline; gap: .5em; }
.sw-meta.vs-stack .sw-meta-key { margin: 0; }
.sw-meta.vs-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; width: 100%; }
.sw-meta.vs-list .sw-meta-cell { display: flex; justify-content: space-between; align-items: baseline; gap: 1.4em; padding: .38em 0; border-top: 1px solid color-mix(in srgb, currentColor 28%, transparent); }
.sw-meta.vs-list .sw-meta-key { margin: 0; }
.sw-meta.vs-joined { display: block; }
.sw-meta.vs-hero .is-hero .sw-meta-val { font-size: 2.1em; font-weight: 600; line-height: 1.05; letter-spacing: -.01em; }
.sw-meta.vs-hero .sw-meta-cell:not(.is-hero) { opacity: .88; font-size: .9em; }
.sw-meta.vs-hero .sw-meta-cell:not(.is-hero) { display: flex; align-items: baseline; gap: .5em; }
.sw-meta.vs-hero .sw-meta-key { margin: 0; }

/* ---- value panel (UI) ---- */
.vchips { display: flex; flex-wrap: wrap; gap: 6px; }
.vchip { position: relative; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font: 12px var(--font-mono); cursor: pointer; background: var(--sunken); user-select: none; }
.vchip:has(input:checked) { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.vchip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.vchip input { position: absolute; opacity: 0; width: 0; height: 0; }
.row label.inl { flex: none; display: inline-flex; align-items: center; gap: 4px; color: var(--fg); }
.vtable { display: grid; gap: 4px; }
.vrow { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; align-items: start; background: var(--sunken); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px 5px 6px; }
.vrow i { width: 18px; height: 18px; border-radius: 3px; margin-top: 2px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.14); }
.vvals { display: flex; flex-wrap: wrap; gap: 2px 4px; min-width: 0; }
.vval { background: none; border: none; border-radius: 3px; padding: 1px 4px; font: 12px var(--font-mono); cursor: copy; color: var(--fg); text-align: left; }
.vval:hover { background: var(--line); }
.vval small { color: var(--muted); font-size: 10px; margin-right: 4px; letter-spacing: .04em; }
.vdetails summary { cursor: pointer; font-size: 13px; padding: 4px 0; }
.vdetails[open] summary { margin-bottom: 6px; }
.sw-meta.has-index { padding-right: 2.6em; }

/* ---- font library (fontlib.js) ---- */
#fontBlock.f-over { outline: 2px dashed var(--accent); outline-offset: 2px; }
.flist { display: grid; gap: 4px; }
.frow { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; align-items: center; gap: 8px; background: var(--sunken); border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px 5px 8px; }
.fprev { font-size: 18px; line-height: 1.1; white-space: nowrap; overflow: hidden; }
.fname { display: grid; min-width: 0; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fname small { color: var(--muted); font-weight: 400; font-size: 11px; }
.facts { display: flex; gap: 4px; }
.facts button { padding: 2px 8px; font-size: 12px; }
.facts .fdel { color: var(--far); }
.hint.f-ok { color: var(--ok); } .hint.f-warn { color: var(--mid); } .hint.f-err { color: var(--far); }

/* ---- site statement: third-party data and licences ---- */
.credits .legal summary { cursor: pointer; font-size: 12px; color: var(--fg); padding: 2px 0; }
.credits .legal h3 { margin: 12px 0 4px; font-size: 11px; font-weight: 600; letter-spacing: .08em; color: var(--muted); }
.credits .legal ul { margin: 0; padding-left: 16px; display: grid; gap: 6px; }
.credits .legal p { margin: 4px 0; }
.credits .legal a { color: var(--fg); text-underline-offset: 2px; }
.credits .legal .mit { font-size: 10px; line-height: 1.5; opacity: .85; }
