:root {
  /* Decksmith — forge theme: charcoal & iron surfaces, molten ember accent. */
  --bg: #110f0e;
  --panel: #1b1816;
  --panel-2: #25211e;
  --border: #3a332e;
  --text: #f2ece6;
  --muted: #a99d92;
  --accent: #f0883e;        /* ember */
  --accent-hot: #ffb35c;    /* the bright core of the glow */
  --accent-ink: #1d0f05;
  --danger: #e5484d;
  --success: #6fcf7f;
  --amber: #f4b223;
  --amethyst: #8b4fa3;
  --emerald: #2b9a49;
  --ruby: #d1253a;
  --sapphire: #1f8ad0;
  --steel: #97a3ae;
  --radius: 10px;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --tint: color-mix(in srgb, var(--accent) 14%, transparent);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 420px at 50% -220px, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, textarea { font: inherit; color: inherit; }

.top {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  padding: 14px 24px; background: linear-gradient(#1f1b18, var(--panel));
}
/* a thin line of hot metal under the header */
.top::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent) 30%, var(--accent-hot) 50%, var(--accent) 70%, transparent);
  opacity: .7;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; flex: none; filter: drop-shadow(0 0 10px color-mix(in srgb, var(--accent) 45%, transparent)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.top h1 { margin: 0; font: 600 24px/1 var(--font-display); letter-spacing: .4px; color: var(--text); }
.top h1 .tld { color: var(--accent); font-weight: 400; }
.tagline { font-size: 12px; color: var(--muted); margin-top: 4px; letter-spacing: .3px; }
nav { display: flex; gap: 6px; }
.tab { background: none; border: 1px solid transparent; padding: 6px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.tab:hover { color: var(--text); }
.tab.active { border-color: color-mix(in srgb, var(--accent) 70%, transparent); color: var(--accent); background: var(--tint); }

main { max-width: 960px; margin: 0 auto; padding: 24px 16px 64px; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: inset 0 1px 0 rgba(255,255,255,.03); }
.label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 0 0 6px; }

input, textarea {
  width: 100%; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { font-family: ui-monospace, Menlo, monospace; font-size: 13px; resize: vertical; }
#deck-form .label { margin-top: 14px; }
#deck-form .label:first-child { margin-top: 0; }

/* autocomplete */
.combo { position: relative; }
.suggestions {
  position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px);
  list-style: none; margin: 0; padding: 4px; max-height: 360px; overflow-y: auto;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.suggestions li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.suggestions li.active, .suggestions li:hover { background: var(--border); }
.suggestions img { width: 34px; height: 47px; object-fit: cover; border-radius: 3px; background: var(--bg); flex: none; }
.suggestions .s-name { font-weight: 600; }
.suggestions .s-meta { font-size: 12px; color: var(--muted); }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 6px 4px 4px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px;
}
.chip img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; object-position: top; }
.chip button { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 4px; }
.chip button:hover { color: var(--danger); }
.clear-chips { background: none; border: 1px solid transparent; border-radius: 999px; padding: 4px 12px; cursor: pointer; color: var(--muted); font-size: 13px; }
.clear-chips:hover, .clear-chips:focus-visible { color: var(--danger); border-color: var(--border); outline: none; }

.mode-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.mode-row .label { margin: 0; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented button { background: var(--panel-2); border: none; padding: 7px 14px; cursor: pointer; color: var(--muted); }
.segmented button.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.summary { color: var(--muted); margin: 20px 2px 10px; }

/* deck cards */
.results { display: grid; gap: 12px; }
.pager { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin: 22px 0 8px; }
.pager button { min-width: 38px; padding: 7px 11px; border-radius: 8px; cursor: pointer; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); font-variant-numeric: tabular-nums; }
.pager button:hover:not(:disabled) { border-color: var(--accent); }
.pager button:disabled { opacity: .45; cursor: default; }
.pager button.current { opacity: 1; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.pager .gap { color: var(--muted); padding: 0 2px; }
.deck { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.deck-head { display: flex; align-items: center; gap: 12px; }
.deck-title { flex: 1; min-width: 0; }
.deck-title h2 { margin: 0; font-size: 17px; }
.meta { font-size: 13px; color: var(--muted); }
.meta a { color: var(--accent); }
.inks { display: flex; gap: 3px; }
.ink { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); }
.ink.Amber { background: var(--amber); } .ink.Amethyst { background: var(--amethyst); }
.ink.Emerald { background: var(--emerald); } .ink.Ruby { background: var(--ruby); }
.ink.Sapphire { background: var(--sapphire); } .ink.Steel { background: var(--steel); }
.match-badge { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--panel-2); color: var(--accent); white-space: nowrap; }
.match-badge:empty { display: none; }
.deck-actions button {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; cursor: pointer; white-space: nowrap;
}
.deck-actions button:hover { border-color: var(--accent); }
.matched-cards { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.matched-cards:empty { display: none; }
.matched-cards span { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--tint); color: var(--accent); }
.matched-cards span.missing { background: transparent; color: var(--muted); text-decoration: line-through; border: 1px dashed var(--border); }

