/* Bolted Joint Calculator. Base design system shared with the other ehcrea engineering tools. */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --border: #dde1e7;
  --border-strong: #7d8592;
  --text: #14181f;
  --text-2: #4a525e;
  --text-3: #5a626e;
  --accent: #1f5ea8;
  --accent-ink: #ffffff;
  --accent-soft: #e6eef8;
  --metal: #dfe6ef;
  --metal-edge: #8f9bab;
  --rubber: #262b33;
  --grid: #e6e9ee;
  --s1: #1f5ea8; --s2: #c8501c; --s3: #117a52; --s4: #946200; --s5: #c2457a;
  --cold: #1f5ea8; --hot: #c8372f;
  --ok: #1d7a46; --warn: #8a4b00; --err: #b3261e; --info: #1f5ea8;
  --warn-bg: #fff4e5; --err-bg: #fdecec; --info-bg: #eaf1fa;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.04);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1216; --surface: #171b21; --surface-2: #1f252d; --border: #2b323c; --border-strong: #6b7482;
    --text: #e7eaef; --text-2: #b4bcc7; --text-3: #9aa3af;
    --accent: #6aa5ec; --accent-ink: #0b1018; --accent-soft: #1b2a3d;
    --metal: #2a3542; --metal-edge: #6b7a8c; --rubber: #d5dae1; --grid: #262c35;
    --s1: #6aa5ec; --s2: #f08a4b; --s3: #3fbf8a; --s4: #e0a030; --s5: #e87ba4;
    --cold: #6aa5ec; --hot: #f07070;
    --ok: #5cc98c; --warn: #f3c27a; --err: #ff8a80; --info: #6aa5ec;
    --warn-bg: #2e2312; --err-bg: #331a1a; --info-bg: #17222f;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1216; --surface: #171b21; --surface-2: #1f252d; --border: #2b323c; --border-strong: #6b7482;
  --text: #e7eaef; --text-2: #b4bcc7; --text-3: #9aa3af;
  --accent: #6aa5ec; --accent-ink: #0b1018; --accent-soft: #1b2a3d;
  --metal: #2a3542; --metal-edge: #6b7a8c; --rubber: #d5dae1; --grid: #262c35;
  --s1: #6aa5ec; --s2: #f08a4b; --s3: #3fbf8a; --s4: #e0a030; --s5: #e87ba4;
  --cold: #6aa5ec; --hot: #f07070;
  --ok: #5cc98c; --warn: #f3c27a; --err: #ff8a80; --info: #6aa5ec;
  --warn-bg: #2e2312; --err-bg: #331a1a; --info-bg: #17222f;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2 { margin: 0; font-weight: 600; }
