:root {
  color-scheme: light;
  --bg: #E6E9EE;
  --surface: #F6F7F9;
  --ink: #1A2238;
  --muted: #596379;
  --line: #C7CDD8;
  --accent: #2E6F6A;
  --accent-ink: #FFFFFF;
  --sticker: #E3B23C;
  --sticker-ink: #3B2B00;
  --rose: #B4505C;
  --danger: #B3261E;
  --groove-a: #17191E;
  --groove-b: #292D36;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(26, 34, 56, .18), 0 10px 20px -12px rgba(26, 34, 56, .5);
  font-family: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121725;
    --surface: #1B2133;
    --ink: #E6E9F1;
    --muted: #98A1B6;
    --line: #2E3650;
    --accent: #62B5AD;
    --accent-ink: #0D2321;
    --sticker: #E3B23C;
    --sticker-ink: #2E2200;
    --rose: #D97C87;
    --danger: #F2867E;
    --groove-a: #08090C;
    --groove-b: #1E2129;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 12px 24px -12px rgba(0, 0, 0, .85);
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 clamp(1rem, 3vw, 2rem); }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--sticker); outline-offset: 2px; }
[hidden] { display: none !important; }

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

.masthead { background: var(--surface); border-bottom: 1px solid var(--line); }
.masthead-inner { display: flex; align-items: center; gap: 1rem 1.5rem; min-height: 4.25rem; flex-wrap: wrap; padding-block: .5rem; }

.wordmark {
  display: inline-flex; align-items: center; gap: .6rem;
  color: var(--ink); text-decoration: none;
  font-size: 1.4rem; font-weight: 800; letter-spacing: -.02em;
  font-variation-settings: "wdth" 85;
}
.wordmark::before {
  content: ""; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background:
    radial-gradient(circle, var(--surface) 0 9%, var(--accent) 10% 34%, transparent 35%),
    repeating-radial-gradient(circle, var(--groove-a) 0 1px, var(--groove-b) 1px 2px);
}

.account { margin-left: auto; display: flex; align-items: center; gap: 1.25rem; }
.account form { margin: 0; }

/* ---------- Controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 2.6rem; padding: .5rem 1.1rem;
  font: inherit; font-weight: 650; text-decoration: none; white-space: nowrap;
  color: var(--accent-ink); background: var(--accent);
  border: 1px solid transparent; border-radius: 999px; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { border-color: var(--ink); filter: none; }
.btn.danger { background: transparent; color: var(--danger); border-color: currentColor; }

.link {
  background: none; border: 0; padding: 0; font: inherit; cursor: pointer;
  color: var(--accent); text-decoration: underline; text-underline-offset: 3px;
}

.field label, .field .label { display: block; font-weight: 650; margin-bottom: .3rem; }

input[type="text"], input[type="search"], input[type="number"], input[type="password"], select, textarea {
  width: 100%; min-height: 2.6rem; padding: .5rem .7rem;
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }

.hint { color: var(--muted); font-size: .875rem; margin: .35rem 0 0; }
.hint.error { color: var(--danger); }

.check { display: flex; align-items: center; gap: .6rem; font-weight: 650; cursor: pointer; }
.check input { width: 1.2rem; height: 1.2rem; margin: 0; accent-color: var(--accent); }

.notice {
  margin: 1.25rem 0 0; padding: .75rem 1rem; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 15%, var(--surface));
}
.notice.error { background: color-mix(in srgb, var(--danger) 15%, var(--surface)); }
.notice p { margin: 0; }
.notice ul { margin: .4rem 0 0; padding-left: 1.2rem; }

/* ---------- List page ---------- */

.tabs { display: flex; gap: .25rem; margin-top: 1.5rem; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a {
  padding: .6rem .9rem; margin-bottom: -1px;
  color: var(--muted); font-weight: 650; text-decoration: none; white-space: nowrap;
  border-bottom: 3px solid transparent;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-color: var(--accent); }
.tabs .count { margin-left: .4rem; font-weight: 400; color: var(--muted); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; padding: 2.25rem 0 .5rem; }

h1 {
  margin: 0; font-size: clamp(2.4rem, 6vw, 4rem); line-height: .95;
  font-weight: 800; letter-spacing: -.035em; font-variation-settings: "wdth" 78;
}
.lede { margin: .6rem 0 0; color: var(--muted); }

.toolbar { display: flex; align-items: flex-end; gap: .75rem; flex-wrap: wrap; margin: 0; }
.toolbar .field { min-width: 9rem; }
.toolbar .field:first-of-type { min-width: min(17rem, 100%); }
.toolbar label { font-size: .875rem; color: var(--muted); font-weight: 500; }

.record-map {
  height: clamp(300px, 46vh, 480px); margin-top: 1.5rem;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); z-index: 0;
}

