/* Borrow — mobile first. Warm paper, ink and a festival-rust accent.
   Every text colour meets WCAG AA (4.5:1) and form edges 3:1, in both
   themes. Type is Atkinson Hyperlegible, built for easy reading. */

:root {
  --paper: #f6f1e9;
  --card: #fffdf8;
  --ink: #1a1612;
  --muted: #5c5247;
  --line: #e4dacb;
  --field: #8f8274;
  --accent: #b13d17;
  --accent-ink: #ffffff;
  --accent-soft: #f8e1d6;
  --ok: #1d6b43;
  --ok-soft: #dcefe3;
  --out: #7a4a05;
  --out-soft: #f8e7c6;
  --bad: #a61f17;
  --bad-soft: #fbdcd8;
  --on-bad: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 0 rgb(31 26 20 / 6%), 0 6px 18px -10px rgb(31 26 20 / 25%);
  --font: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --tabs-height: 64px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12100e;
    --card: #1d1a17;
    --ink: #f6f1e9;
    --muted: #bdb2a5;
    --line: #36302a;
    --field: #7d7166;
    --accent: #ff8f63;
    --accent-ink: #1a0f0a;
    --accent-soft: #4a2718;
    --ok: #86d9a8;
    --ok-soft: #16301f;
    --out: #f5c46e;
    --out-soft: #3a2b10;
    --bad: #ff9b90;
    --bad-soft: #47201c;
    --on-bad: #1a0f0a;
    --shadow: 0 1px 0 rgb(0 0 0 / 30%);
  }
}

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

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  /* No grey flash on tap; our own :active states give feedback instead. */
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  /* Stop the page bouncing behind fixed bars and sheets. */
  overscroll-behavior-y: none;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.55 var(--font);
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 640px;
  margin: 0 auto;
  /* Clear of the notch / status bar when opened from the home screen. */
  padding: calc(16px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(var(--tabs-height) + 32px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  outline: none;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 1.75rem;
  font-weight: 800;
}

h2 {
  font-size: 1.15rem;
  font-weight: 750;
}

h3 {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

p {
  margin: 0;
}

a {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentcolor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.2em;
}

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

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.row > * {
  flex: 1 1 0;
  min-width: 0;
}

.row--wrap {
  flex-wrap: wrap;
}

.row--wrap > * {
  flex: 1 1 auto;
  white-space: nowrap;
}

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

.small {
  font-size: 0.875rem;
}

.prewrap {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.loading,
.empty {
  color: var(--muted);
  padding: 24px 0;
  text-align: center;
}

.error-box {
  background: var(--bad-soft);
  color: var(--bad);
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 600;
}

.notice {
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 650;
}

.notice--overdue {
  width: 100%;
  border: 0;
  background: var(--bad-soft);
  color: var(--bad);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 2px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.button:disabled {
  opacity: 0.55;
  cursor: progress;
}

.button--primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.button--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--field);
}

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

.button--wide {
  width: 100%;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-left: -10px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.page-header__actions .icon-button {
  margin-left: 0;
}

/* Forms */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label,
.choices legend {
  font-weight: 700;
  font-size: 0.95rem;
}

input:not([type="radio"]),
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1.5px solid var(--field);
  border-radius: 12px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
}

/* Lighter than typed text so an empty box doesn't look filled in, but still readable. */
::placeholder {
  color: var(--muted);
  opacity: 0.75;
}

input[type="file"] {
  padding: 10px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: none;
}

[aria-invalid="true"] {
  border-color: var(--bad) !important;
}

.field__hint {
  color: var(--muted);
  font-size: 0.85rem;
}

.field__error {
  color: var(--bad);
  font-size: 0.875rem;
  font-weight: 650;
}

.code-input {
  font: 700 1.75rem/1 var(--mono);
  letter-spacing: 0.4em;
  text-align: center;
}

.choices {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.choices legend {
  margin-bottom: 8px;
  padding: 0;
}

.choice {
  position: relative;
}

.choice input {
  position: absolute;
  opacity: 0;
  inset: 0;
}

.choice span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 14px;
  border: 1.5px solid var(--field);
  border-radius: 999px;
  background: var(--card);
  font-weight: 600;
  font-size: 0.95rem;
}

.choice input:checked + span {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

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

/* Welcome (sign in / join) */

.welcome {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 12vh;
}


.welcome h1 {
  margin-bottom: 8px;
  font-size: 2.4rem;
}

.welcome__sent {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.welcome__sent strong {
  color: var(--ink);
}

.welcome input:not([type="radio"]) {
  min-height: 56px;
  font-size: 1.1rem;
}

.welcome .code-input {
  min-height: 72px;
}

.welcome__foot {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

/* Browse */

.browse {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.browse__header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 8px;
}

.browse__summary {
  font-weight: 600;
}

/* Search and categories stay put while the list scrolls under them. */
.browse__tools {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 -16px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
}

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

.search .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  translate: 0 -50%;
  color: var(--muted);
}

.search input {
  padding-left: 44px;
  border-radius: 999px;
}

.hero .icon {
  width: 40px;
  height: 40px;
  stroke-width: 1.4;
}

/* Luggage-tag status */

/* Page header */

.page-header {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 48px;
}

.page-header h1 {
  flex: 1;
  min-width: 0;
  font-size: 1.5rem;
  overflow-wrap: anywhere;
}

.page-header__actions {
  display: flex;
  margin-right: -10px;
}

/* Item */

.hero {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  font-size: 3rem;
}

.instructions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 12px;
  border-left: 3px solid var(--line);
}

.access {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--paper);
}

.access__details {
  font: 700 1.15rem/1.4 var(--mono);
}

.access__note {
  font-size: 0.8rem;
  opacity: 0.75;
}

.panel {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.panel--accent {
  background: var(--accent-soft);
  box-shadow: none;
}

/* Booking lists */

.bookings {
  list-style: none;
  margin: 0;
  padding: 0;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.bookings li + li {
  border-top: 1px solid var(--line);
}

.bookings a {
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  text-decoration: none;
}

.bookings__dates {
  font-weight: 750;
}

/* Booking ticket */

.ticket {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  border-top: 6px solid var(--line);
}

.ticket--confirmed,
.ticket--returned {
  border-top-color: var(--ok);
}

.ticket--requested,
.ticket--picked_up {
  border-top-color: var(--out);
}

.ticket--overdue,
.ticket--declined {
  border-top-color: var(--bad);
}

.ticket__status {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.ticket__dates {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* Tab bar */

.tabs {
  position: fixed;
  inset: auto 0 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.tabs[hidden] {
  display: none;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 52px;
  justify-content: center;
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
}

.tab .icon {
  width: 24px;
  height: 24px;
}

.tab[aria-current="page"] {
  color: var(--accent);
}

/* Toasts */

.toasts {
  position: fixed;
  inset: auto 16px calc(var(--tabs-height) + 16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: 480px;
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 650;
  box-shadow: var(--shadow);
}

@media (min-width: 720px) {
  .tabs {
    inset: 0 auto auto 50%;
    translate: -50% 0;
    width: 360px;
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px;
  }

  main {
    padding-top: 96px;
  }

  .toasts {
    bottom: 24px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .tile__photo,
  .button {
    transition: transform 120ms ease;
  }

  .tile:active .tile__photo,
  .button:active {
    transform: scale(0.98);
  }
}

/* ── Category tints: one hue per category, for icons, chips and placeholders ── */

.cat {
  --h: 20;
  background: hsl(var(--h) 70% 92%);
  color: hsl(var(--h) 60% 30%);
}

.cat--sound { --h: 14; }
.cat--power { --h: 42; }
.cat--lighting { --h: 52; }
.cat--shelter { --h: 150; }
.cat--camp { --h: 26; }
.cat--kitchen { --h: 195; }
.cat--tools { --h: 215; }
.cat--transport { --h: 265; }
.cat--decor { --h: 330; }
.cat--other { --h: 35; }

@media (prefers-color-scheme: dark) {
  .cat {
    background: hsl(var(--h) 28% 18%);
    color: hsl(var(--h) 70% 76%);
  }
}

/* ── Chips ── */

.chips {
  display: flex;
  gap: 8px;
  margin: 0 -16px;
  padding: 2px 16px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 16px;
  scrollbar-width: none;
}

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

.chip {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px 0 10px;
  border: 1.5px solid var(--field);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  scroll-snap-align: start;
}

.chip[aria-checked="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

/* ── Loading skeletons ── */

.bone {
  display: block;
  width: 70%;
  height: 0.9em;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--line) 25%, color-mix(in srgb, var(--line) 45%, var(--card)) 50%, var(--line) 75%);
  background-size: 300% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.bone--title { width: 55%; height: 1.1em; }
.bone--tag { width: 30%; height: 1.2em; border-radius: 999px; }
.bone--heading { width: 60%; height: 1.75rem; }
.bone--block { width: 100%; height: 120px; border-radius: var(--radius); }
.bone--short { width: 40%; }

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}

/* ── Empty shed ── */

.empty-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 32px 20px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  text-align: center;
}

.empty-hero__title {
  font-size: 1.2rem;
  font-weight: 800;
}

/* ── Brand mark ── */

.brand {
  display: block;
  width: 64px;
  height: 64px;
  filter: drop-shadow(0 8px 14px rgb(177 61 23 / 35%));
}

/* ── Item page ── */

.item__description {
  font-size: 1.05rem;
}

details.howto {
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

details.howto > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

details.howto > summary::-webkit-details-marker {
  display: none;
}

details.howto > summary::after {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 2px solid currentcolor;
  border-bottom: 2px solid currentcolor;
  rotate: 45deg;
  translate: 0 -3px;
  transition: rotate 150ms ease;
}

details.howto[open] > summary::after {
  rotate: 225deg;
  translate: 0 3px;
}

details.howto[open] {
  padding-bottom: 16px;
}

details.howto > :not(summary) {
  margin: 12px 16px 0;
}

/* Book button that follows you down the page until the form is in view. */
.cta-bar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabs-height) + 12px + env(safe-area-inset-bottom));
  z-index: 8;
  width: min(100% - 32px, 608px);
  translate: -50% 0;
  transition: opacity 160ms ease, translate 160ms ease;
}

.cta-bar .button {
  box-shadow: 0 10px 24px -10px rgb(0 0 0 / 45%);
}

/* Room at the bottom of item pages so the borrow bar never covers content. */
.item:has(.cta-bar) {
  padding-bottom: 72px;
}

/* ── Availability calendar ── */

.cal {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cal__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal__weekdays span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

.cal__day {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-height: 40px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.cal__month {
  position: absolute;
  top: 2px;
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.cal__day--past {
  background: transparent;
  color: var(--muted);
  opacity: 0.55;
  cursor: default;
}

.cal__day--booked {
  background: repeating-linear-gradient(-45deg, var(--bad-soft) 0 5px, transparent 5px 10px);
  color: var(--bad);
  text-decoration: line-through;
  cursor: not-allowed;
}

.cal__day--requested::after {
  content: "";
  position: absolute;
  bottom: 5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--out);
}

.cal__day--middle {
  background: var(--accent-soft);
  border-radius: 4px;
}

.cal__day--start,
.cal__day--end,
.cal__day--single {
  background: var(--accent);
  color: var(--accent-ink);
}

.cal__day--start { border-radius: 10px 4px 4px 10px; }
.cal__day--end { border-radius: 4px 10px 10px 4px; }

.cal__day--start .cal__month,
.cal__day--end .cal__month,
.cal__day--single .cal__month {
  color: inherit;
}

.cal__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.cal__key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cal__key::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--paper);
  border: 1px solid var(--line);
}

.cal__key--requested::before {
  background: radial-gradient(circle at 50% 75%, var(--out) 2.5px, var(--paper) 3px);
}

.cal__key--booked::before {
  background: repeating-linear-gradient(-45deg, var(--bad-soft) 0 3px, transparent 3px 6px);
  border-color: var(--bad-soft);
}

.booking-form__chosen {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.booking-form__manual summary {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
  cursor: pointer;
}

.booking-form__manual[open] summary {
  margin-bottom: 10px;
}

/* ── Booking timeline and next step ── */

.timeline {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline__step {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.timeline__step + .timeline__step::before {
  content: "";
  position: absolute;
  top: 7px;
  right: 50%;
  width: 100%;
  height: 2px;
  background: var(--line);
}

.timeline__dot {
  position: relative;
  z-index: 1;
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
}

.timeline__step--done {
  color: var(--ok);
}

.timeline__step--done .timeline__dot {
  border-color: var(--ok);
  background: var(--ok);
}

.timeline__step--done + .timeline__step::before {
  background: var(--ok);
}

.timeline__step--current {
  color: var(--ink);
}

.timeline__step--current .timeline__dot {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.timeline__step--stopped {
  color: var(--bad);
}

.timeline__step--stopped .timeline__dot {
  border-color: var(--bad);
  background: var(--bad);
}

.next-step {
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  border-radius: 4px 12px 12px 4px;
  background: var(--card);
  font-size: 1.02rem;
  font-weight: 600;
}

/* ── Add/edit form ── */

hr {
  width: 100%;
  margin: 4px 0;
  border: 0;
  border-top: 2px dashed var(--line);
}

.reveal {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reveal[hidden] {
  display: none;
}

.photo-pick {
  position: relative;
  border-color: var(--field) !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 120px;
  overflow: hidden;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.photo-pick:focus-within {
  border-color: var(--accent);
}

.photo-pick__preview .icon {
  width: 40px;
  height: 40px;
}

.photo-pick__preview:has(img) {
  position: absolute;
  inset: 0;
}

.photo-pick__preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-pick__preview:has(img) + .photo-pick__caption {
  position: absolute;
  bottom: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgb(0 0 0 / 60%);
  color: #fff;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── Tab bar extras ── */

.tab {
  position: relative;
}

.tab--new .icon {
  box-sizing: content-box;
  padding: 4px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  stroke-width: 2.2;
}

.tab--new[aria-current="page"] {
  color: var(--ink);
}

.tab__badge {
  position: absolute;
  top: 4px;
  left: calc(50% + 6px);
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border: 2px solid var(--paper);
  border-radius: 999px;
  background: var(--bad);
  color: var(--on-bad);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
}

@media (min-width: 720px) {
  .browse__tools {
    top: 72px;
  }

  .cta-bar {
    bottom: 24px;
  }

  .tab {
    flex-direction: row;
    gap: 6px;
    min-height: 40px;
  }

  .tab .icon {
    width: 20px;
    height: 20px;
  }

  .tab--new .icon {
    padding: 2px 8px;
  }

  .tab__badge {
    top: 2px;
    left: auto;
    right: 6px;
  }
}

/* ── Motion ── */

@media (prefers-reduced-motion: no-preference) {
  main > section {
    animation: rise 180ms ease-out;
  }

  .toast {
    animation: rise 200ms ease-out;
  }
}

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

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.bookings__row--overdue {
  border-left: 4px solid var(--bad);
}

.bookings__row--overdue span:last-child {
  color: var(--bad);
  font-weight: 700;
}

/* ── Bigger targets for the main actions ── */

.button--big {
  min-height: 56px;
  font-size: 1.1rem;
}

.input--big {
  font-size: 1.15rem;
  font-weight: 650;
}

.link-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* ── Bottom sheet ── */

body.sheet-open {
  overflow: hidden;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgb(20 15 10 / 45%);
}

.sheet__panel {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--card);
  box-shadow: 0 -10px 40px -10px rgb(0 0 0 / 40%);
  outline: none;
}

.sheet__grip {
  display: block;
  width: 40px;
  height: 5px;
  margin: 0 auto 6px;
  border-radius: 999px;
  background: var(--line);
}

.sheet__close {
  position: absolute;
  top: 8px;
  right: 8px;
  margin: 0;
}

.sheet__body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sheet__title {
  padding-right: 44px;
  font-size: 1.3rem;
}

.sheet .cal__day {
  min-height: 38px;
}

.sheet textarea {
  margin-top: 4px;
}

.done {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 0 4px;
  text-align: center;
}

.done__tick {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 6px;
  border-radius: 50%;
  background: var(--ok-soft);
  color: var(--ok);
}

.done__tick .icon {
  width: 34px;
  height: 34px;
  stroke-width: 2.4;
}

@media (min-width: 720px) {
  .sheet {
    align-items: center;
  }

  .sheet__panel {
    border-radius: 22px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .sheet {
    animation: fade 160ms ease-out;
  }

  .sheet__panel {
    animation: slide-up 220ms cubic-bezier(0.2, 0.9, 0.3, 1);
  }
}

@keyframes fade {
  from { opacity: 0; }
}

@keyframes slide-up {
  from { transform: translateY(40px); opacity: 0.6; }
}

/* ── Category grid ── */

.cat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
}

.cat-grid legend {
  margin-bottom: 8px;
  padding: 0;
  font-weight: 700;
  font-size: 0.95rem;
}

.cat-grid__option {
  position: relative;
  background: var(--card);
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 64px;
  padding: 6px 2px;
  border: 2px solid transparent;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.cat-grid__option input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.cat-grid__option .icon {
  width: 24px;
  height: 24px;
}

/* Neutral until picked, then the category's own colour. */
.cat-grid__option:has(input:checked) {
  border-color: currentcolor;
  background: hsl(var(--h) 70% 92%);
  color: hsl(var(--h) 60% 30%);
}

@media (prefers-color-scheme: dark) {
  .cat-grid__option:has(input:checked) {
    background: hsl(var(--h) 28% 18%);
    color: hsl(var(--h) 70% 76%);
  }
}

.cat-grid__option:has(input:focus-visible) {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.cat-grid .field__error {
  grid-column: 1 / -1;
}

/* ── Folded sections in the add form ── */

.summary-card {
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.summary-card > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 8px 16px;
  cursor: pointer;
  list-style: none;
}

.summary-card > summary::-webkit-details-marker {
  display: none;
}

.summary-card > summary::after {
  content: "";
  flex: none;
  width: 9px;
  height: 9px;
  margin-left: auto;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  rotate: 45deg;
  translate: 0 -3px;
  transition: rotate 150ms ease;
}

.summary-card[open] > summary::after {
  rotate: 225deg;
  translate: 0 3px;
}

.summary-card__label {
  flex: none;
  font-weight: 750;
}

.summary-card__value {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-card[open] {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-bottom: 16px;
}

.summary-card[open] > :not(summary) {
  margin: 0 16px;
}

/* The save button stays reachable at the bottom of the add/edit form. */
.item-form {
  padding-bottom: 72px;
}

.summary-card[open] > .choices,
.summary-card[open] > .reveal > .choices {
  margin-top: 10px;
}

/* ── Photo tiles (browse and My gear) ── */

.hero {
  display: grid;
  place-items: center;
  overflow: hidden;
}

.hero img,
.tile__photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tiles > .empty-hero,
.tiles > .empty,
.tiles > .error-box {
  grid-column: 1 / -1;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
}

.tile__frame {
  position: relative;
  margin-bottom: 6px;
}

.tile__photo {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius);
}

.tile__photo .icon {
  width: 40px;
  height: 40px;
  stroke-width: 1.4;
}

.tile--overdue .tile__photo {
  outline: 3px solid var(--bad);
  outline-offset: -3px;
}

.tile__title {
  font-weight: 750;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.tile__meta {
  color: var(--muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile--skeleton .tile__photo {
  background: var(--line);
}

.badge {
  position: absolute;
  left: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  padding: 3px 9px;
  overflow: hidden;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge--out {
  background: var(--out-soft);
  color: var(--out);
}

.badge--overdue {
  background: var(--bad);
  color: var(--on-bad);
}

.browse__header {
  flex-direction: row;
  align-items: baseline;
  gap: 10px;
}

.browse__count {
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 750;
}

.notice--overdue[aria-pressed="true"] {
  background: var(--bad);
  color: var(--on-bad);
}

@media (min-width: 560px) {
  .tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ── My stuff ── */

.requests {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.request {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.request__text {
  display: flex;
  flex-direction: column;
  text-decoration: none;
}

.request__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.request__actions .button {
  min-height: 44px;
}

.account {
  justify-content: center;
  border-top: 0;
}

/* ── Booking page ── */

.booking:has(.cta-bar) {
  padding-bottom: 72px;
}

.ticket .timeline {
  margin-top: 14px;
}

.ticket__note {
  margin-top: 6px;
  padding-left: 10px;
  border-left: 3px solid var(--line);
  color: var(--muted);
  font-style: italic;
}

.links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 24px;
}

.links .link-button {
  color: var(--muted);
}

.next-step--overdue {
  border-left-color: var(--bad);
  background: var(--bad-soft);
  color: var(--bad);
}

/* ── Add form: photo square beside the name ── */

.name-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
  align-items: start;
}

.name-row .photo-pick {
  height: 88px;
  gap: 2px;
  font-size: 0.8rem;
}

.name-row .photo-pick__preview .icon {
  width: 28px;
  height: 28px;
}

.name-row .input--big {
  min-height: 88px;
  font-size: 1.25rem;
}

.name-row .photo-pick__preview:has(img) + .photo-pick__caption {
  bottom: 6px;
  padding: 2px 8px;
  font-size: 0.78rem;
}

/* ── Item page: one short list of facts ── */

.info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.info li {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 4px 16px;
  font-weight: 650;
}

.info li + li {
  border-top: 1px solid var(--line);
}

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

.info__status--out {
  color: var(--out);
}

.info__status--overdue {
  background: var(--bad-soft);
  color: var(--bad);
}

.info__status .icon {
  color: inherit;
}

/* ── Phone feel ── */

/* Long-pressing buttons and tabs shouldn't select their text or pop a menu. */
button,
.button,
.tab,
.chip,
.choice,
.cat-grid__option,
.tile,
.cal__day {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

@media (max-width: 719px) {
  .browse__tools {
    top: env(safe-area-inset-top);
  }
}

.sheet__panel {
  padding-top: 0;
  overscroll-behavior: contain;
}

/* A wide, easy-to-grab handle: drag it down to close the sheet. */
.sheet__handle {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 28px;
  margin: 0 -16px 4px;
  touch-action: none;
  cursor: grab;
}

.sheet__handle .sheet__grip {
  margin: 0;
}

.sheet__panel {
  transition: transform 180ms ease;
}

/* ── Install card ── */

.install {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 44px 12px 12px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.install__icon {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 11px;
}

.install p {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

.install .icon {
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.15em;
}

.install .button {
  flex: none;
  min-height: 40px;
}

.install__close {
  position: absolute;
  top: 4px;
  right: 4px;
  margin: 0;
}

/* ── Offline notice ── */

/* Sits just above the tab bar, clear of headings, until the signal is back. */
.offline {
  position: fixed;
  bottom: calc(var(--tabs-height) + 12px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 30;
  width: max-content;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 8px 14px;
  translate: -50% 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: var(--shadow);
}
