/* Smart Living Web design system
   Mobile-first, system fonts only (no network font requests), light + dark. */

:root {
  --bg: #ffffff;
  --bg-soft: #f4f7fa;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --text: #101a24;
  --text-muted: #53626f;
  --border: #dfe6ee;
  --border-strong: #c6d2de;
  --accent: #0a5fb4;
  --accent-soft: #e8f1fb;
  --accent-2: #0a7a68;
  --accent-2-soft: #e2f4f0;
  --warn: #9a5b00;
  --warn-soft: #fdf2e0;
  --danger: #a32f2a;
  --shadow: 0 1px 2px rgba(16, 26, 36, .06), 0 6px 20px rgba(16, 26, 36, .06);
  --radius: 12px;
  --radius-sm: 8px;
  --measure: 70ch;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e151d;
    --bg-soft: #121b24;
    --surface: #141e28;
    --surface-2: #18242f;
    --text: #e8eef4;
    --text-muted: #a2b1c0;
    --border: #24323f;
    --border-strong: #35485a;
    --accent: #6fb4ff;
    --accent-soft: #14263a;
    --accent-2: #57d2ba;
    --accent-2-soft: #102b28;
    --warn: #eab464;
    --warn-soft: #2b2313;
    --danger: #ef8b84;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

:root[data-theme="dark"] {
  --bg: #0e151d;
  --bg-soft: #121b24;
  --surface: #141e28;
  --surface-2: #18242f;
  --text: #e8eef4;
  --text-muted: #a2b1c0;
  --border: #24323f;
  --border-strong: #35485a;
  --accent: #6fb4ff;
  --accent-soft: #14263a;
  --accent-2: #57d2ba;
  --accent-2-soft: #102b28;
  --warn: #eab464;
  --warn-soft: #2b2313;
  --danger: #ef8b84;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 1.15rem; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: #fff; padding: .7rem 1rem; border-radius: 0 0 var(--radius-sm) 0;
}
.skip:focus { left: 0; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .16em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: .75rem; min-height: 60px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--text); text-decoration: none; font-size: 1.06rem; margin-right: auto; }
.brand-mark { color: var(--accent); display: inline-flex; }
.brand-text b { font-weight: 700; letter-spacing: -.01em; }
.brand-text { font-weight: 400; letter-spacing: -.01em; }

