/* "Graphite" dark-only theme (design handoff 2026-07-20).
   Single accent is gold; links are blue; never multi-color gradients. */
:root {
  color-scheme: dark;
  --bg: #121318;        /* page (near-black graphite, NOT pure #000) */
  --panel: #1a1c24;     /* panel/card surface */
  --inset: #1e202a;     /* image placeholder / deepest inset */
  --chrome: #16181f;    /* raised chrome: table head, total row */
  --fg: #e8eaf2;        /* primary text */
  --fg-2: #c6cbdb;      /* secondary text (button labels, textarea) */
  --muted: #8b90a3;     /* tertiary/meta — minimum readable text color */
  --line: #262933;      /* borders on panels, inputs */
  --hairline: #21242e;  /* row dividers (subtler than panel border) */
  --page-line: #1b1d25; /* page-level hairlines (header/footer) */
  --edge: #3a3f4c;      /* borders on interactive secondary elements */
  --gold: #c8a94e;      /* the single accent */
  --accent: #8ab0ff;    /* links */
  --accent-hover: #b3ccff;
  --good: #5cb87e;
  --bad: #e07070;
  --btn-bg: var(--gold);
  --btn-fg: #121318;
  --shadow: none;
  --rd: #7eb3f4; --rd-line: #2c4a75; --rd-bg: #141a24;   /* Rolling Dice */
  --ks: #e58f8f; --ks-line: #6e3535; --ks-bg: #221619;   /* Kindleshop */
  --font-display: "Space Grotesk", -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* legacy aliases still referenced by per-page <style> blocks */
  --head-bg: var(--chrome);
  --zebra: transparent;
  --chip-bg: transparent;
  --chip-line: var(--edge);
  --chip-hover: #262933;
  --warn-bg: transparent;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; touch-action: manipulation; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Segoe UI", sans-serif;
  margin: 0; background: var(--bg); color: var(--fg); line-height: 1.5;
}
main, .tool-head, footer { max-width: 920px; margin: 0 auto; padding: 0 1rem; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* Tool header (site chrome may sit above it) */
.tool-head { padding-top: 1.6rem; }
.brand { display: flex; align-items: center; gap: .6rem; }
.brand svg { flex: none; }
.tool-head h1 {
  font-family: var(--font-display);
  font-size: 1.35rem; margin: 0; letter-spacing: -.01em;
}
.tag { color: var(--muted); margin: .3rem 0 0; font-size: .92rem; }
.tag-nav { white-space: nowrap; }
.wubrg {
  height: 1px; border: 0; margin: 1rem 0 1.4rem;
  background: var(--page-line);
}

/* Input panel */
.input-area {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 1rem; box-shadow: var(--shadow);
}
textarea {
  width: 100%; min-height: 11.5rem;
  font: .8rem/1.6 var(--font-mono);
  padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--fg-2); resize: vertical;
}
textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; border-color: transparent; }
textarea.dragover { outline: 2px dashed var(--gold); }
.controls { display: flex; align-items: center; gap: 1rem; margin-top: .7rem; flex-wrap: wrap; }
button#generate {
  background: var(--btn-bg); color: var(--btn-fg); border: 0; border-radius: 10px;
  padding: .6rem 1.6rem; font-size: .95rem; font-weight: 700; cursor: pointer;
  font-family: var(--font-display); box-shadow: var(--shadow);
}
button#generate:hover { filter: brightness(1.06); }
button#generate:disabled { opacity: .55; cursor: wait; }
.rate { color: var(--muted); font-size: .8rem; display: flex; align-items: center; gap: .35rem; font-family: var(--font-mono); }
.rate input {
  width: 5.4rem; padding: .35rem .45rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--fg); font: .8rem var(--font-mono);
}
.linkish {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font-size: .85rem; padding: 0; text-decoration: underline; text-underline-offset: 2px;
}
.linkish:hover { color: var(--accent-hover); }
.hint { font-size: .78rem; color: var(--muted); margin: .55rem 0 0; }
.status { margin-top: .6rem; font-size: .85rem; color: var(--muted); }
.status.error { color: var(--bad); }

