/* ---------- tokens ---------- */
:root {
  --bg: #f5efe4;
  --paper: #fffdf8;
  --card: #ffffff;
  --ink: #2c241d;
  --muted: #7a6d60;
  --line: #e4d9c8;
  --accent: #e2553f;
  --accent-ink: #ffffff;
  --accent-soft: #fbe3dc;
  --good: #2f8f5b;
  --good-soft: #e3f3e9;
  --bad: #c2453a;
  --bad-soft: #fbe6e3;
  --notes-soft: #f3eedf;
  --wall: #eadfcd;
  --wall-dot: rgba(120, 90, 60, .06);
  --plank-top: #b07a4c;
  --plank-bottom: #7d5332;
  --polaroid: #fbfaf6;
  --polaroid-ink: #2b2b2b;
  --shadow: 0 1px 2px rgba(60, 40, 20, .08), 0 4px 14px rgba(60, 40, 20, .08);
  --shadow-lift: 0 10px 24px rgba(40, 25, 10, .28), 0 24px 50px rgba(40, 25, 10, .18);
  --radius: 14px;
  --tier-S: #ff7a7a;
  --tier-A: #ffb36b;
  --tier-B: #ffd866;
  --tier-C: #c5e478;
  --tier-D: #8fd0f2;
  --tier-none: #d8cfc2;
  --card-w: 124px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1915;
    --paper: #26211c;
    --card: #2b251f;
    --ink: #f1e9df;
    --muted: #a8998a;
    --line: #3d342b;
    --accent-soft: #4a2a22;
    --good: #6fcf97;
    --good-soft: #1f3328;
    --bad: #f08a7e;
    --bad-soft: #3a2421;
    --notes-soft: #322b22;
    --wall: #241f1a;
    --wall-dot: rgba(255, 240, 220, .035);
    --plank-top: #8a5d39;
    --plank-bottom: #5a3b22;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    --tier-none: #5a5046;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1d1915; --paper: #26211c; --card: #2b251f; --ink: #f1e9df; --muted: #a8998a; --line: #3d342b;
  --accent-soft: #4a2a22; --good: #6fcf97; --good-soft: #1f3328; --bad: #f08a7e; --bad-soft: #3a2421;
  --notes-soft: #322b22; --wall: #241f1a; --wall-dot: rgba(255, 240, 220, .035); --plank-top: #8a5d39;
  --plank-bottom: #5a3b22; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 14px rgba(0,0,0,.25); --tier-none: #5a5046;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3 { font-family: Fraunces, Georgia, serif; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
main { outline: none; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tiny { font-size: .78rem; }
.spacer { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

input, select, textarea {
  font: inherit; color: inherit;
  /* Under 16px, iPhone Safari zooms the page in on focus and the boxes run off both edges */
  font-size: max(16px, 1em);
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: .6em .75em;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: .3em; font-weight: 500; font-size: .9rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  font: inherit; font-weight: 600;
  padding: .6em 1.1em;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s, background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--bad); border-color: transparent; }
.btn.small { padding: .38em .85em; font-size: .85rem; }
.btn.block { width: 100%; }
.btn.round { width: 40px; height: 40px; padding: 0; font-size: 1.5rem; line-height: 1; }
.btn.sso { background: #fd4b2d; border-color: #fd4b2d; color: #fff; }
.linklike { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; padding: .4em; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.page { --page-max: 1180px; max-width: var(--page-max); margin: 0 auto; padding: 1.5rem 16px 4rem; }
.page.narrow { --page-max: 720px; }
/* Entry boxes sit at least a tenth of the window from its edges: a card near the edge widens its side
   padding by whatever its distance from the edge (page gutter, or centring margin on wide screens) falls short. */
.page .card:has(input, textarea, select) {
  padding-inline: max(var(--pad-min, 1.25rem), calc(10vw - 17px - max(0px, (100vw - var(--page-max)) / 2)));
}
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 1rem;
  padding: .6rem 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .4rem; font-family: Fraunces, Georgia, serif; font-weight: 700; font-size: 1.25rem; color: var(--ink); text-decoration: none; }
.brand-mark { font-size: 1.3rem; }
#nav { display: flex; align-items: center; gap: .25rem; flex: 1; flex-wrap: wrap; }
#nav > a { padding: .4em .8em; border-radius: 999px; color: var(--ink); text-decoration: none; font-weight: 500; }
#nav > a:hover { background: var(--accent-soft); }
#nav > a.active { background: var(--ink); color: var(--bg); }
.nav-user { margin-left: auto; display: flex; align-items: center; gap: .4rem; }
.nav-user a { color: var(--muted); text-decoration: none; font-size: .9rem; padding: .3em .6em; border-radius: 8px; }
.nav-user a.active, .nav-user a:hover { color: var(--ink); background: var(--accent-soft); }

/* ---------- toasts / modals ---------- */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 460px); pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: .7em 1.1em; border-radius: 12px; box-shadow: var(--shadow-lift); animation: toast-in .25s ease-out; font-weight: 500; }
.toast-success { background: var(--good); color: #fff; }
.toast-error { background: var(--bad); color: #fff; }
.toast.leaving { opacity: 0; transform: translateY(8px); transition: .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

.demo-notice {
  position: fixed; top: 68px; right: 16px; z-index: 40;
  width: min(340px, calc(100vw - 32px));
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px;
  padding: .85rem 2.4rem .9rem 1rem; box-shadow: var(--shadow-lift);
  animation: toast-in .3s ease-out;
}
.demo-notice strong { display: block; margin-bottom: .2rem; }
.demo-notice p { margin: 0 0 .7rem; font-size: .9rem; color: var(--muted); line-height: 1.45; }
.demo-notice-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.demo-notice-close {
  position: absolute; top: .35rem; right: .4rem; width: 30px; height: 30px;
  background: none; border: 0; border-radius: 8px; color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.demo-notice-close:hover { background: var(--accent-soft); color: var(--ink); }
.demo-chip {
  background: var(--accent-soft); color: var(--ink); border: 1px dashed var(--accent); border-radius: 999px;
  padding: .3em .8em; font: inherit; font-size: .8rem; font-weight: 600; letter-spacing: .03em; cursor: pointer;
}
@media (max-width: 720px) {
  .demo-notice { top: auto; bottom: 16px; }
}
body.is-dragging .demo-notice { pointer-events: none; opacity: .5; }

.modal-overlay { position: fixed; inset: 0; z-index: 1500; background: rgba(20, 12, 5, .45); display: grid; place-items: center; padding: 16px; }
.modal { background: var(--card); border-radius: var(--radius); padding: 1.4rem; box-shadow: var(--shadow-lift); width: min(100%, 440px); }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .6rem; }
.modal-head h2 { margin: 0; }
.people-modal { width: min(100%, 480px); max-height: calc(100vh - 32px); overflow-y: auto; }
.member-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .3rem; }
.member-list li { display: flex; align-items: center; gap: .6rem; padding: .45rem .2rem; border-bottom: 1px solid var(--line); }
.member-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.add-member { display: flex; gap: .5rem; }
.add-member select { flex: 1; min-width: 0; }
.danger-zone { margin-top: 1.2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.board-pick { margin: .9rem 0 1.1rem; }
.board-filter { width: auto; flex: 0 1 auto; min-width: 0; border-radius: 999px; }
.landing-board { margin: .2rem 0 0; }

.lightbox { position: fixed; inset: 0; z-index: 1600; background: rgba(0, 0, 0, .92); display: grid; place-items: center; }
.lightbox img { max-width: 94vw; max-height: 88vh; object-fit: contain; border-radius: 4px; }
.lb-nav, .lb-close { position: absolute; background: rgba(255, 255, 255, .12); color: #fff; border: 0; border-radius: 50%; width: 48px; height: 48px; font-size: 2rem; cursor: pointer; line-height: 1; }
.lb-nav:hover, .lb-close:hover { background: rgba(255, 255, 255, .25); }
.lb-nav.prev { left: 16px; top: 50%; }
.lb-nav.next { right: 16px; top: 50%; }
.lb-close { right: 16px; top: 16px; }
.lb-count { position: absolute; bottom: 16px; color: #ddd; font-size: .9rem; }

/* ---------- tier badges & buttons ---------- */
.tier-badge {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; border-radius: 8px;
  font: 700 .95rem Fraunces, Georgia, serif;
  color: #2b2118; background: var(--tier-none); flex-shrink: 0;
}
.tier-badge.small { width: 22px; height: 22px; font-size: .8rem; border-radius: 6px; }
.tier-badge.large { width: 54px; height: 54px; font-size: 1.7rem; border-radius: 14px; }
.tier-badge.corner { position: absolute; top: 10px; left: 10px; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.tier-S { --tier: var(--tier-S); } .tier-A { --tier: var(--tier-A); } .tier-B { --tier: var(--tier-B); }
.tier-C { --tier: var(--tier-C); } .tier-D { --tier: var(--tier-D); } .tier-none { --tier: var(--tier-none); }
.tier-badge[class*="tier-"] { background: var(--tier); }

.tier-picker { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .5rem; }
.tier-btn {
  min-width: 52px; height: 52px; padding: 0 .9rem;
  border-radius: 12px; border: 2px solid transparent;
  background: color-mix(in srgb, var(--tier) 35%, var(--card));
  color: var(--ink);
  font: 700 1.3rem Fraunces, Georgia, serif;
  cursor: pointer; transition: transform .12s, box-shadow .12s;
}
.tier-btn.tier-none { font: 600 .9rem Inter, sans-serif; }
.tier-btn:hover { transform: translateY(-2px); }
.tier-btn.selected { background: var(--tier); color: #2b2118; border-color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.tier-btn.tiny { min-width: 32px; height: 32px; font-size: .95rem; border-radius: 8px; padding: 0 .4rem; }
.tier-btn.tiny.tier-none { font-size: .95rem; }

/* ---------- auth ---------- */
.auth-page { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 2rem 16px; }
.auth-card { width: min(100%, 400px); background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 2rem; box-shadow: var(--shadow); text-align: center; }
.auth-card .stack { text-align: left; }
.auth-logo { font-size: 2.6rem; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.form-error { color: var(--bad); font-weight: 500; min-height: 1.2em; margin: .5rem 0; }
.form-error:empty { display: none; }
.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); margin: 1rem 0; font-size: .85rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- landing ---------- */
.landing-head { margin: 1rem 0 1.5rem; }
.landing-head h1 { font-size: 2.3rem; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.25rem; }
.choice-card {
  display: block; text-decoration: none; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  padding: 1.75rem; box-shadow: var(--shadow);
  transition: transform .18s, box-shadow .18s;
}
.choice-card:hover { transform: translateY(-4px) rotate(-.4deg); box-shadow: var(--shadow-lift); }
.choice-card h2 { font-size: 1.6rem; margin-top: .6rem; }
.choice-card p { color: var(--muted); margin: 0; }
.choice-art { width: 130px; color: var(--ink); }
.choice-new { background: linear-gradient(160deg, var(--accent-soft), var(--card) 60%); }
.choice-rank { background: linear-gradient(160deg, color-mix(in srgb, var(--tier-B) 30%, var(--card)), var(--card) 60%); }
.landing-summary { margin-top: 2rem; display: grid; gap: 1.25rem; justify-items: start; }
.tier-counts { display: flex; gap: .6rem; flex-wrap: wrap; }
.tier-count { display: flex; align-items: center; gap: .45rem; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .35rem .7rem .35rem .4rem; color: var(--ink); text-decoration: none; }
.tier-count:hover { border-color: var(--muted); }
.top-picks { width: 100%; }
.top-pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .8rem; }
.top-pick { display: flex; gap: .75rem; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .5rem; color: var(--ink); text-decoration: none; }
.top-pick img, .top-pick .img-fallback { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; background: var(--line); flex-shrink: 0; }
.top-pick > div { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.top-pick strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- editor ---------- */
/* minmax(0, 1fr): an auto column grows to fit the photo strip's full width (every photo in one row) and
   pushes the whole page off screen; this keeps the cards at page width and lets the strip scroll instead. */
.editor { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
.editor-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
.lookup-card h1 { margin-bottom: .2rem; }
.lookup-row { display: flex; gap: .6rem; margin-top: 1rem; }
.lookup-input { font-size: 1.05rem; padding: .8em 1em; border-radius: 999px; }
.lookup-msg { margin-top: .8rem; padding: .7rem 1rem; border-radius: 10px; font-size: .92rem; }
.lookup-msg:empty { display: none; }
.lookup-msg.working { background: var(--notes-soft); }
.lookup-msg.working::before { content: ""; display: inline-block; width: .9em; height: .9em; margin-right: .5em; border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
.lookup-msg.ok { background: var(--good-soft); color: var(--good); }
.lookup-msg.warn { background: var(--notes-soft); }
.lookup-msg.error { background: var(--bad-soft); color: var(--bad); }
@keyframes spin { to { transform: rotate(360deg); } }
.bulk { margin-top: 1rem; }
.bulk summary { cursor: pointer; color: var(--muted); font-weight: 500; }
.bulk textarea { margin: .4rem 0 .6rem; }
.bulk-log { list-style: none; padding: 0; margin: .8rem 0 0; display: grid; gap: .3rem; font-size: .9rem; }
.bulk-log li.error { color: var(--bad); }
.bulk-log li.ok em { color: var(--good); }
.manual-entry { text-align: center; }

.section-head { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; margin-bottom: .8rem; }
.section-head h2 { margin: 0; }
.section-head .btn { margin-left: auto; }
/* ---------- photo carousel ---------- */
.carousel { position: relative; min-width: 0; border-radius: 12px; overflow: hidden; background: #1d1813; outline-offset: 3px; }
.car-viewport { overflow: hidden; aspect-ratio: 4 / 3; max-height: 70vh; width: 100%; cursor: zoom-in; touch-action: pan-y; }
.car-track { display: flex; height: 100%; transition: transform .5s cubic-bezier(.3,.7,.2,1); }
.car-slide { flex: 0 0 100%; min-width: 0; height: 100%; display: grid; place-items: center; }
.car-slide img { width: 100%; height: 100%; object-fit: contain; user-select: none; }
.car-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 253, 248, .88); color: #2c241d; font-size: 1.9rem; line-height: 1; padding-bottom: .15em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35); transition: background .15s, transform .15s;
}
.car-arrow:hover { background: #fff; transform: translateY(-50%) scale(1.08); }
.car-arrow.prev { left: 10px; }
.car-arrow.next { right: 10px; }
.car-count { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: rgba(0, 0, 0, .6); color: #fff; font-size: .8rem; font-weight: 600; padding: .2em .7em; border-radius: 999px; pointer-events: none; }
.car-extras { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.car-extras > * { pointer-events: auto; }
.cover-tag { position: absolute; left: 10px; top: 10px; background: var(--accent); color: #fff; font-size: .75rem; font-weight: 600; padding: .15em .6em; border-radius: 6px; }
.car-actions { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; }
.car-actions button { width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 1.1rem; }
.car-actions button:hover { background: rgba(0,0,0,.85); }
@media (prefers-reduced-motion: reduce) { .car-track { transition: none; } }
.photo-empty { padding: 1.5rem; text-align: center; border: 2px dashed var(--line); border-radius: 10px; }

.page.editor { --page-max: 760px; }
.details-card { display: grid; gap: .9rem; }
.map-card .mini-map { height: 300px; }
.field-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .8rem; }
.review-grid { display: grid; gap: 1rem; margin-bottom: 1.2rem; }
.review > span { font-weight: 600; }
.review.good textarea { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.review.bad textarea { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.review.notes textarea { background: var(--notes-soft); }
.form-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; position: sticky; bottom: 0; padding: .9rem 0; background: linear-gradient(transparent, var(--bg) 35%); }
.editor-title { display: flex; align-items: baseline; justify-content: space-between; }

/* ---------- maps ---------- */
.mini-map-wrap { position: relative; border-radius: 12px; overflow: hidden; cursor: zoom-in; border: 1px solid var(--line); }
.mini-map { height: 240px; background: #2b3a2e; }
.mini-map.empty { height: 160px; display: grid; place-items: center; color: var(--muted); background: var(--notes-soft); border-radius: 12px; }
.mini-map-hint { position: absolute; right: 8px; bottom: 8px; z-index: 500; background: rgba(0,0,0,.65); color: #fff; font-size: .8rem; font-weight: 600; padding: .3em .7em; border-radius: 999px; pointer-events: none; }
.mini-map-wrap:hover .mini-map-hint { background: var(--accent); }
.home-pin { background: none; border: 0; filter: drop-shadow(0 2px 3px rgba(0,0,0,.45)); }

.map-overlay { position: fixed; inset: 0; z-index: 1200; background: #111; animation: map-in .22s ease-out; }
@keyframes map-in { from { opacity: 0; transform: scale(.97); } }
.full-map { position: absolute; inset: 0; }
.full-map.drawing { cursor: crosshair; }
.full-map.drawing .leaflet-interactive { cursor: crosshair; }
.map-header { position: absolute; top: 12px; left: 12px; right: 12px; z-index: 1000; display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; pointer-events: none; }
.map-header > * { pointer-events: auto; }
.map-header > div { background: rgba(20, 16, 12, .78); color: #fff; padding: .55rem .9rem; border-radius: 12px; backdrop-filter: blur(6px); max-width: 70vw; }
.map-header strong { display: block; }
.map-status { font-size: .8rem; opacity: .8; }
.map-toolbar { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; gap: .4rem; flex-wrap: wrap; justify-content: center; background: rgba(20, 16, 12, .78); padding: .5rem; border-radius: 999px; backdrop-filter: blur(6px); max-width: calc(100vw - 24px); }
.map-toolbar:empty { display: none; }
.map-toolbar .btn { background: rgba(255,255,255,.12); color: #fff; border-color: transparent; }
.map-toolbar .btn.primary { background: var(--accent); }
.map-tip { color: #fff; align-self: center; padding: 0 .6rem; font-size: .85rem; }
.leaflet-container { font: inherit; }

/* ---------- profile ---------- */
.profile-top { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.back { text-decoration: none; font-weight: 500; }
.profile-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.gallery { display: grid; gap: .5rem; min-width: 0; }
.gallery.empty { aspect-ratio: 3 / 2; place-items: center; align-content: center; background: var(--notes-soft); border-radius: 12px; color: var(--muted); }
.profile-side { display: grid; gap: .8rem; position: sticky; top: 76px; }
.profile-title { display: flex; gap: .9rem; align-items: center; }
.profile-title h1 { font-size: 1.5rem; margin: 0; }
.profile-title p { margin: .1rem 0 0; font-size: .9rem; }
.price { font: 700 1.6rem Fraunces, Georgia, serif; }
.stats { margin: -.4rem 0 0; color: var(--muted); }
.quick-tier { display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.review-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin: 1.25rem 0; }
.review-box { border-radius: var(--radius); padding: 1.1rem 1.2rem; border: 1px solid var(--line); }
.review-box p { white-space: pre-wrap; margin: 0; }
.review-box.good { background: var(--good-soft); }
.review-box.good h3 { color: var(--good); }
.review-box.bad { background: var(--bad-soft); }
.review-box.bad h3 { color: var(--bad); }
.review-box.notes { background: var(--notes-soft); }
.facts dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem 1.2rem; margin: 0; }
.facts dt { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: 0; font-weight: 600; text-transform: capitalize; }
.description { white-space: pre-wrap; margin: 0; }
.profile > section.card { margin-top: 1.25rem; }

/* ---------- library ---------- */
.library-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.library-head h1 { margin: 0; }
.library-toolbar { --pad-min: .8rem; display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; padding: .8rem; margin-bottom: 1.25rem; }
.library-toolbar input[type=search] { flex: 1 1 220px; width: auto; min-width: 0; border-radius: 999px; }
.toolbar-right { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-left: auto; }
.toolbar-right select { width: auto; border-radius: 999px; }
.chips { display: flex; gap: .3rem; flex-wrap: wrap; }
.chip { border: 1.5px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 999px; padding: .3em .8em; font: 600 .85rem Inter, sans-serif; cursor: pointer; }
.chip[class*="tier-"] { background: color-mix(in srgb, var(--tier) 25%, var(--paper)); }
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.active[class*="tier-"] { background: var(--tier); color: #2b2118; }
.toggle { flex-direction: row; align-items: center; gap: .4rem; font-weight: 500; white-space: nowrap; }
.toggle input { width: auto; }
.seg { display: flex; border: 1.5px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { border: 0; background: transparent; color: var(--ink); padding: .4em .8em; font: 500 .85rem Inter, sans-serif; cursor: pointer; }
.seg button.active { background: var(--ink); color: var(--bg); }

.library-results.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.1rem; }
.home-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
.home-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lift); }
.home-card-photo { position: relative; aspect-ratio: 4 / 3; background: var(--notes-soft); display: grid; place-items: center; color: var(--muted); }
.home-card-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-count { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: .75rem; padding: .15em .5em; border-radius: 6px; }
.home-card-body { padding: .8rem 1rem 1rem; display: grid; gap: .1rem; }
.home-card .price { font-size: 1.25rem; }
.home-card .addr { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.library-results.list { display: grid; gap: .5rem; }
.home-row { display: grid; grid-template-columns: 72px auto 1fr auto auto auto; gap: 1rem; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .5rem 1rem .5rem .5rem; text-decoration: none; color: var(--ink); }
.home-row:hover { border-color: var(--muted); }
.home-row > img, .home-row > .photo-placeholder { width: 72px; height: 54px; object-fit: cover; border-radius: 8px; background: var(--notes-soft); }
.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-main strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-row .price { font-size: 1.05rem; }
.photo-placeholder { display: grid; place-items: center; color: var(--muted); width: 100%; height: 100%; }

/* ---------- settings ---------- */
.settings { display: grid; gap: 1.25rem; }
.account-dl { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.2rem; margin: 0; }
.account-dl dt { color: var(--muted); }
.account-dl dd { margin: 0; }
.user-list { display: grid; gap: .4rem; margin-bottom: 1rem; }
.user-row { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.row-actions { display: flex; gap: .2rem; flex-wrap: wrap; }
.add-user { display: grid; grid-template-columns: 1fr 1fr 1fr auto auto; gap: .5rem; align-items: center; }

/* ---------- ranking board ---------- */
body.wide-page main { background: var(--wall); background-image: radial-gradient(var(--wall-dot) 1.2px, transparent 1.3px); background-size: 18px 18px; min-height: calc(100vh - 57px); }
.board-page { max-width: 1500px; margin: 0 auto; padding: 1.25rem 16px 0; display: flex; flex-direction: column; min-height: calc(100vh - 57px); }
.board-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .8rem; }
.board-head h1 { margin: 0; }
.board-head-main { min-width: 0; }
.board-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .6rem; }
.board-title { overflow-wrap: anywhere; }
.board-switch { width: auto; max-width: 100%; border-radius: 999px; padding: .4em 2em .4em .9em; }
.board-head p { margin: .2rem 0 0; max-width: 60ch; }
.shelves { display: grid; gap: 1.1rem; padding-bottom: 1.5rem; }
.tier-row { display: grid; grid-template-columns: 92px 1fr; gap: .8rem; align-items: stretch; border-radius: 16px; transition: background .15s; }
.tier-row.drop-zone { background: color-mix(in srgb, var(--tier) 18%, transparent); }
.tier-label {
  background: var(--tier); color: #2b2118; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: .5rem; box-shadow: inset 0 -4px 0 rgba(0,0,0,.12), var(--shadow);
}
.tier-letter { font: 700 2.4rem/1 Fraunces, Georgia, serif; }
.tier-name { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; opacity: .75; line-height: 1.2; margin-top: .25rem; }
.shelf { position: relative; padding-bottom: 16px; }
.plank {
  position: absolute; left: -6px; right: -6px; bottom: 0; height: 16px; border-radius: 4px;
  background: linear-gradient(var(--plank-top), var(--plank-bottom));
  box-shadow: 0 6px 10px rgba(40, 20, 5, .3), inset 0 2px 0 rgba(255,255,255,.18);
}
.plank::before { content: ""; position: absolute; inset: 3px 0 auto; height: 1px; background: rgba(0,0,0,.12); }
.slots { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-end; min-height: calc(var(--card-w) * 1.27 + 20px); padding: 10px 14px 6px; position: relative; }
.empty-hint { align-self: center; color: var(--muted); font-style: italic; font-size: .9rem; padding: 0 .5rem; pointer-events: none; }

.pool {
  position: sticky; bottom: 0; z-index: 20; margin: auto -16px 0;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(6px);
  border-top: 2px dashed var(--line);
  box-shadow: 0 -8px 24px rgba(40, 25, 10, .12);
  padding: .6rem 16px .4rem;
  transition: background .15s;
}
.pool.drop-zone { background: color-mix(in srgb, var(--accent-soft) 80%, var(--paper)); }
.pool-head { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; }
.pool-head h2 { margin: 0; font-size: 1.1rem; }
.pool-toggle { margin-left: auto; }
.pool-count { color: var(--muted); font-family: Inter, sans-serif; font-weight: 500; font-size: .95rem; }
.pool-slots { max-height: 36vh; overflow-y: auto; padding-top: 14px; }
.pool.collapsed .pool-slots { display: none; }
.pool-slots:has(> .empty-hint:only-child) { min-height: 0; padding: 6px 14px 10px; }

.polaroid {
  --tilt: 0deg;
  width: var(--card-w);
  background: var(--polaroid);
  padding: 7px 7px 0;
  border-radius: 2px;
  box-shadow: 0 1px 1px rgba(0,0,0,.12), 0 4px 10px rgba(40, 25, 10, .22);
  transform: rotate(var(--tilt));
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  flex-shrink: 0;
  transition: box-shadow .15s, opacity .15s;
}
.polaroid:hover { box-shadow: 0 2px 2px rgba(0,0,0,.12), 0 10px 20px rgba(40, 25, 10, .28); }
.polaroid::before { /* strip of tape */
  content: ""; position: absolute; top: -8px; left: 50%; width: 42px; height: 15px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(255, 245, 210, .6); box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
.pol-photo { aspect-ratio: 1; background: #ddd5c8; overflow: hidden; color: #8b7d6e; display: grid; place-items: center; }
.pol-photo img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.pol-label { height: 40px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; color: var(--polaroid-ink); font-family: "Patrick Hand", "Comic Sans MS", cursive; line-height: 1.05; padding: 0 2px; }
.pol-street { font-size: 1.02rem; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pol-city { font-size: .78rem; opacity: .65; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.polaroid.origin-ghost { opacity: .28; outline: 2px dashed var(--muted); outline-offset: 3px; box-shadow: none; }
.polaroid.dragging {
  position: fixed; left: 0; top: 0; z-index: 1000; margin: 0;
  cursor: grabbing; pointer-events: none;
  box-shadow: var(--shadow-lift);
  transition: none;
  will-change: transform;
}
.polaroid.swap-target { outline: 3px solid var(--accent); outline-offset: 4px; animation: wiggle .5s ease-in-out infinite alternate; }
@keyframes wiggle { from { transform: rotate(calc(var(--tilt) - 2deg)); } to { transform: rotate(calc(var(--tilt) + 2deg)); } }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }
body.is-dragging .polaroid:hover { box-shadow: 0 1px 1px rgba(0,0,0,.12), 0 4px 10px rgba(40, 25, 10, .22); }

.drop-indicator { position: fixed; left: 0; top: 0; width: 4px; border-radius: 4px; background: var(--accent); z-index: 900; pointer-events: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); transition: transform .08s, height .08s; }
.drop-indicator::before, .drop-indicator::after { content: ""; position: absolute; left: -4px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.drop-indicator::before { top: -6px; }
.drop-indicator::after { bottom: -6px; }

.hover-info {
  position: fixed; left: 0; top: 0; z-index: 950; width: 270px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  box-shadow: var(--shadow-lift); pointer-events: none;
  animation: pop .15s ease-out;
}
@keyframes pop { from { opacity: 0; } }
.hover-info > img, .hover-info > .photo-placeholder { width: 100%; height: 150px; object-fit: cover; background: var(--notes-soft); }
.hover-body { padding: .7rem .9rem .8rem; display: grid; gap: .15rem; }
.hover-title { display: flex; gap: .45rem; align-items: center; }
.hover-price { font: 700 1.15rem Fraunces, Georgia, serif; }
.hover-good, .hover-bad { margin: .3rem 0 0; font-size: .82rem; padding: .35rem .5rem; border-radius: 8px; }
.hover-good { background: var(--good-soft); }
.hover-bad { background: var(--bad-soft); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .profile-grid { grid-template-columns: minmax(0, 1fr); }
  .profile-side { position: static; }
  .review-columns { grid-template-columns: 1fr; }
  .home-row { grid-template-columns: 64px auto 1fr auto; }
  .home-row .row-stats, .home-row .row-by { display: none; }
  .add-user { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  :root { --card-w: 92px; }
  h1 { font-size: 1.5rem; }
  .landing-head h1 { font-size: 1.8rem; }
  .topbar { flex-wrap: wrap; gap: .4rem; }
  #nav { flex-basis: 100%; order: 2; }
  .nav-user { margin-left: auto; }
  .lookup-row { flex-direction: column; }
  .tier-row { grid-template-columns: 52px 1fr; gap: .4rem; }
  .tier-letter { font-size: 1.7rem; }
  .tier-name { display: none; }
  .slots { gap: 12px; padding: 10px 6px 6px; }
  .pol-label { height: 36px; }
  .pol-street { font-size: .82rem; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.05; }
  .pol-city { display: none; }
  .board-head > .btn { display: none; } /* "+ Add home": the nav already has it on phones */
  .pool-head .muted { display: none; }
  .pool-slots { max-height: 30vh; }
  .toolbar-right { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