.nav-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 38px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); cursor: pointer;
}
.nav-toggle-bar, .nav-toggle-bar::before, .nav-toggle-bar::after {
  display: block; width: 18px; height: 2px; background: currentColor; border-radius: 2px; position: relative;
}
.nav-toggle-bar::before { content: ""; position: absolute; top: -6px; }
.nav-toggle-bar::after { content: ""; position: absolute; top: 6px; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar::before { top: 0; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar::after { top: 0; transform: rotate(-45deg); }

.site-nav { display: none; width: 100%; padding-bottom: .85rem; }
.site-nav.open { display: block; }
.site-nav ul { list-style: none; margin: 0 0 .7rem; padding: 0; display: flex; flex-wrap: wrap; gap: .2rem .35rem; }
.site-nav a {
  display: block; padding: .5rem .6rem; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-weight: 550; font-size: .96rem;
}
.site-nav a:hover { background: var(--surface-2); }
.site-nav a[aria-current] { color: var(--accent); background: var(--accent-soft); }
.nav-search { display: flex; gap: .4rem; }
.nav-search input {
  flex: 1; min-width: 0; padding: .5rem .7rem; font: inherit; font-size: .94rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
}
.nav-search button, .theme-toggle {
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  border-radius: var(--radius-sm); padding: .45rem .6rem; cursor: pointer; display: inline-flex; align-items: center;
}
.theme-toggle { margin-top: .6rem; }

@media (min-width: 62rem) {
  .nav-toggle { display: none; }
  .site-nav { display: flex !important; align-items: center; gap: .6rem; width: auto; padding: 0; }
  .site-nav ul { margin: 0; flex-wrap: nowrap; }
  .nav-search { width: 190px; }
  .nav-search input { padding: .4rem .6rem; font-size: .88rem; }
  .theme-toggle { margin-top: 0; }
  .header-inner { flex-wrap: nowrap; }
}

/* ---------- breadcrumbs ---------- */
.breadcrumbs { border-bottom: 1px solid var(--border); background: var(--bg-soft); font-size: .85rem; }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .3rem; margin: 0; padding: .55rem 0; color: var(--text-muted); }
.breadcrumbs li + li::before { content: "/"; margin-right: .3rem; color: var(--border-strong); }
.breadcrumbs a { color: var(--text-muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- layout ---------- */
.layout { display: block; padding: 1.6rem 1.15rem 3.5rem; }
.content { max-width: var(--measure); }
.sidebar { margin-top: 3rem; }

@media (min-width: 62rem) {
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 3rem; align-items: start; }
  .layout-wide { grid-template-columns: minmax(0, 1fr); }
  .layout-wide .content { max-width: none; }
  .sidebar { position: sticky; top: 78px; margin-top: .5rem; font-size: .92rem; }
  .page-hub .content, .page-tool .content { max-width: none; }
  .page-hub .layout, .page-tool .layout { grid-template-columns: minmax(0, 1fr); }
  .page-hub .sidebar, .page-tool .sidebar { display: none; }
}

/* ---------- typography ---------- */
h1, h2, h3, h4 { line-height: 1.22; letter-spacing: -.018em; font-weight: 700; }
h1 { font-size: clamp(1.85rem, 5.2vw, 2.6rem); margin: 0 0 .5rem; }
h2 { font-size: clamp(1.35rem, 3.4vw, 1.62rem); margin: 2.4rem 0 .7rem; padding-top: .3rem; }
h3 { font-size: 1.16rem; margin: 1.8rem 0 .5rem; }
h4 { font-size: 1.02rem; margin: 1.4rem 0 .4rem; }
p { margin: 0 0 1.05rem; }
.lede { font-size: 1.16rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 1rem; }
.page-head { margin-bottom: 1.6rem; }
.byline { font-size: .82rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: .35rem .9rem; margin: .6rem 0 0; }
.byline-item { display: inline-flex; align-items: center; gap: .3rem; }
.byline-item + .byline-item::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: var(--border-strong); margin-right: .5rem; }
.hero-note { font-size: .9rem; color: var(--text-muted); border-left: 3px solid var(--border-strong); padding-left: .8rem; margin-top: 1rem; }

.anchor { opacity: 0; margin-left: .35rem; text-decoration: none; color: var(--border-strong); font-weight: 400; }
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }

ul, ol { margin: 0 0 1.15rem; padding-left: 1.3rem; }
li { margin-bottom: .45rem; }
li > ul, li > ol { margin-top: .45rem; }
strong { font-weight: 680; }
code { font-family: var(--mono); font-size: .89em; background: var(--surface-2); border: 1px solid var(--border); padding: .08em .32em; border-radius: 5px; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; overflow-x: auto; font-size: .88rem; }
pre code { background: none; border: 0; padding: 0; }
blockquote { margin: 1.4rem 0; padding: .1rem 0 .1rem 1.1rem; border-left: 3px solid var(--accent); color: var(--text-muted); font-style: normal; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2.4rem 0; }
abbr[title] { text-decoration: underline dotted; text-underline-offset: .2em; cursor: help; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 1.4rem 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
caption { text-align: left; padding: .8rem 1rem 0; color: var(--text-muted); font-size: .86rem; }
th, td { padding: .62rem .8rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
thead th { background: var(--surface-2); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); position: sticky; top: 0; }
tbody th { font-weight: 620; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }

/* ---------- callouts ---------- */
.callout {
  margin: 1.5rem 0; padding: .95rem 1.1rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface-2); border-left: 4px solid var(--border-strong);
}
.callout > :last-child { margin-bottom: 0; }
.callout-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; margin: 0 0 .4rem; color: var(--text-muted); }
.callout-tip { border-left-color: var(--accent-2); background: var(--accent-2-soft); }
.callout-tip .callout-label { color: var(--accent-2); }
.callout-warn { border-left-color: var(--warn); background: var(--warn-soft); }
.callout-warn .callout-label { color: var(--warn); }
.callout-note { border-left-color: var(--accent); background: var(--accent-soft); }
.callout-note .callout-label { color: var(--accent); }
.callout-key { border-left-color: var(--accent); background: var(--surface-2); }
.callout-check { border-left-color: var(--accent-2); }
.callout-source { border-left-color: var(--border-strong); font-size: .93rem; }

