/* WARDOGS Companion — "field manual" theme.
   A printed-manual look, modernised: cream paper, black ink, one dark-red ink for actions,
   a book serif for reading and a typewriter face for numbers and labels. No dark mode. */
:root {
  --paper: #EFE8D6;
  --paper-2: #E7DFCA;     /* sidebar column */
  --plate: #F8F4EA;       /* panels, tiles, tables */
  --plate-2: #F1EBDC;
  --ink: #1A1814;
  --ink-2: #4A463D;
  --ink-3: #7A7566;
  --rule: #B9B098;
  --rule-2: #D7CFB8;
  --red: #8E2A22;
  --red-2: #A8362C;
  --olive: #5B6B3E;
  --good: #3A6B35;
  --bad: #9B2C24;
  --accent: var(--red);
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --mono: "Courier Prime", "Courier New", monospace;
  --ui: var(--serif);
  --head: var(--serif);
  --label: var(--mono);
  --body: var(--serif);
  --prose: var(--serif);
  /* legacy tokens used by page stylesheets written for the dark theme */
  --bg: var(--paper);
  --bg-2: var(--plate-2);
  --panel: var(--plate);
  --panel-solid: var(--plate);
  --panel-hi: var(--plate-2);
  --panel-bg: var(--plate);
  --panel-edge: var(--rule);
  --panel-bar: var(--plate-2);
  --line: var(--rule-2);
  --line-2: var(--rule);
  --text: var(--ink);
  --muted: var(--ink-2);
  --dim: var(--ink-3);
  --accent-dim: rgba(142, 42, 34, .12);
}
* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--serif); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .2 0 0 0 0 .18 0 0 0 0 .12 0 0 0 .06 0'/></filter><rect width='200' height='200' filter='url(%23p)'/></svg>");
}
a { color: inherit; text-decoration: none; }
p a, .prose a, .lede a { text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
img { max-width: 100%; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.good { color: var(--good); } .bad { color: var(--bad); }

/* ---------- type ---------- */
.h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.9rem, 3.4vw, 2.6rem); line-height: 1.1; margin: 0 0 .5rem; letter-spacing: .01em; }
.h2 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.35rem, 2.2vw, 1.7rem); line-height: 1.15; margin: 0 0 .9rem; }
.label { font-family: var(--mono); font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.lede { max-width: 62ch; color: var(--ink-2); margin: 0 0 1.6rem; font-size: 1.02rem; }
.fineprint { font-size: .82rem; color: var(--ink-3); margin: 1rem 0 0; font-family: var(--mono); }
.caps { font-variant: small-caps; letter-spacing: .06em; }

/* chapter heading block used by tool pages (replaces the old photo header strips) */
.chapter { border-bottom: 3px double var(--ink); padding-bottom: .6rem; margin-bottom: 1.4rem; }
.chapter .label { display: block; margin-bottom: .2rem; }

/* ---------- buttons: printed-manual plates ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font-family: var(--mono); font-weight: 700; font-size: .82rem; letter-spacing: .04em; text-transform: uppercase;
  padding: .6rem 1rem; line-height: 1; cursor: pointer; color: var(--ink);
  background: var(--plate); border: 1px solid var(--ink);
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn-primary { background: var(--red); border-color: var(--red); color: #FBF6EA; }
.btn-primary:hover { background: var(--red-2); border-color: var(--red-2); color: #fff; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-link { font-family: var(--mono); font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: .2em; }
.btn-link:hover { color: var(--red); }

/* ---------- layout ---------- */
.section { max-width: 1200px; margin: 0 auto; padding: 2.2rem 1.8rem 3rem; }
.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.panel { background: var(--plate); border: 1px solid var(--ink); padding: .9rem 1rem 1rem; }
.panel h3 { margin: 0 0 .3rem; font-family: var(--serif); font-weight: 600; font-size: 1.15rem; }
.panel p { margin: 0; color: var(--ink-2); font-size: .95rem; }

.table-wrap { overflow-x: auto; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); margin-bottom: 1.4rem; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { padding: .55rem .8rem; text-align: left; border-bottom: 1px solid var(--rule-2); white-space: nowrap; }
.table th { font-family: var(--mono); font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); border-bottom: 1px solid var(--ink); }
.table th.num, .table td.num { text-align: right; }
.table td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.conf { font-family: var(--mono); font-size: .66rem; letter-spacing: .05em; text-transform: uppercase; padding: .1rem .35rem; border: 1px solid; }
/* Four provenance tiers. The legacy words are kept as aliases because the raw
   data files still carry them; see apps/core/provenance.py. */
