:root {
  --bg: #07090d;
  --panel: #0d1118;
  --panel-2: #121823;
  --line: #28313b;
  --muted: #8b97a5;
  --text: #edf1f4;
  --yellow: #f1eb24;
  --cyan: #35d9e7;
  --red: #ff5266;
  --green: #78d66b;
  --blue: #5b8cff;
  --card-width: 238px;
  --header: 74px;
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); font-size: 16px; }
button, input, select { font: inherit; }
button, select, input { color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: square; stroke-linejoin: miter; }

.noise { position: fixed; inset: 0; pointer-events: none; opacity: .22; z-index: -1; background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px); background-size: 40px 40px; mask-image: linear-gradient(to bottom, black, transparent 80%); }
.topbar { height: var(--header); position: sticky; top: 0; z-index: 50; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; padding: 0 24px; background: rgba(7,9,13,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); }
.brand { display: inline-flex; width: fit-content; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; background: var(--yellow); color: #07090d; font-size: 13px; font-weight: 900; letter-spacing: -.04em; clip-path: polygon(0 0, 100% 0, 100% 74%, 76% 100%, 0 100%); }
.brand b { display: block; font: 800 15px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.brand small { color: var(--muted); font-size: 12px; }
.views { display: flex; align-items: center; height: 100%; }
.view-tab { align-self: stretch; position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 0 18px; background: transparent; border: 0; color: var(--muted); font-weight: 700; font-size: 14px; }
.view-tab svg { width: 17px; height: 17px; }
.view-tab::after { content: ""; position: absolute; left: 18px; right: 18px; bottom: -1px; height: 3px; background: transparent; }
.view-tab:hover { color: var(--text); }
.view-tab.active { color: var(--yellow); }
.view-tab.active::after { background: var(--yellow); box-shadow: 0 0 16px rgba(241,235,36,.42); }
.header-actions { justify-self: end; display: flex; align-items: center; gap: 10px; }
.source-link { font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); text-decoration: none; text-transform: uppercase; letter-spacing: .05em; }
.source-link:hover { color: var(--cyan); }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--line); background: var(--panel); }
.icon-button:hover { border-color: var(--yellow); color: var(--yellow); }
.icon-button svg { width: 19px; height: 19px; }
.mobile-only { display: none; }

