/* Same look as ETFlabbet and Filamentlabbet: neutral greys, cards, a segmented menu */
:root {
  --bg: #f5f6f8; --card: #ffffff; --seg: #e9ecf0; --ink: #15181d; --muted: #646c76; --rule: #e3e6eb; --rule-strong: #c9ced6; --hover: #f6f7f9;
  --accent: #b45309; --accent-ink: #ffffff; --accent-soft: #fef3c7; --tld: #d97706; --sig: #dc2626; --plat: #c5cbd3; --lo: #17804f; --no: #b03a2a;
  --ok-soft: #e3f3ea; --warn: #b4321f; --warn-soft: #fbe6e1;
  --radius: 14px;
  color-scheme: light;
}
/* Explicit light and dark theme overrides */
html[data-theme="light"] {
  --bg: #f5f6f8; --card: #ffffff; --seg: #e9ecf0; --ink: #15181d; --muted: #646c76; --rule: #e3e6eb; --rule-strong: #c9ced6; --hover: #f6f7f9;
  --accent: #b45309; --accent-ink: #ffffff; --accent-soft: #fef3c7; --tld: #d97706; --sig: #dc2626; --plat: #c5cbd3; --lo: #17804f; --no: #b03a2a;
  --ok-soft: #e3f3ea; --warn: #b4321f; --warn-soft: #fbe6e1;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0e1114; --card: #171a1f; --seg: #22262c; --ink: #e7e9ec; --muted: #959ba3; --rule: #2a2f36; --rule-strong: #3c424a; --hover: #1c2026;
  --accent: #facc15; --accent-ink: #1c1603; --accent-soft: #2b240b; --tld: #facc15; --sig: #ef4444; --plat: #8b939e; --lo: #6fd39b; --no: #e8836f;
  --ok-soft: #15291f; --warn: #f2907a; --warn-soft: #33191a;
  color-scheme: dark;
}

