.deck-editor-page .content-shell {
  max-width: 1320px;
  padding-right: clamp(12px, 2vw, 24px);
  padding-left: clamp(12px, 2vw, 24px);
}

.deck-editor-shell {
  display: grid;
  grid-template-columns: minmax(15rem, 18rem) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.deck-editor-shell > .page-heading {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.deck-editor-sidebar {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 18px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(252, 250, 247, 0.92);
  box-shadow: 0 16px 44px rgba(50, 42, 34, 0.1);
}

.deck-editor-sidebar h2,
.deck-editor-heading h2,
.deck-search-heading h2 {
  margin: 3px 0 0;
}

.deck-editor-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.deck-editor-actions--danger {
  margin-top: -11px;
}

.deck-editor-actions .button {
  min-height: 42px;
  padding: 9px 5px;
  font-size: 10px;
  line-height: 1.1;
  white-space: nowrap;
}

.button-danger {
  border: 1px solid rgba(196, 52, 42, 0.5);
  color: var(--red);
  background: rgba(196, 52, 42, 0.06);
}

.button-danger:disabled,
.deck-editor-actions .button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.deck-editor-status {
  min-height: 3.2rem;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  background: rgba(244, 241, 234, 0.68);
}

.deck-editor-status p {
  margin: 0 0 5px;
}

.deck-editor-status p:last-child {
  margin-bottom: 0;
}

.deck-editor-status[data-tone="ok"] {
  border-color: rgba(31, 99, 54, 0.5);
  color: #1f6336;
  background: rgba(31, 99, 54, 0.08);
}

.deck-editor-status[data-tone="error"] {
  border-color: rgba(196, 52, 42, 0.5);
  color: #8e211b;
  background: rgba(196, 52, 42, 0.08);
}

.deck-editor-feedback {
  min-width: 0;
}

.deck-format-status {
  margin-top: 0.8rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(244, 241, 234, 0.68);
}

.deck-format-status header {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 0.2rem;
}

.deck-format-status strong {
  color: var(--ink);
  font-size: 0.86rem;
}

.deck-format-status header span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.deck-format-status p {
  margin: 0.35rem 0 0;
  font-size: 0.76rem;
  line-height: 1.4;
}

.deck-format-status[data-deck-format-status="legal"] {
  border-color: rgba(31, 99, 54, 0.62);
  background: rgba(31, 99, 54, 0.08);
}

.deck-format-status[data-deck-format-status="legal"] strong {
  color: #1f6336;
}

.deck-format-status[data-deck-format-status="illegal"] {
  border-color: rgba(196, 52, 42, 0.65);
  background: rgba(196, 52, 42, 0.08);
}

.deck-format-status[data-deck-format-status="illegal"] strong {
  color: var(--red);
}

.deck-editor-main {
  min-width: 0;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(252, 250, 247, 0.82);
}

.deck-editor-heading,
.deck-search-heading {
  display: flex;
  gap: 22px;
  align-items: end;
  justify-content: space-between;
}

.deck-summary {
  margin: 16px 0 1rem;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.18), rgba(99, 74, 50, 0.06)),
    rgba(252, 250, 247, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.deck-summary-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: clamp(0.8rem, 1.8vw, 1.15rem);
  border: 0;
  color: inherit;
  text-align: left;
  background: transparent;
  cursor: pointer;
  transition: background 150ms ease;
}

.deck-summary-toggle:hover {
  background: rgba(99, 74, 50, 0.06);
}

.deck-summary-toggle:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: -3px;
}

.deck-summary-title {
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
}

.deck-summary-meta {
  display: flex;
  flex: none;
  align-items: center;
  gap: 0.75rem;
}

.deck-summary-count {
  display: flex;
  align-items: baseline;
  gap: 0.28rem;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 750;
}

.deck-summary-count strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 3vw, 2.1rem);
  line-height: 1;
}

.deck-summary-chevron {
  width: 0.62rem;
  height: 0.62rem;
  border-right: 2px solid var(--ink-soft);
  border-bottom: 2px solid var(--ink-soft);
  transform: translateY(-0.16rem) rotate(45deg);
  transition: transform 160ms ease;
}

.deck-summary-toggle[aria-expanded="true"] .deck-summary-chevron {
  transform: translateY(0.16rem) rotate(225deg);
}

