@import url("https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;600;700;800&family=Orbitron:wght@500;700&display=swap");

:root {
  --asset-bg-16x10: url("assets/skeuo/backgrounds/bg_desk_main_1920x1200.png");
  --asset-bg-16x9: url("assets/skeuo/backgrounds/bg_desk_main_3840x2160.png");
  --asset-walnut: url("assets/skeuo/textures/tx_walnut_seamless_2048.png");
  --asset-leather: url("assets/skeuo/textures/tx_leather_dark_seamless_2048.png");
  --asset-aluminum: url("assets/skeuo/textures/tx_aluminum_brushed_seamless_2048.png");
  --asset-paper: url("assets/skeuo/textures/tx_paper_warm_seamless_2048.png");
  --asset-btn-amber: url("assets/skeuo/buttons/tx_button_amber_1024x256.png");
  --asset-btn-slate: url("assets/skeuo/buttons/tx_button_slate_1024x256.png");
  --asset-gloss: url("assets/skeuo/overlays/ov_gloss_strip_2048x512.png");
  --asset-vignette: url("assets/skeuo/overlays/ov_inner_vignette_2048x2048.png");
  --asset-dust: url("assets/skeuo/overlays/ov_micro_dust_2048x2048.png");
  --asset-divider: url("assets/skeuo/overlays/ui_divider_emboss_2048x128.png");
  --text-light: #f9f0dc;
  --text-dark: #2c2418;
  --text-muted: #5a4b35;
  --ok: #245f3a;
  --warn: #9d6021;
  --err: #8f272d;
  --accent: #8a6227;
  --scroll-track: rgba(36, 24, 12, 0.72);
  --scroll-thumb: rgba(189, 145, 85, 0.82);
  --scroll-thumb-hover: rgba(222, 176, 114, 0.9);
  --shadow-outer: 0 14px 26px rgba(15, 9, 3, 0.52);
  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 10px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

*::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

*::-webkit-scrollbar-track {
  border-radius: 999px;
  border: 1px solid rgba(109, 80, 46, 0.64);
  background:
    linear-gradient(180deg, rgba(20, 13, 7, 0.78), rgba(78, 56, 31, 0.66)),
    var(--asset-walnut);
  background-size: cover, 260px 260px;
}

*::-webkit-scrollbar-thumb {
  border-radius: 999px;
  border: 1px solid rgba(108, 70, 30, 0.92);
  background:
    linear-gradient(180deg, rgba(243, 207, 154, 0.94), rgba(148, 104, 56, 0.94)),
    var(--asset-btn-amber);
  background-size: cover, 160% 180%;
  box-shadow:
    inset 0 1px 0 rgba(255, 240, 211, 0.4),
    0 0 0 1px rgba(12, 7, 4, 0.24);
}

*::-webkit-scrollbar-thumb:hover {
  filter: brightness(1.06);
}

*::-webkit-scrollbar-corner {
  background: rgba(38, 26, 13, 0.82);
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  position: relative;
  color: var(--text-light);
  font-family: "Nunito Sans", sans-serif;
  background: #1c140e;
}

[hidden] {
  display: none !important;
}

.desk-backdrop,
.desk-vignette,
.desk-dust {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.desk-backdrop {
  background-image: var(--asset-bg-16x9);
  background-size: cover;
  background-position: center;
  filter: brightness(0.62) saturate(0.76);
}

.desk-vignette {
  background-image:
    radial-gradient(circle at 16% 12%, rgba(255, 224, 166, 0.19) 0%, rgba(255, 224, 166, 0) 42%),
    var(--asset-vignette);
  background-size: cover, cover;
  background-position: center, center;
  mix-blend-mode: multiply;
  opacity: 0.56;
}

.desk-dust {
  background-image: var(--asset-dust);
  background-size: 900px 900px;
  mix-blend-mode: screen;
  opacity: 0.16;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1700px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100dvh;
  overflow: hidden;
}

.app-body {
  display: flex;
  min-height: 0;
  overflow: hidden;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  letter-spacing: 0.03em;
  color: #f6eddd;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

h1 {
  font-size: clamp(22px, 2.6vw, 34px);
  line-height: 1.1;
}

.topbar-brand h1 {
  font-size: clamp(18px, 1.8vw, 26px);
}

h2 {
  font-size: 17px;
}

.topbar {
  position: relative;
  overflow: clip;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  justify-content: space-between;
  gap: 12px;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(166, 149, 118, 0.86);
  background-image:
    linear-gradient(165deg, rgba(255, 255, 255, 0.24), rgba(75, 63, 47, 0.28)),
    var(--asset-aluminum);
  background-size: cover, 540px 540px;
  background-position: center, center;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    inset 0 -2px 10px rgba(0, 0, 0, 0.3),
    var(--shadow-outer);
}

.topbar-brand {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  padding: 5px 10px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(18, 13, 8, 0.56), rgba(72, 57, 36, 0.34));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.topbar::after {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 62%;
  background-image: var(--asset-gloss);
  background-size: cover;
  background-position: center top;
  opacity: 0.42;
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 5px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: #f3e3c4;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.subtitle {
  margin: 7px 0 0;
  max-width: 760px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  color: #fff3df;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

.status-wrap {
  align-self: center;
  display: inline-flex;
  align-items: center;
  position: relative;
  z-index: 1;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(176, 159, 126, 0.8);
  background:
    linear-gradient(145deg, rgba(39, 31, 20, 0.76), rgba(88, 72, 46, 0.64)),
    var(--asset-walnut);
  background-size: cover, 440px 440px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.status-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #96f5b8 0%, #2f7f45 76%);
  box-shadow: 0 0 8px rgba(123, 249, 160, 0.62);
}

.status {
  font-size: 12px;
  font-weight: 700;
  color: #d9ffeb;
}

.layout {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: grid;
  gap: 12px;
  align-items: start;
  grid-template-columns: minmax(0, 2fr) minmax(340px, 1fr);
  padding: 10px 12px 12px 10px;
  overflow: hidden;
}

body.workspace-auto-builder-active .layout {
  grid-template-columns: minmax(0, 2.55fr) minmax(300px, 0.9fr);
}

body.workspace-discover-active .layout {
  grid-template-columns: minmax(0, 1fr);
}

body.workspace-model-observation-active .layout {
  grid-template-columns: minmax(0, 1fr);
}

body.workspace-discover-active #workspace-panel {
  display: none;
}

body.workspace-discover-active #inspector-panel {
  grid-column: 1;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
}

.auth-card {
  width: min(720px, 100%);
  display: grid;
  gap: 20px;
  padding: 26px;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(178, 157, 118, 0.82);
  background:
    linear-gradient(180deg, rgba(34, 25, 14, 0.92), rgba(74, 57, 35, 0.82)),
    var(--asset-walnut);
  background-size: cover, 460px 460px;
  box-shadow: var(--shadow-outer);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.auth-form input {
  width: 100%;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.auth-footer {
  margin-top: 14px;
  font-size: 14px;
}

.auth-link {
  color: #e8c97a;
  text-decoration: underline;
}

.auth-link:hover {
  color: #f4dfb8;
}

.setup-card {
  max-width: 560px;
}

.setup-header {
  margin-bottom: 20px;
}

.setup-tagline {
  margin: 8px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: rgba(240, 220, 180, 0.8);
}

.setup-steps {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  gap: 10px;
}

.setup-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(160, 130, 80, 0.22);
  background: rgba(255, 250, 240, 0.06);
}

.setup-step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(220, 180, 100, 0.5);
  background: rgba(200, 155, 75, 0.18);
  font-size: 12px;
  font-weight: 800;
  color: #e8c97a;
}

.setup-step-body {
  display: grid;
  gap: 3px;
  font-size: 13px;
}

.setup-step-body strong {
  font-weight: 800;
  color: #f4e9d4;
}

.setup-step-body span {
  color: rgba(230, 210, 175, 0.72);
  line-height: 1.4;
}

.setup-note {
  margin: 0 0 16px;
  font-size: 12px;
  font-style: italic;
}

.setup-actions {
  margin-top: 4px;
}

.account-setup-complete .auth-actions {
  margin-top: 12px;
}

.account-shell {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(176, 159, 126, 0.78);
  background: linear-gradient(180deg, rgba(24, 18, 10, 0.74), rgba(71, 56, 36, 0.6));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.account-copy {
  display: grid;
  gap: 2px;
}

.account-copy strong {
  font-size: 13px;
  color: #fff2d9;
}

.account-copy span {
  font-size: 12px;
  color: #d7ccb8;
}

.account-role-chip {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(169, 88, 30, 0.88);
  color: #fff2de;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.account-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.worktable-meta-row {
  align-items: end;
}

.deck-meta-field {
  min-width: 170px;
}

.deck-save-state {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f4d29b;
}

.deck-save-state.is-clean {
  color: #b4ebc4;
}

.discover-tab-strip {
  display: inline-flex;
  gap: 10px;
  margin-bottom: 12px;
}

.discover-tab-btn {
  min-width: 140px;
}

.discover-tab-btn.is-active {
  filter: brightness(1.08);
}

.deck-import-dropzone {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px dashed rgba(214, 188, 142, 0.66);
  background: rgba(38, 28, 16, 0.58);
}

.workspace-zone {
  min-width: 0;
  display: grid;
  gap: 10px;
}

body.workspace-model-observation-active .inspector-zone {
  display: none;
}

.workspace-tabs {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  position: relative;
  z-index: 1;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid rgba(132, 112, 84, 0.82);
  background:
    linear-gradient(145deg, rgba(39, 31, 20, 0.76), rgba(88, 72, 46, 0.64)),
    var(--asset-walnut);
  background-size: cover, 440px 440px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.workspace-tab-btn {
  min-height: 32px;
  height: 32px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.02em;
  border: 1px solid rgba(96, 76, 52, 0.86);
  background:
    linear-gradient(180deg, rgba(222, 193, 154, 0.28), rgba(99, 70, 43, 0.54)),
    rgba(56, 39, 22, 0.42);
  color: #f4e9d2;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 2px 4px rgba(0, 0, 0, 0.25);
}

.workspace-tab-btn.is-active {
  border-color: rgba(225, 197, 144, 0.92);
  background:
    linear-gradient(180deg, rgba(247, 225, 188, 0.92), rgba(176, 129, 75, 0.94)),
    var(--asset-btn-amber);
  background-size: cover, 120% 130%;
  color: #2d2010;
  box-shadow:
    inset 0 1px 0 rgba(255, 245, 228, 0.7),
    0 3px 6px rgba(0, 0, 0, 0.28);
}

.topbar-tabs {
  margin-left: auto;
}

/* ── Sidebar navigation ───────────────────────────────────────────── */
.sidebar-nav {
  width: 72px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 10px 6px;
  overflow: hidden;
  border-right: 1px solid rgba(100, 78, 44, 0.35);
  background:
    linear-gradient(180deg, rgba(28, 20, 11, 0.82), rgba(44, 32, 18, 0.74)),
    var(--asset-walnut);
  background-size: cover, 260px 260px;
}

.sidebar-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 6px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(210, 180, 130, 0.5);
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
  font-size: 0; /* reset — children set their own sizes */
}

.sidebar-icon {
  font-size: 18px;
  line-height: 1.2;
}

.sidebar-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sidebar-nav-btn:hover {
  background: rgba(200, 160, 80, 0.1);
  color: rgba(230, 200, 150, 0.85);
}

.sidebar-nav-btn.is-active {
  background: rgba(200, 160, 80, 0.18);
  border-color: rgba(200, 160, 80, 0.38);
  color: #e8d0a0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 2px 8px rgba(0, 0, 0, 0.24);
}

.sidebar-spacer {
  flex: 1;
}

#workspace-panel {
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-top: 8px;
  height: 100%;
}

#inspector-panel {
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-top: 8px;
  height: 100%;
}

.workspace-pane {
  display: none;
}

.workspace-pane.is-active {
  display: block;
  animation: panel-fade-in 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes panel-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.zone {
  min-height: min(82vh, 980px);
}

.module {
  position: relative;
  overflow: clip;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(132, 112, 84, 0.9);
  padding: 13px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -10px 16px rgba(0, 0, 0, 0.3),
    var(--shadow-outer);
  color: var(--text-dark);
}

.module::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--asset-dust);
  background-size: 900px 900px;
  opacity: 0.08;
  pointer-events: none;
}

