/* darkroom: a phone-first photo booth. Dark only. Mobile first; landscape and desktop at the end. */
:root {
  color-scheme: dark;
  --bg: #08060a;
  --bg2: #110c10;
  --card: #18111a;
  --card2: #211823;
  --line: #2c2030;
  --line2: #463448;
  --ink: #f6eff4;
  --mute: #b2a0ae;
  --lime: #c6ff4d;
  --lime-ink: #10140a;
  --lime-soft: #c6ff4d1c;
  --coral: #ff8b68;
  --safe: #ff3b2f;
  --lav: #b9a7ff;
  --r: 14px;
  --pad: 16px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); height: 100%; }
body { margin: 0; height: 100%; color: var(--ink); font: 15px/1.4 var(--font); background: var(--bg); overflow: hidden; }
.defs { position: absolute; }
svg { width: 20px; height: 20px; flex: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--lav); outline-offset: 2px; }
a { color: var(--lime); }
h1, h2, p { margin: 0; }

/* ---------- Shell ---------- */
.app {
  height: 100%; height: 100dvh;
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  background:
    radial-gradient(120% 50% at 50% -10%, #ff3b2f22, transparent 60%),
    var(--bg);
}
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px var(--pad); min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; color: var(--ink); text-decoration: none; font-weight: 800; font-size: 19px; letter-spacing: -.01em; }
.logo { width: 30px; height: 30px; image-rendering: pixelated; border-radius: 7px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line2); background: var(--card); color: var(--ink); font-weight: 700; font-size: 14px;
  max-width: 60vw;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.is-holder { border-color: var(--lime); color: var(--lime); }
.stage { display: contents; }

