/* Her Closet - the visual layer.
 *
 * Dried flowers and linen: sage is the hero, warm brown is the ink, cream is
 * the paper, terracotta is the blush. One light theme only - this lives on a
 * phone in a bedroom, not on a monitor at midnight, and a second theme is a
 * second thing to keep beautiful.
 *
 * Everything below is driven by the tokens in `:root`. Designed at 375px,
 * checked at 390px.
 */

:root {
  /* -- sage: the hero ---------------------------------------------------- */
  --sage-50: #f2f5ec;
  --sage-100: #e3ead9;
  --sage-200: #c8d6b7;
  --sage-300: #a9bd90;
  --sage-400: #8b9f72;
  --sage-500: #7d8f6a; /* brand mark, decorative fills */
  --sage-600: #64764c; /* anything carrying text */
  --sage-700: #4a5a3b; /* sage text on cream */

  /* -- clay: the blush --------------------------------------------------- */
  --clay-500: #c0714e; /* hearts */
  --clay-600: #a85b3c;

  /* -- ink and paper ----------------------------------------------------- */
  --ink: #3a322a;
  --ink-strong: #2e2720;
  --muted: #6f6152;
  --bg: #f7f2e8;
  --surface: #fffdf9;
  --surface-2: #fbf6ec;
  --line: #e8dfcd;
  --line-strong: #d8cbb2;

  /* -- states ------------------------------------------------------------ */
  --danger: #9c4227;
  --danger-soft: #f8e5de;
  --danger-line: #e6c3b6;
  --success: #4a5a3b;
  --success-soft: #e3ead9;

  /* -- spacing ----------------------------------------------------------- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* -- radii ------------------------------------------------------------- */
  --radius-sm: 12px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --radius-pill: 999px;

  /* -- shadows: warm-tinted, never grey ---------------------------------- */
  --shadow-xs: 0 1px 2px rgba(74, 56, 34, 0.05);
  --shadow-sm: 0 2px 6px rgba(74, 56, 34, 0.06);
  --shadow-md: 0 4px 14px rgba(74, 56, 34, 0.08);
  --shadow-lg: 0 10px 28px rgba(74, 56, 34, 0.12);
  --shadow-sage: 0 4px 14px rgba(90, 108, 70, 0.24);

  /* -- type -------------------------------------------------------------- */
  --font: ui-rounded, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --fs-xs: 0.72rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.9rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.3rem;
  --fs-2xl: 1.6rem;

  /* -- chrome ------------------------------------------------------------ */
  --tab-height: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
  min-height: 100vh;
}

/* The linen. Two hairline weaves plus a couple of very soft washes of sage and
 * clay - faint enough that you read it as paper rather than as a pattern. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(58% 42% at 12% 4%, rgba(125, 143, 106, 0.1), transparent 70%),
    radial-gradient(52% 38% at 92% 22%, rgba(192, 113, 78, 0.07), transparent 72%),
    radial-gradient(70% 40% at 50% 100%, rgba(125, 143, 106, 0.08), transparent 70%),
    repeating-linear-gradient(90deg, rgba(120, 96, 64, 0.016) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(0deg, rgba(120, 96, 64, 0.014) 0 1px, transparent 1px 3px),
    var(--bg);
}

h1,
h2,
h3 {
  margin: 0 0 var(--space-2);
  line-height: 1.22;
  color: var(--ink-strong);
  font-weight: 700;
  letter-spacing: -0.015em;
}

h1 {
  font-size: var(--fs-2xl);
  margin-bottom: var(--space-4);
}

h2 {
  font-size: var(--fs-xl);
  letter-spacing: -0.01em;
}

h3 {
  font-size: var(--fs-lg);
  letter-spacing: 0;
}

p {
  margin: 0 0 var(--space-3);
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--sage-700);
}

::selection {
  background: var(--sage-200);
}

/* ---------------------------------------------------------------- layout */

