:root {
  --bg: #17191a;
  --panel: #202325;
  --panel2: #282c2e;
  --line: #3a4043;
  --text: #e7e4dc;
  --muted: #9da3a4;
  --accent: #e07a1f;
  --accent-ink: #1a1206;
  --caution: #d9a400;
  --head: "Bahnschrift", "DIN Alternate", "Roboto Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --body: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: Consolas, "SF Mono", Menlo, "DejaVu Sans Mono", monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text); font: 15px/1.5 var(--body);
  display: flex; flex-direction: column; overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* top bar */
.bar {
  display: flex; align-items: center; gap: 18px; padding: 0 14px; min-height: 52px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex: none;
}
.brand {
  font: 700 19px/1 var(--head); letter-spacing: .14em; text-transform: uppercase;
  padding: 7px 10px; border: 2px solid var(--accent); color: var(--accent);
}
.gun { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.gun strong { font: 600 18px/1.15 var(--head); letter-spacing: .03em; }
.gun span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tool {
  min-height: 44px; padding: 0 14px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 3px; font: 600 13px var(--head); letter-spacing: .08em; text-transform: uppercase;
}
.tool[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tool.xr { border-color: var(--accent); color: var(--accent); }

/* layout */
main { flex: 1; display: flex; min-height: 0; }
#stage { position: relative; flex: 1; min-width: 0; background: #c5c6c1; }
#canvasWrap { position: absolute; inset: 0; }
#canvasWrap canvas { display: block; touch-action: none; }
#panel {
  width: 400px; flex: none; display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-left: 1px solid var(--line);
}
footer {
  flex: none; padding: 6px 14px; font-size: 11.5px; color: var(--muted);
  background: var(--bg); border-top: 1px solid var(--line);
}

/* stage overlays */
#loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 600 15px var(--head); letter-spacing: .16em; text-transform: uppercase; color: #3a3f42;
}
#chip {
  position: absolute; left: 12px; top: 12px; max-width: min(360px, calc(100% - 24px));
  background: rgba(27, 29, 30, .94); border-left: 4px solid var(--accent); padding: 10px 12px; border-radius: 2px;
}
.chip-name { font: 600 17px/1.2 var(--head); letter-spacing: .03em; }
.chip-text { font-size: 13.5px; color: #cfd0cb; margin-top: 3px; }
.link { background: none; border: 0; padding: 8px 0 0; color: var(--accent); font-size: 13px; text-decoration: underline; min-height: 32px; }
#explodeBar {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  width: min(460px, calc(100% - 24px)); display: flex; align-items: center; gap: 12px;
  background: rgba(27, 29, 30, .94); padding: 4px 14px; border-radius: 2px; min-height: 48px;
}
#explodeBar label { font: 600 12px var(--head); letter-spacing: .12em; text-transform: uppercase; white-space: nowrap; }
#explode { flex: 1; accent-color: var(--accent); height: 44px; margin: 0; }
#hint {
  position: absolute; right: 12px; top: 12px; max-width: 280px; text-align: right;
  font-size: 12px; color: #474d50;
}

