/* Stiki's Kickvault. The design (docs/design/, Claude Design, Nov 2026) is dark; M9 adds a light
   palette (Kira), chosen per account in Settings or following the phone (see the :root blocks).
   Fonts are bundled (CSP: font-src 'self'): Inter for body and UI, Space Grotesk for
   headings and numbers. Both SIL OFL 1.1, licences beside them in /fonts/. */
@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter-latin-wght.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Space Grotesk';
  src: url('/fonts/space-grotesk-latin-wght.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #07080a;
  --surface: #111318;
  --surface-2: #181b22;
  --line: #23272f;
  --line-soft: #1c1f26;
  --bar: #0c0d10;
  --ink: #f2f4f7;
  --ink-2: #d5dae1;
  --muted: #9aa3b2;
  --accent: #2f78c4;
  --accent-tint: #14233a;
  --link: #6aa6e8;
  --link-hover: #9cc4f0;
  --on-accent: #ffffff;
  --error: #ff8a9a;
  --danger: #c8283a;
  --gain: #7ee29a;
  --focus: #9cc4f0;
  --accent-hi: #3d8bdb;
  --dash: #2a3a52;
  --dash-bg: #0d1118;
  --placeholder: #8a93a3;
  --error-bg: #1f1015;
  --edge: #3a3f48;
  --notice-edge: #23324a;
  --radius: 14px;
  --radius-lg: 20px;
  --display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --tabbar: 4.5rem;
  --rail: 6rem;
  color-scheme: dark;
  accent-color: var(--accent);
}

/* Light and dark (M9). The values above are the dark ones and the fallback. Where the browser has
   light-dark() (Baseline 2024) the page follows the phone, or the account's choice: Settings
   puts data-theme="light" or "dark" on <html>, and with neither the phone decides. The light
   palette is Kira's (deliverables/sandbox-media/sneakers/m9-ui). Both pass 4.5:1 for text. */
:root {
  color-scheme: light dark;
}

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

:root[data-theme='dark'] {
  color-scheme: dark;
}

/* Fallback for browsers without light-dark() (before Safari 17.5): the same light palette, set
   by the prefers-color-scheme media query, or by the account's choice. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) {
    --bg: #f3f5f8;
    --surface: #ffffff;
    --surface-2: #eaeef3;
    --line: #dce1e8;
    --line-soft: #e6eaf0;
    --bar: #ffffff;
    --ink: #0b0d11;
    --ink-2: #2a303a;
    --muted: #596273;
    --accent-tint: #e3eef9;
    --link: #1f5fa6;
    --link-hover: #164b85;
    --error: #b4323a;
    --danger: #b4323a;
    --gain: #1e7a3e;
    --focus: #1f5fa6;
    --dash: #b9cce3;
    --dash-bg: #f7f9fb;
    --placeholder: #6b7585;
    --error-bg: #fbecee;
    --edge: #c9d0da;
    --notice-edge: #bcd3ec;
  }
}

:root[data-theme='light'] {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #eaeef3;
  --line: #dce1e8;
  --line-soft: #e6eaf0;
  --bar: #ffffff;
  --ink: #0b0d11;
  --ink-2: #2a303a;
  --muted: #596273;
  --accent-tint: #e3eef9;
  --link: #1f5fa6;
  --link-hover: #164b85;
  --error: #b4323a;
  --danger: #b4323a;
  --gain: #1e7a3e;
  --focus: #1f5fa6;
  --dash: #b9cce3;
  --dash-bg: #f7f9fb;
  --placeholder: #6b7585;
  --error-bg: #fbecee;
  --edge: #c9d0da;
  --notice-edge: #bcd3ec;
}

@supports (color: light-dark(#000, #fff)) {
  :root {
    --bg: light-dark(#f3f5f8, #07080a);
    --surface: light-dark(#ffffff, #111318);
    --surface-2: light-dark(#eaeef3, #181b22);
    --line: light-dark(#dce1e8, #23272f);
    --line-soft: light-dark(#e6eaf0, #1c1f26);
    --bar: light-dark(#ffffff, #0c0d10);
    --ink: light-dark(#0b0d11, #f2f4f7);
    --ink-2: light-dark(#2a303a, #d5dae1);
    --muted: light-dark(#596273, #9aa3b2);
    --accent-tint: light-dark(#e3eef9, #14233a);
    --link: light-dark(#1f5fa6, #6aa6e8);
    --link-hover: light-dark(#164b85, #9cc4f0);
    --error: light-dark(#b4323a, #ff8a9a);
    --danger: light-dark(#b4323a, #c8283a);
    --gain: light-dark(#1e7a3e, #7ee29a);
    --focus: light-dark(#1f5fa6, #9cc4f0);
    --dash: light-dark(#b9cce3, #2a3a52);
    --dash-bg: light-dark(#f7f9fb, #0d1118);
    --placeholder: light-dark(#6b7585, #8a93a3);
    --error-bg: light-dark(#fbecee, #1f1015);
    --edge: light-dark(#c9d0da, #3a3f48);
    --notice-edge: light-dark(#bcd3ec, #23324a);
  }
}

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

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  min-block-size: 100dvh;
}

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

a {
  color: var(--link);
}

a:hover {
  color: var(--link-hover);
}

h1,
h2,
h3 {
  font-family: var(--display);
  font-weight: 700;
  line-height: 1.15;
  text-wrap: balance;
}

h1 {
  font-size: clamp(1.5rem, 1.25rem + 1.2vw, 2.25rem);
  margin-block: 0.25rem 1rem;
}

h2 {
  font-size: 1.25rem;
  margin-block: 2rem 0.75rem;
}

h3 {
  font-size: 1.0625rem;
  margin-block: 1.5rem 0.5rem;
}

/* Brand: the vault-dial mark and the wordmark, "Kickvault" with "vault" in the link blue. */
header.site {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: calc(0.75rem + env(safe-area-inset-top, 0px)) clamp(1.25rem, 4vw, 2rem) 0.25rem;
  max-inline-size: 76rem;
  margin-inline: auto;

  .home {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    min-block-size: 44px;
    color: var(--ink);
    text-decoration: none;
  }

  .header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
}

