/* Sideboard Guide Builder — custom styles layered on USWDS */

:root {
  /* Printed card dimensions: a bare MTG card (63mm x 88mm). Used by both
     the on-screen preview (.print-card) and the print layout, so the two
     always agree. Change here to change the printed size everywhere. */
  --card-w: 63mm;
  --card-h: 88mm;

  --mtg-white: #f7f7f2;
  --mtg-blue: #4a90d9;
  --mtg-black: #2a2a2a;
  --mtg-red: #d9462b;
  --mtg-green: #4a8a4a;
  --mtg-gold: #c9a94a;
  --mtg-colorless: #9a9a9a;

  /* "Forge" palette: warm-cool dark, lifted one notch brighter. Print
     cards intentionally do NOT use these; they stay black-on-white
     because they go on paper. */
  --site-bg: #22242c;
  --site-surface: #2c2f38;
  --site-surface-alt: #343843;
  --site-surface-hi: #3e4350;
  --site-border: #4a5062;
  --site-border-soft: #3a3f4d;
  --site-text: #ebe7df;
  --site-text-muted: #a9a597;
  --site-accent: #c8804a;
  --site-accent-hover: #d99163;
}

body {
  background: var(--site-bg);
  color: var(--site-text);
  font-family: "Source Pro", "Source Sans Pro", "Helvetica Neue", Arial, sans-serif;
}

/* Dark overrides for USWDS defaults. */
.usa-intro { color: var(--site-text-muted); }

.grid-container {
  max-width: min(1600px, 96vw);
}

.usa-label,
.usa-hint {
  color: var(--site-text);
}

.usa-hint { color: var(--site-text-muted); }

.usa-textarea,
.usa-input,
.usa-select {
  background: var(--site-surface);
  color: var(--site-text);
  border-color: var(--site-border);
}

/* The deck textarea is monospace and dense. Give it a light parchment
   surface with near-black text so long lists stay crisp and readable. */
#decklist-input,
.deck-input textarea {
  background: #ebe7df;
  color: #14161c;
  border: 1px solid #14161c;
  caret-color: #14161c;
}

#decklist-input::placeholder,
.deck-input textarea::placeholder {
  color: #6a6a60;
}

.usa-textarea:focus,
.usa-input:focus,
.usa-select:focus {
  border-color: var(--site-accent);
  outline: 2px solid var(--site-accent);
  outline-offset: 0;
}

.usa-button {
  background: var(--site-accent);
  color: #1a1a1a;
}

.usa-button:hover {
  background: var(--site-accent-hover);
}

.usa-button--outline {
  background: transparent;
  color: var(--site-text);
  border: 1px solid var(--site-border);
  box-shadow: none;
}

.usa-button--outline:hover {
  background: var(--site-surface-alt);
  color: var(--site-text);
}

.usa-button--unstyled {
  background: transparent;
  color: var(--site-text-muted);
}

.usa-button--unstyled:hover {
  background: transparent;
  color: var(--site-text);
}

.site-header {
  border-bottom-color: var(--site-accent);
  box-shadow: 0 1px 0 rgba(200, 128, 74, 0.25);
}

.site-header h1 {
  color: var(--site-text);
}

/* Site title is a reset link back to the app root. Keeps the same
   visual weight as a heading but adds a subtle hover affordance. */
.site-title-link {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  transition: color 0.15s;
}

.site-title-link:hover {
  color: var(--site-accent);
}

/* Placeholder logo mark in front of the site title. */
.site-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: var(--site-accent);
  transition: transform 0.2s, color 0.15s;
}

.site-title-link:hover .site-logo {
  color: inherit;
  transform: rotate(-4deg);
}

.site-logo svg {
  display: block;
}

.site-title-text {
  display: inline-block;
}

.site-header {
  padding: 1.5rem 0 1rem;
  border-bottom: 4px solid var(--mtg-gold);
  margin-bottom: 1.5rem;
}

.site-header h1 {
  margin: 0 0 0.25rem;
  font-size: 2rem;
}

.usa-intro {
  margin: 0;
  color: #555;
}

/* Deck input */
.deck-input {
  margin-bottom: 0.75rem;
}

.deck-input-collapsed {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  border-radius: 8px;
  flex-wrap: wrap;
}

.deck-input-summary {
  flex: 1 1 auto;
  font-size: 0.9rem;
  color: var(--site-text);
}

.deck-input-reset-link {
  color: var(--site-text-muted) !important;
  font-size: 0.85rem;
  text-decoration: underline !important;
  background: none !important;
  border: none !important;
  padding: 0.25rem 0.5rem !important;
}

.deck-input-grid {
  display: grid;
  /* The card hugs its content: button panel (14rem) + textarea (<=300px),
     nothing more. The right edge of the card lands just past the
     textarea, so the space between the card and the preview pane is the
     page background rather than more charcoal. fit-content makes the
     grid sized to its columns instead of filling the workspace column. */
  grid-template-columns: 14rem minmax(0, 300px);
  width: fit-content;
  gap: 1rem;
  align-items: stretch;
  background: var(--site-surface-alt);
  border: 1px solid var(--site-border-soft);
  border-radius: 6px;
  padding: 0.75rem;
}

@media (max-width: 640px) {
  .deck-input-grid {
    grid-template-columns: 1fr;
    /* Stacked: a little gap between the textarea and the button panel,
       since they no longer share a visible internal divider. */
    gap: 0.75rem;
  }
}

/* On mid-width screens the sidebar may be too wide for a narrow
   workspace; stack them vertically before things get crushed. */
@media (max-width: 1200px) {
  .deck-input-grid {
    grid-template-columns: 1fr;
  }
}

.deck-input-textarea-wrap {
  position: relative;
  min-width: 0;
}

.deck-input-textarea-wrap.drag-over::after {
  content: "Drop decklist file";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(74, 144, 217, 0.12);
  border: 2px dashed var(--mtg-blue);
  border-radius: 4px;
  font-weight: 700;
  color: var(--mtg-blue);
  pointer-events: none;
}

.deck-input-side {
  /* No surface of its own now -- the background, border, and radius live
     on .deck-input-grid so the panel and the empty third column share one
     continuous charcoal area. This is just the content column. */
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.deck-input-file-hidden {
  display: none;
}

.deck-input-upload-btn,
.deck-input-paste-btn {
  width: 100%;
  font-size: 0.9rem;
}

.deck-input-example-btn {
  width: 100%;
  font-size: 0.85rem;
}

.deck-input-side-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--site-text-muted);
  line-height: 1.3;
}

.deck-input-side-divider {
  border: none;
  border-top: 1px solid var(--site-border-soft);
  margin: 0.25rem 0;
}

.deck-input-file-error {
  margin-top: 0.5rem;
  padding: 0.5rem 0.6rem;
  font-size: 0.78rem;
  color: #f4c0b8;
  background: rgba(200, 60, 50, 0.18);
  border: 1px solid rgba(200, 60, 50, 0.45);
  border-radius: 4px;
  line-height: 1.35;
}

.deck-input textarea {
  font-family: "Courier New", monospace;
  font-size: 0.85rem;
  min-height: 16rem;
  width: 100%;
  box-sizing: border-box;
}

.deck-input-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  align-items: center;
}

