/*
 * Design tokens and the components built from them.
 *
 * Phone first throughout: this application is used standing up, one-handed, in a room full
 * of clothes. Nothing here has a desktop breakpoint yet because nothing yet needs one.
 */

:root {
  color-scheme: light dark;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  /* Quiet metadata only — a caption beside something, never an input, and never the only
     place a piece of information appears. 13px is the floor; --text-sm at 14px remains the
     size for secondary text that has to be read rather than glanced at. */
  --text-xs: 0.8125rem;
  --text-sm: 0.875rem;
  /* Anything below 16px makes iOS Safari zoom the viewport when an input takes focus, so this
     is the floor for anything typed into. */
  --text-base: 1rem;
  --text-lg: 1.25rem;
  --text-xl: 1.75rem;
  /* Display sizes. Nothing reads these yet — premium-visual-language is their consumer. They
     live here so the scale stays in one place rather than being reopened by a later change. */
  --text-2xl: 2.25rem;
  --text-3xl: 3rem;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* State feedback, not the sanctioned three animated jobs — see premium-visual-language
     design decision 5. No GSAP, no timeline, nothing written to a style attribute, so nothing
     for Turbo's snapshot to capture or AnimatedController to tear down. Never applied to
     `main` or anything else carrying `data-controller~="reveal"` — those elements' opacity
     and transform are GSAP's, written directly to the inline style, and a CSS transition on
     the same properties on the same element would race the timeline that owns them. Reduced
     to 0s under prefers-reduced-motion below, the same way AnimatedController#seconds already
     does for GSAP. */
  --transition-quick: 150ms ease;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Headings and figures only — see premium-visual-language design decision 1. Body text,
     labels, inputs and buttons stay on --font-sans, which is unchanged and untouched by this
     token. The fallback chain is a serif, not the system stack, so the swap in from the
     fallback to Fraunces (decision 4) is a change in character, not a change in family. */
  --font-display: "Fraunces", ui-serif, Georgia, "Times New Roman", serif;

  /* Smallest comfortable touch target. Every interactive element meets it. */
  --tap-target: 44px;
  /* The action that advances the task gets more than the floor: it is pressed one-handed
     while the other hand is holding a garment. Raising --tap-target itself would inflate
     every quiet button, radio row and list link where 44px is already right. */
  --tap-target-primary: 56px;

  --surface: #faf9f7;
  --surface-raised: #ffffff;
  --border: #e0dcd5;
  --ink: #1c1a17;
  --ink-muted: #6b655c;
  --danger: #8c2f22;
  --danger-surface: #fbeae7;

  /* The accent as a scale rather than a single value: a tinted surface, a border, a solid
     fill, and the ink that sits on that fill. Hand-tuned per theme rather than mixed with
     color-mix() — mixing this green toward the warm surface reads grey, the dark theme has
     to mix the other way, and every pair needs checking by hand regardless. */
  --accent-surface: #e8f0ed;
  --accent-border: #5e9482;
  --accent-solid: #2f5d50;
  --accent-ink: #ffffff;

  /* Meanings, not colours. Each points at a step above, so it follows the theme without
     being redefined in the dark block below — a custom property is substituted where it is
     used, not where it is declared.

     --accent was carrying three unrelated meanings at once: the action, a confidence at or
     above the threshold, and a price achieved on a sale. Naming them separately is what
     makes it possible to change one without changing the other two. They deliberately share
     a value today; this change adds the names, not a new look.

     A fourth meaning turned up during that same change and was left on --accent rather than
     named, since naming it then would have meant adding a token no artifact specified —
     `.status--ready` and a done step's own number both use --accent for a positive or
     completed state, which is none of the three above. premium-visual-language is already
     touching done-state transitions, so it is named here: --state-done. Still the same value
     today, for the same reason the other three are. */
  --accent: var(--accent-solid);
  --outcome: var(--accent-solid);
  --confidence-ok: var(--accent-solid);
  --confidence-low: var(--danger);
  --state-done: var(--accent-solid);

  /* A notice and a confirmed badge are the accent's tinted surface under another name, so
     they read the step rather than repeating its value. */
  --notice-surface: var(--accent-surface);

  /* A raised surface reads as layered rather than only bordered. Used sparingly: cards and
     the primary button, not every element with a border. */
  --shadow-raised: 0 1px 2px rgba(28, 26, 23, 0.06), 0 6px 16px rgba(28, 26, 23, 0.08);
}

