/* myvinyl themes, all in Buffalo Bills colors (royal blue, navy, red, white).
   Pick one per user on the Profile page; "auto" follows the system: royal by day, navy at
   night. Red is only a background or border on blue, never text: red-on-blue text fails
   contrast. Every color below goes through a token so themes only redefine tokens. */

:root {
  --royal: #00338d;
  --navy: #0c2340;
  --red: #c60c30;
  --red-dark: #a00926;
  --white: #ffffff;

  /* Royal (default): royal-blue pages, red and white controls. */
  --page: var(--royal);
  --panel: #00296f;
  --panel-edge: rgba(255, 255, 255, 0.14);
  --bar: var(--navy);
  --bar-text: var(--white);
  --text: #ffffff;
  --muted: #c9d6f2;
  --strong: #ffffff;         /* stars, chart line, emphasis */
  --line: rgba(255, 255, 255, 0.16);
  --row-alt: rgba(255, 255, 255, 0.05);
  --row-hover: rgba(255, 255, 255, 0.11);
  --input-bg: #ffffff;
  --input-fg: var(--navy);
  --input-border: #ffffff;
  --link: #ffffff;
  --btn-border: #ffffff;
  --outline-text: #ffffff;
  --outline-hover-bg: #ffffff;
  --outline-hover-text: var(--royal);
  --chip-border: #ffffff;
  --chip-text: #ffffff;
  --notice-bg: #ffffff;
  --notice-text: var(--navy);
  --chosen: rgba(198, 12, 48, 0.28);
  --gain: #8ef0b0;
  --loss: #ffb3c1;
  --tile-blank: var(--navy);
  --shadow: 0 8px 24px rgba(0, 10, 40, 0.35);
  color-scheme: dark;
}

/* Navy: deep navy pages with a royal header. Also "auto" at night. */
:root[data-theme="navy"] {
  --page: var(--navy);
  --panel: #11305a;
  --bar: var(--royal);
  --muted: #b4c3e0;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --page: var(--navy);
    --panel: #11305a;
    --bar: var(--royal);
    --muted: #b4c3e0;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  }
}

/* Light: white pages and panels, royal header, navy text, red buttons. */
:root[data-theme="light"] {
  --page: #f7f9fd;
  --panel: #ffffff;
  --panel-edge: #d6deef;
  --bar: var(--royal);
  --text: var(--navy);
  --muted: #4a5876;
  --strong: var(--royal);
  --line: #dfe5f1;
  --row-alt: #f3f6fc;
  --row-hover: #e8eefb;
  --input-border: #b8c4dd;
  --link: var(--royal);
  --btn-border: var(--red);
  --outline-text: var(--royal);
  --outline-hover-bg: var(--royal);
  --outline-hover-text: #ffffff;
  --chip-border: var(--royal);
  --chip-text: var(--navy);
  --notice-bg: #eef3fc;
  --chosen: rgba(198, 12, 48, 0.12);
  --gain: #0b7a3b;
  --loss: var(--red);
  --tile-blank: #dfe5f1;
  --shadow: 0 6px 18px rgba(12, 35, 64, 0.10);
  color-scheme: light;
}