.mark {
  inline-size: 2.25rem;
  block-size: 2.25rem;
  flex: none;
}

.wordmark {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;

  span {
    color: var(--link);
  }
}

main {
  max-inline-size: 76rem;
  margin-inline: auto;
  padding: 0.75rem clamp(1.25rem, 4vw, 2rem) 3rem;
}

/* Main navigation. Phone held upright: a tab bar along the bottom with the add button in
   the middle (the design's portrait boards). Phone on its side and wider screens: a rail
   down the left (the landscape boards). One <nav>, the same order either way. */
nav.tabs {
  position: fixed;
  z-index: 10;
  inset-inline: 0;
  inset-block-end: 0;
  display: grid;
  /* Five tabs since v1.5.2 (Vault, Wishlist, +, Stats, Profile): the + is the middle column,
     on the centre line of the phone. */
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  padding: 0.5rem calc(0.5rem + env(safe-area-inset-right, 0px)) calc(0.5rem + env(safe-area-inset-bottom, 0px)) calc(0.5rem + env(safe-area-inset-left, 0px));
  background: var(--bar);
  border-block-start: 1px solid var(--line-soft);

  a,
  button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    min-block-size: 48px;
    padding: 0.25rem;
    border: 0;
    border-radius: var(--radius);
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 0.6875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
  }

  a:hover,
  button:hover {
    color: var(--ink);
  }

  a[aria-current='page'] {
    color: var(--link);
    font-weight: 600;
  }

  svg {
    inline-size: 22px;
    block-size: 22px;
    flex: none;
  }

  .add {
    justify-self: center;
    inline-size: 56px;
    block-size: 56px;
    border-radius: 18px;
    background: var(--accent);
    color: var(--on-accent);
  }

  .add:hover,
  .add[aria-current='page'] {
    color: var(--on-accent);
    background: var(--accent-hi);
  }

  .add svg {
    inline-size: 26px;
    block-size: 26px;
  }
}

body.has-tabs {
  padding-block-end: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 1rem);
}

/* The brand mark heads the rail (landscape boards); the bottom bar has no room for it. */
.rail-mark {
  display: none;
}

/* The add button's label is for screen readers; the + is the visible label, as designed. */
.tab-label-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (orientation: landscape) and (max-height: 32rem), (min-width: 48rem) {
  body.has-tabs {
    padding-block-end: 0;
    padding-inline-start: calc(var(--rail) + env(safe-area-inset-left, 0px));
  }

  /* The rail already carries the logomark: the header keeps only the wordmark, so a page never
     shows the mark twice (M9). */
  header.site .home .mark {
    display: none;
  }

  nav.tabs {
    inset-block: 0;
    inset-inline-end: auto;
    inline-size: calc(var(--rail) + env(safe-area-inset-left, 0px));
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 0.375rem;
    padding: 1rem 0.75rem 1rem calc(0.75rem + env(safe-area-inset-left, 0px));

    .rail-mark {
      display: block;
      margin-block-end: auto;
    }

    .rail-mark .mark {
      inline-size: 2.5rem;
      block-size: 2.5rem;
    }

    > a:last-of-type {
      margin-block-end: auto;
    }
    border-block-start: 0;
    border-inline-end: 1px solid var(--line-soft);
    background: var(--bg);
    overflow-y: auto;

    a,
    button {
      inline-size: 100%;
      min-block-size: 52px;
    }

    a[aria-current='page'] {
      background: var(--accent-tint);
    }

    .add {
      inline-size: 52px;
      block-size: 52px;
      border-radius: 16px;
      margin-block: 0.25rem;
    }
  }
}

/* A phone on its side is short: the rail shows icons only, each still named for screen readers. */
@media (orientation: landscape) and (max-height: 32rem) {
  nav.tabs .tab-label {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* Buttons and fields */
input,
select,
textarea,
button,
.button {
  font: inherit;
  font-size: max(1rem, 1em);
}

input:not([type='radio'], [type='checkbox'], [type='file']),
select,
textarea {
  inline-size: 100%;
  min-block-size: 48px;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

input::placeholder,
textarea::placeholder {
  color: var(--placeholder);
}

input:not([type='radio'], [type='checkbox'], [type='file']):focus,
textarea:focus {
  border-color: var(--accent);
}

/* The Add board's photo tile: dashed, camera and title in the link blue, the hint under it,
   then the native picker (compact) so the chosen file's name still shows. */
.photo-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-block-size: 150px;
  padding: 1.25rem 1rem 1rem;
  border: 2px dashed var(--dash);
  border-radius: var(--radius-lg);
  background: var(--dash-bg);
  text-align: center;

  label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--link);
    cursor: pointer;
  }

  .tile-icon {
    inline-size: 30px;
    block-size: 30px;
  }

  .tile-title {
    font-size: 0.9375rem;
    font-weight: 600;
  }

  .hint {
    font-size: 0.75rem;
  }
}

