/* GameCircle — "Spieltisch": warm paper and wood, serif titles, brick-red accent.
   Both colour schemes come from the same variables. The server sets
   <html data-theme="light|dark"> for an explicit choice and no attribute for "system". */

:root {
  color-scheme: light;
  --bg: #f4ede1;
  --card: #fffdf8;
  --ink: #3b2f22;
  --muted: #7a6650;
  --line: #d9cbb3;
  --accent: #a4462c;
  --accentink: #fff;
  --star: #c08a2e;
  --chip: #3b2f22;
  --chipink: #f4ede1;
  --shadow: rgba(59, 47, 34, .15);
  --serif: Georgia, 'Iowan Old Style', serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius: 12px;
  --tabbar: 64px;
  --barh: 58px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    color-scheme: dark;
    --bg: #1e1914;
    --card: #2a231c;
    --ink: #efe4d2;
    --muted: #a8957b;
    --line: #3d332a;
    --accent: #e0805f;
    --accentink: #1e1914;
    --star: #e0b05a;
    --chip: #efe4d2;
    --chipink: #1e1914;
    --shadow: rgba(0, 0, 0, .4);
  }
}

:root[data-theme=dark] {
  color-scheme: dark;
  --bg: #1e1914;
  --card: #2a231c;
  --ink: #efe4d2;
  --muted: #a8957b;
  --line: #3d332a;
  --accent: #e0805f;
  --accentink: #1e1914;
  --star: #e0b05a;
  --chip: #efe4d2;
  --chipink: #1e1914;
  --shadow: rgba(0, 0, 0, .4);
}

/* ---------- Base ---------- */

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

h1, h2, h3, .serif { font-family: var(--serif); }
h1 { font-size: 30px; line-height: 1.15; letter-spacing: -.01em; margin: 0 0 10px; }
h2 { font-size: 19px; line-height: 1.25; margin: 0 0 6px; }
p { margin: 0 0 12px; }

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

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

::selection { background: var(--accent); color: var(--accentink); }

[hidden] { display: none !important; }

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

.lead { color: var(--muted); font-size: 17px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 2px 7px var(--shadow);
}

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* ---------- Header ---------- */

/* The backdrop-filter makes .top the containing block of position:fixed
   descendants, so the tab bar (.tabs) must stay outside the header. */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.top-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: -3px auto -3px 0;
  color: var(--ink);
  text-decoration: none;
  font-size: 19px;
  font-weight: 700;
  white-space: nowrap;
}

.mark { width: 30px; height: 30px; flex: none; }
.mark-ring { fill: none; stroke: var(--accent); stroke-width: 36; }
.mark-meeple { fill: var(--ink); }

.prefs { display: flex; gap: 8px; flex: none; }

.toggle {
  display: flex;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
}

.toggle button {
  position: relative;
  appearance: none;
  border: 0;
  margin: 0;
  background: transparent;
  color: var(--muted);
  font: 600 13px/1 var(--sans);
  min-width: 40px;
  height: 36px;
  padding: 0 10px;
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
.toggle button:first-child { border-radius: 999px 0 0 999px; }
.toggle button:last-child { border-radius: 0 999px 999px 0; }
/* the pill stays 38 px tall, the tap area is 44 */
.toggle button::before { content: ""; position: absolute; inset: -4px 0; }

.toggle button:hover { color: var(--ink); }

/* ☀︎ renders much smaller than ☾ at the same size */
.toggle .theme-light { font-size: 18px; }
.toggle .theme-dark { font-size: 15px; }

.toggle button:focus-visible { outline-offset: -3px; }

/* The active colour-scheme button follows the attribute, so app.js only has to set it. */
.toggle button.on,
:root[data-theme=light] .theme-light,
:root[data-theme=dark] .theme-dark,
:root:not([data-theme]) .theme-light {
  background: var(--chip);
  color: var(--chipink);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-light { background: transparent; color: var(--muted); }
  :root:not([data-theme]) .theme-dark { background: var(--chip); color: var(--chipink); }
}

/* ---------- Navigation: bottom tab bar on the phone, in the header row on wide screens ---------- */

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  min-height: var(--tabbar);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px var(--shadow);
}

.tabs a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 48px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
}