.crate {
  list-style: none; margin: 2rem 0 5rem; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 2.75rem 2.5rem;
}

.record { position: relative; --label: var(--accent); }
.record:nth-child(3n + 2) { --label: var(--sticker); }
.record:nth-child(3n) { --label: var(--rose); }
.record:hover, .record:focus-within { z-index: 2; }

.sleeve { position: relative; display: block; aspect-ratio: 1; color: inherit; }
.sleeve img, .sleeve .blank {
  position: relative; z-index: 1; display: block; width: 100%; height: 100%;
  object-fit: cover; border-radius: 3px; box-shadow: var(--shadow); background: var(--surface);
}
.sleeve .blank {
  display: grid; place-items: center;
  font-size: 2.6rem; font-weight: 800; letter-spacing: -.04em; color: var(--muted);
  border: 1px solid var(--line);
}

/* The record slides out of its sleeve. */
.disc {
  position: absolute; inset: 3%; z-index: 0; border-radius: 50%;
  background:
    radial-gradient(circle, var(--bg) 0 2.4%, var(--label) 2.8% 17%, transparent 17.5%),
    repeating-radial-gradient(circle, var(--groove-a) 0 1.2px, var(--groove-b) 1.2px 2.6px);
  box-shadow: var(--shadow);
  transition: transform .55s cubic-bezier(.2, .8, .2, 1);
}
.record:hover .disc, .sleeve:focus-visible .disc { transform: translateX(24%) rotate(50deg); }

.sticker {
  position: absolute; z-index: 3; top: -.55rem; right: -.55rem;
  padding: .15rem .55rem; border-radius: 999px;
  background: var(--sticker); color: var(--sticker-ink);
  font-size: .75rem; font-weight: 700; transform: rotate(7deg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}

.record h2 { margin: .9rem 0 0; font-size: 1.05rem; line-height: 1.25; font-weight: 700; }
.record .artist { margin: .1rem 0 0; }
.record .genre { margin: .4rem 0 0; }
.record .genre a {
  display: inline-block; padding: .05rem .5rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; text-decoration: none;
  color: var(--ink); background: color-mix(in srgb, var(--label) 22%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--label) 45%, transparent);
}
.record .genre a:hover { border-color: var(--label); }
.record .meta { margin: .3rem 0 0; color: var(--muted); font-size: .875rem; line-height: 1.4; }

.empty { padding: 5rem 0; text-align: center; color: var(--muted); }
.empty p { font-size: 1.15rem; margin: 0 0 1rem; }

/* ---------- Map pins ---------- */

.leaflet-container { font: inherit; background: var(--surface); }
.pin-icon { background: none; border: 0; }
.pin {
  display: block; width: 46px; height: 46px; overflow: hidden; border-radius: 50%;
  border: 3px solid var(--surface); box-shadow: var(--shadow);
  background:
    radial-gradient(circle, var(--surface) 0 8%, var(--accent) 9% 30%, transparent 31%),
    repeating-radial-gradient(circle, var(--groove-a) 0 1px, var(--groove-b) 1px 2.5px);
}
.pin img { display: block; width: 100%; height: 100%; object-fit: cover; }
.pin-small { width: 32px; height: 32px; }
.pin-count {
  position: absolute; top: -6px; right: -8px; min-width: 1.35rem; padding: 0 .35rem;
  border-radius: 999px; background: var(--sticker); color: var(--sticker-ink);
  font-size: .72rem; font-weight: 700; line-height: 1.35rem; text-align: center;
}

.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--ink); }
.leaflet-popup-content-wrapper { border-radius: var(--radius-sm); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.popup p.popup-place { margin: 0 0 .5rem; font-weight: 700; }
.popup ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; max-height: 260px; overflow-y: auto; }
.popup li { display: flex; align-items: center; gap: .6rem; line-height: 1.3; }
.popup img { width: 46px; height: 46px; object-fit: cover; border-radius: 2px; flex: none; }
.popup small { color: var(--muted); }

/* ---------- Form ---------- */

.record-form {
  display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 2.5rem; align-items: start; padding: 1.5rem 0 2rem;
}