.photo-tile:has(input:focus-visible) {
  border-color: var(--focus);
}

input[type='file'] {
  max-inline-size: 100%;
  color: var(--muted);
  font-size: 0.8125rem;
}

input[type='file']::file-selector-button {
  margin-inline-end: 0.75rem;
  min-block-size: 44px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

textarea {
  resize: vertical;
}

input:user-invalid,
textarea:user-invalid,
[aria-invalid='true'] {
  border-color: var(--error);
  border-width: 2px;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-block-size: 48px;
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--accent);
  border-radius: 16px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--accent-hi);
  color: var(--on-accent);
}

/* Icons in buttons and button-links (M9, Kira's set): 20px, in the link blue on the quiet
   buttons, always beside the words, so the label still names the button. */
button svg,
.button svg {
  inline-size: 1.25rem;
  block-size: 1.25rem;
  flex: none;
}

button.secondary svg,
.button.secondary svg {
  color: var(--link);
}

.button.danger-text,
.button.danger-text svg {
  color: var(--error);
}

button.secondary,
.button.secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

button.secondary:hover,
.button.secondary:hover {
  background: var(--surface-2);
  color: var(--ink);
}

button.link {
  min-block-size: auto;
  padding: 0.75rem 0;
  border: 0;
  background: none;
  color: var(--link);
  font-weight: inherit;
  text-decoration: underline;
}

button.danger {
  background: var(--danger);
  border-color: var(--danger);
}

/* Round icon buttons from the design (back, edit), always with a name. */
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 44px;
  block-size: 44px;
  flex: none;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);

  svg {
    inline-size: 20px;
    block-size: 20px;
  }
}

.icon-button:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.header-actions .button,
.header-actions button {
  min-block-size: 44px;
  padding-inline: 1rem;
  border-radius: 22px;
  font-size: 0.875rem;
}

form.inline {
  display: inline;
}

.stack {
  display: flex;
  flex-direction: column;
}

.narrow {
  max-inline-size: 36rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-block-end: 1.125rem;

  > label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted);
  }
}

.hint {
  color: var(--muted);
  font-size: 0.875rem;
}

.field-error {
  color: var(--error);
  font-weight: 600;
}

.field-error::before {
  content: '\26A0\FE0E  ' / '';
}

.error-summary {
  border: 2px solid var(--error);
  border-radius: var(--radius);
  background: var(--error-bg);
  padding: 0.75rem 1rem;
  margin-block: 0 1.25rem;

  h2 {
    font-size: 1.0625rem;
    margin: 0 0 0.25rem;
  }

  ul {
    margin: 0;
    padding-inline-start: 1.25rem;
  }

  a {
    color: var(--error);
  }
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 1.125rem;
  min-inline-size: 0;
}

legend {
  padding: 0;
  margin-block-end: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
}

/* A row of radios drawn as the design's segmented control. The radios stay real radios:
   arrow keys move between them and the focus ring shows on the segment. */
.segments {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 4.5rem), 1fr));
  gap: 0.25rem;
  padding: 0.25rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);

  .choice {
    position: relative;
    display: block;
  }

  .choice input {
    position: absolute;
    inset: 0;
    inline-size: 100%;
    block-size: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
  }

  .choice label {
    display: flex;
    align-items: center;
    justify-content: center;
    min-block-size: 44px;
    padding: 0.25rem 0.5rem;
    border-radius: 10px;
    color: var(--ink-2);
    font-size: 0.875rem;
    text-align: center;
  }

  .choice input:checked + label {
    background: var(--ink);
    color: var(--bg);
    font-weight: 600;
  }

  .choice input:focus-visible + label {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
  }
}

.choice {
  display: flex;
  align-items: center;
  gap: 0.5rem;

  input {
    inline-size: 1.25rem;
    block-size: 1.25rem;
    margin: 0;
  }

  label {
    padding-block: 0.6rem;
  }
}

.two-up {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
  gap: 0 0.75rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-block-start: 1rem;
}

/* Remove sits on its own at the foot of the pair and edit pages, away from the everyday
   buttons, so it isn't tapped by mistake. It still goes through the confirm page. */
.remove-row {
  margin-block-start: 2.5rem;
  padding-block-start: 1rem;
  border-block-start: 1px solid var(--line-soft);
}

/* Profile: who is signed in, with Sign out beside it (moved off the tab bar, v1.5.1). */
.signed-in {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-block-end: 1rem;

  .hint {
    margin: 0;
  }
}

/* Search (vault and lookup) */
.searchbar {
  margin-block-end: 1rem;

  label {
    display: block;
    margin-block-end: 0.375rem;
    font-size: 0.8125rem;
    color: var(--muted);
  }

  .row {
    display: flex;
    gap: 0.5rem;
    max-inline-size: 36rem;
  }

  input[type='search'] {
    border-radius: 24px;
    padding-inline: 1.125rem;
  }

  button {
    border-radius: 24px;
  }
}

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

/* Vault header: title with its sort note, stat tiles and the brand chips. */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;

  h1 {
    margin: 0;
  }

  .hint {
    font-size: 0.8125rem;
  }
}

.page-head {
  margin-block-end: 1rem;
}

.stat-strip {
  flex-basis: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0 0;
  padding: 1.125rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);

  div {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-inline-size: 0;
  }

  dt {
    font-size: 0.6875rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }

  dd {
    margin: 0;
    font-family: var(--display);
    font-size: clamp(1.25rem, 1rem + 1.5vw, 1.625rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
  }

  .value {
    color: var(--link);
  }
}

