/* Pool Dose Calculator: design system */
:root {
  --bg: #f4f8fb;
  --surface: #ffffff;
  --surface-2: #eef5f9;
  --text: #0f2233;
  --muted: #557086;
  --border: #d9e5ee;
  --brand: #0b6e99;
  --brand-dark: #08506f;
  --aqua: #15b0d4;
  --aqua-soft: #e3f6fb;
  --ok: #1a9e6a;
  --warn: #d98a04;
  --bad: #d0453b;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 34, 51, .05), 0 8px 24px rgba(15, 34, 51, .06);
  --max: 1080px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1620;
    --surface: #10202d;
    --surface-2: #142838;
    --text: #e6f0f6;
    --muted: #93aec1;
    --border: #22394b;
    --brand: #3fb6e0;
    --brand-dark: #2b9cc6;
    --aqua: #3fc7e6;
    --aqua-soft: #12313f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.65; font-size: 16.5px; }
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--brand-dark); }
img, svg { max-width: 100%; }
.container { max-width: var(--max); margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; backdrop-filter: saturate(1.5) blur(8px); }
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.12rem; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.logo svg { width: 32px; height: 32px; flex: none; }
.logo span { color: var(--brand); }
.nav { display: flex; gap: 22px; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: .95rem; }
.nav a:hover, .nav a[aria-current] { color: var(--brand); }
@media (max-width: 720px) { .nav { gap: 14px; } .nav .hide-sm { display: none; } }

