/* Photo Studio styles: the "Seamless Sweep" world — a product-photo studio's paper
   backdrop, 1px rules, three greys and one tungsten light. One screen, no page scroll. */
:root {
  --sweep: #8E8B86;      /* mid grey: rules, quiet text on paper */
  --paper: #D9D5CE;      /* backdrop paper */
  --lit: #F4F1EC;        /* paper under light: panels */
  --ink: #1E1D1B;
  --ink-2: #4F4C47;      /* secondary text, 7:1 on lit paper */
  --tungsten: #E8A33D;   /* the one light: work in progress, primary action */
  --tungsten-hi: #F0B65E;
  --fail: #9B2C1F;
  --rule: 1px solid var(--sweep);
  --gap: 16px;
  --pad: 24px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: var(--paper);
  accent-color: var(--ink);
  caret-color: var(--ink);
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; }
body { display: grid; grid-template-rows: 48px minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); height: 100dvh; }
::selection { background: var(--tungsten); color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---- shared controls ---- */
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.big { width: 28px; height: 28px; stroke-width: 1.25; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border: 1px solid var(--ink); background: transparent; cursor: pointer; white-space: nowrap;
  transition: background-color .15s var(--ease), color .15s var(--ease); }
.btn:hover:not(:disabled) { background: var(--lit); }
.btn:active:not(:disabled) { background: var(--paper); }
.btn:disabled { border-color: var(--sweep); color: var(--sweep); cursor: not-allowed; }
.btn.primary { background: var(--tungsten); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--tungsten-hi); }
.btn.primary:disabled { background: transparent; }
.btn.solid { background: var(--ink); color: var(--lit); }
.btn.solid:hover:not(:disabled) { background: #33312e; }
.btn.solid:disabled { background: transparent; }
.link { border: 0; background: none; padding: 0; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 12px; }
.link:hover { color: var(--ink); }
.hint { font-size: 12px; color: var(--ink-2); }
.error { font-size: 13px; color: var(--fail); min-height: 1.45em; }
.phone-only, .touch-only { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.btn.square { width: 44px; padding: 0; }
@media (pointer: coarse) { .touch-only { display: inline-flex; } }

/* ---- top bar ---- */
.bar { display: flex; align-items: center; gap: var(--pad); padding: 0 var(--pad); background: var(--lit); border-bottom: var(--rule); }
.mark { font-weight: 650; font-size: 16px; letter-spacing: -.01em; white-space: nowrap; }
.counts { margin-left: auto; font-size: 13px; color: var(--ink-2); }
.counts b { color: var(--ink); font-weight: 600; }

/* ---- login ---- */
.login { align-self: center; justify-self: center; width: min(320px, calc(100vw - 32px)); display: grid; gap: 10px; }
.login label { font-weight: 600; }
.login input { height: 40px; padding: 0 12px; border: var(--rule); background: var(--lit); }
.login input:focus { outline: 0; border-color: var(--ink); }

/* ---- layout ---- */
.studio { display: grid; grid-template-columns: 360px minmax(0, 1fr); min-height: 0; }
.controls { display: flex; flex-direction: column; gap: var(--pad); padding: var(--pad); background: var(--lit); border-right: var(--rule); min-height: 0; }
.work { display: grid; grid-template-rows: minmax(0, 1fr) 36px 112px; gap: var(--gap); padding: var(--pad); min-width: 0; min-height: 0; }

/* ---- drop zone ---- */
.drop { position: relative; display: grid; place-items: center; align-content: center; gap: 6px; height: 152px; text-align: center;
  border: 1px dashed var(--sweep); background: var(--paper); cursor: pointer; transition: border-color .15s, background-color .15s; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--ink); background: #E4E0D9; }
.drop:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.drop-title { font-weight: 600; }

/* ---- prompt ---- */
.prompt { display: grid; gap: 8px; min-height: 0; }
.prompt-head { display: flex; justify-content: space-between; align-items: baseline; }
.prompt-head label { font-weight: 600; }
.prompt textarea { height: 168px; resize: none; padding: 12px; line-height: 1.5; border: var(--rule); background: #FBFAF7; }
.prompt textarea:focus { outline: 0; border-color: var(--ink); }
.actions { margin-top: auto; display: flex; gap: 8px; }
.go { flex: 1; height: 56px; font-size: 16px; }

/* ---- stage: before | after on one centre seam ---- */
.stage { position: relative; display: grid; grid-template-columns: 1fr 1fr; border: var(--rule); min-height: 0; overflow: hidden; }
.stage::after { content: ""; position: absolute; inset: 0 auto 0 50%; border-left: 1px solid var(--ink); pointer-events: none; }
.stage.empty { grid-template-columns: 1fr; }
.stage.empty::after { display: none; }
.half { position: relative; min-width: 0; min-height: 0; display: grid; place-items: center; padding: 40px 24px 24px; overflow: hidden; }
.sweep { background: radial-gradient(130% 95% at 50% 0%, var(--lit) 0%, var(--paper) 58%, #C2BEB7 100%); }
/* The photo fills its half without ever being cropped (pinned to the half's box, then
   contained); the drop shadow follows the drawn photo, not the letterboxed box. */
.half img { position: absolute; inset: 40px 24px 24px; width: calc(100% - 48px); height: calc(100% - 64px);
  object-fit: contain; filter: drop-shadow(0 10px 14px rgba(30, 29, 27, .28)); }
.half .tag { position: absolute; top: 12px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.half.before .tag { left: 16px; } .half.after .tag { right: 16px; }
.half .state { text-align: center; display: grid; gap: 4px; max-width: 30ch; }
.half .state strong { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.half .state.failed strong { color: var(--fail); }
.empty-note { display: grid; gap: 6px; justify-items: center; text-align: center; color: var(--ink-2); }
.empty-note strong { font-size: 20px; color: var(--ink); font-weight: 600; letter-spacing: -.01em; }

/* The light: a tungsten glow rising over a stage while ChatGPT works on it. */
.light { position: relative; isolation: isolate; }
.light::before { content: ""; position: absolute; inset: 0; z-index: -1; opacity: 0;
  background: radial-gradient(90% 75% at 50% -8%, rgba(232, 163, 61, .95), rgba(232, 163, 61, .35) 45%, rgba(232, 163, 61, 0) 80%);
  transition: opacity .6s var(--ease); }
.light.on::before { animation: rise 2.8s var(--ease) infinite alternate; }
@keyframes rise { from { opacity: .3; } to { opacity: .9; } }
.light.settle::before { animation: settle .9s var(--ease); }
@keyframes settle { from { opacity: .9; } to { opacity: 0; } }

/* ---- stage bar ---- */
.stage-bar { display: flex; align-items: center; gap: 8px; min-width: 0; }
.stage-bar .hint { margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- slots: fixed numbered cells; states change inside, the row never reflows ---- */
.slots { list-style: none; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(84px, 168px); gap: 12px; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; scrollbar-color: var(--sweep) transparent; }
.slot { position: relative; height: 100%; border: var(--rule); overflow: hidden; cursor: pointer; transition: opacity .2s var(--ease); }
.slot button.pick { position: absolute; inset: 0; border: 0; background: none; cursor: pointer; }
.slot img { position: absolute; inset: 22px 10px 8px; width: calc(100% - 20px); height: calc(100% - 30px); object-fit: contain; pointer-events: none; }
.slots.has-selection .slot:not(.selected) { opacity: .62; }
.slots.has-selection .slot:not(.selected):hover { opacity: .9; }
.slot.selected { border-color: var(--ink); outline: 1px solid var(--ink); outline-offset: 2px; }
.slot.editing { border-color: var(--tungsten); }
.slot.waiting img, .slot.ready img { filter: saturate(.7) brightness(.95); }
.slot .num { position: absolute; left: 8px; top: 4px; font-weight: 650; font-size: 13px; z-index: 1; pointer-events: none; }
.slot .st { position: absolute; right: 8px; top: 5px; font-size: 11px; color: var(--ink-2); z-index: 1; pointer-events: none; }
.slot.editing .st { color: var(--ink); font-weight: 600; }
.slot.failed .st { color: var(--fail); font-weight: 600; }
.slot.empty-slot { border-style: dashed; cursor: default; background: transparent; }

/* ---- narrow laptops: a slimmer control column ---- */
@media (max-width: 1100px) {
  .studio { grid-template-columns: 300px minmax(0, 1fr); }
  .stage-bar .hint { display: none; }
}

/* ---- phone: stage on top, slots, then one action row; prompt opens in place of the stage ---- */
@media (max-width: 760px) {
  :root { --pad: 12px; --gap: 10px; }
  body { grid-template-rows: 44px minmax(0, 1fr); }
  .bar { gap: 12px; }
  .bar .btn span { display: none; }
  .studio { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .work { grid-row: 1; grid-template-rows: minmax(0, 1fr) 44px 76px; padding-bottom: 0; }
  .controls { grid-row: 2; border-right: 0; border-top: var(--rule); padding: var(--pad); padding-bottom: max(var(--pad), env(safe-area-inset-bottom)); gap: 0; }
  .drop { display: none; }
  .phone-only { display: inline-flex; }
  .prompt { display: none; }
  .studio.prompt-open .prompt { display: grid; padding-bottom: var(--pad); }
  .studio.prompt-open .prompt textarea { height: 30dvh; }
  .studio.prompt-open .work { display: none; }
  .studio.prompt-open { grid-template-rows: 1fr; }
  .studio.prompt-open .controls { grid-row: 1; border-top: 0; }
  .touch-only { display: none !important; }
  .actions .btn { height: 48px; }
  .actions .btn:not(.go):not(.square) { padding: 0 12px; }
  .go { flex: 1; min-width: 0; font-size: 15px; }
  .stage-bar .btn { height: 44px; flex: 1; min-width: 0; padding: 0 8px; }
  .bar .btn { width: 44px; padding: 0; }
  .counts { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* Tall screens: before above after, the seam turns horizontal. */
  .stage { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .stage::after { inset: 50% 0 auto 0; border-left: 0; border-top: 1px solid var(--ink); }
  .stage.empty { grid-template-rows: 1fr; }
  .half { padding: 28px 8px 8px; }
  .half img { inset: 28px 8px 8px; width: calc(100% - 16px); height: calc(100% - 36px); }
  .stage-bar .hint { display: none; }
  .slots { grid-auto-columns: 72px; gap: 8px; }
  .slot img { inset: 18px 6px 6px; width: calc(100% - 12px); height: calc(100% - 24px); }
}
/* Small phones: picker buttons drop their words, the Edit button keeps its own. */
@media (max-width: 400px) {
  .actions .btn:not(.go) { width: 48px; padding: 0; }
  .stage-bar .btn .ic { display: none; }
  /* hidden from sight only, so screen readers still hear "Camera" and "Photos" */
  .actions .btn:not(.go) span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
@media (prefers-reduced-motion: reduce) {
  .light.on::before { animation: none; opacity: .75; }
  .light.settle::before { animation: none; }
}
