body {
  background: linear-gradient(180deg, color-mix(in oklab, var(--edge-bg) 84%, #e7f0ff 16%) 0%, var(--edge-bg) 100%);
}

.back-btn {
  border-radius: var(--edge-control-radius) !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--edge-control-height);
  line-height: 1;
  padding-top: 0;
  padding-bottom: 0;
}

.card {
  border: 1px solid var(--edge-border);
  border-radius: var(--edge-radius);
  box-shadow: var(--edge-shadow);
  overflow: hidden;
}

.card-image-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 63 / 88;
  overflow: hidden;
  background: #1f2936;
  border-radius: var(--edge-radius);
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
  background: #1f2936;
  display: block;
}

.foil-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.8;
  pointer-events: none;
}

.result-col {
  flex: 0 0 50%;
  max-width: 50%;
  padding: 0.35rem;
  overflow: hidden;
}

#scryfall-results,
#singles-results,
#auctions-results {
  margin-left: -0.35rem;
  margin-right: -0.35rem;
}

.result-card {
  border: 1px solid var(--edge-border);
  border-radius: var(--edge-radius);
  box-shadow: var(--edge-shadow-soft);
  overflow: hidden;
  background: var(--edge-surface);
}

.result-content {
  padding: 0.65rem 0.75rem 0.75rem;
}

.result-title {
  font-weight: 600;
  font-size: var(--text-base);
  margin-bottom: 0.25rem;
  line-height: var(--lh-snug);
}

.result-meta {
  color: var(--edge-muted);
  font-size: var(--text-sm);
  line-height: var(--lh-snug);
}

.price-line {
  font-size: var(--text-sm);
  font-weight: 600;
}

.result-link-muted {
  font-size: var(--text-xs);
  color: color-mix(in oklab, var(--edge-muted) 90%, #637a99 10%);
  text-decoration: none;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.result-link-muted:hover {
  color: color-mix(in oklab, var(--edge-text) 70%, #4e6788 30%);
  text-decoration: underline;
}

#sourceTabs {
  flex-wrap: wrap;
}

.mono {
  font-family: "JetBrains Mono", "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: var(--text-sm);
}

.sticky-panel {
  position: sticky;
  top: 16px;
}

.set-icon {
  width: 11px;
  height: 11px;
  vertical-align: -1px;
  margin-right: 3px;
}

.set-icon-parent {
  opacity: 0.85;
}

.exchange-summary {
  background: color-mix(in oklab, var(--edge-surface-alt) 78%, #e7f1ff 22%);
  border: 1px solid var(--edge-border);
  border-radius: var(--edge-control-radius);
  padding: 0.6rem 0.7rem;
  font-size: 0.9rem;
}

.form-control,
.form-select,
.btn,
.nav-pills .nav-link,
.btn-group .btn {
  border-radius: var(--edge-control-radius);
}

.btn-outline-primary.active,
.btn-check:checked + .btn-outline-primary {
  background: color-mix(in oklab, var(--edge-primary) 18%, var(--edge-surface) 82%) !important;
  border-color: color-mix(in oklab, var(--edge-primary) 75%, white 25%) !important;
  color: color-mix(in oklab, var(--edge-primary) 86%, #1f3f68 14%) !important;
}

.btn-outline-secondary.active,
.btn-check:checked + .btn-outline-secondary {
  background: color-mix(in oklab, var(--edge-surface-alt) 48%, #d6e6ff 52%) !important;
  border-color: color-mix(in oklab, var(--edge-border-strong) 62%, #8aa8cf 38%) !important;
  color: color-mix(in oklab, var(--edge-text) 56%, #3f5577 44%) !important;
}

.form-control,
.form-select,
.btn:not(.back-btn) {
  min-height: var(--edge-control-height);
}

.btn-group-sm > .btn,
.btn-sm {
  min-height: var(--edge-control-height-sm);
  border-radius: var(--edge-control-radius);
}

#search-form .form-control,
#search-form .btn,
#usd-rate,
#usd-reset-custom {
  min-height: var(--edge-control-height);
}

#sourceTabs .nav-link {
  border-radius: var(--edge-control-radius);
  padding: 0.55rem 1rem;
  font-weight: 600;
}

.table td,
.table th {
  vertical-align: middle;
}

.table > :not(caption) > * > :first-child {
  padding-left: 0.75rem;
}

.table > :not(caption) > * > :last-child {
  padding-right: 0.75rem;
}

/* Cards per row: phone>=2, tablet=3, desktop=4, wide desktop=5 */
@media (min-width: 768px) {
  .result-col {
    flex: 0 0 33.3333%;
    max-width: 33.3333%;
  }
}

@media (min-width: 1200px) {
  .result-col {
    flex: 0 0 25%;
    max-width: 25%;
  }
}

@media (min-width: 1600px) {
  .result-col {
    flex: 0 0 20%;
    max-width: 20%;
  }
}

/* Mobile compact typography to keep 2 cards readable */
@media (max-width: 767.98px) {
  .result-content {
    padding: 0.5rem 0.55rem 0.6rem;
  }
  .result-title {
    font-size: var(--text-sm);
    margin-bottom: 0.18rem;
  }
  .result-meta {
    font-size: var(--text-xs);
    line-height: 1.15;
  }
  .price-line {
    font-size: var(--text-xs);
  }
  .set-icon {
    width: 10px;
    height: 10px;
  }
}

/* List view */
body.view-list .result-col {
  flex: 0 0 100%;
  max-width: 100%;
}

body.view-list .result-row {
  display: grid;
  grid-template-columns: 84px 1fr 320px;
  align-items: stretch;
}

body.view-list .card-image-frame {
  width: 64px;
  max-width: 64px;
  min-width: 64px;
  margin: 10px;
  aspect-ratio: 63 / 88;
  border-radius: 4px;
}

body.view-list .result-content {
  padding: 10px 12px;
  border-left: 1px solid var(--edge-border);
  border-right: 1px solid var(--edge-border);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

body.view-list .inline-topdeck-link {
  display: none;
}

body.view-list .result-link-col {
  display: flex;
  align-items: center;
  padding: 10px 12px;
}

.result-row {
  display: block;
}

.result-link-col {
  display: none;
}

@media (max-width: 767.98px) {
  body.view-list .result-row {
    grid-template-columns: 72px 1fr;
    grid-template-areas:
      "img main"
      "img link";
  }

  body.view-list .list-col-image {
    grid-area: img;
  }

  body.view-list .result-content {
    grid-area: main;
    border-right: 0;
  }

  body.view-list .result-link-col {
    grid-area: link;
    border-top: 1px solid var(--edge-border);
    border-left: 1px solid var(--edge-border);
  }

  body.view-list .card-image-frame {
    width: 52px;
    max-width: 52px;
    min-width: 52px;
    margin: 10px;
  }
}
