/* The Tuck Box — "The Card Room" palette. No tans, browns or dark red text. */

@font-face { font-family: "EB Garamond"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/eb-garamond-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "EB Garamond"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/eb-garamond-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "EB Garamond"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/eb-garamond-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "EB Garamond"; font-style: italic; font-weight: 400; font-display: swap; src: url("../fonts/eb-garamond-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "IM Fell English SC"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/im-fell-english-sc-latin-400-normal.woff2") format("woff2"); }

:root {
  --bg: #0F3328;
  --panel: #164536;
  --border: #2F6150;
  --input: #0C2A21;
  --input-border: #3E6B5A;
  --text: #F3EEDF;
  --muted: #BFCFC4;
  --placeholder: #9FB5A8;
  --gold: #F2C83A;
  --spade-off: #4F7D6B;
  --overlay: rgba(6, 22, 17, 0.92);
  --display: "IM Fell English SC", Georgia, serif;
  --body: "EB Garamond", Georgia, serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
/* Every text size is in rem, so this one setting scales all of them together. */
html { -webkit-text-size-adjust: 100%; font-size: 115%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); font-size: 1.125rem; line-height: 1.4; }
a { color: var(--text); }
a:hover { color: var(--gold); }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
::placeholder { color: var(--placeholder); opacity: 1; }
[hidden] { display: none !important; }

.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 20; background: var(--gold); color: var(--bg); padding: 8px 14px; border-radius: 3px; }
.skip:focus { left: 8px; }
.js .js-hide { display: none; }
.muted { color: var(--muted); }

/* The safe-area insets keep the page clear of the status bar and notch when opened from the home screen. */
.page { max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px;
        padding: calc(32px + env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 64px max(24px, env(safe-area-inset-left)); }
.stack { display: flex; flex-direction: column; gap: 28px; min-width: 0; }

/* Header */
.site-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--gold); box-shadow: 0 5px 0 -4px var(--gold); }
.brand { display: flex; flex-direction: column; gap: 14px; text-decoration: none; color: var(--text); }
.eyebrow-lg { font-size: 0.875rem; letter-spacing: 0.32em; text-transform: uppercase; color: var(--gold); }
.wordmark { font-family: var(--display); font-size: 4rem; line-height: 1; letter-spacing: 0.02em; }
.main-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 24px; font-size: 1.1875rem; }
.main-nav a { text-decoration: none; padding-bottom: 4px; }
.main-nav a[aria-current="page"]:not(.btn) { border-bottom: 2px solid var(--gold); }
.main-nav a.btn { padding: 10px 18px; }