/* Theme toggle button in header */
.theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  flex: 0 0 34px;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  box-sizing: border-box;
  margin-left: auto;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.theme-btn:hover {
  color: var(--ink);
  border-color: var(--rule-strong);
  background: var(--hover);
}
.theme-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}
/* By default in light mode, show moon (to switch to dark) */
.theme-btn .ico-sun { display: none; }
.theme-btn .ico-moon { display: block; }
/* In dark mode, show sun (to switch to light) */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .theme-btn .ico-sun { display: block; }
  html:not([data-theme="light"]) .theme-btn .ico-moon { display: none; }
}
html[data-theme="dark"] .theme-btn .ico-sun { display: block !important; }
html[data-theme="dark"] .theme-btn .ico-moon { display: none !important; }
html[data-theme="light"] .theme-btn .ico-sun { display: none !important; }
html[data-theme="light"] .theme-btn .ico-moon { display: block !important; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1114; --card: #171a1f; --seg: #22262c; --ink: #e7e9ec; --muted: #959ba3; --rule: #2a2f36; --rule-strong: #3c424a; --hover: #1c2026;
    --accent: #facc15; --accent-ink: #1c1603; --accent-soft: #2b240b; --tld: #facc15; --sig: #ef4444; --plat: #8b939e; --lo: #6fd39b; --no: #e8836f;
    --ok-soft: #15291f; --warn: #f2907a; --warn-soft: #33191a;
    color-scheme: dark;
  }
}
html[data-theme="kloss"] {
  --bg: #0e1114; --card: #171a1f; --seg: #22262c; --ink: #e7e9ec; --muted: #959ba3; --rule: #2a2f36; --rule-strong: #3c424a; --hover: #1c2026;
  --accent: #facc15; --accent-ink: #1c1603; --accent-soft: #2b240b; --tld: #facc15; --sig: #ef4444; --plat: #8b939e; --lo: #6fd39b; --no: #e8836f;
  --ok-soft: #15291f; --warn: #f2907a; --warn-soft: #33191a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

/* header */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--rule); }
.top .wrap { display: flex; align-items: center; gap: 20px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 7px; font-weight: 750; font-size: 19px; letter-spacing: -0.025em; color: var(--ink); text-decoration: none; }
.brand .tld { color: var(--tld); }
.mk-ico { width: 32px; height: 32px; flex: none; margin: -4px 0; }
.mk-ico .glass { fill: none; stroke: var(--ink); }
.mk-ico .liquid { fill: var(--accent); }
.mk-ico .bub { fill: #fff; opacity: .45; }
.mk-ico .dot { fill: var(--sig); }
.mk-ico .sig { fill: none; stroke: var(--sig); }
.top nav { display: flex; gap: 2px; padding: 3px; background: var(--seg); border-radius: 999px; }
.top nav a { padding: 5px 14px; border-radius: 999px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 550; white-space: nowrap; }
.top nav a:hover { color: var(--ink); }
.top nav a[aria-current="page"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* text */
main.wrap { padding-bottom: 48px; }
h1 { font-weight: 720; font-size: clamp(30px, 5vw, 44px); line-height: 1.08; letter-spacing: -0.03em; margin: 36px 0 10px; }
.crumbs + h1 { margin-top: 14px; }
h2 { font-weight: 650; font-size: 19px; letter-spacing: -0.01em; margin: 36px 0 10px; }
h3 { font-weight: 650; font-size: 15px; margin: 20px 0 6px; }
.lead { font-size: 16px; color: var(--muted); max-width: 660px; margin: 0 0 22px; }
.lead b { color: var(--ink); font-weight: 650; }
p, li { max-width: 720px; }
.small { font-size: 13px; color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 20px; }
.card > h2:first-child { margin-top: 0; }
.flush { padding: 4px 20px; }
.note { margin-top: 36px; }
.note p:last-child { margin-bottom: 0; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 22px 0 0; padding: 0; font-size: 13px; color: var(--muted); }
.crumbs li + li::before { content: "›"; margin-right: 6px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }

.links { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; }
.links a { display: inline-block; padding: 6px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--rule); color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 550; }
.links a:hover { border-color: var(--rule-strong); background: var(--hover); }

/* tables sit in a card, like ETFlabbet's fund list */
.tblwrap { background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 4px 20px; overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; font-size: 12px; font-weight: 550; color: var(--muted); padding: 10px 8px 8px; border-bottom: 1px solid var(--rule); vertical-align: bottom; }
.tbl th[data-sort] { cursor: pointer; user-select: none; }
.tbl th[data-sort]:hover { color: var(--ink); }
.tbl th.sort-asc::after { content: " ↑"; color: var(--ink); }
.tbl th.sort-desc::after { content: " ↓"; color: var(--ink); }
.tbl td { padding: 10px 8px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl th:first-child, .tbl td:first-child { padding-left: 0; }
.tbl th:last-child, .tbl td:last-child { padding-right: 0; }
.tbl td a { color: var(--ink); text-decoration: none; font-weight: 550; }
.tbl td a:hover { color: var(--accent); }
.num, .r { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .ok { color: var(--lo); font-weight: 600; }
.tbl .no { color: var(--no); font-weight: 600; }
.tblwrap + .small { margin-top: 10px; }

/* type tabs */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--seg); border-radius: 999px; }
.sub { margin-top: 22px; }
.sub a { padding: 5px 14px; border-radius: 999px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600; white-space: nowrap; }
.sub a:hover { color: var(--ink); }
.sub a[aria-current="page"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.sub + h1 { margin-top: 18px; }

/* cheapest per group */
.areas { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin: 0 0 8px; }
.area { display: flex; flex-direction: column; gap: 2px; min-width: 0; background: var(--card); border: 1px solid var(--rule); border-radius: 12px; padding: 12px 14px; color: var(--ink); text-decoration: none; }
.area:hover { border-color: var(--rule-strong); background: var(--hover); }
.area b { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; color: var(--accent); }
.area .small:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* best buys */
.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin: 0 0 18px; }
.pick { display: flex; flex-direction: column; gap: 4px; min-width: 0; background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px 16px; color: var(--ink); text-decoration: none; }
.pick:hover { border-color: var(--rule-strong); background: var(--hover); }
.pick > .small:first-child { font-weight: 650; color: var(--accent); }
.pick b { font-size: 15px; font-weight: 650; line-height: 1.35; }
.pick .pp { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.pick .pp strong { color: var(--ink); font-weight: 650; }
.pick .tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { display: inline-block; padding: 0 7px; border-radius: 999px; background: var(--seg); color: var(--muted); font-size: 11.5px; font-weight: 600; line-height: 19px; white-space: nowrap; vertical-align: 1px; }
.tag.ok { background: var(--ok-soft); color: var(--lo); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.badge { display: inline-block; margin: 0 0 12px; padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 650; }
ul.know { list-style: none; margin: 0; padding: 4px 20px; }
ul.know li { max-width: none; padding: 10px 0; border-bottom: 1px solid var(--rule); }
ul.know li:last-child { border-bottom: 0; }
ul.know b { font-weight: 650; }

/* shop & set lists */
.shops td small { display: block; margin-top: 2px; font-size: 13px; color: var(--muted); }
.shops td.num s { display: block; font-size: 13px; color: var(--muted); font-weight: 400; }
.shops td.num a { color: var(--accent); white-space: nowrap; }
.shops tr.out td b, .shops tr.out td.num { color: var(--muted); }
.shops tr.best td { background: color-mix(in srgb, var(--accent) 8%, transparent); }

/* product page */
dl.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 12px 0 18px; }
dl.facts > div { background: var(--card); border: 1px solid var(--rule); border-radius: 12px; padding: 12px 14px; }
dl.facts dt { font-size: 12px; color: var(--muted); }
dl.facts dd { margin: 2px 0 0; font-size: 16px; font-weight: 650; letter-spacing: -0.01em; }
.btn { display: inline-block; padding: 9px 18px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); text-decoration: none; font-weight: 600; font-size: 14px; }
.btn:hover { filter: brightness(1.08); }
.chart { margin: 18px 0 0; padding: 14px 16px 12px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart text { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart figcaption { margin-top: 8px; font-size: 13px; color: var(--muted); }
.spec th { width: 38%; font-size: 14px; font-weight: 500; color: var(--muted); padding: 10px 8px; vertical-align: top; }
.spec tbody tr:last-child th { border-bottom: 0; }

.foot { margin-top: 0; border-top: 1px solid var(--rule); font-size: 12px; color: var(--muted); }
.foot .wrap { padding-top: 20px; padding-bottom: 40px; }
.foot p { max-width: 640px; margin: 0 0 6px; }
.foot a { color: var(--muted); }
.foot a:hover { color: var(--ink); }

/* quick filter and the series table on the start page */
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 0 0 14px; }
.filters[hidden] { display: none; }
.filters .seg { flex-wrap: wrap; }
.filters .seg button { font: inherit; font-size: 14px; font-weight: 600; padding: 5px 12px; border: 0; border-radius: 999px; background: none; color: var(--muted); cursor: pointer; white-space: nowrap; }
.filters .seg button:hover { color: var(--ink); }
.filters .seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.flags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.flags button { font: inherit; font-size: 13.5px; font-weight: 600; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--rule-strong); background: var(--card); color: var(--ink); cursor: pointer; white-space: nowrap; }
.flags button:hover { background: var(--hover); }
.flags button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.flags button[aria-pressed="true"]::before { content: "✓ "; }
.filters button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fsearch { font: inherit; font-size: 13.5px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--rule-strong); background: var(--card); color: var(--ink); width: 210px; }
.fsearch::placeholder { color: var(--muted); }
.fcount { margin: 0; flex-basis: 100%; }

