/* ── Theme tokens — Coral (yapg4) ─────────────────────────────
   The app chrome (header / sidebar / canvas) is themed via CSS
   custom properties. The printable cards stay white regardless.  */
:root {
  --bg:           #14141c;
  --panel:        #1c1c28;
  --panel-2:      #242433;
  --border:       #2e2e40;
  --text:         #ececf1;
  --muted:        #9a9ab0;
  --faint:        #6a6a82;
  --accent:       #ff5c5c;
  --accent-2:     #ff8a6b;
  --accent-hover: #ff7373;
  --on-accent:    #ffffff;
  --input-bg:     #242433;
  --input-border: #353548;
  --header-bg:    #16161f;
  --shadow:       0 2px 10px rgba(0,0,0,0.45);
  --radius:       10px;
  --radius-sm:    7px;
  --border-w:     1px;
}

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

/* ── Layout ───────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; min-height: 100vh; }

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--header-bg);
  border-bottom: var(--border-w) solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}

.header-title { display: flex; align-items: center; gap: 12px; }

.header-logo {
  height: 46px;
  width: auto;
  display: block;
}

/* ── Layout ───────────────────────────────────────────────── */
.layout { display: flex; flex: 1; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: 244px;
  min-width: 244px;
  background: var(--panel);
  border-right: var(--border-w) solid var(--border);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  height: calc(100vh - 67px);
  position: sticky;
  top: 67px;
}

.control-group { display: flex; flex-direction: column; gap: 7px; }

.group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}

.tabs { display: flex; gap: 6px; }