/* `viewport-fit=cover` puts the shell under the status bar, so the top pad has
 * to earn its own safe area back. */
#view {
  padding: calc(env(safe-area-inset-top, 0px) + var(--space-5)) var(--space-4) 0;
  padding-bottom: calc(var(--tab-height) + var(--safe-bottom) + var(--space-10));
  max-width: 640px;
  margin: 0 auto;
}

.view-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.view-header h1 {
  margin-bottom: 0;
}

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

.small {
  font-size: var(--fs-sm);
  line-height: 1.45;
}

/* Category names are stored lower-case because they are values, not prose;
 * this is the one place they are read as a line of copy. */
.meta {
  text-transform: capitalize;
  letter-spacing: 0.01em;
}

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

.filters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.filters select {
  padding-left: var(--space-3);
  padding-right: 26px;
}

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

.center {
  text-align: center;
}

/* The line of copy directly under a view's title. */
.lead {
  margin: calc(var(--space-3) * -1) 0 var(--space-4);
  font-size: var(--fs-md);
  max-width: 38ch;
  text-wrap: pretty;
}

/* A quiet line above a set of results, or in place of them. */
.hint {
  margin: var(--space-4) 0 var(--space-3);
}

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

.mt-4 {
  margin-top: var(--space-4);
}

/* Botanicals are always the same faded green, wherever they land. */
.sprig {
  color: var(--sage-300);
}

/* A sprig of something pressed between two hairlines. Purely decorative. */
.divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--sage-300);
  margin: var(--space-4) 0;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
}

/* ---------------------------------------------------------------- tabs */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--tab-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  background: rgba(255, 253, 249, 0.92);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 18px rgba(74, 56, 34, 0.05);
  z-index: 20;
}

.tabbar a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.005em;
  text-decoration: none;
  color: var(--muted);
  padding: 6px 2px;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

/* The pill lives on the icon, so the active tab reads as a pressed key rather
 * than as a differently coloured word. */
.tabbar a .tab-icon {
  width: 46px;
  height: 26px;
  padding: 2.5px 12px;
  box-sizing: border-box;
  border-radius: var(--radius-pill);
  transition: background-color 0.18s ease;
}

.tabbar a[aria-current="page"] {
  color: var(--sage-700);
}

.tabbar a[aria-current="page"] .tab-icon {
  background: var(--sage-100);
}

/* ---------------------------------------------------------------- controls */

button,
.button {
  font-family: inherit;
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: 0.005em;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 11px 16px;
  cursor: pointer;
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  text-decoration: none;
  box-shadow: var(--shadow-xs);
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background-color 0.12s ease;
}

button:active,
.button:active {
  transform: translateY(1px);
  box-shadow: none;
}

/* Outline icons sit inside buttons and headings; both are flex or inline
 * contexts, so this is alignment only. */
.icon {
  flex: 0 0 auto;
  vertical-align: -0.15em;
}

h2.verdict {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  color: var(--sage-700);
}

/* Sits on the first line of the verdict, not halfway down two of them. */
h2.verdict .icon {
  margin-top: 3px;
}

button:disabled,
.button:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}

button.primary,
.button.primary {
  background: var(--sage-600);
  border-color: var(--sage-600);
  color: var(--surface);
  box-shadow: var(--shadow-sage);
}

button.primary:active,
.button.primary:active {
  background: var(--sage-700);
}

button.danger,
.button.danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: var(--danger-line);
  box-shadow: none;
}

/* A small delete is a footnote, not a warning: keep the colour, drop the fill. */
button.danger.small,
.button.danger.small {
  background: transparent;
}

/* The wand button: a suggestion is an offer, not the main event, so it reads as
 * a sage note rather than a second primary. */
button.suggest,
.button.suggest {
  background: var(--sage-50);
  border-color: var(--sage-200);
  color: var(--sage-700);
  box-shadow: none;
}

/* This one is only ever disabled because it is thinking, and thinking should
 * not look switched off. */