.parse-status {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.parse-status.error { color: var(--mtg-red); }
.parse-status.ok { color: var(--mtg-green); }

/* Title card */
.title-card {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #f7f7f2;
  border-radius: 12px;
  padding: 1.5rem 2rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}

.title-card h2 {
  margin: 0;
  font-size: 2.25rem;
  letter-spacing: 0.02em;
  color: #f7f7f2;
}

.title-card .deck-meta {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.95rem;
  color: #cfd3dc;
}

.title-card .color-pips {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.color-pip {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  border: 2px solid rgba(255,255,255,0.7);
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.pip-W { background: var(--mtg-white); color: #333; text-shadow: none; }
.pip-U { background: var(--mtg-blue); }
.pip-B { background: var(--mtg-black); }
.pip-R { background: var(--mtg-red); }
.pip-G { background: var(--mtg-green); }

.mana-curve {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  margin-top: 1.25rem;
  height: 90px;
}

.curve-bar {
  flex: 1;
  min-width: 18px;
  background: var(--mtg-gold);
  border-radius: 3px 3px 0 0;
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  color: #1a1a2e;
  font-size: 0.7rem;
  font-weight: 700;
  padding-top: 2px;
  transition: height 0.3s ease;
}

.curve-label {
  font-size: 0.7rem;
  color: #cfd3dc;
  margin-top: 0.25rem;
  text-align: center;
}

.curve-column {
  flex: 1;
  min-width: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Sideboard guide */
.sideboard-guide {
  margin-top: 2rem;
}

.sideboard-guide h3 {
  margin-bottom: 0.5rem;
}

.matchup-header {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.matchup-input {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.matchup-input input {
  padding: 0.4rem 0.6rem;
  border: 1px solid #aaa;
  border-radius: 4px;
  font-size: 0.9rem;
}

.guide-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--site-border);
  border-radius: 8px;
  background: var(--site-surface);
}

table.guide-table {
  border-collapse: collapse;
  /* min-width lets the table exceed its container when many matchup
     columns are present; the wrapper's overflow-x scrolls. */
  min-width: 100%;
  font-size: 0.85rem;
  table-layout: fixed;
}

/* Matchup header cell: cap width, ellipsize long names, keep edit/remove buttons. */
.matchup-th {
  /* Floor so matchup cells stay readable ("IN 4" / "OUT 2"). When many
     are present the table grows past its container and the wrapper
     scrolls horizontally. */
  min-width: 3.5rem;
  max-width: 12rem;
}

.matchup-th-inner {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
}

.matchup-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
}

.matchup-edit,
.matchup-remove {
  flex: 0 0 auto;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 0.2rem;
  opacity: 0.6;
}

.matchup-edit:hover,
.matchup-remove:hover {
  opacity: 1;
}

.matchup-rename-input {
  width: 100%;
  min-width: 0;
  font: inherit;
  padding: 0.15rem 0.3rem;
  border: 1px solid #999;
  border-radius: 3px;
}

/* Card name column: ellipsize if too long. */
table.guide-table th.card-col {
  /* In the per-matchup focus view there's only one Plan column, so the
     card column can flex up to fill available width instead of being
     pinned to 14rem. */
  width: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toggle-cell {
  overflow: hidden;
}

table.guide-table th,
table.guide-table td {
  border: 1px solid var(--site-border-soft);
  padding: 0.4rem 0.5rem;
  text-align: left;
  white-space: nowrap;
  color: var(--site-text);
}

table.guide-table thead th {
  background: #2a2a3e;
  color: #f7f7f2;
  position: sticky;
  top: 0;
  z-index: 2;
}

table.guide-table th.card-col {
  position: sticky;
  left: 0;
  background: var(--site-surface-alt);
  color: var(--site-text);
  z-index: 3;
  /* width/min-width already set above; keep sticky behavior intact. */
}

table.guide-table thead th.card-col {
  z-index: 4;
  background: #2a2a3e;
  color: #f7f7f2;
}

table.guide-table tr.section-row td {
  background: var(--site-surface-hi);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--site-text-muted);
}

.toggle-cell {
  text-align: center;
  cursor: pointer;
  user-select: none;
  min-width: 64px;
  position: relative;
  padding: 0.4rem 0.5rem;
}

.toggle-cell:hover { background: var(--site-surface-hi); }
.toggle-cell.state-in { background: #1e4a2a; color: #b8e6c4; font-weight: 700; }
.toggle-cell.state-out { background: #4a1e24; color: #f4b8c0; font-weight: 700; }

/* Partial (fewer than all copies) gets a lighter tint and italic count. */
.toggle-cell.state-in.partial { background: #e7f5eb; }
.toggle-cell.state-out.partial { background: #fde6e9; }

.toggle-cell .partial-count {
  font-weight: 700;
  margin-left: 0.25rem;
}

.toggle-cell .edit-hint {
  display: inline-block;
  margin-left: 0.25rem;
  font-size: 0.7rem;
  opacity: 0.5;
  vertical-align: super;
}

/* Popover for partial counts */
.plan-popover {
  position: absolute;
  z-index: 20;
  background: #fff;
  border: 1px solid #999;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  padding: 0.5rem;
  min-width: 180px;
  font-weight: normal;
  color: #1a1a2e;
  text-align: left;
}

.plan-popover h5 {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #666;
}

.plan-popover-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 0.35rem;
}

.plan-popover-row:last-child { margin-bottom: 0; }

.plan-popover-label {
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 2rem;
}

.plan-popover-btn {
  border: 1px solid #aaa;
  background: #f8f8f8;
  border-radius: 4px;
  width: 1.75rem;
  height: 1.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
}

.plan-popover-btn:hover { background: #e8e8e8; }
.plan-popover-btn.active-in { background: #4a8a4a; color: #fff; border-color: #4a8a4a; }
.plan-popover-btn.active-out { background: #d9462b; color: #fff; border-color: #d9462b; }

.plan-popover-clear {
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.3rem;
  font-size: 0.8rem;
  border: 1px solid #aaa;
  background: #f0f0f0;
  border-radius: 4px;
  cursor: pointer;
}

.plan-popover-clear:hover { background: #e0e0e0; }

.matchup-remove {
  background: none;
  border: none;
  color: #a00;
  cursor: pointer;
  font-size: 1rem;
  padding: 0 0.25rem;
}

.mana-cost {
  display: inline-flex;
  gap: 2px;
  margin-left: 0.4rem;
  vertical-align: middle;
}

.mana-symbol {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ccc;
  color: #1a1a2e;
  font-size: 0.65rem;
  font-weight: 700;
  text-align: center;
  line-height: 14px;
}

/* Retired: mana-symbol-img approach reverted; see .mana-symbol for the
   styled-letter version used in the deck grid. */

.ms-W { background: #f7f7f2; border: 1px solid #999; }
.ms-U { background: #4a90d9; color: #fff; }
.ms-B { background: #2a2a2a; color: #fff; }
.ms-R { background: #d9462b; color: #fff; }
.ms-G { background: #4a8a4a; color: #fff; }
.ms-C { background: #9a9a9a; color: #fff; }

.card-count-badge {
  display: inline-block;
  min-width: 20px;
  text-align: center;
  font-weight: 700;
  /* Match the surrounding card-name text so the count reads as part of
     the label rather than fading into the background. */
  color: var(--site-text);
  margin-right: 0.35rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #777;
}

/* Guide toolbar */
.guide-toolbar {
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  margin: 0 0 0.75rem;
}

/* (Removed: prior attempt to merge toolbar and print controls assumed
   they were stacked in the same column; they are not.) */

.toolbar-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.toolbar-row:last-child { margin-bottom: 0; }

/* Primary row: Format dropdown on the left, action buttons pushed right. */
.toolbar-row-primary {
  gap: 0.75rem;
}

.toolbar-format-select {
  max-width: 14rem;
  flex: 0 0 auto;
}

.toolbar-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-left: auto;      /* push the buttons to the right edge */
  flex-wrap: wrap;
}

/* Quick-add label row: its own line, compact. */
.toolbar-row-preset-label {
  margin-bottom: 0.25rem;
}

/* Presets row: chips flow freely below the format selector. */
.toolbar-row-presets {
  gap: 0.35rem;
}

.toolbar-row .usa-button {
  margin-right: 0;
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
}

.toolbar-msg {
  margin-left: 0.5rem;
  font-size: 0.85rem;
}

.toolbar-msg.ok { color: #155724; }
.toolbar-msg.error { color: #721c24; }

.preset-label {
  font-size: 0.85rem;
  color: #555;
  margin-left: 0.5rem;
}

.preset-chip {
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem !important;
  border-radius: 999px;
  background: #eef2f7;
  color: #1a1a2e;
  border: 1px solid #ccd4e0;
  text-decoration: none;
}

.preset-chip:hover {
  background: #dde6f1;
  text-decoration: none;
}

/* Title card: count validation + export button */
.count-good { color: #a3e6a3; }
.count-bad  { color: #ff9d9d; font-weight: 700; }

.title-card-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.title-export-btn {
  border-color: #cfd3dc !important;
  color: #f7f7f2 !important;
  background: transparent !important;
  font-size: 0.85rem;
  padding: 0.4rem 0.9rem;
}

.title-export-btn:hover {
  background: rgba(255,255,255,0.1) !important;
}

.title-export-err {
  color: #ff9d9d;
  font-size: 0.85rem;
}

/* ============================================================
   Print cards (sized to fit a standard MTG sleeve) + print-only root
   ============================================================ */

.print-view {
  margin: 0.75rem 0 1rem;
}

.print-view-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0;
  /* Softer treatment: no heavy box, just a thin rule to separate the
     controls from the printable cards below. */
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0;
  color: #f5f2ea;
  /* The controls panel uses light-themed native UI (selects, checkboxes,
     color pickers). Set the whole subtree's preferred scheme so the
     browser renders their native chrome in light mode. */
  color-scheme: light;
}

/* Force legible text color throughout the controls regardless of which
   child element is doing the rendering. */
.print-view-controls,
.print-view-controls * {
  color: #f5f2ea;
}

.print-view-controls strong {
  color: #ffffff;
  font-weight: 700;
}

.print-view-controls .print-summary,
.print-view-controls .print-tip {
  color: #d8d4c8;
}

.print-view-controls .print-include-label {
  color: #ffffff;
}

.print-view-controls select,
.print-view-controls input {
  color: #14161c;
  background-color: #ebe7df;
  border: 1px solid #4a5062;
  border-radius: 4px;
  padding: 0.15rem 0.35rem;
  font-size: 0.85rem;
  /* Tell the browser to render the native chrome (dropdown list,
     scrollbars, etc.) in light mode. Without this, dark-mode operating
     systems override our colors and produce white-on-parchment text. */
  color-scheme: light;
}

/* Explicitly style the dropdown options — otherwise some browsers
   render them with OS defaults that clash with our parchment. */
.print-view-controls select option,
.print-view-controls select optgroup {
  color: #14161c;
  background-color: #ebe7df;
}

.print-view-controls select option:checked,
.print-view-controls select option:hover {
  background-color: #d8d4c8;
  color: #14161c;
}

.print-view-controls input[type="checkbox"] {
  padding: 0;
  background: transparent;
  border: none;
  accent-color: var(--site-accent);
  color-scheme: light;
}

.print-view-controls input[type="color"] {
  padding: 0;
  border: 1px solid #6a7080;
  width: 2rem;
  height: 1.6rem;
  color-scheme: light;
}

/* Print chips: legible in both on/off states on the darker controls bg. */
.print-view-controls .print-chip {
  background: #2c2f38;
  color: #f5f2ea;
  border: 1px solid #5a6070;
}

.print-view-controls .print-chip:hover {
  background: #3e4350;
  border-color: #8a8f9c;
}

.print-view-controls .print-chip-on {
  background: var(--site-accent);
  color: #14161c;
  border-color: var(--site-accent);
}

.print-view-controls .print-chip-on * {
  color: #14161c;
}

.print-view-controls .print-chip-disabled {
  opacity: 0.5;
}

.print-view-controls label {
  font-size: 0.9rem;
  color: #333;
}

.print-cards-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25in;
  padding: 0;
  /* The preview grid sits on the page background, not a panel. */
  background: var(--site-bg);
  border-radius: 0;
  justify-content: center;
}

/* A physical card, sized to fit a standard MTG sleeve (66.5mm x 92.5mm). */
.print-card {
  /* Bare MTG card size (63mm x 88mm), not sleeve size. This is what fits
     9 per Letter sheet in a 3x3 grid, and it reads as a companion to the
     deck rather than an insert. Both the on-screen preview and the printed
     output derive from these two values. */
  width: var(--card-w);
  height: var(--card-h);
  background: #fff;
  color: #000;
  border: 1px solid #333;
  padding: 0.1in 0.12in;
  box-sizing: border-box;
  font-family: "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  page-break-inside: avoid;
  break-inside: avoid;
}

.pc-header {
  border-bottom: 1pt solid #000;
  padding-bottom: 0.03in;
  margin-bottom: 0.05in;
  flex: 0 0 auto;
}

.pc-title {
  font-weight: 700;
  line-height: 1.1;
  /* Compact one-line header: the name, format, and colors are reminder
     text (so the card goes in the right box), not a headline. Keeping
     them to a single 9pt line reclaims roughly two table rows' worth of
     vertical space, which the matchup content needs. */
  font-size: 9pt;
  white-space: nowrap;
  /* Clip long names rather than showing "..." on the physical card. */
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

/* The format and colors now sit inline in .pc-title, so .pc-sub is gone.
   The name is bold; the metadata is lighter so the name still leads. */
.pc-title-name {
  font-weight: 700;
}

/* The checklist card reuses the compact one-line header. */
.print-list-card .pc-title {
  font-size: 9pt;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

.pc-title-meta {
  font-weight: 400;
  color: #555;
}

.pc-pips {
  letter-spacing: 0.08em;
  font-weight: 700;
}

.pc-table {
  width: 100%;
  border-collapse: collapse;
  flex: 1 1 auto;
  /* Fit-to-space: the font size is computed per card by the measure-and-fit
     routine in PrintView (which accounts for wrapping names, unlike a
     row-count formula). --fit-size is set on the card root. The fallback
     covers the first paint before the fit runs. */
  font-size: var(--fit-size, 8pt);
  table-layout: fixed;
  /* A touch of bottom breathing room so the last row never sits flush
     against the card edge when the table fills the available height. */
  margin-bottom: 0.05in;
}

/* When the fit routine determines every row can share the tallest cell's
   height, --cell-h is set on the card and applied here, making the row
   grid uniform. When it is not set, rows size to their content (ragged). */
.print-card[style*="--cell-h"] .pc-table tbody tr {
  height: var(--cell-h);
}

.pc-table th,
.pc-table td {
  border: 0.5pt solid #999;
  padding: 0.02in 0.02in;
  vertical-align: middle;
  line-height: 1.1;
}

.pc-table thead th {
  background: #eee;
  font-weight: 700;
  font-size: 7pt;
  text-align: center;
}

.pc-col-card {
  text-align: left;
  /* Wider than before (was 0.75in): card names are the content of this
     column and some are long single words (Spinewoods, Vitu-Ghazi) that
     were forcing the width-aware fit to shrink the whole card's font
     just to fit a narrow column. The matchup columns hold tiny content
     (-4, +2, "Tron"), so they can yield the space. */
  width: 1.0in;
  /* Names wrap at spaces only (normal wrapping). The fit routine shrinks
     the font until the widest single word fits the column, so a word
     never needs to break mid-word; it just wraps to the next line. */
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  /* A little breathing room between the name and the cell walls: enough
     to look deliberate, not so much that it steals font size (the fit is
     width-aware, so wider padding means a smaller fitted font). */
  padding: 0.04in 0.05in;
}

.pc-col-mu {
  text-align: center;
  width: auto;
  /* Wrap long matchup names rather than ellipsizing them. */
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
  line-height: 1.05;
  padding: 0.02in 0.02in;
}

.pc-count {
  display: inline-block;
  min-width: 0.14in;
  margin-right: 0.02in;
  font-weight: 700;
}

.pc-cell {
  text-align: center;
  font-weight: 700;
  /* The IN/OUT numbers are the point of the card, so they lead: the
     same fitted size as the row text, scaled up a touch. */
  font-size: calc(var(--fit-size, 8pt) * 1.15);
  line-height: 1.05;
}

/* Sample wrappers: render real print cards at their true size, then
   scale them down with a CSS transform so they fit in the preview pane.
   This guarantees the sample always matches production output. */
.sample-mini-wrap {
  /* Sized to the visible (scaled) card: a full card is 2.48in x 3.46in;
     at scale 0.89 that is ~2.2in x 3.08in. Larger than the previous
     1.95in minis so the samples read as real cards, not thumbnails. */
  width: 2.2in;
  height: 3.08in;
  position: relative;
  overflow: hidden;
  flex: 0 0 auto;
}

.sample-mini-wrap > .print-card {
  transform: scale(0.89);
  transform-origin: top left;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}

.pc-in {
  color: #000;
}

.pc-out {
  /* Direction is conveyed by the label ("OUT N") and the cell's
     background tint. A strikethrough over the whole number reads as
     "crossed out" rather than "boarded out". */
  color: #000;
}

.pc-row-side .pc-col-card {
  font-style: italic;
}

.pc-divider td {
  background: #ddd;
  font-weight: 700;
  font-size: 6.5pt;
  text-align: left;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Print root: hidden on screen, shown only during print. */
.print-root {
  /* Laid out but off-screen, not display:none. The print cards need to be
     measurable (scrollHeight/clientHeight) so the fit-to-space routine can
     size their text. display:none would make them unmeasurable. Off-screen
     absolute positioning keeps them out of view without affecting layout
     or print (the print media rule repositions/resets this). */
  position: absolute;
  left: -10000px;
  top: 0;
  visibility: hidden;
}

/* Print media: hide the on-screen app entirely, show only the print root. */
@media print {
  @page {
    size: letter;
    /* Small page margin clears the printer's non-printable edge. It does
       not add cuts: the only cuts are the internal grid lines. */
    margin: 0.25in;
  }

  html, body {
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .app-shell {
    display: none !important;
  }

  .print-root {
    /* Reset the off-screen measurement positioning for actual printing. */
    position: static !important;
    left: auto !important;
    visibility: visible !important;
    display: block !important;
  }

  .print-view {
    margin: 0;
    padding: 0;
  }

  .print-view-controls {
    display: none !important;
  }

  .print-cards-grid {
    display: grid;
    /* 3 across, no gap: cards share edges so the borders form a grid of
       cut lines. 3x3 fills a Letter sheet at bare-card size, and the
       shared edges mean only 4 cuts separate 9 cards. */
    grid-template-columns: repeat(3, var(--card-w));
    gap: 0;
    padding: 0;
    background: none;
    justify-content: start;
  }

  .print-card {
    /* Solid hairline, not dashed: cards share edges, so each border is a
       continuous cut line across the sheet. */
    border: 0.5pt solid #999;
    box-shadow: none;
    page-break-inside: avoid;
    break-inside: avoid;
    /* Force the browser to render the card's actual background colors,
       gradients, and images. Without this, browsers strip backgrounds
       for ink savings — which would erase the user's custom title card
       color, texture, and mana symbol watermark. The user chose those;
       they should print exactly as designed. */
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    color-adjust: exact;
  }
}

/* ============================================================
   DeckGrid: unified deck list + sideboard guide.
   ============================================================ */

.deck-grid {
  margin: 0.75rem 0 1rem;
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  border-radius: 8px;
  padding: 0.75rem 1rem 1rem;
}

.deck-grid-header {
  margin-bottom: 0.75rem;
}

.deck-grid-title {
  width: 100%;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--site-text);
  border: none;
  border-bottom: 2px solid var(--site-accent);
  padding: 0.25rem 0;
  background: transparent;
}

.deck-grid-title:focus {
  outline: none;
  border-bottom-color: var(--mtg-blue);
}

/* ============================================================
   Matchup tabs: horizontal row of buttons above the focus view.
   ============================================================ */
/* ============================================================
   Matchup tabs: styled like file-folder tabs sitting on top of
   the plan panel below. The active tab visually joins the panel.
   ============================================================ */

.matchup-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0;
  padding: 0 0.6rem;
  /* Bottom border acts as the baseline all tabs sit on. The active tab
     breaks through this by shifting down 1px. */
  border-bottom: 1px solid var(--site-border);
  margin-top: 0.6rem;
}

/* Status dot on each matchup tab: shows whether the plan is untouched,
   balanced, off (deck grows), or illegal (deck shrinks). */
.matchup-tab-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  margin-right: 0.35rem;
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--site-border);
}
.matchup-tab-dot.tab-empty {
  background: transparent;
  border-color: var(--site-border);
}
.matchup-tab-dot.tab-ok {
  background: #4a8a4a;
  border-color: #4a8a4a;
}
.matchup-tab-dot.tab-warn {
  background: #c9a94a;
  border-color: #c9a94a;
}
.matchup-tab-dot.tab-bad {
  background: #d9462b;
  border-color: #d9462b;
}

.matchup-tabs-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--site-text-muted);
  padding: 0 0.75rem 0.4rem 0.1rem;
  align-self: flex-end;
}

.matchup-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  background: var(--site-surface-alt);
  border: 1px solid var(--site-border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  color: var(--site-text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  bottom: -1px;         /* sit on the baseline, in front of the border */
  margin-right: 0.2rem;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.matchup-tab:hover {
  background: var(--site-surface-hi);
  color: var(--site-text);
}

.matchup-tab.is-active {
  background: var(--site-surface);
  color: var(--site-text);
  font-weight: 700;
  border-color: var(--site-border);
  border-top: 2px solid var(--site-accent);
  padding-top: calc(0.4rem - 1px);   /* compensate for the thicker top border */
  /* Extend down by 1 extra px to break through the strip's baseline and
     merge with the panel below. */
  padding-bottom: calc(0.4rem + 1px);
  z-index: 1;
}

.matchup-tab-name {
  white-space: nowrap;
}

.matchup-tab-remove {
  display: inline-block;
  opacity: 0.5;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.2rem;
  margin-left: 0.1rem;
  border-radius: 3px;
}

.matchup-tab-remove:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.2);
}

.matchup-tab.is-active .matchup-tab-remove:hover {
  background: rgba(0, 0, 0, 0.15);
}

/* The add-matchup control is an action, not a tab. Style it as a
   compact dashed chip pushed to the right of the strip. */
.matchup-tab-add {
  background: transparent;
  border: 1px dashed var(--site-border);
  border-radius: 6px 6px 0 0;
  color: var(--site-text-muted);
  font-weight: 500;
  margin-left: auto;
  margin-right: 0.1rem;
}

.matchup-tab-add:hover {
  border-color: var(--site-accent);
  color: var(--site-text);
  background: var(--site-surface-hi);
}

.matchup-tab-rename {
  font: inherit;
  color: #14161c;
  background: #ebe7df;
  border: 1px solid #14161c;
  border-radius: 3px;
  padding: 0.05rem 0.35rem;
  min-width: 8rem;
}

/* Focus panel below the tabs */
.matchup-focus {
  min-width: 0;
}

.matchup-focus {
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 0.75rem 1rem 1rem;
}

/* When the tabs row is present, the focus panel is attached below it. */
.matchup-focus-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--site-border-soft);
}

.matchup-focus-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--site-text-muted);
}

.matchup-focus-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--site-text);
}

.matchup-focus-balance {
  margin-left: auto;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--site-text-muted);
}

.matchup-focus-balance.net-ok { color: #7ac886; }
.matchup-focus-balance.net-warn { color: #e6c96a; }
.matchup-focus-balance.net-bad { color: #f4828c; font-weight: 700; }

/* Popover heading: differentiate main vs side when a card is in both. */
.plan-popover-section {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--site-text-muted);
  text-transform: lowercase;
}

.matchup-focus-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--site-text-muted);
  font-style: italic;
}

/* Hint text used in the header when no matchup is selected. */
.matchup-focus-balance.matchup-focus-hint {
  font-style: italic;
  font-weight: 400;
}

/* Cells that have no matchup to write into: dimmed, non-interactive. */
.toggle-cell-idle {
  color: var(--site-text-muted);
  cursor: not-allowed;
  background: transparent;
}

.toggle-cell-idle:hover {
  background: transparent;
}

.toggle-cell-placeholder {
  opacity: 0.4;
}

/* Header add-matchup cell: narrow by default so it reads as a slim
   "+" affordance rather than competing with real matchup columns. */
.add-matchup-th {
  width: 2.25rem;
  white-space: nowrap;
  padding: 0.3rem 0.2rem;
  text-align: center;
}

/* When the input is open, let the cell expand so typing is comfortable. */
.add-matchup-th.add-matchup-th-wide {
  width: 10rem;
  padding: 0.3rem 0.5rem;
  text-align: left;
}

.add-matchup-btn {
  background: none;
  border: 1px dashed var(--site-border);
  border-radius: 4px;
  color: var(--site-text-muted);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.15rem 0.4rem 0.25rem;
  cursor: pointer;
  width: 100%;
  min-width: 1.6rem;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.add-matchup-btn:hover {
  background: var(--site-surface-hi);
  border-color: var(--site-accent);
  color: var(--site-text);
}

.add-matchup-filler {
  background: transparent;
  border-left: 1px solid var(--site-border-soft);
  border-right: 1px solid var(--site-border-soft);
}

/* Sideboard divider row: darker than the type section headers so it reads
   as a hard boundary between main and side. */
/* Higher specificity than `tr.section-row td` so the divider colors
   actually win the cascade. */
table.guide-table tr.section-row.sideboard-divider td {
  /* Visually distinct "Sideboard" band: darker than the surrounding rows
     so the boundary between maindeck and sideboard reads at a glance. */
  background: #14161e;
  color: var(--site-accent);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
  border-top: 1px solid var(--site-accent);
  border-bottom: 1px solid var(--site-accent);
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}

/* Net row */
.net-row td {
  background: #f4f4ea;
}

.net-cell {
  text-align: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.net-ok { color: #155724; }
.net-bad { color: #a00; }

/* Board totals rows: IN / OUT / Balance */
.net-in-cell {
  color: #155724;
}

.net-out-cell {
  color: #a00;
}

.net-balance-cell {
  font-size: 0.8rem;
  font-weight: 700;
}

.net-in-label {
  color: #155724;
  font-weight: 700;
}

.net-out-label {
  color: #a00;
  font-weight: 700;
}

.net-balance-label {
  color: #333;
  font-weight: 700;
}

/* ============================================================
   Print controls: prominent chip toggles + inventory cards.
   ============================================================ */

.print-view-controls-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.print-view-controls-row:last-child { margin-bottom: 0; }

.print-summary {
  color: #555;
  font-size: 0.85rem;
}

.print-include-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #333;
}

.print-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  color: var(--site-text);
  padding: 0.22rem 0.55rem;
  border: 1px solid var(--site-border);
  border-radius: 999px;
  background: var(--site-surface);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.print-chip input {
  margin: 0;
  accent-color: #1a1a2e;
}

.print-chip:hover {
  background: #eef2f7;
  border-color: #888;
}

.print-chip-on {
  background: #1a1a2e;
  color: #f7f7f2;
  border-color: #1a1a2e;
}

.print-chip-on:hover {
  background: #262645;
}

.print-chip-on input {
  accent-color: #f7f7f2;
}

.print-chip-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.print-chip-label { font-weight: 700; }

.print-chip-count {
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

.print-tip {
  color: var(--site-text-muted);
  font-size: 0.75rem;
  margin-left: 0.5rem;
  flex: 1 1 100%;
}

/* Inventory (checklist) card: two-column list. */
.print-list-card .pl-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* Fit-to-space: set per card by the measure-and-fit routine in
     PrintView. Fallback covers the first paint. */
  font-size: var(--fit-size, 8pt);
}

/* Divider between stacked sections (main / side on a combined card). */
.pl-section-divider {
  display: flex;
  align-items: center;
  margin: 0.06in 0 0.04in;
  font-size: 7pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #333;
}

.pl-section-divider::before,
.pl-section-divider::after {
  content: "";
  flex: 1 1 auto;
  border-top: 0.75pt solid #333;
}

.pl-section-divider-label {
  padding: 0 0.05in;
}

.print-list-card .pl-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 0.1in;
  flex: 0 1 auto;
  overflow: hidden;
  min-width: 0;
}

.pl-col {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 8.5pt;
  line-height: 1.15;
  /* Grid children default to min-width:auto which lets content push
     them past their column share. Setting 0 keeps columns in bounds. */
  min-width: 0;
}

.pl-row {
  display: flex;
  gap: 0.03in;
  padding: 0.005in 0;
  min-width: 0;
}

.pl-count {
  font-weight: 700;
  min-width: 0.15in;
  text-align: right;
}

.pl-name {
  flex: 1 1 auto;
  min-width: 0;
  /* Allow wrapping instead of ellipsizing or overflowing. */
  overflow: hidden;
  text-overflow: clip;
  white-space: normal;
  word-break: break-word;
  line-height: 1.1;
}

.pl-empty {
  font-size: 8pt;
  color: #666;
  padding: 0.1in 0;
}

/* ============================================================
   Title card (decorative cover, sized to fit a standard sleeve).
   ============================================================ */

.print-title-card {
  position: relative;
  overflow: hidden;
  padding: 0.2in 0.2in;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: stretch;
}

/* Texture overlay: absolutely positioned, sits between the gradient
   background and the content. Blend mode keeps the underlying color
   visible. */
.ptc-texture {
  position: absolute;
  inset: 0;
  background-size: auto;
  /* overlay reads more strongly than soft-light — the previous mode was
     too subtle to notice against dark deck colors. */
  mix-blend-mode: overlay;
  pointer-events: none;
  z-index: 1;
}

/* Frame-mode textures (e.g. Leaves Frame) draw a full-card SVG. They get
   a slightly higher z-index than tiled textures so they sit above the
   pattern layer and below the content. */
.ptc-texture-frame {
  z-index: 2;
}

/* .ptc-top removed — the title card no longer shows decorative pips. */

.ptc-pips {
  display: inline-flex;
  gap: 0.06in;
}

.ptc-pip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.22in;
  height: 0.22in;
  border-radius: 50%;
  font-size: 9pt;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.6);
}

.ptc-pip-W { background: #f0ece1; color: #333; text-shadow: none; border-color: #999; }
.ptc-pip-U { background: #4a90d9; }
.ptc-pip-B { background: #1a1a1a; }
.ptc-pip-R { background: #d9462b; }
.ptc-pip-G { background: #2f7a3d; }

/* Real mana symbol images (from Scryfall CDN, or inline fallback). */
.ptc-pip-img {
  width: 0.28in;
  height: 0.28in;
  display: inline-block;
  vertical-align: middle;
}

.ptc-watermark-img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2.4in;
  height: 2.4in;
  opacity: 0.18;
  pointer-events: none;
  user-select: none;
  z-index: 1;
  filter: brightness(1.05);
}

.ptc-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 320pt;
  font-weight: 900;
  line-height: 0.85;
  pointer-events: none;
  user-select: none;
  z-index: 1;
}

.ptc-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2;
  text-align: center;
  padding: 0 0.1in;
}

.ptc-name {
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 0.01em;
  word-break: break-word;
  text-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

.ptc-subtitle {
  margin-top: 0.1in;
  font-size: 10pt;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ptc-bottom {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  z-index: 2;
}

.ptc-date {
  font-size: 7pt;
  letter-spacing: 0.1em;
  font-variant-numeric: tabular-nums;
}

/* Title card controls inside the print toolbar */
.title-card-controls {
  /* Wrapping flex row that includes both the collapsed button and the
     expanded panel; the panel takes a full-width row via flex-basis. */
  padding-top: 0.4rem;
  border-top: 1px dashed #4a5062;
  flex-wrap: wrap;
}

/* Collapsed controls (Option B): a single button + summary hint. */
.title-options-btn {
  font-size: 0.85rem;
  padding: 0.3rem 0.75rem !important;
  margin: 0 !important;
}

.title-options-hint {
  color: #d8d4c8;
  font-size: 0.8rem;
  font-style: italic;
}

/* Options panel: expands in place inside the controls box rather than
   floating over the cards. Full width of the controls container, laid
   out as a horizontal toolbar so it doesn't add too much height. */
.title-options-panel {
  flex: 1 1 100%;
  margin-top: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: #1e222a;
  border: 1px solid #4a5062;
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  color-scheme: light;
}

.title-options-row {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.title-options-row select {
  min-width: 8rem;
}

.title-options-label {
  color: #f5f2ea;
  font-size: 0.8rem;
  font-weight: 700;
  margin-right: 0.15rem;
}

.title-options-row input[type="color"] {
  width: 2rem;
  height: 1.6rem;
  padding: 0;
  border: 1px solid #6a7080;
  border-radius: 4px;
}

.title-control {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: #333;
}

.title-control-label {
  font-weight: 700;
}

.title-control input[type="color"] {
  width: 2rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid #999;
  border-radius: 4px;
  cursor: pointer;
  background: none;
}

.title-control select {
  font-size: 0.85rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid #999;
  border-radius: 4px;
}

.title-reset-btn {
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border: 1px solid #bbb;
  border-radius: 999px;
  background: #f4f4f4;
  cursor: pointer;
  color: #555;
}

.title-reset-btn:hover {
  background: #e8e8e8;
  color: #333;
}

/* ============================================================
   Two-column deck-builder layout: input column left (1/3),
   cards column right (2/3).
   ============================================================ */

/* ============================================================
   App two-column layout: workspace (2/3) + preview pane (1/3).
   ============================================================ */

/* One stable ratio in both the empty and loaded states. Previously the
   columns flipped from workspace-1/3+preview-2/3 (empty) to
   workspace-2/3+preview-1/3 (loaded), which reflowed the whole page on
   the click that loads a deck and read as an abrupt change. Using the
   loaded proportions always means nothing rearranges on load; the empty
   state simply has less content in the left column.

   If a smaller shift is preferred over no shift, change the base ratio
   to something between the two, e.g. `minmax(0, 1.4fr) minmax(0, 1fr)`,
   and leave the loaded override neutralized as it is here. */
.app-two-col,
.app-two-col.app-two-col-loaded {
  display: grid;
  /* One ratio for both states, no flip on load. The input column is
     narrower than before (was 2fr) so the preview column is wider, which
     lets the sample cards on the empty screen render larger (near full
     size) and gives the loaded print preview more room too. */
  grid-template-columns: minmax(0, 1.3fr) minmax(360px, 1fr);
  gap: 1.25rem;
  align-items: start;
  margin-top: 0.5rem;
}

@media (max-width: 1000px) {
  /* Match the loaded state's specificity too. The base rule uses
     `.app-two-col.app-two-col-loaded` (two classes), which otherwise
     beats this single-class selector and keeps the loaded layout
     two-column on a phone. Listing both here makes them equal, so the
     media rule wins and both states stack to one column on mobile. */
  .app-two-col,
  .app-two-col.app-two-col-loaded {
    grid-template-columns: 1fr;
  }
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* The guide-toolbar and deck-grid shouldn't double up on margin; the
   workspace handles spacing itself. */
.workspace > .guide-toolbar {
  margin: 1.5rem 0 1rem;
}

/* --- Preview pane (right) ---
   Deliberately frameless: cards float on the page background rather than
   living inside a bordered container. Sticky so they stay visible while
   the user works in the grid on the left. */

.preview-pane {
  align-self: start;
  display: flex;
  flex-direction: column;
  min-width: 0;
  /* Match the page background so the preview cards sit on the site
     surface rather than a contrasting slab. */
  background: var(--site-bg);
}

.preview-pane-body {
  min-height: 0;
  background: var(--site-bg);
}

.preview-pane-off {
  text-align: center;
  padding: 1rem 0.5rem;
  color: var(--site-text-muted);
  font-size: 0.9rem;
}

.preview-pane-off p {
  margin: 0 0 0.75rem;
}

/* (Pane scrolls with the page; no responsive overrides needed.) */

/* Sample cards panel: shown inside the preview pane on empty state. */
.sample-cards {
  margin: 0;
  text-align: center;
}

/* --- Mana curve (preview pane) --- */

.mana-curve {
  margin: 0 0 1.25rem;
  padding: 0.75rem;
  background: var(--site-surface);
  border: 1px solid var(--site-border-soft);
  border-radius: 8px;
}

.mana-curve-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.mana-curve-title {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--site-text-muted);
}

.mana-curve-sub {
  font-size: 0.78rem;
  color: var(--site-accent);
}

.mana-curve-amv {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
  font-size: 0.85rem;
}

.mana-curve-amv-label {
  color: var(--site-text-muted);
  font-size: 0.78rem;
}

.mana-curve-amv-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--site-text);
}

.mana-curve-amv-value.after {
  color: var(--site-accent);
}

.mana-curve-amv-arrow {
  color: var(--site-text-muted);
}

.mana-curve-amv-delta {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--site-text-muted);
}

.mana-curve-amv-delta.is-up {
  color: #c9a94a;
}

.mana-curve-amv-delta.is-down {
  color: #4a8a4a;
}

.mana-curve-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
  height: 5rem;
}

.mana-curve-col {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.mana-curve-bars {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
}

.mana-curve-bar {
  display: block;
  width: 40%;
  border-radius: 2px 2px 0 0;
  min-height: 1px;
}

.mana-curve-bar.before {
  background: var(--site-surface-hi);
  border: 1px solid var(--site-border);
}

.mana-curve-bar.after {
  background: var(--site-accent);
}

.mana-curve-label {
  margin-top: 0.3rem;
  font-size: 0.7rem;
  color: var(--site-text-muted);
}

.mana-curve-empty {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--site-text-muted);
}

.mana-curve-legend {
  margin-top: 0.5rem;
  font-size: 0.72rem;
  color: var(--site-text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.mana-curve-swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
}

.mana-curve-swatch.before {
  background: var(--site-surface-hi);
  border: 1px solid var(--site-border);
}

.mana-curve-swatch.after {
  background: var(--site-accent);
}

/* The empty-state headline. Large and full-color so it is the page's
   focal point: the site's "why" before the input's "how". The emphasis
   on "plan" ties the headline to the product. */
.sample-cards-headline {
  margin: 0 0 1rem;
  font-size: 1.9rem;
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--site-text);
}

.sample-cards-headline em {
  font-style: italic;
  color: var(--site-accent);
}

.sample-cards-row {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 0.25in;
  flex-wrap: wrap;
}

/* Print preview sits flush in its pane. */
.print-view-live {
  margin: 0;
  background: transparent;
  border: none;
  padding: 0;
}



/* Give the print cards a soft drop shadow so they read as physical cards
   floating on the page rather than borders. */
.preview-pane .print-card {
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  border: 1px solid #1a1a1a;
}

/* Print-chip-on: dark text on copper accent for high contrast. */
.print-chip-on {
  background: var(--site-accent);
  color: #1a1a1a;
  border-color: var(--site-accent);
}

/* Print card backdrop: near-black so white cards pop dramatically. */
.print-cards-grid {
  /* Was a near-black slab (#0e1016), darker than the page, which read as
     a contrasting panel behind the preview cards. Match the page
     background so the cards sit on the site surface. */
  background: var(--site-bg);
}

/* Grid cell state colors on the dark Forge palette. */
.toggle-cell.state-in {
  background: #1e3a24;
  color: #b8e6c4;
  font-weight: 700;
}
.toggle-cell.state-out {
  background: #3a1e24;
  color: #f0b8c0;
  font-weight: 700;
}

/* Status messages on the dark surface. */
.toolbar-msg.ok { color: #7ac886; }
.toolbar-msg.error { color: #f4828c; }

/* ============================================================
   Card hover preview (global floating overlay)
   ============================================================ */

/* Small image-icon next to each card name; only this triggers the
   preview so hovering the whole row stays quiet. */
.card-preview-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0 0.1rem;
  margin-right: 0.1rem;
  color: var(--site-text-muted);
  opacity: 0.35;
  cursor: pointer;
  vertical-align: middle;
  transition: opacity 0.15s, color 0.15s;
}

th.card-col:hover .card-preview-icon,
.card-preview-icon:hover {
  opacity: 0.85;
  color: var(--site-accent);
}

.card-preview-icon svg {
  display: block;
}

th.card-col:hover .card-preview-icon,
.card-preview-icon:hover {
  opacity: 0.85;
  color: var(--site-accent);
}

.card-preview-icon svg {
  display: block;
}

.card-preview {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  filter: drop-shadow(0 12px 30px rgba(0, 0, 0, 0.6));
  transition: opacity 0.08s ease;
}

.card-preview-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
}

.card-preview-empty {
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  color: var(--site-text);
}

.card-preview-name {
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.card-preview-note {
  font-size: 0.8rem;
  color: var(--site-text-muted);
}

/* Hidden file input used by the toolbar's Import button. */
.toolbar-import-input {
  display: none;
}

/* ============================================================
   Site header mode nav (Build / Browse)
   ============================================================ */

.site-header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-mode-nav {
  display: inline-flex;
  gap: 0;
  border: 1px solid var(--site-border);
  border-radius: 999px;
  background: var(--site-surface);
  overflow: hidden;
}

.site-mode-btn {
  background: transparent;
  border: none;
  color: var(--site-text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.site-mode-btn:hover {
  color: var(--site-text);
  background: var(--site-surface-alt);
}

.site-mode-btn.is-active {
  background: var(--site-accent);
  color: #14161c;
}

/* ============================================================
   Guide library (browse mode) — Direction A card showroom
   ============================================================ */

.guide-library {
  margin: 1rem 0 3rem;
}

.guide-library-header {
  margin-bottom: 1.25rem;
}

.guide-library-header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--site-border-soft);
}

.guide-library-eyebrow {
  margin: 0 0 0.15rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--site-accent);
  font-weight: 700;
}

.guide-library-header h2 {
  margin: 0 0 0.35rem;
  font-size: 1.75rem;
  letter-spacing: -0.01em;
  color: var(--site-text);
}

.guide-library-lead {
  margin: 0;
  color: var(--site-text-muted);
  max-width: 34rem;
}

.guide-library-submit {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* --- Format tabs + search --- */

.guide-library-tabs {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--site-border-soft);
}

.guide-library-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  border-radius: 999px;
  color: var(--site-text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.38rem 0.85rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.guide-library-tab:hover {
  color: var(--site-text);
  background: var(--site-surface-alt);
}

.guide-library-tab.is-active {
  background: var(--site-accent);
  color: #14161c;
  border-color: var(--site-accent);
}

.guide-library-tab-count {
  display: inline-block;
  min-width: 1.35rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.15);
  font-size: 0.72rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.guide-library-tab.is-active .guide-library-tab-count {
  background: rgba(0, 0, 0, 0.22);
}

.guide-library-search {
  margin-left: auto;
  display: inline-flex;
}

.guide-library-search input {
  font-size: 0.85rem;
  padding: 0.35rem 0.65rem;
  background: var(--site-surface);
  color: var(--site-text);
  border: 1px solid var(--site-border);
  border-radius: 999px;
  min-width: 15rem;
}

.guide-library-info {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: 1px solid var(--site-border);
  background: var(--site-surface);
  color: var(--site-text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  font-style: italic;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.guide-library-info:hover {
  color: var(--site-text);
  background: var(--site-surface-alt);
}

.guide-library-source-inline {
  font-size: 0.78rem;
  color: var(--site-text-muted);
  margin: -0.25rem 0 0.85rem;
  padding: 0.4rem 0.6rem;
  background: var(--site-surface);
  border: 1px solid var(--site-border-soft);
  border-radius: 6px;
  display: inline-block;
}

/* --- Status (loading, error, empty) --- */

.guide-library-status {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--site-text-muted);
}

.guide-library-status p {
  margin: 0 0 0.75rem;
}

.guide-library-error { color: #f4828c; }

.guide-library-spinner {
  display: inline-block;
  width: 1.75rem;
  height: 1.75rem;
  border: 2px solid var(--site-border);
  border-top-color: var(--site-accent);
  border-radius: 50%;
  animation: gl-spin 0.8s linear infinite;
  margin-bottom: 0.75rem;
}

@keyframes gl-spin {
  to { transform: rotate(360deg); }
}

/* --- Card grid --- */

.guide-library-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  gap: 1rem;
}

.guide-library-card {
  position: relative;   /* anchor for the stretched-link overlay below */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.15rem 1.25rem;
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  border-radius: 12px;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}

.guide-library-card:hover {
  transform: translateY(-2px);
  border-color: var(--site-accent);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.guide-library-card-body { min-width: 0; }

.guide-library-card-name {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--site-text);
  word-break: break-word;
}

.guide-library-card-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
  min-height: 1.35rem;    /* reserve a row so cards align vertically */
}

/* Format pill — colors per format. Falls back to neutral gray. */
.guide-library-pill {
  display: inline-block;
  padding: 0.12rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: 1px solid rgba(0, 0, 0, 0.2);
  color: #1a1a1a;
  background: #cfcfcf;
}

.pill-pauper      { background: #8fc78f; }
.pill-modern      { background: #8fb3e0; }
.pill-legacy      { background: #c9a0e0; }
.pill-vintage     { background: #e0c98f; }
.pill-pioneer     { background: #e0b48f; }
.pill-standard    { background: #e0a0a0; }
.pill-commander   { background: #e0d68f; }
.pill-other       { background: #cfcfcf; }

.guide-library-archetype {
  font-size: 0.85rem;
  color: var(--site-text-muted);
}

/* Reserve a line so cards line up even when the archetype is redundant. */
.guide-library-archetype:empty,
.guide-library-archetype {
  min-height: 1.15rem;
}

.guide-library-card-author {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--site-text);
  letter-spacing: 0.01em;
  opacity: 0.85;
}

.guide-library-by {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--site-text-muted);
  margin-right: 0.2rem;
  opacity: 0.65;
  font-weight: 700;
}

.guide-library-open {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.42rem 0.85rem;
  border: 1px solid var(--site-border);
  background: var(--site-surface-alt);
  color: var(--site-text);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s, transform 0.12s;
}

/* Whole-card click target: an invisible overlay stretched from the Open
   button to fill the card, so clicking anywhere on the card opens the
   guide. The button stays a real focusable <button> (keyboard and screen
   readers unaffected); only its hit area grows. */
.guide-library-open::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
}

.guide-library-open:hover:not(:disabled) {
  background: var(--site-accent);
  border-color: var(--site-accent);
  color: #14161c;
}

.guide-library-open:hover:not(:disabled) svg {
  transform: translateX(2px);
}

.guide-library-open svg {
  transition: transform 0.12s ease;
}

.guide-library-open:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* --- Footer --- */

.guide-library-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--site-border-soft);
  font-size: 0.8rem;
  color: var(--site-text-muted);
}

.guide-library-footer strong {
  color: var(--site-text);
}

/* Submit status feedback bar (bottom-right toast-like) */
.submit-status-bar {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  color: var(--site-text);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  z-index: 1500;
}

.submit-status-bar.ok {
  border-color: var(--site-accent);
}

.submit-status-bar.error {
  border-color: #f4828c;
  color: #f4828c;
}

/* ============================================================
   Device auth dialog (GitHub OAuth device flow)
   ============================================================ */

.device-auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.device-auth-panel {
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  border-radius: 10px;
  width: 100%;
  max-width: 30rem;
  color: var(--site-text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
}

.device-auth-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--site-border);
}

.device-auth-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.device-auth-close {
  background: transparent;
  border: none;
  color: var(--site-text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.3rem;
}

.device-auth-close:hover { color: var(--site-text); }

.device-auth-body,
.device-auth-status {
  padding: 1rem 1.15rem 1.25rem;
}

.device-auth-status {
  color: var(--site-text-muted);
  text-align: center;
}

.device-auth-error {
  color: #f4828c;
}

.device-auth-instructions {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--site-text-muted);
}

.device-auth-code {
  font-family: "Courier New", monospace;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-align: center;
  padding: 0.75rem;
  background: var(--site-surface-alt);
  border: 1px solid var(--site-border);
  border-radius: 6px;
  margin-bottom: 0.75rem;
  color: var(--site-text);
  user-select: all;
}

.device-auth-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.device-auth-waiting {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--site-text-muted);
  font-style: italic;
}

/* ============================================================
   Community guide browser (modal)
   ============================================================ */

.guide-browser-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.guide-browser-panel {
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  border-radius: 10px;
  width: 100%;
  max-width: 44rem;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  color: var(--site-text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.guide-browser-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--site-border);
}

.guide-browser-header h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--site-text);
}

.guide-browser-close {
  background: transparent;
  border: none;
  color: var(--site-text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.3rem;
}

.guide-browser-close:hover { color: var(--site-text); }

.guide-browser-source {
  margin: 0;
  padding: 0.5rem 1rem 0;
  font-size: 0.78rem;
  color: var(--site-text-muted);
}

.guide-browser-status {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--site-text-muted);
}

.guide-browser-error { color: #f4828c; }

.guide-browser-list {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0;
  overflow-y: auto;
}

.guide-browser-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--site-border-soft);
}

.guide-browser-item:last-child { border-bottom: none; }

.guide-browser-info { min-width: 0; }

.guide-browser-name {
  font-weight: 700;
  color: var(--site-text);
  font-size: 0.95rem;
}

.guide-browser-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.2rem;
  font-size: 0.8rem;
  color: var(--site-text-muted);
  flex-wrap: wrap;
}

.guide-browser-tag {
  background: var(--site-surface-hi);
  border: 1px solid var(--site-border);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-size: 0.72rem;
}

.guide-browser-author { font-style: italic; }

.guide-browser-load {
  flex: 0 0 auto;
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
}

.guide-browser-footer {
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--site-border);
  font-size: 0.78rem;
  color: var(--site-text-muted);
}

.guide-browser-hint a {
  color: var(--site-accent);
}

/* ============================================================
   Print / PDF icon buttons in the print controls.
   ============================================================ */

.print-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
}

.print-icon-btn svg {
  display: block;
  flex: 0 0 auto;
}

.print-icon-label {
  font-size: 0.85rem;
}

.print-export-err {
  font-size: 0.8rem;
  color: #f4828c;
  margin-left: 0.5rem;
}

/* ============================================================
   Submit-guide info modal (Browse): explains the contribution
   flow in plain language and offers a jump to Build mode.
   ============================================================ */

.submit-info-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 2000;
}

.submit-info-panel {
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  border-radius: 10px;
  max-width: 32rem;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
}

.submit-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--site-border-soft);
}

.submit-info-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--site-text);
}

.submit-info-close {
  background: transparent;
  border: none;
  color: var(--site-text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}

.submit-info-close:hover {
  color: var(--site-text);
}

.submit-info-body {
  padding: 1.1rem 1.25rem;
  color: var(--site-text);
}

.submit-info-body p {
  margin: 0 0 0.85rem;
  font-size: 0.92rem;
  line-height: 1.5;
}

.submit-info-body strong {
  color: var(--site-accent);
}

.submit-info-note {
  color: var(--site-text-muted);
  font-size: 0.85rem !important;
}

.submit-info-actions {
  display: flex;
  gap: 0.6rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--site-border-soft);
}

/* ============================================================
   Mode bar: the Build / Browse switch, promoted from a small
   nav in the header corner to a full-width band directly under
   the header. Build and Browse are the two things the site
   does, so the switch is a primary navigation element, not an
   afterthought.
   ============================================================ */

/* Segmented control: the two mode buttons join into one unit. The
   gap is removed, the doubled border at the seam is collapsed, and
   only the outer corners are rounded. */
.mode-bar {
  display: flex;
  margin: 0 0 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--site-border-soft);
}

