/* MeasureQuik design system — no frameworks, no webfonts, fast by default */
:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --surface-2: #f1f0ec;
  --text: #131210;
  --text-muted: #45423a;
  --brand: #c2410c;        /* burnt orange — tools/construction, not tech-blue */
  --brand-ink: #9a3412;
  --brand-soft: #ffedd5;
  --border: #cfccc2;
  --ok: #15803d;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 6px 18px rgba(0,0,0,.07);
  --edge: rgba(0,0,0,.16);          /* bottom edge for raised elements */
  --hilite: rgba(255,255,255,.85);  /* top inner highlight */
  --well: inset 0 2px 4px rgba(0,0,0,.07), inset 0 1px 2px rgba(0,0,0,.05);
  --maxw: 62rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16150f;
    --surface: #1f1e18;
    --surface-2: #29271f;
    --text: #f4f2ec;
    --text-muted: #bab5a8;
    --brand: #fb923c;
    --brand-ink: #fdba74;
    --brand-soft: #3b2a1a;
    --border: #38352c;
    --ok: #4ade80;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
    --edge: rgba(0,0,0,.55);
    --hilite: rgba(255,255,255,.07);
    --well: inset 0 2px 5px rgba(0,0,0,.45);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}
img, svg { max-width: 100%; height: auto; }

/* ---------- layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 1.25rem; }
main.wrap { padding-block: 1.5rem 3rem; }

/* ---------- header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 3.5rem; gap: 1rem;
}
.logo {
  display: flex; align-items: center; gap: .5rem;
  font-weight: 700; font-size: 1.2rem; text-decoration: none; color: var(--text);
  letter-spacing: -.01em;
}
.logo svg { flex: none; }
.logo .q { color: var(--brand); }
.site-nav { display: flex; gap: 1.25rem; }
.site-nav a { color: var(--text-muted); text-decoration: none; font-size: .95rem; font-weight: 500; }
.site-nav a:hover { color: var(--brand); }

/* ---------- breadcrumbs ---------- */
.crumbs { font-size: .85rem; color: var(--text-muted); margin: 1rem 0 .25rem; }
.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--brand); }

/* ---------- typography ---------- */
h1 { font-size: clamp(1.6rem, 4vw, 2.15rem); line-height: 1.2; letter-spacing: -.02em; margin: .5rem 0 .5rem; }
.subtitle { color: var(--text-muted); margin: 0 0 1.5rem; max-width: 46rem; }
h2 { font-size: 1.45rem; letter-spacing: -.01em; margin: 2.5rem 0 .75rem; }
h3 { font-size: 1.15rem; margin: 1.75rem 0 .5rem; }
a { color: var(--brand-ink); }
code, .formula {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: .92em;
  background: var(--surface-2);
  padding: .1em .35em; border-radius: 5px;
}
.formula { display: inline-block; padding: .5rem .85rem; margin: .35rem 0; }