/* v1.5.2: the Paid figure stays on one line ("$1,540.00" broke after "0" at 390). The two
   counts take what they need; Paid gets the rest and a smaller figure on a narrow phone. */
.stat-strip {
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 0.75rem 1.25rem;

  dd.value {
    white-space: nowrap;
    overflow-wrap: normal;
  }
}

@media not ((orientation: landscape) and (max-height: 32rem)) {
  .stat-strip dd.value {
    font-size: clamp(1.125rem, 0.75rem + 1.75vw, 1.625rem);
  }
}

.chips {
  display: flex;
  gap: 0.5rem;
  margin: 0 0 1.25rem;
  padding: 0 0 0.25rem;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;

  a,
  .chip {
    display: inline-flex;
    align-items: center;
    min-block-size: 36px;
    padding: 0 1rem;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-2);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
  }

  a[aria-current='page'],
  .chip.on {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
  }
}

.chips.static {
  flex-wrap: wrap;
  overflow: visible;
}

/* Pair cards */
.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

@media (orientation: landscape) and (max-height: 32rem), (min-width: 48rem) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  }
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.75rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  min-inline-size: 0;

  > a {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    color: inherit;
    text-decoration: none;
  }

  > a:hover .name {
    text-decoration: underline;
  }

  .brand {
    font-size: 0.6875rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .name {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25;
  }

  .meta {
    color: var(--muted);
    font-size: 0.75rem;
  }

  form {
    margin-block-start: 0.5rem;
  }
}

.card-photo {
  position: relative;
  display: block;
}

.badge {
  position: absolute;
  inset-block-start: 0.5rem;
  inset-inline-start: 0.5rem;
  padding: 0.1875rem 0.4375rem;
  border-radius: 6px;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--bg);
  color: var(--ink-2);
  border: 1px solid var(--edge);
}

.badge.ds {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.photo {
  display: block;
  inline-size: 100%;
  block-size: auto;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--surface-2);
}

/* Stock product shots are on white with the shoe side-on: show all of it. */
.photo.stock {
  object-fit: contain;
  background: #fff;
}

/* v1.8.0: the see-through copy. No white tile behind it, in light or dark; a soft shadow
   follows the shoe's own outline (drop-shadow, not box-shadow) so it still sits on the page. */
.photo.cutout {
  object-fit: contain;
  background: transparent;
  filter: drop-shadow(0 6px 8px rgb(0 0 0 / 0.25));
}

/* The photo-background buttons may wrap their words and shrink with the grid, so at 390px
   they stay inside the page instead of pushing it wider. */
.button.wrap {
  white-space: normal;
  text-align: center;
  min-inline-size: 0;
}

.actions > form,
.panel .actions > * {
  min-inline-size: 0;
}

/* Before and after, side by side: the original's white tile next to the cut-out on the page. */
.compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 1rem;
  margin-block: 1rem;
}

.compare figure {
  margin: 0;
  display: grid;
  gap: 0.5rem;
  justify-items: center;
}

.compare .photo {
  inline-size: 100%;
  block-size: auto;
}

.photo.placeholder {
  display: grid;
  place-items: center;
  color: var(--edge);
}

.photo.placeholder svg {
  inline-size: 60%;
  block-size: auto;
}

.lookup-pick {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 0 1.25rem;
  padding: 0.75rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);

  .photo {
    inline-size: 6rem;
    flex: none;
  }
}

/* Pair page: the photo as a hero with back and edit on it, then the details. */
.detail {
  display: grid;
  gap: 1.25rem;
  align-items: start;
}

@media (orientation: landscape) and (max-height: 32rem), (min-width: 48rem) {
  .detail {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    gap: 1.5rem;
  }

  .hero {
    position: sticky;
    inset-block-start: 1rem;
  }
}

/* Phone held upright (Detail board): the photo panel runs edge to edge from the top of the
   screen, about 360 px tall, with back and edit on it; the site header is hidden on this page. */
body.bare header.site {
  display: none;
}

.hero {
  position: relative;
  display: grid;
  place-items: center;
  min-block-size: 22.5rem;
  margin-block-start: calc(-0.75rem - env(safe-area-inset-top, 0px));
  margin-inline: calc(-1 * clamp(1.25rem, 4vw, 2rem));
  padding: calc(4.5rem + env(safe-area-inset-top, 0px)) 2.5rem 1.5rem;
  background: var(--surface);
  border-block-end: 1px solid var(--line-soft);

  .photo {
    inline-size: min(100%, 18rem);
  }

  .hero-bar {
    position: absolute;
    inset-block-start: calc(0.75rem + env(safe-area-inset-top, 0px));
    inset-inline: 1rem;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
  }

  .hero-bar a {
    pointer-events: auto;
  }
}

/* Wider screens: header back, and the photo as a card beside the details. */
@media (min-width: 48rem) and (min-height: 32.01rem) {
  body.bare header.site {
    display: flex;
  }

  .hero {
    min-block-size: 0;
    margin: 0;
    padding: 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line-soft);

    .photo {
      inline-size: 100%;
      max-block-size: 70dvh;
    }

    .hero-bar {
      inset-block-start: 1rem;
    }
  }
}

/* Phone on its side (the landscape boards): no site header, everything that matters on the
   first 390 px. The Admin button floats top right; the vault's figures sit on one line beside
   the heading; the photo panel runs down the left edge of the pair page. */
