@layer reset, base, layout, components, utilities;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  body, h1, h2, h3, p, ul, ol, figure { margin: 0; }
  img, svg { display: block; max-width: 100%; }
  button, select { font: inherit; }
}

@layer base {
  :root {
    color-scheme: light dark;
    --paper: #f5f1e8;
    --paper-strong: #fffdf8;
    --ink: #1f2925;
    --ink-soft: #51605a;
    --line: #d7cfc0;
    --oak: #b47a49;
    --oak-dark: #865533;
    --clay: #b95843;
    --sage: #60786b;
    --sage-soft: #dce5df;
    --shadow: 0 16px 40px rgba(43, 52, 47, .09);
    --radius: 18px;
    --max: 1180px;
  }
  :root[data-theme="dark"] {
    --paper: #151b18;
    --paper-strong: #202824;
    --ink: #f6f0e5;
    --ink-soft: #bdc8c1;
    --line: #3a4540;
    --oak: #d39a68;
    --oak-dark: #efb884;
    --clay: #e27c66;
    --sage: #9db7a8;
    --sage-soft: #293a32;
    --shadow: 0 16px 42px rgba(0, 0, 0, .28);
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --paper: #151b18;
      --paper-strong: #202824;
      --ink: #f6f0e5;
      --ink-soft: #bdc8c1;
      --line: #3a4540;
      --oak: #d39a68;
      --oak-dark: #efb884;
      --clay: #e27c66;
      --sage: #9db7a8;
      --sage-soft: #293a32;
      --shadow: 0 16px 42px rgba(0, 0, 0, .28);
    }
  }
  body {
    min-width: 320px;
    background: var(--paper);
    color: var(--ink);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 17px;
    line-height: 1.65;
    text-rendering: optimizeLegibility;
  }
  h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; line-height: 1.12; text-wrap: balance; }
  h1 { font-size: clamp(2.35rem, 5.8vw, 5.15rem); letter-spacing: -.045em; }
  h2 { font-size: clamp(1.75rem, 3.2vw, 2.75rem); letter-spacing: -.025em; }
  h3 { font-size: clamp(1.25rem, 2vw, 1.55rem); }
  a { color: var(--oak-dark); text-underline-offset: .2em; }
  a:hover { color: var(--clay); }
  p, li { max-width: 74ch; }
  :focus-visible { outline: 3px solid var(--clay); outline-offset: 3px; }
}

@layer layout {
  .wrap { width: min(calc(100% - 36px), var(--max)); margin-inline: auto; }
  .section { padding: clamp(58px, 8vw, 104px) 0; }
  .section--tight { padding: clamp(38px, 5vw, 68px) 0; }
  .section-head { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 38%); align-items: end; gap: 32px; margin-bottom: 34px; }
  .section-head p { color: var(--ink-soft); }
  .content-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(260px, .6fr); gap: clamp(30px, 6vw, 74px); align-items: start; }
  .article-flow { display: grid; gap: 24px; }
  .article-flow > h2 { margin-top: 42px; }
  .article-flow > h3 { margin-top: 20px; }
  .article-flow ul, .article-flow ol { display: grid; gap: 10px; padding-left: 1.3em; }
}