.app-view { display: none; }
.app-view.active { display: block; }
#catalog-view.active { display: grid; grid-template-columns: 292px minmax(0, 1fr); }
.filters { position: sticky; top: var(--header); height: calc(100vh - var(--header)); overflow: auto; padding: 25px 22px 40px; background: rgba(13,17,24,.82); border-right: 1px solid var(--line); scrollbar-width: thin; }
.filters-head { display: flex; justify-content: space-between; align-items: start; margin-bottom: 22px; }
.eyebrow { display: block; margin-bottom: 7px; color: var(--cyan); font: 700 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(27px, 3vw, 42px); line-height: 1.05; letter-spacing: -.045em; }
h2 { margin-bottom: 0; font-size: 21px; letter-spacing: -.025em; }
.filters h2 { font-size: 23px; }
.filter-section { padding: 17px 0; border-top: 1px solid var(--line); }
.field-label { display: block; margin-bottom: 9px; color: #b8c1ca; font: 700 12px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; letter-spacing: .06em; }
.search-box { position: relative; display: flex; align-items: center; min-width: 0; height: 43px; background: #080b10; border: 1px solid #343e4a; }
.search-box:focus-within { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(53,217,231,.08); }
.search-box svg { width: 18px; height: 18px; margin-left: 12px; color: var(--muted); }
.search-box input { width: 100%; min-width: 0; height: 100%; padding: 0 10px; background: transparent; border: 0; outline: 0; font-size: 14px; }
.search-box kbd { margin-right: 8px; padding: 2px 6px; border: 1px solid var(--line); color: var(--muted); font: 11px/1.4 ui-monospace, monospace; }
select { width: 100%; height: 41px; padding: 0 34px 0 11px; appearance: none; background-color: #080b10; background-image: linear-gradient(45deg, transparent 50%, #8b97a5 50%), linear-gradient(135deg, #8b97a5 50%, transparent 50%); background-position: calc(100% - 15px) 17px, calc(100% - 10px) 17px; background-size: 5px 5px; background-repeat: no-repeat; border: 1px solid #343e4a; border-radius: 0; font-size: 14px; }
select:focus { outline: 2px solid rgba(53,217,231,.18); border-color: var(--cyan); }
.color-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.color-choice { position: relative; display: grid; place-items: center; gap: 5px; min-height: 51px; border: 1px solid var(--line); background: #080b10; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.color-choice::before { content: ""; width: 18px; height: 5px; background: var(--choice); box-shadow: 0 0 11px color-mix(in srgb, var(--choice) 55%, transparent); }
.color-choice.active { color: var(--text); border-color: var(--choice); background: color-mix(in srgb, var(--choice) 9%, #080b10); }
.check-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.check-choice { display: flex; align-items: center; gap: 8px; min-height: 35px; padding: 0 9px; border: 1px solid var(--line); background: #080b10; color: var(--muted); font-size: 13px; }
.check-choice input { appearance: none; width: 11px; height: 11px; margin: 0; border: 1px solid #66717e; }
.check-choice input:checked { background: var(--yellow); border-color: var(--yellow); box-shadow: inset 0 0 0 2px #080b10; }
.check-choice:has(input:checked) { color: var(--text); border-color: #596471; }
.split-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toggles { display: grid; gap: 11px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; color: #c4cbd2; font-size: 14px; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-row i { position: relative; flex: 0 0 auto; width: 36px; height: 20px; background: #26303b; border: 1px solid #46515d; }
.toggle-row i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; background: #7d8995; transition: transform .16s, background .16s; }
.toggle-row input:checked + i { border-color: #777412; background: #2f2e0e; }
.toggle-row input:checked + i::after { transform: translateX(16px); background: var(--yellow); }
.toggle-row.inline { justify-content: flex-start; padding-left: 5px; }
.secondary-button { min-height: 40px; padding: 0 15px; border: 1px solid #46515d; background: transparent; color: #d4dae0; font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.secondary-button:hover { color: var(--yellow); border-color: var(--yellow); }
.filters > .secondary-button { width: 100%; }

.catalog-stage { min-width: 0; padding: 38px clamp(20px, 3.4vw, 56px) 70px; }
.catalog-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.result-summary { margin: 0; color: var(--muted); font-size: 14px; }
.result-summary b { color: var(--text); }
.toolbar-controls { min-width: 190px; }
.sort-control { color: var(--muted); font: 700 11px/1 ui-monospace, monospace; text-transform: uppercase; letter-spacing: .08em; }
.sort-control select { margin-top: 7px; text-transform: none; font-family: Inter, ui-sans-serif, sans-serif; letter-spacing: 0; }
.active-filters { display: flex; flex-wrap: wrap; gap: 7px; min-height: 0; margin-bottom: 18px; }
.active-filters:empty { display: none; }
.filter-chip { display: inline-flex; align-items: center; gap: 7px; height: 29px; padding: 0 8px 0 10px; background: rgba(53,217,231,.07); border: 1px solid rgba(53,217,231,.3); color: #c9f8fc; font: 700 11px/1 ui-monospace, monospace; }
.filter-chip button { padding: 0; background: none; border: 0; color: var(--cyan); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--card-width)), 1fr)); gap: 18px; align-items: start; }
.card-tile { position: relative; min-width: 0; padding: 0; overflow: hidden; background: var(--panel); border: 1px solid var(--line); text-align: left; transition: transform .18s ease, border-color .18s ease, background .18s; }
.card-tile::after { content: ""; position: absolute; top: 0; left: 0; width: 38%; height: 3px; background: var(--card-color); box-shadow: 0 0 12px color-mix(in srgb, var(--card-color) 70%, transparent); }
.card-tile:hover, .card-tile:focus-visible { z-index: 2; transform: translateY(-3px); border-color: #637080; background: #121823; outline: none; }
.card-image-wrap { position: relative; aspect-ratio: 733 / 1024; overflow: hidden; background: #05070a; border-bottom: 1px solid var(--line); }
.card-image { display: block; width: 100%; height: 100%; object-fit: contain; object-position: center; }
[data-preview-card] { cursor: zoom-in; }
.card-number { display: block; width: fit-content; margin-bottom: 9px; padding: 4px 6px; background: #080b10; border: 1px solid #26303b; color: #d8dee5; font: 700 10px/1 ui-monospace, monospace; }
.card-body { min-height: 168px; padding: 14px 14px 13px; }
.card-title-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 10px; }
.card-title { margin: 0; font-size: 17px; line-height: 1.18; letter-spacing: -.02em; }
.card-subname { display: block; margin-top: 3px; color: var(--muted); font-weight: 500; font-size: 12px; line-height: 1.25; }
.ram-badge { display: grid; place-items: center; width: 31px; height: 31px; background: color-mix(in srgb, var(--card-color) 15%, #07090d); border: 1px solid var(--card-color); color: var(--card-color); font: 900 13px/1 ui-monospace, monospace; }
.ram-badge small { display: none; }
.stat-line { display: flex; gap: 6px; margin: 11px 0; color: #bdc6cf; font: 700 11px/1 ui-monospace, monospace; text-transform: uppercase; }
.stat-line span { padding: 4px 6px; background: #080b10; border: 1px solid #26303b; }
.stat-line .sellable-stat { border-color: rgba(241,235,36,.48); color: var(--yellow); }
.effect-preview { min-height: 34px; margin: 0 0 10px; color: #acb6c0; font-size: 12px; line-height: 1.42; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tag-row { display: flex; flex-wrap: wrap; gap: 4px; }
.micro-tag { max-width: 100%; padding: 4px 6px; overflow: hidden; background: rgba(255,255,255,.035); color: #9da8b3; font: 700 9px/1 ui-monospace, monospace; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.catalog-stage.hide-images .card-image-wrap { display: none; }
.catalog-stage.hide-images .card-body { min-height: 188px; }
.catalog-stage.dense { --card-width: 190px; }
.catalog-stage.dense .card-body { min-height: 155px; padding: 12px; }
.catalog-stage.dense .card-title { font-size: 15px; }
.catalog-stage.dense .effect-preview { display: none; }
.empty-state { padding: 80px 20px; border: 1px dashed #36414d; text-align: center; }
.empty-code { color: var(--red); font: 800 12px/1 ui-monospace, monospace; letter-spacing: .15em; }
.empty-state h2 { margin: 10px 0 8px; font-size: 28px; }
.empty-state p { color: var(--muted); }

.network-view { min-height: calc(100vh - var(--header)); padding: 35px clamp(18px, 3.5vw, 56px) 50px; }
.network-toolbar { display: flex; justify-content: space-between; align-items: end; gap: 30px; max-width: 1500px; margin: 0 auto 22px; }
.network-toolbar p, .taxonomy-intro p { max-width: 710px; margin: 0; color: var(--muted); line-height: 1.5; }
.legend-slot-count { flex: 0 0 auto; min-width: 150px; padding: 12px 15px; background: #0b0f15; border: 1px solid #3c4652; text-align: right; }
.legend-slot-count b { display: block; color: var(--yellow); font: 900 24px/1 ui-monospace, monospace; }
.legend-slot-count span { color: var(--muted); font: 700 10px/1 ui-monospace, monospace; letter-spacing: .09em; }
.legend-builder { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, .72fr); gap: 16px; max-width: 1500px; margin: 0 auto 16px; }
.legend-picker-panel, .ram-matrix-panel, .legend-plan-panel, .deck-fit-panel { background: rgba(13,17,24,.86); border: 1px solid var(--line); }
.legend-picker-panel, .ram-matrix-panel, .legend-plan-panel { padding: 18px; }
.section-heading, .deck-fit-head { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 15px; }
.section-heading h2, .deck-fit-head h2 { font-size: 21px; }
.section-heading small { max-width: 410px; color: var(--muted); font-size: 12px; text-align: right; }
.legend-picker { display: grid; gap: 13px; }
.legend-color-group { border-left: 3px solid var(--group-color); }
.legend-color-head { display: flex; justify-content: space-between; padding: 0 8px 7px; color: var(--group-color); font: 800 11px/1 ui-monospace, monospace; text-transform: uppercase; letter-spacing: .07em; }
.legend-color-head small { color: var(--muted); }
.legend-choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; padding-left: 8px; }
.legend-choice { position: relative; display: grid; grid-template-columns: 39px minmax(0, 1fr); align-items: center; gap: 9px; min-height: 60px; padding: 5px 8px 5px 5px; background: #090d13; border: 1px solid #2a333e; text-align: left; }
.legend-choice:hover:not(.unavailable) { border-color: var(--legend-color); background: color-mix(in srgb, var(--legend-color) 7%, #090d13); }
.legend-choice.active { border-color: var(--legend-color); box-shadow: inset 3px 0 0 var(--legend-color); background: color-mix(in srgb, var(--legend-color) 10%, #090d13); }
.legend-choice.unavailable { opacity: .48; }
.legend-choice img { width: 39px; height: 51px; object-fit: cover; }
.legend-choice b { display: block; font-size: 11px; line-height: 1.22; }
.legend-choice small { display: block; margin-top: 4px; color: var(--legend-color); font: 700 9px/1 ui-monospace, monospace; text-transform: uppercase; }
.legend-order { position: absolute; top: -5px; left: -5px; z-index: 2; display: grid; place-items: center; width: 19px; height: 19px; background: #080b10; border: 1px solid var(--legend-color); color: var(--legend-color); font: 900 10px/1 ui-monospace, monospace; }
.ram-budget { display: grid; gap: 8px; }
.ram-budget-row { position: relative; display: grid; grid-template-columns: 54px minmax(80px, 1fr) 24px; align-items: center; gap: 8px; min-height: 58px; padding: 9px 10px; background: color-mix(in srgb, var(--ram-color) 6%, #080b10); border: 1px solid color-mix(in srgb, var(--ram-color) 45%, #28313b); }
.ram-budget-row.locked { opacity: .45; background: #080b10; border-color: var(--line); }
.ram-color-name { color: var(--ram-color); font: 800 11px/1 ui-monospace, monospace; text-transform: uppercase; }
.ram-budget-row > b { color: var(--ram-color); font: 900 20px/1 ui-monospace, monospace; text-align: right; }
.ram-budget-row > small { grid-column: 1 / -1; color: var(--muted); font: 10px/1 ui-monospace, monospace; }
.ram-pips { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; }
.ram-pips i { height: 8px; background: #222a34; border: 1px solid #36404c; }
.ram-pips i.filled { background: var(--ram-color); border-color: var(--ram-color); box-shadow: 0 0 8px color-mix(in srgb, var(--ram-color) 55%, transparent); }
.ram-rule { margin: 13px 1px 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.legend-plan-panel, .deck-fit-panel { max-width: 1500px; margin: 0 auto 16px; }
.legend-strategies { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.legend-strategy { display: grid; grid-template-columns: 66px minmax(0, 1fr); gap: 12px; min-width: 0; padding: 9px; background: #090d13; border-top: 3px solid var(--legend-color); }
.legend-strategy img { width: 66px; height: 92px; object-fit: cover; }
.legend-strategy-kicker { color: var(--legend-color); font: 800 10px/1 ui-monospace, monospace; text-transform: uppercase; }
.legend-strategy h3 { margin: 5px 0; font-size: 14px; line-height: 1.2; }
.legend-strategy p { display: -webkit-box; margin: 0 0 8px; overflow: hidden; color: #aeb8c2; font-size: 11px; line-height: 1.4; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.legend-strategy .legend-exclusion { display: block; margin: 7px 0 0; color: #d79a76; font-size: 10px; -webkit-line-clamp: unset; }
.legend-exclusion b { color: #ffb37d; }
.strategy-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.strategy-tags span { padding: 3px 5px; background: rgba(255,255,255,.04); color: #9aa6b1; font: 700 9px/1 ui-monospace, monospace; text-transform: uppercase; }
.legend-empty { padding: 22px; border: 1px dashed #38424e; color: var(--muted); text-align: center; }
.effect-packages { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 7px; margin-top: 13px; }
.effect-package { min-height: 70px; padding: 9px 10px; background: #0a0e14; border: 1px solid #303945; text-align: left; }
.effect-package:hover, .effect-package.active { border-color: var(--yellow); background: rgba(241,235,36,.07); }
.effect-package.active { box-shadow: inset 3px 0 0 var(--yellow); }
.package-type { display: block; color: var(--cyan); font: 700 9px/1 ui-monospace, monospace; text-transform: uppercase; letter-spacing: .08em; }
.effect-package b { display: block; margin: 6px 0; font-size: 12px; }
.effect-package small { color: var(--muted); font-size: 10px; line-height: 1.3; }
.deck-fit-panel { padding: 18px; }
.deck-fit-head p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.legal-finishers:not(:empty) { margin: 0 0 14px; padding: 12px; background: linear-gradient(105deg, rgba(241,235,36,.08), rgba(255,82,102,.035)); border: 1px solid rgba(241,235,36,.42); }
.finisher-head { display: flex; justify-content: space-between; align-items: end; gap: 15px; margin-bottom: 9px; }
.finisher-head h3 { margin: 0; font-size: 16px; }
.finisher-head small { color: var(--yellow); font: 800 10px/1 ui-monospace, monospace; }
.finisher-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 6px; }
.finisher-list .deck-fit-card { border-color: rgba(241,235,36,.3); }
.deck-mode { display: flex; border: 1px solid #37414c; }
.deck-mode button { min-height: 38px; padding: 0 12px; background: #090d13; border: 0; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.deck-mode button + button { border-left: 1px solid #37414c; }
.deck-mode button.active { background: var(--yellow); color: #08090c; }
.ram-groups { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; align-items: start; }
.ram-color-column { min-width: 0; background: #090d13; border: 1px solid color-mix(in srgb, var(--ram-color) 45%, #28313b); }
.ram-color-column > header { display: flex; justify-content: space-between; padding: 11px; background: color-mix(in srgb, var(--ram-color) 9%, #090d13); border-bottom: 2px solid var(--ram-color); color: var(--ram-color); font: 800 11px/1 ui-monospace, monospace; text-transform: uppercase; }
.ram-color-column > header b { color: #dbe2e8; font-size: 10px; }
.ram-color-column.locked { opacity: .48; border-color: var(--line); }
.locked-color-message { padding: 28px 14px; color: var(--muted); font-size: 12px; line-height: 1.45; text-align: center; }
.ram-tier + .ram-tier { border-top: 1px solid #252e38; }
.ram-tier-head { display: flex; justify-content: space-between; padding: 9px 10px 7px; color: var(--ram-color); font: 800 10px/1 ui-monospace, monospace; }
.ram-tier-head small { color: var(--muted); }
.deck-fit-list { display: grid; gap: 5px; padding: 0 6px 8px; }
.deck-fit-card { display: grid; grid-template-columns: 38px minmax(0, 1fr) 26px; align-items: center; gap: 8px; min-height: 58px; padding: 4px; background: #0d1219; border: 1px solid #28313b; text-align: left; }
.deck-fit-card:hover { border-color: var(--fit-color); background: color-mix(in srgb, var(--fit-color) 6%, #0d1219); }
.deck-fit-card img { width: 38px; height: 50px; object-fit: cover; }
.deck-fit-copy { min-width: 0; }
.deck-fit-copy b { display: block; overflow: hidden; font-size: 10px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.deck-fit-copy small, .deck-fit-copy > span { display: block; margin-top: 3px; overflow: hidden; color: var(--muted); font: 8px/1.25 ui-monospace, monospace; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.deck-fit-copy > span { color: #aeb8c2; }
.deck-fit-card > strong { display: grid; place-items: center; width: 26px; height: 26px; background: color-mix(in srgb, var(--fit-color) 12%, #080b10); border: 1px solid var(--fit-color); color: var(--fit-color); font: 900 11px/1 ui-monospace, monospace; }
.legend-alternative-tier { background: color-mix(in srgb, var(--ram-color) 5%, #090d13); }
.legend-alternative-tier .ram-tier-head span { color: #f3f6f8; }
.legend-alternative-card { border-style: dashed; }
.selected-pool-legend { border-style: solid; box-shadow: inset 3px 0 0 var(--fit-color); }
.no-tier-match { margin: 0; padding: 5px 10px 12px; color: #65717d; font-size: 10px; }

.taxonomy-view { min-height: calc(100vh - var(--header)); padding: 38px clamp(18px, 4vw, 64px) 70px; }
.taxonomy-intro { max-width: 1500px; margin: 0 auto 28px; }
.taxonomy-layout { display: grid; grid-template-columns: minmax(330px, .8fr) minmax(0, 1.7fr); gap: 22px; max-width: 1500px; margin: auto; }
.taxonomy-tree, .taxonomy-results { background: rgba(13,17,24,.84); border: 1px solid var(--line); }
.taxonomy-tree { padding: 18px; }
.tree-family + .tree-family { margin-top: 8px; }
.family-button { display: flex; justify-content: space-between; width: 100%; min-height: 42px; padding: 0 11px; align-items: center; background: #111722; border: 1px solid #2e3844; font-weight: 800; text-align: left; }
.family-label { display: inline-flex; align-items: center; gap: 9px; }
.family-label i { width: 8px; height: 8px; border-right: 2px solid var(--cyan); border-bottom: 2px solid var(--cyan); transform: rotate(45deg) translateY(-2px); transition: transform .16s ease; }
.tree-family.collapsed .family-label i { transform: rotate(-45deg); }
.family-button span:last-child { color: var(--muted); font: 11px/1 ui-monospace, monospace; }
.family-button:hover { border-color: var(--cyan); }
.tree-children { position: relative; margin: 6px 0 14px 16px; padding-left: 17px; border-left: 1px solid #34404c; }
.tree-child { position: relative; display: flex; justify-content: space-between; width: 100%; min-height: 35px; padding: 7px 8px; background: transparent; border: 0; color: #aab4be; font-size: 13px; text-align: left; }
.tree-child::before { content: ""; position: absolute; left: -18px; top: 50%; width: 12px; height: 1px; background: #34404c; }
.tree-child:hover, .tree-child.active { color: var(--yellow); background: rgba(241,235,36,.055); }
.tree-child span:last-child { color: #6f7b88; font: 11px/1 ui-monospace, monospace; }
.taxonomy-results { min-width: 0; padding: 23px; }
.taxonomy-result-head { display: flex; align-items: start; justify-content: space-between; gap: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.count-badge { padding: 7px 9px; background: var(--yellow); color: #08090c; font: 900 12px/1 ui-monospace, monospace; }
.taxonomy-description { margin: 15px 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.mini-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 9px; }
.mini-card { display: grid; grid-template-columns: 42px minmax(0, 1fr); align-items: center; gap: 10px; min-height: 65px; padding: 7px; background: #0a0e14; border: 1px solid #28313b; text-align: left; }
.mini-card:hover { border-color: var(--card-color); background: #111722; }
.mini-card img { width: 42px; height: 54px; object-fit: cover; }
.mini-card b { display: block; overflow: hidden; font-size: 12px; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.mini-card small { color: var(--muted); font: 10px/1.4 ui-monospace, monospace; text-transform: uppercase; }

.backdrop { position: fixed; inset: 0; z-index: 69; background: rgba(0,0,0,.66); backdrop-filter: blur(3px); }
.card-detail { position: fixed; top: 0; right: 0; z-index: 70; width: min(560px, 100%); height: 100vh; overflow: auto; background: #0b0f15; border-left: 1px solid #46515d; transform: translateX(103%); transition: transform .22s ease; box-shadow: -25px 0 70px rgba(0,0,0,.5); }
.card-detail.open { transform: translateX(0); }
.detail-close { position: sticky; top: 14px; float: right; z-index: 3; margin: 14px 14px -52px 0; background: rgba(7,9,13,.92); }
.detail-hero { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 733 / 1024; overflow: hidden; background: radial-gradient(circle at 50% 38%, #222c38, #07090d 68%); border-bottom: 1px solid var(--line); }
.detail-hero img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: center; opacity: 1; }
.detail-identity { position: static; margin-bottom: 18px; }
.detail-identity h2 { margin: 5px 0 3px; font-size: 29px; line-height: 1.05; }
.detail-identity p { margin: 0; color: #bbc5cf; }
.detail-inner { padding: 22px 25px 38px; }
.detail-stats { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 21px; border: 1px solid var(--line); }
.detail-stat { padding: 11px 9px; border-right: 1px solid var(--line); }
.detail-stat:last-child { border-right: 0; }
.detail-stat small { display: block; color: var(--muted); font: 700 9px/1 ui-monospace, monospace; text-transform: uppercase; }
.detail-stat b { display: block; margin-top: 5px; font: 800 15px/1 ui-monospace, monospace; }
.detail-section { margin-top: 22px; }
.detail-section h3 { margin-bottom: 10px; color: #d5dce3; font: 800 11px/1 ui-monospace, monospace; text-transform: uppercase; letter-spacing: .09em; }
.rules-box { padding: 15px; background: #111722; border-left: 3px solid var(--card-color, var(--yellow)); color: #e4e9ed; font-size: 15px; line-height: 1.55; white-space: pre-line; }
.analysis-box { color: #acb6c0; font-size: 14px; line-height: 1.5; }
.analysis-box strong { color: var(--text); }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-tag { padding: 6px 8px; background: rgba(53,217,231,.055); border: 1px solid rgba(53,217,231,.2); color: #bfeff3; font: 700 10px/1 ui-monospace, monospace; text-transform: uppercase; }
.relation-group { margin-top: 14px; }
.relation-group-head { display: flex; justify-content: space-between; margin-bottom: 7px; color: #dbe1e6; font-size: 13px; font-weight: 700; }
.relation-group-head span { color: var(--muted); font: 11px/1 ui-monospace, monospace; }
.relation-list { display: flex; flex-wrap: wrap; gap: 5px; }
.relation-pill { display: inline-flex; align-items: center; gap: 7px; max-width: 220px; min-height: 42px; padding: 4px 8px 4px 4px; overflow: hidden; background: #121823; border: 1px solid #303a46; color: #b9c2cb; font-size: 11px; text-align: left; }
.relation-pill img { flex: 0 0 auto; width: 26px; height: 34px; object-fit: cover; }
.relation-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.relation-pill:hover { border-color: var(--yellow); color: var(--yellow); }
.detail-actions { display: flex; gap: 8px; margin-top: 23px; }
.primary-button { min-height: 43px; padding: 0 16px; background: var(--yellow); border: 1px solid var(--yellow); color: #08090c; font-weight: 900; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 0 100%); }
.primary-button:hover { background: #fff947; }

.card-preview { width: min(960px, calc(100vw - 28px)); max-width: none; height: min(92vh, 900px); max-height: none; margin: auto; padding: 0; overflow: hidden; background: #080b10; border: 1px solid #53606e; color: var(--text); box-shadow: 0 30px 100px rgba(0,0,0,.8); }
.card-preview::backdrop { background: rgba(0,0,0,.86); backdrop-filter: blur(7px); }
.preview-shell { display: grid; grid-template-rows: minmax(0, 1fr) auto; height: 100%; }
.preview-close { position: absolute; top: 12px; right: 12px; z-index: 3; background: rgba(7,9,13,.92); }
.preview-image-stage { min-width: 0; min-height: 0; display: grid; place-items: center; overflow: hidden; padding: 18px 18px 10px; background: radial-gradient(circle at 50% 35%, #1d2631 0, #080b10 58%); }
.preview-image-stage img { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; object-position: center; filter: drop-shadow(0 18px 35px rgba(0,0,0,.6)); }
.preview-meta { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 15px 18px; background: #0d1118; border-top: 1px solid var(--line); }
.preview-meta h2 { margin-bottom: 4px; font-size: 20px; }
.preview-meta p { margin: 0; color: var(--muted); font-size: 13px; }
.preview-actions { display: flex; align-items: center; gap: 8px; }
.preview-actions .secondary-button { display: inline-grid; place-items: center; min-height: 43px; text-decoration: none; white-space: nowrap; }

footer { display: flex; justify-content: space-between; gap: 30px; padding: 20px 28px; border-top: 1px solid var(--line); color: #6f7b87; font: 10px/1.5 ui-monospace, monospace; text-transform: uppercase; }
footer span:last-child { max-width: 750px; text-align: right; }
footer a { color: #aab4be; }

@media (max-width: 980px) {
  :root { --header: 66px; }
  .topbar { grid-template-columns: 1fr auto; padding: 0 16px; }
  .views { position: fixed; left: 0; right: 0; bottom: 0; z-index: 65; height: 59px; justify-content: space-around; background: #0a0e14; border-top: 1px solid var(--line); }
  .view-tab { flex: 1; justify-content: center; padding: 0 6px; }
  .view-tab::after { top: -1px; bottom: auto; left: 24%; right: 24%; }
  .source-link { display: none; }
  .mobile-only { display: grid; }
  #catalog-view.active { grid-template-columns: 1fr; }
  .filters { position: fixed; inset: 0 auto 0 0; z-index: 80; width: min(340px, 90vw); height: 100vh; transform: translateX(-102%); transition: transform .2s; box-shadow: 20px 0 50px rgba(0,0,0,.5); }
  .filters.open { transform: translateX(0); }
  .catalog-stage { padding: 28px 18px 90px; }
  .network-view, .taxonomy-view { padding: 28px 18px 90px; }
  .legend-builder { grid-template-columns: 1fr; }
  .ram-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .taxonomy-layout { grid-template-columns: 1fr; }
  body { padding-bottom: 59px; }
  footer { padding-bottom: 80px; }
}

@media (max-width: 640px) {
  .brand small { display: none; }
  .brand b { font-size: 13px; }
  .catalog-toolbar, .network-toolbar, .deck-fit-head, .section-heading { align-items: stretch; flex-direction: column; }
  .legend-slot-count { width: 100%; text-align: left; }
  .section-heading small { max-width: none; text-align: left; }
  .toolbar-controls { width: 100%; }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .card-body { min-height: 155px; padding: 11px; }
  .card-title { font-size: 14px; }
  .card-subname { font-size: 11px; }
  .ram-badge { width: 27px; height: 27px; }
  .effect-preview { display: none; }
  .legend-choice-grid, .legend-strategies, .ram-groups { grid-template-columns: 1fr; }
  .finisher-head { align-items: flex-start; flex-direction: column; }
  .deck-mode { width: 100%; }
  .deck-mode button { flex: 1; }
  .taxonomy-results { padding: 16px; }
  .mini-card-grid { grid-template-columns: 1fr; }
  .card-preview { height: calc(100vh - 18px); width: calc(100vw - 18px); }
  .preview-image-stage { padding: 52px 8px 8px; }
  .preview-meta { align-items: stretch; flex-direction: column; gap: 12px; }
  .preview-actions { display: grid; grid-template-columns: 1fr; }
  .preview-meta .primary-button, .preview-actions .secondary-button { width: 100%; }
  footer { flex-direction: column; }
  footer span:last-child { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