@media (orientation: landscape) and (max-height: 32rem) {
  header.site {
    position: absolute;
    inset-block-start: 0;
    inset-inline-end: 0;
    padding: calc(0.75rem + env(safe-area-inset-top, 0px)) calc(1.25rem + env(safe-area-inset-right, 0px)) 0 0;

    .home {
      display: none;
    }
  }

  main {
    padding-block-start: 1rem;
    padding-inline-end: calc(clamp(1.25rem, 4vw, 2rem) + env(safe-area-inset-right, 0px));
  }

  .page-head {
    align-items: baseline;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 1rem;
    margin-block-end: 0.75rem;
    padding-inline-end: 6rem;

    h1 {
      font-size: 1.5rem;
      white-space: nowrap;
    }

    .sort {
      display: none;
    }
  }

  .stat-strip {
    flex-basis: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0 0.5rem;
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
    font-size: 0.8125rem;

    div {
      flex-direction: row-reverse;
      align-items: baseline;
      gap: 0.25em;
    }

    div + div::before {
      content: '\00B7' / '';
      color: var(--muted);
      margin-inline-end: 0.25rem;
      order: 3;
    }

    dt {
      font-size: inherit;
      letter-spacing: normal;
      text-transform: lowercase;
    }

    dd {
      font-family: inherit;
      font-size: inherit;
      font-weight: 600;
    }
  }

  .searchbar {
    margin-block-end: 0.75rem;

    label {
      position: absolute;
      inline-size: 1px;
      block-size: 1px;
      overflow: hidden;
      clip-path: inset(50%);
      white-space: nowrap;
    }

    input[type='search'],
    button {
      min-block-size: 40px;
      padding-block: 0.375rem;
    }
  }

  .chips {
    margin-block-end: 0.75rem;

    a {
      min-block-size: 34px;
      font-size: 0.8125rem;
    }
  }

  main > .summary {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .card {
    padding: 0.625rem;

    .photo {
      aspect-ratio: 4 / 3;
    }

    .name {
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
  }

  .detail {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  }

  .hero {
    position: sticky;
    inset-block-start: 0;
    min-block-size: 100dvh;
    margin-block: -1rem -3rem;
    margin-inline: calc(-1 * clamp(1.25rem, 4vw, 2rem)) 0;
    padding: 4.5rem 1.5rem 1.5rem;
    border-radius: 0;
    border-block-end: 0;
    border-inline-end: 1px solid var(--line-soft);

    .photo {
      inline-size: min(100%, 15rem);
    }

    .hero-bar {
      inset-block-start: 1rem;
    }
  }

  .title-block h1 {
    font-size: 1.375rem;
  }
}

.title-block {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-block-end: 1rem;

  h1 {
    margin: 0;
    font-size: clamp(1.5rem, 1.25rem + 1.2vw, 2rem);
  }

  .kicker {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--link);
  }

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

.detail .notes {
  white-space: pre-line;
  color: var(--ink-2);
}

/* Figures as tiles: the pair page and the value page. */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr));
  gap: 0.625rem;
  margin: 0 0 1rem;

  .tile {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.875rem;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    min-inline-size: 0;
  }

  dt {
    font-size: 0.6875rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
  }

  dd {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-wrap: anywhere;
  }

  .figure {
    font-family: var(--display);
    font-size: 1.375rem;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
  }

  .hint {
    font-size: 0.8125rem;
  }
}

.tiles.wide {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
}

/* The pair page's price section: paid, market, difference, side by side and nothing else. */
.price-box {
  container-type: inline-size;
}

/* Rows (name left, figure right) while the box is narrow, so a figure like US$1,250.00 never
   breaks across two lines; three boxes side by side once there is room. */
.tiles.price-tiles {
  grid-template-columns: 1fr;
  gap: 0.5rem;

  .tile {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }

  dt {
    letter-spacing: 0.02em;
    text-transform: none;
    font-size: 0.875rem;
  }

  dd {
    align-items: flex-end;
    text-align: end;
  }

  .figure {
    font-size: 1.25rem;
    white-space: nowrap;
  }

  .figure.muted {
    color: var(--muted);
    font-weight: 500;
  }
}

@container (min-width: 28rem) {
  .tiles.price-tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));

    .tile {
      flex-direction: column;
      align-items: stretch;
      gap: 0.25rem;
    }

    dd {
      align-items: flex-start;
      text-align: start;
    }

    .figure {
      font-size: 1.375rem;
    }
  }
}

/* The size input with its system beside it, same height, one row. */
.size-row {
  display: flex;
  gap: 0.5rem;

  input {
    flex: 1 1 5rem;
    min-inline-size: 0;
  }

  select {
    flex: 0 1 auto;
    inline-size: auto;
    max-inline-size: 55%;
  }
}

/* Short button labels stay on one line beside their icon; inside a result card a long label wraps
   rather than run past the card's edge. */
button,
.card-actions .button {
  white-space: nowrap;
}

.grid .card form button {
  white-space: normal;
  max-inline-size: 100%;
  text-align: center;
}

.searchbar .row {
  input {
    flex: 1 1 auto;
    min-inline-size: 0;
  }

  button {
    flex: none;
  }
}

/* v1.5.2 ---------------------------------------------------------------------------------- */

/* A button that is only an icon (Admin in the header, search on the vault). Its name is in
   aria-label; the target stays 44 px. */
.button.icon-only,
button.icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  inline-size: 44px;
  block-size: 44px;
  min-block-size: 44px;
  padding: 0;
  border-radius: 22px;

  svg {
    inline-size: 22px;
    block-size: 22px;
  }
}

.header-actions .button.icon-only {
  padding: 0;
}