.collection-zone {
  background-image:
    linear-gradient(160deg, rgba(244, 237, 222, 0.72), rgba(146, 128, 100, 0.8)),
    var(--asset-aluminum);
  background-size: cover, 580px 580px;
}

.worktable-zone {
  background-image:
    linear-gradient(166deg, rgba(240, 226, 196, 0.64), rgba(91, 69, 44, 0.78)),
    var(--asset-walnut);
  background-size: cover, 760px 760px;
}

.inspector-zone {
  background-image:
    linear-gradient(170deg, rgba(243, 227, 200, 0.62), rgba(70, 52, 36, 0.86)),
    var(--asset-leather);
  background-size: cover, 600px 600px;
}

.module-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.worktable-zone .module-head > div:first-child {
  flex: 1 1 320px;
  min-width: 0;
}

.module-head h2 {
  color: #f7e9cc;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.divider {
  position: relative;
  z-index: 1;
  height: 11px;
  margin: 0 0 9px;
  background-image: var(--asset-divider);
  background-size: cover;
  background-position: center;
  opacity: 0.56;
}

.deck-worktable {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 10px;
}

.worktable-row {
  border: 1px solid rgba(79, 59, 34, 0.62);
  border-radius: 12px;
  padding: 10px;
  background:
    linear-gradient(180deg, rgba(255, 243, 220, 0.26), rgba(87, 63, 33, 0.34)),
    var(--asset-walnut);
  background-size: cover, 560px 560px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    inset 0 -2px 5px rgba(0, 0, 0, 0.25);
}

.worktable-top {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

.deck-name-field {
  margin: 0;
  width: 100%;
  min-width: 0;
}

.deck-name-field input {
  margin-top: 4px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.worktable-name-row {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 220px);
  align-items: end;
}

.deck-format-field {
  margin: 0;
  display: grid;
  gap: 4px;
  min-width: 0;
}

.deck-format-field select {
  min-height: 36px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.deck-primary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  margin-left: auto;
  flex: 0 1 auto;
}

.deck-primary-actions > button {
  min-height: 36px;
  height: 36px;
}

.worktable-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slot-block {
  display: grid;
  gap: 6px;
}

.slot-block h3 {
  font-size: 12px;
  color: #f2dfc2;
}

.slot-card {
  display: grid;
  grid-template-rows: auto auto;
  gap: 5px;
  height: auto;
  min-height: 0;
  padding: 7px;
  border-radius: 12px;
  border: 1px solid rgba(245, 231, 207, 0.32);
  background:
    linear-gradient(180deg, rgba(42, 31, 20, 0.72), rgba(123, 95, 63, 0.55)),
    var(--asset-aluminum);
  background-size: cover, 420px 420px;
}

.slot-card-art-wrap {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid rgba(250, 235, 210, 0.35);
  background: #0e1730;
}

.slot-card-art {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.slot-card-name {
  font-size: 11px;
  font-weight: 700;
  color: #f7e8ca;
  line-height: 1.2;
  text-wrap: balance;
}

.qty-stepper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.step-btn {
  min-width: 28px;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
}

.step-value {
  min-width: 24px;
  text-align: center;
  color: #f8ecd7;
  font-weight: 800;
  font-size: 13px;
}

.rune-block {
  min-width: 0;
}

.rune-stepper-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  align-items: start;
}

.rune-slot-card {
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
  gap: 5px;
  border-radius: 11px;
  border: 1px solid rgba(245, 231, 207, 0.32);
  background:
    linear-gradient(180deg, rgba(42, 31, 20, 0.72), rgba(123, 95, 63, 0.55)),
    var(--asset-aluminum);
  background-size: cover, 420px 420px;
  padding: 5px;
  min-width: 0;
}

.rune-slot-art-wrap {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(250, 235, 210, 0.35);
  background: #0d1730;
}

.rune-slot-art {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.rune-slot-meta {
  display: grid;
  gap: 3px;
}

.rune-slot-domain {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #f2dfbf;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rune-slot-title {
  font-size: 11px;
  line-height: 1.2;
  color: #f7ebd5;
}

.rune-slot-stepper {
  justify-content: flex-start;
}

.rune-slot-stepper .step-btn {
  min-width: 24px;
  width: 24px;
  height: 24px;
  min-height: 24px;
  font-size: 13px;
}

.rune-slot-stepper .step-value {
  min-width: 22px;
  font-size: 12px;
}

.rune-slot-card.is-disabled {
  opacity: 0.78;
}

.rune-slot-card.is-back-only .rune-slot-meta,
.rune-slot-card.is-back-only .rune-slot-stepper {
  display: none;
}

.rune-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
}

.rune-dot.domain-calm { background: #77a7d9; }
.rune-dot.domain-chaos { background: #d77b63; }
.rune-dot.domain-body { background: #b79464; }
.rune-dot.domain-fury { background: #d14848; }
.rune-dot.domain-mind { background: #7a76cf; }
.rune-dot.domain-order { background: #4ea972; }
.rune-dot.domain-none { background: #999; }

.counter-pill {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid rgba(248, 228, 187, 0.4);
  background: rgba(24, 17, 11, 0.44);
  color: #faefd9;
  font-size: 11px;
  font-weight: 700;
}

.counter-pill.is-analysis-active {
  border-color: rgba(228, 172, 106, 0.68);
  background: rgba(43, 27, 14, 0.66);
  color: #ffdeb4;
  box-shadow: inset 0 1px 0 rgba(255, 228, 182, 0.22);
}

.worktable-row-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.worktable-row-head h3 {
  margin: 0;
  font-size: 13px;
  color: #f6e8cd;
}

.section-expand-btn {
  min-height: 30px;
  height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.02em;
}

.section-expand-btn[aria-pressed="true"] {
  border-color: rgba(148, 107, 45, 0.98);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.36),
    0 0 0 1px rgba(255, 222, 158, 0.4);
}

.section-expandable {
  transition: padding 0.18s ease, opacity 0.18s ease, filter 0.18s ease;
}

.section-expandable.is-minimized {
  padding-bottom: 8px;
  opacity: 0.92;
  filter: saturate(0.82) brightness(0.92);
}

.section-expandable.is-minimized > :not(.worktable-row-head) {
  display: none;
}

.deck-worktable.is-focus-battlefields .section-expandable[data-worktable-section="battlefields"],
.deck-worktable.is-focus-main-deck .section-expandable[data-worktable-section="main-deck"],
.deck-worktable.is-focus-sideboard .section-expandable[data-worktable-section="sideboard"],
.deck-worktable.is-focus-library .section-expandable[data-worktable-section="library"] {
  border-color: rgba(250, 218, 158, 0.64);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 -2px 5px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(255, 222, 165, 0.28);
}

.battlefield-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
}

.battlefield-slot-card {
  display: grid;
  gap: 4px;
  width: 100%;
  height: auto;
  min-height: 0;
  padding: 6px;
  border-radius: 11px;
}

.battlefield-slot-card .slot-card-art-wrap {
  /* Rotated card face ratio (portrait 3:4 => landscape 4:3). */
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
}

.battlefield-slot-card .slot-card-art {
  /* Pre-rotation dimensions swap wrapper width/height, so rotated art fills fully. */
  width: 75%;
  height: 133.333%;
  max-width: none;
  max-height: none;
  object-fit: cover;
  object-position: center;
  transform: rotate(90deg) scale(1.01);
  transform-origin: center center;
}

.main-row-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.main-row-head .row {
  margin-bottom: 0;
  min-width: 260px;
}

.main-shelf-block + .main-shelf-block {
  margin-top: 8px;
}

.main-shelf-block h4 {
  margin: 0 0 6px;
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  letter-spacing: 0.03em;
  color: #f4e3c4;
  text-transform: uppercase;
}

.main-shelf-grid:not(.main-deck-shelf) {
  --shelf-row: 248px;
  display: grid;
  align-content: start;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0) 0,
      rgba(255, 255, 255, 0) calc(var(--shelf-row) - 11px),
      rgba(32, 23, 14, 0.42) calc(var(--shelf-row) - 11px),
      rgba(32, 23, 14, 0.42) calc(var(--shelf-row) - 6px),
      rgba(0, 0, 0, 0.08) calc(var(--shelf-row) - 6px),
      rgba(0, 0, 0, 0.08) var(--shelf-row)
    ),
    linear-gradient(180deg, rgba(19, 15, 10, 0.24), rgba(248, 225, 190, 0.14)),
    var(--asset-paper);
  background-size: 100% var(--shelf-row), cover, 440px 440px;
  background-repeat: repeat-y, no-repeat, repeat;
}

.main-shelf-grid:not(.main-deck-shelf).tile-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(var(--main-shelf-min, 116px), 1fr));
  gap: var(--tile-gap, 8px);
}

.main-catalog-grid {
  max-height: 46vh;
}

#sideboard-list {
  max-height: 34vh;
}

.main-shelf-grid.main-catalog-grid {
  background:
    linear-gradient(180deg, rgba(19, 15, 10, 0.24), rgba(248, 225, 190, 0.14)),
    var(--asset-paper);
  background-size: cover, 440px 440px;
  background-repeat: no-repeat, repeat;
}

.main-shelf-grid.main-deck-shelf {
  position: relative;
  isolation: isolate;
  display: block;
  width: 100%;
  min-width: 0;
  margin-top: 0;
  grid-template-columns: none;
  gap: 0;
  align-content: initial;
  max-height: 34vh;
  overflow: auto;
  --main-shelf-min: 172px;
  --main-card-min-height: 280px;
  --main-deck-card-height: 280px;
  --tile-gap: 18px;
  --shelf-lip-h: 38px;
  perspective: 1200px;
  perspective-origin: 50% 36%;
  padding: 12px;
  border: 1px solid rgba(66, 46, 27, 0.82);
  background:
    linear-gradient(180deg, rgba(34, 23, 13, 0.72), rgba(11, 7, 4, 0.84)),
    var(--asset-walnut);
  background-size: cover, 560px 560px;
  background-repeat: no-repeat, repeat;
  box-shadow:
    inset 0 2px 8px rgba(255, 255, 255, 0.12),
    inset 0 -8px 14px rgba(0, 0, 0, 0.42),
    inset 0 0 0 1px rgba(0, 0, 0, 0.16);
}

.main-deck-shelf .main-shelf-stack {
  --main-row-cols: 1;
  display: grid;
  width: 100%;
  gap: var(--tile-gap);
  align-content: start;
}

.main-deck-shelf .main-shelf-row {
  position: relative;
  isolation: isolate;
}

.main-deck-shelf .main-shelf-row-cards,
.main-deck-shelf .main-shelf-row-lip {
  display: grid;
  grid-template-columns: repeat(var(--main-row-cols), minmax(0, 1fr));
  column-gap: var(--tile-gap);
  align-items: start;
}

.main-deck-shelf .main-shelf-row-cards {
  position: relative;
  z-index: 1;
  padding: 10px 10px 1px;
  border: 1px solid rgba(78, 55, 33, 0.86);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  background:
    linear-gradient(180deg, rgba(159, 118, 72, 0.28), rgba(29, 19, 11, 0.88)),
    var(--asset-walnut);
  background-size: cover, 540px 540px;
  box-shadow:
    inset 0 1px 0 rgba(255, 233, 194, 0.24),
    inset 0 -8px 15px rgba(0, 0, 0, 0.42);
}

.main-deck-shelf .main-shelf-row-cards::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, rgba(255, 225, 173, 0.24), rgba(255, 225, 173, 0.08), rgba(255, 225, 173, 0.24));
  opacity: 0.8;
}

.main-deck-shelf .main-shelf-row-lip {
  position: relative;
  z-index: 2;
  margin-top: -3px;
  padding: 1px 10px 11px;
}

.main-deck-shelf .main-shelf-row-lip::before {
  content: "";
  position: absolute;
  left: -8px;
  right: -8px;
  top: 0;
  bottom: 0;
  z-index: -1;
  border-radius: 0 0 13px 13px;
  border: 1px solid rgba(75, 54, 33, 0.9);
  background:
    linear-gradient(180deg, rgba(192, 149, 96, 0.62), rgba(64, 40, 22, 0.9) 45%, rgba(22, 13, 7, 0.94)),
    var(--asset-walnut);
  background-size: cover, 480px 480px;
  box-shadow:
    inset 0 1px 0 rgba(255, 239, 208, 0.36),
    inset 0 -2px 0 rgba(20, 12, 7, 0.74),
    0 8px 10px rgba(0, 0, 0, 0.36);
}

