/* StructMath — site styles (mobile-first, light + system dark) */
:root {
  --brand: #ea580c;
  --brand-ink: #c2410c;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --brand-soft: rgba(234, 88, 12, .10);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e5e7eb;
    --muted: #94a3b8;
    --line: #24324a;
    --bg: #0b1220;
    --card: #101a2c;
    --brand-soft: rgba(234, 88, 12, .16);
    --brand-ink: #fb923c;
    --ok: #4ade80;
    --warn: #fbbf24;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}
.wrap { max-width: 1060px; margin: 0 auto; padding: 0 16px; }
.wrap.narrow { max-width: 780px; }
a { color: var(--brand-ink); }
img, svg { max-width: 100%; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 8px; top: 8px; background: var(--card); padding: 8px 12px; border-radius: 8px; z-index: 99; }

/* ---------- header + tabs ---------- */
header.site { background: var(--card); border-bottom: 1px solid var(--line); }
header.site .wrap { display: flex; align-items: center; gap: 18px; height: 58px; }
.logo { font-weight: 800; font-size: 1.1rem; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 9px; letter-spacing: -.2px; }
.mark { width: 22px; height: 22px; border-radius: 6px; background: var(--brand); position: relative; flex: 0 0 auto; }
.mark::after { content: ""; position: absolute; left: 5px; right: 5px; top: 7px; height: 2.5px; background: #fff; box-shadow: 0 4px 0 #fff, 0 8px 0 #fff; border-radius: 2px; }
nav.main { margin-left: auto; display: flex; gap: 16px; }
nav.main a { color: var(--muted); font-weight: 600; font-size: .88rem; text-decoration: none; padding: 4px 0; }
nav.main a:hover, nav.main a.active { color: var(--brand); }
.tabbar { display: none; }
@media (max-width: 860px) {
  nav.main { display: none; }
  body { padding-bottom: 76px; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    background: var(--card); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; font-size: .66rem; font-weight: 600; color: var(--muted); text-decoration: none; }
  .tab svg { width: 22px; height: 22px; }
  .tab.active { color: var(--brand); }
}

/* ---------- hero + home ---------- */
.hero { padding: 42px 0 10px; }
.hero h1 { font-size: clamp(1.7rem, 4.6vw, 2.5rem); line-height: 1.15; margin: 0 0 10px; letter-spacing: -.5px; }
.hero h1 em { color: var(--brand); font-style: normal; }
.hero .sub { color: var(--muted); font-size: 1.02rem; max-width: 640px; margin: 0 0 18px; }
.search-wrap input {
  width: 100%; padding: 14px 16px; font-size: 1rem; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; outline: none;
}
.search-wrap input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
::placeholder { color: var(--muted); opacity: 1; }
.chips-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 6px; }
.pill { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: .85rem; color: var(--ink); text-decoration: none; font-weight: 600; }
.pill:hover { border-color: var(--brand); color: var(--brand); }
h2.sec { font-size: 1.3rem; margin: 38px 0 14px; letter-spacing: -.3px; }
.grid { display: grid; gap: 14px; }
.grid.tools { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grid.cats { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tool-card, .cat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-decoration: none; color: var(--ink); display: block; transition: border-color .15s, transform .15s; }
.tool-card:hover, .cat-card:hover { border-color: var(--brand); transform: translateY(-1px); }
.tool-card h3 { margin: 8px 0 6px; font-size: 1.02rem; }
.tool-card p { margin: 0 0 10px; color: var(--muted); font-size: .86rem; }
.chip { display: inline-block; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--brand-ink); background: var(--brand-soft); padding: 3px 8px; border-radius: 6px; }
.go { color: var(--brand); font-weight: 700; font-size: .84rem; }
.cat-card h3 { margin: 0 0 6px; }
.cat-card p { color: var(--muted); font-size: .88rem; margin: 0 0 10px; }
.cat-card .count { color: var(--brand); font-weight: 700; font-size: .84rem; }
.more { margin: 14px 0 0; }
.more a { font-weight: 700; text-decoration: none; }
.promise { display: grid; grid-template-columns: 1fr; gap: 14px; margin: 38px 0 10px; }
@media (min-width: 760px) { .promise { grid-template-columns: repeat(3, 1fr); } }
.promise-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.promise-item h3 { margin: 0 0 6px; font-size: .98rem; }
.promise-item p { margin: 0; color: var(--muted); font-size: .86rem; }

/* ---------- tool page ---------- */
.crumbs { font-size: .84rem; color: var(--muted); margin: 18px 0 6px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--brand); }
h1 { font-size: clamp(1.5rem, 4vw, 2rem); margin: .2em 0 .35em; letter-spacing: -.4px; line-height: 1.2; }
.quick-answer { background: var(--brand-soft); border-left: 4px solid var(--brand); padding: 10px 14px; border-radius: 0 10px 10px 0; font-size: .95rem; margin: 0 0 18px; }
.tool-grid { display: grid; gap: 16px; margin: 0 0 10px; }
@media (min-width: 920px) { .tool-grid { grid-template-columns: 1fr 1fr; align-items: start; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.live-note { font-size: .76rem; color: var(--muted); margin: 12px 0 0; }
/* schematic diagrams */
.diagram { margin: 0 0 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px 2px; }
.diagram:empty { display: none; }
.diagram svg { display: block; width: 100%; height: auto; max-height: 250px; }
.dg-f1 { fill: var(--card); stroke: var(--ink); stroke-width: 1.5; }
.dg-f2 { fill: var(--bg); stroke: var(--ink); stroke-width: 1.5; }
.dg-f3 { fill: var(--card); stroke: var(--ink); stroke-width: 1.5; opacity: .72; }
.dg-dim { stroke: var(--brand); stroke-width: 1.2; }
.dg-rebar { stroke: var(--brand); stroke-width: 1.1; opacity: .85; }
.dg-stringer { stroke: var(--brand); stroke-width: 1.6; stroke-dasharray: 5 4; }
.dg-t { fill: var(--ink); font-family: 'Segoe UI', system-ui, sans-serif; font-size: 11.5px; font-weight: 600; }
.dg-ts { fill: var(--muted); font-family: 'Segoe UI', system-ui, sans-serif; font-size: 10.5px; font-weight: 500; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 5px; letter-spacing: .2px; }
.input-wrap { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); overflow: hidden; }
.input-wrap:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input-wrap input { border: 0; background: transparent; padding: 11px 12px; font-size: 1rem; width: 100%; color: var(--ink); outline: none; min-width: 0; }
.input-wrap .unit { padding: 0 12px; color: var(--muted); font-size: .82rem; border-left: 1px solid var(--line); white-space: nowrap; font-weight: 600; }
select { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: .95rem; color: var(--ink); }
select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); outline: none; }
@media (max-width: 919px) {
  #tool-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
  #tool-form .field:has(select) { grid-column: 1 / -1; }
}
/* result card */
.result-card { border-color: var(--brand); scroll-margin-top: 80px; }
.result-head { font-weight: 800; color: var(--ok); font-size: 1.02rem; margin-bottom: 4px; }
.result-sub { color: var(--muted); font-size: .84rem; margin: 0 0 12px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
@media (max-width: 520px) { .stats { grid-template-columns: 1fr 1fr; } .stats .stat:last-child:nth-child(odd) { grid-column: 1 / -1; } }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat-v { font-size: 1.12rem; font-weight: 800; letter-spacing: -.3px; }
.stat-l { font-size: .68rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; margin-top: 2px; }
.stat-s { font-size: .78rem; color: var(--brand-ink); font-weight: 700; margin-top: 3px; }
.rrows { margin: 10px 0; }
.rrow { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: .89rem; }
.rrow span { color: var(--muted); }
.rrow b { text-align: right; }
.rrow.stack { flex-direction: column; gap: 2px; }
.rrow.stack b { text-align: left; }
.order { background: var(--bg); border: 1px dashed var(--brand); border-radius: 12px; padding: 12px 14px; margin-top: 12px; }
.order h4 { margin: 0 0 8px; font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; color: var(--brand-ink); }
.order ul { list-style: none; padding: 0; margin: 0; }
.order li { padding: 5px 0; font-size: .93rem; font-weight: 600; }
.qty { color: var(--brand); font-weight: 800; }
.buy-row { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; font-size: .78rem; color: var(--muted); }
.buy-label { font-weight: 600; }
.buy-links { display: flex; flex-wrap: wrap; gap: 8px; }
.buy { font-size: .78rem; font-weight: 700; color: var(--brand-ink); text-decoration: none; border: 1px solid var(--brand); border-radius: 999px; padding: 5px 10px; min-width: 96px; text-align: center; }
.buy:hover { background: var(--brand); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 4px; }
.mini { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; font-size: .8rem; font-weight: 600; }
.btn { display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 700; cursor: pointer; font-size: .88rem; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--brand-ink); border: 1px solid var(--brand); }
.note { font-size: .8rem; color: var(--muted); margin: 10px 0 0; }
.checks { list-style: none; padding: 0; margin: 10px 0; }
.checks li { font-size: .9rem; padding: 4px 0; font-weight: 600; }
.checks .ok { color: var(--ok); }
.checks .warn { color: var(--warn); }

