/* VDI 2230 calculator.  Visual idea: a drawing sheet - cool paper, ink-blue line work,
   dimension-line blue for everything interactive, and the live section drawing as the
   one prominent element. */
:root {
  --paper: #f3f6f9;
  --sheet: #ffffff;
  --ink: #14213d;
  --ink-2: #4a5a70;
  --line: #c9d3de;
  --line-2: #e3e9ef;
  --dim: #1f5fbf;          /* dimension-line blue: links, focus, selection */
  --dim-soft: #e6effb;
  --pass: #1a7a4c;
  --pass-soft: #e3f3ea;
  --fail: #b23a22;
  --fail-soft: #fbe9e4;
  --wait: #8a6100;
  --wait-soft: #fbf1d9;
  --r: 6px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font); line-height: 1.45;
  font-variant-numeric: tabular-nums; }
h1, h2, h3, p { margin: 0; }
a { color: var(--dim); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--dim); outline-offset: 2px; }

/* ------------------------------------------------------------- page chrome */
.top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .6rem 1.25rem; background: var(--ink); color: #fff; }
.brand { display: flex; align-items: baseline; gap: .75rem; color: #fff; text-decoration: none; }
.brand-m { font-weight: 700; letter-spacing: .02em; border: 1.5px solid #fff; padding: .05rem .45rem; border-radius: 3px; }
.brand-t { font-size: .92rem; opacity: .85; }
.nav { display: flex; align-items: center; gap: 1.1rem; font-size: .92rem; flex-wrap: wrap; }
.nav a, .nav .link { color: #fff; }
.nav form { margin: 0; }
.langs { display: flex; gap: .6rem; padding-left: 1rem; border-left: 1px solid rgba(255,255,255,.3); }
.langs a { text-decoration: none; opacity: .7; }
.langs a[aria-current] { opacity: 1; text-decoration: underline; text-underline-offset: 4px; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--dim); text-decoration: underline; cursor: pointer; }
.page { max-width: 1320px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font: inherit; font-weight: 600;
  padding: .55rem 1rem; border-radius: var(--r); border: 1px solid var(--line); background: var(--sheet); color: var(--ink);
  text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--dim); border-color: var(--dim); color: #fff; }
.btn.primary:hover { background: #184e9e; }
.btn.danger { background: var(--fail); border-color: var(--fail); color: #fff; }
.btn.ghost { border-style: dashed; color: var(--dim); font-weight: 500; }
.btn:disabled { opacity: .45; cursor: default; }
.tag { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .82rem; font-weight: 600; }
.tag.pass { background: var(--pass-soft); color: var(--pass); }
.tag.fail { background: var(--fail-soft); color: var(--fail); }
.tag.wait { background: var(--wait-soft); color: var(--wait); }

.hero { max-width: 46rem; padding: 2.5rem 0 2rem; }
.hero h1 { font-size: 2.3rem; line-height: 1.15; letter-spacing: -.01em; }
.lead { font-size: 1.1rem; color: var(--ink-2); margin-top: 1rem; }
.actions { display: flex; gap: .75rem; margin-top: 1.5rem; flex-wrap: wrap; }
.three { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 2rem; border-top: 1px solid var(--line); padding-top: 1.75rem; }
.three h2 { font-size: 1.05rem; margin-bottom: .35rem; }
.three p { color: var(--ink-2); }
.narrow { max-width: 28rem; margin: 2rem auto; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); padding: 1.75rem; }
.narrow h1 { font-size: 1.5rem; margin-bottom: 1rem; }
.narrow p { margin-top: 1rem; }
.auth p { margin: 0 0 .9rem; }
.auth label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .2rem; }
.auth input[type=text], .auth input[type=password] { width: 100%; }
.auth .helptext, .auth ul { display: block; font-size: .8rem; color: var(--ink-2); margin: .3rem 0 0; padding-left: 1.1rem; }
.auth ul.errorlist { color: var(--fail); list-style: none; padding: 0; }
.list-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; gap: 1rem; flex-wrap: wrap; }
.list-head h1 { font-size: 1.6rem; }
.empty { background: var(--sheet); border: 1px dashed var(--line); border-radius: var(--r); padding: 2rem; color: var(--ink-2); }

input[type=text], input[type=password], select, textarea { font: inherit; color: var(--ink); background: var(--sheet);
  border: 1px solid var(--line); border-radius: var(--r); padding: .5rem .6rem; min-width: 0; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-2); }
textarea { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }

