:root {
  --bg: #f6f6f2; --surface: #ffffff; --surface-2: #efefe9; --text: #1b1d21; --muted: #5d6370;
  --border: #e1e1d9; --accent: #e4561a; --accent-2: #b8420f; --accent-soft: #fdeee6;
  --ok: #1f7a4d; --warn: #9a5b00; --bad: #b3261e; --ok-soft: #e5f4ec; --warn-soft: #fff4e0; --bad-soft: #fde8e6;
  --radius: 12px; --maxw: 820px;
  --shadow: 0 1px 2px rgba(20,20,30,.05), 0 10px 30px -14px rgba(20,20,30,.18);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131417; --surface: #1c1e23; --surface-2: #24272d; --text: #e9e9e4; --muted: #a1a6b1;
    --border: #2f333b; --accent: #ff7a3d; --accent-2: #ffa079; --accent-soft: #3a2418;
    --ok-soft: #173325; --warn-soft: #3a2c10; --bad-soft: #3d1c1a; --ok: #6fcf97; --warn: #ffc466; --bad: #ff8a80;
    --shadow: none;
  }
}
@font-face { font-family: "Manrope"; font-style: normal; font-weight: 200 800; font-display: swap; src: url("/static/fonts/manrope-latin.woff2") format("woff2"); }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--accent-2); }
a:hover { color: var(--accent); }
h1, h2, h3, h4, .brand, .result .v, .hero-stats b { font-family: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.02em; font-weight: 800; }
h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); margin: .2em 0 .3em; }
h2 { font-size: 1.35rem; margin: 2em 0 .6em; }
h3 { font-size: 1.05rem; margin: 1.4em 0 .4em; font-weight: 700; }
p, ul, ol { margin: 0 0 1em; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
pre { background: var(--surface-2); border: 1px solid var(--border); padding: 12px 14px; border-radius: 8px; overflow-x: auto; font-size: .88rem; line-height: 1.45; }
pre code { background: none; padding: 0; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
.table-wrap { overflow-x: auto; margin: 0 0 1.2em; -webkit-overflow-scrolling: touch; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff; padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* header */
.masthead { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px); }
@supports not (color: color-mix(in srgb, red, blue)) { .masthead { background: var(--surface); } }
.masthead .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav a { text-decoration: none; color: var(--muted); font-weight: 600; padding: 6px 11px; border-radius: 8px; font-size: .92rem; }
.nav a:hover, .nav a[aria-current] { color: var(--text); background: var(--surface-2); }
@media (max-width: 560px) { .brand span { display: none; } .nav a { padding: 6px 8px; font-size: .88rem; } }

/* hero + cards */
.home { position: relative; }
.home::before { content: ""; position: absolute; inset: -62px 0 auto 0; height: 560px; z-index: -1; pointer-events: none;
  background: radial-gradient(55% 60% at 85% 0%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%),
              radial-gradient(40% 50% at 10% 10%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%); }
.hero { padding: 64px 0 28px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-2); margin: 0 0 14px; }
.eyebrow::before { content: ""; width: 22px; height: 2px; background: var(--accent); border-radius: 2px; }
.hero h1 { font-size: clamp(2.1rem, 5.4vw, 3.4rem); max-width: 16em; margin: 0 0 .35em; line-height: 1.08; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { font-size: 1.15rem; color: var(--muted); max-width: 36em; margin: 0 0 1.4em; }
.hero-search { position: relative; max-width: 560px; }
.hero-search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; stroke: var(--muted); fill: none; stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.hero-search input { width: 100%; padding: 15px 18px 15px 48px; font: inherit; font-size: 1.02rem; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(20,20,30,.04), 0 12px 32px -18px rgba(20,20,30,.3); }
.hero-search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.hero-stats { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 22px 0 0; color: var(--muted); font-size: .92rem; }
.hero-stats b { color: var(--text); font-weight: 800; font-size: 1.15rem; margin-right: 4px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin: 0 0 8px; }
.card { position: relative; display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 18px 18px 16px; text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s, box-shadow .15s; box-shadow: 0 1px 2px rgba(20,20,30,.03); }
.card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); transform: translateY(-2px); color: var(--text); box-shadow: 0 14px 30px -18px rgba(20,20,30,.35); }
.card-icon { width: 40px; height: 40px; border-radius: 11px; background: var(--accent-soft); display: grid; place-items: center; }
.card-icon svg { width: 22px; height: 22px; stroke: var(--accent); fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.card h3 { margin: 0; font-size: 1.02rem; color: var(--text); line-height: 1.3; }
.card p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.45; }
.card::after { content: "→"; position: absolute; right: 16px; top: 18px; color: var(--muted); opacity: 0; transform: translateX(-4px); transition: opacity .15s, transform .15s; font-weight: 700; }
.card:hover::after { opacity: 1; transform: none; color: var(--accent); }
.card[hidden] { display: none; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 2.6em 0 .5em; }
.section-head h2 { margin: 0; font-size: 1.5rem; }
.section-head a { font-size: .9rem; white-space: nowrap; font-weight: 600; text-decoration: none; }
.section-head a:hover { text-decoration: underline; }
.section-head + p { color: var(--muted); margin-top: 0; max-width: 46em; }
.section[hidden] { display: none; }
.no-results { color: var(--muted); padding: 30px 0; }
.why { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0; margin: 3em 0 0; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.why div { padding: 20px 20px 18px; border-left: 1px solid var(--border); }
.why div:first-child { border-left: 0; }
@media (max-width: 700px) { .why div { border-left: 0; border-top: 1px solid var(--border); } .why div:first-child { border-top: 0; } }
.why h3 { margin: 0 0 4px; font-size: .98rem; }
.why p { margin: 0; color: var(--muted); font-size: .9rem; }

/* tool page */
.breadcrumb { font-size: .85rem; color: var(--muted); padding: 14px 0 0; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.tool-head { padding-top: 8px; }
.lede { font-size: 1.08rem; color: var(--muted); max-width: 44em; margin-bottom: 1.2em; }
.calc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
@media (max-width: 480px) { .calc { padding: 16px 14px; } }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 16px; }
.fields.two { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.field { min-width: 0; }
.field label, .group-label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field input[type=number], .field input[type=text], .field select, .field textarea {
  width: 100%; padding: 9px 12px; font: inherit; font-size: 1rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
}
.field textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; min-height: 90px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.field .hint { font-size: .78rem; color: var(--muted); margin: 4px 0 0; line-height: 1.35; }
.inwrap { position: relative; }
.inwrap .unit { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .82rem; pointer-events: none; }
.inwrap input { padding-right: 52px !important; }
.inwrap.prefix input { padding-left: 30px !important; padding-right: 12px !important; }
.inwrap .pre { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .9rem; pointer-events: none; }
fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
legend { font-size: .95rem; font-weight: 700; padding: 0; margin-bottom: 10px; }
.group { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.group:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 14px; flex-wrap: wrap; }
.seg label { position: relative; padding: 7px 14px; cursor: pointer; font-size: .92rem; font-weight: 500; color: var(--muted); background: var(--surface); }
.seg label + label { border-left: 1px solid var(--border); }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg input:checked + span { color: var(--accent-2); font-weight: 700; }
.seg label:has(input:checked) { background: var(--accent-soft); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-size: .95rem; margin: 8px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.results { margin-top: 20px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.result { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; min-width: 0; }
.result .l { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.result .v { font-size: 1.55rem; font-weight: 700; line-height: 1.2; margin-top: 2px; word-break: break-word; }
.result .s { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.result.primary { background: var(--accent-soft); grid-column: 1 / -1; }
.result.primary .v { font-size: 2rem; color: var(--accent-2); }
.result.ok { background: var(--ok-soft); } .result.ok .v { color: var(--ok); }
.result.warn { background: var(--warn-soft); } .result.warn .v { color: var(--warn); }
.result.bad { background: var(--bad-soft); } .result.bad .v { color: var(--bad); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; align-items: center; }
.btn, .btn-ghost { font: inherit; font-weight: 600; font-size: .95rem; padding: 9px 16px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.btn { background: var(--accent); color: #fff; }
.btn:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.cur-label { font-size: .85rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.cur-label select { font: inherit; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.calc .breakdown { margin-top: 18px; }
.calc .breakdown td:last-child, .calc .breakdown th:last-child { text-align: right; white-space: nowrap; }
.calc .breakdown tr.total td { font-weight: 700; border-top: 2px solid var(--border); }
.note, .warn-box, .ok-box { border-radius: 8px; padding: 10px 14px; font-size: .92rem; margin: 14px 0 0; }
.note { background: var(--surface-2); color: var(--muted); }
.warn-box { background: var(--warn-soft); color: var(--text); border-left: 4px solid var(--warn); }
.ok-box { background: var(--ok-soft); color: var(--text); border-left: 4px solid var(--ok); }
.calc pre.gcode { max-height: 260px; overflow: auto; margin: 12px 0 0; }
.article { margin-top: 36px; max-width: 46em; }
.article h2 { font-size: 1.3rem; }
.article .formula { background: var(--surface-2); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 6px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .95rem; margin: 1em 0; overflow-x: auto; }
.article .example { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; margin: 1em 0; }
.article .example h3 { margin-top: 0; }
.faq { max-width: 46em; }
.faq h3 { margin-top: 1.3em; font-size: 1.02rem; }
.faq p { color: var(--text); }
.updated { color: var(--muted); font-size: .85rem; margin-top: 2.5em; }
.related { margin: 40px auto 10px; }
.related h2 { margin: 0 0 12px; font-size: 1.15rem; }
.ad-slot { margin: 26px 0; text-align: center; }
.ad-slot ins { display: block; }

/* generic page */
.page { max-width: 46em; padding-top: 24px; }
.page h1 { margin-top: .4em; }
.ref-controls { margin: 0 0 14px; }
.ref-controls input { width: 100%; max-width: 360px; padding: 9px 12px; font: inherit; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.ref-table td:first-child { font-weight: 600; white-space: nowrap; }
.ref-table td { font-size: .9rem; }

/* footer */
.footer { margin-top: 72px; border-top: 1px solid var(--border); background: var(--surface); font-size: .9rem; color: var(--muted); }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 32px; padding-top: 36px; padding-bottom: 28px; }
@media (max-width: 700px) { .footer-grid { grid-template-columns: 1fr; gap: 22px; } }
.footer-brand .brand span { display: inline; }
.footer-brand p { margin: 12px 0 0; max-width: 30em; }
.footer-col { display: flex; flex-direction: column; gap: 6px; }
.footer-col h4 { margin: 0 0 4px; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text); }
.footer-col a { color: var(--muted); text-decoration: none; }
.footer-col a:hover { color: var(--accent); }
.footer-legal { border-top: 1px solid var(--border); padding-top: 16px; padding-bottom: 28px; font-size: .82rem; }
.footer-legal p { margin: 0; }
.home-faq { max-width: 46em; }
@media print { .masthead, .footer, .ad-slot, .related, .actions { display: none; } }
