:root {
  --bg: #f6f4ef;
  --bg-elev: #ffffff;
  --bg-sunk: #ece9e1;
  --ink: #16181d;
  --ink-2: #4a4f5a;
  --ink-3: #80858f;
  --line: #dedad0;
  --accent: #b8862b;
  --accent-ink: #ffffff;
  --accent-soft: #f3e7cc;
  --danger: #c0392b;
  --ok: #2e8b57;
  --football: #2f7d4a;
  --basketball: #e0702a;
  --baseball: #c7373f;
  --shadow-sm: 0 1px 2px rgba(20, 20, 30, .06), 0 1px 1px rgba(20, 20, 30, .04);
  --shadow-md: 0 6px 18px rgba(20, 20, 30, .08), 0 2px 6px rgba(20, 20, 30, .05);
  --shadow-lg: 0 24px 60px rgba(20, 20, 30, .18), 0 8px 20px rgba(20, 20, 30, .08);
  --radius: 14px;
  --radius-sm: 9px;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Barlow Condensed", "Inter", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1015;
    --bg-elev: #171a21;
    --bg-sunk: #0a0b0f;
    --ink: #eef0f4;
    --ink-2: #b4b9c4;
    --ink-3: #7c8290;
    --line: #262a33;
    --accent: #e0b354;
    --accent-ink: #1a1405;
    --accent-soft: #2e2615;
    --football: #4fb873;
    --basketball: #f38a43;
    --baseball: #ec5a62;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 8px 22px rgba(0, 0, 0, .45);
    --shadow-lg: 0 30px 70px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1015;
  --bg-elev: #171a21;
  --bg-sunk: #0a0b0f;
  --ink: #eef0f4;
  --ink-2: #b4b9c4;
  --ink-3: #7c8290;
  --line: #262a33;
  --accent: #e0b354;
  --accent-ink: #1a1405;
  --accent-soft: #2e2615;
  --football: #4fb873;
  --basketball: #f38a43;
  --baseball: #ec5a62;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, .45);
  --shadow-lg: 0 30px 70px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg-elev); color: var(--ink);
  font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none;
  transition: transform .12s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.05); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-sunk); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-icon { width: 44px; padding: 0; }
.btn svg { width: 18px; height: 18px; flex: none; }

.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-elev); color: var(--ink);
  font-size: 16px; /* stops iOS zoom */
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2380858f' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.textarea { min-height: 80px; resize: vertical; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  background: var(--bg-sunk); color: var(--ink-2); white-space: nowrap;
}
.badge-rc { background: var(--accent); color: var(--accent-ink); }
.badge-auto { background: #6b4bd8; color: #fff; }
.badge-relic { background: #2d6fd2; color: #fff; }
.badge-grade { background: var(--ink); color: var(--bg); }
.badge-serial { background: var(--accent-soft); color: var(--accent); }

.sport-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.sport-football { --sport: var(--football); }
.sport-basketball { --sport: var(--basketball); }
.sport-baseball { --sport: var(--baseball); }
.sport-dot { background: var(--sport, var(--ink-3)); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px;
  font-weight: 600; box-shadow: var(--shadow-lg); z-index: 100;
  transition: opacity .2s ease, transform .2s ease; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
