/* Ridgeline Field Check
   Layout: one phone-width column, sticky brand bar, fixed bottom tab bar.
   Brand from ridgelinesafetysolutions.com: warm off-white ground, tan accent, Archivo and IBM Plex Mono. */

@font-face { font-family: "Archivo"; src: url("/fonts/archivo-wght.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/plex-mono-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/fonts/plex-mono-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }

:root {
  --bg: #FAF7F1; --surface: #FFFFFF; --sunk: #F2EDE3; --ink: #1C1917; --muted: #736C64; --line: #E3DDD2;
  --tan: #C8AD86; --tan-hover: #B3986B; --tan-ink: #1C1917; --tan-text: #7A6040; --tan-soft: #F3EADC;
  --noted: #43606E; --noted-bg: #E6EDF0; --opp: #8A5A0B; --opp-bg: #F6EBD3; --review: #A3261D; --review-bg: #F8E2DF;
  --chart-a: #A8875A; --chart-b: #43606E; --grid: #ECE6DA; --scrim: rgba(28, 25, 23, .5);
  --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141210; --surface: #1C1A17; --sunk: #25221E; --ink: #EEE8DC; --muted: #A69E92; --line: #37322B;
    --tan: #C8AD86; --tan-hover: #D5C1A3; --tan-ink: #1C1917; --tan-text: #D5C1A3; --tan-soft: #3A3226;
    --noted: #A3BBC8; --noted-bg: #1F2A30; --opp: #E3B25C; --opp-bg: #33281A; --review: #F08A80; --review-bg: #3A1E1B;
    --chart-a: #C8AD86; --chart-b: #A3BBC8; --grid: #2C2823; --scrim: rgba(0, 0, 0, .62);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15.5px; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-top: 0; padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--tan-text); outline-offset: 2px; }
textarea:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--tan); outline-offset: -1px; border-color: var(--tan); }
#flow > *, #recent { scroll-margin-top: calc(env(safe-area-inset-top, 0px) + 72px); }
a { color: var(--tan-text); }
.app { max-width: 640px; margin: 0 auto; }

/* Brand bar */
.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 6; background: var(--bg); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 12px 10px; border-bottom: 1px solid var(--line); margin-top: env(safe-area-inset-top, 0px); }
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.brand img { width: 30px; height: 30px; flex: none; }
.word { font-weight: 800; font-size: 17px; letter-spacing: .12em; text-transform: uppercase; line-height: 1; }
.sub { font-size: 13px; color: var(--muted); white-space: nowrap; }
@media (max-width: 370px) { .sub { display: none; } }
.bar-right { display: flex; align-items: center; gap: 8px; }
.pill { font-family: var(--mono); font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; border: 1px solid var(--line); color: var(--muted); padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.iconbtn { width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; background: none; border: 1px solid transparent; border-radius: 6px; cursor: pointer; color: var(--ink); }
.iconbtn:hover { border-color: var(--line); }

/* Type */
h1 { font-weight: 800; font-size: 34px; line-height: 1.04; letter-spacing: -.02em; margin: 22px 0 6px; text-wrap: balance; }
h2 { font-weight: 750; font-size: 20px; line-height: 1.15; letter-spacing: -.01em; margin: 0; text-wrap: balance; }
h3 { font-size: 15.5px; font-weight: 650; margin: 0; line-height: 1.35; }
.lede { color: var(--muted); margin: 0 0 16px; max-width: 54ch; }
.label { display: block; font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.label.flush { margin: 0; }
.small { font-size: 13.5px; color: var(--muted); }
p { margin: 0; }

/* Surfaces */
.view { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }

/* Inputs */
textarea, select, input[type="text"], input[type="number"], input[type="email"], input[type="tel"] {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 11px 12px; font-size: 16px;
}
textarea { resize: vertical; min-height: 88px; line-height: 1.45; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 380px) { .row2 { grid-template-columns: 1fr; } .row3 { grid-template-columns: 1fr 1fr; } }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 650; font-size: 15.5px; padding: 12px 16px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; text-align: center; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--tan); border-color: var(--tan); color: var(--tan-ink); }
.btn.primary:hover { background: var(--tan-hover); border-color: var(--tan-hover); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small { font-size: 14px; padding: 8px 12px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--review); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.msg { font-size: 14px; color: var(--review); }
.ok { font-size: 14.5px; color: var(--noted); font-weight: 600; }

/* Install banner */
.install { display: flex; align-items: center; gap: 12px; background: var(--tan-soft); border-radius: 8px; padding: 12px 14px; margin-top: 14px; }
.install img { width: 40px; height: 40px; border-radius: 9px; flex: none; }
.install div { flex: 1; min-width: 0; font-size: 14px; }
.install b { display: block; font-weight: 650; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 9px 13px; border-radius: 999px; font-size: 14.5px; cursor: pointer; line-height: 1.2; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip:disabled { cursor: default; }
.chip:disabled:not([aria-pressed="true"]) { opacity: .5; }
.ex-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 480px) { .ex-grid { grid-template-columns: 1fr; } }
.ex-chip { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 10px 12px; cursor: pointer; text-align: left; min-width: 0; }
.ex-chip:hover { border-color: var(--muted); }
.ex-chip b { font-weight: 650; font-size: 14.5px; }
.ex-chip span { font-size: 12.5px; color: var(--muted); }

/* Questions */
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
legend { font-weight: 650; padding: 0; margin-bottom: 8px; }
.qlist { display: flex; flex-direction: column; gap: 18px; }

/* Thinking */
.thinking { flex-direction: row; align-items: center; justify-content: space-between; }
.dots { display: inline-flex; gap: 5px; margin-right: 10px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--tan); opacity: .35; animation: pulse 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; opacity: .8; } }

