:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --ink: #0c264d;
  --muted: #576d85;
  --line: #d1dde8;
  --accent: #003b7a;
  --accent-ink: #ffffff;
  --gold: #dfb15b;
  --gold-dark: #b88b30;
  --focus: #1d74c4;
  --danger: #c0392b;
  --shadow: 0 4px 20px rgba(12, 38, 77, 0.08), 0 16px 36px rgba(12, 38, 77, 0.12);
  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: #071526;
    --surface: #0e223b;
    --ink: #f0f5fc;
    --muted: #95acc2;
    --line: #1c3959;
    --accent: #dfb15b;
    --accent-ink: #071526;
    --gold: #dfb15b;
    --gold-dark: #e8c47a;
    --focus: #5ca5e8;
    --danger: #ff7675;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4), 0 20px 48px rgba(0, 0, 0, 0.5);
  }
}

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: 'Hind Vadodara', 'Poppins', system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 18px 48px;
}

.page-header {
  margin-bottom: 24px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}

h1 {
  font-size: clamp(1.4rem, 1.1rem + 1.4vw, 2.1rem);
  line-height: 1.25;
  margin: 0 0 6px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.lede {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  max-width: 58ch;
}

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

@media (min-width: 880px) {
  .grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(360px, 1fr);
    gap: 40px;
  }
  .stage {
    position: sticky;
    top: 24px;
  }
}

/* Poster Preview Canvas */
.poster-wrap {
  position: relative;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #092040;
  aspect-ratio: 768 / 1376;
}

@media (min-width: 880px) {
  .poster-wrap {
    max-width: min(440px, calc((100vh - 120px) * (768 / 1376)));
  }
}

canvas#poster {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Interactive Hit Circle */
.frame-hit {
  position: absolute;
  touch-action: none;
  cursor: grab;
  outline-offset: -3px;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.frame-hit:not(.has-photo) {
  cursor: pointer;
}

.frame-hit:not(.has-photo):hover {
  background: rgba(223, 177, 91, 0.15);
}

.frame-hit.dragging {
  cursor: grabbing;
}

.frame-hit:focus-visible {
  outline: 3px solid var(--focus);
}

.stage-hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  margin: 12px 0 0;
  font-weight: 500;
}

/* Controls Panel */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  display: grid;
  gap: 22px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.field {
  display: grid;
  gap: 8px;
}

.field > label, .field > .label {
  font-weight: 600;
  font-size: 0.96rem;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.sub-label {
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--muted);
}

.field-hint {
  font-size: 0.82rem;
  color: var(--muted);
}

input[type="text"] {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: color-mix(in srgb, var(--surface) 90%, var(--bg));
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  min-height: 46px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus {
  border-color: var(--focus);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent);
}

input[type="text"]::placeholder {
  color: var(--muted);
  opacity: 0.75;
}

/* Buttons */
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: 1.5px solid var(--line);
  background: transparent;
  color: var(--ink);
  transition: all 0.15s ease;
}

.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: 0.92;
  transform: translateY(-1px);
}

.btn.primary-outline {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.btn.primary-outline:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn.small {
  min-height: 40px;
  min-width: 40px;
  padding: 0 12px;
}

/* Drag & Drop */
.drop {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 18px;
  display: grid;
  gap: 10px;
  justify-items: start;
  transition: border-color 0.15s, background-color 0.15s;
  background: color-mix(in srgb, var(--surface) 95%, var(--bg));
}

.drop.over {
  border-color: var(--focus);
  background: color-mix(in srgb, var(--focus) 10%, transparent);
}

.drop .file-name {
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Zoom Slider */
.zoom-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  min-height: 28px;
  cursor: pointer;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.muted {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0;
}

/* Exports */
.exports {
  display: grid;
  gap: 12px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.exports .row > .btn {
  flex: 1 1 auto;
  white-space: nowrap;
}

#status {
  min-height: 1.4em;
  font-size: 0.92rem;
  margin: 0;
  font-weight: 500;
}

#status.error {
  color: var(--danger);
}