button.suggest:disabled {
  opacity: 0.92;
}

button.full,
.button.full {
  width: 100%;
}

button.small,
.button.small {
  min-height: 44px;
  padding: 8px 14px;
  font-size: var(--fs-sm);
  border-radius: var(--radius-sm);
}

input[type="text"],
input[type="password"],
input[type="search"],
select,
textarea {
  font-family: inherit;
  font-size: var(--fs-base);
  width: 100%;
  padding: 12px 14px;
  min-height: 46px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-xs) inset;
  transition:
    border-color 0.14s ease,
    box-shadow 0.14s ease;
}

input::placeholder,
textarea::placeholder {
  color: #a2937f;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--sage-400);
  box-shadow: 0 0 0 3px var(--sage-100);
}

/* A warm chevron instead of the platform grey one. Inline data URI: this is an
 * offline app, so nothing may reach for the network. */
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236f6152' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  text-transform: capitalize;
}

/* A magnifier tucked into the field, so the box says what it is before she
 * reads the placeholder. */
input[type="search"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%236f6152' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='16.6' y1='16.6' x2='21' y2='21'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
  padding-left: 42px;
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

textarea {
  min-height: 82px;
  resize: vertical;
  line-height: 1.5;
}

label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
  margin-bottom: var(--space-1);
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4) var(--space-4);
  margin: 0;
  background: var(--surface-2);
}

legend {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--muted);
  padding: 0 var(--space-2);
}

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

/* Each option is its own little pill, so a tick is a 44px target rather than a
 * 18px box you have to aim at. */
.checks label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  min-height: 44px;
  padding: 0 14px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-weight: 600;
  color: var(--ink);
  font-size: var(--fs-md);
  text-transform: capitalize;
  cursor: pointer;
}

.checks label:has(input:checked) {
  background: var(--sage-100);
  border-color: var(--sage-300);
  color: var(--sage-700);
}

.checks input {
  width: 18px;
  height: 18px;
  accent-color: var(--sage-600);
  margin: 0;
}

/* file inputs are wrapped in a label styled as a button */
.filepick input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------------------------------------------------------------- chips */

.chips {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding: 2px var(--space-4) var(--space-2);
  margin: 0 calc(var(--space-4) * -1) var(--space-4);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  /* Fades the right edge so it is obvious the row keeps going. */
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent);
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: var(--radius-pill);
  padding: 10px 16px;
  font-size: var(--fs-md);
  font-weight: 600;
  min-height: 44px;
  white-space: nowrap;
  text-transform: capitalize;
  box-shadow: var(--shadow-xs);
}

.chip[aria-pressed="true"] {
  background: var(--sage-600);
  border-color: var(--sage-600);
  color: var(--surface);
  box-shadow: var(--shadow-sage);
}

/* ---------------------------------------------------------------- grid */

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-align: left;
  padding: 0;
  display: block;
  min-height: 0;
  box-shadow: var(--shadow-sm);
}

/* The tappable body of a card. The card itself is a wrapper now, so that a
 * second action can sit under it without nesting one button inside another. */
.card-tap {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  text-align: left;
  min-height: 0;
  box-shadow: none;
}

.card-action {
  width: calc(100% - (var(--space-3) * 2));
  margin: 0 var(--space-3) var(--space-3);
  min-height: 44px;
  padding: 8px 10px;
  font-size: var(--fs-sm);
  border-radius: var(--radius-sm);
  background: var(--sage-50);
  border-color: var(--sage-200);
  color: var(--sage-700);
  box-shadow: none;
}

/* Grid thumbnails are the photo she took, not the cutout, so they fill their
 * tile: a square of picture reads as a wardrobe, letterboxed bars read as a
 * spreadsheet. The cream underneath only shows while the image loads. */
.card .thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: radial-gradient(circle at 50% 46%, #fffdf8 0%, #f6efe1 100%);
  display: block;
}

.card .card-body {
  padding: var(--space-2) var(--space-3) var(--space-3);
}