/* The system preference is the default, but the toggle in the shell (theme_controller.js)
   can override it either way by setting data-theme on the root element and remembering the
   choice in localStorage. :not([data-theme="light"]) is what lets a dark system with no
   explicit choice keep following prefers-color-scheme below, while [data-theme="dark"] is
   what lets a light system be switched to dark anyway — both selectors point at the same
   values, so a system dark reader and someone who tapped the toggle see the same theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: #171614;
    --surface-raised: #222120;
    --border: #38352f;
    --ink: #f2efe9;
    --ink-muted: #a49d92;
    --danger: #f0a094;
    --danger-surface: #34211e;

    /* Only the steps are redefined here. The semantic tokens in :root point at these and so
       follow the theme on their own. */
    --accent-surface: #1d2a26;
    --accent-border: #557f70;
    --accent-solid: #8fc9b6;
    --accent-ink: #14201c;

    /* A drop shadow disappears against a near-black surface, so dark mode gets a faint highlight
       instead of a darker shadow. */
    --shadow-raised: 0 1px 0 rgba(255, 255, 255, 0.05);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: #171614;
  --surface-raised: #222120;
  --border: #38352f;
  --ink: #f2efe9;
  --ink-muted: #a49d92;
  --danger: #f0a094;
  --danger-surface: #34211e;

  --accent-surface: #1d2a26;
  --accent-border: #557f70;
  --accent-solid: #8fc9b6;
  --accent-ink: #14201c;

  --shadow-raised: 0 1px 0 rgba(255, 255, 255, 0.05);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --transition-quick: 0s;
  }
}

/* Fraunces, self-hosted — OFL, licence text alongside the file in app/assets/fonts/. Subset to
   Latin plus the diacritics and euro sign the Dutch copy actually uses (design decision 2);
   variable on weight and optical size only, which is what a phone downloading it over mobile
   data pays for. `swap` plus the preload in the layout means text is never invisible while it
   loads (design decision 4); only headings and figures use it, so the reflow it causes is
   confined to those rather than the whole page. */
