/* 201-MCT: the project site. Same bench as the BOM site: solder-mask ground, silkscreen type, gold pads. */

:root {
  color-scheme: dark light;

  --ground: #082a21;
  --surface: #0c3428;
  --field: #061f18;
  --rule: rgba(236, 238, 220, 0.14);
  --rule-strong: rgba(236, 238, 220, 0.32);
  --edge: rgba(236, 238, 220, 0.46);
  --silk: #eceedc;
  --silk-dim: #a6beb0;
  --placeholder: #7f9d8e;
  --gold: #e2b94b;
  --gold-ink: #1b1500;
  --accent: #e2b94b;
  --gold-soft: rgba(226, 185, 75, 0.11);
  --hover: rgba(236, 238, 220, 0.04);
  --warn: #f2a65e;
  --danger: #ff9484;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.25), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
  --mat: #ffffff;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* narrowest table: 706px of columns + 8 gaps of 10px + 24px row padding = 810px, inside the 901px window where the
     cards hand over (minus 48px of gutters and a scrollbar) */
  --cols: minmax(180px, 2.2fr) minmax(100px, 1.2fr) minmax(80px, 1fr) 44px 44px 70px 76px minmax(72px, 0.9fr) 40px;
  --gutter: 24px;
  --bar: 56px;
  --tabbar: 0px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --ground: #f2f3ec;
    --surface: #ffffff;
    --field: #fbfbf7;
    --rule: rgba(14, 38, 28, 0.16);
    --rule-strong: rgba(14, 38, 28, 0.38);
    --edge: rgba(14, 38, 28, 0.52);
    --silk: #12211a;
    --silk-dim: #475a50;
    --placeholder: #5a6c61;
    --accent: #7a5a00;
    --gold-soft: rgba(226, 185, 75, 0.24);
    --hover: rgba(14, 38, 28, 0.04);
    --warn: #8f4300;
    --danger: #a8281a;
    --shadow: 0 1px 0 rgba(14, 38, 28, 0.06), 0 8px 24px -12px rgba(14, 38, 28, 0.25);
  }
}

* { box-sizing: border-box; }

html { background: var(--ground); -webkit-text-size-adjust: 100%; }
html.lb-open { overflow: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--silk);
  font: 16px/1.5 var(--sans);
  scrollbar-color: var(--rule-strong) transparent;
  overflow-wrap: break-word;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }
#app.has-tabs { padding-bottom: calc(var(--tabbar) + var(--safe-b)); }

::selection { background: var(--gold); color: var(--gold-ink); }
input, textarea, select { caret-color: var(--gold); accent-color: var(--gold); }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1:focus { outline: none; }

a { color: inherit; }
img { max-width: 100%; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--silk-dim); }
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 50;
  padding: 10px 14px;
  background: var(--gold);
  color: var(--gold-ink);
  font-weight: 600;
  border-radius: 4px;
}
.skip:focus { top: 8px; }

.lab, .eyebrow {
  margin: 0;
  font: 600 11px/1.2 var(--sans);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--silk-dim);
}
.eyebrow { font-family: var(--mono); letter-spacing: 0.12em; color: var(--accent); margin-bottom: 10px; }

/* ---- top bar and navigation ------------------------------------------------ */

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--bar);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 max(var(--gutter), env(safe-area-inset-right, 0px)) 0 max(var(--gutter), env(safe-area-inset-left, 0px));
  background: var(--ground);
  border-bottom: 1px solid var(--rule);
}

.mark {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  text-decoration: none;
  font: 700 17px/1 var(--mono);
  letter-spacing: 0.14em;
  color: var(--silk);
}
.mark svg { color: var(--gold); }

.nav { display: flex; align-items: stretch; gap: 2px; min-width: 0; height: 100%; }
.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  color: var(--silk-dim);
  font: 600 14px/1 var(--sans);
  text-decoration: none;
  white-space: nowrap;
}
.nav-link:hover { color: var(--silk); }
.nav-link[aria-current="page"] { color: var(--silk); }
.nav-link[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 9px;
  right: 9px;
  bottom: -1px;
  height: 2px;
  background: var(--gold);
}
.nav-link:focus-visible { outline-offset: -4px; }
.nav-ico, .l-short { display: none; }

.bar-end { margin-left: auto; flex: none; display: flex; gap: 4px; }
.bar-end .btn { text-decoration: none; }

