:root {
  color-scheme: dark;
  --bg-a: #121712;
  --bg-b: #201b0f;
  --text: rgba(238, 237, 229, 0.9);
  --muted: rgba(238, 237, 229, 0.48);
  --button-bg: rgba(18, 18, 16, 0.58);
  --button-border: rgba(255, 255, 255, 0.2);
  --button-shadow: 0 10px 30px rgba(0, 0, 0, 0.34);
  --accent: #d7b454;
  --gallery-clear-filter-width: 28px;
  --gallery-sort-width: min(150px, calc(100vw - 188px));
  --gallery-trait-search-width: 108px;
  --gallery-control-gap: 12px;
  --gallery-favorite-space: 54px;
  --gallery-corner-inset: max(20px, env(safe-area-inset-right));
  --gallery-corner-bottom: max(20px, env(safe-area-inset-bottom));
  --site-font: Optima, Candara, "Lucida Sans", "Lucida Grande", "Trebuchet MS", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

img,
svg,
canvas {
  -webkit-user-drag: none;
  user-drag: none;
}

::selection {
  background: transparent;
  color: inherit;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 64% 78%, rgba(108, 84, 30, 0.32), transparent 46%),
    linear-gradient(145deg, var(--bg-a), var(--bg-b));
  color: var(--text);
  font-family: var(--site-font);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.86' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.64'/%3E%3C/svg%3E");
  background-size: 140px 140px;
  mix-blend-mode: soft-light;
  filter: contrast(135%);
  opacity: 0.24;
}

body.is-light {
  color-scheme: light;
  --bg-a: #e9e4d5;
  --bg-b: #f8f4e8;
  --text: rgba(28, 27, 24, 0.86);
  --muted: rgba(28, 27, 24, 0.5);
  --button-bg: rgba(255, 255, 255, 0.6);
  --button-border: rgba(31, 28, 20, 0.18);
  --button-shadow: 0 8px 22px rgba(44, 35, 16, 0.14);
}

body.is-light::before {
  mix-blend-mode: multiply;
  opacity: 0.15;
}

button {
  color: inherit;
  font: inherit;
}

.table {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.card-rig {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto auto;
  justify-items: center;
  align-items: center;
  padding: clamp(18px, 4vmin, 42px) 16px clamp(34px, 7vmin, 70px);
  transition: opacity 240ms ease;
}

body.is-gallery .card-rig {
  pointer-events: none;
  opacity: 0;
}

#cardCanvas {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  height: 100svh;
  display: block;
  touch-action: none;
  filter: drop-shadow(0 0 18px rgba(230, 210, 148, 0.1));
  opacity: 1;
  transition: opacity 260ms ease;
}

body.is-light #cardCanvas {
  filter: drop-shadow(0 16px 28px rgba(55, 45, 24, 0.12));
}

.button-row,
.binder-page-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 42px;
}

.button-row {
  position: fixed;
  left: 50%;
  bottom: clamp(108px, 14vh, 154px);
  transform: translateX(-50%);
  z-index: 2;
  margin-top: 0;
}

.card-filename {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
}

.card-filename {
  bottom: clamp(78px, 10.2vh, 116px);
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--button-border);
  border-radius: 9px;
  background: var(--button-bg);
  box-shadow: var(--button-shadow);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(16px);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, opacity 160ms ease;
}

a.icon-button {
  color: var(--text);
  text-decoration: none;
}

.icon-button:hover {
  transform: translateY(-1px);
  border-color: rgba(215, 180, 84, 0.48);
}

.icon-button:active {
  transform: translateY(0) scale(0.97);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#binderShuffleButton::before {
  content: "";
  display: none;
  position: absolute;
  inset: 0;
  width: 18px;
  height: 18px;
  margin: auto;
  box-sizing: border-box;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  pointer-events: none;
  transform-origin: 50% 50%;
  animation: binder-shuffle-spin 680ms linear infinite;
}

#binderShuffleButton.is-loading::before {
  display: block;
}

#binderShuffleButton.is-loading svg {
  opacity: 0;
}

@keyframes binder-shuffle-spin {
  to { transform: rotate(360deg); }
}

.icon-button[aria-pressed="true"] {
  color: var(--accent);
  border-color: rgba(215, 180, 84, 0.62);
}

#galleryToggleButton[aria-pressed="true"] {
  color: var(--text);
  border-color: var(--button-border);
}

.icon-button[aria-expanded="true"] {
  color: var(--accent);
  border-color: rgba(215, 180, 84, 0.62);
}

#favoriteButton[aria-pressed="true"] svg path,
#favoriteFilterButton[aria-pressed="true"] svg path,
#binderFavoriteButton[aria-pressed="true"] svg path {
  fill: currentColor;
}