.card-name {
  font-size: var(--fs-md);
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink-strong);
  margin: 0 0 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card .card-body .badge {
  margin-bottom: var(--space-1);
}

/* The only muted line inside a card body is the slot it fills - "top", "shoes" -
 * stored lower-case as a value and read here as a word. */
.card .card-body .muted {
  margin: 0;
  text-transform: capitalize;
}

/* The read-only row is small, so it takes the deeper clay to stay legible; the
 * picker below is 24px of glyph and can afford the prettier one. */
.hearts {
  letter-spacing: 2px;
  font-size: var(--fs-sm);
  color: var(--clay-600);
  line-height: 1.2;
}

.heart-picker {
  display: flex;
  gap: var(--space-1);
}

.heart-picker button {
  border: none;
  background: none;
  box-shadow: none;
  color: var(--clay-500);
  font-size: 1.6rem;
  line-height: 1;
  padding: 2px 6px;
  min-height: 44px;
  min-width: 44px;
}

/* ---------------------------------------------------------------- panels */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-4) var(--space-5);
  box-shadow: var(--shadow-md);
}

.panel + .panel {
  margin-top: var(--space-3);
}

.hero-image {
  width: 100%;
  max-height: 42vh;
  object-fit: contain;
  padding: var(--space-4);
  background:
    radial-gradient(circle at 50% 44%, #ffffff 0%, #fdf8ee 44%, #f2e9d7 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  display: block;
  margin-bottom: var(--space-4);
}

.badge {
  display: inline-block;
  background: var(--sage-600);
  color: var(--surface);
  border-radius: var(--radius-pill);
  padding: 3px 10px;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.badge.quiet {
  background: var(--sage-50);
  color: var(--sage-700);
  border: 1px solid var(--sage-200);
  font-weight: 600;
  text-transform: capitalize;
}

.hscroll {
  display: flex;
  gap: var(--space-3);
  overflow-x: auto;
  padding-bottom: var(--space-2);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.hscroll::-webkit-scrollbar {
  display: none;
}

.hscroll .card {
  flex: 0 0 47%;
}

.outfit-piece {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--line);
}

/* Garment names are long ("Cream Leather Loafers"), and the row also has to
 * hold a padlock and a swap, so give the name two lines and then stop. */
.outfit-piece .card-name {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.outfit-piece .small {
  padding: 8px 12px;
}

/* The last piece in the run drops its rule - whatever follows (the notes, the
 * sprig, the buttons) draws its own separation. */
.outfit-piece:last-child,
.outfit-piece:has(+ :not(.outfit-piece)) {
  border-bottom: none;
}

.outfit-piece img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  background: radial-gradient(circle at 50% 46%, #fffdf8 0%, #f6efe1 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  flex: 0 0 auto;
}

.outfit-piece .grow {
  flex: 1;
  min-width: 0;
}

.outfit-piece .grow p {
  margin: 0;
}

.outfit-piece .grow .muted {
  text-transform: capitalize;
}

/* The padlock. Locked is a filled sage key; unlocked is an open outline, so the
 * two states differ in shape and in weight, not only in colour. */
.lock-toggle {
  flex: 0 0 auto;
  width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: var(--radius-pill);
  color: var(--muted);
  background: var(--surface);
  border-color: var(--line-strong);
  border-style: dashed;
  box-shadow: none;
}

.lock-toggle[aria-pressed="true"] {
  background: var(--sage-600);
  border-color: var(--sage-600);
  border-style: solid;
  color: var(--surface);
  box-shadow: var(--shadow-sage);
}

/* A locked piece is the one she chose. The whole row says so, not just the
 * button: settled things get the confirming green. */
.outfit-piece:has(.lock-toggle[aria-pressed="true"]) {
  background: var(--success-soft);
  border-radius: var(--radius-md);
  padding-left: var(--space-2);
  padding-right: var(--space-2);
  margin: 0 calc(var(--space-2) * -1);
  border-bottom-color: transparent;
}

.outfit-piece:has(.lock-toggle[aria-pressed="true"]) .grow .muted {
  color: var(--success);
  font-weight: 600;
}

.notes-list {
  margin: var(--space-3) 0 0;
  padding-left: var(--space-5);
  color: var(--muted);
  font-size: var(--fs-sm);
}

.notes-list li + li {
  margin-top: var(--space-1);
}

.notes-list::marker,
.notes-list li::marker {
  color: var(--sage-300);
}

/* The banner that names the piece an outfit is being built around. */
.anchor-note {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--sage-50);
  border: 1px solid var(--sage-200);
  color: var(--sage-700);
  border-radius: var(--radius-lg);
  padding: 10px var(--space-3);
  margin: 0 0 var(--space-3);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.anchor-note:empty {
  display: none;
}

/* The lead tucks under a title, but not under the banner. */
.anchor-note + .lead {
  margin-top: 0;
}

/* Nothing fits, because everything is locked. Stack the ways out. */
.lock-conflict {
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.lock-conflict button {
  width: 100%;
  max-width: 280px;
}

/* The first way out is the one that actually undoes the knot. */
.lock-conflict button:first-of-type {
  background: var(--sage-50);
  border-color: var(--sage-200);
  color: var(--sage-700);
}

/* ---------------------------------------------------------------- fab */

.fab {
  position: fixed;
  right: var(--space-4);
  bottom: calc(var(--tab-height) + var(--safe-bottom) + var(--space-4));
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--sage-500), var(--sage-600));
  color: var(--surface);
  border: none;
  min-height: 60px;
  box-shadow: 0 6px 20px rgba(74, 88, 56, 0.34);
  z-index: 15;
  padding: 0;
}

.fab:active {
  transform: translateY(1px) scale(0.97);
  box-shadow: 0 3px 10px rgba(74, 88, 56, 0.3);
}

/* ---------------------------------------------------------------- states */

.empty {
  text-align: center;
  padding: var(--space-8) var(--space-4) var(--space-6);
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.empty p {
  margin: 0;
  max-width: 34ch;
}

.empty .icon-large {
  display: block;
  width: 76px;
  height: 76px;
  padding: 18px;
  border-radius: 50%;
  background: var(--sage-50);
  border: 1px solid var(--sage-100);
  color: var(--sage-600);
}


.loading {
  text-align: center;
  color: var(--muted);
  padding: var(--space-8) var(--space-3);
  font-size: var(--fs-md);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--sage-100);
  border-top-color: var(--sage-600);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
  vertical-align: -4px;
}

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

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }

  button,
  .button,
  .tabbar a .tab-icon {
    transition: none;
  }
}