.main-deck-shelf .main-shelf-row-lip::after {
  content: "";
  position: absolute;
  left: -8px;
  right: -8px;
  top: 0;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 233, 188, 0.35), rgba(255, 233, 188, 0.12), rgba(255, 233, 188, 0.35));
  pointer-events: none;
}

.main-deck-shelf .main-shelf-stepper-slot {
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.deck-worktable.is-focus-main-deck .main-deck-shelf {
  max-height: 58vh;
  --main-shelf-min: 188px;
  --main-card-min-height: 344px;
  --main-deck-card-height: 344px;
  --tile-gap: 16px;
  padding: 12px;
}

.deck-worktable.is-focus-library .main-catalog-grid {
  max-height: 60vh;
  --main-shelf-min: 172px;
  --main-card-min-height: 268px;
  --tile-gap: 12px;
  padding: 12px;
}

.deck-worktable.is-focus-sideboard #sideboard-list {
  max-height: 60vh;
  --main-shelf-min: 172px;
  --main-card-min-height: 268px;
  --tile-gap: 12px;
  padding: 12px;
}

.deck-worktable.is-focus-battlefields .battlefield-slots {
  max-height: 54vh;
  overflow: auto;
  padding-right: 2px;
}

.sideboard-stepper {
  width: 100%;
  justify-content: center;
}

.main-deck-shelf .card-tile.shelf-card {
  min-height: 0;
  display: block;
  overflow: visible;
  cursor: pointer;
  --card-shadow: 0;
  --card-contact-shadow: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transform: none;
  transition: filter 220ms ease;
}

.main-deck-shelf .card-tile.shelf-card::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 2px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.42) 0%, rgba(0, 0, 0, 0) 72%);
  opacity: calc(0.22 + (var(--card-contact-shadow, 0) * 0.34));
  transform: translateY(calc(var(--card-contact-shadow, 0) * 3px));
  filter: blur(4px);
  pointer-events: none;
  z-index: 0;
  transition:
    opacity 240ms cubic-bezier(0.2, 0.7, 0.25, 1),
    transform 240ms cubic-bezier(0.2, 0.7, 0.25, 1);
}

.main-deck-shelf .card-tile.shelf-card:hover {
  transform: none;
  box-shadow: none;
}

.main-deck-shelf .card-tile.shelf-card::after {
  content: none;
}

.main-deck-shelf .shelf-card .card-art {
  margin: 2px 2px 0;
  aspect-ratio: 23 / 32;
  transform-origin: 50% 84%;
  transform-style: preserve-3d;
  will-change: transform, filter;
  box-shadow:
    0 calc(8px + (var(--card-shadow, 0) * 10px)) calc(16px + (var(--card-shadow, 0) * 16px)) rgba(0, 0, 0, 0.46),
    0 calc(4px + (var(--card-shadow, 0) * 6px)) 0 rgba(0, 0, 0, 0.2);
  transform:
    translate3d(var(--card-float-x, 0px), calc(var(--card-float-y, 0px) + var(--card-lift, 0px)), 0)
    rotateX(var(--card-tilt-x, 0deg))
    rotateY(var(--card-tilt-y, 0deg));
  transition:
    transform 260ms cubic-bezier(0.2, 0.7, 0.25, 1),
    box-shadow 240ms cubic-bezier(0.2, 0.7, 0.25, 1),
    filter 240ms ease;
  z-index: 2;
}

.main-deck-shelf .shelf-card[data-main-missing-card] {
  cursor: pointer;
}

.main-deck-shelf .shelf-card.is-collection-missing .card-art img {
  filter: grayscale(0.84) saturate(0.42) brightness(0.72);
}

.main-deck-shelf .shelf-card.is-collection-ghost {
  opacity: 0.86;
}

.main-deck-shelf .shelf-card[data-main-ghost-card="1"] {
  pointer-events: none;
}

.main-deck-shelf .main-shelf-stepper-slot.is-ghost-slot {
  align-items: center;
}

.main-deck-shelf .main-shelf-stepper-slot .main-ghost-remove-btn {
  min-height: 24px;
  height: 24px;
  padding: 1px 10px;
  font-size: 10px;
  line-height: 1;
  border-radius: 999px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 1px 2px rgba(0, 0, 0, 0.32);
}

.main-deck-shelf .shelf-card .main-missing-chip-stack {
  position: absolute;
  right: 6px;
  bottom: 6px;
  z-index: 4;
  display: grid;
  gap: 4px;
  justify-items: end;
}

.main-deck-shelf .shelf-card .main-missing-chip {
  min-height: 0;
  height: auto;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(255, 226, 184, 0.54);
  background: rgba(27, 20, 13, 0.8);
  color: #f8ebd4;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.25;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.28);
}

.main-deck-shelf .shelf-card .main-missing-chip.is-owned {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: rgba(191, 236, 177, 0.56);
  background: rgba(18, 42, 24, 0.78);
  color: #d8ffe0;
}

.main-deck-shelf .shelf-card .main-missing-chip.is-missing {
  border-color: rgba(245, 171, 171, 0.65);
  background: rgba(69, 19, 19, 0.82);
  color: #ffd8d8;
}

.main-deck-shelf .shelf-card .main-missing-chip.is-ghost-count {
  cursor: default;
  pointer-events: none;
}

.main-deck-shelf .shelf-card .main-missing-chip.is-missing:hover {
  filter: brightness(1.06);
}

.main-deck-shelf .shelf-card .card-art::before {
  inset: 6px;
  border-radius: 8px;
  border: 1px solid rgba(255, 214, 128, 0.64);
}

.main-deck-shelf .shelf-card .card-art img {
  object-fit: cover;
  width: 100%;
  height: 100%;
  margin-left: 0;
  margin-top: 0;
  transform: none;
}

.main-deck-shelf .shelf-card .card-body {
  display: none;
}

.main-deck-shelf .main-shelf-stepper {
  pointer-events: auto;
  width: min(126px, 100%);
  margin: 0;
  padding: 1px 8px;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid rgba(114, 82, 50, 0.66);
  background:
    linear-gradient(180deg, rgba(149, 115, 74, 0.5), rgba(55, 37, 21, 0.42)),
    rgba(26, 16, 9, 0.38);
  box-shadow:
    inset 0 1px 0 rgba(255, 242, 210, 0.16),
    0 1px 2px rgba(0, 0, 0, 0.32);
}

.main-deck-shelf .main-shelf-stepper .step-btn {
  min-width: 22px;
  width: 22px;
  height: 22px;
  min-height: 22px;
  font-size: 12px;
}

.main-deck-shelf .main-shelf-stepper .step-value {
  font-size: 11px;
  min-width: 40px;
}

.main-deck-shelf .main-shelf-stepper .step-btn[disabled] {
  cursor: default;
  filter: grayscale(0.3) brightness(0.9);
}

.main-deck-shelf .shelf-card .card-actions,
.main-deck-shelf .shelf-card .card-title,
.main-deck-shelf .shelf-card .card-subtitle,
.main-deck-shelf .shelf-card .card-pill {
  display: none;
}

.main-deck-shelf.is-drop-target {
  border-color: rgba(232, 200, 143, 0.9);
  box-shadow:
    inset 0 0 0 2px rgba(255, 228, 168, 0.5),
    inset 0 2px 8px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.main-shelf-grid:not(.main-deck-shelf) .card-tile {
  min-height: var(--main-card-min-height, 224px);
  transform: none;
}

.main-shelf-grid:not(.main-deck-shelf) .card-tile:hover {
  transform: translateY(-3px);
}

.main-deck-shelf .card-tile.shelf-card.is-phys-active .card-art {
  filter: saturate(1.05) brightness(1.04);
}

.main-shelf-grid:not(.main-deck-shelf) [data-main-drag] {
  cursor: grab;
}

.main-shelf-grid:not(.main-deck-shelf) [data-main-drag].is-dragging {
  opacity: 0.78;
  cursor: grabbing;
}

.main-shelf-grid:not(.main-deck-shelf) .card-action-btn[disabled] {
  cursor: default;
  filter: grayscale(0.3) brightness(0.9);
}

.main-shelf-grid:not(.main-deck-shelf) .card-actions {
  margin-top: 5px;
}

.main-row .deck-card-empty {
  display: grid;
  place-items: center;
  min-height: 72px;
}

.deck-card-empty {
  border: 1px dashed rgba(246, 230, 202, 0.34);
  border-radius: 9px;
  padding: 9px;
  color: #f2dfbe;
  font-size: 12px;
}

.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(176, 159, 126, 0.56);
  background: rgba(33, 24, 16, 0.48);
  font-size: 12px;
  font-weight: 700;
  color: #f4e7cb;
}

.toggle-inline input {
  margin: 0;
}

.auto-builder-layout {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
}

.auto-builder-sidebar,
.auto-builder-detail {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.auto-builder-controls {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.auto-builder-controls select,
.auto-builder-controls label,
.auto-builder-filter-slot {
  min-width: 0;
}

.auto-builder-filter-slot {
  display: grid;
  gap: 6px;
}

.auto-builder-slot-card {
  min-height: 100px;
}

.auto-builder-slot-card .slot-card-art-wrap {
  min-height: 72px;
}

.auto-builder-slot-card .slot-card-name {
  font-size: 12px;
}

.auto-builder-filter-clear {
  justify-self: stretch;
}

.auto-builder-status-line {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(246, 223, 191, 0.18);
  background:
    linear-gradient(180deg, rgba(37, 25, 14, 0.68), rgba(82, 58, 33, 0.5)),
    var(--asset-walnut);
  background-size: cover, 360px 360px;
  color: #f0dfbf;
}

.auto-builder-summary {
  display: grid;
  gap: 10px;
}

.auto-builder-summary-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.auto-builder-summary-card {
  display: grid;
  gap: 6px;
  min-height: 92px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(245, 224, 190, 0.16);
  background:
    linear-gradient(180deg, rgba(47, 31, 18, 0.9), rgba(93, 66, 36, 0.58)),
    var(--asset-leather);
  background-size: cover, 420px 420px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 8px 18px rgba(0, 0, 0, 0.18);
}

.auto-builder-summary-card small {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #d9c39b;
}

.auto-builder-summary-card strong {
  font-size: 15px;
  line-height: 1.3;
  color: #fff2da;
}

.auto-builder-summary-note {
  margin: 0;
  color: #dfcbab;
  font-size: 12px;
}

.auto-builder-results {
  display: grid;
  gap: 10px;
  align-content: start;
  max-height: 62vh;
  overflow: auto;
  padding-right: 4px;
}

.auto-builder-loading-list {
  display: grid;
  gap: 10px;
}

.auto-builder-loading-card {
  min-height: 122px;
  border-radius: 14px;
  border: 1px solid rgba(245, 224, 190, 0.12);
  background:
    linear-gradient(90deg, rgba(58, 41, 24, 0.62), rgba(106, 78, 47, 0.42), rgba(58, 41, 24, 0.62));
  background-size: 220% 100%;
  animation: auto-builder-shimmer 1.4s linear infinite;
}

@keyframes auto-builder-shimmer {
  from {
    background-position: 200% 0;
  }

  to {
    background-position: -20% 0;
  }
}

.auto-builder-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(243, 224, 188, 0.18);
  background:
    linear-gradient(180deg, rgba(43, 30, 18, 0.8), rgba(98, 72, 43, 0.58)),
    var(--asset-paper);
  background-size: cover, 520px 520px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 8px 20px rgba(0, 0, 0, 0.22);
}

.auto-builder-card.is-selected {
  border-color: rgba(255, 220, 156, 0.72);
  box-shadow:
    inset 0 0 0 1px rgba(255, 230, 176, 0.22),
    0 14px 28px rgba(0, 0, 0, 0.34);
}

.auto-builder-card-art-wrap {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(250, 235, 210, 0.26);
  background: rgba(13, 23, 48, 0.72);
  aspect-ratio: 3 / 4;
}

.auto-builder-card-art {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.auto-builder-card-body {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.auto-builder-card-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.auto-builder-card-rank {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #ffdeae;
}

.auto-builder-card-title {
  font-family: "Orbitron", sans-serif;
  font-size: 15px;
  line-height: 1.2;
  color: #fff3de;
}

.auto-builder-card-subtitle {
  font-size: 12px;
  color: #ead6b0;
}

.auto-builder-card-score {
  flex: 0 0 auto;
  min-width: 58px;
  text-align: center;
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 221, 167, 0.42);
  background: rgba(35, 24, 14, 0.56);
  color: #fff1d2;
  font-weight: 800;
}

.auto-builder-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.auto-builder-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(249, 229, 190, 0.18);
  background: rgba(32, 22, 13, 0.42);
  color: #f0dfbf;
  font-size: 11px;
  font-weight: 700;
}

.auto-builder-card-meta {
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  color: #ead8b7;
  font-size: 12px;
}

.auto-builder-card-actions {
  margin-top: 2px;
}

.auto-builder-detail .result {
  min-height: 280px;
}

.auto-builder-detail-panel {
  padding: 14px;
  background:
    linear-gradient(180deg, rgba(31, 21, 13, 0.78), rgba(78, 56, 33, 0.54)),
    var(--asset-walnut);
  background-size: cover, 540px 540px;
  border: 1px solid rgba(244, 223, 190, 0.18);
}

.auto-builder-detail-hero {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 223, 172, 0.22);
  background: rgba(21, 14, 9, 0.34);
}