.verdict {
  margin: 0 0 1.8rem; padding: 1.1rem 1.2rem; border-radius: var(--radius);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}
.verdict-title { font-size: .78rem !important; text-transform: uppercase; letter-spacing: .08em; margin: 0 0 .5rem !important; color: var(--accent); padding: 0 !important; }
.verdict > :last-child { margin-bottom: 0; }
.verdict p { font-size: 1.04rem; }

/* ---------- toc ---------- */
.toc { margin: 0 0 2rem; padding: .9rem 1.1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.toc-title { font-size: .76rem !important; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin: 0 0 .5rem !important; padding: 0 !important; }
.toc ol { margin: 0; padding-left: 1.1rem; font-size: .94rem; }
.toc li { margin-bottom: .25rem; }
.toc a { text-decoration: none; }
.toc a:hover { text-decoration: underline; }

/* ---------- sidebar ---------- */
.aside-title { font-size: .76rem !important; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin: 0 0 .5rem !important; padding: 0 !important; }
.aside-hub { display: block; font-weight: 650; margin-bottom: .5rem; text-decoration: none; }
.aside-list { list-style: none; margin: 0 0 1.6rem; padding: 0; border-left: 2px solid var(--border); }
.aside-list li { margin: 0; }
.aside-list a { display: block; padding: .32rem .75rem; text-decoration: none; color: var(--text-muted); border-left: 2px solid transparent; margin-left: -2px; }
.aside-list a:hover { color: var(--accent); background: var(--surface-2); }
.aside-list a[aria-current] { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }

/* ---------- cards / grids ---------- */
.grid { display: grid; gap: 1rem; margin: 1.5rem 0; }
@media (min-width: 40rem) { .grid-2 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 64rem) { .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(4, 1fr); } }
.card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1.05rem 1.15rem;
  background: var(--surface); box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
.card-title { margin: 0 0 .45rem; font-size: 1.05rem; }
.card-title a { text-decoration: none; }
.card-title a:hover { text-decoration: underline; }
.card p { font-size: .95rem; color: var(--text-muted); }
.card ul { font-size: .95rem; }

/* ---------- steps ---------- */
.steps { list-style: none; padding: 0; counter-reset: step; margin: 1.6rem 0; }
.step { counter-increment: step; position: relative; padding: 0 0 1.2rem 2.6rem; border-left: 2px solid var(--border); margin-left: .9rem; }
.step:last-child { border-left-color: transparent; padding-bottom: 0; }
.step::before {
  content: counter(step); position: absolute; left: -1.05rem; top: -.15rem;
  width: 2rem; height: 2rem; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: .85rem; font-weight: 700;
}
.step-title { margin: .15rem 0 .5rem; font-size: 1.06rem; }

/* ---------- faq ---------- */
.faq { margin: 1.5rem 0; border-top: 1px solid var(--border); }
.faq-item { border-bottom: 1px solid var(--border); padding: 1rem 0; }
.faq-q { margin: 0 0 .45rem; font-size: 1.06rem; }
.faq-a > :last-child { margin-bottom: 0; }
.faq-a { color: var(--text); }

/* ---------- related / sources ---------- */
.related { margin: 3rem 0 0; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.related h2 { margin-top: 0; }
.rel-list { list-style: none; padding: 0; display: grid; gap: .7rem; }
@media (min-width: 44rem) { .rel-list { grid-template-columns: 1fr 1fr; } }
.rel-list a {
  display: block; padding: .8rem .95rem; border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; background: var(--surface); height: 100%;
}
.rel-list a:hover { border-color: var(--accent); }
.rel-title { display: block; font-weight: 640; color: var(--accent); margin-bottom: .2rem; }
.rel-desc { display: block; font-size: .88rem; color: var(--text-muted); line-height: 1.5; }

.sources { margin: 2.6rem 0 0; padding: 1.1rem 1.2rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); font-size: .92rem; }
.sources h2 { margin: 0 0 .4rem; font-size: 1rem !important; }
.sources-note { color: var(--text-muted); font-size: .87rem; }
.sources ul { margin-bottom: 0; }