/* Gray: light-gray pages, near-white panels, navy header. */
:root[data-theme="gray"] {
  --page: #e6e9ee;
  --panel: #f5f6f8;
  --panel-edge: #cfd5de;
  --bar: var(--navy);
  --text: var(--navy);
  --muted: #4d5a70;
  --strong: var(--royal);
  --line: #d3d8e0;
  --row-alt: #eceef2;
  --row-hover: #e1e5ec;
  --input-border: #aab3c2;
  --link: var(--royal);
  --btn-border: var(--red);
  --outline-text: var(--navy);
  --outline-hover-bg: var(--navy);
  --outline-hover-text: #ffffff;
  --chip-border: var(--navy);
  --chip-text: var(--navy);
  --notice-bg: #ffffff;
  --chosen: rgba(198, 12, 48, 0.12);
  --gain: #0b7a3b;
  --loss: var(--red);
  --tile-blank: #d3d8e0;
  --shadow: 0 6px 18px rgba(12, 35, 64, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* --- Top bar: a red-white-red helmet stripe under the header ---------------------------- */

.bar {
  background: var(--bar);
  border-bottom: 4px solid var(--red);
  box-shadow: 0 4px 0 var(--white), 0 8px 0 var(--red), var(--shadow);
  margin-bottom: 36px;
}
header, main { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
main { padding-bottom: 48px; }
header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; min-height: 64px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--bar-text);
  font-size: 1.35rem;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
}
.brand-logo { display: block; width: 34px; height: 34px; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding: 8px 0; }
.nav a, .bar button.link { color: var(--bar-text); font-weight: 700; text-decoration-color: var(--red); }
.nav form { margin: 0; }

.viewing {
  background: var(--red);
  color: var(--white);
  text-align: center;
  padding: 8px 16px;
  margin: -28px 0 24px;
  font-weight: 600;
}
.viewing form { margin: 0; }
.viewing button.link { color: var(--white); text-decoration-color: var(--white); }

/* --- Type ------------------------------------------------------------------------------ */

h1 { margin: 0 0 8px; font-size: 1.6rem; font-weight: 800; letter-spacing: 0.01em; }
h2 {
  margin: 0 0 12px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
a { color: var(--link); text-decoration-color: var(--red); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
code { font-size: 0.9em; }
.small { margin-left: 8px; font-size: 0.75rem; letter-spacing: 0.04em; text-transform: none; }
.muted, .hint, .meta { color: var(--muted); }
.hint { margin: 6px 0 0; font-size: 0.85rem; }
.meta { margin-top: 32px; font-size: 0.8rem; }
.prewrap { white-space: pre-wrap; margin: 0; }
.empty { padding: 32px; text-align: center; background: var(--panel); border-radius: 12px; border: 2px dashed var(--line); }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.plain { margin: 0 0 12px; padding: 0; list-style: none; }
.plain li { padding: 3px 0; }

/* --- Controls: red and white ---------------------------------------------------------- */

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--input-border);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--input-fg);
  font: inherit;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 2px;
}

button, .button, .button-outline {
  display: inline-block;
  padding: 10px 18px;
  border: 2px solid var(--btn-border);
  border-radius: 8px;
  background: var(--red);
  color: var(--white);
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}
button:hover, .button:hover { background: var(--white); color: var(--red); }
:root[data-theme="light"] button:hover, :root[data-theme="light"] .button:hover,
:root[data-theme="gray"] button:hover, :root[data-theme="gray"] .button:hover {
  background: var(--red-dark); color: var(--white);
}
.button-outline { background: transparent; color: var(--outline-text); border-color: var(--outline-text); }
.button-outline:hover { background: var(--outline-hover-bg); color: var(--outline-hover-text); }
button:disabled { opacity: 0.5; cursor: wait; }

button.link {
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  text-decoration: underline;
  text-decoration-color: var(--red);
}
button.link:hover { color: var(--text); background: none; }
button.link.danger-link { color: var(--loss); }
.button-small { padding: 4px 10px; font-size: 0.75rem; box-shadow: none; }