.trait-panel {
  position: fixed;
  z-index: 3;
  top: 43.5%;
  right: clamp(132px, 16vw, 260px);
  width: min(430px, calc(50vw - 96px));
  max-height: min(62vh, 580px);
  opacity: 0;
  pointer-events: none;
  transform: translate(22px, -50%);
  transition:
    opacity 320ms ease,
    transform 460ms cubic-bezier(0.2, 0.82, 0.2, 1);
}

body.traits-open .trait-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translate(0, -50%);
}

.trait-panel-content {
  max-height: inherit;
  display: grid;
  gap: 18px;
}

.trait-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 132px));
  justify-content: center;
  gap: 10px;
  max-height: calc(min(62vh, 580px) - 48px);
  overflow: auto;
  padding: 5px;
  scrollbar-width: thin;
}

.trait-tile {
  color: inherit;
  font: inherit;
  min-width: 0;
  min-height: 82px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 12px 10px;
  border: 1px solid color-mix(in srgb, var(--button-border), var(--accent) 10%);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.072), rgba(255, 255, 255, 0.018)),
    rgba(15, 14, 12, 0.46);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(14px);
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.trait-tile:hover {
  border-color: rgba(215, 180, 84, 0.52);
  transform: translateY(-1px);
}

.trait-tile:active {
  transform: translateY(0) scale(0.99);
}

body.is-light .trait-tile {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.42)),
    rgba(255, 255, 255, 0.54);
  box-shadow: 0 12px 24px rgba(44, 35, 16, 0.1);
}

.trait-category,
.trait-value,
.trait-total {
  min-width: 0;
  overflow-wrap: anywhere;
  letter-spacing: 0;
}

.trait-category {
  color: var(--muted);
  font-size: 9px;
  line-height: 1.1;
  font-weight: 520;
  text-transform: uppercase;
}

.trait-value {
  color: var(--text);
  font-size: 12px;
  line-height: 1.15;
  font-weight: 520;
}

.trait-total {
  color: var(--muted);
  font-size: 9px;
  font-weight: 480;
  line-height: 1;
}

.trait-tile-empty {
  grid-column: 1 / -1;
  min-height: 96px;
}

.trait-action-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
}

.trait-link-button,
.trait-download-button {
  justify-self: center;
  color: var(--text);
}

.trait-link-button[aria-disabled="true"] {
  opacity: 0.42;
  pointer-events: none;
}

.trait-logo-image {
  display: block;
  width: 24px;
  height: 24px;
  object-fit: contain;
  pointer-events: none;
}

.solscan-logo {
  width: 22px;
  height: 22px;
  transform: translateY(-1px);
}

.card-filename,
.binder-page-status {
  width: min(86vw, 600px);
  text-align: center;
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 0;
  color: var(--muted);
  min-height: 14px;
}

.card-filename {
  margin-top: 0;
  font-weight: 500;
}

.card-filename.is-card-jump-enabled {
  width: max-content;
  max-width: min(86vw, 600px);
  cursor: pointer;
}

.card-filename.is-editing {
  width: max-content;
  max-width: min(86vw, 600px);
  color: var(--text);
  min-width: 118px;
  transform: translate(-50%, 5px);
}

.card-name-jump-input {
  width: 118px;
  height: 24px;
  border: 1px solid var(--button-border);
  border-radius: 6px;
  background: var(--button-bg);
  box-shadow: var(--button-shadow);
  color: var(--text);
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 22px;
  outline: none;
  padding: 0 8px;
  text-align: center;
  -webkit-user-select: text;
  user-select: text;
}

.card-name-jump-input:focus {
  border-color: rgba(215, 180, 84, 0.62);
  box-shadow: 0 0 0 2px rgba(215, 180, 84, 0.16), var(--button-shadow);
}

.card-name-jump-input::selection {
  background: rgba(215, 180, 84, 0.36);
  color: var(--text);
}

.gallery-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
}

body.is-gallery .gallery-panel {
  opacity: 1;
  pointer-events: auto;
}

body.binder-card-transitioning .card-rig {
  pointer-events: none;
}

body.binder-card-transitioning.binder-card-transition-show-card .card-rig {
  opacity: 1;
}

body.binder-card-transitioning .button-row,
body.binder-card-transitioning .card-filename {
  opacity: 0;
  transition: opacity 360ms ease;
}

body.binder-card-transitioning.binder-card-transition-show-card .button-row,
body.binder-card-transitioning.binder-card-transition-show-card .card-filename {
  opacity: 1;
}

body.binder-card-transitioning .gallery-panel,
body.binder-card-transitioning .binder-page-controls,
body.binder-card-transitioning .binder-page-status,
body.binder-card-transitioning .gallery-view-toggle,
body.binder-card-transitioning .wallet-search-toggle,
body.binder-card-transitioning .corner-favorites {
  transition: opacity 420ms ease;
}

