/* Scheme 03: ivory card archive, ink sidebars and crimson navigation.
   Scoped to out-of-match surfaces; card/economy and battle layout are untouched. */
.archive-surface {
 --archive-paper: #f1e7cd; --archive-ink: #141316; --archive-red: #ad1831;
 --ui-text: #f5ecd8; --ui-muted: #bdb4a8; --ui-metal: #e2d0a3; --ui-accent: #bb1c36;
 --archive-scene: url('./assets/ui/crown-rebellion-bg.webp');
 color: var(--archive-paper); font-family: system-ui, sans-serif; letter-spacing: 0;
 scrollbar-width: thin; scrollbar-color: #ad1831 #181719;
}
.archive-logo { width: 100%; max-width: 230px; height: auto; object-fit: contain; display: block; }
.archive-title { margin: 18px 0; color: #fff2d7; font: 900 italic 42px/1.2 'Songti SC',serif; text-shadow: 3px 3px #991a2f; }
.archive-kicker,.archive-rail-label { color: #d5c5a6; font-size: 10px; letter-spacing: .12em; }
.archive-rail-label { margin-top: 8px; }
body :is(#collectionEditor,#libraryOverlay,#deckBuilderOverlay,#deckNameDialog,#deckDetailsDialog,#deckCodeDialog).archive-surface button { color: #f5ecd8; background: #19181b; border: 1px solid #6c6257; border-radius: 0; box-shadow: none; font-size: 13px; font-weight: 600; min-height: 36px; transition: background-color .15s,color .15s,translate .15s; }
body :is(#collectionEditor,#libraryOverlay,#deckBuilderOverlay,#deckNameDialog,#deckDetailsDialog,#deckCodeDialog).archive-surface button.primary-button,body :is(#collectionEditor,#libraryOverlay,#deckBuilderOverlay,#deckNameDialog,#deckDetailsDialog,#deckCodeDialog).archive-surface button[aria-pressed='true']:not(.card),body :is(#collectionEditor,#libraryOverlay,#deckBuilderOverlay,#deckNameDialog,#deckDetailsDialog,#deckCodeDialog).archive-surface button.active { color: #fff3df; background: #a41930; border-color: #bf6d6d; }
body :is(#collectionEditor,#libraryOverlay,#deckBuilderOverlay,#deckNameDialog,#deckDetailsDialog,#deckCodeDialog).archive-surface button:not(:disabled):not(.card):hover,body :is(#collectionEditor,#libraryOverlay,#deckBuilderOverlay,#deckNameDialog,#deckDetailsDialog,#deckCodeDialog).archive-surface button:not(:disabled):not(.card):focus-visible { background: #fff7e7; color: #111; border-color: #a41930; box-shadow: 3px 3px 0 #a41930; transform: none; translate: 0 -1px; }
body :is(#collectionEditor,#libraryOverlay,#deckBuilderOverlay,#deckNameDialog,#deckDetailsDialog,#deckCodeDialog).archive-surface button:disabled { opacity: .4; cursor: not-allowed; }
body :is(#collectionEditor,#libraryOverlay,#deckBuilderOverlay,#deckNameDialog,#deckDetailsDialog,#deckCodeDialog).archive-surface button:focus-visible,body .archive-surface input:focus-visible,body .archive-surface select:focus-visible { outline: 2px solid #c22a42; outline-offset: 3px; }
body .archive-surface :is(input:not([type='checkbox']),select,textarea) { background: #171619; color: #f5ecd8; border: 1px solid #6e665b; border-radius: 0; min-height: 36px; padding: 6px 9px; font: 13px system-ui; }
body :is(#collectionEditor,#libraryOverlay,#deckBuilderOverlay,#deckNameDialog,#deckDetailsDialog,#deckCodeDialog).archive-surface button svg { width: 18px; height: 18px; }
/* The editor is a real three-column workspace, not an enlarged dialog. */
body #collectionEditor.archive-surface[open] {
 position: fixed; inset: 0; margin: 0; width: 100%; max-width: none; height: 100dvh; max-height: none;
 padding: max(16px,env(safe-area-inset-top)) max(18px,env(safe-area-inset-right)) max(14px,env(safe-area-inset-bottom)) max(18px,env(safe-area-inset-left));
 display: grid; grid-template-columns: 205px minmax(0,1fr) 230px; grid-template-rows: 55px 48px 40px minmax(0,1fr) 58px; gap: 0 18px;
 background: linear-gradient(100deg,#111014ee 0 17%,#11101492 38%,#111014dc 100%),var(--archive-scene) center/cover; border: 0; border-radius: 0; overflow: hidden;
}
/* Compact deck ledger: stable columns and one hover surface per row. */
#collectionEditor.archive-surface .archive-editor-rail { grid-column: 1; grid-row: 1/-1; display: flex; flex-direction: column; min-height: 0; padding: 4px 12px 0 0; border-right: 1px solid #e4cfad35; }
#collectionEditor.archive-surface .archive-editor-rail .archive-logo { width: 160px; max-width: 100%; max-height: 58px; object-position: left; }
#collectionEditor.archive-surface .archive-kicker { display: none; }
#collectionEditor.archive-surface .archive-title { font-size: 28px; margin: 8px 0 14px; text-shadow: 2px 2px #991a2f; }
#collectionEditor.archive-surface .archive-rail-label { margin: 0; font-size: 10px; letter-spacing: .08em; }
#collectionEditor.archive-surface #collectionDeckCount { margin: 5px 0 12px; font-size: 13px; color: #fff4df; line-height: 1.5; font-variant-numeric: tabular-nums; }
#collectionEditor.archive-surface #collectionDeckSummary { display: block; min-height: 0; flex: 1; border: 0; padding: 0 4px 0 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
#collectionEditor.archive-surface #collectionDeckSummary .deck-cost-curve { margin: 0; height: 76px; min-height: 0; gap: 5px; }
#collectionEditor.archive-surface .deck-cost-bin { font-size: 10px; min-height: 0; height: 76px; gap: 3px; color: #d8cdb8; }
#collectionEditor.archive-surface .deck-cost-bin i { background: #e3d4b4; border: 0; }
#collectionEditor.archive-surface .deck-cost-bin small { font-size: 10px; color: #ad9f87; }
#collectionEditor.archive-surface .deck-composition { margin: 9px 0 0; padding: 8px 0; }
#collectionEditor.archive-surface .deck-composition > span { display: flex; align-items: baseline; justify-content: center; gap: 4px; }
#collectionEditor.archive-surface .deck-composition b { font-size: 15px; color: #eee3cb; }
#collectionEditor.archive-surface .deck-composition small { font-size: 9px; }
#collectionEditor.archive-surface #collectionDeckSummary h4 { margin: 14px 0 6px; font-size: 11px; letter-spacing: .08em; color: #bdae94; }
#collectionEditor.archive-surface .deck-summary-line { display: flex; align-items: center; min-height: 40px; gap: 0; margin: 3px 0; border: 1px solid #ffffff0c; background: #18161be0; transition: background-color .12s; }
body #collectionEditor.archive-surface .deck-summary-row { display: grid; grid-template-columns: 18px 24px minmax(0,1fr) 22px; width: auto; flex: 1; min-width: 0; min-height: 38px; height: 38px; overflow: hidden; padding: 2px 4px; gap: 5px; border: 0; background: transparent; font-size: 11px; text-align: left; }
#collectionEditor.archive-surface .deck-summary-row img { width: 24px; height: 34px; object-fit: cover; border-radius: 1px; }
#collectionEditor.archive-surface .deck-row-cost { width: 18px; height: 22px; display: grid; place-items: center; background: #832338; color: #fff1da; font-size: 11px; font-weight: 700; }
#collectionEditor.archive-surface .deck-row-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: inherit; }
#collectionEditor.archive-surface .deck-row-count { color: #e8dcc4; font-size: 10px; text-align: center; font-variant-numeric: tabular-nums; }
body #collectionEditor.archive-surface .deck-summary-line .deck-row-remove { flex: 0 0 25px; min-width: 25px; width: 25px; height: 36px; min-height: 36px; margin: 0; padding: 3px; border: 0; border-left: 1px solid #ffffff15; background: transparent; color: #a99d88; }
body #collectionEditor.archive-surface .deck-summary-line:has(button:not(:disabled):is(:hover,:focus-visible)) { background: #fff4df; border-color: #fff4df; box-shadow: inset 3px 0 #b11d35; }
body #collectionEditor.archive-surface .deck-summary-line:has(button:not(:disabled):is(:hover,:focus-visible)) :is(.deck-summary-row,.deck-row-count,.deck-row-remove) { color: #181317; background: transparent; box-shadow: none; translate: none; border-color: #21171920; }
body #collectionEditor.archive-surface .deck-summary-line .deck-row-remove:not(:disabled):is(:hover,:focus-visible) { color: #a4142e; background: #a4142e16; }
#collectionEditor.archive-surface header { grid-column: 2/4; grid-row: 1; flex-wrap: nowrap; padding: 0 0 8px; gap: 8px; border: 0; min-width: 0; }
#collectionEditor.archive-surface header label { font-size: 12px; color: #ede2c8; }
#collectionEditor.archive-surface #collectionDeckName { width: min(240px,22vw); }
#collectionEditor.archive-surface #collectionEditorBack { margin-left: auto; flex-shrink: 0; }
#collectionEditor.archive-surface .collection-editor-tools { grid-column: 2; grid-row: 2; padding: 9px 12px 0; gap: 6px; flex-wrap: nowrap; min-width: 0; background: var(--archive-paper); }
#collectionEditor.archive-surface .collection-editor-tools > div { flex-shrink: 0; }
#collectionEditor.archive-surface .collection-editor-tools button { font-size: 12px; padding: 5px 10px; }
#collectionEditor.archive-surface #collectionCardSearch { min-width: 70px; width: 0; flex: 1; }
#collectionEditor.archive-surface .collection-editor-tools select { max-width: 105px; min-width: 0; width: 82px; font-size: 12px; }
#collectionEditor.archive-surface .collection-editor-scope { grid-column: 2; grid-row: 3; background: var(--archive-paper); padding: 5px 12px; min-width: 0; flex-wrap: nowrap; gap: 6px; }
#collectionEditor.archive-surface #collectionCardResults { color: #605647; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 10px; min-width: 0; }
#collectionEditor.archive-surface .collection-editor-scope button { min-height: 28px; height: 28px; font-size: 11px; padding: 3px 7px; }
#collectionEditor.archive-surface .collection-editor-body { display: contents; }
#collectionEditor.archive-surface #collectionCardGrid { grid-column: 2; grid-row: 4; display: grid; grid-template-columns: repeat(auto-fill,minmax(140px,1fr)); align-content: start; align-items: start; justify-items: center; gap: 18px 12px; background: var(--archive-paper); color: #191718; padding: 14px 16px 22px; min-height: 0; overflow: auto; scrollbar-gutter: stable; scrollbar-color: #a41930 #e1d5b8; }
#collectionEditor.archive-surface .collection-build-card { width: 100%; max-width: 190px; min-width: 0; gap: 7px; }
#collectionEditor.archive-surface .collection-card-count { height: 30px; grid-template-columns: 32px 1fr 32px; color: #171518; }
#collectionEditor.archive-surface .collection-card-count strong { font-size: 13px; color: #181517; }
#collectionEditor.archive-surface .collection-card-count button { height: 30px; min-height: 30px; font-size: 18px; border-color: #766655; padding: 0; }
/* Use the exact 2:3 card geometry and artwork in every collection tile. */
body #collectionEditor.archive-surface #collectionCardGrid .card,
body #collectionEditor.archive-surface .archive-card-face,
body :is(#libraryOverlay.archive-surface #cardLibrary,#deckBuilderOverlay.archive-surface #deckBuilderCards) .card {
 container-type: inline-size; position: relative; display: block; flex: none; width: 100%; height: auto; min-height: 0; aspect-ratio: 2/3; max-width: none;
 padding: 0; margin: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; overflow: visible; transform: none; text-align: center;
}
body #collectionEditor.archive-surface .card .card-art,
body :is(#libraryOverlay.archive-surface #cardLibrary,#deckBuilderOverlay.archive-surface #deckBuilderCards) .card .card-art { display: block; position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 0; background: transparent; aspect-ratio: 2/3; }
body #collectionEditor.archive-surface .card .card-art img,
body :is(#libraryOverlay.archive-surface #cardLibrary,#deckBuilderOverlay.archive-surface #deckBuilderCards) .card .card-art img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; margin: 0; }
body #collectionEditor.archive-surface .card.ornate-card .card-art img,
body :is(#libraryOverlay.archive-surface #cardLibrary,#deckBuilderOverlay.archive-surface #deckBuilderCards) .card.ornate-card .card-art img { object-fit: cover; }
body #collectionEditor.archive-surface .card .card-name,
body :is(#libraryOverlay.archive-surface #cardLibrary,#deckBuilderOverlay.archive-surface #deckBuilderCards) .card .card-name { position: absolute; top: 8%; bottom: auto; left: 12%; right: 10%; color: #fff2d6; text-shadow: 0 1px 3px #000; font: 700 min(8cqw,calc(77cqw / var(--title-length,8))) / 1.2 'Songti SC',serif; white-space: nowrap; padding: 0; margin: 0; display: block; background: none; z-index: 4; }
body #collectionEditor.archive-surface .card.printed-card .card-name,
body :is(#libraryOverlay.archive-surface #cardLibrary,#deckBuilderOverlay.archive-surface #deckBuilderCards) .card.printed-card .card-name { display: none; }
body #collectionEditor.archive-surface .card :is(.card-type,.card-text,.keywords,.rarity,.stats),
body :is(#libraryOverlay.archive-surface #cardLibrary,#deckBuilderOverlay.archive-surface #deckBuilderCards) .card :is(.card-type,.card-text,.keywords,.rarity,.stats) { display: none; }
body #collectionEditor.archive-surface .card .card-top,
body :is(#libraryOverlay.archive-surface #cardLibrary,#deckBuilderOverlay.archive-surface #deckBuilderCards) .card .card-top { display: block; position: absolute; top: 0; left: 0; z-index: 5; margin: 0; padding: 0; width: auto; }
body #collectionEditor.archive-surface .card .cost,
body :is(#libraryOverlay.archive-surface #cardLibrary,#deckBuilderOverlay.archive-surface #deckBuilderCards) .card .cost { position: relative; inset: auto; width: 19cqw; height: 19cqw; min-width: 0; min-height: 0; font: 700 12cqw / 1 'Songti SC',serif; display: grid; place-items: center; background: #6e253e; color: #fff4df; border: 1px solid #ecd3a0; border-radius: 50%; box-shadow: none; }
#collectionEditor.archive-surface .archive-selected .card { outline: 2px solid #b31f36; outline-offset: 4px; }
#collectionEditor.archive-surface .card:hover { filter: brightness(1.06); }
#collectionEditor.archive-surface .archive-card-details { grid-column: 3; grid-row: 2/5; display: flex; flex-direction: column; align-items: center; gap: 16px; min-width: 0; min-height: 0; overflow: auto; background: #151418ef; padding: 16px; border-top: 3px solid #a51a31; }
#collectionEditor.archive-surface .archive-card-face { width: min(145px,100%); flex-shrink: 0; }
.archive-card-reading { width: 100%; color: #e8dfcf; }
.archive-card-reading h3 { font: 700 22px/1.4 'Songti SC',serif; margin: 9px 0; }
.archive-card-meta { color: #bbab91; font-size: 11px; }
.archive-card-reading p { font-size: 13px; line-height: 1.9; margin: 10px 0 18px; white-space: pre-line; }
.archive-card-reading button { width: 100%; font-size: 12px; }
#collectionEditor.archive-surface footer { grid-column: 2/4; grid-row: 5; border: 0; padding: 10px 0 0; flex-wrap: nowrap; }
#collectionEditor.archive-surface footer button { min-height: 40px; padding: 8px 18px; white-space: nowrap; }
#collectionEditor.archive-surface #collectionEditorError { color: #ffcebf; }
#collectionEditor.archive-surface #collectionSummaryToggle { display: none; }
/* Full-effect mode is optional, with a bounded card image and readable text below. */
body #collectionEditor.archive-surface[data-display='effect'] #collectionCardGrid .card { aspect-ratio: auto; height: 380px; display: flex; flex-direction: column; padding: 8px; background: #e8ddc3; color: #171518; }
body #collectionEditor.archive-surface[data-display='effect'] #collectionCardGrid .card .card-art { position: relative; width: 108px; height: 162px; flex-shrink: 0; align-self: center; }
body #collectionEditor.archive-surface[data-display='effect'] #collectionCardGrid .card .card-name { display: block; position: static; color: #171518; font-size: 14px; text-shadow: none; margin: 6px 0; }
body #collectionEditor.archive-surface[data-display='effect'] #collectionCardGrid .card .card-text { display: block; flex: 1; min-height: 0; overflow: auto; color: #302a23; font-size: 12px; line-height: 1.7; text-align: left; }
/* Collection, presets and legacy quick builder use the same material language. */
body #libraryOverlay.archive-surface,body #deckBuilderOverlay.archive-surface { padding: 16px max(18px,env(safe-area-inset-right)) 16px max(18px,env(safe-area-inset-left)); background: linear-gradient(#0d0b1099,#0d0b10bb),var(--archive-scene) center/cover; backdrop-filter: none; }
body #libraryOverlay.archive-surface .library-panel,body #deckBuilderOverlay.archive-surface .library-panel { width: 100%; max-width: none; height: calc(100dvh - 32px); max-height: none; padding: 14px 22px; margin: 0; border: 1px solid #a99169; border-radius: 0; background: #141316f2; box-shadow: none; display: flex; flex-direction: column; overflow: hidden; }
body #libraryOverlay.archive-surface .library-header { flex-wrap: nowrap; padding: 0 0 12px; gap: 18px; border-bottom: 1px solid #7e6657; flex: none; }
body #libraryOverlay.archive-surface .archive-small-logo { width: 148px; max-height: 70px; }
body #libraryOverlay.archive-surface .library-header h2 { color: #fff1d6; font: 800 italic 26px/1.3 'Songti SC',serif; text-shadow: 2px 2px #a41930; }
body #libraryOverlay.archive-surface .library-header .eyebrow { display: none; }
body #libraryOverlay.archive-surface .collection-nav { margin-left: auto; width: auto; order: initial; padding: 0; flex-wrap: nowrap; }
body #libraryOverlay.archive-surface .collection-nav button { min-width: 80px; padding: 7px 12px; }
body #libraryOverlay.archive-surface .collection-nav [aria-pressed='true'] { background: #a41930; color: #fff2db; }
body #libraryOverlay.archive-surface .deck-collection-toolbar { padding: 12px 0; }
body #libraryOverlay.archive-surface #savedDeckList { background: #19171b; padding: 18px; color: #eee3cf; border-top: 2px solid #9d2639; }
body #libraryOverlay.archive-surface #deckPresetGrid { background: var(--archive-paper); padding: 18px; color: #161416; border-top: 3px solid #b2243b; }
body #libraryOverlay.archive-surface .saved-deck { background: #18171a; border-radius: 0; border-color: #a59a84; }
body #libraryOverlay.archive-surface .saved-deck.is-selected { outline: 2px solid #ad1831; }
body #libraryOverlay.archive-surface .saved-deck-cover { background: transparent; }
body #libraryOverlay.archive-surface .deck-artwork { height: 190px; }
body #libraryOverlay.archive-surface .workshop-preset :is(h3,p,small),body #libraryOverlay.archive-surface .preset-size { color: #292321; }
body #libraryOverlay.archive-surface #cardLibrary:not(.hidden) { flex: 1; min-height: 0; overflow: auto; background: var(--archive-paper); border-top: 3px solid #a41930; padding: 18px; display: grid; grid-template-columns: repeat(auto-fill,minmax(135px,1fr)); gap: 20px; grid-auto-rows: max-content; align-items: start; align-content: start; justify-items: center; }
body :is(#libraryOverlay.archive-surface #cardLibrary,#deckBuilderOverlay.archive-surface #deckBuilderCards) .card { max-width: 180px; min-height: auto; align-self: start; }
body #libraryOverlay.archive-surface #librarySeriesIntro { background: transparent; margin: 4px 0; padding: 4px 0; }
body #libraryOverlay.archive-surface #librarySeriesIntro p { display: none; }
body #libraryOverlay.archive-surface #libraryFilters { padding: 8px 0; flex: none; }
body #libraryOverlay.archive-surface #libraryTerms { margin: 4px 0; }
body #libraryOverlay.archive-surface .library-tabs { gap: 5px; margin: 6px 0; flex: none; }
body #libraryOverlay.archive-surface .gallery-details { background: var(--archive-paper); color: #171518; border: 0; padding: 22px; }
body #libraryOverlay.archive-surface .gallery-details :is(h2,h3,p,small,dt,dd) { color: inherit; }
body #deckBuilderOverlay.archive-surface .deck-builder-cards { background: var(--archive-paper); padding: 16px; min-height: 0; overflow: auto; }
/* Compact landscape: preserve card proportions instead of compressing their height. */
@media (max-width: 1100px) {
 body #collectionEditor.archive-surface[open] { grid-template-columns: 170px minmax(0,1fr) 190px; column-gap: 12px; padding: 12px; }
 #collectionEditor.archive-surface #collectionCardGrid { grid-template-columns: repeat(auto-fill,minmax(115px,1fr)); gap: 14px 10px; padding: 12px; }
 #collectionEditor.archive-surface .archive-title { font-size: 26px; }
 body #libraryOverlay.archive-surface .archive-small-logo { width: 104px; }
 body #libraryOverlay.archive-surface .library-header h2 { font-size: 20px; }
}
@media (max-width: 1000px) {
 body #collectionEditor.archive-surface[open] { grid-template-columns: 150px minmax(0,1fr); grid-template-rows: 44px 44px 34px minmax(0,1fr) 48px; }
 #collectionEditor.archive-surface .archive-card-details { display: none; }
 #collectionEditor.archive-surface :is(header,footer) { grid-column: 2; }
 #collectionEditor.archive-surface .archive-title { font-size: 25px; margin: 12px 0; }
 #collectionEditor.archive-surface .archive-kicker { display: none; }
 #collectionEditor.archive-surface .deck-summary-row img { display: none; }
 #collectionEditor.archive-surface .deck-row-cost { width: 15px; }
 body #collectionEditor.archive-surface .deck-summary-row { grid-template-columns: 16px minmax(0,1fr) 19px; font-size: 11px; gap: 3px; padding-inline: 3px; }
 #collectionEditor.archive-surface #collectionDeckCount { font-size: 12px; margin: 6px 0; }
 #collectionEditor.archive-surface #collectionDeckName { width: 150px; }
 #collectionEditor.archive-surface .collection-editor-tools { padding: 5px 8px 0; }
 #collectionEditor.archive-surface .collection-editor-scope { padding: 3px 8px; }
 #collectionEditor.archive-surface header label { font-size: 0; }
 #collectionEditor.archive-surface #collectionCardGrid { grid-template-columns: repeat(auto-fill,minmax(108px,1fr)); }
 #collectionEditor.archive-surface footer button { font-size: 12px; min-height: 36px; padding: 5px 10px; }
 #collectionEditor.archive-surface #collectionEditorError { font-size: 10px; }
 body #collectionEditor.archive-surface :is(input,select) { font-size: 16px; }
 #collectionEditor.archive-surface .collection-editor-tools select { max-width: 90px; font-size: 16px; }
 #collectionEditor.archive-surface #collectionCardResults { display: none; }
 body #libraryOverlay.archive-surface .archive-small-logo { display: none; }
}
@media (max-height: 520px) and (orientation: landscape) {
 body #collectionEditor.archive-surface[open] { padding: 8px max(8px,env(safe-area-inset-right)) 8px max(8px,env(safe-area-inset-left)); grid-template-columns: 145px minmax(0,1fr); grid-template-rows: 38px 40px 32px minmax(0,1fr) 42px; column-gap: 10px; }
 #collectionEditor.archive-surface header { grid-column: 2; padding-bottom: 4px; gap: 5px; }
 #collectionEditor.archive-surface .archive-card-details { display: none; }
 #collectionEditor.archive-surface .archive-editor-rail { padding-top: 0; }
 #collectionEditor.archive-surface .archive-title { font-size: 24px; margin: 7px 0; }
 #collectionEditor.archive-surface .archive-logo { max-height: 42px; object-position: left; }
 #collectionEditor.archive-surface .archive-kicker,#collectionEditor.archive-surface .archive-rail-label { display: none; }
 #collectionEditor.archive-surface #collectionDeckCount { font-size: 11px; margin: 4px 0; width: auto; }
 #collectionEditor.archive-surface .deck-cost-curve,#collectionEditor.archive-surface .deck-cost-bin { height: 64px; min-height: 64px; }
 #collectionEditor.archive-surface .deck-composition { display: none; }
 #collectionEditor.archive-surface #collectionCardGrid { grid-template-columns: repeat(auto-fill,minmax(100px,1fr)); gap: 12px 9px; padding: 9px; }
 #collectionEditor.archive-surface .collection-build-card { max-width: 128px; }
 #collectionEditor.archive-surface footer { grid-column: 2; padding-top: 5px; }
 #collectionEditor.archive-surface footer button { min-height: 34px; }
 #collectionEditor.archive-surface .collection-card-count,#collectionEditor.archive-surface .collection-card-count button { min-height: 30px; height: 30px; }
 body #libraryOverlay.archive-surface { padding: 8px max(10px,env(safe-area-inset-right)) 8px max(10px,env(safe-area-inset-left)); }
 body #libraryOverlay.archive-surface .library-panel { height: calc(100dvh - 16px); padding: 8px 12px; }
 body #libraryOverlay.archive-surface .library-header { gap: 8px; padding: 0 0 5px; }
 body #libraryOverlay.archive-surface .library-header h2 { font-size: 18px; }
 body #libraryOverlay.archive-surface .collection-nav button { min-height: 32px; min-width: 70px; padding: 4px 8px; font-size: 12px; }
 body #libraryOverlay.archive-surface :is(.deck-collection-toolbar,.deck-collection-filters) { padding: 5px 0; gap: 6px; }
 body #libraryOverlay.archive-surface #savedDeckList { padding: 10px; }
 body #libraryOverlay.archive-surface .deck-artwork { height: 88px; width: 64px; padding: 3px; }
 body #libraryOverlay.archive-surface #cardLibrary:not(.hidden) { grid-template-columns: repeat(auto-fill,minmax(100px,1fr)); padding: 12px; gap: 15px; }
 body :is(#libraryOverlay.archive-surface #cardLibrary,#deckBuilderOverlay.archive-surface #deckBuilderCards) .card { max-width: 128px; min-height: auto; }
 body #libraryOverlay.archive-surface #librarySeriesIntro { display: none; }
}
@media (max-width: 650px) {
 body #collectionEditor.archive-surface[open] { grid-template-columns: 118px minmax(0,1fr); column-gap: 7px; }
 #collectionEditor.archive-surface #collectionDeckName { width: 110px; }
 #collectionEditor.archive-surface .archive-title { font-size: 21px; }
 #collectionEditor.archive-surface .collection-editor-tools button { padding: 3px 5px; font-size: 11px; }
 #collectionEditor.archive-surface .collection-editor-tools select { width: 65px; }
 #collectionEditor.archive-surface #collectionCardSearch { min-width: 42px; }
 #collectionEditor.archive-surface #collectionCardGrid { grid-template-columns: repeat(auto-fill,minmax(94px,1fr)); }
 #collectionEditor.archive-surface .editor-history button { width: 28px; height: 30px; min-height: 30px; padding: 5px; }
 #collectionEditor.archive-surface #collectionDraftState { font-size: 9px; }
}
@media(prefers-reduced-motion:reduce) { .archive-surface * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
body.salon-reduced-motion .archive-surface * { animation: none; transition: none; }


body #libraryOverlay.archive-surface.library-gallery-mode #cardLibrary { display: none; }
body #deckBuilderOverlay.archive-surface .deck-builder-section-grid { grid-template-columns: repeat(auto-fill,minmax(140px,1fr)); gap: 16px; align-items: start; }
body #deckBuilderOverlay.archive-surface .deck-builder-card { max-width: 180px; width: 100%; justify-self: center; background: transparent; border: 0; padding: 0; }
body #deckBuilderOverlay.archive-surface .deck-builder-section-header { background: #171518; border-radius: 0; }
body #deckBuilderOverlay.archive-surface .deck-card-controls strong { color: #191718; }
@media (max-height:520px) and (orientation:landscape) {
 body #deckBuilderOverlay.archive-surface { padding: 8px; }
 body #deckBuilderOverlay.archive-surface .library-panel { height: calc(100dvh - 16px); padding: 8px; }
 body #deckBuilderOverlay.archive-surface .library-header { padding: 0; margin: 0; }
 body #deckBuilderOverlay.archive-surface .library-header h2 { font-size: 18px; }
 body #deckBuilderOverlay.archive-surface .library-header .eyebrow { display: none; }
 body #deckBuilderOverlay.archive-surface .deck-builder-toolbar { gap: 5px; padding: 5px 0; }
 body #deckBuilderOverlay.archive-surface #deckBuilderHint { display: none; }
 body #deckBuilderOverlay.archive-surface .deck-builder-actions button { min-height: 32px; font-size: 11px; padding: 4px 8px; }
 body #deckBuilderOverlay.archive-surface .deck-builder-section-grid { grid-template-columns: repeat(auto-fill,minmax(100px,1fr)); }
 body #deckBuilderOverlay.archive-surface .deck-builder-section-header { padding: 5px 8px; }
 body #deckBuilderOverlay.archive-surface .deck-builder-section-header strong { font-size: 14px; }
 body #deckBuilderOverlay.archive-surface .deck-builder-section-header p { display: none; }
 body #deckBuilderOverlay.archive-surface .deck-builder-card { max-width: 128px; }
}

/* Existing special-deck setup keeps its original controls and submit behavior. */
body #phase1Setup { background: #151316; color: #f2e7ce; border: 2px solid #b32339; border-radius: 0; box-shadow: 8px 8px #a61c3333; }
body #phase1Setup fieldset { background: #f1e7cd; color: #201a1b; border: 0; border-top: 3px solid #a61c33; padding: 12px; }
body #phase1Setup legend { background: #a61c33; color: #fff3df; padding: 3px 10px; }
body #phase1Setup label { color: #211a1b; }
body #phase1Setup select { background: #161417; color: #fff2dc; border: 1px solid #807461; border-radius: 0; }
body #phase1Setup button { background: #a61c33; color: #fff4df; border: 1px solid #db9a96; border-radius: 0; }
body #phase1Setup button:hover { background: #fff7e7; color: #121012; }

/* Card archive: consistent dark reading surface in and out of matches. */
body #cardInspector.archive-inspector { width:min(980px,calc(100vw - 48px));height:min(680px,calc(100dvh - 48px));max-height:calc(100dvh - 48px);padding:18px 24px 24px;overflow:hidden;background:linear-gradient(125deg,#35151e88,transparent 40%),#141316;color:#f4e6d0;border:1px solid #61434a;border-top:3px solid #b21d36;border-radius:0;box-shadow:9px 9px 0 #8f182b44,0 24px 70px #000b; }
body #cardInspector.archive-inspector[open] { display:grid;grid-template-rows:40px minmax(0,1fr) auto;gap:16px; }
body #cardInspector.archive-inspector .inspect-toolbar { display:flex;align-items:center;justify-content:space-between;gap:16px;border-bottom:1px solid #604047;padding:0 0 10px; }
body #cardInspector.archive-inspector .inspect-toolbar>span { color:#ecdac0;font:700 13px/1.2 system-ui;letter-spacing:.12em; }
body #cardInspector.archive-inspector .inspect-toolbar small { font:9px/1.2 system-ui;letter-spacing:.18em;color:#a78e8d;margin-left:12px; }
body #cardInspector.archive-inspector .inspect-stage { height:auto;min-height:0;grid-template-columns:minmax(0,min(340px,calc((100dvh - 180px)*.666667))) minmax(0,1fr);gap:28px;align-items:center; }
body #cardInspector.archive-inspector .inspect-front { position:relative;isolation:isolate;width:100%;height:auto;aspect-ratio:2/3;min-height:0;max-height:none;align-self:center;justify-self:center;border:0;background:transparent;box-shadow:none;container-type:inline-size; }
body #cardInspector.archive-inspector .inspect-art { display:block;width:100%;height:100%;aspect-ratio:2/3;object-fit:contain; }
body #cardInspector.archive-inspector.ornate-card .inspect-art { position:absolute;inset:0;object-fit:cover; }
body #cardInspector.archive-inspector.leader-upgrade-card .inspect-art { object-fit:contain; }
body #cardInspector.archive-inspector .inspect-front-name { font-size:min(8cqw,calc(77cqw / var(--title-length,8))); }
body #cardInspector.archive-inspector.ornate-card .inspect-front-name { top:8.6%;bottom:auto;left:12%;right:12%;padding:0;background:none;line-height:1.25;white-space:nowrap;color:#fff0d2; }
body #cardInspector.archive-inspector .inspect-back { height:100%;max-height:100%;min-height:0;align-self:stretch;display:flex;flex-direction:column;background:#1c191e;color:#f0e5d4;border:0;border-top:2px solid #ae2138;border-radius:0; }
body #cardInspector.archive-inspector header { padding:20px 22px 16px;border-bottom:1px solid #69424a; }
body #cardInspector.archive-inspector .inspect-meta { display:block;color:#cba897;font:11px/1.5 system-ui;letter-spacing:.04em; }
body #cardInspector.archive-inspector #inspectTitle { color:#fff0d7;font:800 28px/1.4 'Songti SC','STSong',serif;letter-spacing:.025em;margin:8px 0 14px; }
body #cardInspector.archive-inspector .inspect-stats { display:inline-block;margin:0;padding:6px 12px;border-left:3px solid #c52943;background:#35202a;color:#f2dbbe;font:600 13px/1.5 system-ui; }
body #cardInspector.archive-inspector .inspect-stats:empty { display:none; }
body #cardInspector.archive-inspector .inspect-reading { flex:1;min-height:0;overflow:auto;padding:20px 22px;background:transparent;overscroll-behavior:contain;touch-action:pan-y;scrollbar-width:thin;scrollbar-color:#923145 #1c191e; }
body #cardInspector.archive-inspector .inspect-effect { color:#f0e4d1;font:14px/1.9 system-ui;white-space:pre-wrap;margin:0; }
body #cardInspector.archive-inspector .inspect-keywords { margin:22px 0 0;padding-top:16px;border-top:1px solid #5c4147; }
body #cardInspector.archive-inspector .inspect-keywords:empty { display:none; }
body #cardInspector.archive-inspector .inspect-keywords dt { color:#dfb1a3;font:700 12px/1.7 system-ui; }
body #cardInspector.archive-inspector .inspect-keywords dd { color:#d0c1b8;font:12px/1.8 system-ui;margin:4px 0 15px; }
body #cardInspector.archive-inspector .inspect-actions { position:static;height:auto;min-height:0;margin:0;padding:0;background:none;border:0;justify-content:center; }
body #cardInspector.archive-inspector .inspect-actions:has(.inspect-navigation[hidden]) { display:none; }
body #cardInspector.archive-inspector :is(.inspect-actions,.inspect-toolbar) button { display:grid;place-items:center;width:36px;height:36px;min-height:36px;flex:0 0 36px;padding:7px;border:1px solid #79585a;border-radius:0;background:#322029;color:#f4e4cb;box-shadow:none;transition:background .15s,color .15s; }
body #cardInspector.archive-inspector .inspect-toolbar .inspect-close { margin:0;background:#a61a32; }
body #cardInspector.archive-inspector :is(.inspect-actions,.inspect-toolbar) button:is(:hover,:focus-visible):not(:disabled) { color:#131216;background:#fff4dd;border-color:#fff4dd;transform:none; }
body #cardInspector.archive-inspector :is(.inspect-actions,.inspect-toolbar) button svg { display:block;width:20px;height:20px; }
body #cardInspector.archive-inspector .inspect-position { color:#d7bfae;font:12px/1.5 system-ui; }
@media(max-height:550px) and (orientation:landscape) {
 body #cardInspector.archive-inspector { width:min(740px,calc(100vw - 24px));height:calc(100dvh - 16px);max-height:calc(100dvh - 16px);padding:8px 12px 10px; }
 body #cardInspector.archive-inspector[open] { grid-template-rows:36px minmax(0,1fr) auto;gap:8px; }
 body #cardInspector.archive-inspector .inspect-toolbar { padding-bottom:5px; }
 body #cardInspector.archive-inspector .inspect-stage { grid-template-columns:minmax(0,calc((100dvh - 120px)*.666667)) minmax(0,1fr);gap:14px; }
 body #cardInspector.archive-inspector header { padding:10px 12px 8px; }
 body #cardInspector.archive-inspector #inspectTitle { font-size:18px;line-height:1.3;margin:4px 0 8px; }
 body #cardInspector.archive-inspector .inspect-meta { font-size:10px; }
 body #cardInspector.archive-inspector .inspect-stats { font-size:11px;padding:3px 8px; }
 body #cardInspector.archive-inspector .inspect-reading { padding:10px 12px; }
 body #cardInspector.archive-inspector .inspect-effect { font-size:12px;line-height:1.7; }
 body #cardInspector.archive-inspector .inspect-keywords { margin-top:12px;padding-top:10px; }
 body #cardInspector.archive-inspector .inspect-keywords :is(dt,dd) { font-size:11px;line-height:1.65; }
 body #cardInspector.archive-inspector .inspect-keywords dd { margin-bottom:10px; }
}
@media(max-width:600px) and (orientation:portrait) {
 body #cardInspector.archive-inspector { width:calc(100vw - 20px);height:calc(100dvh - 24px);max-height:calc(100dvh - 24px);padding:10px 14px; }
 body #cardInspector.archive-inspector[open] { gap:10px; }
 body #cardInspector.archive-inspector .inspect-stage { grid-template-columns:1fr;grid-template-rows:minmax(0,35%) minmax(0,1fr);gap:14px; }
 body #cardInspector.archive-inspector .inspect-front { width:auto;height:100%; }
 body #cardInspector.archive-inspector #inspectTitle { font-size:20px; }
 body #cardInspector.archive-inspector header,body #cardInspector.archive-inspector .inspect-reading { padding:10px 14px; }
}