.tab {
  flex: 1;
  padding: 8px 4px;
  border: var(--border-w) solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s;
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.tab:hover:not(.active) { border-color: var(--accent); color: var(--text); }

select, input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  background: var(--input-bg);
  border: var(--border-w) solid var(--input-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

select:focus, input[type="number"]:focus { border-color: var(--accent); }

.range-row { display: flex; gap: 8px; }

.input-pair { flex: 1; display: flex; flex-direction: column; gap: 4px; }

.input-pair label { font-size: 11px; color: var(--faint); }

.checkbox-list { display: flex; flex-direction: column; gap: 7px; }

.checkbox-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}

.checkbox-list input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

input[type="range"] {
  width: 100%;
  height: 4px;
  accent-color: var(--accent);
  cursor: pointer;
  background: var(--input-bg);
  border: none;
  padding: 0;
  border-radius: 2px;
}

.btn-generate {
  width: 100%;
  padding: 11px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: var(--on-accent);
  border: var(--border-w) solid transparent;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s, box-shadow 0.15s;
  margin-top: 4px;
  letter-spacing: 0.3px;
}

.btn-generate:hover { filter: brightness(1.06); box-shadow: var(--shadow); }
.btn-generate:active { transform: scale(0.97); }
.btn-generate:disabled { background: var(--faint); cursor: not-allowed; filter: none; box-shadow: none; }

.btn-print {
  padding: 8px 16px;
  background: transparent;
  color: var(--text);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-print:hover { border-color: var(--accent); color: var(--accent); }

.btn-return {
  margin-top: auto;
  display: block;
  text-align: center;
  text-decoration: none;
  padding: 9px 14px;
  background: transparent;
  color: var(--muted);
  border: var(--border-w) solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-return:hover { border-color: var(--accent); color: var(--accent); }

/* ── Progress ─────────────────────────────────────────────── */
.progress-container { display: flex; flex-direction: column; gap: 6px; }

.progress-bar {
  height: 6px;
  background: var(--input-bg);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: 0%;
  transition: width 0.2s;
}

.progress-text { font-size: 11px; color: var(--faint); text-align: center; }

/* ── Main content ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  background: var(--bg);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--faint);
  padding: 80px 20px;
  text-align: center;
}

.empty-icon { font-size: 64px; opacity: 0.5; }

.empty-state p { font-size: 15px; }

.empty-state strong { color: var(--accent); }

/* ── Card Grid ────────────────────────────────────────────── */
.card-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

/* ── Card ─────────────────────────────────────────────────── */
.pkmn-card {
  width: 63mm;
  height: 88mm;
  border-radius: 4mm;
  background: #fff;
  border: 0.5mm solid #d0d0d0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  page-break-inside: avoid;
  break-inside: avoid;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.card-type-bar {
  height: 5px;
  width: 100%;
  flex-shrink: 0;
}

.card-image-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4mm 3mm 2mm;
  overflow: hidden;
}

.card-image-area img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.card-image-area img.silhouette {
  filter: brightness(0);
}

.pokeball-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.pokeball-icon svg {
  width: 100%;
  height: 100%;
}

.card-info {
  padding: 2mm 3mm 3mm;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2mm;
  background: #fff;
}

.card-number {
  font-size: 9pt;
  color: #888;
  font-weight: 500;
  line-height: 1;
}

.card-name {
  font-size: 11pt;
  font-weight: 700;
  color: #222;
  text-align: center;
  line-height: 1.2;
  word-break: break-word;
}

.card-types {
  display: flex;
  gap: 2mm;
  flex-wrap: wrap;
  justify-content: center;
}

.type-badge {
  display: inline-block;
  padding: 1mm 2.5mm;
  border-radius: 2mm;
  color: #fff;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.set-info {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
  text-align: center;
  padding: 4px 8px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: var(--border-w) solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: var(--radius-sm);
}

.range-sublabel { margin-top: 6px; }

.set-logo {
  width: calc(88% * var(--logo-scale, 1));
  height: auto;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.cover-info { gap: 1mm; }
.cover-line { font-size: 12pt; font-weight: 700; color: #222; }

.rarity-badge {
  display: inline-block;
  padding: 1mm 2.5mm;
  border-radius: 2mm;
  color: #222;
  background: #fff;
  border: 0.3mm solid #ccc;
  font-size: 7pt;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  line-height: 1;
  margin-top: 1mm;
}

.card-image-area.split-layout {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  padding: 4mm 3mm 0;
}

.card-image-area.pokemon-only-layout {
  justify-content: flex-end;
  padding-bottom: 0;
}

.set-logo-small {
  width: calc(68% * var(--logo-scale, 1));
  height: auto;
  max-height: calc(34% * var(--logo-scale, 1));
  object-fit: contain;
  flex-shrink: 0;
  margin-bottom: auto;
}

.card-pokemon-art {
  width: 62%;
  height: auto;
  max-height: 52%;
  object-fit: contain;
  flex-shrink: 0;
}

/* ── Set Checklist ────────────────────────────────────────── */
.set-checklist {
  width: 100%;
  flex-basis: 100%;
  background: #fff;
  color: #222;
  border-radius: 4mm;
  padding: 6mm 7mm;
  margin-top: 8px;
}

.checklist-title {
  font-size: 16pt;
  font-weight: 800;
  text-align: center;
  margin-bottom: 5mm;
  color: #111;
}

.checklist-grid {
  column-count: 3;
  column-gap: 8mm;
}

.checklist-row {
  display: flex;
  align-items: baseline;
  gap: 2mm;
  font-size: 9.5pt;
  padding: 0.8mm 0;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  cursor: pointer;
  color: #222;
}

.checklist-box {
  width: 3.6mm;
  height: 3.6mm;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
  align-self: center;
}

.cl-num {
  color: #888;
  font-variant-numeric: tabular-nums;
  font-size: 8pt;
  flex-shrink: 0;
}

.cl-name { flex: 1; font-weight: 600; }

.cl-rarity {
  color: #aaa;
  font-size: 7pt;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Welcome overlay ──────────────────────────────────────── */
.welcome-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  background: rgba(10, 10, 16, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.welcome-card {
  width: min(440px, 92vw);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel);
  border: var(--border-w) solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 16px;
  padding: 26px 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.welcome-logo {
  height: 54px;
  width: auto;
  margin: 0 auto 2px;
  display: block;
}

.welcome-heading {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.3px;
}

.welcome-body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}

.welcome-divider {
  width: 100%;
  border: none;
  border-top: var(--border-w) solid var(--border);
  margin: 2px 0;
}

.welcome-updates {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  font-size: 13.5px;
  color: var(--text);
}

.welcome-updates-label { font-weight: 700; color: var(--muted); }

.welcome-share {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.welcome-btn {
  width: 100%;
  margin-top: 6px;
}

/* ── Utility ──────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Print ────────────────────────────────────────────────── */
@media print {
  @page {
    size: A4;
    margin: 5mm;
  }

  body { background: #fff; }

  .no-print { display: none !important; }

  .welcome-overlay { display: none !important; }

  .layout { display: block; }

  .main-content {
    padding: 0;
    overflow: visible;
    background: #fff;
  }

  .card-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2mm;
    justify-content: flex-start;
  }

  .pkmn-card {
    box-shadow: none;
    border-color: #ccc;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .empty-state { display: none; }

  /* Checklist prints on its own page after the cards */
  .set-checklist {
    break-before: page;
    page-break-before: always;
    padding: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .checklist-box {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
