/* Water Size Guide - restrained water-themed design. System fonts, no external assets. */
:root {
  --bg: #f4f9fb; --surface: #ffffff; --surface-2: #eaf3f6; --text: #0e2430; --muted: #4a6270;
  --primary: #0a6a87; --primary-hover: #08566e; --on-primary: #ffffff; --accent: #0a747a;
  --border: #d2e2e8; --control-border: #6a8492; --good: #17754a; --warn: #8f5200; --bad: #b3261e;
  --good-bg: #e3f4ec; --warn-bg: #fff1d9; --bad-bg: #fbe5e3;
  --shadow: 0 1px 2px rgba(10, 50, 70, .06), 0 8px 24px rgba(10, 50, 70, .06);
  --radius: 16px; --gap: 1.25rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #08171e; --surface: #102631; --surface-2: #163341; --text: #e7f1f5; --muted: #a2bac4;
  --primary: #52c7e0; --primary-hover: #7ad6ea; --on-primary: #05222b; --accent: #38c2c8;
  --border: #25485a; --control-border: #5b8599; --good: #5fd39b; --warn: #f1b45a; --bad: #ff8d84;
  --good-bg: #123b2b; --warn-bg: #43330f; --bad-bg: #4a1f1c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); font-size: 1.0625rem; line-height: 1.65;
  color: var(--text); background: var(--bg);
}
img, svg { max-width: 100%; }
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 0; background: var(--primary); color: var(--on-primary); padding: .75rem 1rem; z-index: 100; }
.skip:focus, .skip:focus-visible { left: 0; }
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .75rem; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 6vw, 2.9rem); }
h2 { font-size: clamp(1.4rem, 4vw, 1.85rem); margin-top: 2.25rem; }
h3 { font-size: 1.2rem; margin-top: 1.5rem; }
p, ul, ol { margin: 0 0 1rem; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.lead { font-size: 1.2rem; color: var(--muted); max-width: 60ch; }

/* header + nav */
.site-header { position: sticky; top: 0; z-index: 50; background: var(--surface); border-bottom: 1px solid var(--border); }
.header-row { display: flex; align-items: center; gap: .75rem; min-height: 64px; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.2rem; color: var(--text); text-decoration: none; margin-right: auto; flex-shrink: 0; }
.brand span { white-space: nowrap; }
.brand svg { width: 28px; height: 28px; flex-shrink: 0; }
/* Mobile header: brand must never wrap or collide with the buttons (390px and below). */
@media (max-width: 899px) {
  .theme-btn span:last-child { display: none; } /* icon-only theme toggle on mobile; aria-label keeps the meaning */
  .theme-btn { padding: 0 .6rem; }
}
@media (max-width: 640px) {
  .brand { font-size: 1.05rem; gap: .45rem; }
  .brand svg { width: 24px; height: 24px; }
  .header-row { gap: .5rem; }
}
@media (max-width: 380px) {
  .brand { font-size: .95rem; }
}
.icon-btn {
  min-height: 44px; min-width: 44px; padding: 0 .9rem; border: 1.5px solid var(--control-border); border-radius: 12px;
  background: var(--surface); color: var(--text); font: inherit; font-size: .95rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
}
.icon-btn:hover { background: var(--surface-2); }
.nav { display: none; flex-direction: column; border-top: 1px solid var(--border); padding: .5rem 0 1rem; }
.nav.open { display: flex; }
.nav a { padding: .75rem .25rem; text-decoration: none; color: var(--text); font-weight: 500; border-radius: 8px; }
.nav a[aria-current="page"] { color: var(--primary); font-weight: 700; }
.nav a:hover { color: var(--primary); }
@media (min-width: 900px) {
  .nav-toggle { display: none; }
  .header-row { flex-wrap: nowrap; }
  .nav { display: flex; flex-direction: row; border: 0; padding: 0; gap: .25rem; order: 2; margin-left: auto; }
  .nav a { padding: .5rem .7rem; font-size: .98rem; }
  .brand { margin-right: 1rem; }
  .header-row .theme-btn { order: 3; }
}
.header-nav-wrap { width: 100%; }
@media (min-width: 900px) { .header-nav-wrap { width: auto; display: contents; } }

/* hero + sections */
.hero { padding: 2.5rem 0 2rem; background: linear-gradient(180deg, var(--surface-2), var(--bg)); border-bottom: 1px solid var(--border); }
.hero .container { display: grid; gap: 1.75rem; }
@media (min-width: 900px) { .hero .container { grid-template-columns: 1.15fr 1fr; align-items: center; } .hero { padding: 4rem 0 3rem; } }
.page-head { padding: 2rem 0 1rem; }
.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: .75rem; }
.crumbs a { color: var(--muted); }
section.block { padding: 1rem 0 .5rem; }
.grid { display: grid; gap: var(--gap); }
@media (min-width: 640px) { .grid.cols-2, .grid.cols-3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.4rem; box-shadow: var(--shadow);
}
.card h3, .card > h2:first-child { margin-top: 0; }
.h3 { font-size: 1.2rem; margin-top: 0; }
a.card { text-decoration: none; color: inherit; display: block; transition: transform .15s ease, border-color .15s ease; }
a.card:hover { transform: translateY(-2px); border-color: var(--primary); }
.card .tag { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }

/* The `hidden` attribute must win over component display rules (e.g. .btn
   sets display:inline-flex, which otherwise keeps "hidden" buttons visible
   and focusable — Back on step 1, Next on step 3). */
[hidden] { display: none !important; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 52px; padding: .7rem 1.4rem;
  border-radius: 14px; border: 2px solid var(--primary); background: var(--primary); color: var(--on-primary);
  font: inherit; font-weight: 650; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn.secondary { background: transparent; color: var(--primary); }
.btn.secondary:hover { background: var(--surface-2); color: var(--primary-hover); }
.btn-row { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1rem; }
.btn-row .btn { flex: 1 1 140px; }
@media (min-width: 640px) { .btn-row .btn { flex: 0 0 auto; } }

/* forms */
.field { margin-bottom: 1.4rem; }
fieldset.field { border: 0; margin: 0 0 1.4rem; padding: 0; }
fieldset.field legend { font-weight: 650; margin-bottom: .4rem; padding: 0; }
.field label, .field .label { display: block; font-weight: 650; margin-bottom: .4rem; }
.field .hint { display: block; font-size: .92rem; color: var(--muted); margin-top: .35rem; font-weight: 400; }
input[type="number"], input[type="text"], select {
  width: 100%; min-height: 54px; padding: .6rem .9rem; font: inherit; font-size: 1.15rem;
  color: var(--text); background: var(--surface); border: 2px solid var(--control-border); border-radius: 12px;
}
input:focus, select:focus { border-color: var(--primary); outline: 3px solid var(--accent); outline-offset: 2px; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--bad); }
.inline-fields { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 560px) { .inline-fields.two { grid-template-columns: 1fr 1fr; } }
.choice { display: flex; align-items: center; gap: .75rem; min-height: 48px; padding: .5rem .9rem; border: 2px solid var(--control-border); border-radius: 12px; cursor: pointer; background: var(--surface); margin-bottom: .6rem; }
.choice input { width: 22px; height: 22px; accent-color: var(--primary); flex: none; }
.choice:has(input:checked) { border-color: var(--primary); background: var(--surface-2); }
.choice:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.error { color: var(--bad); font-weight: 600; font-size: .95rem; }
details.adv { border: 1.5px dashed var(--control-border); border-radius: 12px; padding: .75rem 1rem; margin-bottom: 1.25rem; }
details.adv summary { cursor: pointer; font-weight: 600; min-height: 40px; display: flex; align-items: center; }
.fixture-row { display: grid; grid-template-columns: 1fr 96px; gap: .75rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.fixture-row .label { font-weight: 600; margin: 0; }
.fixture-row .hint { margin: 0; }

/* wizard */
.wizard-steps { display: flex; gap: .5rem; margin-bottom: 1.25rem; padding: 0; list-style: none; }
.wizard-steps li { flex: 1; text-align: center; font-size: .85rem; font-weight: 600; color: var(--muted); border-bottom: 4px solid var(--border); padding-bottom: .5rem; }
.wizard-steps li.active { color: var(--primary); border-color: var(--primary); }
.wizard-steps li.done { color: var(--good); border-color: var(--good); }
.wizard-steps .n { display: block; font-size: 1.1rem; }
.step[hidden] { display: none; }
.live-strip {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; align-items: center;
  background: var(--surface-2); border-radius: 12px; padding: .75rem 1rem; margin: 1rem 0 0; font-weight: 600;
}
.live-strip strong { color: var(--primary); font-size: 1.15rem; }

/* hardness scale */
.scale { margin: .5rem 0 0; }
.scale-bar { position: relative; display: flex; height: 14px; border-radius: 8px; overflow: hidden; }
.scale-bar span { flex: 1; }
.scale-bar .s1 { background: #bfe6f0; } .scale-bar .s2 { background: #86cfe0; } .scale-bar .s3 { background: #4eb3cb; }
.scale-bar .s4 { background: #2c8db0; } .scale-bar .s5 { background: #1b5f86; }
.scale-wrap { position: relative; }
.scale-marker { position: absolute; top: -6px; width: 4px; height: 26px; background: var(--text); border-radius: 2px; transform: translateX(-2px); transition: left .2s; }
.scale-labels { display: flex; font-size: .72rem; color: var(--muted); margin-top: .35rem; }
.scale-labels span { flex: 1; text-align: center; }
.badge { display: inline-block; padding: .15rem .65rem; border-radius: 999px; font-weight: 700; font-size: .85rem; background: var(--surface-2); color: var(--primary); }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.treatable { background: var(--warn-bg); color: var(--warn); }
.badge.test { background: var(--bad-bg); color: var(--bad); }

/* tabs (topic navigation) */
.tabs { margin: 1.5rem 0; }
.tab-list {
  display: flex; gap: .5rem; overflow-x: auto; padding: .25rem .1rem .75rem; scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem;
}
.tab-btn {
  flex: none; min-height: 46px; padding: .5rem 1.1rem; border-radius: 999px; border: 1.5px solid var(--control-border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; scroll-snap-align: start; white-space: nowrap;
}
.tab-btn:hover { border-color: var(--primary); }
.tab-btn[aria-selected="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.tab-panel[hidden] { display: none; }
.tab-panel > h2:first-child, .tab-panel > h3:first-child { margin-top: 0; }

/* results */
.results { margin-top: 1.5rem; }
.result-hero { text-align: center; padding: 1.75rem 1rem; border-radius: var(--radius); background: linear-gradient(160deg, var(--primary), var(--accent)); color: var(--on-primary); }
html[data-theme="dark"] .result-hero { color: #04202a; }
.result-hero .big { font-size: clamp(2.4rem, 11vw, 4rem); font-weight: 800; line-height: 1.05; }
.result-hero .sub { font-size: 1.05rem; opacity: 1; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin: 1rem 0; }
@media (min-width: 720px) { .stat-grid { grid-template-columns: repeat(3, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: .9rem 1rem; }
.stat .v { font-size: 1.5rem; font-weight: 750; line-height: 1.15; }
.stat .k { font-size: .85rem; color: var(--muted); }
.score-card { display: grid; gap: .5rem; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1rem 1.1rem; margin: 1rem 0; }
.score-top { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; }
.score-num { font-size: 2.4rem; font-weight: 800; line-height: 1; }
.meter { height: 12px; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--primary); border-radius: 8px; transition: width .3s; }
.meter.good > i { background: var(--good); } .meter.treatable > i { background: var(--warn); } .meter.test > i { background: var(--bad); }
.note { border-left: 4px solid var(--accent); background: var(--surface-2); padding: .85rem 1rem; border-radius: 0 12px 12px 0; margin: 1rem 0; }
.note.warn { border-color: var(--warn); background: var(--warn-bg); }
.note.bad { border-color: var(--bad); background: var(--bad-bg); }
.disclaimer { border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: .9rem 1rem; font-size: .95rem; color: var(--muted); margin: 1.25rem 0; }
.disclaimer strong { color: var(--text); }
.chain { list-style: none; padding: 0; counter-reset: step; }
.chain li { counter-increment: step; position: relative; padding: 1rem 1rem 1rem 3.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; margin-bottom: .75rem; }
.chain li::before { content: counter(step); position: absolute; left: 1rem; top: 1rem; width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 700; }
.chain li strong { display: block; }
.sources { font-size: .92rem; color: var(--muted); padding-left: 1.1rem; }
.src-inline { font-size: .85rem; color: var(--muted); }
.src-inline a { color: var(--muted); }
.math { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: .85rem 1rem; border-radius: 12px; overflow-x: auto; font-size: .95rem; line-height: 1.6; }
.prod-grid { display: grid; gap: .75rem; }
@media (min-width: 720px) { .prod-grid { grid-template-columns: 1fr 1fr; } }
.prod { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 1rem 1.1rem; }
.prod h4 { margin: 0 0 .35rem; font-size: 1.05rem; }
.prod dl { margin: 0; font-size: .92rem; display: grid; grid-template-columns: auto 1fr; gap: .15rem .75rem; }
.prod dt { color: var(--muted); } .prod dd { margin: 0; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: .7rem .9rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 700; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
@media (max-width: 719px) {
  table.stack thead { display: none; }
  table.stack tr { display: block; padding: .6rem .25rem; border-bottom: 2px solid var(--border); }
  table.stack td { display: grid; grid-template-columns: 9.5rem 1fr; gap: .5rem; border: 0; padding: .35rem .75rem; }
  table.stack td::before { content: attr(data-label); font-weight: 700; color: var(--muted); }
}
details.faq { border: 1.5px solid var(--control-border); border-radius: 14px; background: var(--surface); margin-bottom: .75rem; padding: 0 1.1rem; }
details.faq summary { cursor: pointer; font-weight: 650; min-height: 52px; display: flex; align-items: center; }
details.faq[open] { padding-bottom: .5rem; }

/* footer */
.site-footer { margin-top: 3.5rem; padding: 2.25rem 0 3rem; border-top: 1px solid var(--border); background: var(--surface); font-size: .95rem; color: var(--muted); }
.footer-grid { display: grid; gap: 1.5rem; }
@media (min-width: 720px) { .footer-grid { grid-template-columns: 2fr 1fr 1fr; } }
.site-footer a { color: var(--muted); }
.site-footer ul { list-style: none; padding: 0; }
.site-footer li { margin-bottom: .45rem; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  a.card, .scale-marker, .meter > i { transition: none; }
}

@media print {
  .site-header, .site-footer, .tab-list, .wizard-controls, .no-print, .wizard-steps, .crumbs, .hero { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .step[hidden], .tab-panel[hidden] { display: none !important; }
  .card, .stat, .score-card { box-shadow: none; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
