/* Layout: cover stage on the left (sticky on desktop, top on phones), controls column on the right. */
:root {
  --bg: #F3EFEE;          /* studio wall, slightly rosy neutral */
  --panel: #FFFFFF;
  --ink: #1D1A1C;
  --muted: #6E6569;
  --line: #E2DADC;
  --brand: #B0175B;       /* deep magazine rose */
  --brand-ink: #FFFFFF;
  --ok: #1F7A4D; --ok-bg: #E7F4EC;
  --warn: #8A5A00; --warn-bg: #FFF4DB;
  --err: #A3172E; --err-bg: #FDE9EC;
  --busy-bg: #EEF0FA; --busy: #33407A;
  --stage: #E7E1E1;
  --display: "Playfair Display", "Didot", "Bodoni 72", Georgia, serif;
  --ui: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161314; --panel: #211D1F; --ink: #F1ECEE; --muted: #A99EA3; --line: #3A3236;
    --brand: #F0559A; --brand-ink: #1A0710; --stage: #0F0D0E;
    --ok: #7FD6A7; --ok-bg: #12291D; --warn: #F2C46B; --warn-bg: #2E2410; --err: #FF8A9C; --err-bg: #34141A; --busy-bg: #1B1F33; --busy: #AEB8F2;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161314; --panel: #211D1F; --ink: #F1ECEE; --muted: #A99EA3; --line: #3A3236;
  --brand: #F0559A; --brand-ink: #1A0710; --stage: #0F0D0E;
  --ok: #7FD6A7; --ok-bg: #12291D; --warn: #F2C46B; --warn-bg: #2E2410; --err: #FF8A9C; --err-bg: #34141A; --busy-bg: #1B1F33; --busy: #AEB8F2;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--ui); margin: 0; }
.topbar { padding-block: 14px 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; border-bottom: 1px solid var(--line); }
.brand { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.brand-house { color: var(--brand); font-weight: 700; }
.brand-sep { margin: 0 6px; }
.topbar h1 { font: 700 clamp(20px, 3vw, 26px)/1.1 var(--display); margin: 0; text-wrap: balance; }
.topbar h1 em { font-style: italic; font-weight: 400; color: var(--muted); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(330px, 440px); gap: 20px; padding-block: 16px 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); align-items: start; }
.stage-wrap { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 12px); min-width: 0; }
.stage { height: calc(100vh - 130px); min-height: 360px; display: grid; place-items: center; background: var(--stage); border-radius: var(--r); padding: 14px; }
#cover { display: block; box-shadow: 0 1px 2px rgba(0,0,0,.18), 0 12px 32px rgba(0,0,0,.18); touch-action: auto; max-width: 100%; }
#cover.movable { cursor: grab; touch-action: none; }
#cover.dragging { cursor: grabbing; }
.stage-hint { margin: 8px 2px 0; font-size: 13px; color: var(--muted); }

.controls { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; }
.tabs { display: flex; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; position: sticky; top: env(safe-area-inset-top, 0px); background: var(--panel); z-index: 2; border-radius: var(--r) var(--r) 0 0; }
.tab { flex: 1 0 auto; font: 500 14px var(--ui); color: var(--muted); background: none; border: 0; padding: 13px 12px 11px; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brand); }
.tab:focus-visible, .btn:focus-visible, .swatch:focus-visible, .font-opt:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.panel { display: none; padding: 16px 18px 20px; flex-direction: column; gap: 14px; }
.panel.active { display: flex; }
.panel h2 { font: 700 21px/1.2 var(--display); margin: 0; }
.panel h3 { font: 700 12px var(--ui); letter-spacing: .12em; text-transform: uppercase; margin: 6px 0 0; color: var(--muted); }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }

.upload { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; cursor: pointer; }
.upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-btn { display: inline-block; background: var(--brand); color: var(--brand-ink); font-weight: 700; padding: 11px 18px; border-radius: 999px; }
.upload input:focus-visible + .upload-btn { outline: 2px solid var(--ink); outline-offset: 2px; }
.upload-sub { font-size: 13px; color: var(--muted); }
#photo-tools { display: flex; flex-direction: column; gap: 12px; }

.btn { font: 500 14px var(--ui); color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 9px 15px; cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--panel); border-color: var(--ink); font-weight: 700; }
.btn.quiet { border: 0; padding-left: 0; color: var(--muted); text-decoration: underline; align-self: flex-start; background: none; }
.btn.icon { width: 38px; height: 38px; padding: 0; display: grid; place-items: center; }
.btn:disabled { opacity: .5; cursor: progress; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.status { margin: 0; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.status[data-kind="ok"] { background: var(--ok-bg); color: var(--ok); }
.status[data-kind="warn"] { background: var(--warn-bg); color: var(--warn); }
.status[data-kind="error"] { background: var(--err-bg); color: var(--err); }
.status[data-kind="busy"] { background: var(--busy-bg); color: var(--busy); }
.status[data-kind="neutral"] { background: var(--bg); color: var(--ink); }
.status[data-kind="ok"]::before { content: "✓ "; font-weight: 700; }
progress { width: 100%; height: 6px; accent-color: var(--brand); }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label, .label { font-size: 13px; font-weight: 500; }
.field input[type="text"], .field input[type="date"], .field select, .list input { font: 15px var(--ui); color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; min-width: 0; }
.field input:focus, .field select:focus, .list input:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
input[type="range"] { width: 100%; accent-color: var(--brand); }
.nudge { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px; }
.nudge-pad { display: flex; gap: 6px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.check input { accent-color: var(--brand); width: 18px; height: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }

.color-group { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.color-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cname { font-size: 13px; color: var(--muted); }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 7px; }
.swatch { aspect-ratio: 1; border-radius: 50%; border: 1px solid rgba(0,0,0,.18); background: var(--sw); cursor: pointer; padding: 0; position: relative; max-width: 100%; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--ink); }
.custom { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.custom input { width: 44px; height: 30px; border: 1px solid var(--line); border-radius: 6px; padding: 2px; background: var(--panel); }

.fonts { display: flex; flex-direction: column; gap: 8px; }
.font-opt { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; color: var(--ink); display: flex; flex-direction: column; gap: 2px; }
.font-opt[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.font-sample { font-size: 24px; line-height: 1.15; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.font-meta { font-size: 12.5px; color: var(--muted); }
.font-meta b { color: var(--ink); font-weight: 500; }

.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 0; font-weight: 500; }
details { border-top: 1px solid var(--line); padding-top: 10px; }
summary { cursor: pointer; font-weight: 500; }

.build { padding: 10px 18px 14px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .stage-wrap { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 3; background: var(--bg); padding-bottom: 6px; }
  .stage { height: 52vh; min-height: 300px; padding: 8px; }
  .stage-hint { font-size: 12px; margin-top: 4px; }
  .tabs { position: static; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
