/* ===== Tokens ===== */
:root {
  --ink-900: #1f0806;
  --ink-800: #33100a;
  --ink-700: #4d1710;
  --line: rgba(255, 190, 170, 0.14);
  --line-strong: rgba(255, 190, 170, 0.28);
  --paper: #f7ede8;
  --muted: #cf9c90;
  --accent: #ff2f00;
  --accent-dim: #c92400;
  --accent-soft: rgba(255, 47, 0, 0.16);
  --gold: #f1c400;

  --font-display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--ink-900);
  color: var(--paper);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255, 190, 170, 0.16) 1px, transparent 0);
  background-size: 22px 22px;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.wrap {
  max-width: 460px;
  margin: 0 auto;
  padding: 28px 20px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--gold);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
}

.eyebrow::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(241, 196, 0, 0.18);
  flex: none;
}

h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(34px, 9vw, 44px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0 0 10px;
  color: var(--paper);
}

.sub {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
  max-width: 34ch;
}

/* ===== Stage panel ===== */
.panel {
  background: linear-gradient(180deg, var(--ink-800), var(--ink-700));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 18px 18px;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.6);
}

.stage-frame {
  position: relative;
  padding: 14px;
}

.bracket {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid var(--accent);
  opacity: 0.9;
}
.bracket.tl { top: 0; left: 0; border-right: none; border-bottom: none; border-top-left-radius: 6px; }
.bracket.tr { top: 0; right: 0; border-left: none; border-bottom: none; border-top-right-radius: 6px; }
.bracket.bl { bottom: 0; left: 0; border-right: none; border-top: none; border-bottom-left-radius: 6px; }
.bracket.br { bottom: 0; right: 0; border-left: none; border-top: none; border-bottom-right-radius: 6px; }

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-md);
  overflow: hidden;
  background:
    repeating-conic-gradient(from 45deg, rgba(255,190,170,0.05) 0deg 90deg, transparent 90deg 180deg) 0 0 / 24px 24px,
    var(--ink-900);
  touch-action: none;
  cursor: grab;
}

.stage.has-photo:active {
  cursor: grabbing;
}

.photo-layer {
  position: absolute;
  inset: 0;
}

.stage.has-photo .photo-layer {
  background: #ffffff;
}

#photoCanvas {
  position: absolute;
  left: 0;
  top: 0;
  display: none;
  user-select: none;
  -webkit-user-drag: none;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  cursor: pointer;
}

.placeholder svg {
  width: 30px;
  height: 30px;
  stroke: var(--muted);
}

.placeholder span {
  font-size: 13px;
  text-align: center;
  line-height: 1.4;
}

.placeholder:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
}

.frame-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
}

/* ===== Readout row ===== */
.readout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 2px 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 100px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  text-transform: uppercase;
}

.status-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}

.status-chip.live {
  color: var(--accent);
  border-color: rgba(255, 47, 0, 0.4);
  background: var(--accent-soft);
}
.status-chip.live::before {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 47, 0, 0.22);
}

.zoom-readout {
  color: var(--muted);
}

.hint {
  margin: 10px 2px 0;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  min-height: 16px;
}

/* ===== Controls ===== */
.controls {
  margin-top: 18px;
  display: none;
}
.controls.visible {
  display: block;
}

.zoom-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.zoom-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--muted);
  flex: none;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 4px;
  background: var(--line-strong);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--ink-900);
  box-shadow: 0 0 0 1px var(--accent);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--ink-900);
  box-shadow: 0 0 0 1px var(--accent);
  cursor: pointer;
  border: none;
}
input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.change-photo {
  display: block;
  margin: 12px auto 0;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 6px 10px;
}
.change-photo:hover {
  color: var(--paper);
}

/* ===== Actions ===== */
.actions {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 15px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15.5px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.btn svg {
  width: 19px;
  height: 19px;
  flex: none;
}
.btn:active {
  transform: scale(0.98);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}
.btn:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:not(:disabled):hover {
  background: #ff3f13;
}

.btn-secondary {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--paper);
}
.btn-secondary:not(:disabled):hover {
  border-color: var(--paper);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

footer {
  margin-top: 30px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  opacity: 0.75;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 12px);
  background: var(--paper);
  color: var(--ink-900);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 12px 18px;
  border-radius: 100px;
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
  max-width: calc(100% - 40px);
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

@media (min-width: 460px) {
  .actions {
    flex-direction: row;
  }
}