/* Result */
.result { padding: 0; gap: 0; overflow: hidden; }
.tierband { display: flex; align-items: center; gap: 9px; padding: 11px 16px; font-weight: 800; font-size: 15px; letter-spacing: .06em; text-transform: uppercase; line-height: 1.2; }
.tierband svg { flex: none; }
.result.noted .tierband { background: var(--noted-bg); color: var(--noted); }
.result.opp .tierband { background: var(--opp-bg); color: var(--opp); }
.result.review .tierband { background: var(--review-bg); color: var(--review); }
.result-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.checks { list-style: none; margin: 0; padding: 0; }
.checks li { border-top: 1px solid var(--line); padding: 12px 0; display: flex; flex-direction: column; gap: 4px; }
.checks li:last-child { padding-bottom: 2px; }
.ref { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.hr-note { background: var(--sunk); border-radius: 6px; padding: 10px 12px; font-size: 14px; }
.who { font-size: 14.5px; }
.who b { font-weight: 650; }
.disclaimer { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }
.meta { font-family: var(--mono); font-size: 11.5px; color: var(--muted); letter-spacing: .02em; }

/* Lists */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; }
.rowbtn { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; padding: 11px 0; text-align: left; cursor: pointer; min-width: 0; }
.rowbtn .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.rowbtn .c { font-size: 12px; color: var(--muted); white-space: nowrap; }
.shape-noted { color: var(--noted); } .shape-opp { color: var(--opp); } .shape-review { color: var(--review); }