/* Hero */
.hero { background: linear-gradient(160deg, #0b6e99 0%, #15b0d4 100%); color: #fff; padding: 56px 0 72px; position: relative; overflow: hidden; }
.hero h1 { font-size: clamp(1.9rem, 5vw, 2.9rem); line-height: 1.12; margin: 0 0 14px; letter-spacing: -.02em; max-width: 680px; }
.hero p { font-size: 1.12rem; max-width: 620px; margin: 0 0 24px; opacity: .93; }
.hero .waves { position: absolute; left: 0; right: 0; bottom: -2px; width: 100%; height: 60px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.btn-light { background: #fff; color: #08506f; }
.btn-ghost { background: rgba(255, 255, 255, .15); color: #fff; border: 1px solid rgba(255, 255, 255, .4); }

/* Page head */
.page-head { padding: 28px 0 6px; }
.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--muted); }
h1 { font-size: clamp(1.7rem, 4.2vw, 2.3rem); line-height: 1.18; margin: 0 0 10px; letter-spacing: -.02em; }
h2 { font-size: 1.4rem; line-height: 1.3; margin: 40px 0 12px; letter-spacing: -.01em; }
h3 { font-size: 1.1rem; margin: 24px 0 6px; }
.lead { color: var(--muted); font-size: 1.1rem; margin: 0; max-width: 760px; }
.prose > p, .prose > ul, .prose > ol, .prose > h2, .prose > h3, .prose > .note { max-width: 760px; }
.prose li { margin-bottom: 6px; }

/* Cards and tools */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.tool-card { display: flex; gap: 14px; align-items: flex-start; text-decoration: none; color: var(--text); transition: transform .12s, border-color .12s; }
.tool-card:hover { transform: translateY(-2px); border-color: var(--aqua); color: var(--text); }
.tool-card h3 { margin: 0 0 4px; font-size: 1.04rem; }
.tool-card p { margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.5; }
.icon { width: 44px; height: 44px; border-radius: 12px; background: var(--aqua-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.icon svg { width: 24px; height: 24px; }

/* Calculator layout */
.calc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; margin: 24px 0; align-items: start; }
@media (max-width: 820px) { .calc { grid-template-columns: 1fr; } }
.field { margin-bottom: 16px; }
.field label, .label { display: block; font-weight: 600; font-size: .94rem; margin-bottom: 6px; }
.field input, .field select {
  width: 100%; padding: 11px 13px; font: inherit; font-size: 1rem; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 10px; appearance: none;
}
.field select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.field input:focus, .field select:focus { outline: none; border-color: var(--aqua); box-shadow: 0 0 0 3px var(--aqua-soft); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: .83rem; color: var(--muted); margin-top: 5px; line-height: 1.45; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; font: inherit; font-weight: 700; font-size: .98rem; border: 0; border-radius: 10px; cursor: pointer; text-decoration: none; background: var(--brand); color: #fff; }
.btn:hover { background: var(--brand-dark); color: #fff; }
.btn-block { width: 100%; }
.btn-soft { background: var(--aqua-soft); color: var(--brand); }
.btn-soft:hover { background: var(--aqua-soft); color: var(--brand-dark); }

/* Segmented control */
.segmented { display: flex; background: var(--surface-2); border-radius: 10px; padding: 4px; gap: 4px; }
.segmented label { flex: 1; margin: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.segmented input:focus-visible + span { outline: 2px solid var(--brand); }
.segmented span { display: block; text-align: center; padding: 8px 6px; border-radius: 8px; font-weight: 600; font-size: .9rem; cursor: pointer; color: var(--muted); }
.segmented input:checked + span { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }

/* Results */
.result-main { background: linear-gradient(160deg, var(--aqua-soft), transparent); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 14px; }
.result-main .label { color: var(--muted); font-weight: 600; font-size: .88rem; margin: 0; }
.result-main .value { font-size: 2.1rem; font-weight: 800; color: var(--brand); line-height: 1.2; letter-spacing: -.02em; }
.result-main .sub { color: var(--muted); font-size: .92rem; }
.result-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: .96rem; }
.result-row:last-child { border-bottom: 0; }
.result-row strong { text-align: right; }
.steps { margin: 14px 0 0; padding-left: 20px; }
.steps li { margin-bottom: 6px; }

/* Gauge */
.gauge { margin: 14px 0 6px; }
.gauge-head { display: flex; justify-content: space-between; font-size: .86rem; color: var(--muted); margin-bottom: 6px; }
.gauge-head b { color: var(--text); }
.gauge-bar { position: relative; height: 12px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.gauge-zone { position: absolute; top: 0; bottom: 0; }
.gauge-zone.low { background: rgba(217, 138, 4, .35); }
.gauge-zone.ok { background: rgba(26, 158, 106, .45); }
.gauge-zone.high { background: rgba(208, 69, 59, .35); }
.gauge-marker { position: absolute; top: -4px; width: 4px; height: 20px; margin-left: -2px; border-radius: 4px; background: var(--text); box-shadow: 0 0 0 2px var(--surface); }
.gauge-wrap { position: relative; }
.gauge-scale { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-top: 4px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .78rem; font-weight: 700; }
.badge.ok { background: rgba(26, 158, 106, .15); color: var(--ok); }
.badge.low { background: rgba(217, 138, 4, .15); color: var(--warn); }
.badge.high { background: rgba(208, 69, 59, .15); color: var(--bad); }

/* Notes and tables */
.note { font-size: .9rem; color: var(--muted); background: var(--surface-2); border-left: 3px solid var(--aqua); padding: 12px 14px; border-radius: 0 10px 10px 0; }
.safety { font-size: .9rem; background: rgba(217, 138, 4, .1); border: 1px solid rgba(217, 138, 4, .35); border-radius: 12px; padding: 12px 14px; margin: 18px 0; }
.safety strong { color: var(--warn); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .94rem; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
th { background: var(--surface-2); font-weight: 700; }
td.num, th.num { text-align: right; white-space: nowrap; }
details { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; margin-bottom: 10px; }
summary { font-weight: 700; cursor: pointer; }
details p { margin: 10px 0 0; }

/* My pool bar */
.mypool { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; font-size: .92rem; margin-top: 16px; }
.mypool .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.mypool button { margin-left: auto; }
.btn-sm { padding: 7px 12px; font-size: .86rem; }

/* Footer */
.site-footer { margin-top: 64px; padding: 36px 0; background: var(--surface); border-top: 1px solid var(--border); color: var(--muted); font-size: .9rem; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; }
@media (max-width: 720px) { .footer-grid { grid-template-columns: 1fr; } }
.site-footer h4 { color: var(--text); margin: 0 0 8px; font-size: .95rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 6px; }
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--brand); }

/* Ads: hidden while empty */
.ad-slot { margin: 28px 0; min-height: 100px; }
.ad-slot:empty { display: none; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