.mode-bar-btn {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.7rem 1rem;
  background: var(--site-surface);
  border: 1px solid var(--site-border);
  border-radius: 0;
  color: var(--site-text-muted);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

/* First and last button own the outer rounding; the seam between them
   uses a negative margin so the two 1px borders overlap into one. */
.mode-bar-btn:first-child {
  border-radius: 8px 0 0 8px;
}

.mode-bar-btn:last-child {
  border-radius: 0 8px 8px 0;
  margin-left: -1px;
}

.mode-bar-btn:hover:not(.is-active) {
  background: var(--site-surface-alt);
  color: var(--site-text);
}

/* Active button sits above its neighbour so its accent border is not
   clipped by the seam overlap. */
.mode-bar-btn.is-active {
  position: relative;
  z-index: 1;
  background: var(--site-surface-hi);
  border-color: var(--site-accent);
  color: var(--site-text);
}

.mode-bar-btn:focus-visible {
  outline: 2px solid var(--site-accent);
  outline-offset: 1px;
  z-index: 2;
}

.mode-bar-label {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.005em;
}

.mode-bar-btn.is-active .mode-bar-label {
  color: var(--site-accent);
}

.mode-bar-hint {
  font-size: 0.78rem;
  color: var(--site-text-muted);
}

@media (max-width: 640px) {
  /* Stacked: restore full rounding and remove the seam overlap. */
  .mode-bar {
    flex-direction: column;
    gap: 0.5rem;
  }
  .mode-bar-btn,
  .mode-bar-btn:first-child,
  .mode-bar-btn:last-child {
    border-radius: 8px;
    margin-left: 0;
  }
}

/* ============================================================
   Archetype view (derived index) + By-archetype / All-guides
   toggle above the Guide library. See /docs/archetype-index-spec.md
   ============================================================ */

.guide-library-view-toggle {
  display: flex;
  gap: 0.4rem;
  margin: 1rem 0 1.25rem;
}

.guide-library-view-btn {
  background: var(--site-surface);
  color: var(--site-text-muted);
  border: 1px solid var(--site-border);
  border-radius: 4px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.guide-library-view-btn:hover:not(:disabled) {
  background: var(--site-surface-alt);
  color: var(--site-text);
}

.guide-library-view-btn.is-active {
  background: var(--site-accent);
  color: #1a1a1a;
  border-color: var(--site-accent);
}

.guide-library-view-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.guide-library-view-btn:focus-visible {
  outline: 2px solid var(--site-accent);
  outline-offset: 1px;
}

/* --- Archetype view root --- */

.archetype-view {
  margin-top: 0.5rem;
}

.archetype-view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.archetype-view-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--site-accent);
  margin: 0 0 0.15rem;
}