.tbl { width: 100%; border-collapse: collapse; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); font-size: .93rem; }
.tbl th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: .82rem; padding: .55rem .75rem; border-bottom: 1px solid var(--line); }
.tbl td { padding: .55rem .75rem; border-bottom: 1px solid var(--line-2); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.crit td { background: var(--fail-soft); font-weight: 600; }
.tbl .strong { font-weight: 600; }
.row-actions { display: flex; gap: .9rem; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.row-actions form { margin: 0; }
.row-actions .danger { color: var(--fail); }

/* ------------------------------------------------------------------ wizard */
.is-wizard .page { padding-top: 1rem; }
.wz { display: grid; grid-template-columns: 11.5rem minmax(0, 1fr) 23rem; grid-template-areas: "bar bar bar" "steps main side"; gap: 1rem 1.5rem; align-items: start; }
.wz-bar { grid-area: bar; display: flex; align-items: center; gap: 1rem; }
.title-in { flex: 1; font-size: 1.25rem !important; font-weight: 600; border-color: transparent !important; background: transparent !important; padding-left: 0 !important; }
.title-in:hover, .title-in:focus { border-color: var(--line) !important; background: var(--sheet) !important; padding-left: .6rem !important; }
.status { font-size: .85rem; color: var(--ink-2); white-space: nowrap; }
.status.saved::before { content: "✓ "; color: var(--pass); }
.status.offline { color: var(--fail); font-weight: 600; }

.steps { grid-area: steps; list-style: none; margin: 0; padding: 0; position: sticky; top: 1rem; }
.steps li { position: relative; }
.steps li + li::before { content: ""; position: absolute; left: 1.02rem; top: -.5rem; height: .5rem; border-left: 1.5px solid var(--line); }
.step { display: flex; align-items: center; gap: .65rem; width: 100%; text-align: left; font: inherit; background: none; border: 0;
  padding: .45rem .3rem; margin-bottom: .5rem; border-radius: var(--r); color: var(--ink-2); cursor: pointer; }
.step-n { flex: none; width: 1.55rem; height: 1.55rem; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center;
  font-size: .85rem; font-weight: 600; background: var(--sheet); }
.step:hover { color: var(--ink); }
.step.on { color: var(--ink); font-weight: 600; }
.step.on .step-n { background: var(--ink); border-color: var(--ink); color: #fff; }
.step.has-err .step-n { border-color: var(--wait); color: var(--wait); background: var(--wait-soft); }
.step.on.has-err .step-n { background: var(--wait); color: #fff; }

.wz-main { grid-area: main; min-width: 0; }
.pane-t { font-size: 1.55rem; letter-spacing: -.01em; }
.pane-d { color: var(--ink-2); margin: .25rem 0 1.25rem; max-width: 42rem; }
.grid { display: grid; gap: 1rem; }
.sec { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); }
.sec-h { padding: .9rem 1.1rem 0; }
.sec-h h3 { font-size: 1rem; }
.sec-d { color: var(--ink-2); font-size: .88rem; margin-top: .2rem; max-width: 44rem; }
.sec-b { padding: .9rem 1.1rem 1.1rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(14.5rem, 1fr)); gap: .9rem 1.1rem; align-items: start; }
.fold > summary { cursor: pointer; padding: .8rem 1.1rem; font-weight: 600; font-size: .95rem; color: var(--ink-2); list-style-position: inside; }
.fold[open] > summary { color: var(--ink); border-bottom: 1px solid var(--line-2); }
.fold.inner { margin-top: .75rem; border: 1px solid var(--line-2); border-radius: var(--r); }
.fold.inner .tbl { border: 0; }
.fld { min-width: 0; }
.fld-wide { grid-column: 1 / -1; }
.lab { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; font-size: .88rem; font-weight: 600; margin-bottom: .25rem; }
.sym { font-weight: 400; color: var(--ink-2); font-style: italic; white-space: nowrap; font-family: "Cambria Math", Cambria, Georgia, serif; }
.ctl { display: flex; align-items: stretch; }
.ctl input, .ctl select { flex: 1; width: 100%; }
.ctl input:not(:last-child), .ctl select:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.unit { display: grid; place-items: center; padding: 0 .55rem; font-size: .82rem; color: var(--ink-2); background: var(--paper);
  border: 1px solid var(--line); border-left: 0; border-radius: 0 var(--r) var(--r) 0; white-space: nowrap; }
.help { font-size: .8rem; color: var(--ink-2); margin-top: .25rem; }
.err { font-size: .82rem; color: var(--fail); font-weight: 600; }
.err:empty { display: none; }
.fld.bad input, .fld.bad select, .layer.bad input { border-color: var(--fail); background: var(--fail-soft); }
.fld-check { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding-top: 1.45rem; }
.fld-check .lab { margin: 0; font-weight: 500; font-size: .93rem; }
.fld-check input { width: 1.05rem; height: 1.05rem; accent-color: var(--dim); }
.fld-check .help, .fld-check .err { flex-basis: 100%; }
.seg { display: flex; flex-wrap: wrap; gap: .4rem; }
.seg-b { font: inherit; padding: .5rem .85rem; border: 1px solid var(--line); background: var(--sheet); border-radius: var(--r); cursor: pointer; color: var(--ink); }
.seg-b:hover { border-color: var(--ink-2); }
.seg-b.on { border-color: var(--dim); background: var(--dim-soft); color: #123f82; font-weight: 600; box-shadow: inset 0 0 0 1px var(--dim); }
.calc-note { font-size: .88rem; background: var(--dim-soft); border-left: 3px solid var(--dim); padding: .5rem .75rem; border-radius: 0 var(--r) var(--r) 0; }
.warn { font-size: .86rem; background: var(--wait-soft); border-left: 3px solid var(--wait); padding: .45rem .7rem; margin-top: .6rem; border-radius: 0 var(--r) var(--r) 0; }

.layer { display: grid; grid-template-columns: 1.6rem 8.5rem minmax(0, 1fr) 2rem; gap: .5rem; align-items: start; margin-bottom: .5rem; }
.layer-head { font-size: .8rem; color: var(--ink-2); margin-bottom: .25rem; }
.layer-n { width: 1.5rem; height: 1.5rem; margin-top: .45rem; border-radius: 3px; background: var(--ink); color: #fff; font-size: .8rem; font-weight: 600; display: grid; place-items: center; }
.layer .err { grid-column: 2 / -1; }
.mat select { width: 100%; }
.mat-c { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .4rem; }
.mini { display: grid; font-size: .76rem; color: var(--ink-2); gap: .1rem; }
.mini input { width: 6.5rem; padding: .3rem .45rem; }
.ico { width: 2rem; height: 2.35rem; border: 1px solid var(--line); background: var(--sheet); border-radius: var(--r); font-size: 1.1rem; cursor: pointer; color: var(--ink-2); }
.ico:hover:not(:disabled) { color: var(--fail); border-color: var(--fail); }
.ico:disabled { opacity: .35; cursor: default; }

.svs { display: flex; flex-wrap: wrap; gap: .5rem; }
.sv { display: grid; justify-items: center; gap: .15rem; padding: .35rem .45rem .3rem; border: 1px solid var(--line); border-radius: var(--r); background: var(--sheet); cursor: pointer; font: inherit; font-size: .8rem; color: var(--ink-2); }
.sv:hover { border-color: var(--ink-2); }
.sv.on { border-color: var(--dim); background: var(--dim-soft); color: #123f82; font-weight: 600; box-shadow: inset 0 0 0 1px var(--dim); }
.gplan { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem; }
.plan { width: 100%; max-height: 300px; background: var(--paper); border: 1px solid var(--line-2); border-radius: var(--r); }
.plan-t { fill: var(--ink); font-family: var(--font); }
.wz-foot { display: flex; justify-content: space-between; margin-top: 1.25rem; }

/* side panel: the live drawing and the verdict */
.wz-side { grid-area: side; position: sticky; top: 1rem; display: grid; gap: .9rem; max-height: calc(100vh - 2rem); overflow: auto; padding-bottom: .5rem; }
.sketch-box { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); padding: .6rem .6rem .45rem;
  background-image: linear-gradient(var(--line-2) 1px, transparent 1px), linear-gradient(90deg, var(--line-2) 1px, transparent 1px); background-size: 16px 16px; }
.sketch { display: block; width: 100%; height: 270px; }
.sk-lt { fill: var(--fail); font-weight: 600; }
.sk-cap { font-size: .8rem; color: var(--ink-2); text-align: center; margin-top: .25rem; background: var(--sheet); }
.sk-plate { fill: #dfe6ee; stroke: var(--ink); }
.sk-plate.alt { fill: #cdd7e2; }
.sk-plate.g-alu { fill: #eef1f4; } .sk-plate.g-alu.alt { fill: #e2e6ea; }
.sk-plate.g-cast { fill: #c3ccd6; } .sk-plate.g-cast.alt { fill: #b3bdc9; }
.sk-plate.g-magnesium { fill: #f2efe6; }
.sk-plate.g-tap { fill: #b9c4d0; }
.sk-bolt { fill: #6f7f92; stroke: var(--ink); }
.sk-thread { fill: #93a2b3; stroke: var(--ink); stroke-dasharray: 1.5 1; }
.sk-axis { stroke: var(--ink-2); stroke-dasharray: 6 2 1 2; stroke-width: .5; fill: none; }
.sk-cone { stroke: var(--dim); stroke-dasharray: 3 2; fill: none; }
.sk-dim { stroke: var(--dim); fill: none; }
.sk-t { fill: var(--dim); font-family: var(--font); }
.sk-load { stroke: var(--fail); fill: none; stroke-width: 1.4; }
.sk-loadhead { fill: var(--fail); }
.sv .sk-plate, .sv .sk-bolt { stroke-width: 1; }

.verdict { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .7rem .9rem; border-radius: var(--r); border: 1px solid; }
.verdict strong { font-size: 1.02rem; }
.verdict span { font-weight: 700; }
.verdict.pass { background: var(--pass-soft); border-color: var(--pass); color: var(--pass); }
.verdict.fail { background: var(--fail-soft); border-color: var(--fail); color: var(--fail); }
.verdict.wait { background: var(--wait-soft); border-color: var(--wait); color: var(--wait); }
.verdict.pass strong, .verdict.fail strong, .verdict.wait strong { color: var(--ink); }
.todo { margin: .6rem 0 0; padding-left: 1.1rem; font-size: .88rem; }
.checks { list-style: none; margin: .8rem 0 0; padding: 0; display: grid; gap: .55rem; }
.checks li { background: var(--sheet); border: 1px solid var(--line); border-left: 4px solid var(--pass); border-radius: var(--r); padding: .5rem .7rem; }
.checks li.ko { border-left-color: var(--fail); }
.ck-h { display: flex; justify-content: space-between; gap: .5rem; font-size: .9rem; }
.ck-n { font-weight: 600; }
.ck-s { white-space: nowrap; color: var(--pass); font-weight: 600; }
.ko .ck-s { color: var(--fail); }
.ck-s small { color: var(--ink-2); font-weight: 400; }
.bar { height: 6px; background: var(--line-2); border-radius: 3px; margin: .35rem 0 .25rem; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--pass); border-radius: 3px; }
.ko .bar i { background: var(--fail); }
.ck-v { font-size: .8rem; color: var(--ink-2); }
.fix { font-size: .84rem; margin-top: .35rem; color: var(--fail); }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .3rem 1rem; margin: .9rem 0 0; font-size: .9rem; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.hint { margin-top: .9rem; padding: .7rem .8rem; background: var(--dim-soft); border-radius: var(--r); display: grid; gap: .5rem; font-size: .9rem; }
.hint .btn { justify-self: start; }

/* results step */
.on-results .wz-side { display: none; }
.on-results { grid-template-columns: 11.5rem minmax(0, 1fr); grid-template-areas: "bar bar" "steps main"; }
.rep-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.1rem; }
.rep-head h2 { font-size: 1.35rem; display: inline; margin-right: .6rem; }
.rep-head p { display: inline-block; }
.rsteps { display: grid; grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr)); gap: 1rem; margin-top: 1rem; }
.rstep { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); padding: .8rem 1rem 1rem; }
.rstep h3 { display: flex; align-items: center; gap: .55rem; font-size: .95rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line-2); }
.rstep h3 b { background: var(--ink); color: #fff; border-radius: 3px; padding: 0 .4rem; font-size: .82rem; }
.rstep h3 .tag { margin-left: auto; }
.rstep .kv { margin-top: .6rem; grid-template-columns: auto minmax(0, 1fr); }
.rstep .kv dt { white-space: nowrap; }
.rstep .kv dt { font-family: "Cambria Math", Cambria, Georgia, serif; font-style: italic; color: var(--ink); }
.rstep .kv dd { font-weight: 500; }
.disclaimer { font-size: .82rem; color: var(--ink-2); margin-top: 1.25rem; max-width: 52rem; }

@media (max-width: 1100px) {
  .wz { grid-template-columns: minmax(0, 1fr) 20rem; grid-template-areas: "bar bar" "steps steps" "main side"; }
  .on-results { grid-template-columns: minmax(0, 1fr); grid-template-areas: "bar" "steps" "main"; }
  .steps { position: static; display: flex; gap: .25rem; overflow-x: auto; }
  .steps li + li::before { display: none; }
  .step { margin: 0; white-space: nowrap; }
}
@media (max-width: 760px) {
  .wz { grid-template-columns: minmax(0, 1fr); grid-template-areas: "bar" "steps" "side" "main"; }
  .wz-side { position: static; max-height: none; }
  .sketch { height: 190px; }
  .checks, .kv, .hint, .todo { display: none; }
  .wz-side .verdict { display: flex; }
  .brand-t { display: none; }
  .hero h1 { font-size: 1.7rem; }
  .layer { grid-template-columns: 1.6rem 6.5rem minmax(0, 1fr) 2rem; }
  .tbl.list thead { display: none; }
  .tbl.list td { display: block; border: 0; padding: .2rem .75rem; }
  .tbl.list tr { display: block; border-bottom: 1px solid var(--line); padding: .5rem 0; }
  .row-actions { justify-content: flex-start; }
}
@media (prefers-reduced-motion: no-preference) {
  .bar i { transition: width .25s ease; }
}