.foot {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  padding: 28px var(--gutter) 24px;
  font-size: 12px;
  color: var(--silk-dim);
}

/* ---- layout ----------------------------------------------------------------- */

main {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px max(var(--gutter), env(safe-area-inset-right, 0px)) 56px max(var(--gutter), env(safe-area-inset-left, 0px));
}
main.center { display: grid; place-items: center; min-height: 60vh; }

@media (prefers-reduced-motion: no-preference) {
  .view { animation: arrive 180ms cubic-bezier(0.16, 1, 0.3, 1); }
  @keyframes arrive { from { transform: translateY(3px); } to { transform: none; } }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.ph-text { min-width: 0; max-width: 820px; }
.ph-actions { display: flex; gap: 10px; flex-wrap: wrap; }

h1 {
  margin: 0;
  font: 650 28px/1.2 var(--sans);
  letter-spacing: -0.01em;
  text-wrap: balance;
}
h2 { margin: 0; font: 650 19px/1.3 var(--sans); }
h3 { margin: 0; }

.lede { margin: 10px 0 0; color: var(--silk-dim); font-size: 16px; max-width: 68ch; }

.block { margin-top: 44px; }
.block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  color: var(--accent);
  font: 600 14px/1 var(--sans);
  text-decoration: none;
}
.more:hover { text-decoration: underline; text-underline-offset: 3px; }

.two { display: grid; grid-template-columns: 1fr; gap: 0 24px; }
@media (min-width: 760px) { .two { grid-template-columns: 1fr 1fr; } }
.card {
  padding: 20px 22px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--surface);
}
.two .card { margin-top: 32px; }
.card .block-head { margin-bottom: 10px; }

/* ---- prose from content.json ------------------------------------------------- */

.prose { max-width: 72ch; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p, .prose ul, .prose ol { margin: 0 0 12px; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.prose a { color: var(--accent); text-underline-offset: 3px; }
.prose code { font: 0.92em var(--mono); padding: 1px 4px; border-radius: 3px; background: var(--rule); }
.prose strong { font-weight: 650; }
.lede-prose { font-size: 17px; line-height: 1.55; }

.steps, .bullets { margin: 0; padding: 0; list-style: none; }
.steps { counter-reset: step; }
.steps li, .bullets li { position: relative; padding: 8px 0 8px 34px; border-top: 1px solid var(--rule); }
.steps li:first-child, .bullets li:first-child { border-top: 0; }
.steps li::before {
  counter-increment: step;
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 10px;
  font: 600 12px/1.4 var(--mono);
  color: var(--accent);
}
.bullets li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 15px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--accent);
  border-radius: 50%;
}

/* ---- facts row: mono facts separated by hairlines ------------------------------ */

.facts {
  display: flex;
  flex-wrap: wrap;
  margin: 28px 0 0;
  padding: 16px 0;
  border-top: 1px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule-strong);
}
.fact { min-width: 0; padding: 4px 22px; border-left: 1px solid var(--rule); }
.fact:first-child { padding-left: 0; border-left: 0; }
.fact dt { font: 600 11px/1.2 var(--sans); letter-spacing: 0.09em; text-transform: uppercase; color: var(--silk-dim); white-space: nowrap; }
.fact dd { margin: 0; }
.fact-val { margin-top: 6px !important; font: 600 18px/1.2 var(--mono); }
.fact-note { margin-top: 3px !important; font-size: 12.5px; color: var(--silk-dim); }
.fact.cart .fact-val { color: var(--accent); }
.fact.warn dt, .fact.warn .fact-val { color: var(--warn); }
@media (min-width: 1100px) {
  .facts { flex-wrap: nowrap; }
  .fact { flex: 1 1 0; }
  .fact dt { white-space: normal; }
}

/* ---- images on a white mat ----------------------------------------------------- */

.mat {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1800 / 1100;
  overflow: hidden;
  background: var(--mat);
  border: 1px solid var(--rule-strong);
  border-radius: 4px;
}
.mat-img { display: block; width: 100%; height: 100%; object-fit: contain; }
.mat-btn { padding: 0; font: inherit; color: inherit; cursor: zoom-in; }
.mat-btn:hover, .still:hover .mat, .sheet:hover .mat { border-color: var(--accent); }
.zoom {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 3px;
  background: rgba(8, 42, 33, 0.84);
  color: #eceedc;
  font: 600 12px/1 var(--sans);
}