.deck-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.danger { color: var(--danger); }

.form-actions { display: flex; align-items: center; gap: 14px; margin-top: 18px; }
.primary {
  background: linear-gradient(180deg, var(--accent-hot), var(--accent)); color: var(--accent-ink);
  border: none; border-radius: 8px; padding: 9px 18px; font-weight: 600; cursor: pointer;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 60%, black) inset, 0 4px 14px color-mix(in srgb, var(--accent) 25%, transparent);
}
.primary:hover { filter: brightness(1.06); }
.status { font-size: 14px; color: var(--muted); white-space: pre-wrap; }
.status.error { color: var(--danger); }
.status.ok { color: var(--emerald); }

.inline { display: flex; gap: 10px; }
.inline input { flex: 1; }
#import-status:not(:empty), #image-status:not(:empty) { display: block; margin-top: 10px; }
.dropzone {
  display: block; margin-top: 8px; padding: 22px; text-align: center; cursor: pointer;
  border: 2px dashed var(--border); border-radius: var(--radius); background: var(--panel-2); color: var(--muted);
}
.dropzone strong { color: var(--accent); }
.dropzone .hint { display: block; margin-top: 6px; }
.dropzone:hover, .dropzone:focus-visible, .dropzone.over { border-color: var(--accent); outline: none; }
.dropzone.busy { opacity: .6; pointer-events: none; }
.hint { font-size: 13px; color: var(--muted); margin: 12px 0 0; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.or { text-align: center; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .6px; margin: 18px 0; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.tab { white-space: nowrap; }

@media (max-width: 760px) {
  /* brand + account on the first row; tabs get their own scrollable row */
  .top { padding: 12px 16px 0; }
  .top nav { order: 3; width: calc(100% + 32px); margin: 0 -16px; padding: 6px 12px 10px; overflow-x: auto; scrollbar-width: none; }
  .top nav::-webkit-scrollbar { display: none; }
}
@media (max-width: 560px) {
  .deck-head { flex-wrap: wrap; }
  .deck-title { flex: 1 1 180px; }     /* keep the name readable; buttons wrap below */
  .tagline { display: none; }
  .brand-mark { width: 32px; height: 32px; }
  .top h1 { font-size: 21px; }
}

.about-title { font: 600 20px/1.2 var(--font-display); margin: 0 0 14px; }
.panel + .panel { margin-top: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-value { display: block; font-size: 28px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--muted); }
.about h3 { font-size: 15px; margin: 18px 0 6px; }
.about h3:first-of-type { margin-top: 0; }
.about ul { margin: 0; padding-left: 20px; line-height: 1.6; }
.about a { color: var(--accent); }

/* accounts */
[hidden] { display: none !important; }
.account { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.who { color: var(--text); }
.role { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; padding: 1px 7px; border-radius: 999px; background: var(--tint); color: var(--accent); }
.link { background: none; border: none; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: var(--accent); }
.primary.small { padding: 6px 14px; }
.count { display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; }

.dialog { width: min(420px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); color: var(--text); }
.dialog::backdrop { background: rgba(8, 5, 3, .72); backdrop-filter: blur(2px); }
.dialog h2 { margin: 0 0 16px; font: 600 22px/1.2 var(--font-display); }
.dialog .label { margin-top: 12px; }
.dialog .status:not(:empty) { margin: 12px 0 0; }
.dialog .form-actions { flex-wrap: wrap; }
.dialog .close { margin-left: auto; }

.section-title { font: 600 20px/1.2 var(--font-display); margin: 8px 0 0; }
.section-title ~ .section-title { margin-top: 32px; }
.notice { margin: 0 0 18px; padding: 12px 16px; border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); background: color-mix(in srgb, var(--accent) 7%, transparent); font-size: 14px; }

.save { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; cursor: pointer; white-space: nowrap; color: var(--muted); }
.save:hover { border-color: var(--accent); color: var(--text); }
.save.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.status-badge { font-size: 12px; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.status-badge.pending { background: var(--tint); color: var(--accent); }
.status-badge.approved { background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); }

.about-intro { font-size: 16px; line-height: 1.6; margin: 0 0 18px; }
.about-intro strong { font-family: var(--font-display); font-size: 18px; color: var(--accent); }
.deck h2 { font-family: var(--font-display); letter-spacing: .2px; }

/* clone & edit */
.clone, .edit { background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; cursor: pointer; white-space: nowrap; color: var(--muted); }
.clone:hover, .edit:hover { border-color: var(--accent); color: var(--text); }
.status-badge.private { background: color-mix(in srgb, var(--steel) 18%, transparent); color: #c9d1d8; }
.deck > .deck-actions { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.deck-actions .publish { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.dialog.wide { width: min(640px, calc(100vw - 32px)); }
.section-hint { margin: 4px 0 0; }
.count-note { text-transform: none; letter-spacing: 0; color: var(--muted); }

/* similar decks */
.similar-head { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.similar-more { display: block; margin: 12px auto 0; }
.status-badge.original { background: var(--tint); color: var(--accent-hot); }

/* ---------- deck editor ---------- */
body.editing main { max-width: 1440px; }
body.deck-open main { max-width: 1240px; }
.editor > .panel + .panel { margin-top: 0; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
select {
  font: inherit; color: inherit; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
}
select:focus { border-color: var(--accent); outline: none; }

.ed-filters { position: sticky; top: 0; z-index: 2; background: var(--panel); padding-bottom: 10px; margin: -18px -18px 0; padding: 18px 18px 10px; border-radius: var(--radius) var(--radius) 0 0; }
.ed-chip-row, .ed-select-row { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 10px; align-items: center; }
.ed-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); font-size: 13px;
}
.ed-chip .ink { width: 11px; height: 11px; border-width: 1px; }
.ed-chip.cost { min-width: 34px; justify-content: center; font-variant-numeric: tabular-nums; }
.ed-chip[aria-pressed="true"] { border-color: var(--accent); color: var(--text); background: var(--tint); }
.ed-check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); cursor: pointer; }
.ed-check input { width: auto; accent-color: var(--accent); }
.ed-result-row { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }

.ed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; padding-top: 6px; }
.ed-grid .empty { grid-column: 1 / -1; }
.ed-card { position: relative; cursor: pointer; border-radius: 9px; transition: transform .12s ease; user-select: none; }
.ed-card img { display: block; width: 100%; aspect-ratio: 367 / 512; object-fit: cover; border-radius: 9px; background: var(--panel-2); box-shadow: 0 3px 10px rgba(0,0,0,.35); }
.ed-card:hover { transform: translateY(-2px); }
.ed-card.in-deck img { outline: 2px solid var(--accent); outline-offset: 2px; }
.ed-card.over img { outline-color: var(--danger); }
.ed-qty {
  position: absolute; top: 6px; right: 6px; min-width: 30px; padding: 2px 7px; border-radius: 999px; text-align: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13px; box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
.ed-qty:empty { display: none; }
.ed-card.over .ed-qty { background: var(--danger); color: #fff; }
.ed-tile-actions { position: absolute; left: 6px; right: 6px; bottom: 6px; display: flex; justify-content: space-between; opacity: 0; transition: opacity .12s; }
.ed-card:hover .ed-tile-actions, .ed-card:focus-within .ed-tile-actions { opacity: 1; }
.ed-tile-actions button, .ed-row button {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border); background: rgba(20,17,15,.9); color: var(--text);
  font-size: 18px; line-height: 1; cursor: pointer;
}
.ed-tile-actions button:hover, .ed-row button:hover { border-color: var(--accent); color: var(--accent); }
.ed-card:not(.in-deck) .minus { visibility: hidden; }
#ed-sentinel { height: 1px; }

.ed-deck { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; }
.ed-deck .label { margin-top: 12px; }
.ed-origin:empty { display: none; }
.ed-origin { margin: 0 0 4px; }
.ed-dirty { color: var(--accent); text-transform: none; letter-spacing: 0; }
.ed-stats { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; align-items: center; margin-top: 16px; }
.ed-stats .hint { grid-column: 1 / -1; margin: 0; }
.ed-count { font-size: 15px; color: var(--muted); }
.ed-count strong { font: 600 30px/1 var(--font-display); color: var(--danger); }
.ed-count.ok strong { color: var(--success); }
.ed-inks-used { display: flex; align-items: center; gap: 4px; justify-content: flex-end; font-size: 14px; color: var(--muted); }

.ed-curve { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; height: 92px; margin-top: 14px; padding-top: 4px; }
.ed-bar { display: grid; grid-template-rows: 16px 1fr 16px; align-items: end; text-align: center; font-size: 11px; color: var(--muted); }
.ed-bar-fill { display: block; min-height: 2px; border-radius: 3px 3px 0 0; background: linear-gradient(180deg, var(--accent-hot), var(--accent)); }
.ed-bar-n { align-self: end; color: var(--text); }

.ed-warnings { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.ed-warnings li { padding: 7px 10px; border-radius: 8px; border-left: 3px solid; }
.ed-warnings .warn { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.ed-warnings .info { border-color: var(--border); background: var(--panel-2); color: var(--muted); }
.ed-warnings .ok { border-color: var(--success); background: color-mix(in srgb, var(--success) 10%, transparent); }

.ed-modes { margin: 16px 0 10px; }
.ed-modes button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.ed-group { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 12px 0 6px; }
.ed-group:first-child { margin-top: 0; }
.ed-group-rows { display: grid; gap: 4px; }
.ed-row {
  position: relative; display: grid; grid-template-columns: 54px 22px 1fr auto auto; align-items: center; gap: 8px;
  padding: 4px 6px 4px 4px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--border); font-size: 14px;
}
.ed-row.over { border-color: var(--danger); }
.ed-row-art { height: 30px; border-radius: 5px; background-size: 130%; background-position: 50% 22%; }
.ed-row-qty { font-weight: 700; text-align: center; color: var(--accent); }
.ed-row-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-row-name .ink { display: inline-block; width: 9px; height: 9px; border-width: 1px; margin-right: 2px; vertical-align: 0; }
.ed-row button { width: 26px; height: 26px; font-size: 16px; }
#ed-textarea { margin-top: 2px; }
.ed-actions { position: sticky; bottom: -18px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 16px -18px -18px; padding: 14px 18px; background: var(--panel); border-top: 1px solid var(--border); }
.primary:disabled { opacity: .5; cursor: default; filter: none; }

.ed-preview { position: fixed; left: 0; top: 0; z-index: 50; width: 300px; pointer-events: none; }
.ed-preview img { display: block; width: 100%; border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.06); }

@media (max-width: 980px) {
  .editor { grid-template-columns: 1fr; }
  .ed-deck { position: static; max-height: none; order: -1; }
  .ed-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
  .ed-tile-actions { opacity: 1; }
  .ed-filters { position: static; }   /* too tall to pin on small screens */
}

/* sharing */
.share-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; }
.share-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.share-head h2 { margin: 0; overflow-wrap: anywhere; }
.share-h { font: 600 16px/1.2 var(--font-display); color: var(--accent); margin: 22px 0 8px; }
.share-hint { margin: 0 0 8px; }
.share-image { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); padding: 8px; min-height: 120px; display: grid; place-items: center; }
.share-image img { display: block; max-width: 100%; border-radius: 6px; }
.share-image img:not([src]) { display: none; }
.share-image .status:empty { display: none; }
.share-dialog .form-actions { margin-top: 10px; }
.share-dialog .inline input { font-size: 14px; }
.deck-actions .share { color: var(--accent); }
.back-row { margin: 0 0 12px; }

/* relevance meter (similar decks) */
.match-badge.relevance { display: inline-flex; align-items: center; gap: 7px; background: var(--panel); border: 1px solid var(--border); color: var(--text); cursor: help; }
.relevance .bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.relevance .bars i { width: 4px; border-radius: 1px; background: var(--border); }
.relevance .bars i:nth-child(1) { height: 4px; } .relevance .bars i:nth-child(2) { height: 6px; }
.relevance .bars i:nth-child(3) { height: 8px; } .relevance .bars i:nth-child(4) { height: 10px; } .relevance .bars i:nth-child(5) { height: 12px; }
.relevance.r1 .bars i:nth-child(-n+1), .relevance.r2 .bars i:nth-child(-n+2), .relevance.r3 .bars i:nth-child(-n+3),
.relevance.r4 .bars i:nth-child(-n+4), .relevance.r5 .bars i:nth-child(-n+5) { background: var(--accent); }
.relevance.r5 .bars i { background: var(--accent-hot); }
.relevance.r1 .r-label, .relevance.r2 .r-label { color: var(--muted); }
.relevance.r4 .r-label, .relevance.r5 .r-label { color: var(--accent-hot); }

/* deck summary cards */
.deck-link { color: inherit; text-decoration: none; }
.deck-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.view-btn {
  white-space: nowrap; text-decoration: none; padding: 5px 12px; border-radius: 6px; font-weight: 600;
  color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent); background: var(--tint);
}
.view-btn:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.deck > .deck-actions { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

/* deck page */
.deck-page { display: grid; gap: 18px; }
.deck-page > .panel + .panel { margin-top: 0; }
.dp-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dp-title-row .inks .ink { width: 18px; height: 18px; }
.dp-name { margin: 0; font: 600 32px/1.15 var(--font-display); letter-spacing: .2px; }
.dp-head .meta { margin-top: 8px; color: var(--muted); font-size: 14px; }
.dp-head .meta a { color: var(--accent); }
.dp-notes { margin: 10px 0 0; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--panel-2); border-radius: 0 8px 8px 0; white-space: pre-wrap; }
.dp-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.dp-actions button {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 7px 14px; cursor: pointer; white-space: nowrap;
}
.dp-actions button:hover { border-color: var(--accent); }
.dp-actions .save.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.dp-actions .share, .dp-actions .publish { color: var(--accent); }

