:root {
  --ink: #1a1a1a;
  --muted: #666;
  --line: #e0e0e0;
  --accent: #2b5d8c;
  --bg-soft: #f7f7f8;
  --good: #0a7a33;
  --warn-bg: #fff7e6;
  --warn-line: #e6c37a;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--ink);
  line-height: 1.5;
  background: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

.site-header { border-bottom: 1px solid var(--line); }
.site-header .wrap {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: 10px;
  padding-top: 16px; padding-bottom: 16px;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 1.15rem; color: var(--ink);
  text-decoration: none; white-space: nowrap;
}
.brand-logo { height: 32px; width: auto; display: block; }
.site-header nav a { margin-left: 20px; color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.site-header nav a:hover { color: var(--accent); }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}
.nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--ink);
  border-radius: 1px;
}
.nav-toggle:hover { border: none; }

main { padding: 24px 0 32px; }

.lede { color: var(--muted); max-width: 760px; }

/* Stepper */
.stepper { display: flex; gap: 8px; margin: 20px 0 24px; flex-wrap: wrap; }
.step-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font-size: 0.92rem; background: #fff;
}
.step-pill .num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg-soft); border: 1px solid var(--line);
  font-size: 0.8rem; font-weight: 600;
}
.step-pill.active { border-color: var(--accent); color: var(--accent); }
.step-pill.active .num { background: var(--accent); border-color: var(--accent); color: #fff; }
.step-pill.done { color: var(--good); }
.step-pill.done .num { background: var(--good); border-color: var(--good); color: #fff; }
.step-pill.clickable { cursor: pointer; }

section.step { display: none; }
section.step.visible { display: block; }

h2 { font-size: 1.25rem; margin: 2.5rem 0 8px; }
section.step h2 { margin: 8px 0 4px; }
.hint { color: var(--muted); font-size: 0.93rem; margin: 2px 0 14px; }

/* Banners */
.banner {
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  background: var(--bg-soft); border-radius: var(--radius);
  padding: 12px 16px; margin: 14px 0; font-size: 0.95rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between;
}
.banner .actions { display: flex; gap: 8px; }
.banner.warn { border-left-color: var(--warn-line); background: var(--warn-bg); }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 44px 20px; text-align: center; color: var(--muted);
  background: var(--bg-soft); cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.dropzone.dragover { border-color: var(--accent); background: #eef4fa; }
.dropzone strong { color: var(--ink); }
.dropzone .sub { font-size: 0.9rem; margin-top: 6px; }

/* Buttons */
button, .btn {
  font: inherit; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; color: var(--ink); padding: 8px 16px;
}
button:hover, .btn:hover { border-color: var(--accent); color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #234c73; color: #fff; }
button.quiet { border-color: transparent; color: var(--muted); }
button.quiet:hover { color: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-row { display: flex; gap: 10px; margin: 18px 0; flex-wrap: wrap; align-items: center; }
.btn-row .spacer { flex: 1; }

/* Tables */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: var(--bg-soft); font-weight: 600; position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Mapping controls */
.map-grid { display: grid; grid-template-columns: 1fr; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.field label { font-size: 0.88rem; font-weight: 600; }
.field .note { font-size: 0.83rem; color: var(--muted); font-weight: 400; }
select, input[type="text"], input[type="number"] {
  font: inherit; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; color: var(--ink); max-width: 320px;
}
input.price-val { max-width: 110px; padding: 4px 8px; font-size: 0.88rem; }
.radio-row { display: flex; gap: 18px; flex-wrap: wrap; margin: 6px 0; }
.radio-row label { font-weight: 400; display: flex; gap: 6px; align-items: baseline; font-size: 0.95rem; }
.radio-row .note { display: block; font-size: 0.83rem; color: var(--muted); }

.controls-box {
  padding: 14px 18px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-soft); margin-bottom: 18px;
}
.controls-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 12px; gap: 12px;
}
.controls-title {
  font-size: 0.78rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--muted);
}
.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px 24px;
  align-items: start;
}
.controls-grid .field { margin: 0; }
.controls-grid select, .controls-grid input[type="text"], .controls-grid input[type="number"] {
  background: #fff; width: 100%; max-width: 100%;
}
.controls-grid .note { line-height: 1.35; }
.check-label {
  display: flex; gap: 7px; align-items: center;
  font-size: 0.88rem; font-weight: 600; cursor: pointer;
  min-height: 33px;
}

/* Results */
.result-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 16px 0; }
.card {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; background: #fff;
}
.card .label { font-size: 0.82rem; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.card .value { font-size: 1.3rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card .value sub { font-size: 0.75em; }
.card .sub { font-size: 0.82rem; color: var(--muted); }
.card .stats {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 0.88rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

#chart { width: 100%; min-height: 460px; margin: 8px 0 4px; }

details.advanced { margin: 14px 0; }
details.advanced summary { cursor: pointer; color: var(--muted); font-size: 0.93rem; }
details.advanced .inner { padding: 10px 0 0 6px; }

/* Clean & recode step */
.derived-item {
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg-soft); padding: 8px 12px; margin: 6px 0;
  font-size: 0.92rem;
}
.derived-item button { margin-left: 8px; padding: 2px 8px; font-size: 0.85rem; }
.filter-values { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 8px 0; font-size: 0.92rem; }
.filter-values label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
#derive-rules textarea {
  width: 100%; max-width: 480px; font: inherit; padding: 8px;
  border: 1px solid var(--line); border-radius: 6px;
}
#derive-rules .table-scroll { max-height: 280px; overflow-y: auto; max-width: 480px; }

/* Individual responses (raster) */
#raster-wrap { margin: 6px 0 4px; }
#raster { display: block; }
#bp-dist { min-height: 320px; margin-top: 18px; }

.saved-note { font-size: 0.83rem; color: var(--muted); }
.saved-note.flash { color: var(--good); }

.warn-list { color: #8a6100; font-size: 0.88rem; margin: 8px 0; }

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}
.site-footer .wrap { padding: 20px; }
.site-footer a { color: var(--accent); }

h3 { font-size: 1.05rem; margin: 22px 0 6px; }
section.step h3 { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 24px; }

/* Org card (shared with HPT Resource Index) */
.org-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--bg-soft);
  max-width: 65ch;
}
.org-logo {
  max-width: 180px;
  width: 100%;
  height: auto;
  display: block;
  margin-bottom: 16px;
}