.cover-panel { display: grid; gap: .75rem; }
.cover-preview {
  aspect-ratio: 1; overflow: hidden; display: grid; place-items: center;
  color: var(--muted); background: var(--surface);
  border: 1px dashed var(--line); border-radius: 3px;
}
.cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.cover-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-btn:focus-within { outline: 3px solid var(--sticker); outline-offset: 2px; }

.cover-results { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.cover-results .hint { grid-column: 1 / -1; margin: 0; }
.cover-option {
  padding: 0; aspect-ratio: 1; cursor: pointer; background: var(--surface);
  border: 3px solid transparent; border-radius: 4px; overflow: hidden;
}
.cover-option img { display: block; width: 100%; height: 100%; object-fit: cover; }
.cover-option[aria-pressed="true"] { border-color: var(--accent); }

.fields { display: grid; gap: 1.2rem; max-width: 40rem; }

fieldset.holiday {
  display: grid; gap: 1.2rem; margin: 0; padding: 1.25rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
}
fieldset.holiday legend { padding: 0 .4rem; font-weight: 700; }
.holiday input[type="text"], .holiday input[type="number"] { background: var(--bg); }

.two { display: grid; grid-template-columns: 8rem minmax(0, 1fr); gap: 1rem; }
.pick-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.pick-map { height: 300px; border: 1px solid var(--line); border-radius: var(--radius-sm); z-index: 0; }

.geo-results { display: grid; gap: .3rem; margin-bottom: .6rem; }
.geo-results:empty { display: none; }
.geo-results button {
  text-align: left; font: inherit; font-size: .9rem; color: var(--ink); cursor: pointer;
  padding: .45rem .65rem; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.geo-results button:hover { border-color: var(--accent); }

.form-actions { display: flex; align-items: center; gap: 1.25rem; }
.danger-zone { padding: 1.5rem 0 5rem; border-top: 1px solid var(--line); }

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

.auth { display: grid; gap: 1.1rem; max-width: 24rem; margin: 4rem auto; }
.auth h1 { margin-bottom: .25rem; }
.auth .btn { justify-self: start; }

/* ---------- Add several ---------- */

textarea { min-height: 12rem; resize: vertical; line-height: 1.5; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.import { display: grid; gap: 1.5rem; max-width: 52rem; padding: 1.5rem 0 1rem; }
.import-source { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.import-source .file-btn { margin-top: .1rem; }
.import input:disabled, .import textarea:disabled { opacity: .6; }

.table-wrap { overflow-x: auto; margin: 1rem 0 0; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.import-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.import-table th { text-align: left; font-weight: 650; color: var(--muted); padding: .7rem .8rem; border-bottom: 1px solid var(--line); }
.import-table td { padding: .55rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.import-table tr:last-child td { border-bottom: 0; }
.import-table .thumb { width: 3.5rem; }
.import-table .thumb img, .mini-disc { display: block; width: 40px; height: 40px; border-radius: 2px; object-fit: cover; }
.mini-disc {
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--surface) 0 8%, var(--muted) 9% 30%, transparent 31%),
    repeating-radial-gradient(circle, var(--groove-a) 0 1px, var(--groove-b) 1px 2.5px);
  opacity: .5;
}
.import-table .status { white-space: nowrap; }
.is-busy .status { color: var(--accent); font-weight: 650; }
.is-busy .mini-disc { opacity: 1; animation: spin 1.2s linear infinite; }
.is-done .status a { color: var(--accent); }
.is-nocover .status a { color: var(--sticker-ink); background: var(--sticker); padding: .1rem .5rem; border-radius: 999px; text-decoration: none; font-weight: 650; }
.is-duplicate td { color: var(--muted); }
.is-error .status { color: var(--danger); }
@keyframes spin { to { transform: rotate(360deg); } }

.missing { margin: 3rem 0 5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); max-width: 52rem; }
.missing h2 { margin: 0 0 .25rem; font-size: 1.35rem; letter-spacing: -.02em; }
.missing p { margin: 0 0 .9rem; }

@media (max-width: 760px) {
  .import-source { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .is-busy .mini-disc { animation: none; }
}

/* ---------- Small screens & motion ---------- */

@media (max-width: 760px) {
  .record-form { grid-template-columns: 1fr; }
  .cover-panel { max-width: 320px; }
  .two { grid-template-columns: 1fr; }
  .crate { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 2.25rem 1.75rem; }
  .account .btn { padding-inline: .85rem; }
}

@media (prefers-reduced-motion: reduce) {
  .disc { transition: none; }
}