.auto-builder-detail-title {
  font-family: "Orbitron", sans-serif;
  font-size: 17px;
  color: #fff1d8;
}

.auto-builder-detail-subtitle,
.auto-builder-detail-tags {
  color: #ead6b0;
  font-size: 12px;
}

.auto-builder-detail-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.auto-builder-detail-metrics span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(67, 47, 28, 0.62);
  border: 1px solid rgba(255, 226, 176, 0.14);
  font-size: 11px;
  color: #fff0cf;
  font-weight: 700;
}

.auto-builder-detail-section {
  margin-top: 12px;
  display: grid;
  gap: 6px;
}

.auto-builder-detail-section h4 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #f2dfbe;
}

.auto-builder-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(244, 227, 194, 0.14);
  background: rgba(24, 17, 11, 0.34);
}

.auto-builder-detail-row span,
.auto-builder-detail-row small {
  min-width: 0;
}

.auto-builder-detail-row small {
  color: #dcc8a3;
  text-align: right;
}

.card-tile.is-selected {
  box-shadow:
    inset 0 0 0 2px rgba(255, 225, 164, 0.42),
    0 14px 28px rgba(0, 0, 0, 0.44);
}

.picker-modal {
  position: fixed;
  z-index: 120;
  inset: 0;
  padding: 26px;
  background: rgba(14, 10, 7, 0.72);
  display: grid;
  place-items: center;
}

.picker-modal[hidden] {
  display: none !important;
}

.confirm-dialog {
  width: min(460px, 100%);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(174, 145, 100, 0.86);
  background:
    linear-gradient(180deg, rgba(49, 36, 22, 0.96), rgba(121, 89, 52, 0.84)),
    var(--asset-walnut);
  background-size: cover, 640px 640px;
  box-shadow: 0 22px 42px rgba(0, 0, 0, 0.58);
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.confirm-dialog-title {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text-light);
}

.confirm-dialog-body {
  margin: 0;
  color: #c8b89a;
  line-height: 1.5;
}

.confirm-dialog-input {
  width: 100%;
}

.confirm-dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 4px;
}

.picker-dialog {
  width: min(1120px, 100%);
  max-height: min(85vh, 900px);
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(174, 145, 100, 0.86);
  background:
    linear-gradient(180deg, rgba(49, 36, 22, 0.92), rgba(121, 89, 52, 0.78)),
    var(--asset-walnut);
  background-size: cover, 640px 640px;
  box-shadow: 0 22px 42px rgba(0, 0, 0, 0.58);
  padding: 10px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 8px;
}

.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.picker-head h3 {
  font-size: 15px;
  color: #f7e5c3;
}

.picker-dialog .tile-grid {
  max-height: unset;
  min-height: 260px;
}

.row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.row.stackable {
  align-items: stretch;
}

.row.inputs-inline {
  flex-wrap: wrap;
}

.row.inputs-inline > * {
  flex: 1;
  min-width: 0;
}

.row.inputs-inline > button {
  flex: 0 0 auto;
}

.grid {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.grid.two {
  grid-template-columns: 1fr 1fr;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #faedd4;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

input,
select,
textarea,
button {
  border-radius: var(--radius-md);
  min-height: 36px;
  font-family: "Nunito Sans", sans-serif;
}

input,
select {
  min-height: 40px;
  height: 40px;
}

input,
select,
textarea {
  border: 1px solid rgba(112, 91, 63, 0.9);
  color: #2d2418;
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.46), rgba(204, 179, 143, 0.44)),
    var(--asset-paper);
  background-size: cover, 440px 440px;
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.34);
  padding: 8px 10px;
}

textarea {
  resize: vertical;
}

input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button {
  border: 1px solid rgba(106, 74, 25, 0.94);
  color: #fff2dd;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  height: 40px;
  line-height: 1;
  white-space: nowrap;
  letter-spacing: 0.01em;
  padding: 7px 12px;
  background-color: #9d682c;
  background-image:
    linear-gradient(180deg, rgba(209, 148, 72, 0.98), rgba(99, 63, 26, 0.98)),
    var(--asset-btn-amber);
  background-size: cover, 110% 128%;
  background-position: center, center 49%;
  background-repeat: no-repeat, no-repeat;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.38),
    inset 0 -2px 4px rgba(0, 0, 0, 0.32),
    0 5px 10px rgba(0, 0, 0, 0.36);
  transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

button:active {
  transform: translateY(0);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.36),
    0 2px 6px rgba(0, 0, 0, 0.34);
}

button:disabled,
button[disabled] {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none !important;
  filter: none !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 2px 4px rgba(0, 0, 0, 0.2) !important;
}

button.is-loading {
  cursor: wait;
  opacity: 0.72;
  position: relative;
}

button.is-loading::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: rgba(255, 255, 255, 0.9);
  animation: btn-spin 0.65s linear infinite;
}

@keyframes btn-spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

button.danger {
  border-color: rgba(112, 34, 29, 0.94);
  background-image: linear-gradient(180deg, rgba(255, 198, 188, 0.35), rgba(120, 22, 22, 0.68));
}

.card-action-btn.secondary {
  border-color: rgba(48, 72, 96, 0.94);
  background-color: #3e6178;
  background-image:
    linear-gradient(180deg, rgba(103, 139, 167, 0.98), rgba(41, 69, 92, 0.98)),
    var(--asset-btn-slate);
  background-size: cover, 110% 128%;
  background-position: center, center 49%;
  background-repeat: no-repeat, no-repeat;
}

.muted {
  position: relative;
  z-index: 1;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: #f2e3c8;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.inspector-block + .inspector-block {
  margin-top: 11px;
  padding-top: 11px;
}

.inspector-block {
  position: relative;
  z-index: 1;
}

.inspector-subtitle {
  margin: 0 0 6px;
  font-family: "Orbitron", sans-serif;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #f6e7cb;
}

.validation-layout {
  display: grid;
  gap: 10px;
}

.validation-layout-block {
  min-width: 0;
}

.library-split {
  display: grid;
  gap: 10px;
}

.library-pane {
  min-width: 0;
}

.library-note {
  margin: 0 0 6px;
  font-size: 11px;
  line-height: 1.3;
  color: #efddbc;
}

.library-pane .tile-grid.compact {
  --tile-min: 126px;
  --tile-gap: 8px;
  max-height: 28vh;
}

.library-pane .tile-grid {
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.library-pane .tile-grid.is-drop-target {
  border-color: rgba(250, 212, 148, 0.92);
  box-shadow:
    inset 0 0 0 2px rgba(255, 227, 172, 0.52),
    inset 0 2px 8px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  animation: library-drop-pulse 0.9s ease-in-out infinite;
}

@keyframes library-drop-pulse {
  0%, 100% { box-shadow: inset 0 0 0 2px rgba(255, 227, 172, 0.52), inset 0 2px 8px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.2); }
  50%       { box-shadow: inset 0 0 0 3px rgba(255, 215, 140, 0.82), inset 0 2px 8px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.2); }
}

.library-deck-tile {
  --card-tilt: 0deg;
  cursor: grab;
  transition: opacity 0.15s ease, filter 0.15s ease, transform 0.15s ease, outline-color 0.15s ease;
}

.library-deck-tile .card-body {
  gap: 2px;
}

.library-deck-tile:active {
  cursor: grabbing;
}

.library-deck-tile:focus-visible {
  outline: 2px solid rgba(252, 218, 163, 0.86);
  outline-offset: 2px;
}

.library-deck-tile.is-dragging {
  opacity: 0.55;
  filter: saturate(0.6) brightness(0.85);
  transform: scale(0.95);
}

.library-deck-tile.is-just-moved {
  animation: lib-tile-confirm 0.55s ease-out forwards;
}

@keyframes lib-tile-confirm {
  0%   { outline: 2px solid rgba(255, 218, 140, 0.9); outline-offset: 2px; transform: scale(1.03); }
  60%  { outline: 2px solid rgba(255, 218, 140, 0.5); outline-offset: 2px; transform: scale(1.01); }
  100% { outline: 2px solid transparent; outline-offset: 2px; transform: scale(1); }
}

.library-deck-tile .card-title {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.library-deck-tile .card-subtitle {
  font-size: 10px;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.library-deck-tile .card-actions {
  margin-top: 4px;
  justify-content: flex-end;
}

.library-deck-tile .card-action-btn {
  padding: 3px 7px;
  font-size: 10px;
}

.library-deck-tile:not(.is-expanded) .card-subtitle,
.library-deck-tile:not(.is-expanded) .card-actions {
  display: none;
}

.library-deck-tile.is-expanded {
  border-color: rgba(236, 201, 147, 0.88);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -2px 5px rgba(0, 0, 0, 0.24),
    0 10px 16px rgba(0, 0, 0, 0.42);
}

.card-tile.is-in-use .card-pill {
  border-color: rgba(235, 181, 123, 0.72);
  background: rgba(85, 53, 21, 0.82);
  color: #ffe8c8;
}

.deck-search-block {
  margin-top: 0;
  padding-top: 0;
}

.deck-search-block .row.inputs-inline {
  align-items: stretch;
  flex-wrap: wrap;
}

#meta-sort-by {
  flex: 0 0 180px;
  min-width: 170px;
}

.deck-search-block .tile-grid.compact {
  --tile-min: 134px;
  --tile-gap: 10px;
  max-height: 50vh;
}

#meta-freshness {
  margin: 6px 0 0;
}

.tile-grid {
  position: relative;
  z-index: 1;
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile-min, 142px), 1fr));
  gap: var(--tile-gap, 8px);
  max-height: 62vh;
  overflow: auto;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid rgba(61, 45, 26, 0.7);
  background:
    linear-gradient(180deg, rgba(19, 15, 10, 0.26), rgba(248, 225, 190, 0.16)),
    var(--asset-paper);
  background-size: cover, 440px 440px;
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.tile-grid.compact {
  --tile-min: 116px;
  --tile-gap: 8px;
  max-height: 42vh;
}

.card-tile {
  --card-tilt: 0deg;
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  min-height: 226px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(97, 70, 42, 0.94);
  background-image:
    linear-gradient(165deg, rgba(255, 245, 224, 0.8), rgba(162, 131, 88, 0.72)),
    var(--asset-aluminum);
  background-size: cover, 480px 480px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.38),
    inset 0 -2px 5px rgba(0, 0, 0, 0.24),
    0 8px 14px rgba(0, 0, 0, 0.35);
  transform: rotate(var(--card-tilt));
  transition: transform 140ms ease, box-shadow 160ms ease;
}

.card-tile:hover {
  transform: translateY(-4px) rotate(var(--card-tilt));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 13px 22px rgba(0, 0, 0, 0.42);
}

.card-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: transparent;
  opacity: 0;
  pointer-events: none;
}

.card-art {
  --card-mx: 50%;
  --card-my: 50%;
  --card-sheen-opacity: 0.22;
  position: relative;
  margin: 8px 8px 6px;
  aspect-ratio: 3 / 4;
  border-radius: 11px;
  border: 1px solid rgba(41, 33, 22, 0.82);
  overflow: hidden;
  background: #0f172b;
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.2),
    inset 0 -5px 10px rgba(0, 0, 0, 0.36);
}

