:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --text: #1d1d1f;
  --muted: #5f6368;
  --accent: #1f5fae;
  --border: #d9d6cf;
  --header-bg: #16202c;
  --header-text: #f3f1ec;
  --error: #a3261b;
  --keyword: #8a5a00;
  --vocab: #7a6200;
  --card-link: #1f5fae;
  /* The "no" of a statistics meter: its track, a light step of the accent, which marks "yes". */
  --stat-no: #c3d4ea;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121418;
    --surface: #1b1e24;
    --text: #e8e6e1;
    --muted: #a0a4ab;
    --accent: #7fb0f0;
    --border: #2e333b;
    --header-bg: #0b0e13;
    --header-text: #e8e6e1;
    --error: #f08a7e;
    --keyword: #f0c060;
    --vocab: #f3dc7c;
    --card-link: #7fb0f0;
    --stat-no: #33465f;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    16px/1.5 system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}

a {
  color: var(--accent);
}

code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.92em;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 10px 16px;
  background: var(--header-bg);
  color: var(--header-text);
}

.site-header a {
  color: var(--header-text);
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
}

.logo {
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
}

.search {
  display: flex;
  flex: 1 1 320px;
  max-width: 720px;
  gap: 6px;
}

.search input[type="search"] {
  flex: 1;
  /* Without a width, the field's intrinsic size would keep the form wider than a phone screen. */
  width: 0;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  font: inherit;
}

.search-scope {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--header-text);
  font-size: 0.9rem;
  white-space: nowrap;
  cursor: pointer;
}

.search-scope input {
  margin: 0;
}

/* On phones the search field shares the logo's line, and the nav gets the second. */
@media (max-width: 640px) {
  .site-header {
    column-gap: 12px;
    padding-inline: 12px;
  }

  .search {
    flex-basis: 0;
  }

  .site-header nav {
    flex-basis: 100%;
    column-gap: 8px;
  }
}

/* Too narrow for the whole nav on one line: the footer links the syntax too. */
@media (max-width: 399px) {
  .site-header .syntax-link {
    display: none;
  }
}

/* Beats the generic `.site-header button` below, which would paint it as a light surface. */
.site-header .search button {
  padding: 8px 14px;
  border-color: transparent;
  background: rgb(255 255 255 / 0.12);
  color: var(--header-text);
}

.site-header .search button:hover {
  background: rgb(255 255 255 / 0.22);
}

main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px;
}

