/* Superformity: technical-drawing theme.
   Drafting paper, hairlines, a title block, dimension-line headings,
   monospaced figures. System fonts only (no external requests). */

:root {
  --paper: #f5f4ef;
  --sheet: #fbfbf8;
  --ink: #1b1f24;
  --ink-2: #3d4450;
  --muted: #6b7280;
  --hair: #cfcdc3;
  --grid: rgba(0, 71, 171, 0.055);
  --grid-major: rgba(0, 71, 171, 0.10);
  --accent: #0047ab;          /* engineering blue */
  --accent-tint: #e8eef8;
  --warn: #d9480f;            /* safety orange: drafts, warnings */
  --warn-tint: #fdf0e8;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;
  --label-size: .68rem;
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  /* drafting paper: 4 mm minor grid, 20 mm major grid */
  background:
    linear-gradient(var(--grid-major) 1px, transparent 1px) 0 0 / 80px 80px,
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px) 0 0 / 80px 80px,
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 16px 16px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 16px 16px,
    var(--paper);
}

/* The drawing sheet: a framed page with registration marks in the corners */
.sheet {
  position: relative;
  max-width: 62rem;
  margin: 1.5rem auto;
  padding: 0;
  background: var(--sheet);
  border: 1px solid var(--ink);
  outline: 1px solid var(--ink);
  outline-offset: 5px;
}
.sheet::before, .sheet::after {
  content: ""; position: absolute; width: 18px; height: 18px; pointer-events: none;
  border-color: var(--accent); border-style: solid;
}
.sheet::before { top: -12px; left: -12px; border-width: 1px 0 0 1px; }
.sheet::after { bottom: -12px; right: -12px; border-width: 0 1px 1px 0; }
main { padding: 1.5rem 2rem 2.5rem; }
@media (max-width: 700px) {
  .sheet { margin: .6rem; outline-offset: 3px; }
  main { padding: 1rem 1rem 2rem; }
}

/* ---------- Type ---------- */
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 1.85rem; font-weight: 650; margin: .2rem 0 .8rem; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-2); margin: 1.4rem 0 .4rem; }

/* Headings drawn like dimension lines: text, then a line with an end tick */
h2 {
  display: flex; align-items: center; gap: .7rem;
  font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink); margin: 2.2rem 0 .9rem;
}
h2::before { content: ""; width: 10px; height: 10px; border: 1px solid var(--ink); flex: none; transform: rotate(45deg); }
h2::after {
  content: ""; flex: 1; height: 7px;
  border-top: 1px solid var(--ink); border-right: 1px solid var(--ink);
  transform: translateY(3px);
}