/* Type */
.h-display { margin: 0; font-family: var(--display); font-weight: 400; font-size: 2.75rem; line-height: 1.05; }
.h-section { margin: 0; font-family: var(--display); font-weight: 400; font-size: 2.375rem; }
.h-sub { margin: 0; font-family: var(--display); font-weight: 400; font-size: 1.75rem; }
.lede { margin: 0; color: var(--muted); font-style: italic; }
.label, .eyebrow { font-size: 0.875rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); font-weight: 400; }
.label .aside { color: var(--muted); letter-spacing: 0.04em; text-transform: none; font-style: italic; }
.page-title { display: flex; flex-direction: column; gap: 6px; }
.empty { color: var(--muted); font-style: italic; margin: 8px 0; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 3px; font: inherit; font-size: 1.0625rem; text-decoration: none; cursor: pointer; border: 1px solid transparent; background: transparent; color: var(--text); }
.btn-gold { background: var(--gold); color: var(--bg) !important; font-weight: 600; border-color: var(--gold); }
.btn-gold:hover { background: #F7D86A; }
.btn-outline { border-color: var(--gold); color: var(--gold); }
.btn-outline:hover { background: rgba(242, 200, 58, 0.1); }
.btn-quiet { border-color: var(--input-border); color: var(--text); }
.btn-quiet:hover, .btn-quiet[aria-pressed="true"] { border-color: var(--gold); }
.btn-quiet[aria-pressed="true"] { background: var(--gold); color: var(--bg); }
.btn-lg { min-height: 50px; padding: 0 28px; font-size: 1.1875rem; }
.btn[disabled] { opacity: 0.6; cursor: progress; }
.link-danger { color: var(--muted); }
.link-danger:hover { color: var(--gold); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 8px; border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.field > legend { padding: 0; margin-bottom: 10px; }
.input { min-height: 44px; padding: 0 12px; background: var(--input); border: 1px solid var(--input-border); border-radius: 3px; color: var(--text); font: inherit; font-size: 1.0625rem; width: 100%; }
select.input { padding: 0 10px; }
textarea.input { padding: 12px 14px; resize: vertical; min-height: 110px; line-height: 1.45; }
.input-sm { min-height: 40px; font-size: 1rem; width: auto; }
.input:focus-visible { outline-offset: 1px; }
.check { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--gold); margin: 0; flex: none; }
.check-sm { font-size: 1rem; color: var(--muted); margin-top: 6px; }
.errors { margin: 0; padding: 14px 18px; border: 2px solid var(--gold); border-radius: 4px; background: var(--input); }
.errors h3 { margin: 0 0 6px; font-size: 1.1875rem; color: var(--gold); }
.errors ul { margin: 0; padding-left: 20px; }
.notice { margin: 0; padding: 12px 16px; border-left: 4px solid var(--gold); background: var(--panel); border-radius: 3px; }

/* Swatches and pills */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.sw { position: relative; width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--text); background: var(--sw); cursor: pointer; flex: none; }
.sw input, .pill input, .spade input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.sw:has(input:checked) { outline: 3px solid var(--gold); outline-offset: 3px; }
.sw:has(input:focus-visible), .pill:has(input:focus-visible) { outline: 3px solid var(--gold); outline-offset: 3px; box-shadow: 0 0 0 2px var(--bg); }
.pill { position: relative; display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--input-border); color: var(--text); font-size: 1rem; cursor: pointer; }
.pill:has(input:checked), a.pill[aria-current="true"] { background: var(--gold); color: var(--bg); border-color: var(--gold); }
a.pill { text-decoration: none; height: 44px; padding: 0 18px; border-radius: 22px; font-size: 1.0625rem; }
.swatch-dot { display: inline-block; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--text); vertical-align: middle; flex: none; }

/* Chips and badges */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 1rem; padding: 3px 12px; background: var(--panel); border: 1px solid var(--input-border); border-radius: 14px; text-decoration: none; }
.chip a, .chip button { color: var(--muted); text-decoration: none; background: none; border: 0; font: inherit; font-size: 1.125rem; cursor: pointer; padding: 0 4px; min-width: 28px; min-height: 28px; }
.chip a:hover, .chip button:hover { color: var(--gold); }
a.chip:hover { border-color: var(--gold); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.badge { font-size: 0.875rem; padding: 2px 8px; border: 1px solid var(--gold); color: var(--gold); border-radius: 2px; }
.badge-solid { background: var(--text); color: var(--bg); border-color: var(--text); }
.badges-lg .badge { font-size: 0.9375rem; padding: 4px 10px; }
.active-tag { margin: 0; color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Spades */
.spades { margin: 2px 0 0; font-size: 1.125rem; letter-spacing: 0.12em; }
.spades .on, .spades-lg { color: var(--gold); }
.spades .off { color: var(--spade-off); }
.spades-lg { margin: 4px 0 0; font-size: 1.875rem; letter-spacing: 0.14em; }
.spades-lg .off { color: var(--spade-off); }

/* Collection layout */
.with-sidebar { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-start; }
.filters { flex: 1 1 240px; max-width: 300px; }
.filters-panel { background: var(--panel); border: 1px solid var(--border); border-radius: 4px; }
.filters-panel > summary { display: none; }
.filters-body { display: flex; flex-direction: column; gap: 24px; padding: 22px; }
.filter-actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; font-size: 1rem; }
.filter-actions a { color: var(--muted); }
.results { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.results-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 12px; }
.results-head > div { display: flex; flex-direction: column; gap: 2px; }
.sort { display: flex; gap: 10px; align-items: center; color: var(--muted); }

/* Grids and tiles */
.grid { display: grid; gap: 22px; }
.grid-tiles { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.tile { display: flex; flex-direction: column; gap: 12px; padding: 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 4px; text-decoration: none; color: var(--text); }
.tile:hover { border-color: var(--gold); color: var(--text); }
.tile-text { display: flex; flex-direction: column; gap: 4px; }
.tile h3 { margin: 0; font-size: 1.3125rem; font-weight: 600; line-height: 1.2; }
.tile .meta { margin: 0; font-size: 1rem; color: var(--muted); }
/* Card photos (backs and highlight cards, never tuck boxes) get a poker card's rounded corners:
   1/8" on a 2.5" x 3.5" card, i.e. 5% of the width and 5/7 of that of the height. */
.card-photo { border-radius: 5% / 3.57%; }
.card-img { display: block; width: 100%; height: auto; aspect-ratio: 5 / 7; object-fit: contain; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35)); }