/* ---------- prose / content ---------- */
.prose { max-width: 780px; margin-top: 8px; }
.prose h2 { font-size: 1.22rem; margin: 34px 0 10px; letter-spacing: -.3px; }
.prose h3 { font-size: 1rem; margin: 22px 0 8px; }
.prose p { margin: 10px 0; }
.formula { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg); padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); font-size: .86rem; overflow-x: auto; }
.assumptions li, .sources li { font-size: .87rem; color: var(--muted); margin: 5px 0; }
.verified { font-size: .84rem; font-weight: 700; color: var(--ok); }
.disclaimer-inline { font-size: .78rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; margin-top: 14px; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .87rem; margin: 10px 0; }
th { background: var(--bg); text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--line); font-size: .74rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
details.faq { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 8px 0; background: var(--card); }
details.faq summary { font-weight: 700; cursor: pointer; font-size: .94rem; }
.faq-a { padding-top: 8px; color: var(--muted); font-size: .9rem; }
.lede { color: var(--muted); font-size: 1rem; }

/* ---------- ad slots ---------- */
.ad-slot { display: none; min-height: 90px; background: var(--bg); border-radius: 12px; margin: 22px 0; text-align: center; color: var(--muted); font-size: .8rem; }
body.has-ads .ad-slot { display: block; }
body.ads-preview .ad-slot { display: block; border: 1px dashed var(--muted); padding-top: 34px; }
body.ads-preview .ad-slot::before { content: "Ad slot · " attr(data-slot); }
ins.adsbygoogle[data-ad-status="unfilled"] { display: none !important; }
.ad-slot:has(ins.adsbygoogle[data-ad-status="unfilled"]) { margin: 0; }