.card-art::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 11px;
  border: 2px solid rgba(248, 236, 213, 0.2);
  pointer-events: none;
}

.card-art::after {
  content: none;
}

.card-art .card-sheen {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(
      circle at var(--card-mx) var(--card-my),
      rgba(255, 255, 255, 0.46),
      rgba(255, 255, 255, 0.14) 24%,
      rgba(255, 255, 255, 0.04) 41%,
      rgba(255, 255, 255, 0) 62%
    ),
    linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0) 45%);
  mix-blend-mode: screen;
  opacity: var(--card-sheen-opacity);
  transition: opacity 170ms ease, filter 170ms ease;
  filter: brightness(1.04) contrast(1.02);
}

.card-tile.is-foil .card-art {
  --foil-mx: var(--card-mx);
  --foil-my: var(--card-my);
  --foil-opacity: 0.8;
  --card-sheen-opacity: 0.34;
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.28),
    inset 0 -5px 10px rgba(0, 0, 0, 0.32),
    0 0 0 1px rgba(255, 224, 176, 0.24),
    0 2px 8px rgba(255, 241, 214, 0.12);
}

.card-tile.is-foil .card-art img {
  position: relative;
  z-index: 1;
  filter: saturate(1.14) contrast(1.08) brightness(1.03);
}

.card-tile.is-foil .card-art .card-sheen {
  filter: brightness(1.1) contrast(1.06);
  opacity: calc(var(--card-sheen-opacity) + 0.06);
}

.card-tile.is-foil .card-art .foil-holo {
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: inherit;
  pointer-events: none;
}

.card-tile.is-foil .card-art .foil-holo {
  background:
    conic-gradient(
      from 0deg at var(--foil-mx) var(--foil-my),
      rgba(255, 47, 210, 0.96),
      rgba(47, 255, 255, 0.95),
      rgba(60, 255, 143, 0.95),
      rgba(255, 233, 111, 0.94),
      rgba(255, 47, 210, 0.96)
    ),
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.09) 0px,
      rgba(255, 255, 255, 0.09) 1px,
      rgba(255, 255, 255, 0) 2px,
      rgba(255, 255, 255, 0) 4px
    ),
    linear-gradient(
      130deg,
      rgba(255, 255, 255, 0) 26%,
      rgba(255, 255, 255, 0.28) 42%,
      rgba(255, 255, 255, 0.08) 56%,
      rgba(255, 255, 255, 0) 70%
    );
  background-blend-mode: overlay, normal, screen;
  mix-blend-mode: color-dodge;
  opacity: var(--foil-opacity);
  filter: saturate(1) contrast(0.30) brightness(0.54);
  transition: opacity 170ms ease, filter 180ms ease;
}

.card-tile.is-foil:hover .card-art .foil-holo {
  filter: saturate(1.08) contrast(0.34) brightness(0.60);
}

.card-tile.is-collection-missing .card-art .card-sheen,
.card-tile.is-unowned .card-art .card-sheen,
.card-tile.is-foil.is-collection-missing .card-art .foil-holo,
.card-tile.is-foil.is-unowned .card-art .foil-holo {
  opacity: 0;
}

.card-art img,
.card-preview-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.card-art img.is-fallback,
.card-preview-image.is-fallback {
  object-fit: cover;
  filter: saturate(1.04) contrast(1.03);
}

.card-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-family: "Orbitron", sans-serif;
  font-size: 26px;
  color: #ece0c4;
  background-image: url("assets/skeuo/card-backs/card_back_clean_768x1024.png");
  background-size: cover;
  background-position: center;
}

.card-pill {
  position: absolute;
  z-index: 3;
  top: 6px;
  left: 6px;
  max-width: calc(100% - 12px);
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(247, 232, 202, 0.52);
  background: rgba(26, 22, 16, 0.74);
  color: #f8f0de;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-pill.is-bottom-right {
  top: auto;
  left: auto;
  right: 6px;
  bottom: 6px;
}

.card-body {
  padding: 2px 8px 9px;
  display: grid;
  align-content: start;
  gap: 4px;
}

.card-title {
  font-size: 12px;
  font-weight: 800;
  line-height: 1.24;
  color: #2d2216;
}

.card-subtitle {
  font-size: 11px;
  color: #4b3f2d;
}

.card-actions {
  margin-top: 3px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.card-action-btn {
  min-height: 0;
  height: auto;
  padding: 4px 7px;
  font-size: 10px;
  border-radius: 999px;
}

.collection-zone .module-head h2 {
  color: #2d2216;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.collection-zone .muted,
.collection-zone label {
  color: #3f311f;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.28);
}

.collection-toolbar {
  align-items: center;
  gap: 8px;
}

.collection-toolbar #collection-import-btn {
  flex: 0 0 auto;
}

.collection-toolbar #collection-import-mode {
  flex: 0 0 170px;
  min-width: 150px;
}

.collection-toolbar #collection-search-input {
  flex: 1 1 auto;
  min-width: 180px;
}

.collection-toolbar .card-action-btn {
  min-height: 36px;
  height: 36px;
  padding: 5px 10px;
  font-size: 11px;
}

.collection-toolbar #collection-export-json-btn,
.collection-toolbar #collection-export-csv-btn {
  min-width: 102px;
}

.collection-filter-panel {
  position: relative;
  z-index: 1;
  margin-bottom: 8px;
  border: 1px solid rgba(108, 81, 48, 0.7);
  border-radius: 10px;
  padding: 8px;
  background:
    linear-gradient(180deg, rgba(255, 243, 220, 0.3), rgba(87, 63, 33, 0.22)),
    var(--asset-paper);
  background-size: cover, 420px 420px;
}

.collection-filter-panel .row {
  margin-bottom: 0;
}

.collection-filter-panel select {
  min-width: 120px;
}

.collection-edit-card.is-edit-mode .card-actions {
  margin-top: 4px;
}

.collection-qty-stepper {
  width: 100%;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid rgba(114, 82, 50, 0.66);
  background:
    linear-gradient(180deg, rgba(149, 115, 74, 0.4), rgba(55, 37, 21, 0.34)),
    rgba(26, 16, 9, 0.26);
  padding: 2px 8px;
}

.collection-qty-stepper .step-btn {
  min-width: 22px;
  width: 22px;
  height: 22px;
  min-height: 22px;
  font-size: 12px;
}

.collection-qty-stepper .step-value {
  min-width: 24px;
  font-size: 12px;
}

.collection-edit-card.is-unowned .card-art img {
  filter: grayscale(0.9) saturate(0.36) brightness(0.7);
}

.collection-edit-card.is-unowned .card-pill {
  border-color: rgba(181, 160, 129, 0.5);
  color: #d8cab4;
}

.card-tile.skeleton {
  background-image:
    linear-gradient(165deg, rgba(255, 245, 224, 0.46), rgba(145, 122, 92, 0.5)),
    var(--asset-aluminum);
}

.card-tile.skeleton .card-art,
.card-tile.skeleton .card-body {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.18);
}

.card-tile.skeleton .card-body {
  min-height: 60px;
}

.card-tile.skeleton::before {
  content: "";
  position: absolute;
  inset: -40% auto -40% -52%;
  width: 42%;
  transform: rotate(14deg);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 246, 225, 0.55), rgba(255, 255, 255, 0));
  animation: shimmer 1.15s linear infinite;
}

@keyframes shimmer {
  to {
    left: 120%;
  }
}

.result {
  margin-top: 7px;
  min-height: 46px;
  max-height: 210px;
  overflow: auto;
  border-radius: var(--radius-md);
  border: 1px solid rgba(114, 89, 57, 0.88);
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(201, 173, 134, 0.44)),
    var(--asset-paper);
  background-size: cover, 380px 380px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.28);
  color: var(--text-dark);
  padding: 8px 10px;
  font-size: 13px;
}

.validation-result {
  min-height: 128px;
  max-height: 340px;
  padding: 10px;
}

.analysis-result {
  max-height: 250px;
}

.validation-panel {
  display: grid;
  gap: 9px;
  color: #2d2418;
}

.validation-panel.is-empty,
.validation-panel.is-valid {
  padding: 2px 0;
}

.validation-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.validation-state-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid rgba(58, 47, 35, 0.38);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.validation-state-pill.is-legal {
  border-color: rgba(45, 102, 56, 0.44);
  background: linear-gradient(180deg, rgba(190, 238, 200, 0.8), rgba(133, 206, 149, 0.85));
  color: #1d572f;
}

.validation-state-pill.is-illegal {
  border-color: rgba(133, 36, 39, 0.48);
  background: linear-gradient(180deg, rgba(249, 202, 202, 0.84), rgba(230, 149, 149, 0.86));
  color: #81262a;
}

.validation-summary-text {
  font-weight: 800;
  line-height: 1.3;
  color: #2f2618;
}

.validation-headline {
  font-size: 12px;
  font-weight: 600;
  color: #3f311f;
}

.validation-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.validation-metric {
  border: 1px solid rgba(127, 97, 63, 0.34);
  border-radius: 8px;
  padding: 5px 7px;
  background: linear-gradient(180deg, rgba(255, 250, 241, 0.64), rgba(229, 206, 171, 0.58));
  display: grid;
  gap: 2px;
}

.validation-metric span {
  font-size: 10px;
  line-height: 1.1;
  color: #6a5437;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 800;
}

.validation-metric strong {
  font-size: 14px;
  line-height: 1;
  color: #2f2619;
}

.validation-groups {
  display: grid;
  gap: 8px;
}

.validation-group {
  border: 1px solid rgba(118, 88, 56, 0.35);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 248, 237, 0.64), rgba(220, 190, 149, 0.56));
  overflow: hidden;
}

.validation-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-bottom: 1px solid rgba(118, 88, 56, 0.28);
  font-weight: 800;
  font-size: 12px;
  color: #3e2f1b;
}

.validation-group-head span {
  min-width: 18px;
  text-align: center;
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 10px;
  background: rgba(72, 51, 29, 0.16);
}

.validation-issue-list {
  display: grid;
  gap: 5px;
  padding: 7px;
}

.validation-issue-row {
  border-radius: 8px;
  border: 1px solid rgba(124, 90, 55, 0.3);
  background: rgba(255, 255, 255, 0.46);
  padding: 6px 7px;
  display: grid;
  gap: 5px;
}

.validation-issue-top {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.validation-code-pill {
  border-radius: 999px;
  border: 1px solid rgba(145, 49, 54, 0.42);
  background: linear-gradient(180deg, rgba(252, 220, 220, 0.8), rgba(241, 174, 174, 0.86));
  color: #8b2429;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.03em;
  padding: 2px 7px;
}

.validation-issue-message {
  font-size: 12px;
  color: #3d2e1a;
  line-height: 1.35;
}

.validation-refs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.validation-ref-chip {
  border-radius: 999px;
  border: 1px solid rgba(74, 91, 117, 0.4);
  background: linear-gradient(180deg, rgba(226, 236, 248, 0.82), rgba(189, 210, 236, 0.84));
  color: #2c4a6b;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  white-space: nowrap;
}

.analysis-result .warn,
.analysis-result .ok,
.analysis-result .err {
  display: block;
  margin-bottom: 4px;
}

.analysis-buy-link {
  color: #0e4f84;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.analysis-buy-link:hover {
  color: #0a65a8;
}

@media (max-width: 720px) {
  .validation-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .validation-metrics {
    grid-template-columns: 1fr;
  }
}

.ok {
  color: var(--ok);
}

.warn {
  color: var(--warn);
}

.err {
  color: var(--err);
}

code {
  color: var(--accent);
}

.card-preview {
  position: fixed;
  z-index: 80;
  width: 292px;
  overflow: hidden;
  pointer-events: none;
  border-radius: 14px;
  border: 1px solid rgba(135, 112, 84, 0.94);
  background-image:
    linear-gradient(166deg, rgba(255, 248, 231, 0.88), rgba(169, 133, 88, 0.64)),
    var(--asset-aluminum);
  background-size: cover, 500px 500px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 16px 30px rgba(0, 0, 0, 0.5);
}

.card-preview-art-wrap {
  position: relative;
  aspect-ratio: 3 / 4;
  margin: 8px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(44, 36, 24, 0.85);
  background: #11192f;
}

.card-preview-art-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--asset-gloss);
  background-size: cover;
  opacity: 0.22;
  pointer-events: none;
}