@layer components {
  .affiliate-strip { padding: 8px 18px; background: var(--ink); color: var(--paper); font-size: .78rem; text-align: center; letter-spacing: .025em; }
  .site-header { position: relative; z-index: 20; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(14px); }
  .header-inner { min-height: 76px; display: flex; align-items: center; gap: 22px; }
  .brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-family: Georgia, serif; font-weight: 700; line-height: 1; white-space: nowrap; }
  .brand img { width: 42px; height: 42px; }
  .brand span { display: grid; }
  .brand small { margin-top: 4px; color: var(--ink-soft); font-family: "Segoe UI", sans-serif; font-size: .66rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; }
  .site-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
  .site-nav a { padding: 9px 10px; border-radius: 999px; color: var(--ink); text-decoration: none; font-size: .84rem; font-weight: 650; white-space: nowrap; }
  .site-nav a:hover, .site-nav a[aria-current="page"] { background: var(--sage-soft); color: var(--ink); }
  .theme-toggle, .nav-toggle { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; background: var(--paper-strong); color: var(--ink); cursor: pointer; }
  .nav-toggle { display: none; }

  .breadcrumbs { padding-top: 22px; color: var(--ink-soft); font-size: .84rem; }
  .breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 7px; padding: 0; list-style: none; }
  .breadcrumbs li:not(:last-child)::after { content: "/"; margin-left: 7px; color: var(--line); }

  .hero-wc { padding: clamp(42px, 7vw, 88px) 0 clamp(58px, 8vw, 104px); }
  .hero-grid { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(340px, .88fr); gap: clamp(38px, 7vw, 88px); align-items: center; }
  .eyebrow { display: inline-flex; align-items: center; gap: 9px; color: var(--clay); font-size: .78rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
  .eyebrow::before { content: ""; width: 34px; border-top: 2px solid currentColor; }
  .hero-copy h1 { margin: 16px 0 22px; max-width: 14ch; }
  .hero-copy > p { max-width: 59ch; color: var(--ink-soft); font-size: clamp(1.04rem, 2vw, 1.25rem); }
  .hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
  .trust-row { display: flex; flex-wrap: wrap; gap: 10px 20px; margin-top: 26px; color: var(--ink-soft); font-size: .82rem; }
  .trust-row span::before { content: "✓"; margin-right: 7px; color: var(--sage); font-weight: 900; }

  .space-planner { position: relative; min-height: 430px; padding: 30px; border: 1px solid var(--line); border-radius: 34px 34px 12px 12px; background: var(--paper-strong); box-shadow: var(--shadow); overflow: hidden; }
  .space-planner::after { content: ""; position: absolute; inset: auto 0 0; height: 34%; background: linear-gradient(90deg, color-mix(in srgb, var(--oak) 15%, transparent) 1px, transparent 1px), linear-gradient(color-mix(in srgb, var(--oak) 15%, transparent) 1px, transparent 1px); background-size: 28px 28px; pointer-events: none; }
  .planner-label { position: relative; z-index: 2; color: var(--ink-soft); font-size: .76rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
  .cabinet-sketch { position: relative; z-index: 2; width: 66%; height: 142px; margin: 30px auto 20px; border: 4px solid var(--oak); border-radius: 8px; background: var(--paper); box-shadow: inset 0 0 0 7px color-mix(in srgb, var(--oak) 12%, transparent); }
  .cabinet-sketch::before { content: ""; position: absolute; inset: 0 50% 0 auto; border-left: 2px solid var(--oak); }
  .cabinet-sketch::after { content: "•   •"; position: absolute; inset: 48% 0 auto; color: var(--oak); text-align: center; letter-spacing: 16px; transform: translateY(-50%); }
  .toilet-sketch { position: relative; z-index: 2; width: 46%; height: 77px; margin: 35px auto 0; border: 4px solid var(--sage); border-radius: 8px 8px 40px 40px; }
  .toilet-sketch::before { content: ""; position: absolute; left: 50%; bottom: -38px; width: 65%; height: 40px; border: 4px solid var(--sage); border-top: 0; border-radius: 0 0 22px 22px; transform: translateX(-50%); }
  .measure-x, .measure-y { position: absolute; z-index: 3; color: var(--clay); font-size: .75rem; font-weight: 750; }
  .measure-x { left: 17%; right: 17%; top: 198px; border-top: 1px dashed var(--clay); text-align: center; }
  .measure-y { top: 90px; right: 18px; bottom: 80px; border-left: 1px dashed var(--clay); writing-mode: vertical-rl; text-align: center; }
  .planner-note { position: absolute; z-index: 4; left: 24px; bottom: 20px; max-width: 22ch; padding: 9px 12px; border-radius: 10px; background: var(--ink); color: var(--paper); font-size: .78rem; line-height: 1.35; }

  .button { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 11px 18px; border: 1px solid var(--ink); border-radius: 10px; background: var(--ink); color: var(--paper); text-decoration: none; font-weight: 760; line-height: 1.2; transition: transform .2s ease, background .2s ease; }
  .button:hover { background: var(--clay); border-color: var(--clay); color: #fff; transform: translateY(-2px); }
  .button--secondary { background: transparent; color: var(--ink); }
  .button--amazon { background: #ffb22e; border-color: #d68500; color: #1e1a13; }
  .button--amazon:hover { background: #f19d13; border-color: #c77900; color: #17120c; }

  .choice-rail { border-block: 1px solid var(--line); background: var(--paper-strong); }
  .choice-list { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .choice-link { min-height: 108px; padding: 18px; border-right: 1px solid var(--line); color: var(--ink); text-decoration: none; display: grid; align-content: center; gap: 5px; }
  .choice-link:first-child { border-left: 1px solid var(--line); }
  .choice-link strong { font-family: Georgia, serif; font-size: 1.04rem; }
  .choice-link span { color: var(--ink-soft); font-size: .76rem; }
  .choice-link:hover { background: var(--sage-soft); color: var(--ink); }

  .filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 24px 0 30px; }
  .filter-bar button, .filter-bar select { min-height: 42px; padding: 8px 13px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper-strong); color: var(--ink); }
  .filter-bar button { cursor: pointer; }
  .filter-bar button[aria-pressed="true"] { border-color: var(--sage); background: var(--sage); color: #fff; }
  .result-count { margin-left: auto; color: var(--ink-soft); font-size: .84rem; font-weight: 700; }

  .comparison-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-strong); box-shadow: var(--shadow); }
  .comparison-table { width: 100%; min-width: 850px; border-collapse: collapse; }
  .comparison-table th, .comparison-table td { padding: 15px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
  .comparison-table th { background: var(--ink); color: var(--paper); font-size: .76rem; letter-spacing: .06em; text-transform: uppercase; }
  .comparison-table td { font-size: .9rem; }
  .comparison-table tr:last-child td { border-bottom: 0; }
  .comparison-table img { width: 72px; height: 72px; object-fit: contain; border-radius: 8px; background: #fff; }

  .product-grid { display: grid; gap: 20px; }
  .product-sheet { display: grid; grid-template-columns: 230px minmax(0, 1fr) 190px; min-height: 290px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-strong); overflow: hidden; box-shadow: 0 6px 24px rgba(43, 52, 47, .05); }
  .product-media { display: grid; place-items: center; min-height: 270px; padding: 22px; background: #fff; }
  .product-media img { width: 100%; height: 220px; object-fit: contain; }
  .product-copy { padding: 26px 28px; display: grid; align-content: center; gap: 14px; }
  .product-index { color: var(--clay); font-size: .72rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
  .product-copy h3 { max-width: 30ch; }
  .product-copy p { color: var(--ink-soft); font-size: .93rem; }
  .product-points { display: flex; flex-wrap: wrap; gap: 7px; padding: 0; list-style: none; }
  .product-points li { padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-soft); font-size: .74rem; }
  .product-action { padding: 24px; border-left: 1px solid var(--line); display: grid; align-content: center; gap: 13px; background: color-mix(in srgb, var(--sage-soft) 55%, var(--paper-strong)); }
  .rating { font-weight: 800; }
  .rating span { display: block; color: var(--ink-soft); font-size: .75rem; font-weight: 500; }
  .availability-note { color: var(--ink-soft); font-size: .72rem; line-height: 1.4; }

  .decision-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
  .decision-card { padding: 24px; border-top: 4px solid var(--oak); background: var(--paper-strong); box-shadow: var(--shadow); }
  .decision-card:nth-child(2) { border-color: var(--sage); }
  .decision-card:nth-child(3) { border-color: var(--clay); }
  .decision-card h3 { margin-bottom: 10px; }
  .decision-card p { color: var(--ink-soft); font-size: .92rem; }

  .measure-panel { position: sticky; top: 24px; padding: 25px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--ink); color: var(--paper); }
  .measure-panel h2 { font-size: 1.55rem; margin-bottom: 16px; }
  .measure-panel ol { padding-left: 1.3em; display: grid; gap: 13px; }
  .measure-panel li { font-size: .9rem; }

  .note-box { padding: 22px 24px; border-left: 5px solid var(--clay); background: var(--paper-strong); }
  .note-box strong { display: block; margin-bottom: 5px; }
  .method-box { padding: clamp(24px, 4vw, 42px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--sage-soft); }
  .method-box h2 { margin-bottom: 18px; }

  .faq-list { display: grid; gap: 12px; }
  .faq-list details { padding: 18px 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-strong); }
  .faq-list summary { cursor: pointer; font-weight: 750; }
  .faq-list p { margin-top: 12px; color: var(--ink-soft); }

  .site-footer { margin-top: 64px; padding: 48px 0 26px; background: var(--ink); color: var(--paper); }
  .footer-grid { display: grid; grid-template-columns: 1.2fr .8fr .8fr; gap: 42px; }
  .site-footer .brand { color: var(--paper); }
  .site-footer .brand small, .site-footer p { color: color-mix(in srgb, var(--paper) 72%, transparent); }
  .site-footer p { margin-top: 16px; font-size: .86rem; }
  .footer-links { display: grid; align-content: start; gap: 9px; }
  .footer-links strong { margin-bottom: 4px; font-family: Georgia, serif; }
  .footer-links a { color: var(--paper); text-decoration-color: color-mix(in srgb, var(--paper) 35%, transparent); }
  .footer-bottom { margin-top: 38px; padding-top: 20px; border-top: 1px solid color-mix(in srgb, var(--paper) 18%, transparent); color: color-mix(in srgb, var(--paper) 65%, transparent); font-size: .75rem; }

  .skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 10px 14px; background: var(--clay); color: #fff; transform: translateY(-150%); }
  .skip-link:focus { transform: none; }
}

@layer utilities {
  .muted { color: var(--ink-soft); }
  .kicker { color: var(--clay); font-size: .76rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
  .visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
}

@media (max-width: 1080px) {
  .nav-toggle { display: inline-grid; place-items: center; margin-left: auto; }
  .site-nav { display: none; position: absolute; top: 76px; left: 18px; right: 18px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper-strong); box-shadow: var(--shadow); }
  .site-nav.is-open { display: grid; }
  .site-nav a { border-radius: 8px; }
  .hero-grid { grid-template-columns: 1fr .78fr; gap: 34px; }
  .choice-list { grid-template-columns: repeat(3, 1fr); }
  .choice-link:nth-child(3n) { border-right: 1px solid var(--line); }
  .product-sheet { grid-template-columns: 190px minmax(0, 1fr); }
  .product-action { grid-column: 1 / -1; border-top: 1px solid var(--line); border-left: 0; display: flex; align-items: center; justify-content: space-between; }
}

@media (max-width: 760px) {
  body { font-size: 16px; }
  .wrap { width: min(calc(100% - 28px), var(--max)); }
  .brand > span { font-size: .92rem; }
  .hero-grid, .section-head, .content-grid, .footer-grid { grid-template-columns: 1fr; }
  .hero-copy h1 { max-width: 12ch; }
  .space-planner { min-height: 390px; }
  .choice-list { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; }
  .choice-link { flex: 0 0 185px; border-left: 0; scroll-snap-align: start; }
  .decision-cards { grid-template-columns: 1fr; }
  .product-sheet { grid-template-columns: 1fr; }
  .product-media { min-height: 240px; }
  .product-media img { height: 210px; }
  .product-copy { padding: 22px; }
  .product-action { display: grid; padding: 20px 22px; }
  .product-action .button { width: 100%; }
  .filter-bar { align-items: stretch; }
  .filter-bar select { width: 100%; }
  .result-count { width: 100%; margin-left: 0; }
  .measure-panel { position: static; }
}

@media (max-width: 430px) {
  h1 { font-size: clamp(2.2rem, 13vw, 3.15rem); }
  .affiliate-strip { font-size: .7rem; }
  .header-inner { min-height: 68px; }
  .brand img { width: 36px; height: 36px; }
  .theme-toggle, .nav-toggle { width: 38px; height: 38px; }
  .site-nav { top: 68px; }
  .space-planner { min-height: 350px; padding: 22px; }
  .cabinet-sketch { width: 74%; height: 118px; }
  .measure-x { top: 170px; }
  .measure-y { top: 68px; bottom: 70px; }
  .hero-actions .button { width: 100%; }
  .comparison-wrap { margin-inline: -14px; border-radius: 0; }
}