.archetype-view-header h2 {
  margin: 0;
  color: var(--site-text);
  font-size: 1.5rem;
}

.archetype-view-lead {
  margin: 0.25rem 0 0;
  color: var(--site-text-muted);
  font-size: 0.9rem;
}

.archetype-view-source {
  font-size: 0.75rem;
  color: var(--site-text-muted);
  white-space: nowrap;
  padding-top: 0.35rem;
}

/* --- Archetype list --- */

.archetype-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.archetype-item {
  background: var(--site-surface);
  border: 1px solid var(--site-border-soft);
  border-radius: 6px;
  overflow: hidden;
}

.archetype-item.is-expanded {
  border-color: var(--site-accent);
}

.archetype-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 0.85rem 1.1rem;
  background: transparent;
  border: none;
  color: var(--site-text);
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.archetype-row:hover {
  background: var(--site-surface-alt);
}

.archetype-row:focus-visible {
  outline: 2px solid var(--site-accent);
  outline-offset: -2px;
}

.archetype-row-main {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  min-width: 0;
}

.archetype-row-name {
  font-weight: 600;
  font-size: 1rem;
}

.archetype-row-format {
  font-size: 0.75rem;
  color: var(--site-text-muted);
  border: 1px solid var(--site-border);
  border-radius: 999px;
  padding: 0.05rem 0.55rem;
}