.stills { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.still {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--silk);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
button.still { cursor: zoom-in; }
.still-cap { font-size: 14px; color: var(--silk-dim); }

/* ---- timeline entries ------------------------------------------------------------- */

.entries { margin: 0; padding: 0; list-style: none; }
.entry { padding: 12px 0; border-top: 1px solid var(--rule); }
.entry:first-child { border-top: 0; }
.e-title { margin: 0; font: 600 15px/1.4 var(--sans); }
.e-body { margin: 4px 0 0; font-size: 14.5px; color: var(--silk-dim); }
.e-meta { margin: 4px 0 0; font-size: 12px; color: var(--silk-dim); }
.entry.is-milestone .e-title { color: var(--accent); }
.tag {
  display: inline-block;
  margin-right: 8px;
  padding: 3px 6px;
  border: 1px solid currentColor;
  border-radius: 3px;
  font: 600 10.5px/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  vertical-align: 2px;
}
.tag.cart { margin: 6px 0 0; border-color: var(--gold); background: var(--gold); color: var(--gold-ink); }

/* ---- buttons / fields ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--edge);
  border-radius: 4px;
  background: transparent;
  color: var(--silk);
  font: 600 14px/1 var(--sans);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover { border-color: var(--silk); background: var(--hover); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.quiet { border-color: transparent; color: var(--silk-dim); }
.btn.quiet:hover { color: var(--silk); border-color: var(--rule); }
.btn:disabled { opacity: 0.6; cursor: default; }
.icon-btn { width: 38px; padding: 0; }

.in {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--edge);
  border-radius: 3px;
  background: var(--field);
  color: var(--silk);
  font: 15px/1 var(--sans);
}
.in::placeholder { color: var(--placeholder); opacity: 1; }
.in:hover { border-color: var(--silk-dim); }
.in:focus-visible { outline-offset: 0; border-color: var(--accent); }
select.in { padding-right: 4px; }

.fld { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fld > span { font: 600 11px/1 var(--sans); letter-spacing: 0.09em; text-transform: uppercase; color: var(--silk-dim); }

.panel { max-width: 640px; display: flex; flex-direction: column; gap: 18px; }
.panel p { margin: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-error { margin: 0; color: var(--danger); font-size: 14px; }

/* ---- sign in -------------------------------------------------------------------- */

main.signin {
  flex: 1;
  display: grid;
  place-items: center;
  padding-top: 24px;
  padding-bottom: 24px;
}
.auth {
  width: 100%;
  max-width: 380px;
  padding: 32px 28px 28px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}
.auth-mark { display: flex; justify-content: center; color: var(--gold); }
.auth-title { margin-top: 14px; font: 700 24px/1 var(--mono); letter-spacing: 0.14em; }
.auth-sub { margin: 10px 0 0; font-size: 14px; }
.auth form { display: flex; flex-direction: column; gap: 14px; margin-top: 24px; text-align: left; }
.auth .in { height: 44px; font-size: 16px; font-family: var(--mono); }
.auth .btn { min-height: 44px; width: 100%; font-size: 15px; }
.auth-title-sm { font: 700 19px/1.25 var(--sans); letter-spacing: 0; text-wrap: balance; }
.auth .pw-hint { margin: -6px 0 0; font-size: 13px; }
.auth .check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; color: var(--silk-dim); cursor: pointer; }
.auth .check input { width: 18px; height: 18px; margin: 0; }
.auth-done { margin-top: 24px; }
.notice { margin: 0 0 22px; }
.notice a { color: var(--accent); font-weight: 600; text-underline-offset: 3px; }
@media (max-width: 640px) {
  .bar-end a.btn { width: 44px; padding: 0; }
  .bar-end a.btn .btn-text { display: none; }
}