code, kbd, pre, .sku, .num, td.num, .price strong, .mono { font-family: var(--mono); }
code { font-size: .88em; background: var(--accent-tint); padding: .05rem .3rem; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.lead { font-size: 1.12rem; max-width: 46rem; }
.label, figcaption, .cat {
  font-size: var(--label-size); text-transform: uppercase; letter-spacing: .12em; color: var(--muted);
}
.sku { font-size: .85em; letter-spacing: .02em; color: var(--ink-2); white-space: nowrap; }

/* ---------- Title block (header and footer) ---------- */
.titleblock { display: grid; border-bottom: 1px solid var(--ink); background: var(--sheet); }
header.titleblock { grid-template-columns: auto 1fr auto; }
.tb { padding: .55rem .9rem; border-right: 1px solid var(--ink); display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.tb:last-child { border-right: 0; }
.tb-label { font-size: .6rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); line-height: 1.1; margin-bottom: .2rem; }
.brand { text-decoration: none; color: var(--ink); }
.brand strong { font-size: 1.05rem; letter-spacing: .22em; font-weight: 800; }
.brand .tb-sub { font-size: .7rem; color: var(--muted); letter-spacing: .04em; }
header nav { display: flex; gap: 1.1rem; align-items: center; flex-wrap: wrap; }
header nav > a { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; text-decoration: none; color: var(--ink); font-weight: 600; }
header nav > a:hover { color: var(--accent); }
header .lang a { font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; text-decoration: none; font-weight: 600; }
@media (max-width: 760px) {
  header.titleblock { grid-template-columns: 1fr auto; }
  header.titleblock .tb.navcell { grid-column: 1 / -1; order: 3; border-right: 0; border-top: 1px solid var(--ink); }
}

footer.titleblock { border-bottom: 0; border-top: 1px solid var(--ink); grid-template-columns: auto 1fr auto; font-size: .8rem; color: var(--ink-2); }
footer.titleblock .tb { padding: .5rem .9rem; }
footer a { color: var(--ink-2); }
@media (max-width: 760px) { footer.titleblock { grid-template-columns: 1fr; } footer .tb { border-right: 0; border-bottom: 1px solid var(--hair); } }

/* ---------- Forms ---------- */
input, textarea, button, select { font: inherit; color: inherit; }
input, textarea, select {
  background: #fff; border: 1px solid var(--ink-2); border-radius: 0; padding: .38rem .55rem;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input[name=add] { font-family: var(--mono); font-size: .88rem; }
button, .button {
  display: inline-block; cursor: pointer; border-radius: 0;
  border: 1px solid var(--ink); background: var(--sheet); color: var(--ink);
  padding: .42rem .95rem; font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em;
  text-decoration: none;
}
button:hover:not(:disabled), .button:hover { background: var(--ink); color: var(--sheet); }
.button, button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button:hover { background: #00337d; color: #fff; }
button:disabled { opacity: .45; cursor: not-allowed; }
form.search { display: flex; gap: 0; }
form.search input { min-width: 13rem; border-right: 0; }
form.inline { display: flex; gap: .45rem; flex-wrap: wrap; align-items: stretch; }
form.inline input[name=qty] { width: 5.5rem; font-family: var(--mono); }
textarea.bom { width: 100%; font-family: var(--mono); font-size: .88rem; line-height: 1.5;
  background: #fff linear-gradient(var(--grid) 1px, transparent 1px) 0 .3rem / 100% 1.32rem; }

/* ---------- Tables: spec sheets ---------- */
table { border-collapse: collapse; width: 100%; margin: .4rem 0 1.2rem; border: 1px solid var(--ink); background: #fff; }
th, td { text-align: left; padding: .42rem .65rem; border-bottom: 1px solid var(--hair); vertical-align: top; }
thead th { font-size: var(--label-size); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--ink); background: var(--sheet); }
tbody th { font-weight: 500; color: var(--ink-2); }
main table tr > th:first-child:not(:only-child) { width: 45%; }
td.num, th.num { white-space: nowrap; text-align: right; }
table.cart td.num { font-size: .92rem; }
table.cart tfoot th, table.cart tfoot td { border-bottom: 0; background: var(--sheet); }
table.cart tfoot th { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; font-weight: 600; }
table.cart tfoot th .small { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: .8rem; margin-top: .15rem; }
table.cart tr.total th, table.cart tr.total td { border-top: 1px solid var(--ink); font-size: 1rem; font-weight: 700; }
table.cart tr.total td { font-size: 1.1rem; }

/* ---------- Badges, notices, hints ---------- */
.badge {
  display: inline-block; font-size: .62rem; font-weight: 800; text-transform: uppercase; letter-spacing: .14em;
  color: var(--warn); border: 1.5px solid var(--warn); padding: 0 .35rem; line-height: 1.5;
  transform: rotate(-3deg); background: rgba(255, 255, 255, .6); vertical-align: middle;
}
.notice { border: 1px solid var(--warn); border-left-width: 4px; background: var(--warn-tint); padding: .6rem .9rem; margin: .8rem 0; }
.issues ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.hint { font-size: .82rem; margin-top: .25rem; color: var(--ink-2); }

/* ---------- View switch (For humans / For AI / JSON) ---------- */
.views { display: inline-flex; border: 1px solid var(--ink); margin: .2rem 0 1.1rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }
.views > * { padding: .32rem .8rem; text-decoration: none; border-left: 1px solid var(--ink); color: var(--ink); }
.views > :first-child { border-left: 0; }
.views .active { background: var(--ink); color: var(--sheet); }
.views a:hover { background: var(--accent-tint); }

/* ---------- Part page ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 2rem; align-items: start; }
.hero h1 { margin-top: 0; }
@media (max-width: 760px) { .hero { grid-template-columns: 1fr; } }
figure.drawing {
  position: relative; margin: 0; padding: 1.4rem 1.2rem .8rem;
  border: 1px solid var(--ink);
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 12px 12px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 12px 12px,
    #fff;
}
figure.drawing::before { content: "FIG. 1"; position: absolute; top: .35rem; left: .5rem; font: 700 .6rem var(--mono); letter-spacing: .14em; color: var(--muted); }
figure.drawing img { width: 100%; height: auto; max-height: 22rem; object-fit: contain; display: block; }
figure.drawing .stage { position: relative; }
figure.drawing .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
figure.drawing .stage canvas:active { cursor: grabbing; }
figure.drawing.live .stage img { visibility: hidden; }
.dimlabels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.dimlabels span { position: absolute; left: 0; top: 0; font: 600 .78rem var(--mono); color: var(--accent); background: rgba(255, 255, 255, .88); padding: 0 .2rem; white-space: nowrap; }
.viewbar { display: flex; flex-wrap: wrap; justify-content: center; row-gap: .35rem; margin-top: .5rem; padding-left: 1px; }
.viewbar[hidden] { display: flex; visibility: hidden; }
.viewbar button { font: 700 .66rem var(--mono); letter-spacing: .1em; text-transform: uppercase; padding: .35rem .6rem; min-height: 2rem; border: 1px solid var(--ink); margin-left: -1px; background: #fff; color: var(--ink); cursor: pointer; }
.viewbar .toggles { display: flex; margin-left: .6rem; padding-left: 1px; }
.viewbar button:hover { background: var(--accent-tint); }
.viewbar button[aria-pressed="true"] { background: var(--ink); color: var(--sheet); }
.drawings { margin-top: 1.6rem; }
.plates { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 1rem; margin-top: 1rem; }
figure.plate { margin: 0; padding: .8rem; border: 1px solid var(--ink); background: #fff; }
figure.plate img { width: 100%; height: auto; display: block; }
.drawings > figure.plate img { max-height: 34rem; object-fit: contain; }
.plates figure.plate img { height: 13rem; object-fit: contain; }
figure.plate figcaption { font: 700 .66rem var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
figcaption { margin-top: .6rem; text-align: center; border-top: 1px solid var(--hair); padding-top: .4rem; }
.price { font-size: 1.15rem; margin: .4rem 0; }
.price strong { font-size: 1.45rem; color: var(--ink); }
.facts { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .35rem; margin: .9rem 0; }
.facts li { font: .78rem var(--mono); padding: .25rem .6rem; border: 1px solid var(--ink-2); background: #fff; }
.tips { margin-top: 1.2rem; }
details { margin-top: 1.8rem; border: 1px solid var(--ink); background: #fff; }
summary { cursor: pointer; padding: .55rem .9rem; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::before { content: "+"; display: inline-block; width: 1.1rem; font-family: var(--mono); color: var(--accent); }
details[open] summary::before { content: "−"; }
details[open] summary { border-bottom: 1px solid var(--ink); }
details > :not(summary) { margin-left: .9rem; margin-right: .9rem; }

/* ---------- Cards (parts list, related parts) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0; border-left: 1px solid var(--ink); border-top: 1px solid var(--ink); }
.cards.small { grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); }
.card {
  position: relative; display: flex; flex-direction: column; gap: .3rem; padding: .9rem;
  border-right: 1px solid var(--ink); border-bottom: 1px solid var(--ink);
  text-decoration: none; color: inherit; background: #fff;
}
.card::before, .card::after { content: ""; position: absolute; width: 10px; height: 10px; border: 0 solid var(--accent); opacity: 0; transition: opacity .12s; }
.card::before { top: 5px; left: 5px; border-width: 1px 0 0 1px; }
.card::after { bottom: 5px; right: 5px; border-width: 0 1px 1px 0; }
.card:hover { background: var(--accent-tint); }
.card:hover::before, .card:hover::after { opacity: 1; }
.card strong { font-weight: 600; line-height: 1.3; }
.card .thumb {
  height: 8rem; display: flex; align-items: center; justify-content: center; padding: .5rem; border: 1px solid var(--hair);
  background: linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 10px 10px, linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 10px 10px, var(--sheet);
}
.card .thumb img, .card .thumb svg { max-width: 100%; max-height: 100%; }
.card .row { display: flex; justify-content: space-between; gap: .5rem; font-size: .82rem; margin-top: auto; padding-top: .3rem; border-top: 1px dashed var(--hair); }
.card .row .mono { font-size: .88rem; }

/* ---------- Landing ---------- */
.landing h1 { font-size: 2.3rem; max-width: 40rem; }
.ai-box { position: relative; border: 1px solid var(--accent); background: #fff; padding: 1.4rem 1.3rem .8rem; margin: 2.2rem 0 1.5rem; }
.ai-box h2 {
  position: absolute; top: -.75rem; left: .8rem; margin: 0; padding: .1rem .55rem; background: var(--accent); color: #fff;
  font-size: .7rem;
}
.ai-box h2::before, .ai-box h2::after { display: none; }
.steps li, .ai-box li { margin-bottom: .35rem; }
pre { background: var(--ink); color: #e9edf2; padding: .8rem 1rem; overflow-x: auto; font-size: .86rem; border-left: 4px solid var(--accent); }
pre.prompt { white-space: pre-wrap; }
pre code { background: none; padding: 0; color: inherit; }

/* ---------- Legal pages ---------- */
.legal { max-width: 46rem; }
.legal h2 { margin-top: 1.8rem; }
.legal pre.form { white-space: pre-wrap; font: .85rem/1.5 var(--mono); background: #fff; border: 1px solid var(--hair); padding: .8rem 1rem; }
address { font-style: normal; font-family: var(--mono); font-size: .92rem; }

/* ---------- Phones ---------- */
@media (max-width: 600px) {
  body { font-size: 15px; }
  /* No sideways scrolling: drop the outer frame and corner marks, keep one clean border */
  .sheet { margin: 0; border-left: 0; border-right: 0; outline: 0; }
  .sheet::before, .sheet::after { display: none; }
  main { padding: 1rem .9rem 2rem; }
  h1 { font-size: 1.5rem; }
  .landing h1 { font-size: 1.75rem; }

  /* Comfortable tap targets (about 44 px) */
  header nav { gap: .2rem .4rem; width: 100%; }
  header nav > a, header .lang a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 .5rem; }
  header nav > a:first-child { padding-left: 0; }
  form.search { width: 100%; }
  form.search input { min-width: 0; flex: 1; }
  .views > * { display: inline-flex; align-items: center; min-height: 40px; padding: 0 .75rem; }
  button, .button { min-height: 44px; }
  details summary { padding: .85rem .9rem; }
  /* iOS zooms in on fields with text under 16 px */
  input, textarea, select { font-size: 16px !important; min-height: 44px; }

  .facts li { font-size: .74rem; }
  table { font-size: .9rem; }
  th, td { padding: .4rem .5rem; }
  main table tr > th:first-child:not(:only-child) { width: 52%; }

  /* Cart: each line becomes a small card: name on top, then qty, unit price and total */
  table.cart { display: block; border: 0; background: transparent; }
  table.cart tbody { display: block; }
  table.cart thead { display: none; }
  table.cart tbody tr {
    display: grid; grid-template-columns: repeat(3, 1fr) 44px; border: 1px solid var(--ink); margin-bottom: .6rem; background: #fff;
  }
  table.cart tbody td { border: 0; }
  table.cart tbody td:first-child { grid-column: 1 / -1; border-bottom: 1px solid var(--hair); }
  table.cart tbody td.num { text-align: left; }
  table.cart tbody td.num::before {
    content: attr(data-label); display: block; font: 600 .6rem var(--sans); text-transform: uppercase; letter-spacing: .12em; color: var(--muted);
  }
  table.cart tbody td.rm { grid-column: 4; grid-row: 2; display: flex; align-items: center; justify-content: center; }
  table.cart a.remove { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; text-decoration: none; font-size: 1rem; }
  table.cart tfoot, table.cart tfoot tr { display: block; }
  table.cart tfoot { border: 1px solid var(--ink); background: var(--sheet); }
  table.cart tfoot tr { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 0 .6rem; }
  table.cart tr.total { border-top: 1px solid var(--ink); }
  table.cart tr.total th, table.cart tr.total td { border-top: 0; }
  table.cart tfoot th, table.cart tfoot td { display: block; }
  table.cart tfoot td:empty { display: none; }
  table.cart tfoot th[colspan] { grid-column: 1; }
  table.cart tfoot th { width: auto !important; }
  form.inline input[name=add] { flex: 1 1 10rem; }
}

/* ---------- Admin (private) ---------- */
.admin-nav { align-items: stretch; }
.admin-nav form { display: flex; border-left: 1px solid var(--ink); }
.admin-nav form button { border: 0; min-height: 0; margin: 0; font: inherit; text-transform: inherit; letter-spacing: inherit; background: none; color: inherit; padding: .35rem .8rem; cursor: pointer; line-height: inherit; }
.scroll { overflow-x: auto; }
table.admin td, table.admin th { vertical-align: top; }
table.admin td:last-child { min-width: 12rem; }
table.admin td:last-child a { white-space: nowrap; }
table.admin tr.warn td, table.admin tr.warn th { background: var(--warn-tint); }
td.bad { color: var(--warn); font-weight: 700; }
.slip { max-width: 44rem; background: #fff; border: 1px solid var(--hair); padding: 1.5rem 2rem; }
.slip address.to { font-style: normal; margin: 1.6rem 0 1.4rem; font-size: 1.05rem; }
.slip h1 { font-size: 1.3rem; }
@media print {
  html, body { background: #fff !important; }
  .titleblock, .noprint, .views { display: none !important; }
  .sheet { border: 0 !important; box-shadow: none !important; margin: 0 !important; padding: 0 !important; }
  .sheet::before, .sheet::after { display: none !important; }
  .slip { border: 0; padding: 0; }
}

ol.checklist { list-style: none; padding: 0; border: 1px solid var(--ink); background: #fff; }
ol.checklist li { padding: .5rem .8rem; border-bottom: 1px solid var(--hair); }
ol.checklist li:last-child { border-bottom: 0; }
ol.checklist li.done { color: var(--muted); }
ol.checklist li.done strong { font-weight: 500; }
ol.checklist .tick { display: inline-block; width: 1.3rem; font-family: var(--mono); color: var(--accent); }
ol.checklist li.open .tick { color: var(--warn); }
ol.checklist li .mono { margin-left: 1.3rem; color: var(--ink-2); }
ol.next { padding-left: 1.4rem; }
ol.next li { margin: .2rem 0 .8rem; }