@font-face {
  font-family: "Fraunces";
  src: url("/assets/Fraunces-Variable-2a0ad122.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Room for the theme toggle, fixed in the top-right corner of every screen (see
   .shell__theme-toggle below) — unconditional, unlike the bottom padding reserved by
   body[data-shell], because the toggle is not tied to a screen declaring anything. Without
   this a wide heading runs underneath the button instead of next to it. */
body {
  margin: 0;
  padding-top: calc(var(--tap-target) + var(--space-3) + env(safe-area-inset-top));
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

/* Layout ------------------------------------------------------------------ */

main {
  max-width: 34rem;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-7);
}

/* Desktop, tier two of the shell — see openspec/changes/desktop-design/design.md, Decision 1.
   1024px is a literal here and at every other occurrence of this breakpoint in this file
   because a custom property cannot be read inside a media condition without a build step this
   project deliberately does not have; task 6.1 checks that every occurrence still agrees. */
@media (min-width: 1024px) {
  main {
    /* Decision 4: wide enough that a label and its value have room to sit apart, capped well
       short of an article's measure — this application's content is lists, cards and short
       forms, not prose. */
    max-width: 42rem;
  }
}

h1 {
  margin: 0 0 var(--space-5);
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

@media (min-width: 1024px) {
  h1 {
    /* Decision 5: the one token in the display scale nothing has read yet, and a heading is
       the one place a wider canvas earns a bigger mark without touching body text, a label or
       a button. */
    font-size: var(--text-3xl);
  }
}

.stack > * + * {
  margin-top: var(--space-4);
}

/* Shell -------------------------------------------------------------------
   The frame every screen is rendered into. The layout owns both regions, so a screen
   declares what its primary action is and has no say in where it goes. */

body[data-shell="true"] {
  /* Room for the fixed action, plus its padding and the phone's home indicator, so the end
     of a long screen is never trapped behind it. */
  padding-bottom: calc(var(--tap-target-primary) + var(--space-6) + env(safe-area-inset-bottom));
}

@media (min-width: 1024px) {
  body[data-shell="true"] {
    /* The primary region leaves the fixed bottom bar at this width (see .shell__primary
       below), so there is nothing left for this to reserve room for. */
    padding-bottom: 0;
  }
}

/* The way back. Same container as the quiet region and immediately above it, so on the screens
   that used to declare their own it lands exactly where it always was. */
.shell__back {
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 var(--space-4) var(--space-3);
}

.shell__quiet {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  max-width: 34rem;
  margin: 0 auto;
  padding: 0 var(--space-4) var(--space-5);
}

@media (min-width: 1024px) {
  .shell__back,
  .shell__quiet {
    max-width: 42rem;
  }
}

/* The persistent way to reach any pipeline stage at desktop width — see
   openspec/changes/desktop-design/specs/interface-shell/spec.md and its design.md, Decision 3.
   Rendered unconditionally by the layout, the same as the theme toggle, because nothing on the
   server knows the viewport width; `display: none` below the breakpoint is what actually
   decides whether it is ever seen. A fixed left rail rather than a top bar: a top bar would
   compete with a screen's own <h1> for the vertical space a phone-first screen already treats
   as scarce, where a side rail only costs horizontal space this breakpoint has by definition.

   `body` gains the matching `padding-left` in the same rule, so main/.shell__quiet/.shell__back
   keep centering themselves with a plain `margin: 0 auto` — they simply have less viewport to
   center within, rather than needing their own awareness of the rail. */
.shell__nav {
  display: none;
}

@media (min-width: 1024px) {
  body {
    padding-left: 16rem;
  }

  .shell__nav {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 16rem;
    overflow-y: auto;
    padding: var(--space-6) var(--space-4);
    background: var(--surface-raised);
    border-right: 1px solid var(--border);
  }
}

.shell__nav-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.shell__nav-link {
  display: flex;
  align-items: center;
  min-height: var(--tap-target);
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  color: var(--ink);
  text-decoration: none;
}

.shell__nav-link:hover,
.shell__nav-link:focus-visible {
  background: var(--surface);
}

/* Rare, like signing out, but unlike signing out it is not tied to being signed in at all —
   the login screen has a system colour scheme to override too. Fixed in the corner rather
   than in either flow region, so it is reachable without scrolling on every screen without
   competing with the primary action for the thumb's arc that region exists for. */
.shell__theme-toggle {
  position: fixed;
  top: env(safe-area-inset-top);
  right: 0;
  z-index: 10;
  padding: var(--space-3) var(--space-4);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-target);
  height: var(--tap-target);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--ink);
  box-shadow: var(--shadow-raised);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

/* One icon per state, shown for the theme currently active rather than the one a tap would
   switch to — the icon names what you have, the same convention buttons that toggle a boolean
   already use elsewhere. theme_controller.js sets the `hidden` attribute directly rather than
   this being driven from data-theme in CSS: a reader who has never touched the toggle keeps
   following prefers-color-scheme live if the system theme changes, and the icon has to follow
   that too, not just an explicit choice. Both start `hidden` in the markup so there is never a
   moment with both, or neither, visible before the controller connects. */

/* Fixed rather than sticky. A sticky element only sticks within its scroll container and
   stops at its parent's end, so on a screen shorter than the viewport it would settle
   mid-page — a second position for the thing that is supposed to have exactly one. */
.shell__primary {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding: var(--space-3) var(--space-4);
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

@media (min-width: 1024px) {
  .shell__primary {
    /* Back into the normal flow — there is no thumb to reach across the viewport for at this
       width, so nothing needs fixing to the bottom of it. Every offset above becomes inert
       once this is no longer a positioned element other than static; left here rather than
       reset one by one. */
    position: static;
  }
}

/* button_to wraps its button in a form, so the region's direct child is sometimes that form
   and sometimes the control itself. Both have to fill the width. */
.shell__primary > * {
  width: 100%;
  max-width: calc(34rem - 2 * var(--space-4));
  margin: 0;
}

@media (min-width: 1024px) {
  .shell__primary > * {
    max-width: calc(42rem - 2 * var(--space-4));
  }
}

.shell__primary .button,
.shell__primary button,
.shell__primary input[type="submit"] {
  width: 100%;
  min-height: var(--tap-target-primary);
}

@media (min-width: 1024px) {
  .shell__primary .button,
  .shell__primary button,
  .shell__primary input[type="submit"] {
    /* The larger primary target exists for a thumb pressing it one-handed while holding a
       garment (see phone-navigation-shell's design.md, Decision 4) — a reason that does not
       hold at this width. Every interactive element, this one included, still meets the
       standard floor every other element on the page already does. */
    min-height: var(--tap-target);
  }
}

/* Button ------------------------------------------------------------------ */

.button,
button,
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap-target);
  padding: var(--space-2) var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-ink);
  font-family: inherit;
  font-size: var(--text-base);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-raised);
  transition: background-color var(--transition-quick), color var(--transition-quick),
    border-color var(--transition-quick);
}