.tabs a:hover { color: var(--ink); }
.tabs a[aria-current=page] { color: var(--accent); }

.ico {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.badge {
  position: absolute;
  top: 2px;
  left: calc(50% + 4px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accentink);
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

.has-tabs .wrap { padding-bottom: calc(var(--tabbar) + 40px + env(safe-area-inset-bottom)); }

/* From 920 px the nav sits in the header row. It stays a sibling of the
   header (whose backdrop-filter would capture position:fixed children) and is
   laid over the header's centre with its own fixed positioning. Below 920 px
   five labelled tabs do not fit between logo and switches. */
@media (min-width: 920px) {
  .top-inner { min-height: var(--barh); padding: env(safe-area-inset-top) 16px 0; }
  .brand { font-size: 21px; }
  .tabs {
    top: env(safe-area-inset-top);
    bottom: auto;
    z-index: 11;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2px;
    height: var(--barh);
    min-height: 0;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
    pointer-events: none; /* only the links take clicks, not the empty band */
  }
  .tabs a {
    pointer-events: auto;
    flex-direction: row;
    gap: 7px;
    min-height: 40px;
    padding: 0 12px;
    font-size: 14px;
  }
  .tabs a:hover { background: var(--card); }
  .tabs .ico { width: 20px; height: 20px; }
  .badge { position: static; margin-left: -2px; }
  .has-tabs .wrap { padding-bottom: 48px; }
  h1 { font-size: 36px; }
}

@media (max-width: 359px) {
  .brand span { display: none; }
}

/* ---------- Buttons, notices ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accentink);
  font: 600 16px/1.2 var(--sans);
  text-decoration: none;
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
}

.btn:hover { box-shadow: 0 3px 10px var(--shadow); }
.btn:active { transform: translateY(1px); }

.btn-apple { background: var(--ink); color: var(--bg); }
.btn-google { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-quiet { background: transparent; color: var(--muted); border-color: var(--line); min-height: 44px; }
.btn-quiet:hover { color: var(--ink); }

.logo { width: 20px; height: 20px; flex: none; fill: currentColor; }

.notice, .flash {
  background: var(--card);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 2px 7px var(--shadow);
  padding: 14px 16px;
  margin: 0 0 16px;
}

.notice h2 { font-size: 18px; margin-bottom: 4px; }
.notice p { margin: 0; }

.flash { max-width: 1008px; margin: 16px auto 0; }
@media (max-width: 1039px) { .flash { margin: 16px 16px 0; } }

/* ---------- Login ---------- */

.login { max-width: 420px; margin: 0 auto; padding-top: 8px; }
.login h1, .login .lead { text-align: center; }
.login .lead { margin-bottom: 24px; }

.fan { position: relative; width: 220px; height: 136px; margin: 4px auto 22px; }

.cover {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 80px;
  height: 106px;
  margin-left: -40px;
  border-radius: 7px;
  box-shadow: 0 6px 16px var(--shadow);
  transform-origin: 50% 120%;
  animation: deal .6s cubic-bezier(.2, .8, .3, 1) both;
}

/* a pale label band, like the title on a game box */
.cover::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 12px;
  height: 14px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .38);
}