/* Phones */
@media (max-width: 640px) {
  body { font-size: 1.0625rem; }
  .page { padding: calc(36px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 48px max(16px, env(safe-area-inset-left)); gap: 22px; }
  .wordmark { font-size: 2.75rem; }
  .eyebrow-lg { font-size: 0.75rem; letter-spacing: 0.14em; white-space: nowrap; }
  .main-nav { gap: 16px; font-size: 1.125rem; }
  .h-display { font-size: 2.25rem; }
  .h-section { font-size: 2rem; }
  .filters { max-width: none; flex-basis: 100%; }
  .filters-panel > summary { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px; cursor: pointer; font-size: 0.875rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); list-style: none; }
  .filters-panel > summary::-webkit-details-marker { display: none; }
  .filters-panel > summary::after { content: "▾"; font-size: 1.125rem; margin-left: auto; }
  .filters-panel[open] > summary::after { content: "▴"; }
  .filters-panel[open] > .filters-body { padding-top: 4px; }
  .grid-tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
  .tile { padding: 10px; gap: 10px; }
  .tile h3 { font-size: 1.1875rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* Deck page */
.back-link { align-self: flex-start; font-size: 1.0625rem; color: var(--muted); text-decoration: none; }
.deck-hero { display: flex; flex-wrap: wrap; gap: 48px; align-items: flex-start; }
.deck-photos { flex: 1 1 300px; max-width: 380px; display: flex; flex-direction: column; gap: 20px; }
.deck-photos > .card-img { filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.45)); }
.tuck-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.tuck-pair figure { margin: 0; display: flex; flex-direction: column; gap: 6px; }
.tuck-pair figcaption { font-size: 0.9375rem; color: var(--muted); text-align: center; }
.tuck-img { display: block; width: 100%; height: auto; }
.no-photo { display: flex; align-items: center; justify-content: center; aspect-ratio: 5 / 7; border: 2px dashed var(--input-border); border-radius: 6px; color: var(--muted); font-size: 0.9375rem; font-style: italic; }
.deck-info { flex: 999 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 22px; }
.deck-title { display: flex; flex-direction: column; gap: 6px; }
.eyebrow-wide { font-size: 0.9375rem; letter-spacing: 0.24em; }
.h-deck { margin: 0; font-family: var(--display); font-weight: 400; font-size: 3.75rem; line-height: 1.05; overflow-wrap: anywhere; }
.facts { margin: 0; display: grid; grid-template-columns: minmax(130px, auto) 1fr; gap: 14px 24px; padding: 22px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.facts dt { font-size: 0.875rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold); padding-top: 3px; }
.facts dd { margin: 0; }
.facts .colors { display: flex; flex-wrap: wrap; gap: 18px; align-items: center; }
.facts .colors > span { display: inline-flex; gap: 8px; align-items: center; }
.notes { display: flex; flex-direction: column; gap: 8px; }
.notes h3 { margin: 0; }
.notes p { margin: 0; font-size: 1.1875rem; line-height: 1.55; color: var(--muted); font-style: italic; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.actions .btn { padding: 0 22px; }
.actions .link-danger { margin-left: 8px; }
.highlights { display: flex; flex-direction: column; gap: 18px; padding-top: 12px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 14px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.grid-highlights { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 28px 24px; }
.hl-card { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.hl-card figcaption { font-size: 1.125rem; line-height: 1.35; }
.hl { background: none; border: 0; padding: 0; cursor: pointer; display: block; width: 100%; }
.hl img { transition: transform 0.2s ease; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4)); }
.hl:hover img { transform: translateY(-4px); }
.hl:focus-visible { outline-offset: 6px; border-radius: 10px; }
.add-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; aspect-ratio: 5 / 7; border: 2px dashed var(--input-border); border-radius: 14px; text-decoration: none; color: var(--muted); font-size: 1.125rem; }
.add-card span { font-size: 2.5rem; line-height: 1; color: var(--gold); }
.add-card:hover { border-color: var(--gold); }