body.binder-card-transitioning.binder-card-transition-away .gallery-panel,
body.binder-card-transitioning.binder-card-transition-away .binder-page-controls,
body.binder-card-transitioning.binder-card-transition-away .binder-page-status,
body.binder-card-transitioning.binder-card-transition-away .gallery-view-toggle,
body.binder-card-transitioning.binder-card-transition-away .wallet-search-toggle,
body.binder-card-transitioning.binder-card-transition-away .corner-favorites {
  opacity: 0;
  pointer-events: none;
}

.binder-card-transition-card {
  position: fixed;
  z-index: 90;
  display: block;
  border-radius: 8px;
  object-fit: fill;
  pointer-events: none;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
  opacity: 1;
  transform: translateZ(0);
  transition:
    left 820ms cubic-bezier(0.2, 0.82, 0.2, 1),
    top 820ms cubic-bezier(0.2, 0.82, 0.2, 1),
    width 820ms cubic-bezier(0.2, 0.82, 0.2, 1),
    height 820ms cubic-bezier(0.2, 0.82, 0.2, 1),
    opacity 220ms ease,
    box-shadow 820ms cubic-bezier(0.2, 0.82, 0.2, 1);
  will-change: left, top, width, height, opacity;
}

.binder-card-transition-card.is-dissolving {
  opacity: 0;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.22);
}

.gallery-grid {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  padding: clamp(58px, 13vh, 96px) calc((100vw - min(1180px, calc(100vw - 88px))) / 2 + 10px) clamp(116px, 18vh, 158px);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-content: start;
  gap: 22px;
  scrollbar-width: thin;
}

.gallery-filter-controls {
  position: fixed;
  z-index: 8;
  left: 50%;
  bottom: var(--gallery-corner-bottom);
  display: grid;
  grid-template-columns: var(--gallery-sort-width) var(--gallery-trait-search-width);
  align-items: center;
  gap: var(--gallery-control-gap);
  transform: translateX(-50%);
}

.gallery-clear-filters-button,
.gallery-sort-control,
.gallery-trait-search-button {
  position: static;
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--button-border);
  border-radius: 10px;
  background: var(--button-bg);
  box-shadow: var(--button-shadow);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1;
  backdrop-filter: blur(16px);
}

.gallery-clear-filters-button {
  position: absolute;
  left: calc((var(--gallery-clear-filter-width) + var(--gallery-control-gap)) * -1);
  top: 50%;
  transform: translateY(-50%);
  flex: 0 0 var(--gallery-clear-filter-width);
  justify-content: center;
  width: var(--gallery-clear-filter-width);
  min-height: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}

.gallery-clear-filters-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gallery-sort-control {
  grid-column: 1;
  flex: 0 0 var(--gallery-sort-width);
  gap: 6px;
  width: var(--gallery-sort-width);
  cursor: pointer;
}

body.is-gallery .gallery-sort-control {
  flex-basis: min(148px, calc(100vw - 298px));
  width: min(148px, calc(100vw - 298px));
}

.gallery-sort-control::after {
  content: "";
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  margin-left: -1px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  opacity: 0.74;
  transform: translateY(-2px) rotate(45deg);
  pointer-events: none;
  transition: transform 150ms ease;
}

.gallery-sort-control.is-open::after {
  transform: translateY(2px) rotate(225deg);
}

.gallery-sort-control:has(select:open)::after {
  transform: translateY(2px) rotate(225deg);
}

.gallery-sort-control span {
  flex: 0 0 auto;
  pointer-events: none;
}

.gallery-sort-control select {
  flex: 1;
  min-width: 0;
  max-width: none;
  border: 0;
  border-radius: 7px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 520;
  line-height: 1.2;
  outline: none;
  cursor: pointer;
  overflow: hidden;
  padding-right: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-sort-control option {
  color: #191713;
}

.gallery-trait-search-button {
  grid-column: 2;
  flex: 0 0 var(--gallery-trait-search-width);
  justify-content: center;
  min-width: 0;
  width: var(--gallery-trait-search-width);
  border-radius: 10px;
  color: var(--text);
  text-transform: lowercase;
  cursor: pointer;
  display: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-trait-search-button.has-active-trait {
  justify-content: flex-start;
  text-align: left;
}

.gallery-trait-search-label {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  pointer-events: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.is-gallery .gallery-trait-search-button {
  display: flex;
}

.gallery-trait-search-button[aria-pressed="true"] {
  border-color: rgba(215, 180, 84, 0.62);
  background: rgba(215, 180, 84, 0.18);
}

.gallery-card {
  border: 0;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  content-visibility: auto;
  contain-intrinsic-size: 220px 312px;
}

.gallery-card img {
  display: block;
  width: 100%;
  aspect-ratio: 776 / 1098;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.32);
}

.binder-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

#binderCanvas {
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
  filter: drop-shadow(0 0 18px rgba(230, 210, 148, 0.09));
}

body.is-light #binderCanvas {
  filter: drop-shadow(0 12px 26px rgba(51, 42, 25, 0.12));
}

.binder-loading {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(240px, 54vw);
  height: 4px;
  transform: translate(-50%, -50%);
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.binder-loading span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  animation: loading-bar 1s ease-in-out infinite;
}

