/* =========================================================
   Firearm Modder Canada · Rimfire Workshop
   Original "workbench HUD" look: graphite glass panels,
   maple-red + glacier-cyan accents, angled corners.
   ========================================================= */
:root {
  --bg: #0a0c0f;
  --bg-2: #11151b;
  --panel: rgba(15, 18, 23, 0.78);
  --panel-solid: #12161c;
  --panel-2: rgba(24, 29, 37, 0.85);
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #e9edf2;
  --text-2: #b9c2cd;
  --muted: #7f8a98;
  --maple: #ff4b3e;
  --maple-2: #ff7a5c;
  --glacier: #4fd1ff;
  --glacier-2: #9be6ff;
  --ok: #3ddc97;
  --warn: #ffb547;
  --orange: #ff8a3d;
  --bad: #ff4d6d;
  --risk: #c58cff;
  --info: #7aa7ff;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font-display: "Chakra Petch", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --topbar-h: 62px;
  --legal-h: 30px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
a { color: var(--glacier); }
a:hover { color: var(--glacier-2); }
:focus-visible { outline: 2px solid var(--glacier); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Viewport ---------- */
#viewport { position: fixed; inset: 0; z-index: 0; touch-action: none; }
#viewport canvas { display: block; }
.label-layer { position: absolute; inset: 0; pointer-events: none; }
.vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(0,0,0,.55) 100%),
    linear-gradient(180deg, rgba(10,12,15,.55) 0%, transparent 14%, transparent 82%, rgba(10,12,15,.7) 100%);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line-2); background: rgba(255,255,255,.04);
  font-family: var(--font-display); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; font-size: 12.5px;
  cursor: pointer; transition: background .2s, border-color .2s, transform .15s, box-shadow .2s;
  white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.25); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary {
  background: linear-gradient(180deg, #ff5a4b, #e23b2f); border-color: rgba(255,140,120,.6);
  box-shadow: 0 6px 24px rgba(255, 75, 62, .35), inset 0 1px 0 rgba(255,255,255,.25);
}
.btn-primary:hover { background: linear-gradient(180deg, #ff6b5d, #ec4336); }
.btn-ghost { background: transparent; }
.btn-cyan { border-color: rgba(79,209,255,.5); color: var(--glacier-2); background: rgba(79,209,255,.08); }
.btn-cyan:hover { background: rgba(79,209,255,.16); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 11px; border-radius: 8px; }
.btn-xl { height: 54px; padding: 0 34px; font-size: 15px; border-radius: 12px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  border: 1px solid var(--line-2); background: rgba(255,255,255,.04); cursor: pointer;
  transition: background .2s, border-color .2s;
}
.icon-btn:hover { background: rgba(255,255,255,.1); }
.icon-btn.on { border-color: rgba(79,209,255,.6); background: rgba(79,209,255,.14); color: var(--glacier-2); }
.icon-btn svg, .btn svg { width: 18px; height: 18px; flex: none; }

/* ---------- Intro ---------- */
.intro {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: radial-gradient(80% 70% at 50% 40%, #151b24 0%, #090b0e 70%);
  transition: opacity .9s var(--ease), visibility .9s;
  overflow: auto; padding: 24px 16px;
}
.intro.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.intro-grid {
  position: absolute; inset: 0; opacity: .35;
  background-image: linear-gradient(rgba(79,209,255,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(79,209,255,.08) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(60% 60% at 50% 45%, #000 0%, transparent 75%);
  animation: gridDrift 18s linear infinite;
}
@keyframes gridDrift { to { background-position: 48px 48px, 48px 48px; } }
.intro-inner { position: relative; text-align: center; max-width: 640px; width: 100%; }
.brand-mark { width: 74px; height: 74px; margin: 0 auto 18px; color: var(--maple); filter: drop-shadow(0 0 18px rgba(255,75,62,.45)); animation: markIn 1.2s var(--ease) both; }
@keyframes markIn { from { opacity: 0; transform: scale(.6) rotate(-20deg); } }
.intro-kicker { font-family: var(--font-display); letter-spacing: .32em; text-transform: uppercase; color: var(--muted); font-size: 12px; margin: 0 0 6px; animation: fadeUp .9s .15s var(--ease) both; }
.intro-title {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(34px, 7vw, 64px); line-height: 1; margin: 0;
  letter-spacing: .02em; text-transform: uppercase; animation: fadeUp .9s .25s var(--ease) both;
}
.intro-title span { color: var(--maple); text-shadow: 0 0 30px rgba(255,75,62,.45); }
.intro-tag { color: var(--text-2); font-size: clamp(15px, 2.4vw, 18px); margin: 14px 0 18px; animation: fadeUp .9s .35s var(--ease) both; }
.intro-features { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 26px; animation: fadeUp .9s .45s var(--ease) both; }
.intro-features span { font-size: 12px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--text-2); background: rgba(255,255,255,.03); }
.load-bar { width: min(360px, 80%); height: 4px; margin: 0 auto 22px; border-radius: 4px; background: rgba(255,255,255,.08); overflow: hidden; }
.load-bar i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--maple), var(--glacier)); transition: width .4s var(--ease); }
#enterBtn { animation: fadeUp .9s .55s var(--ease) both; }
#enterBtn:not(:disabled) { animation: fadeUp .9s .55s var(--ease) both, pulseGlow 2.4s 1.4s ease-in-out infinite; }
@keyframes pulseGlow { 50% { box-shadow: 0 6px 34px rgba(255,75,62,.6), inset 0 1px 0 rgba(255,255,255,.25); } }
.intro-legal { color: var(--muted); font-size: 12.5px; max-width: 470px; margin: 22px auto 0; animation: fadeUp .9s .65s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 20;
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: linear-gradient(180deg, rgba(10,12,15,.92), rgba(10,12,15,.55));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.logo { display: flex; align-items: center; gap: 10px; color: var(--maple); text-decoration: none; flex: none; }
.logo svg { width: 32px; height: 32px; }
.logo-text { font-family: var(--font-display); font-weight: 700; color: var(--text); letter-spacing: .08em; font-size: 17px; line-height: 1; display: flex; flex-direction: column; }
.logo-text small { font-size: 9.5px; color: var(--muted); letter-spacing: .2em; text-transform: uppercase; margin-top: 3px; font-weight: 600; }
.modes { display: flex; gap: 4px; margin: 0 auto; padding: 4px; border-radius: 12px; background: rgba(255,255,255,.03); border: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.modes::-webkit-scrollbar { display: none; }
.mode-btn {
  display: flex; align-items: center; gap: 7px; height: 38px; padding: 0 13px; border-radius: 9px; border: 0; background: transparent;
  font-family: var(--font-display); font-weight: 600; font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2);
  cursor: pointer; transition: color .2s, background .2s; white-space: nowrap; position: relative;
}
.mode-btn svg { width: 17px; height: 17px; opacity: .85; }
.mode-btn:hover { color: var(--text); background: rgba(255,255,255,.05); }
.mode-btn.active { color: #fff; background: linear-gradient(180deg, rgba(255,75,62,.28), rgba(255,75,62,.12)); box-shadow: inset 0 0 0 1px rgba(255,75,62,.55); }
.mode-btn.active svg { color: var(--maple-2); opacity: 1; }
.top-actions { display: flex; gap: 8px; flex: none; }

/* ---------- Panels ---------- */
.panel {
  position: fixed; z-index: 15;
  background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .5s var(--ease), opacity .4s var(--ease);
}
.panel::before { /* HUD corner brackets */
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  background:
    linear-gradient(var(--maple), var(--maple)) top left / 18px 2px no-repeat,
    linear-gradient(var(--maple), var(--maple)) top left / 2px 18px no-repeat,
    linear-gradient(var(--glacier), var(--glacier)) bottom right / 18px 2px no-repeat,
    linear-gradient(var(--glacier), var(--glacier)) bottom right / 2px 18px no-repeat;
  opacity: .8;
}
.panel-left { top: calc(var(--topbar-h) + 14px); left: 14px; width: 290px; bottom: calc(var(--legal-h) + 86px); display: flex; flex-direction: column; }
.panel-right { top: calc(var(--topbar-h) + 14px); right: 14px; width: 340px; bottom: calc(var(--legal-h) + 14px); display: flex; flex-direction: column; }
.panel.off-left { transform: translateX(calc(-100% - 30px)); opacity: 0; pointer-events: none; }
.panel.off-right { transform: translateX(calc(100% + 30px)); opacity: 0; pointer-events: none; }
.panel-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-title { font-family: var(--font-display); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: 12.5px; color: var(--text-2); margin: 0; display: flex; align-items: center; gap: 8px; }
.panel-title .dot { width: 7px; height: 7px; border-radius: 2px; background: var(--maple); box-shadow: 0 0 10px var(--maple); transform: rotate(45deg); }
.panel-body { padding: 12px 14px 16px; overflow: auto; flex: 1; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.panel-body::-webkit-scrollbar { width: 8px; }
.panel-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 8px; }

/* ---------- Loadout ---------- */
.presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.preset-chip {
  font-size: 11.5px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line-2); background: rgba(255,255,255,.03);
  cursor: pointer; color: var(--text-2); transition: all .2s;
}
.preset-chip:hover { color: #fff; border-color: rgba(79,209,255,.6); background: rgba(79,209,255,.1); }
.section-label { font-family: var(--font-display); font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin: 6px 2px 8px; font-weight: 600; }
.slot {
  width: 100%; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; text-align: left;
  padding: 9px 10px; margin-bottom: 6px; border-radius: 11px; border: 1px solid var(--line); background: rgba(255,255,255,.025);
  cursor: pointer; transition: background .2s, border-color .2s, transform .2s;
}
.slot:hover { background: rgba(255,255,255,.06); border-color: var(--line-2); transform: translateX(2px); }
.slot.active { border-color: rgba(255,75,62,.65); background: linear-gradient(90deg, rgba(255,75,62,.16), rgba(255,75,62,.03)); }
.slot-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,.05); color: var(--glacier-2); }
.slot-ico svg { width: 19px; height: 19px; }
.slot-name { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; font-family: var(--font-display); font-weight: 600; }
.slot-val { font-weight: 600; font-size: 13px; color: var(--text); line-height: 1.25; }
.slot-state { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.slot-state.warn { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.slot-state.error { background: var(--bad); box-shadow: 0 0 10px var(--bad); animation: blink 1.2s infinite; }
.slot-state.legal { background: var(--orange); box-shadow: 0 0 10px var(--orange); }
@keyframes blink { 50% { opacity: .35; } }

/* ---------- Drawer (option cards) ---------- */
.drawer {
  position: fixed; z-index: 16; left: 318px; right: 368px; bottom: calc(var(--legal-h) + 86px);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow);
  transform: translateY(20px); opacity: 0; pointer-events: none; transition: transform .45s var(--ease), opacity .35s var(--ease);
  max-height: 46vh; display: flex; flex-direction: column;
}
.drawer.open { transform: none; opacity: 1; pointer-events: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; gap: 10px; }
.drawer-title { font-family: var(--font-display); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; font-size: 13px; margin: 0; }
.drawer-sub { color: var(--muted); font-size: 12px; margin: 2px 0 0; }
.cards { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(205px, 1fr); gap: 10px; padding: 4px 14px 14px; overflow-x: auto; scrollbar-width: thin; }
.card {
  position: relative; text-align: left; padding: 12px 12px 11px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.03);
  cursor: pointer; transition: transform .25s var(--ease), border-color .2s, background .2s; display: flex; flex-direction: column; gap: 6px; min-height: 150px;
}
.card:hover { transform: translateY(-3px); border-color: var(--line-2); background: rgba(255,255,255,.06); }
.card.selected { border-color: rgba(79,209,255,.8); background: linear-gradient(180deg, rgba(79,209,255,.14), rgba(79,209,255,.03)); box-shadow: 0 0 0 1px rgba(79,209,255,.3), 0 10px 30px rgba(79,209,255,.12); }
.card.selected::after { content: "EQUIPPED"; position: absolute; top: 10px; right: 10px; font-family: var(--font-display); font-size: 9.5px; letter-spacing: .14em; color: var(--glacier-2); }
.card.locked { cursor: not-allowed; border-style: dashed; background: repeating-linear-gradient(-45deg, rgba(255,77,109,.05) 0 10px, transparent 10px 20px); }
.card.locked:hover { transform: none; }
.card-name { font-weight: 700; font-size: 13.5px; padding-right: 64px; line-height: 1.25; }
.card-short { color: var(--text-2); font-size: 12px; }
.card-stats { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11.5px; color: var(--muted); margin-top: auto; }
.card-stats b { color: var(--text); font-weight: 600; }
.delta-up { color: var(--ok) !important; }
.delta-down { color: var(--bad) !important; }
.card-flags { display: flex; flex-wrap: wrap; gap: 5px; }
.ring-row { display: flex; align-items: center; gap: 8px; padding: 0 14px 12px; color: var(--text-2); font-size: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; font-size: 12px; color: var(--text-2); }
.seg button.on { background: rgba(79,209,255,.18); color: #fff; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 8px; border-radius: 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-family: var(--font-display);
  border: 1px solid currentColor; background: color-mix(in srgb, currentColor 12%, transparent); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-legal { color: var(--ok); }
.st-conditional { color: var(--warn); }
.st-classchange { color: var(--orange); }
.st-highrisk { color: var(--risk); }
.st-prohibited { color: var(--bad); }
.st-info { color: var(--info); }

/* ---------- Build sheet ---------- */
.build-name { background: transparent; border: 1px solid transparent; color: var(--text); font-family: var(--font-display); font-size: 18px; font-weight: 700; letter-spacing: .03em; width: 100%; padding: 4px 6px; border-radius: 8px; }
.build-name:hover, .build-name:focus { border-color: var(--line-2); background: rgba(255,255,255,.04); outline: none; }
.class-card { border-radius: 12px; padding: 12px; margin: 4px 0 12px; border: 1px solid var(--line-2); background: rgba(255,255,255,.03); position: relative; overflow: hidden; }
.class-card::after { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 80% at 100% 0%, color-mix(in srgb, var(--cc, var(--ok)) 22%, transparent), transparent 60%); pointer-events: none; }
.class-kicker { font-size: 10.5px; color: var(--muted); letter-spacing: .16em; text-transform: uppercase; font-family: var(--font-display); font-weight: 600; }
.class-value { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: .04em; color: var(--cc, var(--ok)); text-transform: uppercase; margin: 2px 0 6px; display: flex; align-items: center; gap: 8px; }
.class-device { display: inline-flex; margin-bottom: 6px; }
.class-reasons { margin: 6px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.class-reasons li { display: grid; grid-template-columns: 16px 1fr; gap: 6px; }
.class-reasons .ok { color: var(--ok); } .class-reasons .bad { color: var(--bad); } .class-reasons .warn { color: var(--warn); } .class-reasons .inf { color: var(--info); }
.verify-note { margin-top: 10px; font-size: 11.5px; color: var(--muted); border-top: 1px dashed var(--line-2); padding-top: 8px; }
.verify-note a { white-space: nowrap; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.stat { padding: 9px 10px; border-radius: 10px; background: rgba(255,255,255,.03); border: 1px solid var(--line); }
.stat-k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .12em; font-family: var(--font-display); font-weight: 600; }
.stat-v { font-family: var(--font-display); font-size: 18px; font-weight: 700; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.stat-v small { font-size: 11px; color: var(--muted); font-weight: 500; margin-left: 3px; font-family: var(--font-body); }
.stat.flash { animation: statFlash .7s var(--ease); }
@keyframes statFlash { 30% { border-color: var(--glacier); background: rgba(79,209,255,.12); } }
.bars { display: grid; gap: 9px; margin-bottom: 14px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 32px; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); }
.bar { height: 8px; border-radius: 6px; background: rgba(255,255,255,.07); overflow: hidden; position: relative; }
.bar i { position: absolute; inset: 0 auto 0 0; border-radius: 6px; background: linear-gradient(90deg, var(--glacier), #8af0ff); transition: width .7s var(--ease); box-shadow: 0 0 12px rgba(79,209,255,.5); }
.bar.maple i { background: linear-gradient(90deg, var(--maple), var(--maple-2)); box-shadow: 0 0 12px rgba(255,75,62,.5); }
.bar.ok i { background: linear-gradient(90deg, #22b07a, var(--ok)); box-shadow: 0 0 12px rgba(61,220,151,.45); }
.bar-num { text-align: right; font-family: var(--font-display); font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.issues { display: grid; gap: 7px; margin-bottom: 14px; }
.issue { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.025); font-size: 12.5px; animation: issueIn .45s var(--ease) both; }
@keyframes issueIn { from { opacity: 0; transform: translateX(10px); } }
.issue-ico { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.issue.error { border-color: rgba(255,77,109,.45); background: rgba(255,77,109,.07); } .issue.error .issue-ico { background: var(--bad); color: #1a0508; }
.issue.warn { border-color: rgba(255,181,71,.38); background: rgba(255,181,71,.06); } .issue.warn .issue-ico { background: var(--warn); color: #241600; }
.issue.legal { border-color: rgba(255,138,61,.5); background: rgba(255,138,61,.08); } .issue.legal .issue-ico { background: var(--orange); color: #240e00; }
.issue.danger { border-color: rgba(255,77,109,.6); background: rgba(255,77,109,.1); } .issue.danger .issue-ico { background: var(--bad); color: #1a0508; }
.issue.info { } .issue.info .issue-ico { background: rgba(122,167,255,.25); color: var(--info); }
.issue.okay { border-color: rgba(61,220,151,.35); background: rgba(61,220,151,.06); } .issue.okay .issue-ico { background: var(--ok); color: #03140c; }
.issue-title { font-weight: 700; color: var(--text); margin-bottom: 2px; }
.issue-msg { color: var(--text-2); }
.issue-fix { margin-top: 7px; display: flex; gap: 6px; flex-wrap: wrap; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet-actions .btn { width: 100%; }
.cost-note { font-size: 11px; color: var(--muted); margin: -4px 0 12px; }

/* ---------- Inspector ---------- */
.inspector { right: 14px; top: calc(var(--topbar-h) + 14px); width: 360px; max-height: calc(100% - var(--topbar-h) - var(--legal-h) - 120px); display: flex; flex-direction: column; }
.inspector.hide { transform: translateX(calc(100% + 30px)); opacity: 0; pointer-events: none; }
.insp-cat { font-size: 10.5px; color: var(--glacier-2); letter-spacing: .18em; text-transform: uppercase; font-family: var(--font-display); font-weight: 600; }
.insp-name { font-family: var(--font-display); font-size: 21px; font-weight: 700; letter-spacing: .02em; margin: 2px 0 0; line-height: 1.15; }
.insp-tabs { display: flex; gap: 4px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.insp-tab { border: 0; background: transparent; padding: 9px 10px; cursor: pointer; color: var(--muted); font-family: var(--font-display); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: 11.5px; border-bottom: 2px solid transparent; }
.insp-tab.on { color: #fff; border-bottom-color: var(--maple); }
.insp-text { font-size: 13.5px; color: var(--text-2); }
.insp-text p { margin: 0 0 10px; }
.insp-text strong { color: var(--text); }
.tip { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 10px; border-radius: 10px; background: rgba(79,209,255,.07); border: 1px solid rgba(79,209,255,.22); font-size: 12.5px; color: var(--text-2); margin-top: 6px; }
.tip svg { width: 18px; height: 18px; color: var(--glacier-2); }
.insp-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 14px 14px; border-top: 1px solid var(--line); }
.close-x { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line-2); background: transparent; cursor: pointer; display: grid; place-items: center; flex: none; }
.close-x:hover { background: rgba(255,255,255,.08); }
.close-x svg { width: 16px; height: 16px; }

/* ---------- Dock ---------- */
.dock {
  position: fixed; z-index: 14; left: 50%; bottom: calc(var(--legal-h) + 14px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; padding: 7px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: var(--shadow);
  max-width: calc(100% - 28px); overflow-x: auto; scrollbar-width: none;
}
.dock::-webkit-scrollbar { display: none; }
.dock .sep { width: 1px; height: 26px; background: var(--line-2); margin: 0 4px; flex: none; }
.dock-btn { height: 36px; min-width: 36px; padding: 0 10px; border-radius: 9px; border: 1px solid transparent; background: transparent; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 12px; font-weight: 600; white-space: nowrap; flex: none; }
.dock-btn:hover { background: rgba(255,255,255,.07); color: #fff; }
.dock-btn.on { border-color: rgba(79,209,255,.55); background: rgba(79,209,255,.13); color: var(--glacier-2); }
.dock-btn svg { width: 18px; height: 18px; }
.dock-range { display: flex; align-items: center; gap: 8px; padding: 0 8px; color: var(--text-2); font-size: 12px; flex: none; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 150px; height: 6px; border-radius: 6px; background: rgba(255,255,255,.1); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--maple); border: 3px solid #fff; box-shadow: 0 0 12px rgba(255,75,62,.7); cursor: pointer; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--maple); border: 3px solid #fff; cursor: pointer; }

/* ---------- Field strip card ---------- */
.strip-card {
  position: fixed; z-index: 15; left: 14px; top: calc(var(--topbar-h) + 14px); width: 380px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow);
  transition: transform .5s var(--ease), opacity .4s; display: flex; flex-direction: column; max-height: calc(100% - var(--topbar-h) - var(--legal-h) - 110px);
}
.strip-card.hide { transform: translateX(calc(-100% - 30px)); opacity: 0; pointer-events: none; }
.strip-progress { display: flex; gap: 4px; padding: 12px 14px 0; }
.pip { flex: 1; height: 5px; border-radius: 4px; background: rgba(255,255,255,.1); cursor: pointer; transition: background .3s; border: 0; padding: 0; }
.pip.done { background: rgba(255,75,62,.55); }
.pip.now { background: var(--maple); box-shadow: 0 0 10px var(--maple); }
.strip-step { font-family: var(--font-display); color: var(--maple-2); font-size: 11.5px; letter-spacing: .18em; text-transform: uppercase; font-weight: 700; }
.strip-title { font-family: var(--font-display); font-size: 21px; font-weight: 700; margin: 3px 0 8px; line-height: 1.15; }
.strip-body { font-size: 13.5px; color: var(--text-2); }
.strip-body p { margin: 0 0 8px; }
.safety { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 10px; border-radius: 10px; background: rgba(255,181,71,.08); border: 1px solid rgba(255,181,71,.3); font-size: 12.5px; color: var(--text-2); margin-top: 8px; }
.safety svg { width: 18px; height: 18px; color: var(--warn); }
.tool-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; padding: 4px 9px; border-radius: 999px; background: rgba(255,255,255,.05); border: 1px solid var(--line-2); color: var(--text-2); margin: 2px 4px 2px 0; }
.strip-nav { display: flex; gap: 8px; padding: 12px 14px 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.strip-nav .btn { flex: 1; }

/* ---------- 3D labels ---------- */
.part-label {
  pointer-events: auto; cursor: pointer; transform: translateY(-18px);
  font-family: var(--font-display); font-weight: 600; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 9px 4px 8px; border-radius: 6px; background: rgba(10,12,15,.82); border: 1px solid rgba(79,209,255,.45); color: #dff6ff;
  white-space: nowrap; opacity: 0; transition: opacity .35s, border-color .2s, background .2s; position: relative; user-select: none;
}
.part-label::after { content: ""; position: absolute; left: 50%; bottom: -10px; width: 1px; height: 10px; background: rgba(79,209,255,.6); }
.part-label.show { opacity: 1; }
.part-label:hover, .part-label.sel { border-color: var(--maple); background: rgba(40,12,10,.9); }
.part-label .n { color: var(--maple-2); margin-right: 5px; }
.dim-label {
  font-family: var(--font-display); font-weight: 700; font-size: 12.5px; letter-spacing: .04em; padding: 4px 9px; border-radius: 7px;
  background: rgba(10,12,15,.88); border: 1px solid rgba(255,255,255,.25); color: #fff; white-space: nowrap; pointer-events: none;
}
.dim-label.bad { border-color: var(--bad); color: #ffd5dc; box-shadow: 0 0 18px rgba(255,77,109,.35); }
.dim-label.warn { border-color: var(--warn); color: #ffe7c2; }
.dim-label.ok { border-color: rgba(61,220,151,.7); }
.dim-label small { color: var(--muted); font-weight: 500; margin-left: 4px; font-family: var(--font-body); }
.callout {
  pointer-events: none; font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: .08em; text-transform: uppercase;
  padding: 5px 10px; border-radius: 7px; background: rgba(255,75,62,.9); color: #fff; white-space: nowrap; box-shadow: 0 0 22px rgba(255,75,62,.5);
  animation: calloutIn .5s var(--ease) both;
}
.callout.cyan { background: rgba(20,120,160,.92); box-shadow: 0 0 22px rgba(79,209,255,.5); }
.callout.green { background: rgba(20,140,90,.92); box-shadow: 0 0 22px rgba(61,220,151,.5); }
@keyframes calloutIn { from { opacity: 0; transform: translateY(8px) scale(.9); } }

/* ---------- Hover tip ---------- */
.hover-tip {
  position: fixed; z-index: 30; pointer-events: none; transform: translate(14px, 14px);
  font-family: var(--font-display); font-weight: 600; font-size: 12px; letter-spacing: .05em; text-transform: uppercase;
  padding: 5px 10px; border-radius: 7px; background: rgba(10,12,15,.9); border: 1px solid rgba(79,209,255,.5); color: #e6f8ff;
  opacity: 0; transition: opacity .15s;
}
.hover-tip.show { opacity: 1; }
.hover-tip small { display: block; font-family: var(--font-body); text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 500; font-size: 11px; }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; z-index: 40; top: var(--topbar-h); left: 0; right: 0; bottom: var(--legal-h);
  background: rgba(8,10,13,.86); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  overflow: auto; animation: overlayIn .45s var(--ease) both;
}
@keyframes overlayIn { from { opacity: 0; transform: translateY(12px); } }
.overlay-inner { max-width: 1180px; margin: 0 auto; padding: 26px 22px 60px; }
.overlay-sm .overlay-inner { max-width: 760px; }
.ov-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.ov-kicker { font-family: var(--font-display); letter-spacing: .24em; text-transform: uppercase; color: var(--maple-2); font-size: 11.5px; font-weight: 700; }
.ov-title { font-family: var(--font-display); font-size: clamp(26px, 4vw, 38px); font-weight: 700; margin: 4px 0 6px; line-height: 1.05; }
.ov-sub { color: var(--text-2); max-width: 760px; margin: 0; }
.lib-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 16px 0 12px; position: sticky; top: 0; z-index: 2; padding: 10px 0; background: linear-gradient(180deg, rgba(8,10,13,.97) 70%, rgba(8,10,13,0)); }
.search { flex: 1 1 260px; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: rgba(255,255,255,.04); }
.search svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.search input { flex: 1; background: transparent; border: 0; outline: none; color: var(--text); font: inherit; min-width: 0; }
select.select { height: 40px; border-radius: 10px; border: 1px solid var(--line-2); background: #141820; color: var(--text); padding: 0 10px; font: inherit; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 32px; padding: 0 11px; border-radius: 999px; border: 1px solid var(--line-2); background: rgba(255,255,255,.03); cursor: pointer; font-size: 12px; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.chip.on { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.35); }
.chip .cnt { font-size: 10.5px; color: var(--muted); }
.lib-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.legend-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,.025); font-size: 12px; color: var(--text-2); }
.lib-cat { margin: 26px 0 10px; display: flex; align-items: baseline; gap: 10px; }
.lib-cat h3 { font-family: var(--font-display); font-size: 17px; letter-spacing: .08em; text-transform: uppercase; margin: 0; }
.lib-cat span { color: var(--muted); font-size: 12px; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.mod { border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.025); padding: 13px 14px; display: flex; flex-direction: column; gap: 7px; transition: border-color .2s, background .2s; }
.mod:hover { border-color: var(--line-2); background: rgba(255,255,255,.045); }
.mod-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.mod-name { font-weight: 700; font-size: 14px; line-height: 1.25; }
.mod-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 10.5px; padding: 2px 7px; border-radius: 5px; background: rgba(255,255,255,.06); color: var(--text-2); }
.tag.in3d { background: rgba(79,209,255,.14); color: var(--glacier-2); }
.mod-what { color: var(--text-2); font-size: 12.5px; margin: 0; }
.mod-rule { font-size: 12.5px; margin: 0; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,.035); border-left: 3px solid var(--sc, var(--muted)); color: var(--text); }
.mod-src { font-size: 11.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.mod-src a { text-decoration: none; border-bottom: 1px dotted rgba(79,209,255,.5); }
.mod-actions { display: flex; gap: 6px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Law page */
.law-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.law-card { border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.03); padding: 16px; }
.law-card h3 { font-family: var(--font-display); font-size: 16px; letter-spacing: .06em; text-transform: uppercase; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.law-card p, .law-card li { color: var(--text-2); font-size: 13px; }
.law-card ul { padding-left: 18px; margin: 6px 0 0; }
.law-card li { margin-bottom: 5px; }
.law-section { margin-top: 28px; }
.law-section > h2 { font-family: var(--font-display); font-size: 20px; letter-spacing: .06em; text-transform: uppercase; margin: 0 0 12px; }
.thresholds { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.thr { border-radius: 12px; padding: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.03); }
.thr-num { font-family: var(--font-display); font-size: 30px; font-weight: 700; line-height: 1; }
.thr-num small { font-size: 14px; color: var(--muted); margin-left: 3px; }
.thr-k { font-size: 12.5px; color: var(--text-2); margin-top: 6px; }
.timeline { border-left: 2px solid var(--line-2); margin-left: 8px; padding-left: 18px; display: grid; gap: 14px; }
.tl { position: relative; }
.tl::before { content: ""; position: absolute; left: -25px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--maple); box-shadow: 0 0 10px var(--maple); }
.tl-date { font-family: var(--font-display); font-size: 12px; letter-spacing: .14em; color: var(--maple-2); font-weight: 700; text-transform: uppercase; }
.tl-text { color: var(--text-2); font-size: 13px; }
.src-list { columns: 2 320px; column-gap: 24px; padding-left: 18px; }
.src-list li { margin-bottom: 7px; font-size: 13px; break-inside: avoid; }
.disclaimer { margin-top: 18px; padding: 14px 16px; border-radius: 12px; border: 1px solid rgba(255,181,71,.35); background: rgba(255,181,71,.07); color: var(--text-2); font-size: 13px; }
.disclaimer strong { color: var(--warn); }

/* Help */
.help-steps { display: grid; gap: 10px; }
.help-step { display: grid; grid-template-columns: 44px 1fr; gap: 12px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.03); }
.help-step .n { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,75,62,.14); color: var(--maple-2); }
.help-step .n svg { width: 22px; height: 22px; }
.help-step h4 { margin: 0 0 3px; font-size: 14px; }
.help-step p { margin: 0; color: var(--text-2); font-size: 13px; }
.kbd { display: inline-block; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-2); background: rgba(255,255,255,.06); font-size: 11.5px; font-family: ui-monospace, monospace; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 60; top: calc(var(--topbar-h) + 14px); left: 50%; transform: translateX(-50%); display: grid; gap: 8px; pointer-events: none; width: min(440px, calc(100% - 32px)); }
.toast { pointer-events: auto; padding: 11px 14px; border-radius: 11px; background: rgba(16,20,26,.95); border: 1px solid var(--line-2); box-shadow: var(--shadow); display: grid; grid-template-columns: 20px 1fr; gap: 9px; font-size: 13px; animation: toastIn .4s var(--ease) both; }
.toast.out { animation: toastOut .35s var(--ease) both; }
.toast .ti { font-weight: 800; }
.toast.ok { border-color: rgba(61,220,151,.5); } .toast.ok .ti { color: var(--ok); }
.toast.warn { border-color: rgba(255,181,71,.5); } .toast.warn .ti { color: var(--warn); }
.toast.bad { border-color: rgba(255,77,109,.55); } .toast.bad .ti { color: var(--bad); }
.toast.info .ti { color: var(--glacier); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) scale(.97); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

/* ---------- Legal strip ---------- */
.legal-strip {
  position: fixed; z-index: 18; left: 0; right: 0; bottom: 0; min-height: var(--legal-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 16px;
  font-size: 11px; color: var(--muted); background: rgba(8,10,13,.92); border-top: 1px solid var(--line);
}
.legal-strip a { color: var(--text-2); }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 200; }

/* Mobile slot bar (build mode on small screens) */
.mobile-sheet-toggle { display: none; }

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1180px) {
  .panel-left { width: 260px; }
  .panel-right { width: 310px; }
  .drawer { left: 288px; right: 338px; }
}
@media (max-width: 980px) {
  :root { --topbar-h: 56px; }
  .logo-text small { display: none; }
  .mode-btn span { display: none; }
  .mode-btn { padding: 0 11px; }
  .legal-tm { display: none; }
  .panel-left { width: 250px; }
  .drawer { left: 278px; right: 14px; bottom: calc(var(--legal-h) + 74px); }
  .panel-right { top: auto; height: auto; max-height: 52vh; bottom: calc(var(--legal-h) + 74px); left: 278px; right: 14px; width: auto; }
  .panel-right.collapsed .panel-body { display: none; }
  .mobile-sheet-toggle { display: inline-flex; }
  .drawer.open ~ .panel-right { opacity: 0; pointer-events: none; }
}
@media (max-width: 720px) {
  :root { --legal-h: 26px; }
  .topbar { gap: 8px; padding: 0 10px; }
  .logo-text { display: none; }
  .modes { margin: 0; flex: 1; }
  .mode-btn { height: 36px; padding: 0 10px; }
  .top-actions .icon-btn { width: 34px; height: 34px; }
  .legal-strip { font-size: 10px; padding: 3px 10px; }
  .panel-left {
    top: auto; left: 10px; right: 10px; width: auto; bottom: calc(var(--legal-h) + 66px); height: auto; max-height: 132px;
  }
  .panel-left .panel-head { display: none; }
  .panel-left .panel-body { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 10px; }
  .panel-left .presets, .panel-left .section-label { display: none; }
  .panel-left .slot { min-width: 168px; margin: 0; }
  .panel.off-left { transform: translateY(calc(100% + 120px)); }
  .drawer { left: 10px; right: 10px; bottom: calc(var(--legal-h) + 66px + 0px); max-height: 58vh; }
  .cards { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: 1fr; overflow-y: auto; overflow-x: hidden; }
  .card { min-height: 0; }
  .panel-right { left: 10px; right: 10px; top: calc(var(--topbar-h) + 10px); bottom: auto; max-height: 46vh; }
  .panel-right.collapsed { max-height: 64px; }
  .panel.off-right { transform: translateY(-140%); }
  .inspector { left: 10px; right: 10px; width: auto; top: auto; bottom: calc(var(--legal-h) + 66px); max-height: 52vh; }
  .inspector.hide { transform: translateY(130%); }
  .strip-card { left: 10px; right: 10px; width: auto; top: auto; bottom: calc(var(--legal-h) + 66px); max-height: 50vh; }
  .strip-card.hide { transform: translateY(130%); }
  .strip-title { font-size: 18px; }
  .dock { bottom: calc(var(--legal-h) + 10px); gap: 2px; padding: 5px; }
  .dock-btn span { display: none; }
  input[type=range] { width: 110px; }
  .overlay-inner { padding: 18px 16px 50px; }
  .lib-grid { grid-template-columns: 1fr; }
  body.mode-build .dock { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* =========================================================
   Runtime additions (generated UI)
   ========================================================= */
.dock-range svg { width: 18px; height: 18px; flex: none; }
.dock-btn:disabled { opacity: .35; cursor: default; background: transparent; color: var(--text-2); }
.dock-range input:disabled { opacity: .35; }
.tool-chip svg { width: 13px; height: 13px; }
.card-name svg { width: 14px; height: 14px; vertical-align: -2px; }
.card .card-name, .card .card-short, .card .card-stats, .card .card-flags { display: flex; }
.card .card-name, .card .card-short { display: block; }
.card.finish { min-height: 0; align-items: flex-start; }
.swatch { width: 30px; height: 30px; border-radius: 8px; border: 1px solid rgba(255,255,255,.25); box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 4px 14px rgba(0,0,0,.35); }
.panel-right .panel-head { gap: 8px; }
.sheet-cls { flex: none; }
.class-notes { margin: 8px 0 0; padding-left: 16px; font-size: 11.5px; color: var(--text-2); display: grid; gap: 4px; position: relative; z-index: 1; }
.class-card > * { position: relative; z-index: 1; }
.issue-fix .btn { height: 26px; }
.issue-fix .btn svg { width: 14px; height: 14px; }
.insp-text .tag { display: inline-block; margin-bottom: 2px; }
.mobile-sheet-toggle svg { transition: transform .3s var(--ease); }
.panel-right.collapsed .mobile-sheet-toggle svg { transform: rotate(180deg); }
.slot > span:nth-child(2) { min-width: 0; }
.slot-val { display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.btn-primary svg { width: 18px; height: 18px; }
#enterBtn svg { width: 20px; height: 20px; }
@media (max-width: 980px) {
  body.drawer-open .panel-right { opacity: 0; pointer-events: none; }
}
@media (max-width: 720px) {
  .panel-left .slot > span:nth-child(2) br { display: none; }
  .panel-left .slot-val { display: block; }
}