/* ---- boards ---------------------------------------------------------------------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  font: 600 14px/1 var(--sans);
  text-decoration: none;
  color: var(--silk);
}
.chip:hover { border-color: var(--accent); color: var(--accent); }

.board {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--rule-strong);
  scroll-margin-top: calc(var(--bar) + 12px);
}
.board-head { display: flex; align-items: baseline; gap: 6px 14px; flex-wrap: wrap; margin-bottom: 14px; }
.board-head h2 { font-size: 22px; }
.board-head .mono { font-size: 13px; }
.board-body { display: grid; grid-template-columns: 1fr; gap: 24px; }
@media (min-width: 1000px) { .board-body { grid-template-columns: minmax(0, 1.9fr) minmax(260px, 1fr); gap: 36px; } }

.viewer { min-width: 0; }
.tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 12px;
}
.tab {
  flex: none;
  min-height: 42px;
  padding: 0 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--silk-dim);
  font: 600 14px/1 var(--sans);
  white-space: nowrap;
  cursor: pointer;
}
.tab:hover { color: var(--silk); }
.tab[aria-selected="true"] { color: var(--silk); border-bottom-color: var(--gold); }
.tab:focus-visible { outline-offset: -3px; }
.board-mat { aspect-ratio: 16 / 10; }

.board-info { min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.board-sum { margin: 0; font-size: 16px; }
.kv { display: grid; gap: 12px; margin: 0; }
.kv dt { font: 600 11px/1.2 var(--sans); letter-spacing: 0.09em; text-transform: uppercase; color: var(--silk-dim); }
.kv dd { margin: 4px 0 0; font-size: 15px; }
.board-info .lab { margin-bottom: 4px; }
.board-info .bullets li { font-size: 15px; }

/* ---- assembly -------------------------------------------------------------------- */

.frame-wrap {
  height: 70vh;
  min-height: 320px;
  overflow: hidden;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--mat);
}
.frame { display: block; width: 100%; height: 100%; border: 0; }

/* ---- schematics ------------------------------------------------------------------ */

.sheets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 20px; margin: 0; padding: 0; list-style: none; }
.sheet {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--silk);
  font: inherit;
  text-align: left;
  cursor: zoom-in;
}
.sheet-mat { aspect-ratio: 1.414; }
.sheet-cap { display: flex; align-items: baseline; gap: 10px; }
.sheet-n { flex: none; font-size: 13px; font-weight: 600; color: var(--accent); }
.sheet-t { font: 600 15px/1.35 var(--sans); }

/* ---- BOM ------------------------------------------------------------------------- */

.live { margin: 0 0 18px; font-size: 14px; color: var(--silk-dim); }
.live a { color: var(--accent); font-weight: 600; text-underline-offset: 3px; }
.live-dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; vertical-align: 1px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.page-bom .lede { font-size: 13px; }

.bom-facts { margin-top: 4px; }
.vendors { margin-top: 14px; }
.vendors ul { display: flex; flex-wrap: wrap; gap: 8px 0; margin: 8px 0 0; padding: 0; list-style: none; }
.vendors li { display: flex; align-items: baseline; gap: 10px; padding: 0 18px; border-left: 1px solid var(--rule); font-size: 14px; }
.vendors li:first-child { padding-left: 0; border-left: 0; }
.v-name { font-weight: 600; }
.v-lines { font-size: 12px; color: var(--silk-dim); }
.v-cost { font-weight: 600; }

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.search-wrap { position: relative; flex: 1 1 260px; max-width: 440px; }
.search-ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--silk-dim); pointer-events: none; }
.in.search { padding-left: 34px; font-family: var(--sans); }

.seg { display: inline-flex; border: 1px solid var(--edge); border-radius: 4px; overflow: hidden; }
.seg button {
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-right: 1px solid var(--rule);
  background: transparent;
  color: var(--silk-dim);
  font: 600 13.5px/1 var(--sans);
  white-space: nowrap;
  cursor: pointer;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--silk); }
.seg button[aria-pressed="true"] { background: var(--rule); color: var(--silk); }
.seg button:focus-visible { outline-offset: -3px; }
.seg .n { margin-left: 6px; font: 12px/1 var(--mono); opacity: 0.85; }

.list-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 0 8px; }
.count { margin: 0; font: 13px/1.2 var(--mono); color: var(--silk-dim); }
.sort-wrap { display: none; align-items: center; gap: 8px; }
.sort-sel { width: auto; min-width: 0; max-width: 160px; }
.dir-btn .icon { transition: none; }
.dir-btn[data-dir="-1"] svg { transform: scaleY(-1); }