@keyframes loading-bar {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(260%); }
}

.binder-page-controls {
  position: absolute;
  left: 50%;
  bottom: 87px;
  transform: translateX(-50%);
}

.binder-page-controls.is-intro-focused #binderFavoriteButton,
.binder-page-controls.is-intro-focused #binderOpenCardButton {
  opacity: 0.3;
  pointer-events: none;
}

.binder-page-status {
  position: absolute;
  left: 50%;
  bottom: 65px;
  transform: translateX(-50%);
  width: max-content;
}

.binder-page-status.is-page-jump-enabled {
  cursor: pointer;
}

.binder-page-status.is-editing {
  color: var(--text);
  min-width: 62px;
  transform: translate(-50%, 5px);
}

.binder-page-status.is-card-editing {
  min-width: 118px;
}

.binder-page-jump-input {
  width: 62px;
  height: 24px;
  border: 1px solid var(--button-border);
  border-radius: 6px;
  background: var(--button-bg);
  box-shadow: var(--button-shadow);
  color: var(--text);
  font: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 22px;
  outline: none;
  padding: 0 8px;
  text-align: center;
  -webkit-user-select: text;
  user-select: text;
}

.binder-page-jump-input.is-card-jump {
  width: 118px;
}

.binder-page-jump-input:focus {
  border-color: rgba(215, 180, 84, 0.62);
  box-shadow: 0 0 0 2px rgba(215, 180, 84, 0.16), var(--button-shadow);
}

.binder-page-jump-input::selection {
  background: rgba(215, 180, 84, 0.36);
  color: var(--text);
}

.trait-search-panel {
  position: absolute;
  inset: clamp(30px, 4.8vh, 56px) clamp(20px, 5vw, 76px) clamp(102px, 15vh, 146px);
  z-index: 5;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  place-items: stretch center;
  pointer-events: auto;
}

.trait-search-filter {
  width: min(360px, 100%);
  justify-self: center;
  transform: translateY(-6px);
}

.trait-search-input {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--button-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: var(--button-shadow);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  outline: none;
  padding: 0 10px;
  text-align: center;
  -webkit-user-select: text;
  user-select: text;
  backdrop-filter: blur(16px);
}

.trait-search-input::placeholder {
  color: var(--muted);
  opacity: 0.84;
}

.trait-search-input:focus {
  border-color: rgba(215, 180, 84, 0.62);
}

.trait-search-layout {
  width: min(1240px, 100%);
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(124px, 168px);
  gap: 18px;
  align-items: stretch;
}

.trait-search-groups {
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 12px 6px 26px;
  display: grid;
  align-content: start;
  gap: 22px;
  grid-auto-rows: max-content;
  scrollbar-width: thin;
}

.trait-search-group {
  display: grid;
  align-content: start;
  align-self: start;
  gap: 10px;
}

.trait-search-heading {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1;
  text-transform: lowercase;
}

.trait-search-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100%;
  overflow: auto;
  padding: 12px 4px 18px;
  display: grid;
  align-content: start;
  gap: 2px;
  scrollbar-width: thin;
}

.trait-search-sidebar-button {
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 500;
  line-height: 1.1;
  overflow: hidden;
  padding: 6px 9px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.trait-search-sidebar-button:hover {
  border-color: rgba(215, 180, 84, 0.34);
  background: rgba(215, 180, 84, 0.1);
  color: var(--text);
}

.trait-search-tile-grid {
  display: grid;
  align-content: start;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  grid-auto-rows: minmax(70px, max-content);
  gap: 10px;
}

.trait-search-tile {
  min-height: 70px;
  padding: 12px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(18, 18, 16, 0.46);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  backdrop-filter: blur(14px);
  display: grid;
  align-content: center;
  gap: 7px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.trait-search-tile:hover {
  transform: translateY(-1px);
  border-color: rgba(215, 180, 84, 0.48);
  background: rgba(215, 180, 84, 0.14);
}

body.is-light .trait-search-tile {
  border-color: rgba(31, 28, 20, 0.14);
  background: rgba(255, 255, 255, 0.54);
}

.trait-search-value {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 520;
  line-height: 1.15;
}

.trait-search-count {
  color: var(--muted);
  font-size: 10px;
  font-weight: 480;
  line-height: 1;
}

.trait-search-empty {
  align-self: start;
  justify-self: center;
  margin-top: clamp(42px, 12vh, 96px);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  text-align: center;
}

.gallery-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.wallet-search-panel {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  padding: 24px;
  pointer-events: auto;
}

.wallet-search-dialog {
  width: min(620px, calc(100vw - 44px));
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--button-border), var(--accent) 10%);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.078), rgba(255, 255, 255, 0.024)),
    rgba(15, 14, 12, 0.72);
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
  pointer-events: auto;
}