/* Vault heading with the search button beside it. */
.page-head .title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-inline-size: 0;

  h1 {
    overflow-wrap: anywhere;
  }
}

/* Search opens as a popover from the magnifying glass and floats at the top of the screen.
   Only the box is styled here: the browser shows and hides it, so no display rule. */
.search-pop {
  position: fixed;
  inset: calc(env(safe-area-inset-top, 0px) + 0.75rem) 0.75rem auto;
  inline-size: auto;
  max-inline-size: 36rem;
  margin: 0 auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.35);

  .searchbar {
    margin: 0;
  }

  input[type='search'] {
    background: var(--bg);
  }
}

.search-pop::backdrop {
  background: rgb(0 0 0 / 0.35);
}

/* Without popover (before iOS 17) the field shows in place, as before v1.5.2, and the open and
   close buttons, which would do nothing, are hidden. */
@supports not selector(:popover-open) {
  .search-open,
  .search-pop button[popovertargetaction] {
    display: none;
  }

  .search-pop {
    position: static;
    margin: 0 0 1rem;
    padding: 0;
    border: 0;
    background: none;
    box-shadow: none;
  }
}

/* Look: three buttons, one tap saves and redraws (v1.5.2; it was radios plus Save). */
.look {
  .segments button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    min-block-size: 44px;
    padding: 0.25rem 0.5rem;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--ink-2);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: normal;
    text-align: center;
    cursor: pointer;
  }

  .segments button:hover {
    background: var(--surface-2);
  }

  .segments button[aria-pressed='true'] {
    background: var(--ink);
    color: var(--bg);
    font-weight: 600;
  }

  .segments svg {
    inline-size: 18px;
    block-size: 18px;
    flex: none;
  }
}

/* Profile spacing at 390 portrait (v1.5.2): a hint under a control gets its own line and a
   gap, panels breathe a little, and the segment labels stay on one line where they fit. */
fieldset > .hint,
.look > .hint {
  display: block;
  margin-block-start: 0.5rem;
}

.look > .hint {
  margin-block-end: 0;
}

.narrow > .panel + .panel {
  margin-block-start: 1.25rem;
}

.panel > h2:first-child {
  margin-block-end: 1rem;
}

.signed-in {
  margin-block-end: 1.25rem;
}

/* Item 18 (v1.5.2): Save settings, Change email and Change password are normal-size buttons
   like Share and Edit, not stretched across the panel by the form's column. */
.narrow .panel .stack > button[type='submit'] {
  align-self: flex-start;
  margin-block-start: 0.25rem;
}

.segments .choice label {
  line-height: 1.25;
}

@media (forced-colors: active) {
  .look .segments button[aria-pressed='true'] {
    outline: 2px solid CanvasText;
  }
}

/* Wear history on the pair page. */
.wears {
  margin-block: 1rem;

  .wear-summary {
    margin-block: 0 0.75rem;
    font-weight: 600;
  }

  .wear-form {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.75rem;
  }

  .wear-form .field {
    flex: 1 1 10rem;
  }

  .wear-list {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
    border-block-start: 1px solid var(--line-soft);
  }

  .wear-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-block-size: 44px;
    border-block-end: 1px solid var(--line-soft);
  }

  .wear-list form {
    margin: 0;
  }

  .wear-list button.link {
    min-block-size: 44px;
    padding-inline: 0.5rem;
  }
}

/* Wishlist cards: the card's two actions side by side under its details. */
.card .card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block-start: 0.5rem;

  form {
    margin: 0;
  }

  button,
  .button {
    min-block-size: 44px;
    padding-inline: 0.875rem;
    font-size: 0.9375rem;
  }
}

.section-label {
  font-family: inherit;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-block: 1.25rem 0.375rem;
}

/* Stats. Gain and loss text always carries its + or - sign; colour only adds to it. */
.gain {
  color: var(--gain);
  font-weight: 600;
}

.loss {
  color: var(--error);
  font-weight: 600;
}

/* Plain panels for the account pages (sign in, set up, invite, profile, admin). */
.panel {
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  margin-block-end: 1rem;

  > h2:first-child {
    margin-block-start: 0;
  }

  input:not([type='radio'], [type='checkbox'], [type='file']) {
    background: var(--bg);
  }
}

.auth {
  max-inline-size: 28rem;
  margin: clamp(1rem, 8dvh, 4rem) auto 0;

  .brand-lockup {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-block-end: 1.5rem;
    text-align: center;
  }

  .brand-lockup .mark {
    inline-size: 4.75rem;
    block-size: 4.75rem;
  }

  .brand-lockup .wordmark {
    font-size: 1.625rem;
  }

  h1 {
    text-align: center;
    font-size: 1.5rem;
  }

  button[type='submit'] {
    inline-size: 100%;
  }
}

/* Data tables (responsive-table): the wrapper scrolls and is the container the
   stacked layout queries, so a narrow screen gets one card per row. */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(40rem, 80dvh);
  container-type: inline-size;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

/* On a phone the rows stack into cards and the page itself scrolls: a capped box
   would hide later accounts' fields behind a scroll inside a scroll (v1.7.0). */
@media (width < 40rem) {
  .table-wrapper {
    max-block-size: none;
  }
}