/* ---------- footer ---------- */
footer.site { border-top: 1px solid var(--line); margin-top: 52px; background: var(--card); }
footer.site .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 28px 0 8px; }
@media (min-width: 760px) { footer.site .cols { grid-template-columns: 2fr 1fr 1fr 1fr; } }
footer.site h4 { font-size: .76rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 0 0 8px; }
footer.site a { display: block; color: var(--muted); text-decoration: none; font-size: .87rem; padding: 3px 0; }
footer.site a:hover { color: var(--brand); }
footer.site p { color: var(--muted); font-size: .87rem; margin: 0; }
.disclaimer { border-top: 1px solid var(--line); padding: 14px 0 22px; font-size: .76rem; color: var(--muted); }

/* ---------- print: just the result ---------- */
@media print {
  header.site, footer.site, .tabbar, .ad-slot, nav.main, .crumbs, .quick-answer,
  .tool-card-live, .prose, .live-note, .hero, .promise, .chips-row, .search-wrap { display: none !important; }
  body { background: #fff; padding: 0; }
  .wrap { max-width: none; padding: 0; }
  .tool-grid { display: block; }
  .card { border: 0; padding: 0; }
  .btn, .buy-row { display: none !important; }
  .order { border: 1px solid #999; }
  h1 { font-size: 1.4rem; }
}