.card-preview-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #f2e7cf;
  font-family: "Orbitron", sans-serif;
  font-size: 34px;
  background-image: url("assets/skeuo/card-backs/card_back_clean_768x1024.png");
  background-size: cover;
  background-position: center;
}

.card-preview-body {
  padding: 2px 10px 11px;
  display: grid;
  gap: 4px;
}

.card-preview-title {
  font-family: "Orbitron", sans-serif;
  font-size: 17px;
  line-height: 1.16;
  color: #2b2115;
  text-shadow: none;
}

.card-preview-meta,
.card-preview-stats {
  font-size: 12px;
  color: #4e412f;
}

.main-card-modal {
  z-index: 130;
}

.main-card-dialog {
  width: min(880px, 96vw);
  max-height: min(88vh, 900px);
  overflow: auto;
  border-radius: 14px;
  border: 1px solid rgba(174, 145, 100, 0.9);
  background:
    linear-gradient(180deg, rgba(49, 36, 22, 0.94), rgba(121, 89, 52, 0.8)),
    var(--asset-walnut);
  background-size: cover, 640px 640px;
  box-shadow: 0 24px 44px rgba(0, 0, 0, 0.62);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.main-card-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.main-card-dialog-head h3 {
  font-size: 19px;
  color: #f7e5c4;
}

.main-card-dialog-body {
  display: grid;
  grid-template-columns: minmax(220px, 340px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.main-card-dialog-art-wrap {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(245, 231, 207, 0.5);
  background: #0f172b;
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.2),
    inset 0 -5px 10px rgba(0, 0, 0, 0.36),
    0 10px 18px rgba(0, 0, 0, 0.46);
}

.main-card-dialog-art-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--asset-gloss);
  background-size: cover;
  opacity: 0.2;
  pointer-events: none;
}

.main-card-dialog-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.main-card-dialog-image.is-fallback {
  filter: saturate(1.04) contrast(1.03);
}

.main-card-dialog-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #f2e7cf;
  font-family: "Orbitron", sans-serif;
  font-size: 34px;
  background-image: url("assets/skeuo/card-backs/card_back_clean_768x1024.png");
  background-size: cover;
  background-position: center;
}

.main-card-dialog-copy {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  border-radius: 11px;
  border: 1px solid rgba(118, 90, 55, 0.9);
  padding: 10px;
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(201, 173, 134, 0.44)),
    var(--asset-paper);
  background-size: cover, 380px 380px;
  color: #2d2418;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.22);
}

.main-card-dialog-meta,
.main-card-dialog-stats {
  font-size: 14px;
  line-height: 1.35;
}

.main-card-dialog-detail {
  font-size: 13px;
  font-weight: 700;
  color: #4b3c27;
}

.main-card-dialog-tags {
  font-size: 13px;
  color: #5d4c34;
}

.main-card-dialog-section-label {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #6a5639;
}

.main-card-dialog-effect {
  font-size: 14px;
  line-height: 1.4;
  color: #2d2418;
}

.main-card-dialog-flavor {
  font-size: 13px;
  line-height: 1.35;
  color: #5a4a33;
  font-style: italic;
}

.meta-detail-modal {
  z-index: 145;
}

.meta-detail-dialog {
  width: min(980px, 97vw);
  max-height: min(90vh, 920px);
  overflow: auto;
  border-radius: 15px;
  border: 1px solid rgba(174, 145, 100, 0.9);
  background:
    linear-gradient(180deg, rgba(46, 33, 20, 0.95), rgba(102, 76, 46, 0.84)),
    var(--asset-walnut);
  background-size: cover, 700px 700px;
  box-shadow: 0 24px 44px rgba(0, 0, 0, 0.62);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.meta-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.meta-detail-head h3 {
  font-size: 18px;
}

.meta-detail-meta {
  margin-top: 4px;
  font-size: 12px;
  color: #e9d5b1;
}

.meta-detail-stats {
  font-size: 12px;
  color: #efdcb9;
}

.meta-detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.meta-detail-grid section {
  border: 1px solid rgba(116, 85, 50, 0.82);
  border-radius: 10px;
  padding: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(164, 132, 92, 0.32)),
    var(--asset-paper);
  background-size: cover, 320px 320px;
}

.meta-detail-grid h4 {
  margin: 0 0 6px;
  font-size: 12px;
  color: #2d2418;
}

.meta-detail-list {
  max-height: 180px;
  overflow: auto;
  display: grid;
  gap: 4px;
}

.meta-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: #2d2418;
}

.meta-detail-row small {
  color: #5c4a32;
  text-align: right;
}

.meta-detail-empty {
  font-size: 12px;
  color: #4c3a26;
}

.deck-import-modal {
  z-index: 146;
}

.deck-import-dialog {
  width: min(760px, 96vw);
  max-height: min(86vh, 760px);
  overflow: auto;
  border-radius: 14px;
  border: 1px solid rgba(174, 145, 100, 0.9);
  background:
    linear-gradient(180deg, rgba(46, 33, 20, 0.95), rgba(102, 76, 46, 0.84)),
    var(--asset-walnut);
  background-size: cover, 680px 680px;
  box-shadow: 0 24px 44px rgba(0, 0, 0, 0.62);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.deck-import-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.deck-import-head h3 {
  font-size: 17px;
  color: #f6e8cc;
}

#deck-import-text {
  width: 100%;
  min-height: 220px;
  resize: vertical;
}

.deck-import-actions {
  display: flex;
  justify-content: flex-end;
}

.replacement-modal {
  z-index: 140;
}

.replacement-dialog {
  width: min(1220px, 97vw);
  max-height: min(90vh, 940px);
  overflow: auto;
  border-radius: 15px;
  border: 1px solid rgba(174, 145, 100, 0.9);
  background:
    linear-gradient(180deg, rgba(46, 33, 20, 0.95), rgba(102, 76, 46, 0.84)),
    var(--asset-walnut);
  background-size: cover, 700px 700px;
  box-shadow: 0 24px 44px rgba(0, 0, 0, 0.62);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.replacement-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.replacement-head h3 {
  font-size: 18px;
  color: #f8e7c7;
}

.replacement-body {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 340px);
  gap: 12px;
  align-items: start;
}

.replacement-pane-title {
  margin: 0 0 6px;
  font-family: "Orbitron", sans-serif;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #f7e5c3;
}

.replacement-summary {
  font-size: 12px;
  color: #e9d5b1;
  margin-bottom: 8px;
}

.replacement-suggestions-pane,
.replacement-target-pane {
  border-radius: 11px;
  border: 1px solid rgba(118, 90, 55, 0.9);
  padding: 10px;
  background:
    linear-gradient(180deg, rgba(25, 18, 12, 0.56), rgba(112, 84, 52, 0.34)),
    var(--asset-walnut);
  background-size: cover, 560px 560px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -6px 10px rgba(0, 0, 0, 0.36);
}

.replacement-alcove {
  position: relative;
  min-height: 520px;
  border-radius: 12px;
  border: 1px solid rgba(56, 39, 24, 0.86);
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 12px;
  background:
    linear-gradient(180deg, rgba(14, 10, 7, 0.66), rgba(62, 42, 24, 0.46)),
    var(--asset-walnut);
  background-size: cover, 520px 520px;
  overflow: hidden;
}

.replacement-alcove::before,
.replacement-alcove::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  height: 12px;
  border-radius: 10px;
  border: 1px solid rgba(77, 52, 29, 0.9);
  background:
    linear-gradient(180deg, rgba(195, 153, 100, 0.64), rgba(51, 31, 17, 0.92)),
    var(--asset-walnut);
  background-size: cover, 420px 420px;
  box-shadow:
    inset 0 1px 0 rgba(255, 240, 212, 0.34),
    0 4px 8px rgba(0, 0, 0, 0.42);
  pointer-events: none;
}

.replacement-alcove::before {
  top: calc(50% - 8px);
}

.replacement-alcove::after {
  bottom: 6px;
}

.replacement-option {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid rgba(102, 73, 42, 0.9);
  background:
    linear-gradient(180deg, rgba(252, 240, 220, 0.72), rgba(159, 129, 86, 0.62)),
    var(--asset-aluminum);
  background-size: cover, 420px 420px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.34),
    0 8px 16px rgba(0, 0, 0, 0.34);
}

.replacement-option-art-wrap {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(43, 33, 20, 0.84);
  background: #0f172b;
}

.replacement-option-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.replacement-option-image.is-fallback {
  filter: saturate(1.03) contrast(1.02);
}

.replacement-owned-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(248, 228, 187, 0.52);
  background: rgba(22, 17, 11, 0.76);
  color: #f8ecd7;
  font-size: 10px;
  font-weight: 700;
}

.replacement-option-title {
  font-size: 12px;
  font-weight: 800;
  color: #2d2216;
  line-height: 1.24;
}

.replacement-option-metrics {
  font-size: 11px;
  color: #4f3f2a;
}

.replacement-use-btn {
  width: 100%;
}

.replacement-empty {
  display: grid;
  place-items: center;
  min-height: 250px;
  border: 1px dashed rgba(248, 228, 187, 0.44);
  border-radius: 10px;
  color: #f4dfbd;
  font-size: 13px;
  padding: 12px;
  text-align: center;
}

.replacement-target-pane {
  display: grid;
  align-content: start;
  gap: 8px;
}

.replacement-target-art-wrap {
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(245, 231, 207, 0.5);
  background: #0f172b;
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.2),
    inset 0 -5px 10px rgba(0, 0, 0, 0.36),
    0 10px 18px rgba(0, 0, 0, 0.46);
}

.replacement-target-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.replacement-target-name {
  font-family: "Orbitron", sans-serif;
  font-size: 15px;
  color: #f7e5c3;
}

.replacement-target-meta,
.replacement-target-state {
  font-size: 12px;
  color: #ead8b7;
}

#model-observation-panel {
  overflow: visible;
}

.model-observation-layout {
  display: grid;
  gap: 14px;
  grid-template-columns: 280px minmax(0, 1fr) 320px;
  grid-template-areas: "sidebar canvas controls";
  align-items: start;
}

.model-observation-sidebar,
.model-observation-controls,
.model-observation-canvas {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.model-observation-sidebar {
  grid-area: sidebar;
}

.model-observation-controls {
  grid-area: controls;
}

.model-observation-canvas {
  grid-area: canvas;
}

.model-note-card {
  position: relative;
  padding: 16px 16px 14px;
  border-radius: 18px;
  border: 1px solid rgba(110, 88, 56, 0.72);
  background:
    linear-gradient(180deg, rgba(255, 248, 233, 0.97), rgba(225, 211, 182, 0.92)),
    var(--asset-paper);
  background-size: cover, 560px 560px;
  color: #2d2216;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    0 18px 24px rgba(14, 9, 4, 0.18);
}

.model-note-card h3,
.model-note-card h4 {
  color: #312417;
  text-shadow: none;
}

.model-note-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.model-note-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #7f6036;
}

.model-status-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.model-mini-card {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(145, 118, 73, 0.28);
  background: rgba(255, 250, 241, 0.84);
}

.model-mini-card small {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7c6240;
}

.model-mini-card strong {
  font-size: 18px;
  color: #261b11;
}

.model-live-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.model-live-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, #3a8a3a, #58ab58);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.model-status-note {
  margin: 12px 0 10px;
  font-size: 13px;
  color: #57462f;
}

.model-mini-list,
.model-detail-section,
.model-observation-models {
  display: grid;
  gap: 8px;
}

.model-observation-models {
  max-height: 400px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.model-mini-row,
.model-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(144, 112, 69, 0.18);
}

.model-mini-row span,
.model-detail-row span {
  color: #5a4630;
}

.model-mini-row strong,
.model-detail-row strong {
  color: #281d13;
}

.model-version-card {
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(127, 94, 49, 0.22);
  background: rgba(255, 255, 255, 0.68);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.model-version-card.is-selected {
  border-color: rgba(122, 80, 27, 0.62);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.78),
    0 0 0 2px rgba(158, 110, 45, 0.16);
}