.button--quiet,
button.button--quiet {
  background: transparent;
  border-color: var(--border);
  color: var(--ink);
  box-shadow: none;
}

/* The outline itself is unchanged from what deepen-design-tokens already verified for
   contrast — premium-visual-language design decision 5.5 adds a soft halo in the accent's
   tinted surface step around it, rather than touching the ring's own colour, so the
   "no lower than the current 2px solid var(--accent)" floor cannot regress: the box-shadow is
   a purely additive layer, not a replacement. */
.button:focus-visible,
button:focus-visible,
input[type="submit"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-surface);
  transition: box-shadow var(--transition-quick);
}

/* Field ------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-muted);
}

.field input {
  min-height: var(--tap-target);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--ink);
  font-family: inherit;
  /* Anything below 16px makes iOS Safari zoom the viewport on focus. */
  font-size: var(--text-base);
}

.field input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  box-shadow: 0 0 0 4px var(--accent-surface);
  transition: box-shadow var(--transition-quick);
}

/* Card -------------------------------------------------------------------- */

.card {
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-raised);
}

/* Icon ---------------------------------------------------------------------
   Stroke-based and sized off the type scale, so it inherits both the
   surrounding text colour (and thus the theme) and its scale without its
   own size tokens. */
.icon {
  width: 1.1em;
  height: 1.1em;
  flex: none;
  vertical-align: -0.15em;
}

/* Capture slot ------------------------------------------------------------ */

.slot {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.slot__title {
  margin: 0;
  font-size: var(--text-lg);
}

.slot__hint {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.slot__image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  background: var(--surface);
}

.slot__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.slot__actions > * {
  flex: 1 1 8rem;
}

/* A file input has to stay in the document and stay focusable for its label to drive it, so
   it is hidden from view rather than from the browser. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.visually-hidden:focus-visible + label,
label:has(+ .visually-hidden:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-surface);
  transition: box-shadow var(--transition-quick);
}

/* Status ------------------------------------------------------------------ */

.status {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 600;
}

.status--ready {
  color: var(--state-done);
}

.status--waiting,
.status--analyzing,
.status--captured {
  color: var(--ink-muted);
}

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

.status__detail {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.spend {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.spend--exhausted {
  color: var(--danger);
}

/* Item list --------------------------------------------------------------- */

.item-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.item-list > li + li {
  border-top: 1px solid var(--border);
}

.item-list__row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.item-list__link {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--tap-target);
  padding: var(--space-2) 0;
  color: var(--ink);
  text-decoration: none;
}

/* A row's escape hatch, offered only while nothing downstream has committed to the item — see
   Item#deletable?. Circular and quiet so it reads as secondary to the row it sits beside. */
.item-list__delete {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: var(--tap-target);
  height: var(--tap-target);
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-muted);
  box-shadow: none;
}

.item-list__delete:hover,
.item-list__delete:focus-visible {
  background: var(--danger-surface);
  color: var(--danger);
}

.item-list__status {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

/* An item the owner should look at rather than one merely making its way through: a failed
   analysis, a listing nobody has bought. Emphasis only — whether a row can be opened does not
   depend on this, which is the whole point of separating the two. Matches the stage list's
   own attention treatment below. */
.item-list__row[data-attention="true"] .item-list__status {
  color: var(--danger);
  font-weight: 600;
}

/* Stage list ----------------------------------------------------------------
   The home screen's pipeline. Structurally an item-list — a row, a name, a count on the
   right — but its own component: a row here is a count of items in a stage, not one item.
   Every row is a link, so there is no unlinked variant to style. */

.stage-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.stage-list > li + li {
  border-top: 1px solid var(--border);
}

.stage-list__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--tap-target);
  padding: var(--space-2) 0;
}