/* ---------- home ---------- */
.hero { padding: 2.4rem 0 1.4rem; }
.hero h1 { font-size: clamp(2rem, 6.4vw, 3.1rem); max-width: 18ch; }
.hero p { font-size: 1.14rem; color: var(--text-muted); max-width: 62ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1.4rem; }
.btn {
  display: inline-flex; align-items: center; gap: .45rem; padding: .65rem 1.1rem; border-radius: 999px;
  background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; font-size: .96rem;
  border: 1px solid transparent;
}
.btn:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.section { margin: 3rem 0; }
.section-head { margin-bottom: 1.2rem; }
.section-head h2 { margin-top: 0; }
.section-head p { color: var(--text-muted); max-width: 66ch; }
.stat-row { display: grid; gap: .8rem; grid-template-columns: repeat(2, 1fr); margin: 1.6rem 0; }
@media (min-width: 52rem) { .stat-row { grid-template-columns: repeat(4, 1fr); } }
.stat { border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; background: var(--surface); }
.stat b { display: block; font-size: 1.5rem; letter-spacing: -.02em; line-height: 1.2; }
.stat span { font-size: .84rem; color: var(--text-muted); }

/* ---------- tools ---------- */
.tool { margin: 1.8rem 0; }
.tool-panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.tool-body { padding: 1.1rem 1.15rem; }
.field { margin-bottom: 1.1rem; }
.field > label, .field-label { display: block; font-weight: 620; margin-bottom: .4rem; font-size: .95rem; }
.field-help { font-size: .85rem; color: var(--text-muted); margin: -.2rem 0 .5rem; }
select, input[type="text"], input[type="number"], input[type="search"] {
  width: 100%; padding: .55rem .7rem; font: inherit; font-size: .95rem;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text);
}
.choices { display: flex; flex-wrap: wrap; gap: .5rem; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; width: 0; height: 0; }
.choice span {
  display: inline-block; padding: .45rem .8rem; border: 1px solid var(--border-strong); border-radius: 999px;
  font-size: .92rem; cursor: pointer; background: var(--surface-2);
}
.choice input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.choice input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.tool-result { border-top: 1px solid var(--border); background: var(--surface-2); padding: 1.1rem 1.15rem; }
.tool-result h3 { margin-top: 0; }
.tool-result > :last-child { margin-bottom: 0; }
.score-bar { height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; margin: .35rem 0 .6rem; }
.score-bar i { display: block; height: 100%; background: var(--accent-2); }
.pill { display: inline-block; font-size: .76rem; font-weight: 650; padding: .12rem .5rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-muted); }
.pill-yes { background: var(--accent-2-soft); border-color: var(--accent-2); color: var(--accent-2); }
.pill-no { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1rem; align-items: end; }
.filters .field { margin-bottom: 0; flex: 1 1 160px; }

/* ---------- search page ---------- */
.search-results { list-style: none; padding: 0; }
.search-results li { padding: .9rem 0; border-bottom: 1px solid var(--border); }
.search-results a { font-weight: 620; text-decoration: none; }
.search-results p { margin: .2rem 0 0; font-size: .92rem; color: var(--text-muted); }
.result-cluster { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }

/* ---------- figures ---------- */
figure { margin: 1.8rem 0; }
figure svg { max-width: 100%; height: auto; display: block; }
figcaption { font-size: .86rem; color: var(--text-muted); margin-top: .5rem; }
.diagram { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; background: var(--surface); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--bg-soft); padding: 2.4rem 0 2.6rem; margin-top: 2rem; font-size: .93rem; }
.footer-grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(2, 1fr); margin-bottom: 1.8rem; }
@media (min-width: 52rem) { .footer-grid { grid-template-columns: repeat(4, 1fr); } }
.footer-grid h2 { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin: 0 0 .6rem; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin-bottom: .35rem; }
.footer-grid a { color: var(--text); text-decoration: none; }
.footer-grid a:hover { color: var(--accent); text-decoration: underline; }
.footer-note, .footer-legal { color: var(--text-muted); font-size: .85rem; max-width: 90ch; }
.footer-legal a { color: var(--text-muted); }