body.is-light .wallet-search-dialog {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.58)),
    rgba(255, 255, 255, 0.72);
  box-shadow: 0 16px 36px rgba(44, 35, 16, 0.14);
}

.wallet-search-message {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0;
  text-align: center;
}

.wallet-address-input {
  width: min(100%, 420px);
  min-height: 40px;
  border: 1px solid var(--button-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  letter-spacing: 0;
  outline: none;
  padding: 0 10px;
  text-align: left;
  -webkit-user-select: text;
  user-select: text;
}

.wallet-address-input:focus {
  border-color: rgba(215, 180, 84, 0.62);
}

.wallet-address-input:disabled {
  opacity: 0.64;
}

.wallet-search-submit-button {
  color: var(--text);
}

.wallet-search-submit-button:disabled {
  cursor: progress;
  opacity: 0.58;
}

input[type="text"]::selection,
input[type="search"]::selection,
input:not([type])::selection,
textarea::selection {
  background: rgba(215, 180, 84, 0.64);
  color: #16120b;
}

.corner-gallery,
.corner-favorites,
.gallery-view-toggle,
.wallet-search-toggle,
.theme-switch {
  position: fixed;
  z-index: 10;
}

.corner-gallery {
  right: var(--gallery-corner-inset);
  bottom: var(--gallery-corner-bottom);
}

.gallery-toggle-icon {
  grid-area: 1 / 1;
}

#galleryToggleButton .gallery-binder-icon,
#galleryToggleButton .gallery-grid-icon {
  width: 22px;
  height: 22px;
}

#galleryToggleButton .gallery-binder-icon {
  transform: translateY(-1px);
}

.gallery-grid-icon,
.gallery-card-icon {
  display: none;
}

#galleryToggleButton .gallery-card-icon {
  width: 22px;
  height: 22px;
}

#galleryToggleButton .gallery-card-icon-body {
  fill: currentColor;
  stroke: none;
}

body.is-gallery .gallery-binder-icon {
  display: none;
}

body:not(.is-gallery):not(.is-binder-view) .gallery-binder-icon {
  display: none;
}

body:not(.is-gallery):not(.is-binder-view) .gallery-grid-icon {
  display: block;
}

body.is-gallery .gallery-card-icon {
  display: block;
}

.corner-favorites {
  right: calc(
    var(--gallery-corner-inset)
    + var(--gallery-favorite-space)
    + var(--gallery-favorite-space)
  );
  bottom: var(--gallery-corner-bottom);
  display: none;
}

body.is-gallery .corner-favorites {
  display: inline-grid;
}

.wallet-search-toggle {
  right: calc(
    var(--gallery-corner-inset)
    + var(--gallery-favorite-space)
    + var(--gallery-favorite-space)
    + var(--gallery-favorite-space)
  );
  bottom: var(--gallery-corner-bottom);
  display: none;
}

body.is-gallery .wallet-search-toggle:not([hidden]) {
  display: inline-grid;
}

.gallery-view-toggle {
  right: calc(
    var(--gallery-corner-inset)
    + var(--gallery-favorite-space)
  );
  bottom: var(--gallery-corner-bottom);
  display: none;
}

body.is-gallery .gallery-view-toggle:not([hidden]) {
  display: inline-grid;
}

.theme-switch {
  left: max(20px, env(safe-area-inset-left));
  bottom: max(20px, env(safe-area-inset-bottom));
}

.theme-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  width: 46px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--button-border);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: var(--button-shadow);
  display: block;
  padding: 2px;
  cursor: pointer;
  backdrop-filter: blur(14px);
}

.switch-thumb {
  display: block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  transition: transform 180ms ease, background 180ms ease;
}

.theme-switch input:checked + .switch-track {
  background: rgba(190, 154, 57, 0.72);
}

.theme-switch input:checked + .switch-track .switch-thumb {
  transform: translateX(20px);
}

[hidden] {
  display: none !important;
}

