/* tay13 styles. Colors are tokens on :root, with a dark theme below. */
:root {
  --bg: #f7f4f1;
  --surface: #ffffff;
  --surface-2: #f0ebe6;
  --text: #1f1b22;
  --muted: #6b6470;
  --line: #e3dcd5;
  --accent: #b23a63;
  --accent-ink: #ffffff;
  --accent-soft: #f8e4eb;
  --own: #2f7d5b;
  --own-soft: #e1f2e9;
  --want: #a65a00;
  --want-soft: #fbeedb;
  --list: #3a5fb0;
  --list-soft: #e3eafa;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgb(30 20 30 / 6%), 0 4px 14px rgb(30 20 30 / 6%);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  /* Glitter page: text that sits directly on the red background uses the on-bg colours. */
  --glitter-from: #7a0e20;
  --glitter-mid: #a8162c;
  --glitter-to: #d2452a;
  --on-bg: #fff6ec;
  --on-bg-muted: #ffd9cf;
  --on-bg-link: #ffd27a;
  --bar: rgb(70 6 18 / 78%);
  --scrim: 0 1px 2px rgb(60 0 10 / 55%), 0 0 18px rgb(60 0 10 / 35%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141217;
    --surface: #1d1a21;
    --surface-2: #26222b;
    --text: #eeeaf0;
    --muted: #a69fab;
    --line: #36313c;
    --accent: #e0668f;
    --accent-ink: #1a0d12;
    --accent-soft: #3a1f2a;
    --own: #5cc193;
    --own-soft: #173326;
    --want: #f0a54a;
    --want-soft: #382811;
    --list: #86a6ee;
    --list-soft: #1d2740;
    --danger: #f2817a;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 14px rgb(0 0 0 / 25%);
    --glitter-from: #3a0610;
    --glitter-mid: #5c0c1c;
    --glitter-to: #7e2416;
    --bar: rgb(30 4 10 / 82%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html { background: var(--glitter-mid); }
body {
  margin: 0;
  background: transparent;
  color: var(--text);
  font: 15px/1.5 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 16px 48px; }
main:focus { outline: none; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
/* Red glitter background: a fixed gradient plus two sparkle tiles that twinkle in turn. */
body::before, body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
body::before {
  background:
    url("glitter-a.png") 0 0 / 512px 512px repeat,
    radial-gradient(ellipse at 20% 0%, rgb(255 190 150 / 22%), transparent 55%),
    radial-gradient(ellipse at 90% 100%, rgb(255 140 60 / 25%), transparent 60%),
    linear-gradient(160deg, var(--glitter-from), var(--glitter-mid) 50%, var(--glitter-to));
}
body::after {
  background: url("glitter-b.png") 173px 91px / 512px 512px repeat;
  opacity: 0.3;
  animation: twinkle-b 4.2s ease-in-out infinite alternate;
}
@keyframes twinkle-b { from { opacity: 0.25; } to { opacity: 0.95; } }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; z-index: 50; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.loading { text-align: center; color: var(--on-bg); padding: 64px 16px; text-shadow: var(--scrim); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: var(--bar);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgb(255 210 122 / 35%);
}
.brand { font: 700 26px/1 var(--display); color: var(--on-bg); text-decoration: none; letter-spacing: -0.5px; }
.brand span { color: var(--on-bg-link); }
.topnav { margin-left: auto; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.topnav a, .topnav button {
  background: none; border: 0; padding: 7px 11px; border-radius: 8px; cursor: pointer;
  color: var(--on-bg); text-decoration: none; font-weight: 500;
}
.topnav a:hover, .topnav button:hover { background: rgb(255 255 255 / 14%); }
.topnav a[aria-current="page"] { background: rgb(255 255 255 / 18%); }
.topnav .btn-primary { background: var(--on-bg-link); color: #4a0d14; font-weight: 600; }
.topnav .btn-primary:hover { background: #ffe0a0; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 500; text-decoration: none;
  min-height: 38px;
}
.btn:hover { border-color: color-mix(in srgb, var(--text) 30%, var(--line)); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-small { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn-link { background: none; border: 0; color: var(--accent); padding: 0; cursor: pointer; text-decoration: underline; min-height: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label { display: block; font-weight: 500; font-size: 14px; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); min-height: 38px;
}
textarea { min-height: 70px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-error { color: var(--danger); font-size: 14px; margin: 0 0 10px; }
.form-error:empty { display: none; }

/* ---------- hero & filters ---------- */
.hero { padding: 28px 0 10px; }
.hero h1 { font: 600 clamp(26px, 4vw, 38px)/1.15 var(--display); margin: 0 0 6px; letter-spacing: -0.5px; color: var(--on-bg); text-shadow: var(--scrim); }
.hero p { margin: 0; color: var(--on-bg-muted); max-width: 680px; text-shadow: var(--scrim); }

.filters {
  position: sticky; top: 57px; z-index: 10;
  background: var(--surface);
  padding: 12px 14px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid; gap: 10px;
}
.filters > * { min-width: 0; }
.filters-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; min-width: 0; }
.filters input[type=search] { flex: 1 1 240px; }
.filters select { width: auto; flex: 0 1 auto; max-width: 100%; min-width: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; padding: 7px 12px; cursor: pointer; font-size: 14px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); }
.toggles { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; }
.summary { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.summary strong { color: var(--text); }
.filters-more summary { cursor: pointer; font-size: 14px; color: var(--muted); display: none; }

progress {
  appearance: none; -webkit-appearance: none;
  width: 120px; height: 7px; border: 0; border-radius: 9px; overflow: hidden;
  background: var(--surface-2); vertical-align: middle;
}
progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 9px; }
progress::-webkit-progress-value { background: var(--own); border-radius: 9px; }
progress::-moz-progress-bar { background: var(--own); border-radius: 9px; }

/* ---------- era sections & cards ---------- */
.era { margin-top: 28px; }
.era-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.era-head h2 { font: 600 22px/1.2 var(--display); margin: 0; color: var(--on-bg); text-shadow: var(--scrim); }
.era-head .count { color: var(--on-bg-muted); font-size: 14px; display: flex; align-items: center; gap: 8px; text-shadow: var(--scrim); }
.era-head progress { background: rgb(255 255 255 / 25%); }
.era-head progress::-webkit-progress-bar { background: rgb(255 255 255 / 25%); }
.era-head progress::-webkit-progress-value { background: var(--on-bg-link); }
.era-head progress::-moz-progress-bar { background: var(--on-bg-link); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow);
  position: relative;
}
.card.is-owned { border-color: color-mix(in srgb, var(--own) 55%, var(--line)); }
.card-img { border: 0; padding: 0; background: var(--surface-2); cursor: pointer; aspect-ratio: 1; width: 100%; display: block; overflow: hidden; }
.card-img img { width: 100%; height: 100%; object-fit: cover; }
.noimg { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 13px; padding: 12px; text-align: center; }
.card-body { padding: 10px 11px 6px; flex: 1; display: grid; align-content: start; gap: 2px; }
.card-title { margin: 0; font-size: 14.5px; font-weight: 600; }
.card-title button { all: unset; cursor: pointer; }
.card-title button:hover { text-decoration: underline; }
.card-title button:focus-visible { outline: 2px solid var(--accent); }
.card-variant { margin: 0; font-size: 13px; }
.card-meta { margin: 0; font-size: 12.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.badge { font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge-signed { background: var(--accent-soft); color: var(--accent); }
.badge-own { background: var(--own-soft); color: var(--own); }
.badge-want { background: var(--want-soft); color: var(--want); }
.badge-list { background: var(--list-soft); color: var(--list); }
.card-actions { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.card-actions button {
  border: 0; background: none; padding: 8px 4px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted);
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.card-actions button + button { border-left: 1px solid var(--line); }
.card-actions button:hover { background: var(--surface-2); color: var(--text); }
.card-actions .own[aria-pressed="true"] { color: var(--own); background: var(--own-soft); }
.card-actions .want[aria-pressed="true"] { color: var(--want); background: var(--want-soft); }
.card-listing { padding: 0 11px 10px; font-size: 12.5px; display: grid; gap: 4px; }
.card-listing .lst { background: var(--surface-2); border-radius: 7px; padding: 5px 7px; }
.card-match { position: absolute; top: 8px; left: 8px; }
.empty { text-align: center; padding: 48px 16px; color: var(--on-bg); text-shadow: var(--scrim); }
.empty .btn-link { color: var(--on-bg-link); }

/* ---------- dialogs ---------- */
.dlg {
  border: 0; border-radius: 16px; padding: 0; background: var(--surface); color: var(--text);
  box-shadow: 0 20px 60px rgb(0 0 0 / 30%);
  width: min(960px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
}
.dlg::backdrop { background: rgb(15 10 20 / 55%); }
.dlg-auth { width: min(440px, calc(100vw - 24px)); }
.dlg-head { display: flex; gap: 12px; align-items: flex-start; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.dlg-head h2 { margin: 0; font: 600 22px/1.2 var(--display); }
.dlg-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.dlg-close { margin-left: auto; flex: none; border: 0; background: var(--surface-2); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 18px; line-height: 1; }
.dlg-body { padding: 18px 20px 22px; }

.item-layout { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 24px; }
.item-media img { border-radius: 10px; background: var(--surface-2); width: 100%; }
.item-media .noimg { aspect-ratio: 1; border-radius: 10px; background: var(--surface-2); }
.item-media .seg { margin-top: 8px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.panel h3 { margin: 0 0 10px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.panel h3 .btn { margin-left: auto; }
.copy { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.copy:first-of-type { border-top: 0; padding-top: 0; }
.copy-info { flex: 1 1 200px; display: grid; gap: 2px; font-size: 14px; }
.copy-actions { display: flex; gap: 6px; }
.copy-form { background: var(--surface-2); border-radius: 10px; padding: 12px; margin-top: 10px; }
.copy-form input, .copy-form select, .copy-form textarea { background: var(--surface); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 5px 14px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
details.more { margin-top: 10px; font-size: 14px; }
details.more summary { cursor: pointer; font-weight: 600; }
.tracks { margin: 8px 0 0; padding: 0; list-style: none; columns: 2 220px; font-size: 13.5px; }
.tracks li { break-inside: avoid; display: flex; gap: 8px; padding: 1px 0; }
.tracks .pos { color: var(--muted); min-width: 28px; }
.tracks .dur { color: var(--muted); margin-left: auto; }
.pre { white-space: pre-wrap; font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.offer { padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.offer:first-of-type { border-top: 0; padding-top: 0; }

.tabs { display: flex; gap: 4px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: none; padding: 10px 10px; cursor: pointer; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

/* ---------- account & profile pages ---------- */
.page-head { padding: 28px 0 8px; }
.page-head { color: var(--on-bg); text-shadow: var(--scrim); }
.page-head h1 { font: 600 32px/1.15 var(--display); margin: 0 0 4px; }
.page-head p { margin: 2px 0; color: var(--on-bg-muted); }
.page-head a, #profileView > p.muted a { color: var(--on-bg-link); }
.page-head .btn { text-shadow: none; }
.page-head .btn-primary { background: var(--on-bg-link); border-color: var(--on-bg-link); color: #4a0d14; }
.page-head .btn-primary:hover { background: #ffe0a0; }
#profileView > p.muted { color: var(--on-bg-muted); text-shadow: var(--scrim); }
.notice { border-radius: var(--radius); padding: 12px 14px; margin: 14px 0; background: var(--want-soft); color: var(--text); border: 1px solid color-mix(in srgb, var(--want) 35%, transparent); }
.notice-info { background: var(--list-soft); border-color: color-mix(in srgb, var(--list) 35%, transparent); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 16px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font: 600 26px/1.1 var(--display); }
.stat span { color: var(--muted); font-size: 13px; }
.acct-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.box h2 { margin: 0 0 12px; font-size: 18px; }
.section-title { font: 600 22px/1.2 var(--display); margin: 28px 0 12px; display: flex; gap: 10px; align-items: baseline; color: var(--on-bg); text-shadow: var(--scrim); }
.section-title span { font: 400 14px var(--font); color: var(--on-bg-muted); }

/* ---------- toasts & footer ---------- */
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; animation: toast-in .2s ease-out; }
.toast-error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.footer { background: var(--bar); border-top: 1px solid rgb(255 210 122 / 30%); padding: 20px 16px 28px; text-align: center; color: var(--on-bg-muted); font-size: 13px; }
.footer a { color: var(--on-bg-link); }
.footer p { margin: 4px auto; max-width: 720px; }

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  .filters { top: 53px; position: static; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; }
  .item-layout { grid-template-columns: 1fr; }
  .item-media { max-width: 320px; margin: 0 auto; width: 100%; }
  .grid2 { grid-template-columns: 1fr; }
  .dlg { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100%; border-radius: 0; margin: 0; }
  .dlg-auth { height: auto; border-radius: 16px; margin: auto; width: calc(100vw - 24px); }
  .brand { font-size: 23px; }
  .topnav a, .topnav button { padding: 6px 8px; font-size: 14px; }
  .seg button { padding: 7px 9px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
  body::after { opacity: 0.6; }
}
.row > label { display: inline-flex; gap: 6px; align-items: center; }