/* ---------------------------------------------------------------- motion
 *
 * House style: short (160-320ms), a little springy on the way in, and never
 * anything that has to finish before she can tap. Every rule in this block is
 * switched off wholesale by the `prefers-reduced-motion` block at its end, and
 * the JS that adds these classes checks the same query before it does.
 */

:root {
  --ease-spring: cubic-bezier(0.22, 1.15, 0.36, 1);
  --ease-out: cubic-bezier(0.22, 0.75, 0.3, 1);
}

/* A view arriving after a tab tap or a route change. */
.view-enter {
  animation: view-in 0.2s var(--ease-out) both;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* One element in a staggered reveal. `--reveal-index` is set per node in JS. */
.reveal {
  animation: reveal-in 0.34s var(--ease-spring) both;
  animation-delay: calc(var(--reveal-index, 0) * 70ms);
}

@keyframes reveal-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
}

/* The cutout settling into place at the top of a verdict: a touch slower and a
 * touch further, because it is the thing she is looking at. */
.verdict-cutout.reveal {
  animation-name: cutout-settle;
  animation-duration: 0.52s;
}

@keyframes cutout-settle {
  from {
    opacity: 0;
    transform: translateY(-14px) scale(1.05);
  }
}

/* A press. Buttons already dip a pixel; cards get a whole-card squeeze so a
 * tap on a photo feels like a tap on a thing. */