.model-version-head,
.model-version-body {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.model-version-head {
  margin-bottom: 8px;
}

.model-version-title {
  font-weight: 800;
  color: #241910;
}

.model-version-meta,
.model-version-body {
  font-size: 12px;
  color: #67513a;
}

.model-version-body {
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.model-observation-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.model-note-lane {
  display: grid;
  gap: 10px;
  align-content: start;
}

.model-note-lane > header h4 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.model-node-card {
  padding: 12px;
  border-radius: 15px;
  border: 1px solid rgba(146, 113, 65, 0.2);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(245, 235, 214, 0.9));
  box-shadow: 0 10px 16px rgba(16, 11, 4, 0.08);
}

.model-node-card small {
  display: block;
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #84683e;
}

.model-node-card h4 {
  margin: 0 0 6px;
  font-size: 14px;
}

.model-node-card p {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: #5e4a33;
}

.model-node-meta {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 700;
  color: #7a5e36;
}

.model-graph-shell {
  display: grid;
  gap: 14px;
}

.model-graph-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.model-graph-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.model-graph-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(111, 95, 70, 0.28);
  background: rgba(255, 249, 238, 0.72);
  color: #4f3a23;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 10px 16px rgba(16, 11, 4, 0.08);
}

.model-graph-filter-chip strong {
  color: #8a6022;
}

.model-graph-filter-chip.is-active {
  border-color: rgba(156, 112, 41, 0.5);
  background: linear-gradient(135deg, rgba(255, 244, 219, 0.98), rgba(238, 217, 176, 0.94));
  box-shadow: 0 14px 22px rgba(58, 37, 10, 0.14);
}

.model-graph-tools {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.model-graph-zoom-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 999px;
  border: 1px solid rgba(128, 99, 54, 0.22);
  background: rgba(255, 248, 236, 0.72);
}

.model-graph-zoom-tools .card-action-btn {
  min-width: 38px;
  padding-inline: 12px;
}

.model-graph-zoom-label {
  min-width: 54px;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  color: #6e522f;
}

.model-graph-search {
  display: grid;
  gap: 6px;
  min-width: min(240px, 100%);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #705632;
}

.model-graph-search input {
  min-width: min(240px, 100%);
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(123, 94, 52, 0.24);
  background: rgba(255, 250, 242, 0.92);
  color: #3f2d1b;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.84);
}

.model-graph-caption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  font-weight: 700;
  color: #715939;
}

.model-graph-main {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
  align-items: start;
}

.model-graph-stage {
  position: relative;
  min-height: clamp(700px, 76vh, 980px);
  padding: 18px 20px 16px;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid rgba(58, 46, 30, 0.68);
  background:
    radial-gradient(circle at 20% 18%, rgba(92, 120, 170, 0.28), transparent 24%),
    radial-gradient(circle at 78% 28%, rgba(180, 129, 64, 0.24), transparent 26%),
    radial-gradient(circle at 50% 50%, rgba(54, 86, 131, 0.18), transparent 34%),
    linear-gradient(180deg, rgba(10, 14, 24, 0.98), rgba(20, 27, 41, 0.96));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    inset 0 0 0 1px rgba(164, 188, 224, 0.05),
    0 22px 34px rgba(10, 6, 3, 0.24);
  scrollbar-gutter: stable both-edges;
  cursor: grab;
  touch-action: none;
}

.model-graph-stage.is-panning,
.model-graph-stage.is-dragging-node {
  cursor: grabbing;
}

.model-graph-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 36px 36px;
  opacity: 0.45;
  pointer-events: none;
}

.model-graph-stage-glow {
  position: absolute;
  inset: 10% 16% auto;
  height: 36%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(120, 164, 222, 0.22), transparent 70%);
  filter: blur(22px);
  opacity: 0.8;
  pointer-events: none;
}

.model-graph-scene {
  position: relative;
  min-width: 100%;
  z-index: 1;
  will-change: transform;
}

.model-graph-links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.model-graph-edge {
  fill: none;
  stroke-linecap: round;
  opacity: 0.8;
  filter: drop-shadow(0 0 9px rgba(91, 149, 237, 0.2));
  pointer-events: none;
}

.model-graph-edge.is-win {
  stroke: rgba(255, 185, 100, 0.72);
}

.model-graph-edge.is-shell {
  stroke: rgba(184, 230, 162, 0.66);
}

.model-graph-edge.is-synergy {
  stroke: rgba(97, 195, 206, 0.68);
}

.model-graph-edge.is-card {
  stroke: rgba(149, 171, 223, 0.52);
}

.model-graph-edge.is-dimmed {
  opacity: 0.16;
}

.model-graph-nodes {
  position: absolute;
  inset: 0;
}

.model-graph-node {
  position: absolute;
  border: 0;
  cursor: grab;
  user-select: none;
  touch-action: none;
  will-change: transform;
  transition:
    transform 160ms ease,
    opacity 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease;
}

.model-graph-node:hover {
  transform: translateY(-2px);
}

.model-graph-node.is-selected {
  transform: translateY(-2px) scale(1.03);
  z-index: 4;
}

.model-graph-node.is-dragging,
.model-graph-node.is-dragging:hover {
  cursor: grabbing;
  transform: scale(1.04);
  z-index: 8;
}

.model-graph-node.is-pinned {
  box-shadow:
    0 0 0 1px rgba(255, 215, 123, 0.84),
    0 18px 30px rgba(2, 4, 10, 0.42);
}

.model-graph-node.is-dimmed {
  opacity: 0.24;
}

.model-graph-node.is-feature {
  display: grid;
  align-content: start;
  gap: 5px;
  padding: 12px 14px 12px 68px;
  border-radius: 22px;
  border: 1px solid rgba(123, 148, 187, 0.2);
  background: rgba(12, 17, 28, 0.84);
  color: #f2ecde;
  text-align: left;
  overflow: hidden;
  backdrop-filter: blur(16px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 16px 26px rgba(3, 7, 14, 0.34);
}

.model-graph-node.is-feature.is-win {
  border-color: rgba(255, 177, 77, 0.42);
}

.model-graph-node.is-feature.is-shell {
  border-color: rgba(182, 233, 165, 0.36);
}

.model-graph-node.is-feature.is-synergy {
  border-color: rgba(87, 197, 209, 0.4);
}

.model-graph-node.is-feature.is-archetype {
  border-color: rgba(125, 161, 224, 0.4);
}

.model-graph-node-aura {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top left, rgba(118, 164, 228, 0.24), transparent 44%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.04), transparent 72%);
  opacity: 0.95;
  pointer-events: none;
}

.model-graph-node-avatar {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  overflow: hidden;
  transform: translateY(-50%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.32);
}

.model-graph-node-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.model-graph-node-kicker {
  position: relative;
  z-index: 1;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(233, 224, 206, 0.72);
}

.model-graph-node-title {
  position: relative;
  z-index: 1;
  display: block;
  font-size: 15px;
  line-height: 1.2;
  color: #f8f2e6;
}

.model-graph-node-subtitle {
  position: relative;
  z-index: 1;
  display: block;
  font-size: 11px;
  line-height: 1.4;
  color: rgba(215, 226, 244, 0.74);
}

.model-graph-node.is-card {
  padding: 0;
  border-radius: 18px;
  overflow: hidden;
  background: #101826;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 18px 26px rgba(1, 4, 10, 0.42);
}

.model-graph-card-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.model-graph-card-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(5, 8, 15, 0.02), rgba(5, 8, 15, 0.08) 44%, rgba(5, 8, 15, 0.78));
  pointer-events: none;
}

.model-graph-card-title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 9px 10px 10px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.3;
  color: #fffaf0;
  text-align: left;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.model-graph-inspector {
  min-width: 0;
}

.model-graph-inspector-card {
  display: grid;
  gap: 14px;
  padding: 14px;
  border-radius: 22px;
  border: 1px solid rgba(77, 60, 34, 0.46);
  background:
    radial-gradient(circle at top right, rgba(164, 190, 230, 0.12), transparent 32%),
    linear-gradient(180deg, rgba(32, 24, 17, 0.96), rgba(20, 16, 12, 0.98));
  color: #efe7d8;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 18px 28px rgba(12, 8, 4, 0.24);
  grid-template-columns: minmax(300px, 0.88fr) minmax(0, 1.12fr);
  align-items: start;
}

.model-graph-inspector-hero {
  display: grid;
  gap: 12px;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: start;
}

.model-graph-inspector-art {
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #131b29;
  box-shadow: 0 16px 22px rgba(0, 0, 0, 0.28);
}

.model-graph-inspector-image {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
}

.model-graph-inspector-copy {
  display: grid;
  gap: 8px;
}

.model-graph-inspector-kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(247, 215, 156, 0.76);
}

.model-graph-inspector-copy h4 {
  margin: 0;
  font-size: 22px;
  color: #fff5e2;
}

.model-graph-inspector-copy p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(236, 229, 216, 0.84);
}

.model-graph-inspector-meta {
  font-size: 12px;
  font-weight: 700;
  color: rgba(197, 215, 241, 0.72);
}

.model-graph-stat-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.model-graph-stat {
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.model-graph-stat small {
  display: block;
  margin-bottom: 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(231, 218, 190, 0.7);
}

.model-graph-stat strong {
  color: #fff4de;
}

.model-graph-inspector-section {
  display: grid;
  gap: 10px;
}

.model-graph-inspector-section:first-of-type {
  align-content: start;
}

.model-graph-inspector-card > .model-graph-stat-grid,
.model-graph-inspector-card > .model-graph-inspector-section {
  min-width: 0;
}

.model-graph-inspector-card > .model-graph-inspector-hero,
.model-graph-inspector-card > .model-graph-stat-grid {
  grid-column: 1;
}

.model-graph-inspector-card > .model-graph-inspector-section {
  grid-column: 2;
}

.model-graph-inspector-section h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(245, 223, 183, 0.8);
}

.model-graph-card-strip {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.model-graph-card-chip {
  display: grid;
  gap: 7px;
  padding: 8px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: #f5ecdf;
  text-align: left;
}

.model-graph-card-chip-image {
  display: block;
  width: 100%;
  height: 88px;
  border-radius: 12px;
  object-fit: cover;
  background: #111824;
}

.model-graph-card-chip span {
  font-size: 12px;
  font-weight: 700;
}

.model-graph-related-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.model-graph-related-chip {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #f6edde;
  text-align: left;
}

.model-graph-related-chip small {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(201, 217, 244, 0.62);
}

.model-graph-related-chip strong {
  font-size: 12px;
  line-height: 1.35;
}

.model-train-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.model-train-grid label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #5a4630;
}

.model-train-grid label input,
.model-train-grid label select {
  width: 100%;
}

.model-training-toggle {
  align-items: center;
  grid-column: 1 / -1;
}

.train-section-header {
  grid-column: 1 / -1;
  margin-top: 6px;
  padding-top: 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #7a5c2e;
  border-top: 1px solid rgba(128, 96, 50, 0.2);
}

.model-train-actions {
  margin-top: 12px;
}

.model-progress {
  position: relative;
  margin-top: 12px;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(119, 87, 49, 0.24);
  background: rgba(102, 82, 53, 0.16);
}

.model-progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #9d7132, #d7b676);
  transition: width 180ms ease;
}

.model-progress-bar.is-active {
  box-shadow: 0 0 12px rgba(166, 115, 45, 0.28);
}

.model-training-live {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.model-training-overview {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(138, 103, 58, 0.22);
  background: rgba(255, 255, 255, 0.58);
}

.model-training-overview.is-running {
  border-color: rgba(141, 95, 25, 0.55);
  box-shadow: 0 0 0 2px rgba(180, 125, 44, 0.12);
}

.model-training-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.model-training-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 249, 235, 0.95), rgba(224, 204, 165, 0.95));
  border: 1px solid rgba(134, 100, 56, 0.28);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #674b25;
}

.model-training-meta {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: #6b5233;
}

.model-training-events {
  display: grid;
  gap: 8px;
}

.model-training-event {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(141, 110, 66, 0.18);
}

.model-training-event-stage {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(156, 113, 49, 0.14);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7d5924;
}

.model-training-event-body {
  min-width: 0;
}

.model-training-event-body strong {
  display: block;
  color: #251a10;
  font-size: 13px;
}

.model-training-event-body small {
  display: block;
  margin-top: 3px;
  color: #6d5538;
  font-size: 11px;
}

.model-detail-hero {
  margin-bottom: 12px;
}

.model-detail-title {
  font-family: "Orbitron", sans-serif;
  color: #23180f;
}