/* Saved lists row */
.lists-row { margin-top: .55rem; }
.controls select {
  padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--fg); font-size: .85rem; max-width: 15rem;
}
.hint-inline { font-size: .78rem; color: var(--muted); }
/* "prices as of DATE · refresh" line (pricesnap.js) — own row in .th-controls */
.pricemode { flex-basis: 100%; font-size: .78rem; color: var(--muted); }
.pricemode .linkish { font-size: inherit; }
.hint-inline a { color: var(--accent); }
.hint-inline.sync-error { color: var(--bad); }
.type-head {
  padding: .85rem .9rem .3rem;
  font-family: var(--font-mono);
  font-size: .66rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  border-bottom: 1px solid var(--hairline);
}

/* Result */
#result { margin-top: 1.5rem; }
.summary-bar {
  position: sticky; top: 0; z-index: 30;
  background: var(--bg); padding: .5rem 0 .6rem; margin-bottom: .4rem;
}
.bar-line { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.summary { font-size: .92rem; color: var(--muted); margin: 0 auto 0 0; }
.summary b { color: var(--fg); }

/* Status tabs */
.tabs { display: flex; gap: .5rem; margin-top: .6rem; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; padding: .38rem .95rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--edge); background: transparent; color: var(--muted);
  font-size: .8rem; font-family: inherit; white-space: nowrap;
}
.tab:hover { color: var(--fg-2); }
.tab.on {
  background: var(--gold); border-color: var(--gold); color: #121318; font-weight: 700;
}
.toolbtn {
  background: transparent; color: var(--fg-2); border: 1px solid var(--edge);
  border-radius: 8px; padding: .35rem .8rem; font-size: .8rem; cursor: pointer;
}
.toolbtn:hover { background: var(--chip-hover); }