.dp-stats { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(260px, 2fr); gap: 24px; align-items: end; }
.dp-count { color: var(--muted); }
.dp-count strong { font: 600 40px/1 var(--font-display); color: var(--text); margin-right: 4px; }
.dp-sub { margin: 6px 0 0; }
.dp-types { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.dp-type { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); }
.dp-curve { margin-top: 0; height: 110px; }

.dp-group { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; margin: 22px 0 10px; }
.dp-group:first-child { margin-top: 0; }
.dp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.dp-card { position: relative; border-radius: 9px; }
.dp-card img { display: block; width: 100%; aspect-ratio: 367 / 512; object-fit: cover; border-radius: 9px; background: var(--panel-2); box-shadow: 0 3px 10px rgba(0,0,0,.35); }
.dp-card.hit img { outline: 2px solid var(--accent-hot); outline-offset: 2px; }
.dp-missing { display: grid; place-items: center; aspect-ratio: 367 / 512; padding: 8px; text-align: center; border-radius: 9px; background: var(--panel-2); color: var(--muted); font-size: 13px; }
.dp-similar .section-title { margin-top: 10px; }
.dp-similar > .hint { margin: 4px 0 12px; }
.similar-body .similar-head { margin: 0 0 10px; font-size: 14px; color: var(--muted); }