/* ---------- Tray ---------- */
.trayside { display: grid; justify-items: center; gap: 10px; padding: 0 var(--pad) 10px; }
.tray {
  --size: min(calc(100vw - 2 * var(--pad)), 44dvh, 520px);
  position: relative; width: var(--size); height: var(--size);
  border-radius: 18px; overflow: hidden; isolation: isolate;
  background: #050407;
  box-shadow: inset 0 0 0 1px #ffffff12, 0 18px 50px -20px #ff3b2f55;
}
.safelight {
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(80% 60% at 50% 0%, #ff3b2f33, transparent 70%);
  animation: safelight 4.8s ease-in-out infinite;
}
@keyframes safelight { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
#view, #video { position: absolute; inset: 0; width: 100%; height: 100%; }
#view { image-rendering: pixelated; image-rendering: crisp-edges; }
#video { object-fit: cover; transform: scaleX(-1); background: #000; }
#video.rear { transform: none; }
.busy {
  position: absolute; inset: auto 12px 12px; padding: 12px 14px; border-radius: 12px;
  background: #0a0709e6; border: 1px solid var(--line2); display: grid; gap: 8px; font-weight: 700; font-size: 14px;
}
.bar { display: block; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar i { display: block; width: 40%; height: 100%; background: var(--safe); border-radius: 4px; animation: bar 1.4s ease-in-out infinite; }
.bar.known i { animation: none; transition: width .3s ease-out; }
@keyframes bar { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }
.cam-controls { position: absolute; inset: auto 0 14px; display: flex; justify-content: center; align-items: center; gap: 28px; }
.shutter { width: 68px; height: 68px; border-radius: 50%; border: 4px solid #fff; background: var(--safe); box-shadow: 0 0 0 4px #0006; }
.shutter:active { transform: scale(.94); }
.round { width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; border: 1px solid var(--line2); background: #0a0709cc; color: var(--ink); padding: 0; }
.badge { position: absolute; top: 10px; left: 10px; padding: 5px 10px; border-radius: 999px; background: #0a0709e0; border: 1px solid var(--line2); font-size: 12px; font-weight: 800; color: var(--coral); }

.modes { display: grid; grid-template-columns: 1fr 1fr; width: min(100%, 520px); padding: 4px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); }
.modes button { min-height: 44px; border: 0; border-radius: 999px; background: none; color: var(--mute); font-weight: 800; font-size: 14px; }
.modes button[aria-checked="true"] { background: var(--lime); color: var(--lime-ink); }

/* ---------- Panel ---------- */
.panel { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px var(--pad) 12px; }
.intake { display: grid; gap: 14px; max-width: 520px; margin: 0 auto; }
.intake h1 { font-size: clamp(22px, 6vw, 30px); line-height: 1.12; letter-spacing: -.02em; }
.lead { display: flex; gap: 8px; align-items: flex-start; color: var(--mute); }
.lead svg { color: var(--lime); margin-top: 1px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 16px;
  border-radius: 14px; border: 1px solid var(--line2); background: var(--card2); color: var(--ink); font-weight: 800; font-size: 15px; text-decoration: none;
}
.btn.primary { background: var(--lime); color: var(--lime-ink); border-color: var(--lime); }
.btn.ghost { background: none; }
.btn.small { min-height: 44px; font-size: 14px; padding: 0 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.btn:focus-within { outline: 2px solid var(--lav); outline-offset: 2px; }
.link { border: 0; background: none; padding: 0; color: var(--lime); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; min-height: 44px; display: inline-flex; align-items: center; padding: 0 2px; vertical-align: middle; }
.samples { color: var(--mute); font-size: 14px; }
.perks { display: grid; gap: 8px; padding: 12px; border-radius: var(--r); background: var(--bg2); border: 1px solid var(--line); }
.perk { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--mute); }
.perk b { color: var(--ink); }
.perk svg { margin-top: 1px; color: var(--coral); }
.error { color: #ffb4a8; background: #ff3b2f1a; border: 1px solid #ff3b2f55; padding: 10px 12px; border-radius: 12px; font-size: 14px; }

.editor { display: grid; gap: 12px; max-width: 560px; margin: 0 auto; }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.tabs button { min-height: 44px; border: 0; border-radius: 10px; background: none; color: var(--mute); font-weight: 800; font-size: 14px; }
.tabs button[aria-selected="true"] { background: var(--card2); color: var(--ink); box-shadow: inset 0 -2px 0 var(--lime); }
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.group-title { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.group-title .price { margin-left: auto; text-transform: none; letter-spacing: 0; color: var(--coral); }
.look {
  position: relative; display: grid; gap: 6px; justify-items: center; padding: 8px 6px; min-height: 44px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); color: var(--ink); font-size: 13px; font-weight: 700;
}
.look[aria-pressed="true"] { border-color: var(--lime); box-shadow: 0 0 0 1px var(--lime) inset; }
.look canvas { width: 56px; height: 56px; image-rendering: pixelated; border-radius: 6px; background: #050407; }
.look .lock { position: absolute; top: 6px; right: 6px; width: 16px; height: 16px; color: var(--coral); }
.look .seal { position: absolute; top: 5px; right: 5px; width: 18px; height: 18px; }
.look.is-locked canvas { filter: saturate(.8) brightness(.8); }

.controls { display: grid; gap: 14px; }
.row { display: grid; gap: 6px; }
.row > span { display: flex; justify-content: space-between; font-size: 13px; font-weight: 800; color: var(--mute); }
.row output { color: var(--ink); font-family: var(--mono); font-weight: 600; }
.row input[type="range"] { width: 100%; accent-color: var(--lime); min-height: 44px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 3px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--line); }
.seg button { min-height: 44px; border: 0; border-radius: 9px; background: none; color: var(--mute); font-size: 13px; font-weight: 800; }
.seg button[aria-pressed="true"] { background: var(--card2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line2); }

.saves { display: grid; gap: 8px; }
.save {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; min-height: 60px; text-align: left;
  border-radius: 14px; border: 1px solid var(--line2); background: var(--card2); color: var(--ink);
}
.save b { display: block; font-size: 15px; }
.save small { display: block; color: var(--mute); font-size: 13px; margin-top: 2px; }
.save .tag { font-size: 12px; font-weight: 800; color: var(--coral); white-space: nowrap; }
.save .tag.ok { color: var(--lime); }
.save.primary { background: var(--lime); border-color: var(--lime); color: var(--lime-ink); }
.save.primary small, .save.primary .tag { color: #2a3a10; }
.save:disabled { opacity: .55; cursor: default; }
.save-note { font-size: 13px; color: var(--mute); }
.editor-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.status { font-size: 13px; color: var(--mute); flex: 1; min-width: 50%; }

.foot { display: flex; gap: 0 14px; flex-wrap: wrap; justify-content: center; align-items: center; padding: 0 var(--pad) env(safe-area-inset-bottom); font-size: 12px; color: var(--mute); border-top: 1px solid var(--line); }
.foot .net { color: var(--coral); }
/* Footer links are full 44 px tap targets; the footer's height comes from them, not from padding. */
.foot a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 2px; }
.foot span { display: inline-flex; align-items: center; min-height: 44px; }
@media (max-width: 400px) { .foot .chain { display: none; } }

/* ---------- Sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: grid; align-items: end; background: #000a; padding: env(safe-area-inset-top) 0 0; }
.sheet-card {
  width: 100%; max-height: 92dvh; display: grid; grid-template-rows: auto minmax(0, 1fr);
  background: var(--card); border: 1px solid var(--line2); border-bottom: 0; border-radius: 20px 20px 0 0;
  padding: 14px var(--pad) calc(16px + env(safe-area-inset-bottom));
  animation: rise .22s ease-out;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.sheet-head h2 { font-size: 19px; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; display: grid; gap: 12px; align-content: start; }
.wallets { display: grid; gap: 8px; }
.wallet { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line2); background: var(--card2); font-weight: 700; text-align: left; }
.wallet img { width: 28px; height: 28px; border-radius: 6px; }
.muted { color: var(--mute); font-size: 14px; }
.small-print { color: var(--mute); font-size: 12px; }
.pay-preview { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.pay-preview canvas { width: 100%; aspect-ratio: 1; image-rendering: pixelated; border-radius: 6px; background: #050407; }
.pay-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pay-msg { font-size: 14px; padding: 10px 12px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--line); }
.pay-msg.bad { color: #ffb4a8; border-color: #ff3b2f55; }
.pay-msg.good { color: var(--lime); border-color: #c6ff4d55; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: var(--mute); }
.field input { min-height: 46px; border-radius: 12px; border: 1px solid var(--line2); background: var(--bg2); padding: 0 12px; font-family: var(--mono); font-size: 14px; }

/* ---------- Short phones ---------- */
@media (max-height: 640px) and (orientation: portrait) {
  .tray { --size: min(calc(100vw - 2 * var(--pad)), 38dvh); }
  .top { min-height: 50px; padding-block: 6px; }
  .perks { display: none; }
}

/* ---------- Landscape and desktop: tray left, panel right, no page scroll ---------- */
@media (orientation: landscape) and (min-width: 560px), (min-width: 900px) {
  .stage { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 20px; min-height: 0; padding: 0 var(--pad); }
  .app { grid-template-rows: auto minmax(0, 1fr) auto; }
  .trayside { padding: 0 0 10px; align-content: start; }
  .tray { --size: min(calc(100dvh - 190px), 46vw, 640px); }
  .modes { width: var(--size, 100%); max-width: min(calc(100dvh - 190px), 46vw, 640px); }
  .panel { padding: 0 0 12px; }
  .intake, .editor { margin: 0; }
  .sheet { align-items: center; justify-items: center; }
  .sheet-card { width: min(520px, 94vw); border-radius: 20px; border-bottom: 1px solid var(--line2); max-height: 88dvh; }
}
@media (orientation: landscape) and (max-height: 500px) {
  .top { min-height: 46px; padding-block: 4px; }
  .tray { --size: min(calc(100dvh - 130px), 46vw); }
  .modes { max-width: min(calc(100dvh - 130px), 46vw); }
  .modes button { min-height: 44px; font-size: 13px; }
  .foot { padding-block: 4px calc(4px + env(safe-area-inset-bottom)); }
  .perks { display: none; }
  .intake h1 { font-size: 21px; }
}
@media (min-width: 1200px) {
  .stage { gap: 32px; padding: 0 32px; max-width: 1400px; margin: 0 auto; width: 100%; }
  .top { padding-inline: 32px; }
}

/* The mode switch never wraps (a wrapped label made the column taller than the screen in landscape). */
.modes button { white-space: nowrap; }
.stage > * { min-height: 0; }
@media (max-width: 360px) { .modes button { font-size: 14px; padding-inline: 6px; } }
@media (orientation: landscape) and (max-height: 500px) { .stage { overflow: hidden; } .modes button { padding-inline: 6px; } }

/* ---------- Keyboard shortcuts: one "?" button and a dialog, desktop only (never page text) ---------- */
.top-actions { display: flex; align-items: center; gap: 10px; }
.keys-btn { display: none; }
@media (min-width: 1024px) and (hover: hover) and (pointer: fine) { .keys-btn { display: inline-grid; } }
.shortcuts { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.shortcuts li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 12px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--line); font-size: 14px; }
.shortcuts kbd { display: inline-flex; gap: 4px; }
kbd { font: 700 12px/1 var(--mono); min-width: 24px; padding: 5px 7px; text-align: center; border-radius: 6px; border: 1px solid var(--line2); border-bottom-width: 2px; background: var(--card); color: var(--ink); }

/* ---------- Tablet portrait (700–1180 wide): a big print on top, a roomy two-column toolbox below ---------- */
@media (orientation: portrait) and (min-width: 700px) {
  :root { --pad: 28px; }
  .top { min-height: 64px; }
  .tray { --size: min(calc(100vw - 2 * var(--pad)), 46dvh, 700px); }
  .modes { width: min(100%, 560px); }
  .modes button { min-height: 48px; font-size: 16px; }
  .intake, .editor { max-width: 720px; }
  .intake h1 { font-size: 34px; }
  .perks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .chips { grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; }
  .controls { grid-template-columns: 1fr 1fr; gap: 16px 20px; }
  .saves { grid-template-columns: 1fr 1fr; }
  .saves > :not(.save) { grid-column: 1 / -1; }
}

/* ---------- Tablet landscape (900–1180): print left, tool panel right, sized for the extra room ---------- */
@media (orientation: landscape) and (min-width: 900px) and (max-width: 1199px) and (min-height: 600px) {
  .stage { grid-template-columns: minmax(0, 1fr) minmax(340px, 400px); gap: 24px; padding: 0 24px; }
  .trayside { justify-items: center; }
  .tray { --size: min(calc(100dvh - 200px), calc(100vw - 480px), 720px); }
  .modes { max-width: min(calc(100dvh - 200px), calc(100vw - 480px), 720px); }
  .chips { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Desktop (1200+): a workspace. The print fills the left; a fixed tool column on the right ---------- */
@media (min-width: 1200px) and (min-height: 600px) {
  .stage { grid-template-columns: minmax(0, 1fr) 440px; }
  .tray { --size: min(calc(100dvh - 200px), calc(100vw - 600px), 860px); }
  .modes { max-width: min(calc(100dvh - 200px), calc(100vw - 600px), 860px); }
  .panel { padding-right: 4px; }
  .chips { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .safelight, .bar i { animation: none; }
  .sheet-card { animation: none; }
}
