:root {
  /* Premier League brand palette: deep purple, magenta/pink, cyan */
  --pl-purple-950: #170025;
  --pl-purple-900: #240032;
  --pl-purple-800: #38003c;
  --pl-purple-700: #4e0a55;
  --pl-purple-600: #6a1b7a;
  --pl-magenta: #e90052;
  --pl-cyan: #04f5ff;

  --bg: var(--pl-purple-950);
  --panel: #2b0a3d;
  --panel-raised: #35104a;
  --border: #5c2569;
  --text: #ffffff;
  --text-dim: #c9a9d9;
  --text-faint: #9678ab;
  --accent: var(--pl-magenta);
  --accent-dim: rgba(233, 0, 82, 0.18);
  --accent2: var(--pl-cyan);
  --owned: var(--pl-cyan);
  --owned-bg: rgba(4, 245, 255, 0.14);
  --need-bg: #fff;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.3);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-body: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 15% -10%, var(--pl-purple-600), transparent 55%),
    radial-gradient(circle at 100% 0%, rgba(233, 0, 82, 0.25), transparent 45%),
    linear-gradient(165deg, var(--pl-purple-950), var(--pl-purple-800) 55%, var(--pl-purple-900));
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: 0.01em; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 13px 22px;
  background: rgba(23, 0, 37, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; }
.brand-text {
  display: flex;
  flex-direction: column;
  padding-left: 14px;
  border-left: 2px solid var(--accent);
}
.brand-line1 { display: flex; align-items: center; gap: 8px; }
.brand h1 {
  font-size: 19px;
  margin: 0;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.season-chip {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--pl-purple-950);
  background: var(--accent2);
  padding: 2px 7px 1px;
  border-radius: 4px;
  line-height: 1.4;
}
.subtitle { margin: 3px 0 0; font-size: 12px; color: var(--text-faint); font-weight: 500; }

.search-wrap { position: relative; flex: 1; max-width: 460px; }
.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-faint);
  pointer-events: none;
}
#search {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13.5px;
}
#search::placeholder { color: var(--text-faint); }
#search:focus { outline: none; border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(4,245,255,0.15); }

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 380px;
  overflow-y: auto;
  padding: 4px;
}
.search-result {
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  border-radius: 6px;
}
.search-result:hover { background: var(--accent-dim); }
.search-result .sr-main { font-weight: 600; }
.search-result .sr-meta { color: var(--text-faint); white-space: nowrap; font-size: 11.5px; }

.icon-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 13px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.icon-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
.icon-btn:hover { border-color: var(--accent2); }

.ghost-btn, .primary-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.ghost-btn:hover { color: var(--text); border-color: var(--accent2); }
.primary-btn { background: var(--accent); color: #fff; border: none; padding: 8px 16px; font-size: 13px; }
.primary-btn:hover { background: #c9004a; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: calc(100vh - 62px); }

.sidebar {
  width: 268px;
  flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,0.08);
  background: var(--panel);
  overflow-y: auto;
  max-height: calc(100vh - 62px);
  position: sticky;
  top: 62px;
}
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 13px 16px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  cursor: default;
  font-family: var(--font-display);
}
.overall-progress { font-variant-numeric: tabular-nums; color: var(--accent2); }
.sidebar-header-right { display: flex; align-items: center; gap: 8px; }
.sidebar-chevron { width: 14px; height: 14px; display: none; transition: transform 0.15s; }