.conf-official { color: var(--good); border-color: var(--good); font-weight: 700; }
.conf-verified { color: var(--ink); border-color: var(--ink); }
.conf-community { color: var(--ink-2); border-color: var(--rule); }
.conf-estimated { color: var(--bad); border-color: var(--bad); }
.conf-confirmed { color: var(--good); border-color: var(--good); }
.conf-reported { color: var(--ink-2); border-color: var(--rule); }
.conf-unconfirmed { color: var(--bad); border-color: var(--bad); }

/* Key that decodes the badges. Collapsed by default so it never competes with
   the data it explains. */
.prov-key { margin: .6rem 0 1.2rem; font-size: .85rem; }
.prov-key > summary {
  cursor: pointer; font-family: var(--mono); font-size: .72rem;
  letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2);
}
.prov-key > summary:hover { color: var(--red); }
.prov-key-list { margin: .6rem 0 0; }
.prov-key-row { display: flex; gap: .6rem; align-items: baseline; margin: .3rem 0; }
.prov-key-row dt { flex: 0 0 auto; min-width: 6.5rem; }
.prov-key-row dd { margin: 0; color: var(--ink-2); }
.prov-key-scope { margin: .6rem 0 0; color: var(--ink-3); font-size: .82rem; }

/* Dataset-level badge, for a page whose numbers all share one source. */
.prov-banner {
  display: flex; flex-wrap: wrap; gap: .5rem .8rem; align-items: baseline;
  border: 1px solid var(--rule); border-left: 3px solid var(--rule);
  padding: .5rem .7rem; margin: 0 0 1rem; font-size: .85rem;
}
.prov-banner.is-estimated { border-left-color: var(--bad); }
.prov-banner.is-community { border-left-color: var(--ink-2); }
.prov-banner.is-official { border-left-color: var(--good); }
.prov-banner-text { color: var(--ink-2); }
@media (max-width: 600px) {
  .prov-key-row { flex-direction: column; gap: .15rem; }
}
.foot { border-top: 1px solid var(--ink); padding: 1rem 1.8rem 1.4rem; display: flex; gap: 1.2rem; justify-content: space-between; flex-wrap: wrap; font-family: var(--mono); font-size: .74rem; color: var(--ink-3); }