.table { border-top: 1px solid var(--rule-strong); }
.thead, .row { display: grid; grid-template-columns: var(--cols); column-gap: 10px; align-items: center; }
.thead {
  position: sticky;
  top: var(--bar);
  z-index: 10;
  padding: 6px 12px;
  background: var(--ground);
  border-bottom: 1px solid var(--rule-strong);
}
.th {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  min-height: 30px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--silk-dim);
  font: 600 11px/1.2 var(--sans);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
}
span.th { cursor: default; }
.th:hover, .th.sorted { color: var(--silk); }
.th .sort-ico { flex: none; opacity: 0; }
.th:hover .sort-ico { opacity: 0.5; }
.th.sorted .sort-ico { opacity: 1; color: var(--accent); }
.th.sorted[data-dir="1"] .sort-ico { transform: rotate(180deg); }
.th.r { justify-self: end; flex-direction: row-reverse; }
.th.c { justify-self: center; }

.row { padding: 10px 12px; border-bottom: 1px solid var(--rule); }
.row:hover { background: var(--hover); }
.row.in-cart { background: var(--gold-soft); }
.cell { min-width: 0; font-size: 14px; }
.cell.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 13.5px; overflow-wrap: anywhere; }
.cell.r { text-align: right; justify-self: end; }
.cell.strong { font-weight: 600; }
.cell.short .cell-v { color: var(--warn); font-weight: 600; }
.cell .none { color: var(--placeholder); }
.cell-label { display: none; }
.link-c { justify-self: center; }

.part-c { display: flex; align-items: flex-start; gap: 12px; }
.part-text { flex: 1; min-width: 0; }
.thumb {
  flex: none;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 1px dashed var(--edge);
  border-radius: 3px;
  background: transparent;
  color: var(--silk-dim);
  overflow: hidden;
}
.thumb.has { border: 1px solid var(--rule-strong); background: var(--mat); cursor: zoom-in; }
.thumb.has:hover { border-color: var(--accent); }
.thumb-img { display: block; width: 100%; height: 100%; object-fit: contain; }

.name {
  display: inline-flex;
  align-items: flex-start;
  gap: 6px;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--silk);
  font: 600 15px/1.35 var(--sans);
  text-align: left;
  cursor: pointer;
}
.name:hover .name-text { text-decoration: underline; text-underline-offset: 3px; }
.name .chev { flex: none; margin-top: 3px; color: var(--silk-dim); }
.name[aria-expanded="true"] .chev { transform: rotate(180deg); }
.refs { margin: 3px 0 0; font-size: 12px; color: var(--silk-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.open {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--edge);
  border-radius: 3px;
  color: var(--accent);
}
.open:hover { border-color: var(--accent); }

.detail {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px 22px;
  margin-top: 10px;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--field);
}
.dfield { min-width: 0; }
.dfield.wide { grid-column: 1 / -1; }
.dfield p { margin: 5px 0 0; font-size: 14px; }
.dfield p.mono { font-size: 13px; overflow-wrap: anywhere; }
.detail > .muted { margin: 0; font-size: 14px; }

.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 32px 12px; color: var(--silk-dim); border-bottom: 1px solid var(--rule); }
.empty p { margin: 0; }

/* ---- timeline ---------------------------------------------------------------------- */

.milestones { margin: 0; padding: 0; list-style: none; }
.ms { position: relative; display: flex; align-items: flex-start; gap: 14px; padding: 0 0 18px; }
.ms::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 28px;
  bottom: 2px;
  width: 2px;
  background: var(--rule-strong);
}
.ms:last-child::before { display: none; }
.ms.done::before { background: var(--gold); opacity: 0.6; }
.ms-pad {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid var(--edge);
  border-radius: 50%;
  background: var(--ground);
}
.ms.done .ms-pad { background: var(--gold); border-color: var(--gold); }
.ms.done .ms-pad::after {
  content: "";
  width: 11px;
  height: 6px;
  margin-top: -2px;
  border-left: 2.5px solid var(--gold-ink);
  border-bottom: 2.5px solid var(--gold-ink);
  transform: rotate(-45deg);
}
.ms-text { display: flex; flex-direction: column; gap: 2px; padding-top: 2px; min-width: 0; }
.ms-title { font: 600 15.5px/1.35 var(--sans); }
.ms:not(.done) .ms-title { color: var(--silk-dim); }
.ms-date { font-size: 12.5px; color: var(--silk-dim); }

.day { margin-top: 22px; }
.day:first-of-type { margin-top: 0; }
.day-h { padding-bottom: 6px; border-bottom: 1px solid var(--rule-strong); font: 600 13px/1.3 var(--mono); color: var(--accent); }