.set-list { padding: 8px; }
.set-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 9px 11px;
  border-radius: 8px;
  border-left: 3px solid transparent;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.12s, border-color 0.12s;
}
.set-item:hover { background: rgba(255,255,255,0.04); border-left-color: var(--border); }
.set-item.active { background: var(--accent-dim); border-left-color: var(--accent); }
.set-item .si-top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; letter-spacing: 0.01em; }
.set-item.active .si-top { color: #fff; }
.set-item .si-bar {
  height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.set-item .si-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.set-item .si-count { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* ---------- Content / toolbar ---------- */
.content { flex: 1; padding: 20px 26px 64px; min-width: 0; }
.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}
.content-header h2 {
  margin: 0;
  font-size: 22px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.toolbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.set-progress-text {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent2);
  font-variant-numeric: tabular-nums;
}
.btn-group { display: flex; gap: 6px; }

.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.seg-btn {
  border: none;
  background: var(--panel);
  color: var(--text-dim);
  padding: 7px 14px;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.seg-btn.active { background: var(--accent); color: #fff; }

/* ---------- Flip / binder view ---------- */
.flip-view {
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 14px;
}
.flip-arrow {
  flex-shrink: 0;
  width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-dim);
  border-radius: 12px;
  cursor: pointer;
}
.flip-arrow svg { width: 20px; height: 20px; }
.flip-arrow:hover { color: var(--text); border-color: var(--accent2); }
.flip-arrow:disabled { opacity: 0.25; cursor: default; }
.flip-arrow:disabled:hover { border-color: var(--border); color: var(--text-dim); }

.binder {
  flex: 1;
  min-width: 0;
  display: flex;
  position: relative;
  background: linear-gradient(160deg, var(--pl-purple-700), var(--pl-purple-900) 55%, #12001c);
  border-radius: 22px;
  padding: 24px 16px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.5), inset 0 0 0 1px rgba(255,255,255,0.06);
  min-height: 600px;
}
.binder-spine {
  width: 26px;
  flex-shrink: 0;
  background:
    radial-gradient(circle, rgba(0,0,0,0.5) 3px, transparent 3.5px) 50% 6% / 100% 34px repeat-y,
    linear-gradient(90deg, var(--pl-magenta), var(--pl-purple-800) 35%, var(--pl-purple-800) 65%, var(--pl-cyan));
  border-radius: 4px;
  margin: 0 -2px;
  z-index: 2;
  opacity: 0.9;
}
.binder-page {
  flex: 1;
  min-width: 0;
  --panel: #fffaf0;
  --border: #e8ddc6;
  --text: #241d10;
  --text-dim: #6e6349;
  --text-faint: #9a8f74;
  --accent: #7a1653;
  --accent-dim: #f7e6ee;
  --accent2: #0f8f8a;
  --owned: #0f8f8a;
  --owned-bg: #e1f5f3;
  --need-bg: #fffaf0;
  background:
    linear-gradient(115deg, rgba(0,0,0,0.05) 0%, transparent 12%),
    var(--panel);
  color: var(--text);
  padding: 20px 22px;
  overflow-y: auto;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  transition: opacity 0.18s ease;
  min-height: 556px;
}
.binder-page-left { border-radius: 4px 14px 14px 4px; }
.binder-page-right { border-radius: 14px 4px 4px 14px; }
.binder-page.turning { opacity: 0; }
.binder-page.empty { display: flex; align-items: center; justify-content: center; color: var(--text-faint); font-size: 13px; font-style: italic; }

.flip-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 26px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-dim);
}
.mini-nav-btn {
  width: 26px; height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}
.mini-nav-btn:hover { color: var(--text); border-color: var(--accent2); }
.mini-nav-btn:disabled { opacity: 0.25; cursor: default; }
.mini-nav-btn:disabled:hover { border-color: var(--border); color: var(--text-dim); }
#pageIndicator { min-width: 190px; text-align: center; }
.flip-nav-divider { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.flip-nav input[type="number"] {
  width: 92px;
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
}
.flip-nav input[type="range"] { width: 160px; accent-color: var(--accent2); }

.pages { display: flex; flex-direction: column; gap: 22px; }
.page {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.page-label {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-faint);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pocket-grid { display: grid; gap: 12px; }

/* ---------- Checklist cover page ---------- */
.checklist-page .page-label { font-size: 20px; margin-bottom: 4px; color: var(--text); }
.checklist-page::before {
  content: "Season index";
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 2px;
}
.checklist-list {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}
.checklist-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 10px;
  border-bottom: 1px solid var(--border);
  padding: 9px 0;
}
.cl-top { grid-column: 1 / 2; display: flex; flex-direction: column; }
.cl-name { font-family: var(--font-display); font-size: 14px; font-weight: 700; letter-spacing: 0.01em; }
.cl-pages { font-size: 10.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.cl-bar { grid-column: 1 / 2; height: 4px; border-radius: 2px; background: rgba(0,0,0,0.08); overflow: hidden; margin-top: 5px; }
.cl-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.cl-count {
  grid-column: 2 / 3;
  grid-row: 1 / 3;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (min-width: 900px) {
  .checklist-list { grid-template-columns: 1fr 1fr; column-gap: 22px; }
}

/* ---------- Pocket card ---------- */
.pocket {
  min-width: 0;
  border: 1px solid var(--border);
  border-left: 3px solid var(--pocket-team, var(--border));
  border-radius: 7px;
  padding: 10px 12px;
  background: var(--need-bg);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 130px;
  transition: background 0.15s, border-color 0.15s;
  overflow: hidden;
}
.pocket.owned { background: var(--owned-bg); }
.pocket.highlight { box-shadow: 0 0 0 3px var(--accent2); }

.pocket-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; }
.slot-tag { font-size: 9.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.card-number {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.set-badge {
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  font-weight: 700;
}

.player-name { font-family: var(--font-display); font-size: 15px; font-weight: 700; line-height: 1.15; letter-spacing: 0.01em; }
.team-row { display: flex; align-items: center; gap: 6px; }
.team-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.team-name { font-size: 10.5px; color: var(--text-dim); font-weight: 500; }
.rookie-badge {
  font-size: 9px;
  font-weight: 700;
  color: #2b2417;
  background: linear-gradient(90deg, #ffd23f, #ffb703);
  padding: 1px 5px;
  border-radius: 4px;
  align-self: flex-start;
  letter-spacing: 0.03em;
}

.pocket-controls { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px; margin-top: auto; padding-top: 4px; border-top: 1px dashed var(--border); }
.owned-toggle { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--text-dim); cursor: pointer; }
.owned-toggle input { width: 14px; height: 14px; accent-color: var(--owned); cursor: pointer; }
.pocket.owned .owned-toggle { color: var(--owned); }

.dupe-stepper { display: flex; align-items: center; gap: 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.dupe-stepper button {
  width: 19px; height: 19px;
  border: none;
  background: var(--need-bg);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.dupe-stepper button:hover { background: var(--accent-dim); color: var(--accent); }
.dupe-stepper span { font-size: 11px; min-width: 16px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- Modal / toast ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal {
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  width: 320px;
  box-shadow: var(--shadow);
}
.modal.modal-wide { width: 420px; max-width: calc(100vw - 40px); }
.modal h3 { margin-top: 0; font-size: 17px; text-transform: uppercase; letter-spacing: 0.02em; }

.help-list {
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.help-list li {
  padding-left: 16px;
  border-left: 2px solid var(--accent);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
}
.help-list strong { color: var(--text); }
.modal label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: 12px; }
.modal input {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 7px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
}
.modal .hint { font-size: 12px; color: var(--text-faint); line-height: 1.5; }
.modal-actions { text-align: right; margin-top: 10px; }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--pl-purple-950);
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 700;
  box-shadow: var(--shadow);
  z-index: 60;
}

.site-footer {
  padding: 16px 26px 28px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-faint);
  max-width: 720px;
}

.hidden { display: none !important; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; position: static; max-height: none; }
  .sidebar-header { cursor: pointer; }
  .sidebar-chevron { display: block; }
  .sidebar:not(.expanded) .set-list { display: none; }
  .sidebar.expanded .set-list { max-height: 320px; overflow-y: auto; }
  .sidebar.expanded .sidebar-chevron { transform: rotate(180deg); }
  .topbar { flex-wrap: wrap; row-gap: 10px; padding: 10px 14px; }
  .brand-text { padding-left: 10px; }
  .brand h1 { font-size: 16px; }
  .subtitle { font-size: 11px; }

  /* Search gets its own full-width row; icon buttons shrink to icon-only so
     they don't crowd it out. */
  .search-wrap { order: 3; flex-basis: 100%; max-width: none; }
  .icon-btn span { display: none; }
  .icon-btn { padding: 9px; }

  /* The big side flip-arrows duplicate the compact prev/next in .flip-nav -
     drop them on narrow screens so the page itself gets the width instead. */
  .flip-arrow { display: none; }
  .binder { padding: 14px 10px; min-height: 0; }
  .binder-page { min-height: 0; padding: 14px; }
  .binder-page-left { display: none; }
  .binder-spine { display: none; }

  .flip-nav { flex-wrap: wrap; }
  .flip-nav input[type="range"] { width: 120px; }
  .content { padding: 14px 14px 40px; }
  .content-header h2 { font-size: 19px; }
  .site-footer { padding: 12px 14px 22px; }
}