.gallery-clear-filters-button[hidden] {
  display: flex !important;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

@media (max-width: 720px) {
  :root {
    --gallery-clear-filter-width: 26px;
    --gallery-sort-width: min(112px, calc(100vw - 252px));
    --gallery-trait-search-width: 82px;
    --gallery-control-gap: 10px;
    --gallery-favorite-space: 48px;
    --gallery-filter-center-shift: -167px;
    --gallery-filter-center-shift-clear: -185px;
    --gallery-corner-inset: max(12px, env(safe-area-inset-right));
    --gallery-corner-bottom: max(12px, env(safe-area-inset-bottom));
  }

  #cardCanvas {
    width: 100vw;
    height: 100vh;
    height: 100svh;
  }

  .gallery-grid {
    padding-left: 27px;
    padding-right: 27px;
    padding-top: clamp(46px, 10vh, 76px);
    padding-bottom: clamp(106px, 16vh, 132px);
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
  }

  .gallery-clear-filters-button,
  .gallery-sort-control,
  .gallery-trait-search-button {
    min-height: 32px;
    padding: 6px 8px;
    font-size: 10px;
  }

  .gallery-clear-filters-button {
    flex-basis: 26px;
    width: 26px;
    min-height: 26px;
    height: 26px;
    padding: 0;
    font-size: 11px;
  }

  .gallery-clear-filters-button svg {
    width: 14px;
    height: 14px;
  }

  .gallery-sort-control {
    gap: 5px;
  }

  body.is-gallery .gallery-sort-control {
    flex-basis: min(112px, calc(100vw - 266px));
    width: min(112px, calc(100vw - 266px));
  }

  .gallery-sort-control select {
    min-width: 0;
    max-width: none;
  }

  .icon-button {
    width: 36px;
    height: 36px;
    border-radius: 8px;
  }

  .icon-button svg {
    width: 18px;
    height: 18px;
  }

  .button-row,
  .binder-page-controls {
    gap: 12px;
    min-height: 36px;
  }

  .binder-page-controls {
    bottom: 80px;
  }

  .binder-page-status {
    bottom: 59px;
  }

  .trait-search-panel {
    inset: 22px 14px 92px;
  }

  .trait-search-layout {
    display: block;
    width: 100%;
  }

  .trait-search-sidebar {
    display: none;
  }

  .trait-search-groups {
    gap: 18px;
  }

  .trait-search-tile-grid {
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 8px;
  }

  .trait-search-tile {
    min-height: 62px;
    padding: 10px 8px;
  }

  .trait-search-value {
    font-size: 12px;
  }

  .button-row {
    bottom: clamp(92px, 12.6vh, 124px);
  }

  .card-filename {
    bottom: clamp(66px, 9.4vh, 92px);
  }

  .trait-panel {
    left: 50%;
    right: auto;
    top: calc(50% - 18px);
    width: min(92vw, 440px);
    max-height: min(56vh, 520px);
    transform: translate(-50%, calc(-50% + 18px));
  }

  body.traits-open .trait-panel {
    transform: translate(-50%, -50%);
  }

  body.traits-open:not(.is-gallery) #cardCanvas {
    opacity: 0;
    pointer-events: none;
  }

  .trait-grid {
    grid-template-columns: repeat(auto-fit, minmax(108px, 126px));
    gap: 8px;
    max-height: calc(min(56vh, 520px) - 44px);
  }

  .trait-tile {
    min-height: 72px;
    padding: 10px 8px;
  }

  .trait-category {
    font-size: 8px;
  }

  .trait-value {
    font-size: 11px;
  }

  .switch-track {
    width: 42px;
    height: 24px;
  }

  .switch-thumb {
    width: 18px;
    height: 18px;
  }

  .theme-switch input:checked + .switch-track .switch-thumb {
    transform: translateX(18px);
  }
}

@media (max-width: 820px), (max-aspect-ratio: 28 / 25) {
  .trait-search-layout {
    display: block;
    width: 100%;
  }

  .trait-search-sidebar {
    display: none;
  }

  .trait-panel {
    left: 50%;
    right: auto;
    top: calc(50% - 18px);
    width: min(92vw, 440px);
    max-height: min(56vh, 520px);
    transform: translate(-50%, calc(-50% + 18px));
  }

  body.traits-open .trait-panel {
    transform: translate(-50%, -50%);
  }

  body.traits-open:not(.is-gallery) #cardCanvas {
    opacity: 0;
    pointer-events: none;
  }
}

@media (max-width: 520px) {
  :root {
    --gallery-clear-filter-width: 24px;
    --gallery-sort-width: 86px;
    --gallery-trait-search-width: 66px;
    --gallery-control-gap: 5px;
    --gallery-favorite-space: 42px;
    --gallery-filter-center-shift: -131.5px;
    --gallery-filter-center-shift-clear: -146px;
    --gallery-corner-inset: max(8px, env(safe-area-inset-right));
  }

  .icon-button,
  .button-row .icon-button {
    width: 34px;
    height: 34px;
  }

  .icon-button svg {
    width: 17px;
    height: 17px;
  }
}