/* ---------- calculator card ---------- */
.calc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 3px 0 var(--edge), var(--shadow);
  overflow: hidden;
  margin: 1.25rem 0 2rem;
}
.tabs {
  display: flex; flex-wrap: wrap;
  gap: .45rem;
  padding: .6rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--well);
}
.tab {
  flex: 1 1 auto;
  appearance: none; cursor: pointer;
  font: inherit; font-size: .92rem; font-weight: 600;
  color: var(--text);
  padding: .6rem .6rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(to bottom, var(--surface), var(--surface-2));
  box-shadow: inset 0 1px 0 var(--hilite), 0 2px 0 var(--edge), 0 3px 6px rgba(0,0,0,.07);
  white-space: nowrap;
  text-align: center;
  min-height: 44px;
  transition: transform .06s ease, box-shadow .06s ease;
}
.tab:hover { border-color: var(--brand); color: var(--brand); }
@media (max-width: 719px) {
  .tab { flex-basis: 29%; padding-inline: .3rem; font-size: .88rem; }
}
.tab[aria-selected="true"] {
  color: #fff;
  border-color: var(--brand-ink);
  background: linear-gradient(to bottom, var(--brand), #a63a0a);
  box-shadow: inset 0 2px 4px rgba(0,0,0,.28), inset 0 1px 2px rgba(0,0,0,.2);
  transform: translateY(1px);
}
@media (prefers-color-scheme: dark) {
  .tab[aria-selected="true"] { background: linear-gradient(to bottom, #c2410c, #9a3412); border-color: #7c2d12; }
}
.calc-body { display: grid; gap: 1.5rem; padding: 1.4rem; }
@media (min-width: 720px) {
  .calc-body { grid-template-columns: 1fr 1fr; align-items: start; }
}

/* inputs */
.field { margin-bottom: .9rem; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .3rem; }
.field-row { display: flex; gap: .5rem; }
.unit-fixed {
  display: inline-flex; align-items: center;
  padding: 0 .8rem; min-height: 44px;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--surface-2); color: var(--text-muted);
  font-weight: 600; font-size: .9rem;
}
.field input, .field select {
  width: 100%;
  font: inherit; color: var(--text);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: .55rem .7rem;
  min-height: 44px;
  box-shadow: var(--well);
}
.field input:focus, .field select:focus {
  outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand);
}
.field select { flex: none; width: auto; }
.hint { font-size: .85rem; color: var(--text-muted); margin-top: .25rem; }

/* diagram */
.diagram {
  display: flex; justify-content: center; padding: .5rem 0 1rem;
}
.diagram svg { width: min(100%, 260px); }
.diagram .dim { fill: var(--text-muted); font-size: 13px; font-family: inherit; }
.diagram .shape { fill: var(--brand-soft); stroke: var(--brand); stroke-width: 2; }
.diagram .line { stroke: var(--text-muted); stroke-width: 1.25; }

/* results */
.results {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--well);
}
.results h2 { margin: 0 0 .75rem; font-size: 1.05rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.big-result { font-size: 2.6rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.big-result span { color: var(--brand-ink); }
.big-result small { font-size: 1.05rem; font-weight: 600; color: var(--text); }
.result-note { font-size: .85rem; color: var(--text-muted); margin: .35rem 0 0; }
.result-table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: .95rem; }
.result-table th, .result-table td { text-align: left; padding: .45rem .25rem; border-bottom: 1px solid var(--border); }
.result-table td:last-child, .result-table th:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.result-table tr:last-child td { border-bottom: 0; }
.cost-line { margin-top: 1rem; padding-top: .75rem; border-top: 2px solid var(--border); font-weight: 650; display: flex; justify-content: space-between; }

.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }
.btn {
  appearance: none; cursor: pointer; text-decoration: none;
  font: inherit; font-size: .9rem; font-weight: 600;
  border-radius: 8px; padding: .5rem .95rem; min-height: 40px;
  border: 1.5px solid var(--border);
  background: linear-gradient(to bottom, var(--surface), var(--surface-2));
  color: var(--text);
  display: inline-flex; align-items: center; gap: .4rem;
  box-shadow: inset 0 1px 0 var(--hilite), 0 2px 0 var(--edge), 0 3px 6px rgba(0,0,0,.08);
  transition: transform .06s ease, box-shadow .06s ease;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn:active {
  transform: translateY(2px);
  box-shadow: inset 0 1px 0 var(--hilite), 0 0 0 var(--edge), 0 1px 2px rgba(0,0,0,.08);
}
.btn-primary {
  background: linear-gradient(to bottom, #ea580c, var(--brand));
  border-color: var(--brand-ink); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 2px 0 #7c2d12, 0 3px 6px rgba(0,0,0,.15);
}
.btn-primary:hover { background: linear-gradient(to bottom, var(--brand), var(--brand-ink)); color: #fff; }
.btn-primary:active {
  transform: translateY(2px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 0 0 #7c2d12, 0 1px 2px rgba(0,0,0,.15);
}

/* ---------- ad slots: reserved height = zero layout shift ---------- */
.ad-slot {
  min-height: 100px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: .75rem; letter-spacing: .08em; text-transform: uppercase;
  margin: 1.75rem 0;
}

/* ---------- content tables ---------- */
.table-scroll { overflow-x: auto; margin: 1rem 0; }
table.content {
  width: 100%; border-collapse: collapse; font-size: .95rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
table.content th {
  background: var(--surface-2); text-align: left;
  padding: .6rem .8rem; border-bottom: 2px solid var(--border);
}
table.content td { padding: .55rem .8rem; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
table.content tr:last-child td { border-bottom: 0; }

/* ---------- FAQ ---------- */
.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: .6rem;
}
.faq summary {
  cursor: pointer; font-weight: 600; padding: .85rem 1.1rem;
  list-style: none; position: relative;
}
.faq summary::after { content: "+"; position: absolute; right: 1.1rem; color: var(--brand); font-weight: 700; }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 0; padding: 0 1.1rem .95rem; color: var(--text-muted); }

/* ---------- author / references ---------- */
.byline {
  display: flex; gap: .85rem; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .9rem 1.1rem; margin: 2rem 0; font-size: .92rem;
}
.byline .avatar {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; font-size: 1.1rem;
}
.byline p { margin: 0; color: var(--text-muted); }
.byline strong { color: var(--text); }
.refs { font-size: .87rem; color: var(--text-muted); }
.refs li { margin-bottom: .35rem; }

/* ---------- related grid / home grid ---------- */
.tool-grid {
  display: grid; gap: .9rem; margin: 1.25rem 0;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.tool-card {
  display: block; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem;
  color: var(--text);
}
.tool-card {
  box-shadow: inset 0 1px 0 var(--hilite), 0 2px 0 var(--edge), 0 3px 8px rgba(0,0,0,.06);
  transition: transform .08s ease, box-shadow .08s ease;
}
.tool-card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: inset 0 1px 0 var(--hilite), 0 4px 0 var(--edge), 0 8px 18px rgba(0,0,0,.1);
}
.tool-card .t-icon { font-size: 1.4rem; margin-bottom: .35rem; }
.tool-card h3 { margin: 0 0 .25rem; font-size: 1.02rem; }
.tool-card p { margin: 0; font-size: .85rem; color: var(--text-muted); }
.tool-card.soon { opacity: .55; pointer-events: none; }
.tool-card.soon h3::after { content: " · soon"; font-size: .75rem; color: var(--text-muted); font-weight: 500; }

/* ---------- hero (home) ---------- */
.hero { text-align: center; padding: 3rem 0 1.5rem; }
.hero h1 { font-size: clamp(1.9rem, 5vw, 2.75rem); margin: 0 0 .75rem; }
.hero p { color: var(--text-muted); max-width: 40rem; margin: 0 auto; font-size: 1.1rem; }

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  margin-top: 3rem;
  font-size: .88rem; color: var(--text-muted);
}
.site-footer .wrap {
  padding: 1.5rem 1.25rem;
  display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: center;
}
.site-footer a { color: var(--text-muted); text-decoration: none; margin-right: 1rem; }
.site-footer a:hover { color: var(--brand); }

/* ---------- legal pages ---------- */
.prose { max-width: 44rem; }
.prose h2 { font-size: 1.25rem; }

@media print {
  .site-header, .site-footer, .ad-slot, .actions, .tabs, .crumbs { display: none !important; }
  body { background: #fff; color: #000; }
}