.deck-summary-details {
  padding: 0 clamp(0.8rem, 1.8vw, 1.15rem) clamp(0.8rem, 1.8vw, 1.15rem);
}

.deck-summary-details[hidden] {
  display: none;
}

.deck-progress {
  height: 7px;
  margin: 0 0 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(42, 35, 29, 0.1);
}

.deck-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--orange), #efbe5a);
  transition: width 180ms ease;
}

.deck-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 27px;
  margin-bottom: 16px;
}

.deck-breakdown span {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  background: var(--paper);
}

.deck-current-grid,
.deck-card-results {
  --deck-builder-card-w: 4.4rem;
  --deck-builder-card-h: 6.15rem;
  display: grid;
  grid-template-columns:
    repeat(auto-fill, minmax(calc(var(--deck-builder-card-w) + 1.35rem), 1fr));
  gap: 16px 11px;
  align-content: start;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(244, 241, 234, 0.68);
}

.deck-current-grid {
  min-height: 13.5rem;
  max-height: 44vh;
  overflow: auto;
}

.deck-card-results {
  min-height: 32rem;
  max-height: 66vh;
  overflow: auto;
}

.deck-search-heading {
  margin: 28px 0 16px;
}

.deck-search-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.deck-search-controls input,
.deck-search-controls select {
  min-height: 42px;
}

.deck-search-controls input {
  width: min(310px, 36vw);
}

.deck-color-filters {
  display: flex;
  flex: none;
  flex-wrap: nowrap;
  gap: 6px;
  margin: 0;
}

.deck-color-filter {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgb(11 11 14 / 24%);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 28%);
  cursor: pointer;
  transition: filter 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.deck-color-filter input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--white);
  cursor: pointer;
}

.deck-color-filter:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.deck-color-filter:has(input:checked) {
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 35%),
    0 0 0 2px var(--paper),
    0 0 0 4px currentcolor;
}

.deck-color-filter:has(input:focus-visible) {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}

.deck-color-filter--red {
  color: var(--red);
  background: var(--red);
}

.deck-color-filter--green {
  color: var(--green);
  background: var(--green);
}

.deck-color-filter--blue {
  color: var(--blue);
  background: var(--blue);
}

.deck-builder-card {
  position: relative;
  width: calc(var(--deck-builder-card-w) + 1.35rem);
  min-width: 0;
  color: inherit;
}

.deck-card-face {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  color: inherit;
  text-align: left;
  background: transparent;
}

button.deck-card-face {
  cursor: pointer;
}

button.deck-card-face:disabled {
  cursor: default;
}

