:root {
  color-scheme: light;
  --ink: #151515;
  --muted: #666052;
  --paper: #f8f4ea;
  --panel: #fffdf8;
  --panel-strong: #f0e6d2;
  --line: #d7cab2;
  --charcoal: #20242a;
  --red: #b34435;
  --blue: #2f6fa3;
  --green: #3c7a4a;
  --gold: #b68127;
  --violet: #725b93;
  --shadow: 0 18px 60px rgb(37 30 18 / 16%);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgb(179 68 53 / 16%), transparent 31%),
    linear-gradient(45deg, rgb(47 111 163 / 13%), transparent 36%),
    var(--paper);
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  padding: 24px;
}

.workbench {
  width: min(1500px, 100%);
  margin: 0 auto;
}

.mast,
.toolbar,
.deck-hero,
.deck-actions,
.button-row,
.range-field,
.check-field,
.format-tabs,
.color-row {
  display: flex;
  align-items: center;
}

.mast {
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4.4rem);
  line-height: 0.95;
}

.status-pill {
  min-width: 132px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(255 253 248 / 82%);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  text-align: center;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 20px;
  align-items: start;
}

.control-panel,
.results-area {
  border: 1px solid var(--line);
  background: rgb(255 253 248 / 91%);
  box-shadow: var(--shadow);
}

.control-panel {
  position: sticky;
  top: 20px;
  display: grid;
  gap: 16px;
  padding: 16px;
  border-radius: var(--radius);
}

.results-area {
  min-height: 720px;
  padding: 18px;
  border-radius: var(--radius);
}

.format-tabs {
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
}

.tab {
  flex: 1;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.tab.is-active {
  background: var(--charcoal);
  color: white;
}

.field,
.field-group {
  display: grid;
  gap: 7px;
}

.field span,
.field-group legend,
.range-field span,
.check-field span,
.mini-title {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffaf1;
  color: var(--ink);
  padding: 0 12px;
}

.field textarea {
  min-height: 74px;
  padding: 11px 12px;
  resize: vertical;
}

.commander-only[hidden] {
  display: none;
}

.field-group {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.field-group legend {
  padding: 0 6px;
}

.range-field {
  gap: 10px;
  min-height: 34px;
}

.range-field span {
  width: 84px;
}

.range-field input {
  flex: 1;
  accent-color: var(--red);
}

.range-field output {
  width: 24px;
  color: var(--ink);
  font-weight: 850;
  text-align: right;
}

.toggle-stack {
  display: grid;
  gap: 9px;
}

.check-field {
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffaf1;
}

.check-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.button-row {
  gap: 8px;
}

.primary-button,
.secondary-button,
.icon-button,
.secondary-link {
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid var(--charcoal);
  font-weight: 900;
  text-decoration: none;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

.primary-button {
  flex: 1;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  background: var(--charcoal);
  color: #fff;
  padding: 0 16px;
}

.button-mark {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--ink);
}

.secondary-button,
.icon-button,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fffaf1;
  color: var(--charcoal);
  padding: 0 13px;
}

.primary-button:hover,
.secondary-button:hover,
.icon-button:hover,
.secondary-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 9px 24px rgb(34 31 25 / 12%);
}

.mini-panel {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.mini-panel dl {
  display: grid;
  gap: 8px;
  margin: 9px 0 0;
}

.mini-panel div {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 8px;
}

.mini-panel dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.mini-panel dd {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 750;
}

.viability-summary {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
  font-weight: 900;
  line-height: 1.25;
}

.mini-panel .viability-details {
  display: block;
  grid-template-columns: none;
  margin-top: 4px;
}

.viability-toggle,
.negative-filter-toggle,
.reference-check-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-width: 0;
  min-height: 0;
  border: 1px solid rgb(47 111 163 / 42%);
  border-radius: 4px;
  background: rgb(47 111 163 / 7%);
  color: var(--blue);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1.25;
  padding: 1px 6px;
  text-align: left;
  user-select: none;
  white-space: nowrap;
}

.viability-toggle:hover,
.negative-filter-toggle:hover,
.reference-check-button:hover {
  background: rgb(47 111 163 / 12%);
}