/* Lightbox */
/* 100dvh is the visible height. On iPhone Safari, 100vh reaches under the browser's own
   toolbars, which hid the buttons and swallowed taps. */
.lightbox { border: 0; padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom)); background: transparent; color: var(--text); margin: 0;
            width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; height: 100dvh; max-height: 100dvh;
            overflow: auto; overscroll-behavior: contain; }
/* While the lightbox is open, the page behind it must not scroll (iPhone Safari won't stop it on its own). */
html.lightbox-open, html.lightbox-open body { overflow: hidden; }
.lightbox[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
.lightbox::backdrop { background: var(--overlay); }
.lightbox figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 14px; min-height: 0; }
.lightbox img { max-height: min(70vh, 640px); max-height: min(62dvh, 640px); max-width: 90vw; width: auto; height: auto; filter: drop-shadow(0 16px 30px rgba(0, 0, 0, 0.6)); }
.lightbox figcaption { font-size: 1.375rem; font-weight: 600; text-align: center; }
.lightbox-buttons { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

@media (max-width: 640px) {
  .deck-hero { gap: 28px; }
  .deck-photos { max-width: none; }
  .h-deck { font-size: 2.625rem; }
  .facts { grid-template-columns: 1fr; gap: 4px; }
  .facts dd { margin-bottom: 12px; }
  .grid-highlights { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 20px 14px; }
  .lightbox { padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom)); }
}