/* tabs */
.tabs { display: flex; flex: none; border-bottom: 1px solid var(--line); }
.tabs button {
  flex: 1; min-height: 48px; background: none; border: 0; border-bottom: 3px solid transparent;
  font: 600 13px var(--head); letter-spacing: .09em; text-transform: uppercase; color: var(--muted); padding: 0 6px;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabbody { flex: 1; overflow-y: auto; padding: 14px; min-height: 0; -webkit-overflow-scrolling: touch; }

.card { background: var(--panel2); border: 1px solid var(--line); border-radius: 3px; padding: 12px 14px; margin-bottom: 14px; }
.card h2 { font: 600 20px/1.2 var(--head); letter-spacing: .02em; margin: 0 0 2px; }
.card .tag { font: 12px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.card h3, .info h3 { font: 600 11.5px var(--head); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 12px 0 2px; }
.card p { margin: 0 0 4px; }
.muted { color: var(--muted); }

/* parts list */
.group-title {
  font: 600 12px var(--head); letter-spacing: .16em; text-transform: uppercase; color: var(--accent);
  margin: 16px 0 4px; padding-bottom: 4px; border-bottom: 1px solid var(--line);
}
.part-row {
  display: flex; align-items: center; width: 100%; min-height: 44px; padding: 0 10px; text-align: left;
  background: none; border: 0; border-bottom: 1px solid #2c3133; border-left: 3px solid transparent;
}
.part-row.hover { background: #2b3033; }
.part-row.selected { background: #33291c; border-left-color: var(--accent); }

/* steps */
.seg { display: flex; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.seg button { flex: 1; min-height: 44px; background: var(--panel2); border: 0; font: 600 13px var(--head); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: #3a3f42; color: var(--text); box-shadow: inset 0 -3px 0 var(--accent); }
.nav { display: grid; grid-template-columns: 1fr 1.4fr 1fr 1.3fr; gap: 8px; margin-bottom: 12px; }
.nav button {
  min-height: 46px; background: var(--panel2); border: 1px solid var(--line); border-radius: 3px;
  font: 600 13px var(--head); letter-spacing: .07em; text-transform: uppercase; padding: 0 4px;
}
.nav button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.nav button:disabled { opacity: .4; cursor: default; }
.stepno { font: 12px var(--mono); color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.safety {
  margin-top: 10px; padding: 9px 11px; background: #2f2710; border-left: 4px solid var(--caution); border-radius: 2px; font-size: 14px;
}
.safety b { font: 600 11.5px var(--head); letter-spacing: .14em; text-transform: uppercase; color: var(--caution); display: block; }
#stepList { list-style: none; margin: 0; padding: 0; counter-reset: s; }
#stepList li { counter-increment: s; }
#stepList .sect { counter-increment: none; font: 600 11.5px var(--head); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 12px 0 2px; }
#stepList button {
  display: flex; gap: 10px; align-items: center; width: 100%; min-height: 44px; text-align: left; padding: 4px 8px;
  background: none; border: 0; border-bottom: 1px solid #2c3133; border-left: 3px solid transparent; color: var(--muted);
}
#stepList button::before { content: counter(s, decimal-leading-zero); font: 12px var(--mono); color: var(--muted); flex: none; }
#stepList li.done button { color: var(--text); }
#stepList li.current button { color: var(--text); background: #33291c; border-left-color: var(--accent); }

/* info */
.info h2 { font: 600 20px/1.2 var(--head); margin: 20px 0 6px; padding-bottom: 6px; border-bottom: 2px solid var(--accent); }
.info h2:first-child { margin-top: 0; }
.info p { margin: 0 0 8px; }
table.specs { width: 100%; border-collapse: collapse; font-size: 14px; }
table.specs th { text-align: left; font-weight: 400; color: var(--muted); padding: 7px 8px 7px 0; vertical-align: top; width: 38%; }
table.specs td { padding: 7px 0 7px 8px; font-family: var(--mono); font-size: 13.5px; vertical-align: top; }
table.specs tr { border-bottom: 1px solid #2f3437; }
table.specs td.wide { font-family: var(--body); font-size: 14px; }
table.specs small { display: block; font-family: var(--body); color: var(--muted); }
.src { font-size: 12px; color: var(--muted); margin-top: 8px; }
ul.plain { margin: 0 0 8px; padding-left: 18px; }
ul.plain li { margin-bottom: 5px; }
ol.cycle { margin: 0; padding: 0; list-style: none; counter-reset: c; }
ol.cycle li { counter-increment: c; padding: 8px 0 8px 40px; position: relative; border-bottom: 1px solid #2f3437; }
ol.cycle li::before { content: counter(c); position: absolute; left: 0; top: 9px; width: 26px; height: 26px; border: 1px solid var(--accent); color: var(--accent); font: 13px/24px var(--mono); text-align: center; }
ol.cycle b { font: 600 15px var(--head); letter-spacing: .03em; display: block; }

/* phone and narrow screens */
@media (max-width: 860px) {
  main { flex-direction: column; }
  #stage { flex: none; height: 44vh; min-height: 250px; }
  #panel { width: auto; flex: 1; border-left: 0; border-top: 1px solid var(--line); }
  #hint { display: none; }
  .bar { gap: 10px; padding: 4px 8px; flex-wrap: wrap; }
  .brand { font-size: 14px; padding: 5px 7px; }
  .gun strong { font-size: 16px; }
  .gun span { display: none; }
  .tool { padding: 0 10px; font-size: 12px; }
  .tabs button { font-size: 12px; letter-spacing: .05em; }
  #chip { left: 8px; top: 8px; padding: 7px 10px; }
  .chip-text { display: none; }
  #explodeBar { bottom: 8px; }
  footer { font-size: 10.5px; padding: 4px 8px; }
  .nav { grid-template-columns: 1fr 1.3fr 1fr 1.4fr; gap: 6px; }
  .nav button { font-size: 12px; letter-spacing: .03em; }
}

/* desktop: keep the selected part description in view while the list scrolls */
@media (min-width: 861px) {
  #partDetail { position: sticky; top: -14px; z-index: 2; box-shadow: 0 10px 0 var(--panel); }
}
table.specs td:not(.wide) { white-space: nowrap; }
table.specs td small { white-space: normal; }
a.brand { text-decoration: none; display: inline-block; }
/* thumbnail capture: model only */
body.thumb .bar, body.thumb #panel, body.thumb footer, body.thumb #explodeBar, body.thumb #hint, body.thumb #chip { display: none !important; }

a.brand { text-decoration: none; display: inline-block; }
/* thumbnail capture: model only */
body.thumb .bar, body.thumb #panel, body.thumb footer, body.thumb #explodeBar, body.thumb #hint, body.thumb #chip { display: none !important; }

/* home page */
body.home { overflow: hidden; }
.home-scroll { flex: 1; overflow-y: auto; padding: 0 20px 28px; }
.home-intro { max-width: 760px; padding: 30px 0 6px; }
.home-intro h1 { font: 600 32px/1.15 var(--head); letter-spacing: .01em; margin: 0 0 10px; }
.home-intro p { color: #c9cbc6; margin: 0; font-size: 16px; }
.cat h2 {
  font: 600 13px var(--head); letter-spacing: .18em; text-transform: uppercase; color: var(--accent);
  margin: 30px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.gcard {
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 3px;
  color: var(--text); text-decoration: none; overflow: hidden; max-width: 460px;
}
.gcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.gcard img { display: block; width: 100%; aspect-ratio: 3 / 2; object-fit: cover; background: #b7b9b4; }
.gcard-body { display: flex; flex-direction: column; padding: 12px 14px 14px; gap: 2px; border-top: 3px solid var(--accent); }
.gcard strong { font: 600 22px/1.2 var(--head); letter-spacing: .02em; }
.gcard .variant { font: 12px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.gcard .blurb { color: #c9cbc6; font-size: 14px; margin-top: 4px; }
@media (max-width: 860px) {
  .home-scroll { padding: 0 12px 20px; }
  .home-intro h1 { font-size: 24px; }
}

body.thumb #stage { height: 100vh !important; flex: 1 !important; }

/* phone header: one row. A long firearm name wraps inside its own box instead of pushing the buttons down. */
@media (max-width: 860px) {
  .bar { flex-wrap: nowrap; gap: 8px; }
  .brand { font-size: 13px; flex: none; }
  .gun { flex: 1 1 0; }
  .gun strong { font-size: 15px; line-height: 1.1; }
  .tools { flex: none; flex-wrap: nowrap; gap: 6px; }
  .tool { padding: 0 8px; font-size: 11.5px; }
}

/* spec table: fixed columns so a long value wraps inside its cell instead of pushing the US column off the panel */
table.specs { table-layout: fixed; }
table.specs td:not(.wide) { white-space: normal; overflow-wrap: break-word; }
