:root {
  --bg: #f4f3f1;
  --surface: #ffffff;
  --surface-2: #ecebe8;
  --line: #d9d7d2;
  --text: #1d1c1a;
  --muted: #6b6862;
  --accent: #c2581c;
  --accent-text: #ffffff;
  --stage: #161615;
  --stage-text: #e9e7e3;
  --danger: #b3261e;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111110;
    --surface: #1b1b1a;
    --surface-2: #252523;
    --line: #34332f;
    --text: #ecebe7;
    --muted: #9b988f;
    --accent: #f0883e;
    --accent-text: #1a1209;
    --stage: #0b0b0a;
    --stage-text: #e9e7e3;
    --danger: #f2b8b5;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111110;
  --surface: #1b1b1a;
  --surface-2: #252523;
  --line: #34332f;
  --text: #ecebe7;
  --muted: #9b988f;
  --accent: #f0883e;
  --accent-text: #1a1209;
  --stage: #0b0b0a;
  --stage-text: #e9e7e3;
  --danger: #f2b8b5;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

/* Top bar */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mark {
  flex: none;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.bar-actions { display: flex; gap: 8px; flex: none; }

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  font-size: 14px;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn.ghost { background: transparent; }
.btn.wide { width: 100%; margin-top: 8px; }

.link {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

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

/* Scrolls when the start page is taller than the window. */
main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-color: var(--line) transparent;
}

/* Empty state */
.empty {
  flex: 1;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.drop {
  border: 1.5px dashed var(--line);
  border-radius: 16px;
  background: var(--surface);
  padding: 64px 24px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

body.dragging .drop {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.drop h1 {
  margin: 0 0 8px;
  font-size: clamp(22px, 4vw, 30px);
  letter-spacing: -0.02em;
  line-height: 1.2;
  text-wrap: balance;
}

.drop p { margin: 6px 0; }
.fine { color: var(--muted); font-size: 13.5px; }
.error { color: var(--danger); font-weight: 550; }

.about {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.about h2 { margin: 0 0 4px; font-size: 15px; }
.about p { margin: 0; color: var(--muted); font-size: 14px; }

/* Workspace */
.work {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    "stage panel"
    "strip panel";
}

.stage {
  grid-area: stage;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--stage);
  color: var(--stage-text);
}

.frame {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#view {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 2px 24px rgb(0 0 0 / 0.5);
  touch-action: none;
}

/* Placed over the photo's top-left corner by app.js. */
.badge {
  position: absolute;
  top: 26px;
  left: 26px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.6);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.badge.original { background: rgb(255 255 255 / 0.85); color: #111; }

.busy {
  position: absolute;
  top: 26px;
  left: 26px;
  width: 18px;
  height: 18px;
}

.busy span {
  display: block;
  width: 100%;
  height: 100%;
  border: 2px solid rgb(255 255 255 / 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.stage-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px 12px;
}

.stage-bar .btn {
  flex: none;
  color: var(--stage-text);
  border-color: rgb(255 255 255 / 0.25);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.stage-bar .btn.held { background: rgb(255 255 255 / 0.15); }

.info { min-width: 0; }
.summary { margin: 0; font-size: 13.5px; font-weight: 550; }

.notes {
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12.5px;
  color: rgb(233 231 227 / 0.7);
}

.notes li.blocked { color: #ffb4a8; font-weight: 550; }

/* Recipe panel */
.panel {
  grid-area: panel;
  min-height: 0;
  overflow-y: auto;
  scrollbar-color: var(--line) transparent;
  border-left: 1px solid var(--line);
  background: var(--surface);
  padding: 16px;
}

.panel.disabled form { opacity: 0.45; pointer-events: none; }

.field { margin: 0 0 14px; padding: 0; border: 0; min-width: 0; }

.field > label, .field > legend {
  display: flex;
  justify-content: space-between;
  padding: 0;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.field output {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

select {
  width: 100%;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 32px 7px 10px;
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23888' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center;
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
}

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2);
}

.seg button {
  appearance: none;
  border: 0;
  border-left: 1px solid var(--line);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  padding: 6px 4px;
  cursor: pointer;
}

.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }

.panel.mono .colour-only { opacity: 0.4; pointer-events: none; }

/* Film simulation strip */
.strip {
  grid-area: strip;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 12px 16px 14px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.sim {
  flex: none;
  width: 116px;
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

/* Until its thumbnail renders, a look shows its colours. */
.sim .thumb {
  display: block;
  width: 116px;
  height: 78px;
  border-radius: 6px;
  background: linear-gradient(to top, var(--look-b) 0 7px, var(--look-a) 7px);
  overflow: hidden;
  outline: 2px solid transparent;
  outline-offset: 1px;
  transition: outline-color 0.15s;
}

.sim canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.sim:hover .thumb { outline-color: var(--line); }
.sim[aria-pressed="true"] .thumb { outline-color: var(--accent); }

.tag {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 22px;
  margin-top: 6px;
  padding: 0 3px 0 9px;
  border-radius: 5px;
  background: linear-gradient(to right, var(--look-b) 0 4px, var(--look-a) 4px);
  color: var(--look-ink);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.tag-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tag .dot { margin-left: auto; }
.sim[aria-pressed="true"] .tag { box-shadow: 0 0 0 2px var(--accent); }

/* A colour filter on a black-and-white look. */
.dot {
  flex: none;
  min-width: 18px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--filter);
  color: var(--filter-ink);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

/* The start page's cards, one per look. */
.looks h2 { margin: 0 0 10px; font-size: 15px; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  width: 100%;
  aspect-ratio: 3 / 2;
  padding: 10px 12px 18px;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  appearance: none;
  background: linear-gradient(to top, var(--look-b) 0 8px, var(--look-a) 8px);
  color: var(--look-ink);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.08), 0 6px 16px rgb(0 0 0 / 0.18);
}

.looks .fine { margin: -6px 0 10px; }

body.loading, body.loading .card, body.loading .link { cursor: progress; }

.card-name { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; }
.card-trait { margin-top: 2px; font-size: 12px; line-height: 1.3; opacity: 0.85; }
.card .dots { position: absolute; top: 9px; right: 9px; display: flex; gap: 4px; }

/* Each look's colours: the fill, the stripe and the text on the fill. */
[data-look] { --look-a: var(--surface-2); --look-b: var(--line); --look-ink: var(--text); }
[data-look="Provia"] { --look-a: #1f5fae; --look-b: #e8e2d4; --look-ink: #fff; }
[data-look="Velvia"] { --look-a: #0e7a45; --look-b: #c2187a; --look-ink: #fff; }
[data-look="Astia"] { --look-a: #f1d5cd; --look-b: #86aed6; --look-ink: #43262a; }
[data-look="ClassicChrome"] { --look-a: #4d6766; --look-b: #c9a04a; --look-ink: #fff; }
[data-look="ProNegHi"] { --look-a: #2b2522; --look-b: #e2a17e; --look-ink: #fff; }
[data-look="ProNegStd"] { --look-a: #dcd5ca; --look-b: #8e8a85; --look-ink: #2a2622; }
[data-look="ClassicNeg"] { --look-a: #2c6c70; --look-b: #e3a03a; --look-ink: #fff; }
[data-look="Eterna"] { --look-a: #2d3a40; --look-b: #b98a5a; --look-ink: #ece6dd; }
[data-look="EternaBleach"] { --look-a: #50585c; --look-b: #c9ccc8; --look-ink: #fff; }
[data-look="NostalgicNeg"] { --look-a: #9a5a28; --look-b: #f0c96b; --look-ink: #fff; }
[data-look="RealaAce"] { --look-a: #24688a; --look-b: #ead9bd; --look-ink: #fff; }
[data-look="Acros"] { --look-a: #141414; --look-b: #bdbdbd; --look-ink: #fff; }
[data-look="Monochrome"] { --look-a: #6a6a6a; --look-b: #d8d8d8; --look-ink: #fff; }
[data-look="Sepia"] { --look-a: #6c4729; --look-b: #dcc39d; --look-ink: #fff; }
[data-filter="Ye"] { --filter: #f3c300; --filter-ink: #1d1a10; }
[data-filter="R"] { --filter: #d23a2a; --filter-ink: #fff; }
[data-filter="G"] { --filter: #2f7f3b; --filter-ink: #fff; }

.foot {
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.foot p { margin: 0; }

/* Narrow screens: photo, strip, then the recipe, scrolling as a page. */
@media (max-width: 860px) {
  body { height: auto; }
  .work {
    display: flex;
    flex-direction: column;
  }
  .frame { flex: none; padding: 12px; }
  #view { width: 100%; height: auto; max-height: 72vh; }
  .strip { order: 1; }
  .panel { order: 2; border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .stage-bar { flex-direction: column; }
  .stage-bar .btn { align-self: stretch; }
  .card { aspect-ratio: auto; min-height: 88px; }
  .card-name { font-size: 15px; }
  .brand span { font-size: 15px; }
}

@media (max-width: 420px) {
  .bar { padding: 8px 12px; }
  .brand span { display: none; }
}

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