.stage-list__link {
  color: var(--ink);
  text-decoration: none;
}

.stage-list__count,
.stage-list__status {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.stage-list__link--attention .stage-list__status {
  color: var(--danger);
  font-weight: 600;
}

/* Review ------------------------------------------------------------------ */

.review-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
}

.sessions__tagline {
  margin: calc(var(--space-5) * -1) 0 var(--space-5);
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.review-header__count {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink-muted);
  /* The count changes as the queue is worked through; tabular digits stop it shifting. */
  font-variant-numeric: tabular-nums;
}

/* Reused outside its usual `.review-header` flex row — releases/index.html.erb stacks it under
   an intro paragraph instead. Same specificity as the reset above, so without this the two sit
   flush against each other regardless of source order; scoping to `.stack >` outweighs it. */
.stack > .review-header__count {
  margin-top: var(--space-4);
}

/* The empty message steps aside as soon as the queue has anything in it, so an item arriving
   by broadcast needs no second message to clear the text. */
.review-empty {
  margin: 0;
  color: var(--ink-muted);
  text-align: center;
}

.empty-state {
  text-align: center;
  color: var(--ink-muted);
}

#review_queue:has(li) + .review-empty {
  display: none;
}

/* auto-fit already gives decision 6's "largest element" for free here: since
   guided-step-review moved the garment out to the condition step, a standard item's grid
   holds one photo (the label), which a `1fr` track with nothing to share the row with
   stretches to the full column width without this rule doing anything extra. */
/* `auto-fill`, not `auto-fit`: with the garment moved to the condition step,
   guided-step-review left this grid holding just the item's other photograph(s), and
   `auto-fit` collapses tracks with no content, so a lone photo's `1fr` track stretched to the
   full column — a secondary photo opening the app's most-used screen at full viewport height,
   above the content it exists to support. `auto-fill` keeps the second (empty) track in the
   layout instead of collapsing it, so the real photo's `1fr` only claims its share — reading
   like one cell of the two-up grid this always was, even when there is only one photo to show.
   Tried capping the track with `minmax(9rem, 12rem)` first: a definite max makes `auto-fit`
   compute its track *count* from that max, which cut a genuine two-photo row down to one column
   stacked instead of side by side — confirmed by screenshotting `items/_summary.html.erb`,
   which shares this class. `auto-fill` with the original `1fr` max avoids that; the two-photo
   case is provably unaffected, since auto-fill and auto-fit only differ when a track goes
   unfilled. */
.review-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: var(--space-3);
}

.review-photos__figure {
  margin: 0;
}

.review-photos__figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

.review-photos__figure figcaption {
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

/* Photo dialog ----------------------------------------------------------------
   A photograph that opens onto itself at full viewport size via a native <dialog> — see
   shared/_photo.html.erb and guided-step-review design decision 3. No pan or zoom: the
   dialog's own focus trap, Escape-to-dismiss and top layer are the whole interaction.
   Deliberately near-black regardless of theme, the way a photo viewer conventionally is —
   this is the one surface in the app that does not follow --surface. */

.photo__trigger {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: none;
  cursor: pointer;
}

.photo__trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-surface);
  transition: box-shadow var(--transition-quick);
}

.photo-dialog {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  margin: 0;
  padding: var(--space-5);
  border: none;
  background: #000;
}