table.data {
  border-collapse: separate;
  border-spacing: 0;
  inline-size: 100%;
  font-variant-numeric: tabular-nums;

  caption {
    text-align: start;
    padding: 0.875rem 1rem 0.25rem;
    color: var(--muted);
  }

  th,
  td {
    padding: 0.625rem 1rem;
    text-align: start;
    border-block-end: 1px solid var(--line);
    vertical-align: top;
  }

  .num {
    text-align: end;
    white-space: nowrap;
  }

  thead {
    position: sticky;
    inset-block-start: 0;
    z-index: 1;
  }

  thead th {
    background: var(--surface);
    color: var(--muted);
    font-size: 0.8125rem;
    font-weight: 500;
  }

  tbody th {
    position: sticky;
    inset-inline-start: 0;
    background: var(--surface);
    font-weight: 600;
  }

  .meta {
    display: block;
    color: var(--muted);
    font-weight: 400;
    font-size: 0.875rem;
  }
}

@container (width < 34rem) {
  table.data,
  table.data thead,
  table.data tbody,
  table.data tr,
  table.data th,
  table.data td {
    display: block;
  }

  table.data thead {
    display: none;
  }

  table.data caption {
    display: block;
  }

  table.data tr {
    margin: 0.75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
  }

  table.data tbody th {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    background: var(--surface-2);
  }

  table.data td {
    border-block-end: 0;
  }

  table.data td.num,
  table.data td[data-label] {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    text-align: end;
  }

  /* The label is the cell's column heading (data-label, set in views.js), so
     "Paid (CAD)" and "Market value (CAD)" keep their currency. */
  table.data td[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    text-align: start;
  }
}

/* Account pages (admin, profile). */
.visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

form.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;

  input {
    flex: 1 1 10rem;
    inline-size: auto;
  }
}

.invites {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;

  li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--line);
  }
}

code {
  overflow-wrap: anywhere;
  font-size: 0.9375rem;
  color: var(--ink);
}

.summary[role='status'] code {
  display: block;
  padding: 0.75rem;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--line);
}

div.summary[role='status'],
p.summary.notice {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  background: var(--accent-tint);
  border: 1px solid var(--notice-edge);
  color: var(--ink);
}

/* Share cards (M8): the canvas preview beside its controls when there's room, above them on a
   phone. The canvas keeps its 4:5 or 9:16 shape from its own width and height attributes. */
.share {
  display: grid;
  /* minmax(0, 1fr), not the implicit auto track: a select sizes to its longest option, and a
     long pair name would otherwise make the whole page wider than a phone (v1.4.1). */
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;

  canvas {
    display: block;
    inline-size: 100%;
    block-size: auto;
    max-block-size: 70svh;
    object-fit: contain;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
  }

  &[hidden] {
    display: none;
  }

  &[aria-busy='true'] canvas {
    opacity: 0.6;
  }

  .actions .button[aria-disabled='true'] {
    opacity: 0.5;
    pointer-events: none;
  }

  input[type='checkbox'][switch] {
    accent-color: var(--accent);
    cursor: pointer;
  }
}

@media (min-width: 48rem) {
  .share {
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem);
  }
}

@media (prefers-reduced-motion: no-preference) {
  a,
  button,
  .button {
    transition: background-color 0.15s, color 0.15s;
  }
}

@media (forced-colors: active) {
  .segments .choice input:checked + label {
    outline: 2px solid CanvasText;
  }
}

/* v1.6.0 ---------------------------------------------------------------------------------- */

/* No small all-caps labels (house rule: no eyebrows). The stat strip, the figure tiles, the
   card's brand line, the corner pill, the pair page's brand line and section labels read in
   normal case. The landscape strip keeps its own lowercase ("4 pairs · 2 deadstock"). */
.stat-strip dt,
.tiles dt {
  font-size: 0.8125rem;
  letter-spacing: normal;
  text-transform: none;
}

.card .brand {
  font-size: 0.75rem;
  letter-spacing: normal;
  text-transform: none;
}

.badge {
  font-size: 0.6875rem;
  letter-spacing: normal;
  text-transform: none;
}

.title-block .kicker {
  font-size: 0.875rem;
  letter-spacing: normal;
  text-transform: none;
}

.section-label {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
}

@media (orientation: landscape) and (max-height: 32rem) {
  .stat-strip dt {
    font-size: inherit;
    text-transform: lowercase;
  }
}

/* Item 19: the heading row runs the full width, so the search button sits at its right end.
   A phone on its side keeps the button beside the heading (the figures share that line). */
@media not ((orientation: landscape) and (max-height: 32rem)) {
  .page-head .title-row {
    flex: 1 1 100%;
    justify-content: space-between;
  }
}

/* Item 23: brand chips on the left, the pairs-per-row buttons on the right. */
.vault-tools {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-block-end: 1.25rem;

  nav {
    flex: 1 1 auto;
    min-inline-size: 0;
  }

  .chips {
    margin: 0;
    padding: 0;
  }
}

.layout-pick {
  flex: none;
  margin-inline-start: auto;

  .segments {
    display: flex;
    gap: 0.125rem;
    padding: 0.1875rem;
  }

  button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 40px;
    block-size: 40px;
    min-block-size: 40px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--muted);
  }

  button:hover {
    background: var(--surface-2);
    color: var(--ink);
  }

  button[aria-pressed='true'] {
    background: var(--ink);
    color: var(--bg);
  }

  svg {
    inline-size: 20px;
    block-size: 20px;
  }
}

@media (forced-colors: active) {
  .layout-pick button[aria-pressed='true'] {
    outline: 2px solid CanvasText;
  }
}

/* The vault grid: 1, 2 or 3 per row on a phone held upright. Wider screens and a phone on
   its side scale the same choice: half, the same, or more than the 2-per-row look. */
.vault-grid[data-cols='1'] {
  grid-template-columns: minmax(0, 1fr);
}