@media (max-width: 420px) {
  :root {
    --gallery-clear-filter-width: 22px;
    --gallery-sort-width: 82px;
    --gallery-trait-search-width: 64px;
    --gallery-control-gap: 5px;
    --gallery-favorite-space: 38px;
    --gallery-filter-center-shift: -128.5px;
    --gallery-filter-center-shift-clear: -142px;
    --gallery-corner-inset: max(8px, env(safe-area-inset-right));
    --gallery-corner-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .card-rig {
    padding-inline: 6px;
  }

  .button-row {
    gap: 8px;
  }

  .icon-button,
  .button-row .icon-button {
    width: 34px;
    height: 34px;
  }

  #cardCanvas {
    width: 100vw;
    height: 100vh;
    height: 100svh;
  }

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

  .trait-panel {
    width: calc(100vw - 28px);
    max-height: min(52vh, 460px);
  }

  .trait-grid {
    grid-template-columns: repeat(auto-fit, minmax(96px, 118px));
    gap: 7px;
    max-height: calc(min(52vh, 460px) - 44px);
    padding: 4px;
  }

  .trait-tile {
    min-height: 68px;
    padding: 9px 7px;
  }

  .corner-gallery {
    right: 8px;
    bottom: var(--gallery-corner-bottom);
  }

  .corner-favorites {
    bottom: var(--gallery-corner-bottom);
  }

  .gallery-sort-control {
    gap: 6px;
    padding-inline: 6px;
  }

  .gallery-clear-filters-button {
    flex-basis: var(--gallery-clear-filter-width);
    width: var(--gallery-clear-filter-width);
    min-height: 22px;
    height: 22px;
    font-size: 10px;
  }

  body.is-gallery .gallery-sort-control {
    flex-basis: var(--gallery-sort-width);
    width: var(--gallery-sort-width);
  }

  .gallery-trait-search-button {
    padding-inline: 6px;
    font-size: 9px;
  }

  .binder-page-controls {
    bottom: 77px;
  }

  .binder-page-status {
    bottom: 57px;
  }

  .theme-switch {
    left: 8px;
    bottom: 10px;
  }

}

@media (max-width: 720px) {
  body.is-gallery .gallery-filter-controls {
    left: calc(50vw + var(--gallery-filter-center-shift));
    bottom: var(--gallery-corner-bottom);
    transform: none;
  }

  body.is-gallery .gallery-filter-controls {
    width: auto;
    padding-inline: 0;
    grid-template-columns: var(--gallery-sort-width) var(--gallery-trait-search-width);
  }

  body.is-gallery .gallery-filter-controls:has(.gallery-clear-filters-button:not([hidden])) {
    left: calc(50vw + var(--gallery-filter-center-shift-clear));
    grid-template-columns: var(--gallery-clear-filter-width) var(--gallery-sort-width) var(--gallery-trait-search-width);
  }

  body.is-gallery .gallery-filter-controls:has(.gallery-clear-filters-button:not([hidden])) .gallery-clear-filters-button {
    position: static;
    grid-column: 1;
    transform: none;
  }

  body.is-gallery .gallery-filter-controls:has(.gallery-clear-filters-button:not([hidden])) .gallery-sort-control {
    grid-column: 2;
  }

  body.is-gallery .gallery-filter-controls:has(.gallery-clear-filters-button:not([hidden])) .gallery-trait-search-button {
    grid-column: 3;
  }

  body.is-gallery .gallery-sort-control {
    flex-basis: auto;
    width: var(--gallery-sort-width);
  }
}

@media (max-width: 420px) {
  body.is-gallery .gallery-filter-controls {
    left: calc(50vw + var(--gallery-filter-center-shift));
  }

  body.is-gallery .gallery-filter-controls:has(.gallery-clear-filters-button:not([hidden])) {
    left: calc(50vw + var(--gallery-filter-center-shift-clear));
  }
}

@media (max-width: 360px) {
  :root {
    --gallery-clear-filter-width: 20px;
    --gallery-sort-width: 58px;
    --gallery-trait-search-width: 48px;
    --gallery-control-gap: 4px;
    --gallery-favorite-space: 35px;
    --gallery-filter-center-shift: -106.5px;
    --gallery-filter-center-shift-clear: -118.5px;
  }

  .icon-button,
  .button-row .icon-button {
    width: 32px;
    height: 32px;
  }

  .icon-button svg {
    width: 16px;
    height: 16px;
  }

  body.is-gallery .gallery-filter-controls {
    left: calc(50vw + var(--gallery-filter-center-shift));
  }

  .gallery-clear-filters-button {
    min-height: 20px;
    height: 20px;
  }

  .gallery-clear-filters-button svg {
    width: 12px;
    height: 12px;
  }

  .gallery-clear-filters-button,
  .gallery-sort-control,
  .gallery-trait-search-button {
    min-height: 28px;
    padding: 5px 5px;
    font-size: 8px;
  }

  .gallery-clear-filters-button {
    min-height: 20px;
    height: 20px;
    padding: 0;
  }

  .gallery-sort-control {
    gap: 4px;
  }

  .gallery-sort-control::after {
    width: 5px;
    height: 5px;
  }

  .switch-track {
    width: 34px;
    height: 22px;
  }

  .switch-thumb {
    width: 16px;
    height: 16px;
  }

  .theme-switch input:checked + .switch-track .switch-thumb {
    transform: translateX(12px);
  }
}