/* Add / Edit form */
.deck-form { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-start; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 4px; padding: 28px; display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.panel-title { border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.form-main { flex: 999 1 520px; }
.form-photos { flex: 1 1 340px; max-width: 460px; gap: 22px; }
.req { color: var(--text); }
.input-lg { min-height: 48px; padding: 0 14px; font-size: 1.25rem; }
.input-short { width: 100px; }
.input-mid { max-width: 280px; }
.input-url { min-height: 40px; font-size: 1rem; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; }
.field-row-sm { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.swatches-lg { gap: 12px; }
.swatches-lg .sw { width: 38px; height: 38px; }
.swatches-lg .pill { height: 38px; border-radius: 19px; }
.boxed { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: 3px; }
.boxed .check input { width: 22px; height: 22px; }
.reveal { padding-left: 32px; }
.edition-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.hint { margin: 0; font-size: 1rem; color: var(--muted); font-style: italic; }
.tag-box { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-height: 48px; padding: 6px 10px; background: var(--input); border: 1px solid var(--input-border); border-radius: 3px; }
.tag-box:focus-within { outline: 3px solid var(--gold); outline-offset: 1px; }
.tag-box .chip { padding: 2px 4px 2px 12px; }
.new-tag-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.spade-rating { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.spade-rating .pill { margin-right: 10px; height: 36px; font-size: 0.9375rem; }
.spade { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; font-size: 2.125rem; line-height: 1; color: var(--spade-off); cursor: pointer; }
.spade.on { color: var(--gold); }
.spade:has(input:focus-visible) { outline: 3px solid var(--gold); outline-offset: 0; border-radius: 4px; }
.drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; height: 120px; border: 2px dashed var(--input-border); border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 1rem; text-align: center; padding: 8px; overflow: hidden; }
.drop:hover, .drop.dragging { border-color: var(--gold); }
.drop:focus-within { outline: 3px solid var(--gold); outline-offset: 2px; }
.drop-lg { height: 180px; font-size: 1.125rem; }
.drop-lg u { color: var(--text); }
.drop-sm { flex: 0 0 72px; height: 100px; color: var(--gold); font-size: 1.625rem; padding: 0; }
.drop.has-file { border-style: solid; border-color: var(--gold); }
.drop .preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--input); }
.drop .file-name { font-size: 0.875rem; color: var(--text); word-break: break-all; padding: 4px; }
.photo-slot { display: flex; flex-direction: column; gap: 8px; }
.current-photo { display: flex; gap: 12px; align-items: center; }
.current-photo img { width: 64px; height: auto; }
.current-photo img:not(.card-photo) { border-radius: 3px; }
.tuck-slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.existing-hl { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.hl-row, .hl-slot { display: flex; gap: 12px; align-items: flex-start; }
.hl-row > img { flex: 0 0 72px; width: 72px; height: auto; }
.hl-fields { flex: 1 1 auto; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hl-controls { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.btn-icon { width: 40px; min-height: 36px; padding: 0; font-size: 1.125rem; }
.btn-icon[disabled] { opacity: 0.35; cursor: default; }
.new-hl { display: flex; flex-direction: column; gap: 14px; }
.add-slot { align-self: flex-start; }
.tip { margin: 0; padding: 14px 16px; background: var(--input); border-radius: 3px; font-size: 1rem; line-height: 1.5; color: var(--muted); }
.tip span { color: var(--gold); }
.form-actions { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding-top: 8px; border-top: 1px solid var(--border); }
.form-actions .btn-outline { padding: 0 24px; }
.cancel { margin-left: 8px; color: var(--muted); }

@media (max-width: 640px) {
  .panel { padding: 18px; gap: 20px; }
  .form-photos { max-width: none; }
  .reveal { padding-left: 0; }
  .form-actions .btn { flex: 1 1 100%; }
  .spade { width: 40px; font-size: 1.875rem; }
  .spade-rating .pill { margin-right: 6px; padding: 0 12px; }
  .cancel { margin: 6px auto 0; }
}

/* Quick-add highlight */
.quick-add { display: flex; flex-wrap: wrap; gap: 40px; align-items: flex-start; }
.quick-deck { flex: 0 1 200px; }
.quick-main { flex: 1 1 420px; max-width: 640px; gap: 20px; }
@media (max-width: 640px) { .quick-deck { display: none; } }

/* Gallery */
.gallery-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.gallery-controls { display: flex; flex-wrap: wrap; gap: 10px; }
.gallery-wall { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 34px 26px; }
.gallery-item { display: flex; flex-direction: column; gap: 10px; }
.card { perspective: 1200px; background: none; border: 0; padding: 0; display: block; width: 100%; color: inherit; }
button.card { cursor: pointer; }
.card:focus-visible { outline-offset: 6px; border-radius: 10px; }
.flipper { position: relative; display: block; width: 100%; aspect-ratio: 5 / 7; transition: transform 0.6s ease; transform-style: preserve-3d; }
.card[aria-pressed="true"] .flipper { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; backface-visibility: hidden; -webkit-backface-visibility: hidden; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4)); }
.faceup { transform: rotateY(180deg); }
.gallery-caption { display: flex; flex-direction: column; }
.gallery-caption a { font-size: 1.1875rem; font-weight: 600; text-decoration: none; }
.gallery-caption span { font-size: 0.9375rem; color: var(--muted); font-style: italic; }

/* Gimmicks */
.gimmick-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 14px; padding: 16px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.chip-row { display: flex; flex-wrap: wrap; gap: 10px; }

@media (max-width: 640px) {
  .gallery-wall { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 24px 16px; }
  .gallery-controls .btn { flex: 1 1 auto; }
}
.edition-hint { flex-basis: 100%; }

/* Singles: a salon wall, featured cards hang at double size */
.salon { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-auto-flow: dense; gap: 22px; }
.salon-item { margin: 0; min-width: 0; align-self: start; }
.salon-item.featured { grid-column: span 2; grid-row: span 2; }
.salon-item .hl:hover img { transform: translateY(-4px); }
.salon-item .hl img { transition: transform 0.2s ease; }
.lightbox-note { margin: 0; max-width: 40rem; color: var(--muted); font-style: italic; text-align: center; }
@media (max-width: 640px) {
  .salon { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
}

/* Wide screens: a wider page (7 card backs across on the Gallery, 6 decks beside the Collection filters)
   and more room for Photos on the Add / Edit form. Smaller screens keep the 1240px page. */
@media (min-width: 1700px) {
  .page { max-width: 1648px; }
  .form-photos { flex-basis: 600px; max-width: 640px; }
}

/* Tags page: one row per tag, wrapping on phones */
.tag-group { display: flex; flex-direction: column; gap: 8px; }
.tag-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.tag-row { scroll-margin-top: 24px; }
.tag-row-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.tag-row-form input.input { flex: 1 1 180px; width: auto; min-width: 0; }
.tag-row-form select.input { flex: 1 1 130px; width: auto; min-width: 0; max-width: 220px; }
.tag-count { flex: none; color: var(--muted); font-size: 1rem; min-width: 4.5em; }

/* Other backs: a compact grid of small cards (a spectrum deck has 54) */
.alt-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 10px 8px; }
.alt-grid:empty { display: none; }
.alt-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.alt-item img, .alt-strip img { display: block; width: 100%; height: auto; }
.alt-item .check-sm { margin-top: 0; justify-content: center; min-height: 32px; }
.alt-item .check input { width: 18px; height: 18px; }
.alt-drop { height: auto; min-height: 72px; color: var(--gold); font-size: 1rem; }
.alt-strip { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 14px; }
@media (max-width: 640px) { .alt-strip { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; } }

/* TV slideshow: one card at a time, large, on the green, with a museum-style label beside it
   (below it on a tall screen). The controls fade in on a tap or mouse move. */
body.slideshow { margin: 0; height: 100vh; height: 100dvh; overflow: hidden; background: var(--bg); cursor: none; }
body.slideshow.awake { cursor: auto; }
.stage { position: fixed; inset: 0; }
.slide { position: absolute; inset: 0; margin: 0; display: flex; align-items: center; justify-content: center; gap: 5vw;
         padding: calc(4vh + env(safe-area-inset-top)) max(6vw, env(safe-area-inset-right))
                  calc(4vh + env(safe-area-inset-bottom)) max(6vw, env(safe-area-inset-left));
         opacity: 0; transition: opacity 1.2s ease; }
.slide.on { opacity: 1; }
.slide img { height: auto; width: auto; max-height: 86vh; max-height: 86dvh; max-width: 52vw; filter: drop-shadow(0 18px 36px rgba(0, 0, 0, 0.55)); }
.placard { display: flex; flex-direction: column; gap: 1.2vh; max-width: 36vw; }
.placard-title { font-family: var(--display); font-size: clamp(2rem, 4.5vw, 5rem); line-height: 1.1; color: var(--text); }
.placard-note { font-style: italic; font-size: clamp(1rem, 1.7vw, 1.9rem); color: var(--muted); }
.placard-details { font-size: clamp(0.95rem, 1.4vw, 1.6rem); color: var(--muted); letter-spacing: 0.02em; }
.placard span:empty { display: none; }
.slideshow-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 10vw; text-align: center; font-size: 1.5rem; color: var(--muted); }
.slideshow-controls { position: fixed; left: 0; right: 0; bottom: 0; padding: 16px max(16px, env(safe-area-inset-left)) calc(16px + env(safe-area-inset-bottom));
                      background: linear-gradient(transparent, rgba(8, 26, 20, 0.92) 40%); opacity: 0; pointer-events: none; transition: opacity 0.4s ease; }
body.slideshow.awake .slideshow-controls { opacity: 1; pointer-events: auto; }
.slideshow-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.slideshow-settings { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px 32px; margin-top: 16px; }
.slideshow-settings fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.slideshow-settings .field { flex-direction: row; align-items: center; gap: 10px; }
@media (max-aspect-ratio: 1/1) {
  .slide { flex-direction: column; gap: 2.5vh; }
  .slide img { max-height: 70vh; max-height: 70dvh; max-width: 86vw; }
  .placard { max-width: 86vw; text-align: center; align-items: center; }
  .placard-title { font-size: clamp(1.75rem, 7.5vw, 3.25rem); }
  .placard-note { font-size: clamp(1rem, 3.8vw, 1.4rem); }
}
@media (prefers-reduced-motion: reduce) { .slide { transition: none; } }

/* Deck of the Day: the panel above the Collection, with the card back and highlight cards fanned out.
   The fan opens when the page loads and spreads a little wider under the pointer. */
.dotd { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 24px; align-items: center;
        padding: 26px 32px; overflow: hidden; background: var(--panel); border: 1px solid var(--gold); border-radius: 4px; }
.dotd-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.dotd .label, .dotd .meta { margin: 0; }
.dotd .meta { color: var(--muted); }
.dotd h2 a { color: inherit; text-decoration: none; }
.dotd h2 a:hover { color: var(--gold); }
.dotd-stored { margin: 4px 0 0; color: var(--muted); font-size: 1rem; }
.dotd-stored b { color: var(--text); font-weight: 500; }
.dotd-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.dotd-recent { display: flex; flex-direction: column; gap: 6px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.dotd-recent ol { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.dotd-recent li { width: 40px; }
.dotd-recent a { display: block; opacity: 0.85; }
.dotd-recent a:hover { opacity: 1; }
.dotd-recent .card-img { filter: none; }
.spread { position: relative; display: block; height: 300px; }
.spread img { position: absolute; top: 20px; left: 50%; width: 170px; height: auto; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
              transform-origin: 50% 120%; transform: translateX(-50%) rotate(var(--r));
              transition: transform 0.25s; animation: spread-open 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) 0.15s backwards; }
@keyframes spread-open { from { transform: translateX(-50%) rotate(0deg); } }
@media (hover: hover) {
  .spread:hover img { transform: translateX(-50%) rotate(calc(var(--r) * 1.25)); }
}
@media (max-width: 640px) {
  .dotd { grid-template-columns: 1fr; padding: 18px; gap: 4px; }
  .dotd .spread { order: -1; height: 230px; }
  .spread img { width: 118px; top: 22px; }
}

/* Footer: the header's double gold rule again, with the four suits, then the cabinet in one line and links. */
.site-footer { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 28px; text-align: center; }
.footer-ornament { display: flex; align-items: center; gap: 18px; width: 100%; margin: 0 0 6px; color: var(--gold); font-size: 1rem; letter-spacing: 0.4em; }
.footer-ornament::before, .footer-ornament::after { content: ""; flex: 1; height: 1px; background: var(--gold); box-shadow: 0 -4px 0 0 var(--gold); }
.footer-ornament span { margin-right: -0.4em; }
.footer-tally { margin: 0; color: var(--muted); font-style: italic; }
.footer-tally a { color: var(--text); }
.footer-tally a:hover { color: var(--gold); }
.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 28px; font-size: 1.0625rem; }
.footer-links a { color: var(--muted); text-decoration: none; padding: 8px 0; }
.footer-links a:hover { color: var(--gold); }

/* Tags page: adding a tag, in a panel above the groups */
.tag-add { display: flex; flex-direction: column; gap: 4px; padding: 14px 20px 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 4px; }
.tag-add .label { margin: 0; }
.tag-add .tag-row-form { border-bottom: 0; }

/* "Add many at once" boxes on the Add / Edit form (highlight cards, Other backs) */
.bulk-upload { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