.photo-dialog[open] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.photo-dialog::backdrop {
  background: #000;
}

.photo-dialog__image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.photo-dialog__close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--tap-target);
  height: var(--tap-target);
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.photo-dialog__close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.review-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
}

/* Anything the owner should look at before trusting it. */
.review-field--attention {
  border-color: var(--border);
  background: var(--surface);
}

.review-field__label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-muted);
}

/* Text entry only. Without the exclusion this also catches the condition radios and turns
   each one into a full-width 44px circle. */
.review-field input:not([type="radio"]):not([type="checkbox"]),
.review-field textarea {
  width: 100%;
  min-height: var(--tap-target);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--ink);
  font-family: inherit;
  font-size: var(--text-base);
}

/* These fell outside `.field input:focus-visible` — a different class scope, not a
   deliberate exception — and so were still on the browser's own default ring. Matched to it
   now rather than left the one unstyled ring on the screen used most. */
.review-field input:not([type="radio"]):not([type="checkbox"]):focus-visible,
.review-field textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  box-shadow: 0 0 0 4px var(--accent-surface);
  transition: box-shadow var(--transition-quick);
}

.review-field__reasoning {
  margin: 0 var(--space-3);
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.badge {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--text-sm);
  color: var(--ink-muted);
  /* Carries the confidence percentage, which is compared field to field down the screen. */
  font-variant-numeric: tabular-nums;
}

.badge--confirmed {
  background: var(--notice-surface);
  color: var(--ink);
}

.badge--attention {
  background: var(--danger-surface);
  color: var(--danger);
}

/* A value drawn from another item's confirmed field, not from this item's own analysis —
   bordered rather than filled so it reads as offered, not decided, distinct from
   .badge--confirmed's solid fill. */
.badge--suggestion {
  border: 1px solid var(--accent-border);
  color: var(--ink);
}

/* Meter ----------------------------------------------------------------------
   A proportional bar, its fill width set per-instance via the --pct custom
   property. Shared by the review screen's confidence indicator and the sale
   outcome's estimated/achieved comparison, so both read as a shape rather
   than a number to compare by hand. */