.chip {
  display: inline-block;
  padding: 2px 10px;
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  color: var(--chip-text);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.chip-red { background: var(--red); border-color: var(--red); color: var(--white); }

.toggle {
  padding: 6px 12px;
  border: 2px solid var(--outline-text);
  border-radius: 8px;
  color: var(--outline-text);
  font-weight: 700;
  text-decoration: none;
}
.toggle.on { background: var(--outline-hover-bg); color: var(--outline-hover-text); }
.spacer { flex: 1; }

/* --- Collection -------------------------------------------------------------------------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat, .card, .panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-top: 5px solid var(--red);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.stat { padding: 16px 20px; }
.stat-num { display: block; font-size: 1.6rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 0 0 16px; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 16px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
}
.filters input, .filters select { width: auto; padding: 6px 8px; font-size: 0.9rem; }
.filters .filter-q { flex: 1 1 220px; }
.filters .filter-money { width: 90px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-bottom: 4px solid var(--red);
}
th a { text-decoration: none; }
tbody tr:nth-child(even) { background: var(--row-alt); }
tbody tr:hover { background: var(--row-hover); }
td.wrap { white-space: normal; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.range { display: block; color: var(--muted); font-size: 0.75rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.row-actions form, form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
form.inline select { width: auto; padding: 4px 6px; }
form.inline .rename-input { width: 140px; padding: 4px 6px; }
form.inline .email-input { width: 210px; padding: 4px 6px; }
.identity-form { flex-wrap: wrap; }

.cover-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.tile {
  display: block;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  box-shadow: var(--shadow);
}
.tile:hover { outline: 3px solid var(--red); }
.tile img, .tile-blank { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
.tile-blank { display: grid; place-items: center; background: var(--tile-blank); }
.tile-blank span {
  width: 70%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, var(--white) 0 3%, var(--red) 4% 30%, #151515 31% 100%);
}
.tile-text { display: block; padding: 10px 12px; color: var(--text); }
.tile-text strong, .tile-text span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-text span { color: var(--muted); font-size: 0.85rem; }
.tile-meta { margin-top: 4px; }

/* --- Album page ------------------------------------------------------------------------- */

.album-head { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-end; margin-bottom: 24px; }
.cover {
  width: 180px;
  height: 180px;
  object-fit: cover;
  border: 4px solid var(--white);
  border-radius: 6px;
  box-shadow: 8px 8px 0 var(--red);
}
.cover-blank { display: grid; place-items: center; background: var(--navy); }
.cover-blank span {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--page) 0 4px, var(--red) 5px 34px, var(--white) 35px 37px,
      #151515 38px 46px, #262626 47px 48px, #151515 49px 58px, #262626 59px 60px, #151515 61px 100%);
}
.album-title { flex: 1; min-width: 240px; }
.album-title h1 { font-size: 2.2rem; line-height: 1.15; }
.eyebrow { margin: 0; color: var(--muted); font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 16px; }
.actions form { margin: 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 16px; }
.card { padding: 18px 20px; }
.card-value { border-top-color: var(--strong); }
.big { margin: 0; font-size: 1.8rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.big small { font-size: 0.9rem; font-weight: 600; color: var(--muted); }

.panel { padding: 20px; margin-bottom: 16px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; margin: 0; }
.facts dt { color: var(--muted); font-weight: 700; }
.facts dd { margin: 0; }
.more { margin-top: 12px; }
.more summary { cursor: pointer; color: var(--muted); font-weight: 700; }
.more .facts { margin-top: 10px; }
tr.chosen, tr.deal { background: var(--chosen) !important; }
.tracks .pos { width: 48px; color: var(--muted); font-weight: 700; }
.credits { columns: 2 260px; margin: 0; padding: 0; list-style: none; }
.credits li { break-inside: avoid; padding: 3px 0; }
.credits span { color: var(--muted); }

.journal { margin: 16px 0 0; padding: 0; list-style: none; }
.journal li { padding: 10px 0; border-top: 1px solid var(--line); }
.journal .when { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 0.8rem; }
.journal .when form { margin: 0; }

.notice {
  padding: 12px 16px;
  border-left: 6px solid var(--red);
  border-radius: 6px;
  background: var(--notice-bg);
  color: var(--notice-text);
  font-weight: 600;
}
.notice a { color: var(--royal); }

.art-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.art-grid form { margin: 0; }
button.art {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 3px solid transparent;
  border-radius: 8px;
  background: var(--navy);
  box-shadow: none;
  overflow: hidden;
}
button.art:hover { background: var(--navy); border-color: var(--strong); }
button.art img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; }
button.art-selected { border-color: var(--red); box-shadow: 0 0 0 2px var(--white); }
.art-tag {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--red);
  color: var(--white);
  font-size: 0.7rem;
}

/* --- Forms ------------------------------------------------------------------------------ */