.viability-toggle::before,
.negative-filter-toggle::before {
  content: "+ ";
}

.viability-toggle[aria-expanded="true"]::before,
.negative-filter-toggle[aria-expanded="true"]::before {
  content: "- ";
}

.viability-toggle:focus-visible,
.negative-filter-toggle:focus-visible,
.reference-check-button:focus-visible {
  outline: 2px solid rgb(47 111 163 / 48%);
  outline-offset: 3px;
  border-radius: 4px;
}

.viability-list[hidden] {
  display: none;
}

.viability-list {
  display: grid;
  gap: 4px;
  margin: 7px 0 0;
  padding-left: 16px;
  color: #4b4439;
  font-size: 0.76rem;
  font-weight: 760;
  line-height: 1.25;
}

.meta-list {
  display: grid;
  gap: 7px;
  margin: 9px 0 10px;
  padding: 0;
  list-style: none;
}

.meta-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.meta-list span {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-list strong {
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 950;
}

.mini-link {
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 900;
  text-decoration: none;
}

.mini-link:hover {
  text-decoration: underline;
}

.pauper-only[hidden] {
  display: none;
}

.pauper-brain {
  display: grid;
  gap: 10px;
  margin-top: 9px;
}

.negative-filter {
  display: grid;
  gap: 9px;
  margin-top: 9px;
}

.mini-panel .pauper-brain,
.mini-panel .negative-filter {
  grid-template-columns: none;
  justify-items: start;
}

.mini-panel .negative-filter-details {
  display: grid;
  grid-template-columns: none;
  gap: 9px;
  justify-self: stretch;
  width: 100%;
}

.negative-filter-details[hidden] {
  display: none;
}

.reference-check {
  display: grid;
  gap: 8px;
  margin-top: 9px;
  justify-items: start;
}

.mini-panel .reference-check {
  grid-template-columns: none;
}

.reference-status {
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 950;
}

.reference-status.is-current {
  border-color: rgb(60 122 74 / 28%);
  background: rgb(60 122 74 / 10%);
  color: var(--green);
}

.reference-status.is-due {
  border-color: rgb(179 68 53 / 32%);
  background: rgb(179 68 53 / 10%);
  color: var(--red);
}

.reference-due-list {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 18px;
  color: #4b4439;
  font-size: 0.76rem;
  font-weight: 760;
  line-height: 1.25;
}

.knowledge-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.mini-panel .knowledge-row {
  grid-template-columns: 72px minmax(0, 1fr);
}

.knowledge-row span,
.knowledge-copy {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.35;
}

.mini-panel .knowledge-copy,
.mini-panel .filter-label {
  display: block;
  grid-template-columns: none;
}

.knowledge-row strong {
  color: var(--ink);
  font-size: 0.84rem;
  line-height: 1.25;
}

.filter-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.chip-stack,
.axis-stack,
.filter-stack,
.exception-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-panel .chip-stack,
.mini-panel .axis-stack,
.mini-panel .filter-stack,
.mini-panel .exception-stack {
  display: flex;
  grid-template-columns: none;
}

.chip-stack span,
.axis-stack span,
.filter-stack span,
.exception-stack span {
  min-height: 26px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffaf1;
  color: var(--charcoal);
  font-size: 0.73rem;
  font-weight: 900;
}

.axis-stack span,
.exception-stack span {
  border-color: rgb(47 111 163 / 28%);
  background: rgb(47 111 163 / 9%);
  color: #285d88;
}

.filter-stack span {
  border-color: rgb(179 68 53 / 24%);
  background: rgb(179 68 53 / 8%);
  color: #7b332a;
}

.toolbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.toolbar h2 {
  margin-bottom: 0;
  font-size: 1.5rem;
}

.message {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid rgb(182 129 39 / 36%);
  border-radius: var(--radius);
  background: rgb(182 129 39 / 12%);
  color: #5d4620;
}

.message.is-error {
  border-color: rgb(179 68 53 / 42%);
  background: rgb(179 68 53 / 12%);
  color: #76291f;
}

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

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

.deck-card {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.deck-hero {
  gap: 12px;
  align-items: stretch;
}

.anchor-art {
  width: 108px;
  aspect-ratio: 63 / 88;
  flex: 0 0 auto;
  border-radius: 6px;
  object-fit: cover;
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.deck-heading {
  min-width: 0;
  display: grid;
  align-content: start;
}

.deck-kicker {
  color: var(--red);
  font-size: 0.74rem;
  font-weight: 950;
  text-transform: uppercase;
}

.deck-heading h3 {
  margin: 3px 0 6px;
  font-size: 1.08rem;
  line-height: 1.15;
}

.deck-plan {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.89rem;
  line-height: 1.38;
}

.color-row {
  gap: 5px;
  flex-wrap: wrap;
}

.pip {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgb(20 20 20 / 24%);
  color: #111;
  font-size: 0.75rem;
  font-weight: 950;
}

.pip-w {
  background: #f5e8bc;
}

.pip-u {
  background: #b9d8eb;
}

.pip-b {
  background: #7c7480;
  color: #fff;
}

.pip-r {
  background: #e49a76;
}

.pip-g {
  background: #98c285;
}

.pip-c {
  background: #ddd6ca;
}

.deck-body {
  display: grid;
  gap: 12px;
}

.deck-grid.is-single .deck-body {
  grid-template-columns: minmax(240px, 0.9fr) minmax(360px, 1.25fr);
  align-items: start;
}

.deck-body h4 {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.insight-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 18px;
  color: #3d382f;
  font-size: 0.9rem;
  line-height: 1.35;
}

.decklist {
  display: grid;
  gap: 10px;
  max-height: 270px;
  margin: 0;
  padding: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #1b1e22;
  color: #f6efe2;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.8rem;
  line-height: 1.42;
}

.decklist-section {
  display: grid;
  gap: 3px;
}

.decklist-section + .decklist-section {
  padding-top: 9px;
  border-top: 1px solid rgb(246 239 226 / 14%);
}

.decklist-heading {
  color: #d9c892;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.decklist-row {
  display: grid;
  grid-template-columns: 3ch minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  min-height: 22px;
}

.decklist-count {
  color: #b9afa0;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  text-align: right;
}

.decklist-card {
  min-width: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  padding: 0 2px;
  text-align: left;
  line-height: inherit;
}

.decklist-card:hover,
.decklist-card:focus-visible {
  color: #ffe39a;
  outline: 1px solid rgb(255 227 154 / 54%);
  outline-offset: 2px;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.card-preview-popover {
  position: fixed;
  z-index: 20;
  width: min(252px, calc(100vw - 24px));
  padding: 8px;
  border: 1px solid rgb(255 250 241 / 20%);
  border-radius: var(--radius);
  background: #14171b;
  box-shadow: 0 24px 70px rgb(0 0 0 / 34%);
  pointer-events: none;
}

.card-preview-popover[hidden] {
  display: none;
}

.card-preview-popover img {
  display: block;
  width: 100%;
  aspect-ratio: 63 / 88;
  border-radius: 7px;
  background: #252a30;
  object-fit: cover;
}

.card-preview-popover img[hidden] {
  display: none;
}

.card-preview-meta {
  display: grid;
  gap: 2px;
  padding: 8px 3px 2px;
}

.card-preview-meta strong {
  color: #fffaf1;
  font-size: 0.86rem;
  line-height: 1.2;
}

.card-preview-meta span {
  color: #d9c892;
  font-size: 0.72rem;
  line-height: 1.25;
}

.card-preview-popover.is-loading,
.card-preview-popover.is-error {
  width: min(220px, calc(100vw - 24px));
}

.deck-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px;
}

.deck-actions .secondary-button,
.deck-actions .secondary-link {
  flex: 1 1 118px;
  text-align: center;
}

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

  .control-panel {
    position: static;
  }

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

@media (max-width: 760px) {
  .shell {
    padding: 12px;
  }

  .mast,
  .toolbar,
  .deck-hero,
  .deck-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .status-pill {
    width: 100%;
  }

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

  .deck-grid.is-single .deck-body {
    grid-template-columns: 1fr;
  }

  .anchor-art {
    width: min(220px, 100%);
  }

  .format-tabs,
  .button-row {
    flex-wrap: wrap;
  }
}