/* Citation page */
h1 { font-size: 1.8rem; margin-bottom: 8px; }

/* Methods page */
.equation {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 16px 0;
  max-width: 65ch;
  text-align: center;
  font-size: 1.15rem;
}
.param-group {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 22px 0 0;
}
.param-list { max-width: 65ch; margin: 6px 0 14px; }
.param-list dt {
  font-weight: 600;
  margin-top: 12px;
}
.param-list dd {
  margin: 2px 0 0 0;
  color: var(--muted);
}
.page-methods p, .page-methods ul { max-width: 72ch; }
p.reference {
  padding-left: 2em;
  text-indent: -2em;
  max-width: 72ch;
}
.citation-block {
  border-left: 3px solid var(--accent);
  background: var(--bg-soft);
  padding: 14px 18px;
  margin: 0 0 12px;
  max-width: 65ch;
  font-size: 0.95rem;
}
.cta {
  display: inline-block;
  margin-top: 8px;
  padding: 10px 16px;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 0.95rem;
}
.cta:hover { background: #234c73; color: #fff; }
.copy-feedback {
  margin-left: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 640px) {
  .stepper { gap: 6px; }
  .step-pill { padding: 6px 10px; font-size: 0.85rem; }
  .brand-logo { height: 22px; }
  .brand { font-size: 0.95rem; }

  .nav-toggle { display: flex; }

  .site-header nav {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 2px;
  }
  .site-header nav.nav-open { display: flex; }
  .site-header nav a {
    margin-left: 0;
    padding: 10px 0;
    border-top: 1px solid var(--line);
  }
}