.series td { vertical-align: middle; }
.series td.c-name { width: 38%; min-width: 220px; }
.series td small { display: block; margin-top: 1px; font-size: 13px; color: var(--muted); }
.series td .tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.series td.c-price { white-space: nowrap; }
.series td.c-price small { font-size: 12.5px; }
.series td.c-price small a { color: var(--accent); font-weight: 550; }
.ptb, .ppb { color: var(--lo); font-weight: 700; }
.set-cell { display: flex; align-items: center; gap: 10px; }
.set-thumb { width: 38px; height: 38px; border-radius: 6px; background: #fff; object-fit: contain; padding: 2px; border: 1px solid var(--rule); flex-shrink: 0; }
.set-head { display: flex; align-items: center; gap: 16px; margin: 22px 0 6px; }
.set-head img { width: 72px; height: 72px; border-radius: 10px; background: #fff; object-fit: contain; padding: 4px; border: 1px solid var(--rule); flex-shrink: 0; }
.set-head h1 { margin: 0; }

.promo { display: flex; flex-direction: column; gap: 4px; margin-top: 18px; color: var(--ink); text-decoration: none; }
.promo:hover { border-color: var(--rule-strong); background: var(--hover); }
.promo b { font-size: 16px; color: var(--accent); }
.promo span { font-size: 14px; color: var(--muted); }

/* accessories */
.forget { margin-top: 28px; }
.forget ul { margin: 0; padding-left: 20px; }
.forget li { margin: 6px 0; }

/* Calculator (/byggbord) */
.raid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; margin: 0 0 14px; }
.fld { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fld > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.fld > span b { color: var(--ink); }
.fld select, .fld input[type=number] { font: inherit; font-size: 15px; padding: 8px 10px; border: 1px solid var(--rule-strong); border-radius: 10px; background: var(--card); color: var(--ink); width: 100%; min-width: 0; }
.fld .seg { flex-wrap: wrap; align-self: flex-start; }
.fld .seg button { font: inherit; font-size: 14px; font-weight: 600; padding: 5px 12px; border: 0; border-radius: 999px; background: none; color: var(--muted); cursor: pointer; }
.fld .seg button:hover { color: var(--ink); }
.fld .seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.need-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px 14px; }
.need { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; }
.fld .need input[type=number] { width: 84px; flex: none; }
.kl { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.kl span small { display: block; color: var(--muted); font-size: .85em; }
.kl b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.kl.sum b { font-size: 1.15em; color: var(--accent); }
.kl:last-of-type { border-bottom: 0; }

@media (max-width: 900px) {
  .areas { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .tblwrap { padding: 4px 14px; }
  .card { padding: 16px; }
  dl.facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .raid { grid-template-columns: minmax(0, 1fr); }
  .series thead { display: none; }
  .series, .series tbody { display: block; }
  .series tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
  .series tbody tr:last-child { border-bottom: 0; }
  .series td { display: block; padding: 0 !important; border: 0 !important; text-align: left !important; white-space: normal; }
  .series td.c-name { grid-column: 1 / -1; width: auto; min-width: 0; }
  .series td[data-l]::before { content: attr(data-l); display: block; font-size: 11.5px; color: var(--muted); }
  .tbl.shops .go { display: none; }
  .tbl.shops td small { word-break: break-word; }
}
@media (max-width: 560px) {
  .top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .brand { flex: 0 0 auto; font-size: 17px; }
  .brand span { display: none; }
  .top nav { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .top nav::-webkit-scrollbar { display: none; }
  .top nav a { padding: 5px 9px; font-size: 13px; }
  .top nav .lg { display: none; }
  .theme-btn { flex: 0 0 34px !important; width: 34px !important; height: 34px !important; min-width: 34px !important; min-height: 34px !important; margin-left: 2px; }
  .sub a { padding: 5px 10px; font-size: 13px; }
}
@media (max-width: 520px) {
  .filters .seg { display: flex; flex-wrap: wrap; width: 100%; border-radius: 16px; }
  .filters .seg button { flex: 1 1 auto; padding: 5px 9px; }
}

/* Visual LDraw part breakdown on /byggbord */
.part-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 10px;
  margin: 14px 0 4px;
}
.part-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 11px;
  padding: 9px 11px;
}
.part-img-wrap {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  flex-shrink: 0;
}
.part-img-wrap img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.part-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.part-meta b {
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
  line-height: 1.25;
}
.part-meta small {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
}

.pick-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 2px; }
.pick-img { width: 58px; height: 58px; object-fit: contain; background: #fff; border: 1px solid var(--rule); border-radius: 8px; padding: 3px; flex-shrink: 0; }
.pick-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pick-lbl { font-weight: 650; color: var(--accent); }
.area-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.area-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.area-img { width: 42px; height: 42px; object-fit: contain; background: #fff; border: 1px solid var(--rule); border-radius: 8px; padding: 2px; flex-shrink: 0; }

/* Interactive LEGO Track Studio (/byggbord) – Mobile-First & Zero-Jank */
.studio-ctrl {
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ctrl-top-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ctrl-top-row .seg {
  display: inline-flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  max-width: 100%;
  width: fit-content;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.ctrl-top-row .seg::-webkit-scrollbar { display: none; }
.ctrl-top-row .seg button {
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  padding: 5px 11px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
}
.ctrl-top-row .seg button:hover {
  color: var(--ink);
}
.ctrl-top-row .seg button[aria-pressed="true"] {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.ctrl-inputs-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
}
.ctrl-inputs-row[hidden] { display: none !important; }
.ctrl-dims, .ctrl-train {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  flex: 1 1 auto;
}
.ctrl-dims[hidden], .ctrl-train[hidden] { display: none !important; }
.shops-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.shops-head h2 {
  margin: 0;
}
.shops-head .ctrl-train {
  flex: 0 1 auto;
}
.mini-fld {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 550;
}
.mini-fld.mini-grow {
  flex: 1 1 180px;
}
.mini-fld input[type="number"] {
  width: 78px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--rule-strong);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
}
.mini-fld select {
  width: 100%;
  padding: 6px 9px;
  border-radius: 8px;
  border: 1px solid var(--rule-strong);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 550;
}
.mini-chk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink);
  padding: 6px 4px;
  cursor: pointer;
}
.mini-chk[hidden] { display: none !important; }

.studio-card {
  margin: 0 0 14px;
  padding: 12px 14px;
}
.canvas-hud-top {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  pointer-events: none;
}
.canvas-status {
  pointer-events: auto;
  font-size: 12px;
  color: var(--ink);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(6px);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 3px 10px;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.canvas-status b { color: var(--ink); }
.canvas-status .loop-ok {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--lo);
  font-weight: 700;
  font-size: 11.5px;
}
.canvas-status .port-pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 11.5px;
}
.canvas-status .out-warn {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-weight: 700;
  font-size: 11.5px;
}
.canvas-zoom {
  pointer-events: auto;
  display: inline-flex;
  gap: 2px;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(6px);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 2px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}
.zoom-btn {
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.zoom-btn:hover {
  background: var(--hover);
}

#bb-svg-wrap {
  background: color-mix(in srgb, var(--bg) 75%, var(--card));
  border: 1px solid var(--rule-strong);
  border-radius: 11px;
  overflow: hidden;
  position: relative;
}
#bb-svg {
  display: block;
  width: 100%;
  height: clamp(235px, 42vh, 410px);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* 6-Piece Single-Row LEGO Track Dock directly below canvas */
.studio-dock {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}
.dock-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px 5px;
  border-radius: 10px;
  border: 1px solid var(--rule-strong);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  font: inherit;
  transition: border-color 0.12s, background 0.12s, transform 0.08s;
}
.dock-btn:hover {
  border-color: var(--accent);
  background: var(--hover);
}
.dock-btn:active {
  transform: scale(0.95);
  border-color: var(--accent);
}
.dock-svg {
  width: 100%;
  max-width: 56px;
  height: 28px;
  display: block;
  pointer-events: none;
}
.dock-btn b {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  pointer-events: none;
}
.dock-btn small {
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.1;
  white-space: nowrap;
  pointer-events: none;
}