.notice {
  color: var(--muted);
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  padding: 24px 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer a {
  color: inherit;
}

.prose {
  max-width: 680px;
  margin: 0 auto;
  line-height: 1.55;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  color: var(--muted);
}

.toolbar .summary {
  margin: 0;
}

.sort {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.sort select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  font: inherit;
}

.sort button {
  padding: 6px 12px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.notice.error {
  color: var(--error);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(45%, 200px), 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card-grid img {
  display: block;
  width: 100%;
  height: auto;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 16px;
}

.home {
  max-width: 720px;
  margin: 32px auto;
}

.examples {
  padding-left: 1.2em;
}

.card-row {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  margin-bottom: 24px;
}

.card-image {
  display: block;
  width: 100%;
  height: auto;
}

@media (max-width: 640px) {
  .card-row {
    grid-template-columns: 1fr;
  }

  .card-image {
    max-width: 340px;
    margin: 0 auto;
  }
}

.card-text {
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.card-text h1,
.card-text h2 {
  margin: 0 0 4px;
  font-size: 1.5rem;
}

.leveled-up {
  font-size: 0.75em;
  font-weight: normal;
  color: var(--muted);
}

.type-line,
.artist {
  color: var(--muted);
}

.level-up .label {
  font-weight: 600;
  font-variant: small-caps;
  letter-spacing: 0.04em;
  color: var(--keyword);
}

.flavor {
  font-style: italic;
  color: var(--muted);
}

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 12px;
  margin: 12px 0;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
}

/* Data Dragon's text styles */

.text-keyword {
  font-weight: 600;
  color: var(--keyword);
}

.text-vocab {
  font-weight: 600;
  color: var(--vocab);
}

.text-associatedcard {
  color: var(--card-link);
}

.nobr {
  white-space: nowrap;
}

/* Tooltips: shown on hover and focus without JavaScript; tooltips.js keeps them inside the
   window and adds long press on touch screens (.tip-open). */

.has-tip {
  position: relative;
}

.term {
  cursor: help;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

.card-ref {
  text-decoration: none;
  -webkit-touch-callout: none;
}

/* The default outline would also frame the preview image. */
.card-ref:focus-visible {
  outline: none;
  text-decoration: underline 2px;
}

.tip {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 10;
  /* The tip is a child of its trigger, so pointing at it would keep the trigger's :hover alive. */
  pointer-events: none;
  width: max-content;
  max-width: min(300px, 80vw);
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.25);
  font-size: 0.9rem;
  font-weight: normal;
  white-space: normal;
  text-align: left;
}

.card-tip {
  width: 240px;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
}

.card-tip img {
  display: block;
  width: 100%;
  height: auto;
}

@media (hover: hover) {
  .has-tip:hover > .tip {
    display: block;
  }
}

.has-tip:focus > .tip,
.has-tip.tip-open > .tip {
  display: block;
}

/* tooltips.js measures tips through this before they're shown. */
.has-tip.tip-measure > .tip {
  display: block;
  visibility: hidden;
}

.tip-left > .tip {
  left: auto;
  right: 0;
}

.tip-above > .tip {
  top: auto;
  bottom: 100%;
}

@media (hover: none) {
  .has-tip {
    user-select: none;
  }
}

.docs table {
  width: 100%;
  border-collapse: collapse;
}

.docs th,
.docs td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

@media (max-width: 640px) {
  .docs table,
  .docs tbody,
  .docs tr,
  .docs td {
    display: block;
  }

  .docs thead {
    display: none;
  }
}

/* Advanced search */

.advanced {
  max-width: 960px;
  margin: 0 auto;
}

.advanced select,
.advanced input[type="text"],
.advanced input[type="number"] {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  font: inherit;
}

.advanced input[type="number"] {
  width: 6em;
}

.advanced button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.advanced button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

/* The form's first submit button, which Enter clicks; see pages/advanced.ts. */
.default-action {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.adv-group,
.adv-options {
  margin: 0;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.adv-group legend,
.adv-options legend {
  padding: 0 4px;
  color: var(--muted);
}

.adv-group + .adv-group {
  margin-top: 16px;
}

/* Legends read "Any of", then "And any of". */
.adv-group + .adv-group > legend::before {
  content: "and ";
}

.adv-group > legend::first-letter {
  text-transform: uppercase;
}

.adv-rows {
  margin: 0;
  padding: 0;
  list-style: none;
}

.adv-row,
.adv-controls,
.adv-options,
.adv-group-actions,
.adv-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.adv-row {
  padding: 6px 0;
}

.adv-row + .adv-row {
  border-top: 1px dashed var(--border);
}

.adv-row + .adv-row::before {
  content: "or";
  flex-basis: 100%;
  color: var(--muted);
  font-variant: small-caps;
}

.adv-controls input[type="text"] {
  flex: 1 1 12em;
  min-width: 0;
}

.adv-controls {
  flex: 1 1 16em;
  min-width: 0;
}

.adv-group-actions,
.adv-form-actions {
  margin: 8px 0 0;
}

.adv-form-actions {
  margin: 16px 0;
}

.adv-options {
  gap: 8px 16px;
}

.adv-options label {
  flex-basis: 100%;
}

.adv-options label:has(select) {
  flex-basis: auto;
}

/* Deck builder: hidden without JavaScript. Beside the page from 900px (panelBesidePage in
   src/deck/page.ts), covering it below. */

:root {
  --deck-width: 380px;
}

@media (min-width: 900px) {
  .deck-open body {
    padding-right: var(--deck-width);
  }
}

.site-header button,
.deck-panel button,
.deck-actions button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.deck-panel button:disabled,
.deck-panel select:disabled,
.deck-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.site-header .deck-toggle {
  padding: 2px 10px;
  border-color: transparent;
  background: rgb(255 255 255 / 0.12);
  color: var(--header-text);
}

.deck-toggle[aria-expanded="true"] {
  background: var(--accent);
}

.deck-size {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.deck-noscript {
  color: var(--header-text);
  opacity: 0.7;
}

.deck-panel {
  position: fixed;
  inset: 0 0 0 auto;
  /* Above the page's tooltips (.tip), which it otherwise follows in painting order. */
  z-index: 20;
  width: var(--deck-width);
  max-width: 100%;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  border: 0;
  border-left: 1px solid var(--border);
}

/* The head stays put; the cards below it scroll. */
.deck-panel[open] {
  display: flex;
  flex-direction: column;
}

.deck-panel-body {
  flex: 1;
  min-height: 0;
  padding-bottom: 16px;
  overflow-y: auto;
}

@media (max-width: 899px) {
  .deck-panel {
    width: 100%;
    border-left: 0;
  }
}

.deck-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* The deck's name, edited in place: a heading until it's focused. */
.deck-panel .deck-name {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 2px 4px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  text-overflow: ellipsis;
}

.deck-panel .deck-name:hover {
  border-color: var(--border);
}

.deck-panel .deck-name:focus {
  border-color: var(--accent);
  background: var(--bg);
  outline: none;
}

.deck-menu {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}

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

.deck-menu summary {
  color: var(--muted);
  cursor: pointer;
}

.deck-menu-list {
  margin: 6px 0;
  padding: 0;
  list-style: none;
}

.deck-menu-list button {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.deck-menu-list button:hover {
  background: var(--bg);
}

.deck-menu-list button[aria-current="true"] {
  font-weight: 600;
  color: var(--accent);
}

.deck-menu-regions {
  display: flex;
  flex: none;
  gap: 2px;
  min-width: 38px;
  --icon-size: 18px;
}

.deck-menu-name {
  flex: 1;
}

.deck-menu-size {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.deck-menu-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.deck-total {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.deck-status,
.deck-empty {
  margin: 12px;
  color: var(--muted);
}

.deck-list {
  margin: 0;
  padding: 4px 0;
  list-style: none;
}

.deck-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 12px;
}

.deck-cost {
  min-width: 1.6em;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.deck-card-cell {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.deck-card {
  color: inherit;
}

.deck-row-problem .deck-card {
  color: var(--error);
}

.deck-card-problems {
  color: var(--error);
  font-size: 0.8rem;
}

.deck-card-problems:empty {
  display: none;
}

.deck-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

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

.deck-summary select {
  margin-left: 6px;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  font: inherit;
}

.deck-format-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.deck-region-icons {
  display: flex;
  gap: 4px;
  margin-left: auto;
  --icon-size: 22px;
}

/* The origin icons' previews: a flex box like the plain icons, so they line up. */
.deck-region-icons > .has-tip {
  display: flex;
}

/* One square of the image of all region icons (src/card-images.ts), picked by --row. */
.region-icon {
  display: inline-block;
  flex: none;
  width: var(--icon-size, 18px);
  height: var(--icon-size, 18px);
  background-repeat: no-repeat;
  background-size: 100% auto;
  background-position: 0 calc(var(--row, 0) * var(--icon-size, 18px) * -1);
  vertical-align: middle;
}

.region-icon-text {
  width: auto;
  height: auto;
  color: var(--muted);
  font-size: 0.8rem;
}

/* Room for two icons, so card names line up. */
.deck-card-regions {
  display: flex;
  flex: none;
  gap: 2px;
  width: calc(2 * 18px + 2px);
}

.deck-problems {
  margin: 0;
  padding-left: 1.2em;
  color: var(--error);
}

.deck-problems.deck-legal {
  padding-left: 0;
  list-style: none;
  color: var(--accent);
}

.deck-row .deck-copies {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.deck-row button {
  min-width: 2em;
  padding: 0 6px;
}

.deck-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

/* Shown as soon as the head script marks the page as having JavaScript, not only once
   client/deck.ts runs, so the header and card text don't shift. */
.deck-builder .deck-toggle[hidden] {
  display: inline-block;
}

.deck-builder .search-scope[hidden] {
  display: flex;
}

.deck-builder .deck-actions[hidden] {
  display: flex;
}

.deck-actions .deck-copies {
  color: var(--muted);
}

/* Touch screens can't drag cards. */
@media not (pointer: fine) {
  .deck-drag-hint {
    display: none;
  }
}

/* Where a dragged card can be dropped to add it. */
.deck-panel.deck-drop .deck-panel-body {
  outline: 3px dashed var(--accent);
  outline-offset: -3px;
}

.site-header .deck-toggle.deck-drop {
  outline: 2px dashed var(--header-text);
  outline-offset: 0px;
}

/* Deck codes: in the deck panel, and the shared deck page (pages/deck.ts). */

.deck-codes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

.deck-code-box,
.deck-code-open {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.deck-code-box[hidden] {
  display: none;
}

.deck-code-box label {
  display: flex;
  flex: 1 1 12em;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.deck-code-box input,
.deck-code-open input {
  flex: 1;
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  font:
    0.85rem ui-monospace,
    "SFMono-Regular",
    Menlo,
    monospace;
}

.deck-code-open button,
.deck-code-box button {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

/* The shared page's buttons need JavaScript; shown as soon as the head script runs. */
.deck-builder .deck-code-box button[hidden] {
  display: inline-block;
}

.shared-deck {
  max-width: 560px;
  margin: 0 auto;
}

.shared-deck-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.shared-deck-head h1 {
  margin: 0;
}

.shared-deck .deck-legal {
  color: var(--accent);
}

.shared-deck .deck-illegal {
  color: var(--error);
}

.shared-deck .deck-list {
  margin: 12px 0;
  padding: 8px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.shared-deck .deck-row {
  padding: 3px 12px;
}

/* The dialogs creating a deck and importing a deck code (pages/deck-builder.ts). */

.deck-import form,
.deck-new form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: min(22rem, 80vw);
}

.deck-import form > label,
.deck-new-name-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.deck-import form > label input,
.deck-new-name {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  font: inherit;
}

.deck-place {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  border: 0;
}

.deck-place legend {
  padding: 0;
  margin-bottom: 4px;
}

.deck-import-error {
  margin: 0;
  color: var(--error, inherit);
}

.deck-import-actions,
.deck-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.deck-import input:disabled,
.deck-import-actions button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.deck-import-actions button,
.deck-dialog-actions button {
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.deck-import-actions .primary,
.deck-dialog-actions .primary {
  font-weight: 600;
  border-color: currentColor;
}

/* The online decks' parts of the panel, their dialogs and their page (client/deck-online.ts). */

.deck-online {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

.deck-online-text {
  margin: 0 0 8px;
  color: var(--muted);
}

.deck-online-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.deck-panel .deck-online-actions button {
  padding: 4px 10px;
}

.deck-menu-group {
  margin: 8px 8px 2px;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.deck-menu-group:has(.deck-menu-refresh) {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.deck-menu-list .deck-menu-refresh {
  width: auto;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: inherit;
  font-size: 1rem;
  line-height: 1.4;
  cursor: pointer;
}

.deck-menu-list .deck-menu-refresh:hover,
.deck-menu-list .deck-menu-refresh:focus-visible {
  border-color: var(--border);
}

.deck-menu-refresh:disabled {
  opacity: 0.5;
  cursor: progress;
}

.deck-menu-none {
  padding: 4px 8px;
  color: var(--muted);
  font-style: italic;
}

.deck-menu-list li[draggable="true"] {
  border-radius: 6px;
}

.deck-menu-list .drop-before {
  box-shadow: 0 -2px 0 var(--accent);
}

.deck-menu-list .drop-after {
  box-shadow: 0 2px 0 var(--accent);
}

.deck-menu-list .drop-into {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.deck-menu-tag,
.deck-read-only-tag {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: normal;
}

.deck-share-dialog,
.deck-confirm,
.deck-new {
  max-width: min(32rem, calc(100vw - 32px));
}

.deck-share-dialog h2 {
  margin-top: 0;
  font-size: 1.15rem;
}

.deck-share-dialog h3 {
  font-size: 1rem;
}

.deck-share-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.deck-share-head h3 {
  margin: 14px 0 4px;
}

/* Right-aligned, so the tips open leftwards. */
.deck-share-dialog .tip {
  left: auto;
  right: 0;
}

.deck-dialog-actions .deck-share-privacy {
  align-self: center;
  font-size: 0.9rem;
}

.deck-share-dialog section[hidden] {
  display: none;
}

.deck-link-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 10px 0;
}

.deck-link-box[hidden] {
  display: none;
}

.deck-link-box label {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.deck-link-box input {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  font:
    0.85rem ui-monospace,
    "SFMono-Regular",
    Menlo,
    monospace;
}

.deck-link-box button,
.deck-visit {
  padding: 4px 10px;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.deck-confirm form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.deck-confirm p {
  margin: 0;
}

.deck-confirm-online[hidden] {
  display: none;
}

.online-deck-actions {
  align-items: center;
  margin-top: 8px;
}

.deck-import-name-line {
  display: flex;
  align-items: center;
  min-height: 22px;
}

/* Statistics (pages/stats.ts, the deck page and the deck panel). Charts are drawn by CSS alone;
   their tables also hold every count as text (src/stats/chart.ts). */

.stats {
  max-width: 960px;
  margin: 0 auto;
}

.stat-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.stat-form label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-filter {
  flex: 1 1 260px;
}

.stat-form input {
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: inherit;
  font: inherit;
}

.stat-filter input {
  flex: 1;
}

.stat-target {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-target input {
  width: 10em;
}

/* Also in the deck panel, whose buttons are styled otherwise. */
.stat-help,
.deck-panel .stat-help {
  display: inline-grid;
  place-items: center;
  flex: none;
  line-height: 1;
  width: 1.7em;
  height: 1.7em;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: help;
}

.stat-help > .tip {
  width: 300px;
}

.stat-help-target:not(:empty) {
  display: block;
  margin-top: 6px;
  color: var(--text);
}

.stat-form button[type="submit"],
.deck-panel .stat-form button[type="submit"] {
  padding: 6px 14px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.stat-chart {
  margin-top: 16px;
}

.stat-total {
  color: var(--muted);
}

.stat-count {
  display: block;
  color: var(--text);
  font-size: 3rem;
  font-weight: 600;
  line-height: 1.1;
}

.stat-count a {
  color: inherit;
  text-decoration: none;
}

.stat-bars,
.stat-legend {
  border-collapse: collapse;
}

.stat-bars {
  width: 100%;
}

.stat-bars th,
.stat-bars td,
.stat-legend th,
.stat-legend td {
  padding: 3px 12px 3px 0;
  font-weight: normal;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.stat-bars thead th,
.stat-legend thead th {
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.stat-bars tbody th {
  width: 1%;
  min-width: 2.5em;
  max-width: 12em;
}

.stat-track {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Leaves room for the count beside the longest bar. */
.stat-bar {
  flex: 0 0 calc(var(--share) * (100% - 5ch));
  height: 16px;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
}

.stat-meter-chart {
  max-width: 480px;
}

.stat-meter {
  display: flex;
  height: 16px;
  margin-bottom: 12px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--stat-no);
}

.stat-meter-yes {
  width: var(--yes);
  background: var(--accent);
}

.stat-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 2px;
}

.stat-swatch.stat-yes {
  background: var(--accent);
}

.stat-swatch.stat-no {
  background: var(--stat-no);
}

.deck-stats {
  margin-top: 16px;
}

.deck-stats > summary {
  font-weight: 600;
  cursor: pointer;
}

.deck-stats > .stat-form {
  margin-top: 8px;
}

.deck-panel .deck-stats {
  margin: 0;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

.deck-panel .stat-chart {
  margin-top: 8px;
}

.deck-panel .stat-count {
  font-size: 2rem;
}