/* ---------- builder ---------- */
.builder-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.builder-actions { display: flex; gap: .5rem; }
#build-name { outline: none; min-width: 6ch; border-bottom: 1px dashed var(--rule); }
#build-name:focus { border-bottom-color: var(--red); }
.builder-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr) 270px; gap: 1rem; align-items: start; }
@media (max-width: 1000px) { .builder-grid { grid-template-columns: 1fr; } }
.slots { display: flex; flex-direction: column; gap: 0; border-top: 1px solid var(--ink); }
.slot { display: grid; grid-template-columns: 64px 1fr auto; gap: .05rem .7rem; padding: .5rem .5rem .5rem .3rem; background: transparent; border: 0; border-bottom: 1px solid var(--rule-2); cursor: pointer; text-align: left; color: inherit; font: inherit; }
.slot:hover { background: var(--plate); }
.slot.active { background: var(--plate); box-shadow: inset 3px 0 0 var(--red); }
.slot .k { grid-column: 2; font-family: var(--mono); font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.slot .n { grid-column: 2; font-weight: 500; font-size: .98rem; }
.slot .n.empty { color: var(--ink-3); font-style: italic; }
.slot .p { grid-column: 3; grid-row: 1 / span 2; align-self: center; font-family: var(--mono); font-weight: 700; font-size: .95rem; font-variant-numeric: tabular-nums; }
.slot-img { grid-column: 1; grid-row: 1 / span 2; width: 64px; height: 42px; object-fit: contain; background: #fff; border: 1px solid var(--rule); align-self: center; display: block; padding: 2px; }
.stage { background: var(--plate); border: 1px solid var(--ink); min-height: 420px; padding: 1rem; }
.stage-empty { color: var(--ink-3); text-align: center; padding: 6rem 1rem; font-style: italic; }
.stage-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .7rem; border-bottom: 1px solid var(--ink); padding-bottom: .4rem; }
.stage-head h2 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 1.3rem; }
.search { width: 100%; padding: .55rem .7rem; background: #fff; color: var(--ink); border: 1px solid var(--ink); font: inherit; margin-bottom: .5rem; }
.picklist { display: flex; flex-direction: column; border-top: 1px solid var(--ink); max-height: 60vh; overflow: auto; }
.pick { display: grid; grid-template-columns: 44px 1fr auto auto; gap: .8rem; align-items: center; padding: .5rem .6rem; background: transparent; border: 0; border-bottom: 1px solid var(--rule-2); cursor: pointer; text-align: left; color: inherit; font: inherit; }
.pick-img { width: 44px; height: 30px; object-fit: contain; background: #fff; border: 1px solid var(--rule); padding: 1px; display: block; }
.pick:hover { background: #fff; }
.pick.selected { background: #fff; box-shadow: inset 3px 0 0 var(--red); }
.pick .cat { font-family: var(--mono); font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.pick .price { font-family: var(--mono); font-weight: 700; font-size: .95rem; font-variant-numeric: tabular-nums; min-width: 4.5rem; text-align: right; }
/* the pack and the armory: two standing panels under the builder grid */
.pack-panel, .armory { margin-top: 1.5rem; }
.panel-bar { display: flex; align-items: baseline; gap: .7rem; border-bottom: 2px solid var(--ink); padding-bottom: .35rem; margin-bottom: .8rem; }
.panel-bar .num { font-family: var(--mono); font-size: .68rem; letter-spacing: .05em; color: var(--paper); background: var(--ink); padding: .1rem .34rem; align-self: center; }
.panel-bar h2 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 1.25rem; }
.panel-bar .cap { margin-left: auto; font-family: var(--mono); font-size: .74rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.panel-bar .cap.over { color: var(--bad); }
.panel-bar .search { margin: 0 0 0 auto; width: 15rem; padding: .35rem .5rem; }
.pack-none { margin: 0; padding: 1.6rem 1rem; text-align: center; font-style: italic; color: var(--ink-3); background: var(--plate); border: 1px dashed var(--rule); }
.pack-top { display: grid; grid-template-columns: 72px 1fr auto; gap: .9rem; align-items: center; background: var(--plate); border: 1px solid var(--ink); padding: .6rem .9rem; }
.pack-top .pick-img { width: 72px; height: 48px; }
.pack-top .name { font-family: var(--serif); font-weight: 600; font-size: 1.3rem; line-height: 1.1; }
.pack-top .cat { font-family: var(--mono); font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); margin-top: .2rem; }
.pack-load { text-align: right; font-family: var(--mono); font-size: 1.05rem; font-variant-numeric: tabular-nums; color: var(--ink-2); line-height: 1; }
.pack-load b { font-size: 1.9rem; color: var(--ink); }
.pack-load small { display: block; font-size: .6rem; letter-spacing: .06em; text-transform: uppercase; margin-top: .2rem; }
.pack-load.over b, .kv span.over { color: var(--bad); }

/* Square cells on a fixed grid, so a 2x2 item reads as a square rather than a wide box.
   --cell is the side of one cell; the grid is exactly the pack's columns by rows. */
.pack-scroll { overflow-x: auto; margin-top: .9rem; }
/* A pack with more than one compartment shows each as its own grid, side by side,
   so a 1x3 pocket reads as a pocket and not as part of the main sack. */
.pack-comps { display: flex; align-items: flex-start; gap: .9rem; width: max-content; max-width: 100%; }
.pack-comp { display: flex; flex-direction: column; gap: .3rem; }
.comp-lbl { font-family: var(--mono); font-size: .62rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.pack-grid { --cell: 122px; display: grid; width: max-content; max-width: 100%;
  grid-template-columns: repeat(var(--cols), var(--cell)); grid-template-rows: repeat(var(--rows), var(--cell));
  gap: 0; border: 1px solid var(--ink); border-width: 1px 0 0 1px; }
.pack-cell { position: relative; border: 1px solid var(--ink); border-width: 0 1px 1px 0; background: #fff; padding: .45rem .35rem .3rem; display: grid; grid-template-rows: 1fr auto auto; gap: .25rem; justify-items: center; align-content: center; overflow: hidden; }
.pack-cell .pick-img { width: 100%; height: 100%; max-height: 58px; border: 0; padding: 0; align-self: center; }
.pack-cell.big .pick-img { max-height: 120px; }
.pack-cell .fp { position: absolute; top: 0; left: 0; background: var(--ink); color: var(--paper); font-family: var(--mono); font-size: .6rem; padding: .1rem .28rem; }
.pack-cell .tag { position: absolute; top: 0; right: 0; background: var(--red); color: var(--paper); font-family: var(--mono); font-size: .62rem; letter-spacing: .02em; padding: .1rem .32rem; }
.pack-cell .pn { grid-row: 2; font-size: .72rem; line-height: 1.1; text-align: center; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pack-cell .qty { grid-row: 3; display: flex; align-items: center; gap: .3rem; font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .76rem; }
.pack-cell .qty b { min-width: 1.9rem; text-align: center; }
.pack-cell .qty button { width: 22px; height: 22px; line-height: 1; background: var(--plate); border: 1px solid var(--ink); color: inherit; font: inherit; cursor: pointer; padding: 0; }
.pack-cell .qty button:hover { background: var(--ink); color: var(--paper); }
.pack-cell.over { background: #FBEFEC; }
.pack-cell.empty { background: var(--plate-2); align-content: end; justify-items: end; padding: .35rem .45rem; color: var(--ink-3); font-family: var(--mono); font-size: .68rem;
  background-image: linear-gradient(to bottom right, transparent calc(50% - 1px), var(--rule-2) calc(50% - 1px), var(--rule-2) calc(50% + 1px), transparent calc(50% + 1px)); }
.pack-warn { font-family: var(--mono); font-size: .74rem; letter-spacing: .04em; text-transform: uppercase; color: var(--bad); margin: .6rem 0 0; }

.armory-tabs { display: flex; flex-wrap: wrap; border: 1px solid var(--ink); border-bottom: 0; }
.armory-tabs .tab { flex: 1; min-width: 6rem; display: flex; justify-content: center; align-items: baseline; gap: .35rem; background: var(--plate); border: 0; border-right: 1px solid var(--ink); padding: .4rem .3rem; font-family: var(--mono); font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); cursor: pointer; }
.armory-tabs .tab:last-child { border-right: 0; }
.armory-tabs .tab small { font-size: .62rem; color: var(--ink-3); }
.armory-tabs .tab.on { background: var(--ink); color: var(--paper); }
.armory-tabs .tab.on small { color: var(--rule); }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(164px, 1fr)); gap: 0; border: 1px solid var(--ink); border-width: 1px 0 0 1px; max-height: 32rem; overflow-y: auto; }
.card { position: relative; display: grid; grid-template-rows: 88px auto auto auto; gap: .25rem; justify-items: center; align-content: start; background: #fff; border: 1px solid var(--ink); border-width: 0 1px 1px 0; padding: .6rem .5rem .35rem; cursor: pointer; color: inherit; font: inherit; text-align: center; }
.card:hover { background: var(--plate); }
.card.in { box-shadow: inset 0 -4px 0 var(--red); }
.card .tag { position: absolute; top: 0; right: 0; background: var(--red); color: var(--paper); font-family: var(--mono); font-size: .66rem; padding: .12rem .34rem; }
.card .art { display: grid; place-items: center; width: 100%; height: 88px; }
.card .art .pick-img { width: 100%; height: 88px; border: 0; padding: 0; }
.card .cat { font-family: var(--mono); font-size: .62rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.card .nm { font-size: .88rem; line-height: 1.2; }
.card .act { margin-top: .45rem; width: 100%; border-top: 1px solid var(--rule-2); padding-top: .3rem; font-family: var(--mono); font-size: .66rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); }
.card.in .act { color: var(--red); font-weight: 700; }
@media (max-width: 640px) {
  .pack-grid { --cell: 92px; }
  .shelf { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
  .panel-bar .search { width: 100%; }
}

.weapon-card { display: grid; grid-template-columns: 1fr; gap: .8rem; }
.weapon-hero { background: #fff; border: 1px solid var(--ink); min-height: 160px; display: grid; place-items: center; text-align: center; padding: 1rem; }
.weapon-hero.has-img { grid-template-rows: auto auto; gap: .4rem; padding: .6rem 1rem .9rem; }
.weapon-hero img { max-height: 220px; width: auto; max-width: 100%; }
.weapon-hero .name { font-family: var(--serif); font-weight: 600; font-size: 1.6rem; line-height: 1; }
.weapon-hero .cat { font-family: var(--mono); font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); margin-top: .3rem; }
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 0; margin: 0; border: 1px solid var(--ink); }
.stat-strip div { background: #fff; padding: .45rem .7rem; border-right: 1px solid var(--rule-2); }
.stat-strip div:last-child { border-right: 0; }
.stat-strip dt { font-family: var(--mono); font-size: .64rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.stat-strip dd { margin: 0; font-family: var(--mono); font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; }
.attach-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .5rem; }
.attach { background: #fff; border: 1px solid var(--rule); padding: .55rem .65rem; }
.attach label { display: block; font-family: var(--mono); font-size: .66rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); margin-bottom: .3rem; }
.attach select { width: 100%; background: #fff; color: var(--ink); border: 1px solid var(--ink); padding: .4rem .45rem; font: inherit; font-size: .95rem; }
.attach .none { color: var(--ink-3); font-size: .85rem; font-style: italic; }
.summary { background: var(--plate); border: 1px solid var(--ink); padding: 0; position: sticky; top: 1rem; }
.panel-title { font-family: var(--mono); font-size: .74rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 .6rem; }
.big-num { display: flex; justify-content: space-between; align-items: baseline; }
.big-num .k { font-family: var(--mono); font-size: .68rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); }
.big-num .v { font-family: var(--mono); font-weight: 700; font-size: 1.8rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.big-num .v.ok { color: var(--good); }
.big-num .v.over { color: var(--bad); }
.bar { height: 6px; background: var(--rule-2); margin: .5rem 0 .8rem; border: 1px solid var(--rule); }
.bar i { display: block; height: 100%; background: var(--ink); transition: width .2s; }
.bar i.over { background: var(--bad); }
.kv { display: flex; justify-content: space-between; font-size: .9rem; color: var(--ink-2); padding: .4rem 0; border-top: 1px solid var(--rule-2); }
.kv span:last-child { color: var(--ink); font-family: var(--mono); font-weight: 700; }
.chips { display: flex; gap: 0; margin: .8rem 0 .2rem; border: 1px solid var(--ink); }
.chip { flex: 1; display: grid; gap: .1rem; text-align: center; font-family: var(--mono); font-size: .68rem; letter-spacing: .03em; text-transform: uppercase; padding: .38rem .2rem; border-right: 1px solid var(--ink); color: var(--ink-2); line-height: 1.1; background: #fff; }
/* only the segmented bar doubles its border against the strip edge; standalone .chip plates
   on economy/progression/skills keep all four sides (:where keeps this at .chip:last-child weight) */
.chip:where(.chips > *):last-child { border-right: 0; }
.chip small { font-size: .62rem; letter-spacing: 0; text-transform: none; font-variant-numeric: tabular-nums; opacity: .85; }
.chip.on { background: var(--ink); color: var(--paper); }
.chip.over { color: var(--bad); }
.toast { position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: .55rem .9rem; font-family: var(--mono); font-size: .85rem; z-index: 50; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* guides keep the reading face */
.guide p, .guide li, .guide td, .guide dd, .lede { font-family: var(--serif); }

/* ---- gunsmith: the weapon stage, read from the game's own item definitions ---- */
.slot .n .sub { display: block; font-weight: 400; font-size: .72rem; color: var(--ink-2); line-height: 1.2; margin-top: .1rem; }
.gs { display: grid; gap: .8rem; }
.gs-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "img img" "id price"; gap: .5rem 1rem; align-items: end; background: #fff; border: 1px solid var(--ink); padding: .8rem 1rem .9rem; }
.gs-hero img { grid-area: img; justify-self: center; max-height: 200px; width: auto; max-width: 100%; }
.gs-hero .gs-id { grid-area: id; min-width: 0; }
.gs-hero .name { font-family: var(--serif); font-weight: 600; font-size: 1.7rem; line-height: 1; }
.gs-hero .cat { font-family: var(--mono); font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); margin-top: .35rem; }
.gs-hero .flav { margin: .4rem 0 0; font-family: var(--serif); font-style: italic; color: var(--ink-2); font-size: .95rem; line-height: 1.3; }
.gs-price { grid-area: price; text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; display: grid; justify-items: end; gap: .15rem; }
.gs-price b { font-size: 1.7rem; line-height: 1; }
.gs-price small { font-size: .66rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.gs-price small.lvl { color: var(--red); font-weight: 700; }
.gs-rail { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); border: 1px solid var(--ink); border-width: 1px 0 0 1px; }
.gs-slot { display: grid; grid-template-rows: auto 64px auto auto; gap: .3rem; justify-items: center; align-content: start; background: #fff; border: 1px solid var(--ink); border-width: 0 1px 1px 0; padding: .5rem .5rem .45rem; cursor: pointer; color: inherit; font: inherit; text-align: center; position: relative; }
.gs-slot:hover { background: var(--plate); }
.gs-slot.open { background: var(--plate); box-shadow: inset 0 -3px 0 var(--red); }
.gs-slot.changed::after { content: ""; position: absolute; top: 0; right: 0; border: 7px solid transparent; border-top-color: var(--red); border-right-color: var(--red); }
.gs-slot .k { font-family: var(--mono); font-size: .66rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); display: grid; }
.gs-slot .k small { font-size: .58rem; color: var(--ink-3); letter-spacing: .03em; }
.gs-slot .n { font-size: .84rem; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gs-slot .n.empty { color: var(--ink-3); font-style: italic; }
.gs-slot .p { font-family: var(--mono); font-size: .72rem; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.gs-img { width: 100%; height: 64px; object-fit: contain; display: block; }
.gs-img.none { background: repeating-linear-gradient(45deg, var(--plate-2) 0 6px, transparent 6px 12px); border: 1px dashed var(--rule); }
.gs-img.none.big { height: 160px; }
.gs-fixed { margin: -.3rem 0 0; font-size: .82rem; color: var(--ink-2); }
.gs-fixed .k { font-family: var(--mono); font-size: .64rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); margin-right: .4rem; }
.gs-picker { background: #fff; border: 1px solid var(--ink); }
.gs-picker-head { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; padding: .55rem .8rem; border-bottom: 1px solid var(--ink); background: var(--plate); }
.gs-picker-head h3 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 1.15rem; }
.gs-picker-head .cat { font-family: var(--mono); font-size: .66rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); flex: 1; }
.btn.small { padding: .2rem .55rem; font-size: .72rem; }
.gs-opts { max-height: 30rem; overflow-y: auto; }
.gs-opt { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: .2rem .9rem; align-items: center; width: 100%; padding: .55rem .8rem; background: transparent; border: 0; border-bottom: 1px solid var(--rule-2); cursor: pointer; text-align: left; color: inherit; font: inherit; }
.gs-opt:last-child { border-bottom: 0; }
.gs-opt:hover { background: var(--plate); }
.gs-opt.selected { background: var(--plate); box-shadow: inset 3px 0 0 var(--red); }
.gs-opt .gs-img { height: 56px; }
.gs-opt .body { display: grid; gap: .2rem; min-width: 0; }
.gs-opt .nm { font-weight: 500; font-size: .98rem; }
.gs-opt .nm em { font-style: normal; font-family: var(--mono); font-size: .62rem; letter-spacing: .04em; text-transform: uppercase; color: var(--red); margin-left: .3rem; }
.gs-opt .cat { font-family: var(--mono); font-size: .66rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.gs-opt .desc { font-size: .8rem; color: var(--ink-2); line-height: 1.3; }
.gs-opt .price { font-family: var(--mono); font-weight: 700; font-size: .95rem; font-variant-numeric: tabular-nums; min-width: 4.5rem; text-align: right; align-self: start; }
.gs-opt .chips { display: flex; flex-wrap: wrap; gap: .25rem; }
.gs-chip { font-family: var(--mono); font-size: .64rem; letter-spacing: .02em; padding: .08rem .4rem; border: 1px solid var(--rule); color: var(--ink-2); background: #fff; white-space: nowrap; }
.gs-chip.good { border-color: var(--good); color: var(--good); }
.gs-chip.bad { border-color: var(--bad); color: var(--bad); }
.gs-load { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .55rem .8rem; border-top: 1px solid var(--ink); background: var(--plate); }
.gs-load label { font-family: var(--mono); font-size: .66rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.gs-load select { background: #fff; color: var(--ink); border: 1px solid var(--ink); padding: .3rem .45rem; font: inherit; font-size: .9rem; }
.gs-stats { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.gs-stats div { border-bottom: 1px solid var(--rule-2); }
.gs-stats dd .delta { font-size: .7rem; font-weight: 700; margin-left: .2rem; color: var(--ink-2); }
.gs-stats dd .delta.good { color: var(--good); }
.gs-stats dd .delta.bad { color: var(--bad); }
@media (max-width: 640px) {
  .gs-hero { grid-template-columns: 1fr; grid-template-areas: "img" "id" "price"; }
  .gs-price { text-align: left; justify-items: start; }
  .gs-rail { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .gs-opt { grid-template-columns: 56px minmax(0, 1fr); }
  .gs-opt .price { grid-column: 2; text-align: left; }
}

/* ---- the gunsmith figure: the game's mesh on the page, with printed callouts ---- */
.gs-hero.has-figure { grid-template-areas: "img img" "cap cap" "id price"; }
.gs-figure { grid-area: img; position: relative; width: 100%; height: clamp(230px, 36vw, 360px); background: #fff; overflow: hidden; touch-action: none; }
.gs-figcap { grid-area: cap; font-family: var(--mono); font-size: .64rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); border-top: 1px solid var(--rule-2); padding-top: .35rem; }
.gs-viewtoggle { position: absolute; top: .5rem; right: .6rem; z-index: 3; display: flex; border: 1px solid var(--ink); background: #fff; }
.gs-hero { position: relative; }
.gs-viewtoggle button { background: transparent; border: 0; border-right: 1px solid var(--ink); padding: .2rem .5rem; font-family: var(--mono); font-size: .62rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); cursor: pointer; }
.gs-viewtoggle button:last-child { border-right: 0; }
.gs-viewtoggle button.on { background: var(--ink); color: var(--paper); }
.g3 { position: absolute; inset: 0; }
.g3 canvas { display: block; width: 100% !important; height: 100% !important; cursor: grab; }
.g3 canvas:active { cursor: grabbing; }
.g3-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.g3-lines line { stroke: var(--ink); stroke-width: 1; }
.g3-lines circle { fill: var(--red); stroke: #fff; stroke-width: 1; }
.g3-overlay { position: absolute; inset: 0; pointer-events: none; }
.g3-label { position: absolute; left: 0; top: 0; pointer-events: auto; display: grid; gap: .05rem; text-align: left; background: var(--paper); border: 1px solid var(--ink); padding: .22rem .5rem .26rem; cursor: pointer; color: var(--ink); font: inherit; max-width: 170px; box-shadow: 2px 2px 0 rgba(30, 26, 20, .12); }
.g3-label small { font-family: var(--mono); font-size: .56rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.g3-label span { font-size: .78rem; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g3-label.empty span { color: var(--ink-3); font-style: italic; }
.g3-label:hover { background: #fff; }
.g3-label.on { border-color: var(--red); box-shadow: inset 0 -2px 0 var(--red), 2px 2px 0 rgba(30, 26, 20, .12); }
.g3-note { position: absolute; left: .5rem; bottom: .5rem; z-index: 4; background: var(--paper); border: 1px solid var(--ink); padding: .4rem .6rem; font-family: var(--mono); font-size: .66rem; max-width: 70%; }
.g3-note pre { margin: .3rem 0 0; white-space: pre-wrap; word-break: break-all; font-size: .6rem; max-height: 5rem; overflow: auto; }
@media (max-width: 640px) {
  .gs-hero.has-figure { grid-template-areas: "img" "cap" "id" "price"; }
  .gs-figure { height: 240px; }
  .g3-label { max-width: 130px; }
}
.g3.nolabels .g3-overlay, .g3.nolabels .g3-lines { display: none; }