/* Streamlined 1-row Action & Template Bar below dock */
.studio-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
.tool-btn {
  font: inherit;
  font-size: 12.5px;
  font-weight: 650;
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px solid var(--rule-strong);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.tool-btn[hidden] { display: none !important; }
.tool-btn:hover {
  background: var(--hover);
  border-color: var(--accent);
}
.tool-btn.ok-btn {
  background: var(--ok-soft);
  color: var(--lo);
  border-color: color-mix(in srgb, var(--lo) 40%, var(--rule));
  font-weight: 700;
}
.tool-btn.ok-btn:hover {
  border-color: var(--lo);
}
.tool-btn.warn:hover {
  border-color: var(--no);
  color: var(--no);
}
.tpl-select {
  font: inherit;
  font-size: 12.5px;
  font-weight: 650;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--rule-strong);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  margin-left: auto;
}

#bb-figcaption {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 8px;
}

/* 2x2 / 4-col KPI Grid inside #bb-out */
.bb-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.bb-kpi {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bb-kpi.hi {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--rule));
}
.bb-kpi-lbl {
  font-size: 11.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.bb-kpi-val {
  font-size: 18px;
  font-weight: 750;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.bb-kpi-sub {
  font-size: 12px;
  color: var(--muted);
}

/* Interactive SVG Track Elements */
.trk-piece {
  cursor: grab;
}
.trk-piece:active {
  cursor: grabbing;
}
.trk-piece.selected .trk-sel-halo {
  stroke: #facc15;
  stroke-width: 0.55;
  stroke-dasharray: 1.2 0.7;
}
.trk-piece.out-of-bounds .trk-sel-halo {
  stroke: #ef4444;
  stroke-width: 0.65;
}
.sw-box {
  cursor: pointer;
}
.conn-port {
  cursor: pointer;
}
@keyframes portPulse {
  0%, 100% { r: 2.1px; opacity: 0.95; }
  50% { r: 3.1px; opacity: 0.35; }
}
.port-pulse {
  animation: portPulse 1.5s ease-in-out infinite;
}
.drag-floater {
  position: fixed;
  z-index: 999;
  pointer-events: none;
  padding: 5px 10px;
  background: rgba(23, 26, 31, 0.92);
  color: #facc15;
  border: 1.5px solid #facc15;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  transform: translate(-50%, -100%);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}

@media (max-width: 760px) {
  .bb-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .studio-ctrl {
    padding: 10px 11px;
    gap: 8px;
  }
  .studio-card {
    padding: 10px 11px;
  }
  #bb-svg {
    height: clamp(220px, 38vh, 320px);
  }
  .studio-dock {
    gap: 4px;
    margin-top: 8px;
  }
  .dock-btn {
    padding: 5px 2px 4px;
    border-radius: 8px;
  }
  .dock-svg {
    max-width: 46px;
    height: 24px;
  }
  .dock-btn b {
    font-size: 11px;
  }
  .dock-btn small {
    font-size: 9.5px;
  }
  .mini-fld input[type="number"] {
    width: 66px;
    padding: 5px 6px;
  }
}

[hidden] { display: none !important; }

/* Navigation, Search Hero, Section Headers & Large Product Cards */
html, body {
  overflow-x: hidden;
  max-width: 100%;
}
.top nav a[aria-current="page"] {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}

/* Theme bar on theme & category pages */
.theme-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 -10px;
  padding: 6px 10px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 12px;
  max-width: 100%;
  overflow: hidden;
}
.tb-lbl {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.tb-scroll {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  flex: 1 1 auto;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tb-scroll::-webkit-scrollbar { display: none; }
.tb-scroll a {
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
}
.tb-scroll a:hover { color: var(--ink); background: var(--hover); }
.tb-scroll a[aria-current="page"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

/* Section headers & kickers */
.sec-block {
  margin-top: 28px;
}
.sec-hdr {
  margin: 24px 0 12px;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}
.sec-block:first-child .sec-hdr {
  margin-top: 12px;
}
.sec-kicker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 3px;
}
.sec-kicker::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--accent);
}
.sec-hdr h2 {
  margin: 0;
  font-size: clamp(19px, 3vw, 22px);
}

/* Prominent Search & Filter Panel at the top */
.search-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 16px 18px;
  margin: 16px 0 20px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  border: 1.5px solid var(--rule-strong);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
}
.search-bar .s-ico {
  position: absolute;
  left: 14px;
  width: 20px;
  height: 20px;
  color: var(--accent);
  pointer-events: none;
}
.search-bar .fsearch {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  padding: 11px 84px 11px 44px;
  border-radius: 12px;
  border: 1.5px solid var(--rule-strong);
  background: var(--bg);
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-bar .fsearch:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-bar .fclear {
  position: absolute;
  right: 8px;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--rule-strong);
  background: var(--seg);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}