/* ---- downloads --------------------------------------------------------------------- */

.files { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--rule-strong); }
.file {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 68px;
  padding: 12px;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
}
.file:hover { background: var(--hover); }
.file:hover .file-go { border-color: var(--accent); }
.file-ico { flex: none; color: var(--accent); display: grid; }
.file-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.file-title { font: 600 15.5px/1.35 var(--sans); }
.file-note { font-size: 13.5px; color: var(--silk-dim); }
.file-size { font-size: 12.5px; color: var(--silk-dim); }
.file-go { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--edge); border-radius: 4px; color: var(--accent); }

/* ---- notes ------------------------------------------------------------------------- */

.lessons { border-top: 1px solid var(--rule-strong); }
.lesson { border-bottom: 1px solid var(--rule); }
.lesson summary {
  display: flex;
  align-items: center;
  gap: 8px 14px;
  min-height: 52px;
  padding: 10px 4px;
  list-style: none;
  cursor: pointer;
}
.lesson summary::-webkit-details-marker { display: none; }
.lesson summary:hover .lesson-t { text-decoration: underline; text-underline-offset: 3px; }
.lesson summary:focus-visible { outline-offset: -2px; }
.lesson-t { flex: 1; min-width: 0; font: 600 15.5px/1.35 var(--sans); }
.lesson-d { flex: none; font-size: 12.5px; color: var(--silk-dim); }
.lesson summary .chev { flex: none; color: var(--silk-dim); }
.lesson[open] summary .chev { transform: rotate(180deg); }
.lesson .prose { padding: 0 4px 18px; font-size: 15px; }

/* ---- lightbox: always dark, whatever the page theme ------------------------------------ */

.lb {
  --silk: #eceedc;
  --silk-dim: #a6beb0;
  --edge: rgba(236, 238, 220, 0.46);
  --rule: rgba(236, 238, 220, 0.14);
  --hover: rgba(236, 238, 220, 0.06);
  --accent: #e2b94b;
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: rgba(3, 16, 12, 0.97);
  color: var(--silk);
}
@media (prefers-reduced-motion: no-preference) {
  .lb { animation: lb-in 160ms ease-out; }
  @keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }
}
.lb-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top, 0px)) 12px 10px 16px;
}
.lb-cap { display: flex; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; min-width: 0; margin: 0; font: 600 15px/1.35 var(--sans); }
.lb-count { font-size: 13px; font-weight: 400; color: var(--silk-dim); }
.lb-tools { flex: none; display: flex; align-items: center; gap: 8px; }
.lb-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--edge);
  border-radius: 4px;
  background: rgba(8, 42, 33, 0.7);
  color: var(--silk);
  cursor: pointer;
}
.lb-btn:hover { border-color: var(--silk); }
.lb-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
  padding: 4px 72px;
  overflow: hidden;
  touch-action: pinch-zoom;
}
.lb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: var(--mat);
  border-radius: 2px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pinch-zoom;
}
.lb-prev, .lb-next { position: fixed; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; }
.lb-prev { left: 12px; }
.lb-next { right: 12px; }
.lb-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 44px;
  padding: 6px 72px calc(8px + var(--safe-b));
  font-size: 12.5px;
  color: var(--silk-dim);
  text-align: center;
}

/* ---- tablet and narrower: navigation moves to a bottom tab bar -------------------------- */

@media (max-width: 1000px) {
  :root { --gutter: 16px; --tabbar: 60px; }
  .nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(8, minmax(44px, 1fr));
    gap: 0;
    height: calc(var(--tabbar) + var(--safe-b));
    padding: 0 env(safe-area-inset-right, 0px) var(--safe-b) env(safe-area-inset-left, 0px);
    overflow-x: auto;
    background: var(--surface);
    border-top: 1px solid var(--rule-strong);
    box-shadow: 0 -8px 24px -16px rgba(0, 0, 0, 0.5);
  }
  .nav-link {
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 0 2px;
    min-height: 44px;
    font-size: 11px;
    letter-spacing: 0.01em;
  }
  .nav-ico, .l-short { display: block; }
  .l-long { display: none; }
  .nav-link[aria-current="page"] { color: var(--accent); }
  .nav-link[aria-current="page"]::after { top: 0; bottom: auto; left: 22%; right: 22%; height: 3px; border-radius: 0 0 2px 2px; }
  .btn, .chip, .seg button, .in { min-height: 44px; }
  .in { height: 44px; font-size: 16px; }
  .icon-btn { width: 44px; }
  .tab { min-height: 44px; }
  .more { min-height: 44px; }
  .sheets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- the BOM table becomes stacked cards ---------------------------------------------- */