.model-detail-subtitle {
  margin-top: 4px;
  font-size: 12px;
  color: #6a5237;
}

.model-detail-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.model-detail-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(151, 116, 66, 0.12);
  border: 1px solid rgba(138, 99, 45, 0.2);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #6a4f2a;
}

.model-detail-badge.is-live {
  background: rgba(50, 120, 50, 0.12);
  border-color: rgba(45, 106, 45, 0.28);
  color: #2a6b2a;
}

.model-version-score {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  font-size: 12px;
  font-weight: 800;
  color: #7b5824;
  line-height: 1.5;
}

@media (max-aspect-ratio: 16/10) {
  .desk-backdrop {
    background-image: var(--asset-bg-16x10);
  }
}

@media (min-aspect-ratio: 21/9) {
  .layout {
    grid-template-columns: minmax(0, 2.08fr) minmax(360px, 1fr);
  }

  .zone {
    min-height: min(86vh, 920px);
  }

  .main-catalog-grid {
    max-height: 52vh;
  }
}

@media (min-aspect-ratio: 26/9) {
  .layout {
    grid-template-columns: minmax(0, 2.2fr) minmax(400px, 1fr);
  }

  .main-catalog-grid {
    max-height: 56vh;
  }

  .main-deck-shelf {
    max-height: 40vh;
  }
}

@media (max-aspect-ratio: 4/3) and (min-width: 981px) {
  .layout {
    grid-template-columns: minmax(0, 1.58fr) minmax(0, 1fr);
  }

  .zone {
    min-height: min(68vh, 800px);
  }

  .main-catalog-grid {
    max-height: 40vh;
  }

  .main-deck-shelf {
    max-height: 30vh;
  }
}

@media (max-aspect-ratio: 1/1) {
  .topbar {
    padding: 8px 12px;
  }

  .layout {
    gap: 10px;
  }

  .tile-grid {
    max-height: 42vh;
  }

  .main-catalog-grid {
    max-height: 38vh;
  }

  .main-deck-shelf {
    --tile-gap: 14px;
    --shelf-lip-h: 34px;
    max-height: 30vh;
  }

  .main-card-dialog {
    width: min(94vw, 760px);
  }

  .main-card-dialog-body {
    grid-template-columns: 1fr;
  }

  .main-card-dialog-art-wrap {
    width: min(340px, 100%);
    justify-self: center;
  }

  .replacement-dialog {
    width: min(96vw, 900px);
  }

  .meta-detail-dialog {
    width: min(96vw, 900px);
  }

  .meta-detail-grid {
    grid-template-columns: 1fr;
  }

  .replacement-body {
    grid-template-columns: 1fr;
  }

  .replacement-alcove {
    min-height: 440px;
  }

  .deck-worktable.is-focus-main-deck .main-deck-shelf {
    --main-shelf-min: 132px;
    --main-card-min-height: 250px;
    --main-deck-card-height: 250px;
    --tile-gap: 14px;
    --shelf-lip-h: 34px;
    max-height: 54vh;
  }

  .deck-worktable.is-focus-library .main-catalog-grid {
    max-height: 56vh;
  }

  .deck-worktable.is-focus-sideboard #sideboard-list {
    max-height: 56vh;
  }

  .deck-worktable.is-focus-battlefields .battlefield-slots {
    max-height: 48vh;
  }
}

@media (max-width: 1300px) {
  .layout {
    grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr);
  }

  .tile-grid {
    max-height: 46vh;
  }

  .worktable-top {
    grid-template-columns: 1fr 1fr;
  }

  .rune-block {
    grid-column: span 2;
  }

  .main-catalog-grid {
    max-height: 42vh;
  }

  .main-deck-shelf {
    max-height: 30vh;
  }

  .auto-builder-layout {
    grid-template-columns: 1fr;
  }

  .model-observation-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "canvas"
      "sidebar"
      "controls";
  }

  .model-observation-layout .model-observation-sidebar,
  .model-observation-layout .model-observation-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .model-observation-grid,
  .model-train-grid,
  .model-graph-main,
  .model-graph-inspector-card {
    grid-template-columns: 1fr;
  }

  .model-graph-stage {
    min-height: clamp(380px, 55vh, 620px);
  }

  .model-graph-inspector-card > .model-graph-inspector-hero,
  .model-graph-inspector-card > .model-graph-stat-grid,
  .model-graph-inspector-card > .model-graph-inspector-section {
    grid-column: 1;
  }

  body.workspace-auto-builder-active .layout {
    grid-template-columns: 1fr;
  }

  .auto-builder-results {
    max-height: 42vh;
  }
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  /* Sidebar: icon-only, narrowed */
  .sidebar-nav {
    width: 52px;
    padding: 8px 4px;
  }

  .sidebar-nav-btn {
    padding: 9px 4px;
  }

  .sidebar-label {
    display: none;
  }

  .model-status-grid {
    grid-template-columns: 1fr;
  }

  .model-graph-toolbar,
  .model-graph-tools {
    align-items: stretch;
  }

  .model-graph-search,
  .model-graph-search input {
    min-width: 0;
    width: 100%;
  }

  .model-graph-inspector-hero,
  .model-graph-card-strip,
  .model-graph-stat-grid,
  .model-graph-inspector-card {
    grid-template-columns: 1fr;
  }

  .model-graph-stage {
    min-height: 460px;
    padding: 12px;
  }

  .topbar-brand {
    flex: 1 1 100%;
    min-width: 0;
  }

  .status-wrap {
    order: 2;
  }

  .zone {
    min-height: 0;
  }

  .grid.two {
    grid-template-columns: 1fr;
  }

  .row.stackable {
    flex-direction: column;
    align-items: stretch;
  }

  .row.inputs-inline {
    flex-wrap: wrap;
  }

  #meta-sort-by {
    flex: 1 1 100%;
    min-width: 0;
  }

  .card-preview {
    width: 240px;
  }

  .worktable-top {
    grid-template-columns: 1fr;
  }

  .worktable-name-row {
    grid-template-columns: 1fr;
  }

  .deck-primary-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .auto-builder-controls {
    grid-template-columns: 1fr;
  }

  .auto-builder-summary-grid {
    grid-template-columns: 1fr;
  }

  .auto-builder-detail-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .auto-builder-detail-row small {
    text-align: left;
  }

  .auto-builder-card {
    grid-template-columns: 80px minmax(0, 1fr);
  }

  .auto-builder-card-meta {
    grid-template-columns: 1fr;
  }

  .rune-block {
    grid-column: span 1;
  }

  .rune-stepper-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main-row-head {
    flex-direction: column;
    align-items: stretch;
  }

  .main-row-head .row {
    min-width: 0;
  }

  .main-shelf-grid:not(.main-deck-shelf) {
    --shelf-row: 236px;
    --main-shelf-min: 116px;
    --main-card-min-height: 220px;
  }

  .main-catalog-grid {
    max-height: 44vh;
  }

  .main-deck-shelf {
    max-height: 36vh;
    --main-shelf-min: 132px;
    --main-card-min-height: 250px;
    --main-deck-card-height: 250px;
    --tile-gap: 12px;
    --shelf-lip-h: 32px;
  }

  .battlefield-slots {
    grid-template-columns: 1fr;
  }

  .section-expandable.is-minimized {
    display: none;
  }

  .deck-worktable.is-focus-battlefields .battlefield-slots,
  .deck-worktable.is-focus-library .main-catalog-grid,
  .deck-worktable.is-focus-main-deck .main-deck-shelf,
  .deck-worktable.is-focus-sideboard #sideboard-list {
    max-height: 50vh;
  }

  .deck-worktable.is-focus-library .main-catalog-grid {
    --main-shelf-min: 148px;
    --main-card-min-height: 238px;
    --tile-gap: 10px;
    padding: 10px;
  }

  .deck-worktable.is-focus-main-deck .main-deck-shelf {
    --main-shelf-min: 158px;
    --main-card-min-height: 286px;
    --main-deck-card-height: 286px;
    --tile-gap: 12px;
    --shelf-lip-h: 34px;
    padding: 10px;
  }

  .deck-worktable.is-focus-sideboard #sideboard-list {
    --main-shelf-min: 148px;
    --main-card-min-height: 238px;
    --tile-gap: 10px;
    padding: 10px;
  }

  .main-card-dialog {
    width: min(96vw, 680px);
    padding: 10px;
  }

  .main-card-dialog-head h3 {
    font-size: 16px;
  }

  .picker-modal {
    padding: 10px;
  }

  .replacement-dialog {
    width: min(97vw, 760px);
    padding: 10px;
  }

  .meta-detail-dialog {
    width: min(97vw, 760px);
    padding: 10px;
  }

  .replacement-head h3 {
    font-size: 15px;
  }

  .replacement-alcove {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
    min-height: 560px;
  }

  .replacement-alcove::before {
    top: calc(33.333% - 7px);
  }

  .replacement-alcove::after {
    top: calc(66.666% - 7px);
    bottom: auto;
  }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE: Phone  (≤ 640 px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  /* ── Performance: drop expensive compositing layers on phones ── */
  .desk-dust,
  .desk-vignette {
    display: none;
  }

  /* Hover card preview is meaningless on touch – hide it */
  .card-preview {
    display: none !important;
  }

  /* ── Spacing ──────────────────────────────────────────────── */
  .topbar {
    padding: 8px 10px;
    gap: 8px;
  }

  /* ── Typography ───────────────────────────────────────────── */
  h1 {
    font-size: clamp(18px, 5.5vw, 26px);
  }

  h2 {
    font-size: 14px;
  }

  /* ── Sidebar → fixed bottom navigation bar on phones ─────── */
  .sidebar-nav {
    width: 100%;
    height: 56px;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    padding: 0 4px;
    gap: 0;
    border-right: none;
    border-top: 1px solid rgba(100, 78, 44, 0.4);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 60;
    background: rgba(20, 14, 8, 0.94);
    backdrop-filter: blur(14px);
  }

  .app-body {
    padding-bottom: 56px;
  }

  .sidebar-spacer {
    display: none;
  }

  /* ── Account shell: compact ───────────────────────────────── */
  .account-copy {
    display: none; /* hide email/name on phone — just show buttons */
  }

  /* ── Discover tab strip ───────────────────────────────────── */
  .discover-tab-strip {
    width: 100%;
  }

  .discover-tab-btn {
    flex: 1;
    min-width: 0;
    text-align: center;
  }

  /* ── Toolbar inputs: remove hard widths so rows wrap cleanly ─ */
  .collection-toolbar #collection-import-mode {
    flex: 1 1 auto;
    min-width: 0;
  }

  .collection-toolbar #collection-search-input {
    flex: 1 1 100%;
    min-width: 0;
  }

  /* ── Deck meta fields: allow full shrink ─────────────────── */
  .deck-meta-field {
    min-width: 0;
  }

  /* ── Row action buttons: wrap on tight rows ──────────────── */
  .worktable-row-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  /* ── Tile grid heights: shorter on phones ─────────────────── */
  .tile-grid {
    max-height: 38vh;
  }

  .main-deck-shelf {
    max-height: 30vh;
  }

  .library-pane .tile-grid.compact {
    max-height: 30vh;
  }

  /* ── Modals: full-width padding and body layout ───────────── */
  .picker-modal {
    padding: 6px;
  }

  .confirm-dialog {
    padding: 16px 18px;
    width: 100%;
  }

  .main-card-dialog {
    width: 100%;
    max-height: 88vh;
  }

  .main-card-dialog-body {
    grid-template-columns: 1fr;
  }

  .main-card-dialog-art-wrap {
    max-width: 180px;
    justify-self: center;
  }

  .replacement-dialog {
    width: 100%;
    padding: 8px;
  }

  .replacement-body {
    grid-template-columns: 1fr;
  }

  .replacement-alcove {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    min-height: 320px;
  }

  .replacement-alcove::before {
    display: none;
  }

  .replacement-alcove::after {
    display: none;
  }

  .meta-detail-dialog {
    width: 100%;
    padding: 8px;
  }

  .deck-import-dialog {
    padding: 10px;
  }

  /* ── Model observation ────────────────────────────────────── */
  .model-observation-layout .model-observation-sidebar,
  .model-observation-layout .model-observation-controls {
    grid-template-columns: 1fr;
  }

  .model-graph-stage {
    min-height: 280px;
    padding: 8px;
  }
}