.vault-grid[data-cols='3'] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

@media (min-width: 48rem) {
  .vault-grid[data-cols='1'] {
    grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  }

  .vault-grid[data-cols='3'] {
    grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
  }
}

@media (orientation: landscape) and (max-height: 32rem) {
  .vault-grid[data-cols='1'] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vault-grid[data-cols='3'] {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

/* One per row: a wide card, photo on the left, the words beside it. */
.vault-grid[data-cols='1'] .card > a {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  grid-template-rows: auto auto 1fr;
  column-gap: 0.875rem;
  row-gap: 0.25rem;
  align-items: start;

  .card-photo {
    grid-row: 1 / span 3;
  }

  .photo {
    aspect-ratio: 1;
  }

  .brand {
    padding-block-start: 0.25rem;
  }

  .name {
    font-size: 1rem;
    white-space: normal;
  }

  .meta {
    font-size: 0.8125rem;
  }
}

/* Three per row: a tighter card so the photo keeps most of the width. */
.vault-grid[data-cols='3'] .card {
  padding: 0.5rem;

  > a {
    gap: 0.375rem;
  }

  .name {
    font-size: 0.8125rem;
  }

  .meta {
    font-size: 0.6875rem;
  }

  .badge {
    inset-block-start: 0.3125rem;
    inset-inline-start: 0.3125rem;
    padding: 0.125rem 0.3125rem;
    font-size: 0.625rem;
  }
}

/* The meta line now sits inside the card's link: keep it muted, not link-coloured. */
.card > a .meta {
  color: var(--muted);
}

/* Item 26: Market alone when no price paid is set. */
@container (min-width: 28rem) {
  .tiles.price-tiles.single {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Items 27 and 28: the wear form's date box keeps inside its panel (iOS gives a date input a
   wide minimum of its own), and the history is a plain table, one row per wear. */
input[type='date'] {
  display: block;
  min-inline-size: 0;
  max-inline-size: 100%;
  -webkit-appearance: none;
  appearance: none;
  text-align: start;
}

input[type='date']::-webkit-date-and-time-value {
  text-align: start;
}

.wears {
  .wear-form .field {
    flex: 1 1 9rem;
    min-inline-size: 0;
  }

  .wear-form button {
    flex: 0 0 auto;
  }

  .wear-table {
    inline-size: 100%;
    margin-block-start: 1rem;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;

    th,
    td {
      padding: 0 0.25rem;
      text-align: start;
      border-block-end: 1px solid var(--line-soft);
    }

    thead th {
      padding-block: 0.5rem;
      font-size: 0.8125rem;
      font-weight: 500;
      color: var(--muted);
    }

    td {
      block-size: 44px;
    }

    .end {
      text-align: end;
    }

    form {
      margin: 0;
    }

    button.link {
      min-block-size: 44px;
      padding-inline: 0.5rem;
    }
  }
}

/* Item 29: buttons that sit together share one width. A group of two or more becomes an even
   grid: side by side while each fits, stacked full width when they don't. A lone button keeps
   its own width. Where :has() is missing the group stays as it was (a wrapping row). */
.actions:has(> :is(.button, button, form) ~ :is(.button, button, form)) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr));
  max-inline-size: 32rem;

  > .button,
  > button,
  > form > button {
    inline-size: 100%;
  }

  > form {
    margin: 0;
  }

  > .span-all {
    grid-column: 1 / -1;
  }
}

/* Long labels ("Download the collection (CSV)") need more room before they sit side by side. */
.actions.long-labels:has(> :is(.button, button) ~ :is(.button, button)) {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  max-inline-size: 36rem;
}

/* Remove this pair, under its divider, spans the same width as the button row above it. */
.actions.remove-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-inline-size: 32rem;

  > .button {
    inline-size: 100%;
  }
}

/* Log a wear: the date box and the button share one width, stacked, on a phone; side by
   side once the panel has room for both. */
.wears .wear-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
  max-inline-size: 32rem;

  .field {
    margin: 0;
  }

  button {
    inline-size: 100%;
  }
}

/* Wishlist cards: Got it and Remove stack to the card's full width, one size. */
.card .card-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr));

  form > button,
  > .button {
    inline-size: 100%;
  }
}

/* Lookup result cards: the one button fills the card, the same in every card, its label on
   one line ("Add to wishlist" wrapped at 390). */
.grid .card > form > button {
  inline-size: 100%;
  gap: 0.375rem;
  padding-inline: 0.5rem;
  font-size: 0.875rem;
  white-space: nowrap;

  svg {
    inline-size: 1.125rem;
    block-size: 1.125rem;
  }
}

/* The wishlist card's two buttons, the same size and type as the lookup card's. */
.card .card-actions {
  button,
  .button {
    gap: 0.375rem;
    padding-inline: 0.5rem;
    font-size: 0.875rem;
  }
}

/* v1.7.0 (M10): lookups used this month, the admin's limit boxes and an account's facts. */
.usage {
  margin-block: 0.75rem;
  font-variant-numeric: tabular-nums;

  .label {
    font-weight: 600;
  }

  &.at-limit {
    color: var(--error);
  }
}

form.limit {
  flex-wrap: nowrap;
  gap: 0.5rem;

  input[type="number"] {
    inline-size: 6rem;
    min-inline-size: 0;
  }
}

.facts {
  display: grid;
  gap: 0.5rem;
  margin-block: 1rem;

  > div {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    border-block-end: 1px solid var(--line);
    padding-block-end: 0.5rem;
  }

  dd {
    margin: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
  }
}
