:root {
  --bg: #e6e7e9;
  --panel: rgba(35, 29, 20, .88);
  --panel-2: rgba(20, 17, 13, .92);
  --line: rgba(184, 143, 78, .46);
  --line-soft: rgba(224, 196, 126, .18);
  --text: #f8ecd2;
  --muted: #c7ad82;
  --accent: #e3b766;
  --accent-2: #fff0bd;
  --pm-shadow: rgba(0, 0, 0, .48);
  --pm-glow: rgba(226, 173, 87, .28);
}

html, body {
  min-height: 100%;
  background: #e6e7e9;
  color: var(--text);
}

body::before {
  display: none;
}

.library-shell {
  position: relative;
  padding: 22px;
  background: url("./layout_deck_center.png") center top / 100% auto repeat-y;
}

.topbar {
  margin: -22px -22px 22px;
  padding: 18px 22px 16px;
  border-bottom: 1px solid rgba(224, 184, 103, .38);
  background:
    linear-gradient(180deg, rgba(24, 19, 13, .94), rgba(13, 12, 9, .9)),
    url("./panel-grain.png") center / 256px 256px repeat;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .38), inset 0 -1px 0 rgba(255, 232, 166, .12);
}

h1 {
  color: #fff4d4;
  font-size: 25px;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .58), 0 0 18px rgba(234, 178, 86, .26);
}

.meta {
  color: #cdbb91;
}

.toolbar {
  padding: 10px;
  border: 1px solid rgba(194, 151, 82, .32);
  border-radius: 8px;
  background: rgba(14, 12, 9, .68);
  box-shadow: inset 0 1px 0 rgba(255, 239, 190, .08);
}

.control,
.button,
.mini-button {
  border-color: rgba(194, 151, 82, .42);
  background:
    linear-gradient(180deg, rgba(47, 39, 27, .96), rgba(19, 16, 12, .96)),
    url("./panel-grain.png") center / 256px 256px repeat;
  color: #f7e8c5;
  box-shadow: inset 0 1px 0 rgba(255, 244, 204, .12), 0 1px 0 rgba(0, 0, 0, .44);
}

.control:focus {
  border-color: rgba(245, 203, 114, .82);
  box-shadow: 0 0 0 2px rgba(226, 173, 87, .18), inset 0 1px 0 rgba(255, 244, 204, .12);
}

.button:hover,
.button.active,
.mini-button:hover {
  border-color: rgba(249, 211, 126, .8);
  color: #fff5cf;
  background: linear-gradient(180deg, rgba(80, 60, 31, .96), rgba(32, 24, 14, .96));
  box-shadow: 0 0 18px rgba(219, 163, 77, .16), inset 0 1px 0 rgba(255, 244, 204, .16);
}

.grid {
  gap: 18px;
}

.card {
  position: relative;
  padding: 12px;
  border-color: rgba(190, 148, 78, .34);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(41, 35, 25, .9), rgba(17, 16, 12, .94)),
    url("./panel-grain.png") center / 256px 256px repeat;
  box-shadow: 0 14px 32px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 234, 174, .08);
}

.card::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(255, 220, 142, .08);
  border-radius: 7px;
  pointer-events: none;
}

.card:hover {
  transform: translateY(-3px);
  border-color: rgba(239, 195, 103, .78);
  box-shadow: 0 22px 54px rgba(0, 0, 0, .44), 0 0 28px rgba(211, 151, 69, .2), inset 0 1px 0 rgba(255, 234, 174, .12);
}

.thumb {
  border-radius: 8px;
  border-color: rgba(235, 199, 121, .32);
  background: #080806;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .72), 0 8px 20px rgba(0, 0, 0, .35);
}

.name {
  color: #fff1c4;
  font-size: 16px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .65);
}

.line {
  color: #d8c49a;
}

.tagline {
  color: #e3d2aa;
}

.deck-count-pill {
  color: #fff2c3;
  background: linear-gradient(180deg, rgba(106, 83, 40, .9), rgba(44, 34, 21, .9));
  box-shadow: inset 0 1px 0 rgba(255, 239, 187, .18);
}

.deck-panel {
  border-color: rgba(190, 148, 78, .42);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(40, 33, 23, .96), rgba(18, 16, 12, .96)),
    url("./panel-grain.png") center / 256px 256px repeat;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .42), inset 0 1px 0 rgba(255, 234, 174, .1);
}

.deck-row {
  border-color: rgba(190, 148, 78, .28);
  background: rgba(12, 11, 8, .68);
}

.empty-state,
.deck-empty {
  border-color: rgba(190, 148, 78, .34);
  background: rgba(14, 12, 9, .42);
}

/* 图鉴页面参考传统卡牌库布局：横幅、红金筛选栏、浅色卡牌墙。 */
:root {
  --pm-page: #e6e7e9;
  --pm-page-light: #f5e5ba;
  --pm-page-line: rgba(128, 86, 42, .34);
  --pm-red: #711511;
  --pm-red-dark: #330908;
  --pm-red-line: #c58c3d;
  --pm-gold: #f5d66f;
  --pm-gold-dark: #7d4e18;
  --pm-brown: #4a2715;
  --pm-ink: #49311c;
}

html,
body {
  background: var(--pm-page);
  color: var(--pm-ink);
}

body::before {
  display: none;
}

.library-shell {
  min-height: 100vh;
  padding: 0;
  background: url("./layout_deck_center.png") center top / 100% auto repeat-y;
}

.topbar {
  position: static;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
}