h2 { font-size: 14px; letter-spacing: .01em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 10px 20px; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 30px; height: 30px; flex: none; }
.logo rect { fill: var(--accent); }
.logo path { stroke: var(--accent-ink); stroke-width: 2; fill: none; stroke-linecap: round; }
h1 { font-size: 16px; }
.subtitle { margin: 0; color: var(--text-3); font-size: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

select, input[type="number"] {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 7px;
  padding: 6px 8px; width: 100%; min-width: 0; height: 32px;
}
input[type="number"] { font-variant-numeric: tabular-nums; }
select:focus-visible, input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input:invalid, input.bad { border-color: var(--err); }
.lang select { width: auto; }

.btn {
  font: inherit; font-weight: 500; height: 32px; padding: 0 12px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-icon { width: 32px; padding: 0; display: inline-grid; place-items: center; }

.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; padding: 2px; background: var(--surface-2); }
.seg button {
  font: inherit; font-weight: 500; border: 0; background: transparent; color: var(--text-2);
  padding: 4px 12px; border-radius: 6px; cursor: pointer; height: 26px;
}
.seg button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.seg-wide { display: flex; margin-bottom: 10px; }
.seg-wide button { flex: 1; white-space: nowrap; padding: 4px 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Layout ---------- */
.layout {
  display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 20px;
  padding: 20px; max-width: 1440px; margin: 0 auto;
}
.inputs { display: flex; flex-direction: column; gap: 14px; }
fieldset {
  margin: 0; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
}
legend { font-weight: 600; padding: 0 6px; margin-left: -6px; display: flex; align-items: center; gap: 8px; float: left; width: 100%; margin-bottom: 2px; }
legend + * { clear: both; }
.step {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700;
}
label { display: grid; grid-template-columns: auto 1fr; align-content: start; column-gap: 4px; row-gap: 4px; font-size: 12px; color: var(--text-2); font-weight: 500; }
label > input, label > select { grid-column: 1 / -1; }
label .u { color: var(--text-3); font-weight: 400; }
label.check { display: flex; flex-direction: row; align-items: center; gap: 8px; align-self: end; height: 32px; }
label.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.hint { margin: 0; font-size: 12px; color: var(--text-3); }
.hint:empty { display: none; }
[hidden] { display: none !important; }

.layout-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.layout-picker button {
  font: inherit; font-size: 12px; font-weight: 500; color: var(--text-2);
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px 6px;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); cursor: pointer;
}
.layout-picker svg { width: 60px; height: 36px; }
.layout-picker path { fill: none; stroke: var(--text-3); stroke-width: 2.5; stroke-linejoin: round; }
.layout-picker path.metal { stroke-width: 2; }
.layout-picker .ring { fill: var(--text-3); stroke: none; }
.layout-picker .ring-path { display: none; }
.layout-picker button[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.layout-picker button[aria-checked="true"] path { stroke: var(--accent); }
.layout-picker button[aria-checked="true"] .ring { fill: var(--accent); }

/* ---------- Results ---------- */
.results { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); min-width: 0;
}
.card > h2 { margin-bottom: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.card-note { margin: -4px 0 10px; color: var(--text-3); font-size: 12px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }

.hero { display: flex; gap: 20px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.hero-label { color: var(--text-2); font-weight: 500; }
.hero-value { font-size: 40px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.hero-sub { color: var(--text-3); font-size: 12px; }
.hero-side { display: grid; grid-template-columns: repeat(3, auto); gap: 4px 24px; margin: 0; }
.hero-side div { display: flex; flex-direction: column; }
.hero-side dt { color: var(--text-3); font-size: 12px; }
.hero-side dd { margin: 0; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hero.invalid .hero-value { color: var(--text-3); }

/* Source results table */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.data th { text-align: right; font-weight: 500; color: var(--text-3); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
table.data td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data td.strong { font-weight: 600; }
.status { font-weight: 600; }
.status.ok { color: var(--ok); }
.status.over { color: var(--err); }

.issues { display: flex; flex-direction: column; gap: 6px; padding: 12px; }
.issue { display: flex; gap: 8px; align-items: flex-start; padding: 7px 10px; border-radius: 7px; font-size: 13px; }
.issue .tag { flex: none; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding-top: 1px; min-width: 44px; }
.issue.error { background: var(--err-bg); } .issue.error .tag { color: var(--err); }
.issue.warn { background: var(--warn-bg); } .issue.warn .tag { color: var(--warn); }
.issue.info { background: var(--info-bg); } .issue.info .tag { color: var(--info); }

.section-wrap { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
.section-title { font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.section svg { max-height: 150px; }
.temp-legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.map-wrap { position: relative; }
.map-wrap svg { display: block; width: 100%; height: auto; max-height: 460px; }
.temp-legend .ramp { width: 120px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--cold), var(--hot)); }

.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.metric { background: var(--surface); padding: 10px 12px; }
.metric .k { font-size: 12px; color: var(--text-3); }
.metric .v { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric .s { font-size: 11px; color: var(--text-3); }

.notes summary { cursor: pointer; font-weight: 600; }
.notes-body { color: var(--text-2); font-size: 13px; }
.notes-body ul { padding-left: 18px; }
.notes-body li { margin-bottom: 6px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 13px; z-index: 20;
}

@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .inputs { order: 0; }
}
@media (max-width: 640px) {
  .grid4 { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 10px 16px; position: static; }
  .grid-cards { grid-template-columns: 1fr; }
  .hero-value { font-size: 32px; }
  .hero-side { grid-template-columns: repeat(2, auto); }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .toolbar { width: 100%; }
}

@media print {
  .topbar .toolbar, .toast, .site-footer, .about, .lib-tools, #suggest, #apply-rec, .tip { display: none; }
  .topbar { position: static; }
  body { background: #fff; }
  .layout { grid-template-columns: 300px 1fr; padding: 0; gap: 12px; }
  .card, fieldset { box-shadow: none; break-inside: avoid; }
  .notes { display: block; }
  .notes[open] summary ~ *, .notes summary ~ * { display: block; }
}
/* Footer and About dialog */
.site-footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; padding: 18px 16px 28px; color: var(--text-3); font-size: 12px; }
.site-footer a { color: var(--text-2); text-decoration: none; }
.site-footer a:hover { color: var(--accent); text-decoration: underline; }
.about { width: min(520px, calc(100vw - 32px)); padding: 22px 24px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
.about::backdrop { background: rgba(0, 0, 0, 0.4); }
.about-close { position: absolute; top: 12px; right: 12px; }
.about-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; padding-right: 36px; }
.about-head img { width: 44px; height: 44px; border-radius: 10px; }
.about h2 { margin: 0; font-size: 18px; }
.about-head p { margin: 2px 0 0; color: var(--text-3); font-size: 12px; }
.about p { line-height: 1.55; margin: 0 0 10px; }
.about a { color: var(--accent); }
.about-social { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 0; }
.about-social-label { font-weight: 600; margin-right: 4px; }
.about a.social-link { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px; color: inherit; font-weight: 600; font-size: 13px; text-decoration: none; }
.about a.social-link:hover { border-color: currentColor; text-decoration: underline; }
.about-support { margin: 14px 0 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--accent-soft); }
.about-support p { margin: 0 0 10px; }
.about a.btn-support { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; background: #d6303a; color: #fff; font-weight: 600; font-size: 13px; text-decoration: none; }
.about a.btn-support:hover { background: #c42b35; }
.about .about-meta { margin: 14px 0 0; padding-top: 10px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 12px; }

.mini-label { font-size: 12px; color: var(--text-2); font-weight: 500; margin-bottom: 4px; }
.grid2 > div > .seg-wide { margin-bottom: 0; }
fieldset > .btn { align-self: flex-start; }
input[type="number"]:disabled { color: var(--text-2); background: var(--surface-2); }
details.sub { border-top: 1px solid var(--border); padding-top: 8px; display: flex; flex-direction: column; gap: 10px; }
details.sub summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--text-2); }
details.sub[open] { gap: 10px; }
details.sub > * + * { margin-top: 10px; }
label.check { height: auto; font-weight: 500; }
.hero { position: relative; }
.status-chip { position: absolute; top: 14px; right: 16px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 3px 8px; border-radius: 99px; }
.status-chip.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.status-chip.warn { color: var(--warn); background: var(--warn-bg); }
.status-chip.error { color: var(--err); background: var(--err-bg); }
.hero-main { padding-right: 70px; }
.hero-value.ok { color: var(--text); }
.hero-value.warn { color: var(--warn); }
.hero-value.error { color: var(--err); }

.drawing { display: flex; justify-content: center; }
.drawing svg { display: block; width: 100%; height: auto; max-height: 340px; }
.legend-key { font-size: 12px; color: var(--text-3); display: inline-flex; align-items: center; gap: 6px; }
.legend-key .k-free { width: 14px; height: 0; border-top: 1.5px dashed var(--text-3); }
.badge { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: 99px; padding: 2px 8px; }
.badge.bad { color: var(--err); background: var(--err-bg); }
#nasa-table .hint { margin: 2px 0 0; font-size: 11px; }
table.data td.hl, table.data tr.hl td { background: var(--accent-soft); }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: var(--surface-2); }
table.data td.left, table.data th.left { text-align: left; }
table.data td.wrap { white-space: normal; text-align: left; min-width: 180px; color: var(--text-2); font-size: 12px; }
.lib summary { cursor: pointer; font-weight: 600; }
.lib[open] summary { margin-bottom: 10px; }
.lib-tools { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.lib-tools select { width: auto; }
.lib-tools input[type="search"] { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 7px; padding: 6px 8px; height: 32px; flex: 1; min-width: 160px; }
.lib-scroll { max-height: 420px; overflow-y: auto; }
.lib-scroll thead th { position: sticky; top: 0; background: var(--surface); }

.metric.warn .v { color: var(--warn); }
.metric.error .v { color: var(--err); }

@media (max-width: 640px) {
  .status-chip { position: static; }
  .hero-main { padding-right: 0; }
  .layout-picker button span { font-size: 11px; }
}
/* Five seal types, tooltips, help */
.layout-picker.five { grid-template-columns: repeat(5, 1fr); gap: 6px; }
.layout-picker.five button { padding: 6px 2px 5px; font-size: 11px; }
.layout-picker.five svg { width: 46px; height: 28px; }
.lt { display: inline-flex; align-items: center; gap: 4px; }
.tip { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; font-size: 11px; line-height: 1; color: var(--accent); cursor: help; font-weight: 600; }
.tip:hover, .tip:focus-visible { background: var(--accent-soft); outline: none; }
.help { width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow-y: auto; }
.help h3 { font-size: 14px; margin: 16px 0 6px; }
.help ol, .help ul { padding-left: 20px; margin: 0 0 10px; line-height: 1.55; }
.help li { margin-bottom: 4px; }
.help dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 10px; }
.help dt { font-weight: 600; }
.help dd { margin: 0; color: var(--text-2); }
.help svg { display: block; width: 100%; max-width: 420px; height: auto; margin: 6px auto 4px; }
.help svg .metal { fill: var(--metal); stroke: var(--metal-edge); }
.help svg .oring { fill: var(--rubber); }
.help svg .dim { stroke: var(--text-3); fill: none; }
.help svg text { fill: var(--text-2); font-size: 12px; font-weight: 600; }
.toast { max-width: min(520px, calc(100vw - 32px)); text-align: center; }
@media (max-width: 640px) {
  .help dl { grid-template-columns: 1fr; }
  .help dd { margin-bottom: 6px; }
}
.preset select { width: auto; max-width: 200px; }
.toolbar { gap: 6px; }
.toolbar .btn { padding: 0 10px; }
@media (max-width: 640px) { .preset, .preset select { width: 100%; max-width: 100%; } }

/* ---------- Bolted joint additions ---------- */
:root {
  --m-steel: #d9dde3; --m-stainless: #cfd9e3; --m-castiron: #b9bdc3; --m-aluminium: #e8ebef; --m-magnesium: #ece8df;
  --m-titanium: #d5d2e0; --m-copper: #ead2b4; --m-polymer: #f2e3c2; --m-pcb: #c5dfc0; --m-washer: #c4ccd6; --m-nut: #c9ced6;
  --bolt: #8f99a6; --bolt-edge: #4f5865; --cone: rgba(31,94,168,.20); --engaged: rgba(200,80,28,.55); --coil: #c8501c; --insert: #e3b55b;
}
:root[data-theme="dark"] {
  --m-steel: #3a3f46; --m-stainless: #37414c; --m-castiron: #2f3237; --m-aluminium: #464b52; --m-magnesium: #4a463e;
  --m-titanium: #423f4d; --m-copper: #5a4630; --m-polymer: #574b33; --m-pcb: #2e4c34; --m-washer: #5a626d; --m-nut: #505761;
  --bolt: #77818e; --bolt-edge: #b3bcc8; --cone: rgba(106,165,236,.28); --engaged: rgba(240,138,75,.6); --coil: #f08a4b; --insert: #b48a3a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --m-steel: #3a3f46; --m-stainless: #37414c; --m-castiron: #2f3237; --m-aluminium: #464b52; --m-magnesium: #4a463e;
    --m-titanium: #423f4d; --m-copper: #5a4630; --m-polymer: #574b33; --m-pcb: #2e4c34; --m-washer: #5a626d; --m-nut: #505761;
    --bolt: #77818e; --bolt-edge: #b3bcc8; --cone: rgba(106,165,236,.28); --engaged: rgba(240,138,75,.6); --coil: #f08a4b; --insert: #b48a3a;
  }
}
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.layout-picker.four { grid-template-columns: repeat(4, 1fr); gap: 6px; }
.layout-picker.four button { padding: 6px 2px 5px; font-size: 11px; }
.layout-picker.four svg { width: 54px; height: 36px; }
.layout-picker .ring-path { display: inline; fill: none; }
input.derived { color: var(--text-2); background: var(--surface-2); }
.mini-label.strong { font-weight: 600; color: var(--text); }
.sub-block { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.plates { display: flex; flex-direction: column; gap: 6px; }
.plate-row { display: grid; grid-template-columns: 22px 1fr 76px auto 32px; gap: 6px; align-items: center; }
.plate-row label { display: block; }
.plate-row .u { font-size: 12px; color: var(--text-3); }
.plate-no { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--surface-2); color: var(--text-2); font-size: 11px; font-weight: 700; }
.btn:disabled { cursor: not-allowed; opacity: .4; }
.hero-value .unit { font-size: 20px; color: var(--text-3); font-weight: 500; }
.hero-side { grid-template-columns: repeat(3, auto); }
.hero-side dd.error { color: var(--err); }
.status.warn { color: var(--warn); }
.status.error { color: var(--err); }
.legend-row { display: inline-flex; gap: 12px; flex-wrap: wrap; }
.legend-key i { display: inline-block; width: 14px; height: 9px; border-radius: 2px; }
.legend-key .k-cone { background: var(--cone); border: 1px solid var(--accent); }
.legend-key .k-eng { background: var(--engaged); }
.legend-key .k-bolt { height: 0; border-top: 2px solid var(--s1); }
.legend-key .k-plate { height: 0; border-top: 2px solid var(--s3); }
.legend-key .k-max { height: 0; border-top: 1.5px dashed var(--text-3); }
.drawing svg { max-height: 560px; }
.drawing + .metrics { margin-top: 10px; }

/* SVG: joint section */
svg .layer { stroke: var(--metal-edge); stroke-width: .8; }
svg .m-steel { fill: var(--m-steel); } svg .m-stainless { fill: var(--m-stainless); } svg .m-castiron { fill: var(--m-castiron); }
svg .m-aluminium { fill: var(--m-aluminium); } svg .m-magnesium { fill: var(--m-magnesium); } svg .m-titanium { fill: var(--m-titanium); }
svg .m-copper { fill: var(--m-copper); } svg .m-polymer { fill: var(--m-polymer); } svg .m-pcb { fill: var(--m-pcb); } svg .m-washer { fill: var(--m-washer); } svg .m-nut { fill: var(--m-nut); }
svg .hatch-line { stroke: var(--metal-edge); stroke-width: .6; opacity: .7; }
svg .hatch-fill { stroke: none; pointer-events: none; }
svg .bolt { fill: var(--bolt); stroke: var(--bolt-edge); stroke-width: 1; }
svg .socket { fill: var(--surface); stroke: var(--bolt-edge); stroke-width: 1; }
svg .thread-line { stroke: var(--bolt-edge); stroke-width: .8; }
svg .engaged { fill: var(--engaged); }
svg .coil { fill: var(--coil); stroke: var(--bolt-edge); stroke-width: .5; }
svg .insert { fill: var(--insert); stroke: var(--bolt-edge); stroke-width: .7; }
svg .cone { fill: var(--cone); stroke: var(--accent); stroke-width: 1.2; stroke-dasharray: 5 3; }
svg .cone-text { fill: var(--accent); font-size: 12px; font-weight: 600; }
svg .zone { stroke: none; }
svg .z1 { fill: var(--s4); } svg .z2 { fill: var(--s5); } svg .z3 { fill: var(--s1); } svg .z4 { fill: var(--s2); } svg .z5 { fill: var(--s3); }
svg .zone-text { fill: var(--text-2); font-size: 12px; }
svg .zone-title { fill: var(--text-3); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
svg .leader { stroke: var(--text-3); stroke-width: .7; }
svg .lbl { fill: var(--text-2); font-size: 12px; }
svg .arrow-head { fill: var(--text-3); }
svg .dim { stroke: var(--text-3); stroke-width: 1; fill: none; }
svg .ext { stroke: var(--text-3); stroke-width: .7; stroke-opacity: .7; }
svg .dim-text { fill: var(--text-2); font-size: 11px; }
svg .force { stroke: var(--hot); stroke-width: 2; }
svg .force-head { fill: var(--hot); }
svg .force-text { fill: var(--hot); font-size: 12px; font-weight: 700; }

/* SVG: diagrams and charts */
svg .ax { stroke: var(--text-3); stroke-width: 1; }
svg .ax-text, svg .tick { fill: var(--text-3); font-size: 11px; font-variant-numeric: tabular-nums; }
svg .grid { stroke: var(--grid); stroke-width: 1; }
svg .tri-max { fill: none; stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 4 3; }
svg .bolt-line { fill: none; stroke: var(--s1); stroke-width: 2.2; }
svg .plate-line { fill: none; stroke: var(--s3); stroke-width: 2.2; }
svg .fa-line { stroke: var(--s2); stroke-width: 3; }
svg .fkr-line { stroke: var(--s3); stroke-width: 3; opacity: .55; }
svg .guide { stroke: var(--grid); stroke-width: 1; stroke-dasharray: 2 3; }
svg .pt { fill: var(--surface); stroke: var(--s1); stroke-width: 2; }
svg .ann { fill: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; }
svg .pat-flange { fill: var(--cone); stroke: var(--text-3); stroke-width: 1; }
svg .pat-bolt { fill: var(--hot); stroke: var(--text-2); stroke-width: 1.2; }
svg .pat-bolt.crit { stroke: var(--err); stroke-width: 2.6; }
svg .pat-num { fill: var(--text); font-size: 11px; font-weight: 700; text-anchor: middle; }
svg .pat-val { fill: var(--text-2); font-size: 12px; font-variant-numeric: tabular-nums; }
svg .pat-val.crit { fill: var(--err); font-weight: 700; }
svg .pat-shear { stroke: var(--accent); stroke-width: 2; }
svg .pat-shear-head { fill: var(--accent); }
svg .pat-axis { stroke: var(--text-3); stroke-width: 1.2; stroke-dasharray: 6 4; }
svg .pat-axis-text { fill: var(--text-3); font-size: 11px; }
svg .ann.muted { fill: var(--text-3); } svg .ann.bolt { fill: var(--s1); } svg .ann.plate { fill: var(--s3); }
svg .ann.ok { fill: var(--ok); } svg .ann.err { fill: var(--err); } svg .ann.warn { fill: var(--warn); } svg .ann.fa { fill: var(--s2); font-weight: 700; }
svg .band { fill: var(--accent-soft); }
svg .fm-line { fill: none; stroke: var(--s1); stroke-width: 2.4; }
svg .yield-line { fill: none; stroke: var(--err); stroke-width: 1.6; stroke-dasharray: 6 3; }
svg .req-line { stroke: var(--warn); stroke-width: 1.4; stroke-dasharray: 3 3; }
svg .nut-prof { fill: var(--m-nut); stroke: var(--metal-edge); stroke-width: 1; opacity: .85; }
svg .dl { stroke: var(--text-3); stroke-width: .8; stroke-dasharray: 3 3; }
svg .dl.pitch { stroke: var(--s3); } svg .dl.stress { stroke: var(--s2); stroke-dasharray: none; stroke-width: 1.2; }
svg .c-nom { fill: var(--m-steel); stroke: var(--metal-edge); stroke-width: 1; stroke-dasharray: 4 3; }
svg .c-as { fill: color-mix(in srgb, var(--s2) 30%, transparent); stroke: var(--s2); stroke-width: 1.5; }
svg .c-d3 { fill: none; stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 2 2; }

/* torque split bar */
.tbar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; margin: 6px 0; }
.tseg { display: grid; place-items: center; color: var(--accent-ink); font-size: 12px; font-weight: 600; min-width: 34px; }
.tseg.s2, .tlegend i.s2 { background: var(--s2); } .tseg.s3, .tlegend i.s3 { background: var(--s3); } .tseg.s4, .tlegend i.s4 { background: var(--s4); }
.tlegend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-2); }
.tlegend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* calculation steps */
.steps summary { font-size: 14px; }
.steps-body { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.calc-step h3 { font-size: 13px; margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.calc-step .sid { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 5px; padding: 1px 6px; min-width: 34px; text-align: center; }
.ftable { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.ftable td { padding: 5px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.ftable .fl { width: 42%; }
.ftable .fs { color: var(--text-3); font-family: var(--mono); font-size: 12px; }
.ftable .fr { text-align: right; white-space: nowrap; font-weight: 500; }
.lib-body h3 { font-size: 13px; margin: 16px 0 6px; }
.lib-body h3:first-child { margin-top: 4px; }
.lib-scroll { max-height: 320px; }
@media (max-width: 640px) {
  .grid4 { grid-template-columns: 1fr 1fr; }
  .ftable .fl { width: auto; }
  .ftable, .ftable tbody, .ftable tr, .ftable td { display: block; }
  .ftable tr { border-bottom: 1px solid var(--border); padding: 4px 0; }
  .ftable td { border: 0; padding: 2px 4px; }
  .ftable .fr { text-align: left; }
}
@media print {
  .steps { display: block; }
  .drawing svg { max-height: 420px; }
}
/* labels contain sub/sup markup: use block flow instead of the two-column grid */
label:not(.check) { display: block; }
label:not(.check) > input, label:not(.check) > select { display: block; margin-top: 4px; }
.lt { display: inline; }
.lt .tip { vertical-align: 1px; }
.grid-cards { grid-template-columns: repeat(auto-fit, minmax(520px, 1fr)); }
@media (max-width: 640px) { .grid-cards { grid-template-columns: 1fr; } }
svg .nut-prof { fill: color-mix(in srgb, var(--s1) 22%, var(--surface)); stroke: var(--s1); stroke-width: 1; opacity: 1; }

/* flexible flange */
h3.sub { font-size: 14px; font-weight: 600; margin: 18px 0 8px; }

/* custom bolt positions */
textarea[data-key] { width: 100%; box-sizing: border-box; font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 8px 10px;
  border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface, transparent); color: inherit; resize: vertical; }
.pat-fill { font-size: 13px; margin: 6px 0 10px; color: var(--text-2); }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline; }

/* Phones: every panel stays inside the screen width, in every language
   (same rules in all ehcrea calculators). Grid and flex children may shrink below their
   content width, long labels wrap, wide tables scroll inside their own box. */
.layout > *, .results > *, fieldset, .card, .grid2 > *, .grid3 > *, .grid-cards > *, .layout-picker > *, .stack-legend > * { min-width: 0; }
.layout-picker button { overflow-wrap: anywhere; }
input, select, textarea { max-width: 100%; }
.legend-key { display: inline-flex; flex-wrap: wrap; align-items: center; row-gap: 4px; max-width: 100%; }
.table-wrap { max-width: 100%; }
@media (max-width: 640px) {
  table.data td:first-child { white-space: normal; }
  /* Field label and unit wrap onto two lines instead of widening the form. */
  .layout label:not(.check) { display: flex; flex-wrap: wrap; align-items: baseline; }
  .layout label:not(.check) > input, .layout label:not(.check) > select { flex: 1 0 100%; min-width: 0; }
}

/* Theme switch: square icon button with the icon exactly centred (same in every ehcrea
   calculator). ".toolbar .btn" padding must not apply to it, or the 16 px icon is pushed right. */
.toolbar .btn-icon, #theme { width: 32px; height: 32px; padding: 0; display: inline-grid; place-items: center; }