@media (max-width: 320px) {
  :root {
    --gallery-clear-filter-width: 17px;
    --gallery-sort-width: 48px;
    --gallery-trait-search-width: 36px;
    --gallery-control-gap: 3px;
    --gallery-favorite-space: 31px;
    --gallery-filter-center-shift: -90px;
    --gallery-filter-center-shift-clear: -100px;
  }

  .icon-button,
  .button-row .icon-button {
    width: 30px;
    height: 30px;
  }

  .icon-button svg {
    width: 15px;
    height: 15px;
  }

  body.is-gallery .gallery-filter-controls {
    left: calc(50vw + var(--gallery-filter-center-shift));
  }

  .gallery-clear-filters-button,
  .gallery-sort-control,
  .gallery-trait-search-button {
    min-height: 26px;
    padding: 4px 4px;
    font-size: 7px;
  }

  .gallery-clear-filters-button {
    min-height: 18px;
    height: 18px;
    padding: 0;
  }

  .switch-track {
    width: 30px;
    height: 20px;
  }

  .switch-thumb {
    width: 14px;
    height: 14px;
  }

  .theme-switch input:checked + .switch-track .switch-thumb {
    transform: translateX(10px);
  }
}

@media (max-width: 360px) and (orientation: landscape) {
  body.is-gallery .gallery-filter-controls {
    left: 50%;
    bottom: calc(var(--gallery-corner-bottom) + 54px);
    width: 100vw;
    padding-inline: 6px;
    grid-template-columns: minmax(0, 1fr) var(--gallery-trait-search-width);
    transform: translateX(-50%);
  }

  body.is-gallery .gallery-filter-controls:has(.gallery-clear-filters-button:not([hidden])) {
    grid-template-columns: var(--gallery-clear-filter-width) minmax(0, 1fr) var(--gallery-trait-search-width);
  }

  body.is-gallery .gallery-filter-controls:has(.gallery-clear-filters-button:not([hidden])) .gallery-clear-filters-button {
    position: static;
    grid-column: 1;
    transform: none;
  }

  body.is-gallery .gallery-filter-controls:has(.gallery-clear-filters-button:not([hidden])) .gallery-sort-control {
    grid-column: 2;
  }

  body.is-gallery .gallery-filter-controls:has(.gallery-clear-filters-button:not([hidden])) .gallery-trait-search-button {
    grid-column: 3;
  }

  body.is-gallery .gallery-sort-control {
    flex-basis: auto;
    width: auto;
  }

  body.is-gallery.is-binder-view .binder-page-controls {
    bottom: calc(var(--gallery-corner-bottom) + 116px);
  }

  body.is-gallery.is-binder-view .binder-page-status {
    bottom: calc(var(--gallery-corner-bottom) + 94px);
  }
}

@media (max-width: 360px) and (hover: hover) and (pointer: fine) {
  :root {
    --gallery-clear-filter-width: 22px;
    --gallery-sort-width: 82px;
    --gallery-trait-search-width: 64px;
    --gallery-control-gap: 5px;
    --gallery-favorite-space: 38px;
  }

  .icon-button,
  .button-row .icon-button {
    width: 34px;
    height: 34px;
  }

  .icon-button svg {
    width: 17px;
    height: 17px;
  }

  .gallery-clear-filters-button,
  .gallery-sort-control,
  .gallery-trait-search-button {
    min-height: 32px;
    padding: 6px;
    font-size: 9px;
  }

  .gallery-clear-filters-button {
    width: var(--gallery-clear-filter-width);
    min-height: 22px;
    height: 22px;
    padding: 0;
  }

  .gallery-clear-filters-button svg {
    width: 14px;
    height: 14px;
  }

  .gallery-sort-control {
    gap: 6px;
  }

  .gallery-sort-control::after {
    width: 6px;
    height: 6px;
  }

  body.is-gallery .gallery-filter-controls,
  body.is-gallery .gallery-filter-controls:has(.gallery-clear-filters-button:not([hidden])) {
    left: 50%;
    bottom: calc(var(--gallery-corner-bottom) + 54px);
    width: auto;
    padding-inline: 0;
    transform: translateX(-50%);
  }

  body.is-gallery .gallery-filter-controls {
    grid-template-columns: var(--gallery-sort-width) var(--gallery-trait-search-width);
  }

  body.is-gallery .gallery-filter-controls:has(.gallery-clear-filters-button:not([hidden])) {
    grid-template-columns: var(--gallery-clear-filter-width) var(--gallery-sort-width) var(--gallery-trait-search-width);
  }

  body.is-gallery.is-binder-view .binder-page-controls {
    bottom: calc(var(--gallery-corner-bottom) + 116px);
  }

  body.is-gallery.is-binder-view .binder-page-status {
    bottom: calc(var(--gallery-corner-bottom) + 94px);
  }
}

@media (max-width: 720px) and (orientation: portrait) {
  body.is-gallery .gallery-filter-controls {
    bottom: var(--gallery-corner-bottom);
  }
}

@media (max-width: 360px) and (hover: hover) and (pointer: fine) {
  body.is-gallery .gallery-filter-controls,
  body.is-gallery .gallery-filter-controls:has(.gallery-clear-filters-button:not([hidden])) {
    bottom: calc(var(--gallery-corner-bottom) + 54px);
  }
}