.card-tap:active,
.chip:active,
.compare-open:active {
  transform: scale(0.975);
}

.card-tap {
  transition: transform 0.12s var(--ease-out);
}

/* A heart that was just tapped. */
.heart-picker button.popped {
  animation: heart-pop 0.34s var(--ease-spring);
}

@keyframes heart-pop {
  0% {
    transform: scale(1);
  }
  38% {
    transform: scale(1.42) rotate(-6deg);
  }
  100% {
    transform: scale(1);
  }
}

/* An outfit piece that changed in a shuffle or a swap. A locked piece never
 * gets this class, so it visibly stays put while the rest turn over. */
.piece-in {
  animation: piece-in 0.3s var(--ease-out) both;
}

@keyframes piece-in {
  from {
    opacity: 0;
    transform: translateY(6px);
    filter: blur(1.5px);
  }
}

/* Petals. The layer is a zero-size anchor pinned to the middle of whatever was
 * tapped; each particle flies out from it and is removed with the layer. */
.burst {
  position: fixed;
  width: 0;
  height: 0;
  z-index: 50;
  pointer-events: none;
}

.burst .particle {
  position: absolute;
  left: 0;
  top: 0;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  background: var(--tint);
  /* An off-round petal rather than a circle of confetti. */
  border-radius: 60% 8% 60% 8%;
  animation: petal-fly 1s var(--ease-out) both;
  animation-delay: var(--delay, 0ms);
}

.burst .particle.spark {
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50% 6% 50% 6%;
  animation-duration: 0.78s;
}

@keyframes petal-fly {
  from {
    opacity: 0;
    transform: translate(0, 0) scale(0.3) rotate(0deg);
  }
  22% {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(var(--scale, 1)) rotate(var(--rot, 180deg));
  }
}

@media (prefers-reduced-motion: reduce) {
  .view-enter,
  .reveal,
  .verdict-cutout.reveal,
  .piece-in,
  .heart-picker button.popped,
  .burst .particle {
    animation: none;
  }

  .card-tap:active,
  .chip:active,
  .compare-open:active {
    transform: none;
  }

  .card-tap {
    transition: none;
  }
}

/* ---------------------------------------------------------------- verdict */

/* Shorter than a normal hero: the verdict is the point of this screen, and it
 * has to be readable without a scroll on a 375px phone. */
.verdict-cutout {
  max-height: 30vh;
  margin-bottom: var(--space-3);
}

/* The comparison rail: one card per near-twin, snapping so a swipe lands on a
 * whole comparison rather than half of two. */
.compare-rail {
  scroll-snap-type: x mandatory;
  scroll-padding: 0 var(--space-1);
  margin-top: var(--space-1);
}

/* Beats `.hscroll .card`, which sizes the ordinary two-up cards. */
.hscroll .compare-card {
  flex: 0 0 87%;
  scroll-snap-align: center;
  padding: var(--space-3);
  background: var(--surface-2);
}

/* Candidate on the left, the piece she owns on the right, and the likeness
 * between them pinned to the seam - the badge floats rather than taking a
 * column, so both photos stay as large as the card allows. */
.compare-pair {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: var(--space-3);
}

.compare-side {
  margin: 0;
  min-width: 0;
  text-align: center;
}

.compare-side img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: radial-gradient(circle at 50% 46%, #fffdf8 0%, #f6efe1 100%);
  display: block;
}

/* The candidate is a cutout on transparency, so it is shown whole rather than
 * cropped square like a wardrobe thumbnail. */
.compare-side:first-child img {
  object-fit: contain;
  padding: 6px;
}

.compare-side figcaption {
  margin-top: var(--space-1);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--muted);
}

/* The percentage sits on the seam between the two photos, ringed in cream so it
 * reads as a chip laid over them rather than a label belonging to either. */