.cover-1 { background: linear-gradient(135deg, #2f5d50, #8fb39a); --turn: -16deg; }
.cover-2 { background: linear-gradient(135deg, #c9a24a, #e8d8a8); --turn: 0deg; z-index: 1; animation-delay: .08s; }
.cover-3 { background: linear-gradient(135deg, #5b7fa6, #b5cbe0); --turn: 16deg; animation-delay: .16s; }
.cover-1, .cover-2, .cover-3 { transform: rotate(var(--turn)); }

@keyframes deal {
  from { transform: rotate(0deg) translateY(12px); opacity: 0; }
  to { transform: rotate(var(--turn)); opacity: 1; }
}

.signin { display: grid; gap: 12px; padding: 20px; }
.signin .btn { width: 100%; }
.signin .muted { margin: 0; text-align: center; }

.fine { margin: 4px 0 0; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- Waiting for a circle ---------- */

.waiting { max-width: 560px; margin: 0 auto; }

.shelf {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 240px;
  margin: 8px 0 24px;
}

.shelf span {
  aspect-ratio: 3 / 4;
  border: 2px dashed var(--line);
  border-radius: 8px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.steps {
  list-style: none;
  counter-reset: step;
  margin: 8px 0 24px;
  padding: 8px 20px;
}

.steps li {
  counter-increment: step;
  position: relative;
  padding: 10px 0 10px 42px;
}

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

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--chip);
  color: var(--chipink);
  font: 700 15px/28px var(--serif);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Notifications ---------- */

.notes { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }

.note {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-left: 4px solid transparent;
}

.note a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.note.unread { border-left-color: var(--accent); }
.note a { color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.note a:hover { text-decoration: underline; }
.note .when { font-size: 13px; }
.note .new { color: var(--accent); font-weight: 700; }

/* ---------- Household, circles, invites, admin ---------- */

.members { max-width: 720px; margin: 0 auto; }

.panel { padding: 18px 16px; margin: 0 0 16px; }
.panel > h2 { margin-bottom: 10px; }

.block { margin-top: 20px; }
.block > p { font-size: 14px; }

h3 {
  margin: 18px 0 8px;
  color: var(--muted);
  font: 700 12px/1.3 var(--sans);
  letter-spacing: .08em;
  text-transform: uppercase;
}
.block > h3 { margin-top: 0; }

.links { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 20px; }
.links a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }

.people { list-style: none; margin: 0; padding: 0; }
.people li { padding: 9px 0; font-family: var(--serif); font-size: 18px; }
.people li + li { border-top: 1px solid var(--line); }

.households { list-style: none; margin: 0; padding: 0; }
.households > li { padding: 4px 0; }
.households > li + li { border-top: 1px solid var(--line); }
.households .people li:first-child { padding-top: 5px; }

/* A name with its phone number and messenger buttons. */
.contact { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; }
.contact-name { flex: 1 1 8em; min-width: 0; }
.contact-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-family: var(--sans); font-size: 16px; }
.contact-phone { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
/* in the facts list the names sit on the line of their label */
.facts .people li { padding: 0; font: inherit; }
.facts .people li + li { border-top: 0; }

.profile .checks { margin-bottom: 8px; }
.profile .fine { text-align: left; }
.profile .logout { margin: 8px 0 24px; }

.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; padding: 0; }
.chips li {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--chipink);
  font-size: 14px;
  font-weight: 600;
}
.notice .chips { margin: 10px 0 0; }

.rows { list-style: none; margin: 0 0 12px; padding: 0; }
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 0;
}
.row + .row { border-top: 1px solid var(--line); }
.row-text { flex: 1 1 12em; min-width: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.row-actions form { margin: 0; }

.btn-small { min-height: 44px; padding: 0 14px; font-size: 15px; }

.tag {
  padding: 2px 8px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.newlink { display: grid; gap: 8px; }
.newlink .fine { text-align: left; }

.linkbox, .field input, .field select, .field textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.3 var(--sans); /* 16px keeps iOS from zooming in */
}
.field textarea { resize: vertical; }
.field input[type=file] { padding: 8px; }
.linkbox { font-family: ui-monospace, Menlo, monospace; font-size: 14px; }

.field { display: grid; gap: 6px; margin: 0 0 12px; }
.field label { font-weight: 600; }
.inline { display: flex; gap: 8px; }
.inline > :first-child { flex: 1; }
.inline .btn { flex: none; }

.waiting form { margin-bottom: 12px; }

/* ---------- Collection and copy form ---------- */

.games { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.game {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px 14px;
  align-items: start;
  padding: 14px;
}
.game .btn { grid-column: 1 / -1; }
.game-body > :last-child { margin-bottom: 0; }
.game-body p { margin: 0 0 6px; font-size: 14px; }
.game-body .chips { margin-bottom: 8px; }
.game-body .chips li { padding: 3px 10px; font-size: 13px; }
.game h2 a, .loan-text a, .req-text a { display: inline-block; padding: 12px 0; margin: -12px 0; }
.game h2 a { color: var(--ink); text-decoration: none; }
.game h2 a:hover { text-decoration: underline; }

.cover-img, .form-cover {
  display: block;
  width: 72px;
  height: 96px;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: 0 2px 6px var(--shadow);
}
.form-cover { width: 96px; height: 128px; }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.checks { min-width: 0; margin: 0 0 12px; padding: 0; border: 0; }
.checks legend { padding: 0; margin-bottom: 8px; font-weight: 600; }
.check { position: relative; display: inline-block; margin: 0 8px 8px 0; }
.check input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.check span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  font-size: 14px;
  font-weight: 600;
}
.check input:checked + span { border-color: var(--chip); background: var(--chip); color: var(--chipink); }
.check input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.danger { margin: 0 0 16px; }

.catform { padding: 14px 0; border-top: 1px solid var(--line); }
.catform h3 { margin-top: 0; }
.catform .btn { justify-self: start; }
.field .fine { text-align: left; }

/* ---------- BGG search ---------- */

.bgg-results { margin-top: 16px; }
.hits { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.hit {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}
.hit:hover { border-color: var(--accent); }
.hit .fine { margin: 0; text-align: left; font-weight: 400; }

/* ---------- Circle overview: search, filter chips, cover grid ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.overview .eyebrow a { display: inline-block; padding: 15px 0; margin: -15px 0; color: inherit; text-decoration: none; }
.overview .eyebrow a:hover { text-decoration: underline; }

.finder { margin: 14px 0 0; }
.finder .search {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  font: 16px/1.3 var(--sans);
}
.finder .inline .btn { border-radius: 999px; }

.filters { margin: 10px 0 0; padding: 0 16px; }
.filters summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.filters summary::-webkit-details-marker { display: none; }
.filters summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform .15s;
}
.filters[open] summary::after { transform: rotate(-135deg); }
.filters[open] { padding-bottom: 16px; }
.filters .checks { margin-bottom: 4px; }
.filters .checks legend { color: var(--muted); font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }
.filters .check span { padding: 0 13px; }
.count {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--accentink);
  font-size: 12px;
  line-height: 22px;
  text-align: center;
}

.chips.active { margin: 14px 0 0; }
.chips.active li { padding: 0; background: none; }
.chips.active a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 8px 0 14px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--chipink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.chips.active .x { font-size: 18px; line-height: 1; opacity: .7; }
.chips.active a:hover .x { opacity: 1; }

.count-line { margin: 16px 0 10px; font-size: 14px; }

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

.tile {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border-radius: 9px;
  color: var(--ink);
  text-decoration: none;
  transition: box-shadow .15s, transform .15s;
}
.tile:hover { box-shadow: 0 6px 16px var(--shadow); transform: translateY(-2px); }
.tile-cover {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--line);
}
/* a cover-less copy: a coloured box with a pale label band, as on the login page */
span.tile-cover, span.detail-cover, span.cover-img, span.thumb { position: relative; }
span.tile-cover::after, span.detail-cover::after, span.cover-img::after, span.thumb::after {
  content: "";
  position: absolute;
  left: 14%;
  right: 14%;
  top: 14%;
  height: 12%;
  border-radius: 4px;
  background: rgba(255, 255, 255, .38);
}
.tone-0 { background: linear-gradient(135deg, #2f5d50, #8fb39a); }
.tone-1 { background: linear-gradient(135deg, #c9a24a, #e8d8a8); }
.tone-2 { background: linear-gradient(135deg, #5b7fa6, #b5cbe0); }
.tone-3 { background: linear-gradient(135deg, #7a3b2e, #d79a6a); }
.tile-body { display: grid; gap: 2px; padding: 10px 11px 12px; }
.tile-name { font-size: 16px; font-weight: 700; line-height: 1.25; }
.tile-meta { color: var(--muted); font-size: 13px; }
.tile-stars { color: var(--star); font-size: 14px; letter-spacing: 1px; }
.tile-lent { color: var(--accent); font-size: 13px; font-weight: 700; }

.empty { display: grid; justify-items: center; gap: 4px; margin-top: 16px; padding: 28px 20px; text-align: center; }
.empty p { max-width: 34em; color: var(--muted); }
.empty .shelf { width: 132px; gap: 9px; margin: 0 0 14px; }

@media (min-width: 920px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 18px; }
  .finder .inline { max-width: 560px; }
}

/* ---------- Copy detail ---------- */

.detail { max-width: 720px; margin: 0 auto; }
.back { margin: 0 0 12px; }
.back a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; text-decoration: none; }

.detail-head {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 16px;
  margin: 0 0 16px;
}
.detail-cover {
  display: block;
  width: 112px;
  height: 150px;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 3px 10px var(--shadow);
}
.detail-info h1 { font-size: 26px; margin-bottom: 4px; }
.detail-info > p { font-size: 14px; }
.detail-info .chips { margin-bottom: 10px; }
.detail-info .chips li { padding: 3px 10px; font-size: 13px; }

.facts { display: grid; gap: 4px; margin: 10px 0 12px; font-size: 15px; }
.facts div { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); gap: 8px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.stars { color: var(--star); letter-spacing: 1px; }

.status { margin: 0 0 10px; font-weight: 700; }
.status.lent { color: var(--accent); }
.status.free { color: var(--muted); }

@media (max-width: 479px) {
  .detail-head { grid-template-columns: 1fr; }
  .detail-cover { width: 100%; height: auto; aspect-ratio: 4 / 3; max-height: 260px; }
  span.detail-cover { aspect-ratio: auto; height: 88px; }
}

@media (min-width: 920px) {
  .detail-head { grid-template-columns: 200px minmax(0, 1fr); gap: 24px; padding: 20px; }
  .detail-cover { width: 200px; height: 266px; }
  .detail-info h1 { font-size: 32px; }
}

.panel h3 { margin-top: 22px; }
.message {
  margin: 6px 0 8px;
  padding: 8px 12px;
  border-left: 3px solid var(--line);
  color: var(--ink);
  font-style: italic;
  white-space: pre-line;
}

.reqs { list-style: none; margin: 0; padding: 0; }
.req { display: grid; gap: 10px; padding: 14px 0; }
.req + .req { border-top: 1px solid var(--line); }
.req-text p { margin: 0 0 4px; }
.decide { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.decide .field { flex: 1 1 11em; margin: 0; }

.rate { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0 0 8px; }
.rate-label { font-weight: 600; }
.rate-stars { display: inline-flex; }
.star {
  appearance: none;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: color-mix(in srgb, var(--muted) 45%, transparent);
  font-size: 30px;
  line-height: 44px;
  cursor: pointer;
  transition: color .1s, transform .1s;
}
.star.on { color: var(--star); }
/* hovering fills up to the star under the pointer */
.rate-stars:hover .star { color: var(--star); }
.rate-stars .star:hover ~ .star { color: color-mix(in srgb, var(--muted) 45%, transparent); }
.star:active { transform: scale(.9); }
.star:focus-visible { outline-offset: -4px; }
.linkish {
  appearance: none;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: 600 14px/1 var(--sans);
  text-decoration: underline;
  cursor: pointer;
}
.ratings { margin-top: 4px; }
.ratings .stars { flex: none; }

/* ---------- Loans page ---------- */

.loans > h2 { margin: 26px 0 10px; }
.loans .panel { padding: 4px 16px; }
.loanlist { list-style: none; margin: 0 0 16px; padding: 0 16px; }
.loan, .loans .req {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px 14px;
  align-items: start;
  padding: 14px 0;
}
.loan + .loan { border-top: 1px solid var(--line); }
.loan > form, .loans .req > form { grid-column: 2; margin: 0; }
.loans .req-text { min-width: 0; }
.loan-text a { color: var(--ink); font-size: 17px; font-weight: 700; text-decoration: none; }
.loan-text a:hover { text-decoration: underline; }
.loan-text p { margin: 2px 0 0; font-size: 14px; }
.late { color: var(--accent); font-weight: 700; }
.thumb {
  display: block;
  width: 48px;
  height: 64px;
  object-fit: cover;
  border-radius: 5px;
  box-shadow: 0 1px 4px var(--shadow);
}

@media (min-width: 600px) {
  .loan { grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; }
  .loan > form { grid-column: auto; }
}

@media (max-width: 479px) {
  .lend .pair { grid-template-columns: 1fr; gap: 0; }
}

/* ---------- Forms on the phone ---------- */

/* iOS centres the date and lets an empty date field collapse; keep it a normal field. */
.field input[type=date] { -webkit-appearance: none; appearance: none; }
.field input[type=date]::-webkit-date-and-time-value { text-align: left; }