@media (max-width: 640px) {
  .dp-stats { grid-template-columns: 1fr; }
  .dp-name { font-size: 26px; }
  .dp-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
}

.share-qr { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; margin-top: 12px; }
.share-qr canvas { width: 140px; height: 140px; border-radius: 10px; image-rendering: pixelated; }
.share-qr .hint { margin: 0 0 6px; }
.share-qr-toggle { margin-top: 10px; }
@media (max-width: 560px) { .share-qr { grid-template-columns: 1fr; justify-items: start; } }

/* Secondary buttons in dialogs and the editor (buttons without a style of their own). */
.dialog button:not(.primary):not(.link), #ed-apply {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 16px; cursor: pointer; color: var(--text);
}
.dialog button:not(.primary):not(.link):hover:not(:disabled), #ed-apply:hover { border-color: var(--accent); }
.dialog button:disabled { opacity: .5; cursor: default; }

/* jobs (admin) */
.jobs-list { display: grid; gap: 16px; margin-top: 14px; }
.job.running { border-color: color-mix(in srgb, var(--accent) 60%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }
.job-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.job-title { margin: 0; font: 600 18px/1.2 var(--font-display); }
.job-desc { margin: 6px 0 0; max-width: 70ch; }
.job-state { font-size: 12px; padding: 3px 10px; border-radius: 999px; white-space: nowrap; border: 1px solid var(--border); color: var(--muted); }
.job-state.on { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, transparent); }
.job-state.running { color: var(--accent-hot); border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.job-row { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; }
.job-field { display: grid; gap: 4px; }
.job-field .label { margin: 0; }
.job-num { width: 120px; }
.job-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 14px 0 0; font-size: 14px; }
.job-facts dt { color: var(--muted); }
.job-facts dd { margin: 0; }
.job-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 14px; }
.job-btn { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 14px; cursor: pointer; }
.job-btn:hover { border-color: var(--accent); }
.job-runs { margin-top: 12px; display: grid; gap: 6px; }
.job-run { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.job-run summary { cursor: pointer; }
.job-log { margin: 10px 0 2px; max-height: 320px; overflow: auto; font: 12px/1.5 ui-monospace, Menlo, monospace; white-space: pre-wrap; color: var(--muted); }
.run-status { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 1px 7px; border-radius: 999px; }
.run-status.ok { background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); }
.run-status.error { background: color-mix(in srgb, var(--danger) 16%, transparent); color: var(--danger); }
.run-status.running { background: var(--tint); color: var(--accent-hot); }
.run-status.interrupted { background: var(--panel); color: var(--muted); border: 1px solid var(--border); }

