:root {
  --bg: #f1f4f8;
  --surface: #ffffff;
  --ink: #0b2447;
  --muted: #55677a;
  --line: #cfd9e5;
  --accent: #003970;
  --accent-ink: #ffffff;
  --focus: #2f7fc1;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgba(11,36,71,.06), 0 12px 32px rgba(11,36,71,.14);
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1626;
    --surface: #10233b;
    --ink: #eaf2fa;
    --muted: #93a8bd;
    --line: #23405f;
    --accent: #dcecfa;
    --accent-ink: #0a1626;
    --focus: #7db8ea;
    --danger: #ff8a80;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 16px 40px rgba(0,0,0,.45);
  }
}
:root[data-theme="dark"] {
  --bg: #0a1626;
  --surface: #10233b;
  --ink: #eaf2fa;
  --muted: #93a8bd;
  --line: #23405f;
  --accent: #dcecfa;
  --accent-ink: #0a1626;
  --focus: #7db8ea;
  --danger: #ff8a80;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 16px 40px rgba(0,0,0,.45);
}
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
.page { max-width: 1100px; margin: 0 auto; padding: 28px 20px 48px; }
h1 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.1rem); line-height: 1.15; margin: 0 0 6px; letter-spacing: -0.01em; }
.lede { margin: 0 0 26px; color: var(--muted); max-width: 52ch; }

.grid { display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) {
  .grid { grid-template-columns: minmax(0, 1fr) 380px; gap: 44px; }
  .stage { position: sticky; top: 24px; }
}

.poster-wrap { position: relative; width: 100%; max-width: 560px; margin: 0 auto; border-radius: 8px; overflow: hidden; box-shadow: var(--shadow); background: #e8ecf1; }
@media (min-width: 900px) {
  .poster-wrap { max-width: min(560px, calc((100vh - 110px) * 0.7994)); }
}
canvas#poster { display: block; width: 100%; height: auto; }
/* sits exactly over the photo frame; its position is set from CONFIG in script.js */
.frame-hit { position: absolute; touch-action: none; cursor: grab; outline-offset: -3px; }
.frame-hit.dragging { cursor: grabbing; }
.frame-hit:focus-visible { outline: 3px solid var(--focus); }
.stage-hint { text-align: center; color: var(--muted); font-size: .875rem; margin: 12px 0 0; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; display: grid; gap: 22px; }
.field { display: grid; gap: 8px; }
.field > label, .field > .label { font-weight: 600; font-size: .95rem; }
input[type="text"] {
  width: 100%; font: inherit; color: var(--ink); background: transparent;
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; min-height: 46px;
}
input[type="text"]::placeholder { color: var(--muted); opacity: .8; }

button { font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 10px; font-weight: 600;
  border: 1px solid var(--line); background: transparent; color: var(--ink);
}
.btn:hover:not(:disabled) { border-color: var(--ink); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { opacity: .92; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { min-height: 40px; min-width: 40px; padding: 0 12px; }

.drop { border: 1.5px dashed var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 10px; justify-items: start; transition: border-color .15s, background-color .15s; }
.drop.over { border-color: var(--focus); background: color-mix(in srgb, var(--focus) 10%, transparent); }
.drop .file-name { color: var(--muted); font-size: .875rem; overflow-wrap: anywhere; }
input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.zoom-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
input[type="range"] { width: 100%; accent-color: var(--focus); min-height: 28px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; }
.muted { color: var(--muted); font-size: .875rem; margin: 0; }
.exports { display: grid; gap: 10px; }
.exports .row > .btn { flex: 1 1 auto; white-space: nowrap; }
#status { min-height: 1.4em; font-size: .9rem; margin: 0; }
#status.error { color: var(--danger); }