.table-wrap {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden;
}
/* List rows (replaced the old table markup) */
.row {
  display: flex; align-items: center; gap: .7rem; padding: .55rem .9rem;
  border-bottom: 1px solid var(--hairline); flex-wrap: wrap;
}
.prices {
  flex: none; margin-left: auto; text-align: right;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.prices .p1 { font-size: .8rem; }
.prices .p2 { font-size: .72rem; color: var(--muted); }
.shops { display: flex; gap: .35rem; flex-wrap: wrap; flex: none; }
.empty { padding: 1.1rem .9rem; color: var(--muted); font-size: .85rem; }
.total-row {
  display: flex; align-items: baseline; gap: .8rem; padding: .65rem .9rem;
  background: var(--chrome); border-top: 1px solid var(--line); flex-wrap: wrap;
}
.total-row .tl { font-weight: 650; }
.total-row .tnote { color: var(--muted); font-size: .75rem; flex: 1; }
.total-row .tamts {
  margin-left: auto; display: flex; gap: .8rem;
  font-family: var(--font-mono); font-weight: 600; color: var(--gold);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* Card cell */
.cardcell { display: flex; align-items: center; gap: .65rem; min-width: 0; flex: 1 1 16rem; }
.buy { width: 17px; height: 17px; flex: none; margin: 0; accent-color: var(--gold); cursor: pointer; }
.row.bought { opacity: .45; }
.row.bought .nm { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.ownbtn {
  font-size: .68rem; padding: .12rem .55rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--edge); background: none; color: var(--muted);
}
.ownbtn:hover { border-color: var(--gold); color: var(--gold); }
.ownbtn.on { background: none; border-color: var(--gold); color: var(--gold); }
.row.owned { opacity: .6; }
.row.owned .ownbtn { opacity: 1; }
.thumb {
  flex: none; width: 42px; height: 58px; border-radius: 4px; overflow: visible;
  position: relative; background: var(--inset);
}
.thumb img {
  width: 42px; height: 58px; object-fit: cover; border-radius: 4px; display: block;
  transition: transform .12s ease; transform-origin: left center;
}
@media (hover: hover) {
  .thumb:hover img { transform: scale(3.4); z-index: 40; position: relative;
    box-shadow: 0 6px 24px rgba(0,0,0,.45); border-radius: 6px; }
}
.cardmain { min-width: 0; }
.cardname { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.cardname a { color: var(--fg); text-decoration: none; font-weight: 600; }
.cardname a:hover { color: var(--accent); text-decoration: underline; }
.qty { color: var(--muted); font-weight: 650; }
.cardsub { font-size: .72rem; color: var(--muted); margin-top: .1rem; letter-spacing: .02em; }
small.nf { color: var(--gold); }
small.nf .linkish { font-size: inherit; }

/* Color identity pips */
.pips { display: inline-flex; gap: 3px; }
.pip {
  width: 11px; height: 11px; border-radius: 50%; display: inline-block;
  border: 1px solid rgba(255,255,255,.16);
}
.pip.W { background: #f4eece; } .pip.U { background: #3179bd; }
.pip.B { background: #40353f; } .pip.R { background: #d3564a; }
.pip.G { background: #37835a; } .pip.C { background: #b9bec9; border-radius: 3px; }

/* Game Changer badge */
.gc {
  font-size: .64rem; font-weight: 700; letter-spacing: .04em; color: var(--gold);
  background: none; padding: 0; cursor: help;
}

/* Shop chips */
a.shop {
  display: inline-block; padding: .26rem .7rem;
  border: 1px solid var(--edge); border-radius: 999px; text-decoration: none;
  font-size: .8rem; color: var(--fg-2); background: transparent; white-space: nowrap;
}
a.shop::after { content: " \2197"; color: var(--muted); }
a.shop[data-shop="Rolling Dice"] { color: var(--rd); border-color: var(--rd-line); }
a.shop[data-shop="Rolling Dice"]:hover { background: var(--rd-bg); }
a.shop[data-shop="Kindleshop"] { color: var(--ks); border-color: var(--ks-line); }
a.shop[data-shop="Kindleshop"]:hover { background: var(--ks-bg); }
a.shop:hover { background: var(--chip-hover); }

/* Stacked EV bar (evbar.js) — gold = hit EV ($1+ cards), muted = bulk,
   tick = pack price. 2px gaps between fills; values live in adjacent text. */
.evbar {
  position: relative; display: flex; gap: 2px;
  height: 6px; margin-top: .4rem; width: min(100%, 22rem);
  background: var(--inset); border-radius: 3px;
}
.evbar > .evbar-hit  { background: var(--gold); height: 100%; border-radius: 3px 0 0 3px; }
.evbar > .evbar-bulk { background: var(--muted); height: 100%; }
.evbar > .end        { border-radius: 0 3px 3px 0; }
.evbar > .evbar-hit.end { border-radius: 3px; }
.evbar-tick {
  position: absolute; top: -3px; width: 2px; height: 12px;
  background: var(--fg-2); border-radius: 1px;
}
.evbar.big { height: 10px; width: 100%; }
.evbar.big .evbar-tick { top: -4px; height: 18px; }
.evbar-cap { font-size: .74rem; color: var(--muted); margin-top: .4rem; }
.evbar-cap .evc {
  display: inline-block; width: 9px; height: 9px; border-radius: 3px;
  vertical-align: -1px;
}
.evbar-cap .evc-hit  { background: var(--gold); }
.evbar-cap .evc-bulk { background: var(--muted); }
.evbar-cap .evc-tick { width: 2px; height: 12px; background: var(--fg-2); border-radius: 1px; vertical-align: -2px; }

footer { margin-top: 2.2rem; padding-bottom: 2rem; }
footer .inner { border-top: 1px solid var(--page-line); padding-top: 1rem; }
footer p { font-size: .72rem; color: var(--muted); margin: .35rem 0; }

/* Toast — feedback for list-bar actions, above everything */
.toast {
  position: fixed; left: 50%; bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  background: #262933; border: 1px solid var(--edge); color: var(--fg);
  padding: .5rem 1.1rem; border-radius: 999px; font-size: .82rem; z-index: 60;
  opacity: 0; pointer-events: none; white-space: nowrap;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Phone layout — same row structure, bigger touch targets (≥44px rows) */
@media (max-width: 640px) {
  .tool-head { padding-top: 1.1rem; }
  /* The full sticky bar (summary + actions + tabs) eats half the viewport on
     phones — keep only the tabs row pinned, the rest scrolls away.
     display:contents lifts the tabs out of the bar's box so sticky spans the
     whole #result list instead of ending at the bar's bottom edge. */
  .summary-bar { display: contents; }
  .tabs {
    position: sticky; top: 0; z-index: 30;
    background: var(--bg); padding: .45rem 0; margin: .45rem 0;
  }
  .row { padding: .65rem .8rem; }
  .row .shops { flex-basis: 100%; padding-left: 2.15rem; }
  .buy { width: 22px; height: 22px; }
  .ownbtn { padding: .3rem .7rem; }
  a.shop { padding: .45rem .95rem; }
  .tab { padding: .5rem 1rem; }
  .toolbtn { padding: .5rem .9rem; }
  .thumb:active img { transform: scale(3.2); z-index: 40; position: relative; }
}