@media (max-width: 900px) {
  .toolbar {
    position: sticky;
    top: var(--bar);
    z-index: 12;
    margin: 20px calc(-1 * var(--gutter)) 0;
    padding: 10px var(--gutter);
    background: var(--ground);
    border-bottom: 1px solid var(--rule);
  }
  .search-wrap { flex: 1 1 100%; max-width: none; }
  .seg { flex: 1 1 100%; }
  .seg button { flex: 1; padding: 0 8px; }
  .sort-wrap { display: flex; }
  .thead { display: none; }
  .table { border-top: 0; }

  .row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-areas:
      "part part part part"
      "mpn mpn mfr mfr"
      "req buy price line"
      "vendor vendor vendor link";
    gap: 14px 12px;
    padding: 16px 12px;
    border: 1px solid var(--rule);
    border-radius: 6px;
    margin-bottom: 10px;
  }
  .row .part-c { grid-area: part; }
  .row .mpn-c { grid-area: mpn; }
  .row .mfr-c { grid-area: mfr; }
  .row .req-c { grid-area: req; }
  .row .buy-c { grid-area: buy; }
  .row .price-c { grid-area: price; }
  .row .line-c { grid-area: line; }
  .row .vendor-c { grid-area: vendor; align-self: center; }
  .row .link-c { grid-area: link; justify-self: end; }
  .row .detail { grid-column: 1 / -1; margin-top: 0; }
  .cell.r { text-align: left; justify-self: stretch; }
  .cell-label { display: block; margin-bottom: 5px; font: 600 10.5px/1.2 var(--sans); letter-spacing: 0.09em; text-transform: uppercase; color: var(--silk-dim); }
  .cell { font-size: 15px; }
  .thumb { width: 64px; height: 64px; }
  .name { font-size: 16px; min-height: 44px; align-items: center; }
  .name .chev { margin-top: 0; }
  .refs { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .open { width: 44px; height: 44px; }
}

/* ---- phones ---------------------------------------------------------------------------- */

@media (max-width: 640px) {
  :root { --bar: 52px; }
  .bar { gap: 8px; }
  main { padding-top: 22px; }
  h1 { font-size: 24px; }
  .lede-prose { font-size: 16px; }
  .block { margin-top: 36px; }
  .card { padding: 16px; }

  .facts { display: grid; grid-template-columns: 1fr 1fr; padding: 0; }
  .facts .fact { padding: 12px 12px 12px 0; border-left: 0; border-top: 1px solid var(--rule); }
  .facts .fact:nth-child(2n) { padding-left: 12px; border-left: 1px solid var(--rule); }
  .facts .fact:nth-child(-n + 2) { border-top: 0; }
  .fact dt { white-space: normal; }
  .fact-val { font-size: 16px; }

  .stills {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 82%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin: 0 calc(-1 * var(--gutter));
    padding: 0 var(--gutter) 6px;
    scroll-padding: 0 var(--gutter);
  }
  .still { scroll-snap-align: start; }

  .sheets { grid-template-columns: 1fr; }
  .frame-wrap { height: 60vh; }
  .ph-actions, .ph-actions .btn { width: 100%; }

  .vendors ul { display: grid; gap: 0; }
  .vendors li, .vendors li:first-child { display: grid; grid-template-columns: 1fr auto auto; padding: 8px 0; border-left: 0; border-top: 1px solid var(--rule); }
  .vendors li:first-child { border-top: 0; }

  .file { gap: 12px; padding: 12px 4px; }

  .lb-stage { padding: 4px 8px; }
  .lb-prev, .lb-next { top: auto; bottom: calc(8px + var(--safe-b)); transform: none; }
  .lb-foot { min-height: 64px; padding: 6px 68px calc(8px + var(--safe-b)); }
  .lb-orig .btn-text { display: none; }
}

@media (max-width: 380px) {
  .mark { font-size: 15px; letter-spacing: 0.1em; }
  .bar-end .btn-text { display: none; }
  .bar-end .btn { width: 44px; padding: 0; }
}