.archetype-row-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  white-space: nowrap;
}

.archetype-row-count {
  font-size: 0.82rem;
  color: var(--site-text-muted);
}

.archetype-row-chevron {
  color: var(--site-accent);
  font-size: 0.9rem;
}

/* --- Archetype detail --- */

.archetype-detail {
  padding: 0 1.1rem 1.1rem;
  border-top: 1px solid var(--site-border-soft);
}

/* Two-column detail: maindeck frequency on the left, board-in matrix
   on the right, guides as a full-width footer below. Collapses to a
   single stack when the viewport is too narrow for side-by-side. */
.archetype-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .archetype-columns {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

.archetype-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.75rem 0;
}

.archetype-tag {
  font-size: 0.72rem;
  color: var(--site-text);
  background: var(--site-surface-alt);
  border: 1px solid var(--site-border);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
}

.archetype-freq-title,
.archetype-guides-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--site-text-muted);
  margin: 1rem 0 0.5rem;
}

.archetype-freq-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.archetype-freq-row {
  display: grid;
  /* Fixed bar track rather than 1fr: at row width a 100% bar and a 75%
     bar would look nearly identical, because the difference is spread
     across too much space to compare. A fixed track makes the fills
     visually proportional. Track shrinks inside the two-column detail
     (see .archetype-columns .archetype-freq-row below). */
  grid-template-columns: minmax(9rem, 14rem) 20rem 3rem;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}