.compare-badge {
  position: absolute;
  left: 50%;
  /* Centred on the photos, not on the photos-plus-captions. */
  top: calc(50% - 11px);
  transform: translate(-50%, -50%);
  z-index: 2;
  padding: 5px 10px;
  white-space: nowrap;
  border: 2px solid var(--surface);
  box-shadow: var(--shadow-sage);
}

.compare-open {
  width: 100%;
  margin-top: var(--space-3);
  background: var(--surface);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  transition: transform 0.12s var(--ease-out);
}

/* ---------------------------------------------------------------- welcome */

/* The one screen in the app that is only words. Nothing else on it, nothing
 * under it, no way back to it - so it can afford all the room it wants. */
.welcome {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + var(--space-5)) var(--space-5)
    calc(env(safe-area-inset-bottom, 0px) + var(--space-5));
  overflow-y: auto;
  background: var(--bg);
}

.welcome::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(64% 42% at 16% 6%, rgba(125, 143, 106, 0.2), transparent 70%),
    radial-gradient(58% 40% at 90% 94%, rgba(192, 113, 78, 0.14), transparent 72%),
    repeating-linear-gradient(90deg, rgba(120, 96, 64, 0.02) 0 1px, transparent 1px 3px);
}

.welcome.leaving {
  animation: welcome-out 0.34s var(--ease-out) both;
}

@keyframes welcome-out {
  to {
    opacity: 0;
    transform: scale(1.02);
  }
}

.welcome-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  margin: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6) var(--space-6);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.welcome-sprig {
  display: block;
  margin: 0 auto var(--space-3);
  color: var(--sage-400);
}

.welcome-card h1 {
  font-size: var(--fs-2xl);
  margin-bottom: var(--space-2);
}

.welcome-card .divider {
  margin: var(--space-4) 0 var(--space-5);
}

/* Letter type: a little larger, a little looser, generous between paragraphs.
 * Ranged left, because centred prose is a poster and this is a note. */
.welcome-line {
  font-size: var(--fs-md);
  line-height: 1.68;
  color: var(--ink);
  text-align: left;
  text-wrap: pretty;
  margin: 0 0 var(--space-4);
}

/* The unedited placeholder. Loud enough that shipping it is a decision. */
.welcome-placeholder {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--clay-600);
  background: #fdf1e9;
  border: 1px dashed var(--clay-500);
  border-radius: var(--radius-md);
  padding: 10px var(--space-3);
  margin: 0 0 var(--space-4);
}

.welcome-sign {
  margin: var(--space-5) 0 0;
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--sage-700);
  letter-spacing: 0.01em;
}

.welcome-open {
  margin-top: var(--space-8);
}

@media (prefers-reduced-motion: reduce) {
  .welcome.leaving {
    animation: none;
  }
}

/* ---------------------------------------------------------------- toast */

#toasts {
  position: fixed;
  left: var(--space-3);
  right: var(--space-3);
  bottom: calc(var(--tab-height) + var(--safe-bottom) + var(--space-3));
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  background: var(--ink-strong);
  color: #fbf7ef;
  border-radius: var(--radius-lg);
  padding: 12px var(--space-4);
  font-size: var(--fs-md);
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.22s ease-out;
}

.toast.error {
  background: var(--danger);
  color: #fdf3ef;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
  }
}

/* ---------------------------------------------------------------- login */

#login {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

#login::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(60% 40% at 20% 8%, rgba(125, 143, 106, 0.16), transparent 70%),
    radial-gradient(56% 40% at 88% 92%, rgba(192, 113, 78, 0.1), transparent 72%);
}

#login[hidden] {
  display: none;
}

#login form {
  position: relative;
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: var(--space-6) var(--space-5);
  box-shadow: var(--shadow-lg);
}

#login .sprig {
  display: block;
  margin: 0 auto var(--space-2);
  color: var(--sage-400);
}