.meter {
  display: block;
  height: 6px;
  margin-top: var(--space-1);
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.meter__fill {
  display: block;
  height: 100%;
  width: var(--pct, 0%);
  border-radius: inherit;
  background: var(--confidence-ok);
}

.meter__fill--attention {
  background: var(--confidence-low);
}

.meter__fill--muted {
  background: var(--ink-muted);
}

.outcome-meters {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

/* The same bar shape carries two meanings. Inside the sale outcome it is a price achieved,
   not a confidence, so it reads --outcome — except when it is deliberately muted for a sale
   that came in under its estimate, which stays neutral because coming in under is normal
   shopping behaviour rather than a shortfall. The :not() keeps this rule from out-specifying
   the muted modifier it would otherwise override. */
.outcome-meters .meter__fill:not(.meter__fill--muted) {
  background: var(--outcome);
}

/* Empty state --------------------------------------------------------------- */

.empty-illustration {
  display: block;
  width: 3rem;
  height: 3rem;
  margin: 0 auto var(--space-2);
  color: var(--ink-muted);
}

/* The full-width garment inside the condition step — see design decision 5 of
   guided-step-review. `.photo__trigger` already resets the button; this only sets the image's
   own proportions, matching review-photos__figure img's radius. */
.review-condition__garment {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

.review-condition__choices {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

/* The whole row is the target, so the radio itself does not have to be. */
.choice {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap-target);
  cursor: pointer;
}

.choice input[type="radio"] {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  accent-color: var(--accent);
}

.observations {
  margin: 0;
  padding-left: var(--space-4);
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.observations__source {
  font-style: italic;
}

/* Release gate -------------------------------------------------------------
   Previously unstyled: a bare <h2> here fell back to the browser's own default margins,
   which the stack it now sits inside was never designed to sit next to. Only margin-bottom is
   reset here — margin-top is left to `.stack > * + *`, which already outranks the browser
   default on specificity; setting `margin-top: 0` here would only recreate the same tie (and
   the same clobbered spacing) as .review-header__count did above. */
.releases__section {
  margin-bottom: 0;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
}

/* Export ------------------------------------------------------------------ */

.export-intro {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

/* Step ----------------------------------------------------------------------
   A numbered step: dims once done, keeps one thing in focus. Proved on the export screen —
   see shared/_step.html.erb — before review adopted it too, per guided-step-review. Some of
   these rules (__value, __unmapped, __correction) style content only export's steps use;
   review's step bodies are built from reviews/_field and _condition instead, which keep their
   own review-field styles. */

.step {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Only the head dims — the number and label fading is enough to read "handled, look
   elsewhere". Dimming the body too used to take its text below the contrast floor once a
   step's own value (a confirmed field, an exported string) sat inside it at 0.55 opacity;
   review can now show all four steps done at once, where that stacked every body in the
   viewport below the floor simultaneously. Found by screenshotting a fully-confirmed review
   screen in both themes per guided-step-review task 5.1. */
.step[data-done="true"] .step__head {
  opacity: 0.55;
}

/* `.step__head` is a descendant of the element `data-controller="reveal"` animates (`main` or
   `#review_form`), never that element itself, so this never races the GSAP timeline that owns
   opacity on the ancestor — see the --transition-quick token's own note. On export, where
   `data-done` toggles client-side the moment a step is copied, this is the visible "done/undone
   state change" premium-visual-language design decision 5 describes; on review, `data-done` is
   only ever set on the rendered page, so the transition has nothing to animate between. */
.step__head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  transition: opacity var(--transition-quick);
}

.step__number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  flex: none;
  border-radius: 50%;
  background: var(--surface);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink-muted);
  transition: background-color var(--transition-quick), color var(--transition-quick);
}

.step[data-done="true"] .step__number {
  background: var(--state-done);
  color: var(--accent-ink);
}

.step__label {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
}

/* The value itself, sized to be read at arm's length and checked against what was pasted. */
.step__value {
  margin: 0;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.step__unmapped {
  margin: 0;
  color: var(--danger);
  font-size: var(--text-sm);
}

.step[data-unmapped="true"] {
  border-color: var(--danger);
}

.step__note,
.step__note-static {
  margin: 0;
  min-height: 1.25rem;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

/* Reporting that the taxonomy's answer for a field was wrong — see the
   record-taxonomy-corrections change. Closed by default; opening it is the "this didn't
   match" gesture, so it stays visually quiet until then. */
.step__correction {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
}

.step__correction summary {
  color: var(--ink-muted);
  cursor: pointer;
}

.step__correction form {
  margin-top: var(--space-3);
}

/* Kept a compact grid rather than given the full content column premium-visual-language's
   decision 6 otherwise calls for: these are save-to-device targets on a screen whose whole
   design is quick step-by-step scrolling, not a garment being judged, and stacking them would
   lengthen a screen guided-step-review specifically shaped around staying short. The minmax
   floor still grew a step (8rem to 9rem, matching review-photos) so the photos read a little
   larger without giving up the two-up layout at phone width. */
.export-photos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: var(--space-3);
}

.export-photos__figure {
  margin: 0;
}

.export-photos__figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-md);
}

.export-photos__figure figcaption {
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--ink-muted);
}

/* Flash ------------------------------------------------------------------- */

.flash {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  text-align: center;
}

.flash--alert {
  background: var(--danger-surface);
  color: var(--danger);
}

.flash--notice {
  background: var(--notice-surface);
  color: var(--ink);
}

/* Prices and facts -------------------------------------------------------- */

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-1) var(--space-4);
  margin: 0;
  font-size: var(--text-sm);
}

.facts dt {
  color: var(--ink-muted);
}

.facts dd {
  margin: 0;
}

.prices {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  margin: 0;
}

.prices__entry dt {
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.prices__entry dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  /* A price is read against another price, so its digits hold their column. */
  font-variant-numeric: tabular-nums;
}

.prices__entry--achieved dd {
  color: var(--outcome);
}

.prices__history,
.prices__summary {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}

.prices__basis {
  display: block;
}