/* sign-up email + toast */
.auth-hint { margin: 6px 0 0; }
.auth-resend { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
#auth-sent-dialog p { line-height: 1.55; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; max-width: min(560px, calc(100vw - 32px));
  padding: 12px 18px; border-radius: 10px; background: var(--panel); border: 1px solid var(--border); box-shadow: 0 12px 40px rgba(0,0,0,.5); font-size: 15px;
}
.toast.ok { border-color: color-mix(in srgb, var(--success) 55%, transparent); }
.toast.error { border-color: color-mix(in srgb, var(--danger) 55%, transparent); }

.dp-cards-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.dp-cards-head .label { margin: 0; }

/* users (admin) */
.users-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.users-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 14px; }
.users-toolbar input[type=search] { flex: 1 1 260px; width: auto; }
.users-table-wrap { padding: 0; overflow-x: auto; }
.users-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.users-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.users-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.users-table tbody tr { cursor: pointer; }
.users-table tbody tr:hover, .users-table tbody tr:focus-visible { background: var(--panel-2); outline: none; }
.users-table tbody tr:last-child td { border-bottom: none; }
.users-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.users-table .email { color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.users-table .empty { text-align: center; padding: 30px; }
.you { margin-left: 8px; font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-weight: 400; vertical-align: 1px; }
.user-status { font-size: 12px; padding: 2px 9px; border-radius: 999px; white-space: nowrap; font-weight: 600; }
.user-status.active { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
.user-status.pending { background: var(--tint); color: var(--accent-hot); }
.user-status.disabled { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
#ud-title .user-status { font: 600 12px/1.6 system-ui, sans-serif; vertical-align: 4px; }
.ud-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-top: 8px; }
.ud-grid label { display: grid; gap: 4px; }
.ud-grid .label { margin: 0; }
.ud-grid .ed-check { grid-column: 1 / -1; display: flex; }
.dialog button.danger:not(.primary):not(.link) { color: var(--danger); }
.dialog button.danger:not(.primary):not(.link):hover { border-color: var(--danger); }
@media (max-width: 560px) { .ud-grid { grid-template-columns: 1fr; } }

/* Close "×" in a dialog's top-right corner */
.dialog button.dialog-x:not(.primary):not(.link) {
  position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; display: grid; place-items: center;
  padding: 0; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--muted);
  font-size: 26px; line-height: 1; cursor: pointer;
}
.dialog button.dialog-x:not(.primary):not(.link):hover, .dialog button.dialog-x:not(.primary):not(.link):focus-visible { color: var(--text); border-color: var(--border); background: var(--panel-2); outline: none; }
.dialog:has(> .dialog-x) h2 { padding-right: 36px; } /* keep long titles clear of the × */