.deck-card-visual {
  position: relative;
  display: grid;
  width: var(--deck-builder-card-w);
  height: var(--deck-builder-card-h);
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(42, 35, 29, 0.28);
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.94);
  background:
    radial-gradient(circle at 70% 20%, rgba(255, 255, 255, 0.22), transparent 25%),
    linear-gradient(145deg, #2e6e8e, #173a52);
  box-shadow: 0 6px 14px rgba(50, 42, 34, 0.28);
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.deck-builder-card.is-leader .deck-card-visual {
  border-color: rgba(250, 148, 39, 0.9);
  background:
    radial-gradient(circle at 70% 20%, rgba(255, 255, 255, 0.22), transparent 25%),
    linear-gradient(145deg, #fa9427, #a9471d);
  box-shadow:
    0 0 0 1px rgba(250, 148, 39, 0.24),
    0 6px 14px rgba(50, 42, 34, 0.28);
}

.deck-card-visual.has-art {
  background: #17191c;
}

.deck-card-visual.has-art::before {
  display: none;
}

.deck-card-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.deck-card-visual::before {
  width: 50px;
  height: 50px;
  border: 2px solid currentColor;
  border-radius: 50%;
  content: "";
  opacity: 0.55;
  box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.09);
}

.deck-card-type {
  position: absolute;
  top: 4px;
  left: 4px;
  max-width: calc(100% - 8px);
  padding: 2px 4px;
  overflow: hidden;
  border-radius: 3px;
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: uppercase;
  background: rgba(20, 24, 28, 0.6);
  z-index: 1;
}

.deck-card-visual.has-art .deck-card-type {
  display: none;
}

.deck-copy-badge {
  position: absolute;
  right: -6px;
  bottom: -5px;
  min-width: 24px;
  padding: 3px 5px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  background: #efbe5a;
  box-shadow: 0 3px 8px rgba(50, 42, 34, 0.28);
  z-index: 3;
}

.deck-card-copy {
  display: block;
  width: var(--deck-builder-card-w);
  padding: 7px 0 0;
}

.deck-card-copy strong {
  display: -webkit-box;
  width: 100%;
  height: 2.35em;
  overflow: hidden;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.16;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.deck-card-copy small {
  display: none;
}

.deck-card-stats {
  display: none;
}

.deck-card-face:hover:not(:disabled) .deck-card-visual,
.deck-card-face:focus-visible .deck-card-visual {
  transform: translateY(-2px);
  box-shadow: 0 9px 18px rgba(50, 42, 34, 0.34);
}

.deck-card-face:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 4px;
}

.deck-card-zoom {
  position: absolute;
  top: 4px;
  left: calc(var(--deck-builder-card-w) - 26px);
  z-index: 4;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 4px;
  color: white;
  background: rgba(28, 25, 22, 0.82);
  box-shadow: 0 3px 9px rgba(28, 25, 22, 0.38);
  cursor: pointer;
}

.deck-card-zoom::before {
  position: absolute;
  top: 5px;
  left: 6px;
  width: 8px;
  height: 8px;
  border: 2px solid currentColor;
  border-radius: 50%;
  content: "";
}

.deck-card-zoom::after {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 6px;
  height: 2px;
  background: currentColor;
  content: "";
  transform: rotate(45deg);
  transform-origin: left center;
}

.deck-card-zoom:hover:not(:disabled),
.deck-card-zoom:focus-visible {
  border-color: var(--orange);
  color: #efbe5a;
}

.deck-card-zoom:disabled {
  cursor: default;
  opacity: 0.4;
}

.deck-builder-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 38px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 13px;
  color: var(--muted);
  text-align: center;
}

.deck-hover-preview {
  display: grid;
  min-height: 265px;
  place-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(244, 241, 234, 0.68);
}

.deck-hover-preview p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
}

.deck-hover-preview img {
  display: block;
  width: min(100%, 185px);
  max-height: 265px;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 24px rgba(50, 42, 34, 0.28);
}

.deck-hover-preview strong {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.deck-import-dialog {
  width: min(620px, calc(100% - 30px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  color: var(--ink);
  background: transparent;
}

.deck-import-dialog::backdrop {
  background: rgba(24, 20, 18, 0.56);
  backdrop-filter: blur(3px);
}

.deck-import-dialog .dialog-panel {
  max-width: none;
}

.deck-import-dialog textarea {
  width: 100%;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.deck-card-preview-dialog {
  width: min(390px, calc(100% - 30px));
  max-height: calc(100vh - 30px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  color: var(--ink);
  background: transparent;
}

.deck-card-preview-dialog::backdrop {
  background: rgba(24, 20, 18, 0.7);
  backdrop-filter: blur(4px);
}

.deck-card-preview-panel {
  max-width: none;
  padding: 18px;
}

.deck-card-preview-panel .dialog-heading {
  margin-bottom: 12px;
}

.deck-card-preview-panel h2 {
  margin: 0;
  font-size: clamp(18px, 3vw, 24px);
}

.deck-card-preview-image {
  display: block;
  width: 100%;
  max-height: calc(100vh - 120px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 16px 36px rgba(24, 20, 18, 0.36);
}

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

  .deck-editor-sidebar {
    position: static;
    grid-template-columns: 1fr 1fr;
  }

  .deck-editor-sidebar-head,
  .deck-editor-actions,
  .deck-editor-feedback,
  .deck-editor-status,
  .deck-hover-preview {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .deck-editor-heading,
  .deck-search-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .deck-editor-sidebar {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .deck-editor-sidebar > * {
    grid-column: 1;
  }

  .deck-editor-main {
    padding: 18px;
  }

  .deck-search-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .deck-search-controls input {
    width: 100%;
  }

}

@media (prefers-reduced-motion: reduce) {
  .deck-progress span {
    transition: none;
  }
}