/* Inside the two-column layout the frequency list has roughly half the
   width, so the name and bar columns shrink to fit. */
.archetype-columns .archetype-freq-row {
  grid-template-columns: minmax(7rem, 11rem) 1fr 3rem;
}

/* Board-in rows keep a fixed copies column but let the bar take the
   remaining space inside their narrower column. */
.archetype-columns .archetype-boardin .archetype-freq-row {
  grid-template-columns: minmax(7rem, 11rem) 1fr 2.75rem 2.75rem;
}

.archetype-freq-name {
  color: var(--site-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archetype-freq-bar-wrap {
  position: relative;
  height: 8px;
  background: var(--site-surface-hi);
  border-radius: 4px;
  overflow: hidden;
  /* Fill the 20rem grid track. The bar inside fills a percentage of
     this, so the track must have a definite width. */
  width: 100%;
}

.archetype-freq-bar {
  display: block;
  height: 100%;
  background: var(--site-accent);
  border-radius: 4px;
}

.archetype-freq-pct {
  font-variant-numeric: tabular-nums;
  color: var(--site-text-muted);
  text-align: right;
  font-size: 0.8rem;
}

.archetype-freq-more {
  margin-top: 0.6rem;
  background: transparent;
  border: none;
  color: var(--site-accent);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0;
}

.archetype-freq-more:hover {
  color: var(--site-accent-hover);
  text-decoration: underline;
}

/* --- Guides within an archetype --- */

.archetype-guides-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.archetype-guide-row {
  position: relative;   /* anchor for the whole-row click target */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--site-surface-alt);
  border: 1px solid var(--site-border-soft);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

/* The whole row is a link, so hovering anywhere on it should signal that,
   not just hovering the Open button. */
.archetype-guide-row:hover {
  background: var(--site-surface-hi);
  border-color: var(--site-accent);
}

.archetype-guide-info {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
}

.archetype-guide-author {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--site-text);
}

.archetype-guide-verified {
  color: var(--site-accent);
  font-weight: 700;
}

.archetype-guide-date {
  font-size: 0.75rem;
  color: var(--site-text-muted);
}

.archetype-guide-open {
  flex: 0 0 auto;
  padding: 0.3rem 0.85rem;
  font-size: 0.82rem;
}

/* Whole-row click target: the Open button's invisible ::after stretches to
   fill the row, so clicking anywhere on the row opens the guide. The
   button stays a real focusable <button>; only its hit area grows. */
.archetype-guide-open::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 4px;
}