.library-hero {
  position: relative;
  min-height: 292px;
  overflow: hidden;
  display: block;
  background:
    linear-gradient(90deg, rgba(8, 31, 63, .78), rgba(25, 107, 163, .64), rgba(8, 31, 63, .78)),
    url("./library-bg.webp") center 42% / cover no-repeat;
  box-shadow: inset 0 -18px 42px rgba(0, 0, 0, .48);
}

.library-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 38%, rgba(126, 210, 255, .35), transparent 24%),
    radial-gradient(circle at 34% 20%, rgba(255, 223, 112, .18), transparent 18%),
    linear-gradient(180deg, rgba(255, 255, 255, .08), transparent 48%, rgba(0, 0, 0, .52));
  pointer-events: none;
  z-index: 1;
}

.hero-background-carousel {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: url("./library-bg.webp") center 42% / cover no-repeat;
}

.hero-background-slide {
  position: absolute;
  inset: 0;
  background-position: center 42%;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity .72s ease;
  will-change: opacity;
}

.hero-background-slide.active {
  opacity: 1;
}

.hero-emblem {
  display: none;
  place-items: center;
  width: 86px;
  height: 100px;
  border-radius: 20px 20px 28px 28px;
  border: 3px solid rgba(255, 235, 150, .86);
  background: linear-gradient(180deg, #f5d878, #986224);
  color: #57310d;
  font-size: 30px;
  font-weight: 1000;
  box-shadow: 0 12px 24px rgba(0, 0, 0, .3), inset 0 0 0 5px rgba(255, 255, 255, .16);
}

.hero-button {
  display: none;
  min-width: 112px;
  height: 36px;
  border: 2px solid rgba(255, 220, 126, .72);
  border-radius: 8px;
  background: linear-gradient(180deg, #ad37ef, #651a9a);
  color: #fff7df;
  font-weight: 900;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 8px 18px rgba(0, 0, 0, .26);
}

.hero-auth {
  position: absolute;
  top: 12px;
  right: 24px;
  z-index: 4;
}

.hero-purchase {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 4;
  min-width: 132px;
  height: 42px;
  padding: 0 26px;
  border: 2px solid rgba(255, 226, 146, .8);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff6dc;
  text-decoration: none;
  font-size: 17px;
  font-weight: 900;
  background: linear-gradient(180deg, rgba(205, 97, 44, .96), rgba(122, 26, 10, .96));
  box-shadow: 0 12px 30px rgba(0, 0, 0, .34), inset 0 1px 0 rgba(255, 255, 255, .28);
  transform: translateX(-50%);
}

.hero-purchase:hover {
  border-color: rgba(255, 239, 175, .96);
  color: #ffffff;
  background: linear-gradient(180deg, rgba(220, 116, 55, .98), rgba(142, 36, 14, .98));
}

.hero-purchase[hidden] {
  display: none;
}

.filter-band {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 22px 24px;
  border-top: 4px solid #d39b46;
  border-bottom: 4px solid #5c1a0c;
  background:
    linear-gradient(180deg, rgba(148, 28, 24, .98), rgba(88, 14, 12, .98)),
    url("./panel-grain.png") center / 256px 256px repeat;
  box-shadow: 0 8px 18px rgba(55, 25, 10, .35);
}

.toolbar {
  display: grid;
  grid-template-columns: 144px 144px 144px 508px minmax(0, 1fr) 72px 72px;
  max-width: 1444px;
  margin: 0 auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  gap: 12px;
  align-items: center;
}

.control,
.button,
.mini-button {
  border: 2px solid rgba(95, 50, 21, .72);
  color: #4c2a10;
  background:
    linear-gradient(180deg, #f4e68a, #c7a15e),
    url("./ui-input.png") center / 100% 100% no-repeat;
  box-shadow: inset 0 1px 0 rgba(255, 252, 215, .66), 0 2px 0 rgba(58, 22, 7, .42);
}

.control {
  height: 42px;
  border-radius: 12px;
  padding: 0 14px;
  font-weight: 700;
}

.control:focus {
  border-color: rgba(255, 226, 109, .95);
  box-shadow: 0 0 0 3px rgba(249, 213, 100, .26), inset 0 1px 0 rgba(255, 252, 215, .66);
}

.button {
  height: 42px;
  border-radius: 14px;
  padding: 0 20px;
  color: #fff5d1;
  font-weight: 900;
  background: linear-gradient(180deg, #b65b36, #78200f);
}

.button:hover,
.button.active,
.mini-button:hover {
  border-color: rgba(255, 226, 109, .95);
  color: #fff8de;
  background: linear-gradient(180deg, #c9693f, #8e2912);
}

.control-set,
.control-theme,
.control-type,
.control-color,
.control-level {
  width: 100%;
}

.search-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.search-box .search {
  width: 100%;
  color: #f7e5be;
  background: linear-gradient(180deg, #4d0f0c, #2b0807);
  border-color: rgba(219, 160, 62, .75);
}

.search-box .search::placeholder {
  color: rgba(242, 210, 159, .66);
}

.button-search {
  min-width: 72px;
  background: linear-gradient(180deg, #a83ced, #631796);
}

.button-filter,
.button-deck {
  min-width: 72px;
  color: #53300f;
  background: linear-gradient(180deg, #f2df9c, #c79b54);
}

.button-clear-filter {
  justify-self: center;
  width: 74%;
  min-width: 86px;
  padding: 0 10px;
  color: #fff0d4;
  background: linear-gradient(180deg, #c64a35, #7c1712);
  border-color: rgba(255, 200, 132, .72);
}

.button-clear-filter:hover {
  color: #fff7df;
  background: linear-gradient(180deg, #d85c43, #931e16);
}

.advanced-filters {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
  max-width: 1444px;
  margin: 14px auto 0;
}

.advanced-filters[hidden] {
  display: none;
}

.main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  padding: 0;
  background: transparent;
}

.main.deck-open {
  grid-template-columns: minmax(0, 1fr) 390px;
}

.content {
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
  padding: 54px 28px 84px;
}

.collection-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 24px;
  min-height: 56px;
  margin-bottom: 42px;
  color: rgba(83, 54, 26, .82);
  font-weight: 700;
}

.result-summary {
  display: none;
}

.content-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.sort-control {
  width: 190px;
}

.collection-divider {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: 28px;
  place-items: center;
  margin: 0 0 52px;
  color: #6b4822;
  font-size: 24px;
  font-weight: 900;
}

.collection-divider::before,
.collection-divider::after {
  content: "";
  width: 100%;
  max-width: 620px;
  height: 32px;
  background: url("./ui-decorator.png") center / contain no-repeat;
  opacity: .54;
}

.collection-divider::before {
  justify-self: center;
}

.collection-divider::after {
  justify-self: center;
  transform: scaleX(-1);
}

.collection-divider span {
  min-width: 150px;
  padding: 0 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: center;
  box-shadow: none;
}

.grid {
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 54px 52px;
}

.card {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transition: transform .16s ease, filter .16s ease;
}

.card::before {
  display: none;
}

.card:hover {
  transform: translateY(-9px) scale(1.035);
  filter: drop-shadow(0 20px 18px rgba(83, 45, 15, .24));
  border-color: transparent;
  box-shadow: none;
}

.thumb {
  border: 0;
  border-radius: 5.4% / 3.9%;
  background: transparent;
  box-shadow: 0 14px 20px rgba(70, 40, 14, .34);
}

.thumb img {
  object-fit: contain;
}

.thumb.empty {
  border: 2px dashed rgba(120, 76, 35, .3);
  background: rgba(112, 72, 28, .08);
  color: #7d5b31;
}

.name {
  margin: 14px 0 6px;
  color: #4d2e15;
  font-size: 17px;
  text-shadow: none;
}

.line {
  color: rgba(78, 51, 24, .76);
  font-size: 13px;
}

.tagline {
  color: rgba(78, 51, 24, .64);
}

.card-actions {
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity .14s ease, transform .14s ease;
}

.card:hover .card-actions {
  opacity: 1;
  transform: none;
}

.grid .name,
.grid .line,
.grid .card-actions {
  display: none;
}

.mini-button {
  color: #543011;
  background: linear-gradient(180deg, #f2df9c, #c79b54);
}

.deck-count-pill {
  color: #fff8dc;
  background: linear-gradient(180deg, #6b1711, #3b0907);
}

.deck-panel {
  top: 104px;
  margin: 34px 24px 34px 0;
  color: #f9ebc8;
  background:
    linear-gradient(180deg, rgba(76, 28, 17, .98), rgba(31, 13, 8, .98)),
    url("./panel-grain.png") center / 256px 256px repeat;
  border-color: rgba(222, 173, 82, .58);
}

.deck-row {
  background: rgba(20, 10, 6, .54);
}

.empty-state,
.deck-empty {
  color: rgba(86, 56, 26, .76);
  border-color: rgba(120, 76, 35, .34);
  background: rgba(255, 244, 210, .32);
}

@media (max-width: 1180px) {
  .library-hero {
    min-height: 240px;
  }

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

  .search-box {
    grid-column: 1 / -1;
  }

  .main.deck-open {
    grid-template-columns: minmax(0, 1fr);
  }

  .deck-panel {
    position: sticky;
    top: 8px;
    z-index: 12;
    align-self: start;
    max-height: calc(100dvh - 16px);
    margin: 18px 18px 0;
    order: -1;
  }
}

@media (max-width: 720px) {
  .library-hero {
    min-height: 188px;
    padding: 18px 12px;
  }

  .hero-emblem {
    width: 54px;
    height: 64px;
    border-radius: 14px 14px 18px 18px;
    font-size: 19px;
  }

  .hero-button {
    min-width: 96px;
    height: 34px;
  }

  .hero-auth {
    top: 8px;
    right: 10px;
  }

  .hero-purchase {
    bottom: 12px;
    min-width: 108px;
    height: 36px;
    padding: 0 20px;
    border-radius: 12px;
    font-size: 15px;
  }

  .filter-band {
    padding: 10px;
  }

  .toolbar {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
  }

  .control-theme,
  .control-set,
  .control-type {
    grid-column: span 2;
  }

  .control,
  .button {
    height: 38px;
    min-width: 0;
    padding: 0 10px;
    border-radius: 11px;
    font-size: 16px;
  }

  .search-box {
    grid-column: 1 / -1;
  }

  .search-box {
    grid-column: span 4;
    grid-template-columns: minmax(0, 1fr) 64px;
    gap: 8px;
  }

  .button-filter,
  .button-deck {
    grid-column: span 1;
    width: 100%;
    padding: 0 6px;
  }

  .advanced-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .content {
    padding: 28px 12px 56px;
  }

  .collection-status {
    align-items: center;
    flex-direction: row;
    justify-content: flex-end;
    gap: 12px;
    margin-bottom: 28px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
    gap: 34px 18px;
  }

  .deck-panel {
    height: 50dvh;
    max-height: 50dvh;
    margin: 8px 12px 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
  }

}

/* 紧凑信息栏与单行筛选工具栏。 */
.library-hero {
  min-height: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-bottom: 1px solid rgba(211, 155, 70, .46);
  background: linear-gradient(180deg, rgba(28, 25, 20, .98), rgba(15, 14, 12, .98));
  box-shadow: inset 0 -1px 0 rgba(255, 232, 166, .08);
}

.hero-background-carousel,
.hero-purchase {
  display: none !important;
}

.hero-auth {
  position: static;
  display: flex;
  align-items: center;
  justify-content: center;
}

.filter-band {
  position: relative;
  top: auto;
  padding: 10px 0;
}

/* 双端 iframe 的构筑模式禁用批量合成层，避免悬浮后卡图丢帧。 */
.card {
  transition: none;
}

.card:hover {
  transform: none;
  filter: none;
}

.card:hover .thumb,
.card:focus-within .thumb {
  box-shadow:
    0 0 0 4px rgba(67, 235, 116, .94),
    0 0 24px 9px rgba(55, 224, 108, .72),
    0 14px 20px rgba(70, 40, 14, .34);
}

/* 每张卡牌快照统一叠加顶部高光。 */
.thumb-wrap,
.version-card-link {
  position: relative;
  isolation: isolate;
}

.thumb-wrap::after,
.version-card-link::after {
  content: "";
  position: absolute;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  pointer-events: none;
}

.thumb-wrap::after,
.version-card-link::after {
  inset: 0;
  z-index: 2;
  background-image: url("./cardlight.png");
  transform: translate(0, 1px);
}

.thumb-link,
.version-card-link .thumb {
  position: relative;
  z-index: 1;
}

.variant-toggle {
  z-index: 3;
}

.card-add-button,
.variant-toggle {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: 0 28px;
  box-sizing: border-box;
}

.button-home {
  display: inline-flex;
  flex: 0 0 42px;
  width: 42px;
  min-width: 42px;
  height: 42px;
  padding: 0;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.button-home svg {
  flex: 0 0 22px;
  width: 22px;
  min-width: 22px;
  height: 22px;
  stroke-width: 2.8;
}

.control-theme,
.control-type,
.control-color,
.control-level {
  flex: 0 1 124px;
  min-width: 92px;
  padding-inline: 8px;
  -webkit-appearance: none;
  appearance: none;
  text-align: center;
  text-align-last: center;
}

.control-theme option,
.control-type option,
.control-color option,
.control-level option {
  text-align: center;
}

.search-box {
  flex: 0 1 320px;
  width: min(320px, 26vw);
  min-width: 220px;
  margin-left: auto;
}

.button-search {
  min-width: 88px;
  padding-inline: 18px;
}

.button-reset,
.button-deck {
  flex: 0 0 auto;
  min-width: 92px;
  padding-inline: 18px;
}

.button-more {
  display: none;
  flex: 0 0 auto;
}

.button-more svg {
  flex: 0 0 18px;
  width: 18px;
  min-width: 18px;
  height: 18px;
  transition: transform .16s ease;
}

.button-more[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.mobile-select-mask {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, .58);
}

.mobile-select-mask.show {
  display: flex;
}

.deck-preset-mask {
  align-items: center;
}

.mobile-select-sheet {
  display: flex;
  flex-direction: column;
  width: min(420px, 100%);
  max-height: min(72dvh, 640px);
  overflow: hidden;
  border: 2px solid rgba(219, 160, 62, .78);
  border-radius: 16px;
  background: linear-gradient(180deg, #651611, #2c0a08);
  box-shadow: 0 22px 70px rgba(0, 0, 0, .58);
}

.mobile-select-head {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(219, 160, 62, .38);
  color: #fff2c3;
  font-weight: 900;
}

.mobile-select-close {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
}

.mobile-select-options {
  display: grid;
  gap: 8px;
  min-height: 0;
  padding: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.mobile-select-option {
  flex: 0 0 auto;
  width: 100%;
  min-height: 44px;
  border: 2px solid rgba(95, 50, 21, .72);
  border-radius: 12px;
  color: #4c2a10;
  background: linear-gradient(180deg, #f4e68a, #c7a15e);
  box-shadow: inset 0 1px 0 rgba(255, 252, 215, .66), 0 2px 0 rgba(58, 22, 7, .42);
  font-weight: 900;
  cursor: pointer;
}

.mobile-select-option.active {
  border-color: #fff0a7;
  color: #fff8de;
  background: linear-gradient(180deg, #c9693f, #8e2912);
}

.advanced-filters {
  display: none !important;
}

@media (max-width: 720px) {
  .library-hero {
    min-height: 38px;
    height: 38px;
    padding: 0 8px;
  }

  .filter-band {
    padding: 8px 0;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 36px repeat(4, minmax(0, 1fr)) 36px;
    gap: 4px;
    padding-inline: 8px;
  }

  .button-home {
    grid-column: span 1;
    width: 100%;
    min-width: 0;
    height: 38px;
    color: #67320f;
  }

  .button-home svg {
    flex-basis: 24px;
    width: 24px;
    min-width: 24px;
    height: 24px;
  }

  .control-theme,
  .control-type,
  .control-color,
  .control-level {
    display: block;
    grid-column: span 1;
    width: 100%;
    min-width: 0;
    padding-inline: 3px;
    font-size: 13px;
  }

  .search-box,
  .button-reset,
  #toggleDeck {
    display: none;
  }

  .button-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    grid-column: span 1;
    width: 100%;
    min-width: 0;
    height: 38px;
    padding: 0;
    color: #67320f;
    line-height: 1;
  }

  body.toolbar-expanded .toolbar {
    display: grid;
    grid-template-columns: repeat(14, minmax(0, 1fr));
  }

  body.toolbar-expanded .button-home {
    width: 100%;
    min-width: 0;
    grid-column: span 2;
  }

  body.toolbar-expanded .control-theme,
  body.toolbar-expanded .control-type,
  body.toolbar-expanded .control-color,
  body.toolbar-expanded .control-level {
    grid-column: span 3;
  }

  body.toolbar-expanded .search-box {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) 72px;
    width: auto;
    min-width: 0;
    margin-left: 0;
  }

  body.toolbar-expanded .search-box .search {
    width: 100%;
    min-width: 0;
  }

  body.toolbar-expanded .button-search {
    width: 72px;
    min-width: 0;
    padding-inline: 8px;
  }

  body.toolbar-expanded .button-reset,
  body.toolbar-expanded #toggleDeck {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    grid-column: span 6;
  }

  body.toolbar-expanded .button-more {
    width: 100%;
    min-width: 0;
    grid-column: span 2;
  }
}

/* 隐藏滚动条外观，保留滚轮、触控滑动和程序化滚动。 */
* {
  scrollbar-width: none;
  scrollbar-gutter: auto;
  -ms-overflow-style: none;
}

*::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* 固定顶部控件条与右侧构筑栏，构筑时仅压缩卡牌墙。 */
:root {
  --library-topbar-height: 58px;
  --library-deck-width: clamp(375px, 27.5vw, 450px);
}

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
}

.library-shell {
  padding-top: var(--library-topbar-height);
}

.main.deck-open {
  display: block;
  padding-right: var(--library-deck-width);
}

.deck-open .grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.deck-open .card-add-button {
  display: none !important;
}

.deck-open .card {
  cursor: grab;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.deck-open .card:active {
  cursor: grabbing;
}

.deck-open .thumb-link {
  pointer-events: none;
}

.deck-open .card img,
.deck-row[draggable="true"] * {
  -webkit-user-drag: none;
}

.deck-row[draggable="true"] {
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.deck-touch-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 160;
  max-width: min(240px, 62vw);
  min-height: 38px;
  padding: 9px 13px;
  border: 2px solid rgba(255, 226, 109, .92);
  border-radius: 9px;
  background: rgba(66, 27, 13, .94);
  color: #fff4cf;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .48);
  transform: translate(-50%, calc(-100% - 14px));
}

.deck-open .deck-panel {
  position: fixed;
  right: 0;
  top: var(--library-topbar-height);
  bottom: 0;
  z-index: 45;
  display: flex;
  flex-direction: column;
  width: var(--library-deck-width);
  height: auto;
  max-height: none;
  margin: 0;
  overflow: hidden;
  border-radius: 10px 0 0 0;
}

.deck-primary-library,
.deck-environment-library {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}

.deck-primary-library {
  flex: 1 1 auto;
  padding: 6px;
  border: 1px dashed transparent;
  border-radius: 7px;
}

.deck-primary-library > .deck-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 84px;
  box-sizing: border-box;
  padding: 12px 8px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.deck-environment-library {
  display: flex;
  flex: 0 0 25dvh;
  flex-direction: column;
  min-height: 120px;
  margin-top: 10px;
  padding: 8px 6px 6px;
  border-top: 1px solid rgba(222, 173, 82, .42);
  border-right: 1px dashed transparent;
  border-bottom: 1px dashed transparent;
  border-left: 1px dashed transparent;
  border-radius: 7px;
  overflow: hidden;
}

.deck-environment-library .deck-list {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
  grid-auto-rows: 38px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.deck-environment-library .deck-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 8px 6px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.deck-drop-zone.drag-over {
  border-color: rgba(255, 226, 109, .86);
  background: rgba(153, 82, 24, .18);
  box-shadow: inset 0 0 0 2px rgba(255, 226, 109, .13);
}

.deck-section + .deck-section {
  margin-top: 9px;
}

.deck-section-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 5px;
  color: #f5d888;
  font-size: 12px;
  font-weight: 900;
}

.deck-section-rows {
  display: grid;
  gap: 6px;
}

.deck-row {
  grid-template-columns: 26px minmax(0, 1fr) 38px;
  height: 38px;
  min-height: 38px;
}

.deck-row-level {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(244, 216, 136, .7);
  border-radius: 999px;
  color: #fff1bd;
  background: rgba(52, 21, 11, .82);
  font-size: 11px;
  font-weight: 900;
}

.deck-row[draggable="true"] {
  cursor: grab;
}

.deck-row[draggable="true"]:active {
  cursor: grabbing;
}

.deck-row-name {
  min-width: 0;
}

.deck-row-controls {
  grid-template-columns: 34px;
}

.deck-row-controls span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 26px;
  border: 1px solid rgba(244, 216, 136, .58);
  border-radius: 5px;
  background: rgba(52, 21, 11, .82);
}

.deck-row-controls button:disabled,
.card-add-button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.deck-section-empty {
  padding: 7px 8px;
  color: rgba(249, 235, 200, .5);
  font-size: 11px;
  text-align: center;
  border: 1px dashed rgba(222, 173, 82, .22);
  border-radius: 6px;
}

.deck-row-automatic .deck-row-controls {
  grid-template-columns: 34px;
}

.deck-drag-hint {
  position: fixed;
  left: calc((100vw - var(--library-deck-width)) / 2);
  bottom: 14px;
  z-index: 44;
  display: none;
  max-width: min(640px, calc(100vw - var(--library-deck-width) - 32px));
  padding: 10px 18px;
  border: 1px solid rgba(255, 226, 109, .9);
  border-radius: 999px;
  color: #fff3c2;
  background: rgba(92, 28, 13, .94);
  box-shadow: 0 0 0 0 rgba(255, 210, 93, .5), 0 8px 24px rgba(0, 0, 0, .35);
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  pointer-events: none;
  transform: translateX(-50%);
  animation: deck-drag-hint-pulse 1.25s ease-in-out infinite;
}

.deck-open .deck-drag-hint {
  display: block;
}

@keyframes deck-drag-hint-pulse {
  0%, 100% { opacity: .7; box-shadow: 0 0 0 0 rgba(255, 210, 93, .42), 0 8px 24px rgba(0, 0, 0, .35); }
  50% { opacity: 1; box-shadow: 0 0 0 7px rgba(255, 210, 93, 0), 0 8px 28px rgba(0, 0, 0, .46); }
}

@media (max-width: 720px) {
  :root {
    --library-topbar-height: 54px;
    --library-deck-width: 34vw;
  }

  .deck-preset-mask {
    align-items: flex-end;
  }

  .main.deck-open {
    padding-right: var(--library-deck-width);
  }

  .main.deck-open .content {
    padding: 24px 6px 48px;
  }

  .deck-open .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px 7px;
  }

  .deck-open .deck-panel {
    width: var(--library-deck-width);
    padding: 6px;
    border-radius: 7px 0 0 0;
  }

  .deck-environment-library {
    flex-basis: 17.5dvh;
    min-height: 64.4px;
  }

  .deck-primary-library > .deck-empty {
    min-height: 72px;
    padding: 8px 4px;
    font-size: 9px;
  }

  .deck-environment-library .deck-empty {
    padding: 5px 3px;
    font-size: 9px;
  }

  .deck-drag-hint {
    left: 33vw;
    bottom: 8px;
    max-width: calc(66vw - 16px);
    padding: 7px 9px;
    font-size: 10px;
  }

  .deck-head {
    gap: 4px;
    margin-bottom: 4px;
  }

  .deck-preset-button {
    height: 28px;
    padding-inline: 5px;
    font-size: 10px;
  }

  .deck-stat {
    margin: 3px 0 5px;
    font-size: 9px;
  }

  .deck-section + .deck-section {
    margin-top: 5px;
  }

  .deck-section-title {
    margin-bottom: 3px;
    font-size: 10px;
  }

  .deck-section-empty {
    padding: 4px 2px;
    font-size: 9px;
  }

  .deck-row {
    grid-template-columns: 22px minmax(0, 1fr) 28px;
    gap: 4px;
    padding: 4px;
  }

  .deck-row-level {
    width: 20px;
    height: 20px;
    font-size: 9px;
  }

  .deck-row-name {
    font-size: 9px;
  }

  .deck-row-controls {
    grid-template-columns: 26px;
    gap: 2px;
  }

  .deck-row-controls button {
    width: 22px;
    height: 22px;
    padding: 0;
  }

  .deck-row-controls span {
    width: 26px;
    height: 22px;
    font-size: 10px;
  }

  .deck-tools {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px;
    margin-top: 5px;
  }

  .deck-tools .mini-button {
    height: 34px;
    padding: 0 2px;
    font-size: 11px;
  }

  .deck-tool-label-desktop {
    display: none;
  }

  .deck-tool-label-mobile {
    display: inline;
  }

}


/* 图鉴构筑：卡面顶部横条与外置数量；移动端两栏等宽。 */
.deck-open .deck-panel { height:calc(100dvh - var(--library-topbar-height)); align-self:stretch; }
.deck-panel .deck-section-title { padding:8px 7px; border-bottom:1px solid var(--line-soft); color:var(--text); }
.deck-panel .deck-section-title span:last-child { color:var(--muted); font-size:10px; }
.deck-panel .deck-section-rows,.deck-panel .deck-list { gap:0; grid-auto-rows:auto; }
.deck-panel .deck-row { grid-template-columns:minmax(0,1fr) 38px; gap:8px; height:auto; min-height:0; padding:0; border:0; border-radius:0; background:transparent; }
.deck-panel .deck-row + .deck-row { margin-top:-5px; }
.deck-row-art { position:relative; min-width:0; aspect-ratio:4.6; overflow:hidden; border:1px solid var(--line); border-radius:8px; background:var(--panel-2); box-shadow:0 5px 12px rgba(0,0,0,.42); }
.deck-row-art > img:not(.deck-strip-type) { display:block; width:100%; height:100%; object-fit:cover; object-position:center; opacity:.55; }
.deck-strip-level { position:absolute; z-index:1; left:3px; top:50%; transform:translateY(-50%); width:20px; height:20px; border-radius:50%; background:#285173; text-align:center; line-height:20px; font-weight:700; color:#fff; }
.deck-row-art .deck-strip-type { position:absolute; z-index:1; left:26px; top:50%; transform:translateY(-50%); width:20px; height:20px; object-fit:contain; }
.deck-row-art .deck-row-name { position:absolute; inset:0; display:flex; align-items:center; padding:0 5px 0 50px; color:#fff; font-weight:700; text-shadow:0 1px 3px #000; white-space:nowrap; overflow:hidden; }
.deck-row-art .deck-row-name[hidden] { display:none; }
.deck-panel .deck-row-controls,.deck-panel .deck-row-automatic .deck-row-controls { grid-template-columns:minmax(0,1fr); }
.deck-panel .deck-row-controls span { width:100%; height:auto; padding:0; border:0; border-radius:0; background:transparent; color:var(--text); font-size:21px; line-height:1; box-shadow:none; }
.deck-panel .deck-row-automatic { opacity:.72; }
.deck-panel .deck-environment-library { flex-basis:22.4%; min-height:84px; }
.deck-panel .deck-primary-library,.deck-panel .deck-list { scrollbar-width:thin; }
.deck-panel .deck-primary-library::-webkit-scrollbar,.deck-panel .deck-list::-webkit-scrollbar { display:block; width:7px; }
.deck-panel .deck-primary-library::-webkit-scrollbar-thumb,.deck-panel .deck-list::-webkit-scrollbar-thumb { background:var(--line); border-radius:5px; }
@media(max-width:720px) {
  :root { --library-deck-width:50vw; }
  .deck-open .grid { grid-template-columns:minmax(0,1fr); }
  .deck-open .deck-panel { padding:6px; }
  .deck-panel .deck-row { grid-template-columns:minmax(0,1fr) 24px; gap:4px; }
  .deck-panel .deck-row + .deck-row { margin-top:-2px; }
  .deck-row-art { border-radius:5px; }
  .deck-panel .deck-row-controls span { font-size:16px; }
  .deck-panel .deck-section-title { padding:6px 2px; font-size:10px; }
  .deck-panel .deck-section-title span:last-child { font-size:9px; }
  .deck-panel .deck-environment-library { min-height:92px; }
  .deck-drag-hint { left:25vw; max-width:calc(50vw - 16px); }
}

/* 构筑横条：35% 卡面取样、黑白网点与两端统一比例。 */
.deck-panel .deck-row { display:block; }
.deck-panel .deck-row + .deck-row { margin-top:0; }
.deck-strip-background { position:absolute; inset:7.53% calc(var(--deck-strip-unit) * 6.4964) 7.53% calc(var(--deck-strip-unit) * 6.8324); overflow:hidden; background:#090b0e; }
.deck-strip-background > img:not([data-halftone="ready"]) { visibility:hidden; }
.deck-panel .deck-section-rows { padding:4px 0; }
.deck-panel .deck-section-rows,.deck-panel .deck-list { align-content:start; grid-auto-rows:max-content; gap:4px; }
.deck-panel .deck-row { flex:none; }
.deck-panel .deck-primary-library,.deck-panel .deck-environment-library,.deck-panel .deck-list { scrollbar-width:none; -ms-overflow-style:none; }
.deck-panel .deck-primary-library::-webkit-scrollbar,.deck-panel .deck-environment-library::-webkit-scrollbar,.deck-panel .deck-list::-webkit-scrollbar { display:none; width:0; height:0; }
.deck-panel .deck-row-art { aspect-ratio:4.8; border-radius:5px; overflow:visible; container-type:inline-size; --deck-strip-unit:1cqw; isolation:isolate; background:transparent; border:0; }
.deck-panel .deck-row-art .deck-strip-background > img { position:absolute; z-index:0; left:-12.5%; top:50%; width:125%; max-width:none; height:auto; transform:translateY(-35%); object-fit:initial; opacity:1; filter:contrast(1.06) brightness(.9); }
.deck-panel .deck-row-art .deck-strip-background::after { content:""; position:absolute; inset:0; z-index:1; pointer-events:none; background-image:linear-gradient(180deg,rgba(8,9,12,.18),rgba(8,9,12,.30)),linear-gradient(90deg,rgba(8,9,12,.04),rgba(8,9,12,.04)); background-size:100% 100%,100% 100%; border-radius:inherit; }
.deck-panel .deck-row-art::after { display:none; }
.deck-namebar-frame { position:absolute; inset:0; z-index:2; pointer-events:none; border-style:solid; border-width:0 calc(var(--deck-strip-unit) * 6.4964) 0 calc(var(--deck-strip-unit) * 6.8324); border-color:transparent; border-image-source:var(--deck-namebar); border-image-slice:0 58 0 61 fill; border-image-repeat:stretch; box-sizing:border-box; }
.deck-panel .deck-row-art::before { display:none; }
.deck-panel .deck-strip-dots { position:absolute; top:10%; bottom:10%; z-index:3; display:flex; flex-direction:column-reverse; justify-content:space-evenly; align-items:center; pointer-events:none; }
.deck-panel .deck-strip-dots-left { left:3.2%; }
.deck-panel .deck-strip-dots-right { right:3.2%; }
.deck-panel .deck-strip-dots i { display:block; height:2px; width:4px; flex-shrink:0; border-radius:0; background:linear-gradient(90deg,var(--dot-left) 50%,var(--dot-right) 50%); box-shadow:0 0 0 1px #000,0 0 0 2px #fff; }
.deck-panel .deck-strip-dots i.is-hollow { background:transparent; box-shadow:0 0 0 1px #000,0 0 0 2px #fff; }
.deck-panel .deck-strip-dots i { opacity:0; }
.deck-cost-pixels { display:block; position:absolute; z-index:3; pointer-events:none; image-rendering:pixelated; }
@media(max-width:720px) { .deck-panel .deck-strip-dots i { width:2px; height:1px; opacity:0; } .deck-cost-pixels { display:block; } }
.deck-panel .deck-row-art .deck-strip-type { z-index:4; left:calc(var(--deck-strip-unit) * 9.7); width:calc(var(--deck-strip-unit) * 12.6); height:calc(var(--deck-strip-unit) * 12.6); background:var(--deck-rarity-color); mask:var(--deck-type-icon) center / 85% 85% no-repeat; -webkit-mask:var(--deck-type-icon) center / 85% 85% no-repeat; filter:brightness(var(--deck-rarity-brightness,1.15)) saturate(var(--deck-rarity-saturation,1)) drop-shadow(2px 0 0 #000) drop-shadow(-2px 0 0 #000) drop-shadow(0 2px 0 #000) drop-shadow(0 -2px 0 #000); }
.deck-panel .deck-row-art .deck-row-name { z-index:4; left:calc(var(--deck-strip-unit) * 25); right:calc(var(--deck-strip-unit) * 29); top:50%; bottom:auto; transform:translateY(-50%); padding:0; display:block; font-size:calc(var(--deck-strip-unit) * 9.85); text-overflow:clip; color:var(--deck-rarity-color); filter:brightness(var(--deck-rarity-brightness,1.15)) saturate(var(--deck-rarity-saturation,1)); -webkit-text-stroke:2px #000; paint-order:stroke fill; }
.pact-deck-font-ready .deck-panel .deck-row-name,.pact-deck-font-ready .deck-panel .deck-row-controls > span { font-family:PactMasterDeck,"Microsoft YaHei",sans-serif; font-weight:600; -webkit-text-stroke:0; -webkit-text-fill-color:currentColor; text-shadow:-2px -2px 0 #000,2px -2px 0 #000,-2px 2px 0 #000,2px 2px 0 #000,-2px 0 0 #000,2px 0 0 #000,0 -2px 0 #000,0 2px 0 #000,0 1px 2px #000; }
.pact-deck-font-ready .deck-panel .deck-row-art .deck-strip-type-has-glyph { display:none; }
.pact-deck-font-ready .deck-panel .deck-row-art .deck-row-name { left:calc(var(--deck-strip-unit) * 9.7); }
.pact-deck-font-ready .deck-name-type-prefix { display:inline; font:inherit; }
.pact-deck-font-ready .deck-row-name-mobile,.pact-deck-font-ready .deck-row-name-desktop { display:inline-block; }
.pact-deck-font-ready .deck-name-card-text { display:inline-block; transform:scaleX(.93); transform-origin:left center; }
.deck-name-type-text { font:inherit; }
.pact-deck-font-ready .deck-panel .deck-row-controls > span { transform:scaleX(.93); transform-origin:right center; }
.deck-row-name-mobile,.pact-deck-font-ready .deck-row-name-mobile { display:none; }
.deck-row-name-desktop { display:inline; }
@media(max-width:720px) { .deck-row-name-mobile { display:inline; } .pact-deck-font-ready .deck-row-name-mobile { display:inline-block; } .deck-row-name-desktop,.pact-deck-font-ready .deck-row-name-desktop { display:none; } }
.deck-panel .deck-row-art .deck-row-controls { position:absolute; z-index:4; right:calc(var(--deck-strip-unit) * 7); top:50%; transform:translateY(-50%); width:calc(var(--deck-strip-unit) * 22); }
.deck-panel .deck-row-controls span { font-size:calc(var(--deck-strip-unit) * 11); font-style:italic; color:#fff; -webkit-text-stroke:2px #000; paint-order:stroke fill; text-shadow:0 1px 2px #000; }
.deck-cost-curve { display:grid; position:relative; container-type:inline-size; grid-template-columns:minmax(0,4fr) minmax(0,6fr); gap:18px; flex:0 0 auto; margin:0 6px 6px; padding:8px 0; border-bottom:1px solid var(--line-soft); }
.deck-cost-curve-title { text-align:center; margin-bottom:6px; font-size:11px; font-weight:700; color:var(--text); }
.deck-cost-curve::after { content:""; position:absolute; left:calc(40% + 1.8px); top:30%; bottom:22%; width:1px; background:var(--line-soft); transform:translateX(-50%); pointer-events:none; }
.deck-cost-chart { min-width:0; --deck-output-gaps:16px; --deck-bar-scale:.6; }
.deck-cost-curve-bars { display:grid; grid-template-columns:repeat(8,minmax(0,1fr)); gap:2px; }
.deck-cost-column { display:grid; grid-template-rows:14px 54px 14px; gap:3px; text-align:center; font-size:10px; color:var(--text); }
.deck-cost-track { display:flex; align-items:flex-end; border-bottom:1px solid var(--line-soft); }
.deck-cost-bar { width:70%; margin:0 auto; background:linear-gradient(#f8dc88,#ac783b); border-radius:2px 2px 0 0; }
@media(max-width:720px) { .deck-cost-curve { margin:0 0 4px; padding:6px 2px; } .deck-cost-chart { --deck-output-gaps:8px; --deck-bar-scale:1.2; } .deck-cost-curve-bars { gap:1px; } .deck-cost-column { grid-template-rows:12px 40px 12px; font-size:9px; } .deck-cost-curve-title { font-size:10px; } }

@media(min-width:721px) {
  .deck-panel .deck-row-art { --deck-strip-unit:calc((clamp(300px,22vw,360px) - 40px) / 100); aspect-ratio:auto; height:calc(var(--deck-strip-unit) * 100 / 4.8); }
  .deck-panel .deck-strip-dots-left { left:calc(var(--deck-strip-unit) * 3.7); transform:translateX(-50%); }
  .deck-panel .deck-strip-dots-right { right:calc(var(--deck-strip-unit) * 3.7); transform:translateX(50%); }
  .deck-panel .deck-strip-dots i { height:2px; width:5px; }
}