.narrow { max-width: 600px; }
.narrow label, .panel label {
  display: block;
  margin: 16px 0 6px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.login { margin: 48px auto; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.danger { margin-top: 20px; }
.error {
  display: inline-block;
  margin: 6px 0 0;
  padding: 2px 10px;
  border-radius: 6px;
  background: var(--red);
  color: var(--white);
  font-size: 0.85rem;
  font-weight: 700;
}
.callout { margin: 8px 0 4px; padding: 4px 16px 14px; border: 2px dashed var(--line); border-radius: 10px; }
.link-box { font-family: ui-monospace, monospace; font-size: 0.85rem; }
.got-form { display: flex; gap: 6px; align-items: center; margin: 0; }
.got-form select, .got-form input { width: auto; padding: 4px 6px; font-size: 0.85rem; }
.got-form input { width: 80px; }
.theme-choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.panel label.theme-choice {
  display: flex; gap: 8px; align-items: center; margin: 0; padding: 10px;
  border: 2px solid var(--line); border-radius: 10px; cursor: pointer;
  color: var(--text); font-size: 0.9rem; font-weight: 600; letter-spacing: 0; text-transform: none;
}
.panel label.theme-choice:has(input:checked) { border-color: var(--red); }
.theme-choice input { width: auto; flex: none; }
.swatch { flex: none; }
.swatch { display: inline-block; width: 28px; height: 28px; border-radius: 6px; border: 2px solid var(--red); }
.swatch-auto { background: linear-gradient(135deg, #00338d 50%, #0c2340 50%); }
.swatch-royal { background: #00338d; }
.swatch-navy { background: #0c2340; }
.swatch-light { background: #ffffff; }
.swatch-gray { background: #e6e9ee; }

/* --- Ratings, picks, history ------------------------------------------------------------ */

.stars-big { margin: 0 0 8px; font-size: 1.4rem; letter-spacing: 0.08em; color: var(--strong); }
.stars-cell { white-space: nowrap; letter-spacing: 0.05em; }
.track-note { display: block; color: var(--muted); font-size: 0.85rem; }
.review-row { max-width: 260px; margin-bottom: 10px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.inline-note { margin: 0 0 12px; color: var(--muted); }
.track-form select { min-width: 150px; }
.track-form input { min-width: 220px; }

.chart { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 12px; }
.chart .band { fill: var(--red); fill-opacity: 0.35; }
.chart .line { fill: none; stroke: var(--strong); stroke-width: 3; stroke-linejoin: round; }
.chart .dot { fill: var(--strong); stroke: var(--red); stroke-width: 2; }

/* --- Stats ------------------------------------------------------------------------------ */

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.bars th { width: 35%; font-size: 0.85rem; letter-spacing: 0; text-transform: none; border-bottom: 1px solid var(--line); white-space: normal; }
.bar-cell { width: 45%; }
.barline { display: block; width: 100%; height: 12px; }
.barline rect { fill: var(--red); }

/* --- Footer ------------------------------------------------------------------------------ */

.site-footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}
.site-footer a { color: var(--muted); }

/* --- Printed report ----------------------------------------------------------------------- */

.report-head { display: flex; gap: 16px; align-items: center; margin: 16px 0; }
.report-head p { margin: 0; color: var(--muted); }
.report-totals { width: auto; margin-bottom: 16px; }
.report-totals th { border-bottom: 1px solid var(--line); }
.report-table .thumb { width: 52px; }
.report-table .thumb img { width: 44px; height: 44px; object-fit: cover; display: block; }
.report-table td { white-space: normal; }
.report-foot { margin-top: 16px; color: var(--muted); font-size: 0.8rem; }

@media print {
  :root, :root[data-theme] {
    --page: #ffffff; --panel: #ffffff; --text: #000000; --muted: #444444; --line: #bbbbbb;
    --row-alt: #f4f4f4; --row-hover: transparent; --link: #000000; --strong: #000000;
    --shadow: none;
  }
  body { font-size: 11px; }
  .bar, .viewing, .no-print, .toolbar, .filters, .nav, button, .button, .button-outline { display: none !important; }
  main { max-width: none; padding: 0; }
  a { text-decoration: none; }
  th { border-bottom: 2px solid #000; }
  tr { break-inside: avoid; }
  .panel, .stat, .card { box-shadow: none; border: 1px solid #bbb; }
}

@media (max-width: 560px) {
  .row { grid-template-columns: 1fr; }
  .album-title h1 { font-size: 1.7rem; }
  .cover { width: 140px; height: 140px; }
  .cover-blank span { width: 120px; height: 120px; }
  .two-col, .stats-grid { grid-template-columns: 1fr; }
}