/* --- Board-in list (v2 "What comes in") ---
   A card-first view: sideboard cards ranked by how many matchups they
   come in for. Clicking a card reveals the per-matchup detail. The
   index stores this matchup-first; the component inverts it for display. */

.archetype-boardin {
  margin-top: 0;
}

.archetype-boardin-hint {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  color: var(--site-text-muted);
}

.archetype-boardin-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.archetype-boardin-card {
  border-top: 1px solid transparent;
}

/* Visual break between matchup-count tiers (3-matchup cards, then
   2-matchup, then 1-matchup). Drawn as a top border on the first card
   of each new tier, so the list reads as grouped without named labels. */
.archetype-boardin-card.is-new-tier {
  border-top-color: var(--site-border-soft);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
}

.archetype-boardin-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  width: 100%;
  padding: 0.35rem 0;
  background: transparent;
  border: none;
  color: var(--site-text);
  cursor: pointer;
  text-align: left;
  font: inherit;
  font-size: 0.85rem;
}

.archetype-boardin-row:hover .archetype-boardin-name {
  color: var(--site-accent);
}

.archetype-boardin-row:focus-visible {
  outline: 2px solid var(--site-accent);
  outline-offset: -2px;
}

.archetype-boardin-chevron {
  color: var(--site-accent);
  font-size: 0.75rem;
  width: 1rem;
  flex: 0 0 auto;
}

.archetype-boardin-name {
  font-weight: 600;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archetype-boardin-count {
  flex: 0 0 auto;
  color: var(--site-text-muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.archetype-boardin-detail {
  list-style: none;
  margin: 0 0 0.4rem 1.5rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.archetype-boardin-detail-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--site-text-muted);
}

.archetype-boardin-detail-vs {
  color: var(--site-text);
}

.archetype-boardin-detail-pct {
  font-variant-numeric: tabular-nums;
}

.archetype-boardin-detail-copies {
  margin-left: auto;
  color: var(--site-text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}