.search-bar .fclear:hover {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
.filter-row {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  min-width: 0;
}
.f-lbl {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.search-panel .seg,
.search-panel .flags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  min-width: 0;
  background: transparent;
  padding: 0;
  border-radius: 0;
}
.search-panel .seg button,
.search-panel .flags button {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--rule-strong);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
}
.search-panel .seg button:hover,
.search-panel .flags button:hover {
  border-color: var(--accent);
}
.search-panel .seg button[aria-pressed="true"],
.search-panel .flags button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}
.fstatus {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-width: 0;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
  flex-wrap: wrap;
}
.fstatus .fcount {
  flex-basis: auto;
  font-weight: 600;
  color: var(--ink);
}
.sort-lbl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.fsort {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--rule-strong);
  background: var(--bg);
  color: var(--ink);
}

/* Larger images in theme cards (.areas) and top picks (.picks) */
.areas {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.area {
  padding: 14px;
  gap: 6px;
}
.area-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.area-img {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  padding: 4px;
}
.area-foot {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pick-img {
  width: 88px;
  height: 88px;
  border-radius: 10px;
  padding: 5px;
}

/* Larger images & badges in set table */
.set-cell {
  display: flex;
  align-items: center;
  gap: 14px;
}
.set-thumb-link {
  display: block;
  flex-shrink: 0;
}
.set-thumb {
  width: 68px;
  height: 68px;
  border-radius: 10px;
  background: #fff;
  object-fit: contain;
  padding: 4px;
  border: 1px solid var(--rule);
  display: block;
}
.set-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.set-badges {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.snum {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--seg);
  color: var(--muted);
}
.set-info .sn b {
  font-size: 15.5px;
  line-height: 1.3;
}
.shop-pills {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.sp-btn {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 650;
  background: var(--seg);
  border: 1px solid var(--rule-strong);
  color: var(--ink) !important;
  text-decoration: none;
  white-space: nowrap;
}
.sp-btn:hover {
  border-color: var(--accent);
  color: var(--accent) !important;
}

/* Set detail page hero */
.set-hero {
  margin-top: 18px;
  padding: 24px;
}
.set-head {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  align-items: center;
  gap: 28px;
  margin: 0;
}
.set-img-stage {
  width: 100%;
  height: 260px;
  border-radius: 16px;
  background: #ffffff;
  border: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.set-head img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border: 0;
  padding: 0;
  border-radius: 8px;
  background: transparent;
}
.set-head-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.set-head-info h1 {
  margin: 2px 0 4px;
  font-size: clamp(24px, 4vw, 36px);
}
.set-head-info .lead {
  margin: 0 0 8px;
}
.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.btn-sec {
  background: var(--seg);
  color: var(--ink);
  border: 1px solid var(--rule-strong);
}
.btn-sec:hover {
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 900px) {
  .areas { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .search-panel {
    padding: 14px;
    gap: 10px;
  }
  .search-bar .fsearch {
    padding: 10px 72px 10px 40px;
    font-size: 16px;
  }
  .search-panel .seg button,
  .search-panel .flags button {
    padding: 5px 10px;
    font-size: 12.5px;
  }

  /* Clean mobile product cards in set list */
  .tblwrap {
    padding: 4px 12px;
  }
  .series tr.sr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--rule);
    align-items: center;
  }
  .series td.c-name {
    grid-column: 1 / -1;
  }
  .series td.c-theme,
  .series td.c-pieces {
    display: none !important;
  }
  .set-thumb {
    width: 76px;
    height: 76px;
  }
  .series td.c-ppb {
    grid-column: 1;
    grid-row: 2;
    font-size: 16px;
  }
  .series td.c-disc {
    grid-column: 1;
    grid-row: 3;
    font-size: 13px;
  }
  .series td.c-disc small {
    display: inline;
    margin-left: 6px;
  }
  .series td.c-price {
    grid-column: 2;
    grid-row: 2 / span 2;
    text-align: right !important;
    align-self: end;
  }
  .series td.c-price::before {
    text-align: right;
  }
  .series td.c-price .price-val {
    font-size: 18px;
    display: block;
  }
  .shop-pills {
    justify-content: flex-end;
    margin-top: 6px;
  }
  .sp-btn {
    padding: 5px 10px;
    font-size: 12.5px;
  }

  .set-hero {
    padding: 16px;
  }
  .set-head {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }
  .set-img-stage {
    width: 100%;
    height: clamp(230px, 64vw, 300px);
    padding: 12px;
  }
  .set-head img {
    width: 100%;
    height: 100%;
  }
}

[hidden] { display: none !important; }

/* Set Size & Shelf Fit Visualizer (#set-fit-app & /byggbord model selector) */
.ctrl-model-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
}
.ctrl-model-row select {
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--rule-strong);
  background: var(--bg);
  color: var(--ink);
  width: 100%;
  max-width: 100%;
}
.ctrl-model-btns {
  display: flex;
  gap: 6px;
}

.fit-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.fit-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fit-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.fit-presets button {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--rule-strong);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}
.fit-presets button:hover {
  border-color: var(--accent);
}
.fit-presets button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}
.fit-dims-row {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}
.fit-dims-row .mini-fld {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.fit-dims-row .mini-fld span {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.fit-dims-row input[type="number"] {
  width: 96px;
  padding: 6px 9px;
  border-radius: 8px;
  border: 1px solid var(--rule-strong);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}
.fit-stage {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #0b0e14;
  border: 1px solid var(--rule-strong);
  border-radius: 14px;
  padding: 14px;
}
.fit-status {
  font-size: 14px;
  line-height: 1.45;
  color: #e2e8f0;
}
.fit-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  margin-right: 4px;
}
.fit-badge.ok {
  background: rgba(74, 222, 128, 0.18);
  color: #4ade80;
}
.fit-badge.warn {
  background: rgba(239, 68, 68, 0.22);
  color: #f87171;
}
#fit-svg {
  display: block;
  touch-action: none;
  user-select: none;
  width: 100%;
  height: clamp(200px, 42vw, 310px);
  border-radius: 10px;
}
.fit-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
