/* Layout: live preview on a dark "screening room" stage, controls in a scrolling rail on the right; stacks on phones.
   The UI accent follows the colour pulled from the current poster. */
:root {
  --bg: #0f0e10;
  --panel: #18171a;
  --raise: #221f24;
  --line: #2f2c33;
  --fg: #eeeae3;
  --muted: #958f88;
  --accent: #e9b65a;
  --f-ui: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-label: "DM Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --f-display: "Instrument Serif", Georgia, "Times New Roman", serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.45 var(--f-ui); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { display: grid; grid-template-columns: minmax(0, 1fr) 400px; height: 100%; }

/* ---------- stage ---------- */
.stage { display: flex; flex-direction: column; gap: 14px; min-width: 0; min-height: 0; padding: 18px 28px 22px; }
.topbar { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 20px; flex-wrap: wrap; }
.brand { font-family: var(--f-display); font-size: 30px; line-height: 1; letter-spacing: .005em; margin: 0; font-weight: 400; }
.brand em { color: var(--accent); transition: color .4s; }
.specs { font-family: var(--f-label); font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-variant-numeric: tabular-nums; }
.specs b { color: var(--fg); font-weight: 500; }
.canvas-wrap {
  flex: 1; min-height: 0; position: relative; display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line);
  background: radial-gradient(ellipse at 50% 45%, #1d1b20 0%, var(--bg) 70%);
}
#preview { display: block; box-shadow: 0 30px 90px rgba(0,0,0,.55); }
.drop-veil {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 10px;
  border: 2px dashed var(--accent); background: rgba(10,9,11,.78);
  font-family: var(--f-display); font-size: 34px; pointer-events: none;
}
.hint { font-size: 12.5px; color: var(--muted); margin: 0; }
.hint kbd { font-family: var(--f-label); font-size: 11px; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }

/* ---------- rail ---------- */
.rail { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: var(--panel); }
.rail-scroll { flex: 1; overflow-y: auto; }
details { border-bottom: 1px solid var(--line); }
summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  padding: 15px 20px; font-family: var(--f-label); font-size: 11.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font-size: 15px; }
details[open] summary::after { content: "–"; }
details[open] summary { color: var(--fg); }
.sec { display: grid; gap: 14px; padding: 0 20px 20px; }

.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .lbl { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.lbl output, .field > label output { font-family: var(--f-label); font-size: 11.5px; color: var(--fg); font-variant-numeric: tabular-nums; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
input[type="text"], textarea, select {
  width: 100%; background: var(--raise); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; min-width: 0;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
input[type="text"]:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; }
.textmeta { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--muted); }
.textmeta .warn { color: var(--accent); }
.linkbtn { background: none; border: none; padding: 0; cursor: pointer; color: var(--accent); font-size: 11.5px; text-decoration: underline; text-underline-offset: 2px; }

input[type="range"] { width: 100%; accent-color: var(--accent); margin: 0; }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.toggles { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.toggles label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; cursor: pointer; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  flex: 1 1 auto; background: var(--raise); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; cursor: pointer;
  font-family: var(--f-label); font-size: 12px; white-space: nowrap;
}
.seg button small { display: block; font-family: var(--f-ui); font-size: 10.5px; color: var(--muted); }
.seg button[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.seg button:hover { border-color: #4a4650; }

.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.presets button {
  background: var(--raise); border: 1px solid var(--line); border-radius: 8px; padding: 12px 12px 10px; text-align: left; cursor: pointer;
  display: grid; gap: 2px;
}
.presets button span { font-size: 24px; line-height: 1.1; }
.presets button small { font-size: 11px; color: var(--muted); }
.presets .chrome-chip {
  background: linear-gradient(180deg, #fff 0%, #dfe4e8 22%, #8b959e 46%, #2a2f35 50%, var(--accent) 54%, #f4f6f8 85%, #a7b0b8 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.presets button[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.uploader { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  background: var(--raise); border: 1px solid var(--line); border-radius: 6px; padding: 9px 12px; font-size: 13px; text-align: center;
}
.btn:hover { border-color: #4a4650; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #141113; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.08); }
.samples { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.samples button { padding: 0; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; cursor: pointer; background: var(--raise); aspect-ratio: 2 / 3; max-width: 100%; }
.samples img { display: block; width: 100%; height: 100%; object-fit: cover; }
.samples button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatches button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.swatches button[aria-pressed="true"] { border-color: var(--fg); }
.swatches input[type="color"] { width: 30px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: none; cursor: pointer; }
.swatches input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.swatches input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }

.exportbar { display: grid; gap: 10px; padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: var(--panel); }
.exportbar .row { grid-template-columns: 1.3fr 1fr; }
.exportbar .actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.toast { font-size: 12px; color: var(--muted); min-height: 1em; margin: 0; }

@media (max-width: 900px) {
  .app { display: block; height: auto; }
  .stage { padding: 14px 16px; }
  .canvas-wrap { height: 62vh; flex: none; }
  .rail { border-left: none; border-top: 1px solid var(--line); }
  .rail-scroll { overflow: visible; }
  .exportbar { position: sticky; bottom: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