/* Track */
.example-flag { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--tan-text); background: var(--tan-soft); padding: 4px 9px; border-radius: 4px; align-self: flex-start; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .v { font-family: var(--mono); font-weight: 600; font-size: 26px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .k { font-size: 13.5px; font-weight: 650; }
.kpi .f { font-size: 12px; color: var(--muted); }
.chart { width: 100%; display: block; }
.chart text { font-family: var(--mono); }
.c-grid { stroke: var(--grid); stroke-width: 1; }
.c-axis { stroke: var(--line); stroke-width: 1; }
.c-tick { fill: var(--muted); font-size: 11px; }
.c-note { fill: var(--muted); font-size: 11px; font-weight: 600; }
.c-shade { fill: var(--sunk); }
.c-bar { fill: var(--chart-a); }
.c-line { fill: none; stroke: var(--chart-b); stroke-width: 2.25; stroke-linejoin: round; }
.c-pt { fill: var(--surface); stroke: var(--chart-b); stroke-width: 2; }
.c-pt.end { fill: var(--chart-b); }
.c-endlab { fill: var(--chart-b); font-size: 12px; font-weight: 600; }
.c-curve { fill: none; stroke: var(--muted); stroke-width: 1.75; }
.c-opt { stroke: var(--tan-text); stroke-width: 1.5; stroke-dasharray: 4 4; }
.c-optlab { fill: var(--tan-text); font-size: 12px; font-weight: 600; }
.c-dot { stroke: var(--surface); stroke-width: 1.5; }
.c-dot.under { fill: var(--chart-a); }
.c-dot.over { fill: var(--chart-b); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sw.a { background: var(--chart-a); } .sw.b { background: var(--chart-b); }
.sw.line { height: 3px; width: 14px; border-radius: 2px; background: var(--chart-b); }
.sw.round { border-radius: 50%; }
.slider { display: flex; flex-direction: column; gap: 6px; }
.slider-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.slider output { font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; }
input[type="range"] { width: 100%; accent-color: var(--tan-hover); }
.insight { background: var(--sunk); border-radius: 6px; padding: 12px 14px; font-size: 14.5px; }
.insight b { font-weight: 650; }
.counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.count { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--line); border-radius: 6px; padding: 10px; }
.count .n { font-family: var(--mono); font-weight: 600; font-size: 22px; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 7px; }
.count .l { font-size: 12px; color: var(--muted); }
.empty { font-size: 14px; color: var(--muted); }
.calc-out { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.calc-out div { display: flex; flex-direction: column; }
.calc-out .v { font-family: var(--mono); font-weight: 600; font-size: 22px; font-variant-numeric: tabular-nums; }
#summaryText { font-size: 15px; max-width: 62ch; }
.summary-src { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

/* Improve */
.disclose { background: var(--sunk); border-radius: 8px; padding: 12px 14px; font-size: 14px; }
.imp { gap: 8px; }
.imp .from { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag { font-size: 12px; font-weight: 650; padding: 3px 8px; border-radius: 4px; background: var(--sunk); color: var(--ink); line-height: 1.3; }
.tag.spec { background: var(--noted-bg); color: var(--noted); }
.tag.rl { background: var(--tan-soft); color: var(--tan-text); }
.tag.impact { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.cta-card { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.cta-card .small { color: var(--bg); opacity: .78; }
.cta-card .btn.primary { align-self: flex-start; }

/* Tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.tabs-in { max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); }
.tab { position: relative; background: none; border: 0; padding: 10px 0 9px; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; }
.tab[aria-current="page"] { color: var(--ink); }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: -1px; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--tan); }
.badge { position: absolute; top: 5px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--tan); color: var(--tan-ink); font-size: 11px; font-family: var(--mono); display: flex; align-items: center; justify-content: center; letter-spacing: 0; }

/* Sheets */
.scrim { position: fixed; inset: 0; z-index: 40; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; max-height: calc(100% - env(safe-area-inset-top, 0px) - 24px); overflow-y: auto; overscroll-behavior: contain; background: var(--surface); border-radius: 12px 12px 0 0; padding-top: 18px; padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); padding-left: max(18px, env(safe-area-inset-left, 0px)); padding-right: max(18px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 14px; }
.sheet form { display: flex; flex-direction: column; gap: 12px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.direct { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 14.5px; }
.direct a { font-weight: 600; }
.prose { display: flex; flex-direction: column; gap: 10px; font-size: 14.5px; }
.prose h3 { margin-top: 6px; }
.prose ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.confirm-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* First run */
.gate { position: fixed; inset: 0; z-index: 30; background: var(--bg); overflow-y: auto; padding-top: calc(env(safe-area-inset-top, 0px) + 28px); padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 28px); padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); }
.gate-in { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.gate-in img { width: 56px; height: 56px; border-radius: 12px; }
.gate h1 { margin: 0; }
.points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.points li { display: grid; grid-template-columns: 14px 1fr; gap: 12px; align-items: start; }
.points .n { width: 10px; height: 10px; margin-top: 7px; border-radius: 2px; background: var(--tan); }
.points b { display: block; font-weight: 650; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--tan-hover); flex: none; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--tan-text); text-decoration: underline; cursor: pointer; font-size: inherit; }
