/*
 * Shared styles for the calculator site (mobile-first, no build step).
 *
 * Header and footer markup comes from scripts/partials/. Edit those files and
 * run `node scripts/sync-layout.js` to copy them into every page.
 *
 * Design: system fonts (no web-font download, no layout shift), a teal brand
 * colour, one accent colour per category (--cat), soft layered shadows and
 * rounded cards. Theme follows the system preference until the visitor chooses one.
 */

:root {
  color-scheme: light;
  --primary: #176b62;
  --primary-dark: #10564f;
  --primary-strong: #124f49;
  --primary-soft: #e7f2ef;
  --grad-a: #176b62;
  --grad-b: #287d74;
  --on-primary: #ffffff;
  --accent: #b45309;
  --bg: #f6f7f5;
  --card-bg: #ffffff;
  --surface-2: #f0f2ef;
  --input-bg: #fbfcfd;
  --text: #1b2928;
  --text-muted: #5c6b68;
  --border: #e1e7e3;
  --input-border: #64748b; /* 3:1+ against card (WCAG 1.4.11) */
  --result-bg: #effaf8;
  --result-border: #a7e3da;
  --focus: #1d4ed8;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgb(25 45 39 / 0.035), 0 8px 24px -14px rgb(25 45 39 / 0.2);
  --shadow-hover: 0 5px 18px -10px rgb(25 45 39 / 0.24), 0 1px 3px rgb(25 45 39 / 0.06);
  --header-bg: rgb(255 255 255 / 0.82);
  --footer-bg: #eef1ee;
  --glow: rgb(15 118 110 / 0.12);
  --space: 1rem;
  --touch: 44px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* One colour per category: --c-* draws icons and borders, --c-*-soft fills tiles */
  --c-math: #6d28d9;    --c-math-soft: #f1ebff;
  --c-time: #b45309;    --c-time-soft: #fff3dc;
  --c-finance: #047857; --c-finance-soft: #e0f7ec;
  --c-health: #be123c;  --c-health-soft: #ffe9ee;
  --c-conv: #0369a1;    --c-conv-soft: #e3f3fd;
  --c-work: #4338ca;    --c-work-soft: #e9ecff;
  --c-home: #4d7c0f;    --c-home-soft: #eef7dc;
  --c-school: #c2410c;  --c-school-soft: #fff0e5;
  --cat: var(--primary);
  --cat-soft: var(--primary-soft);
}

html[data-theme="dark"] {
    color-scheme: dark;
    --primary: #5eead4;
    --primary-dark: #99f6e4;
    --primary-strong: #8ef3e1;
    --primary-soft: rgb(94 234 212 / 0.12);
    --grad-a: #5eead4;
    --grad-b: #67e8f9;
    --on-primary: #052422;
    --accent: #fbbf24;
    --bg: #111815;
    --card-bg: #19231f;
    --surface-2: #202d27;
    --input-bg: #141e19;
    --text: #e8efeb;
    --text-muted: #b0beb7;
    --border: #304139;
    --input-border: #74867c;
    --result-bg: #18302a;
    --result-border: #346a5b;
    --focus: #93c5fd;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 10px 30px -12px rgb(0 0 0 / 0.6);
    --shadow-hover: 0 2px 4px rgb(0 0 0 / 0.35), 0 18px 36px -12px rgb(0 0 0 / 0.75);
    --header-bg: rgb(17 24 21 / 0.9);
    --footer-bg: #151f1a;
    --glow: rgb(94 234 212 / 0.10);

    --c-math: #c4b5fd;    --c-math-soft: rgb(196 181 253 / 0.14);
    --c-time: #fcd34d;    --c-time-soft: rgb(252 211 77 / 0.13);
    --c-finance: #6ee7b7; --c-finance-soft: rgb(110 231 183 / 0.13);
    --c-health: #fda4af;  --c-health-soft: rgb(253 164 175 / 0.13);
    --c-conv: #7dd3fc;    --c-conv-soft: rgb(125 211 252 / 0.13);
    --c-work: #a5b4fc;    --c-work-soft: rgb(165 180 252 / 0.14);
    --c-home: #bef264;    --c-home-soft: rgb(190 242 100 / 0.13);
    --c-school: #fdba74;  --c-school-soft: rgb(253 186 116 / 0.13);
}

/* Category colours: home cards and sections, hub pages (by canonical URL) and
 * tool pages (by the hub link in the breadcrumb). */
.cat-everyday-math, html:has(link[rel="canonical"][href$="/everyday-math/"]), html:has(.breadcrumb a[href="/everyday-math/"]) { --cat: var(--c-math); --cat-soft: var(--c-math-soft); }
.cat-time-date, html:has(link[rel="canonical"][href$="/time-date/"]), html:has(.breadcrumb a[href="/time-date/"]) { --cat: var(--c-time); --cat-soft: var(--c-time-soft); }
.cat-finance, html:has(link[rel="canonical"][href$="/finance/"]), html:has(.breadcrumb a[href="/finance/"]) { --cat: var(--c-finance); --cat-soft: var(--c-finance-soft); }
.cat-health, html:has(link[rel="canonical"][href$="/health/"]), html:has(.breadcrumb a[href="/health/"]) { --cat: var(--c-health); --cat-soft: var(--c-health-soft); }
.cat-conversions, html:has(link[rel="canonical"][href$="/conversions/"]), html:has(.breadcrumb a[href="/conversions/"]) { --cat: var(--c-conv); --cat-soft: var(--c-conv-soft); }
.cat-productivity, html:has(link[rel="canonical"][href$="/productivity/"]), html:has(.breadcrumb a[href="/productivity/"]) { --cat: var(--c-work); --cat-soft: var(--c-work-soft); }
.cat-home-diy, html:has(link[rel="canonical"][href$="/home-diy/"]), html:has(.breadcrumb a[href="/home-diy/"]) { --cat: var(--c-home); --cat-soft: var(--c-home-soft); }
.cat-school, html:has(link[rel="canonical"][href$="/school/"]), html:has(.breadcrumb a[href="/school/"]) { --cat: var(--c-school); --cat-soft: var(--c-school-soft); }

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5.5rem; }

body {
  font-family: Inter, "Aptos", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg);
  /* Soft glow at the top of every page, tinted by the page's category */
  background-image: radial-gradient(1100px 420px at 50% -160px, var(--glow), transparent 70%);
  background-repeat: no-repeat;
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
@supports (color: color-mix(in srgb, red 50%, blue)) {
  body { background-image: radial-gradient(1100px 420px at 50% -160px, color-mix(in srgb, var(--cat) 14%, transparent), transparent 70%); }
}

main { flex: 1 0 auto; }

h1 {
  font-size: clamp(1.9rem, 1.4rem + 2vw, 2.6rem);
  line-height: 1.15;
  font-weight: 760;
  letter-spacing: -0.04em;
  margin-bottom: 0.6rem;
}
h2 { font-size: 1.4rem; line-height: 1.3; font-weight: 720; letter-spacing: -0.025em; margin: 2rem 0 0.6rem; }
h3 { font-size: 1.1rem; font-weight: 700; margin: 1rem 0 0.35rem; }
p, ul, ol { margin-bottom: 1rem; }
ul, ol { padding-left: 1.25rem; }
li::marker { color: var(--text-muted); }

a { color: var(--primary); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--primary-dark); text-decoration-thickness: 2px; }

img, svg { max-width: 100%; height: auto; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection { background: var(--primary-soft); color: var(--text); }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--card-bg);
  color: var(--text);
  padding: 0.75rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0; }

.container {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  padding: 1rem;
}
.container.wide,
.site-header .container,
.site-footer .container { max-width: 1120px; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.75rem;
}

/* Calculator specific */
.calc-inputs {
  display: grid;
  gap: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
/* Two columns of fields on wider screens; anything that is not a single field
 * (fieldsets, toggles, rows) keeps the full width. */
@media (min-width: 640px) {
  .calc-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  /* Keep controls aligned across columns when one label wraps onto two lines. */
  .calc-inputs > .input-group > label:not(.check-label) { min-height: 3.3em; }
  .calc-inputs > :not(.input-group),
  .calc-inputs > fieldset,
  .calc-inputs > .input-group:has(.check-label, fieldset, textarea) { grid-column: 1 / -1; }
  .calc-inputs .gpa-earlier { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1.25rem; }
}

.input-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
}

.input-group input,
.input-group select {
  width: 100%;
  min-height: 48px;
  padding: 0.75rem 1rem;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  font-size: 1rem; /* 16px prevents iOS zoom on focus */
  font-family: inherit;
  background: var(--input-bg);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background-color 0.15s var(--ease);
}
.input-group input:hover,
.input-group select:hover { border-color: var(--text-muted); }
.input-group input:focus,
.input-group select:focus { border-color: var(--primary); background: var(--card-bg); box-shadow: 0 0 0 4px var(--primary-soft); }

.input-group .unit { color: var(--text-muted); font-size: 0.85rem; font-weight: 500; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.7rem 1.5rem;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  background-image: linear-gradient(135deg, var(--grad-a), var(--grad-b));
  color: var(--on-primary);
  font-size: 1rem;
  font-weight: 650;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 6px 16px -6px rgb(15 118 110 / 0.55);
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), filter 0.15s var(--ease);
}
.btn:hover { filter: brightness(1.06); box-shadow: 0 10px 22px -8px rgb(15 118 110 / 0.6); }
.btn:active { transform: translateY(1px); }

.result-box {
  position: relative;
  background: var(--result-bg);
  background-image: linear-gradient(160deg, var(--result-bg), var(--card-bg) 140%);
  border: 1px solid var(--result-border);
  border-radius: 16px;
  padding: 1.5rem 1.25rem;
  margin-top: 1.25rem;
  text-align: center;
  min-height: 7.75rem; /* reserve space so JS-rendered results shift less */
}

.result-box .value {
  font-size: clamp(1.75rem, 1.4rem + 1.4vw, 2.25rem);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--primary-strong);
  font-variant-numeric: tabular-nums;
}

.error-msg { color: var(--accent); font-weight: 600; margin-top: 0.5rem; }
.error-msg:empty { margin: 0; }

/* Related tools */
.related-tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.related-tools a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: var(--touch);
  padding: 0.8rem 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), border-color 0.15s var(--ease);
}
.related-tools a::after, .tool-grid a::after {
  content: "";
  flex-shrink: 0;
  width: 0.5rem;
  height: 0.5rem;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.45;
  transition: transform 0.15s var(--ease), opacity 0.15s var(--ease);
}

/* Homepage tool directory */
.tool-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
}

.tool-grid a,
.tool-grid .tool-soon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 52px;
  padding: 0.8rem 1.1rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), border-color 0.15s var(--ease);
}
.tool-grid .tool-soon { color: var(--text-muted); border-style: dashed; box-shadow: none; }

@media (hover: hover) {
  .tool-grid a:hover, .related-tools a:hover, .cat-card:hover {
    transform: translateY(-2px);
    border-color: var(--cat);
    box-shadow: var(--shadow-hover);
    color: var(--text);
  }
  .tool-grid a:hover::after, .related-tools a:hover::after { opacity: 1; transform: translateX(3px) rotate(45deg); color: var(--cat); }
}

.badge {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  white-space: nowrap;
}

.cluster-desc { color: var(--text-muted); }

/* ---- Home page hero and categories ---- */
.hero { text-align: center; max-width: 800px; margin: 2.6rem auto 3.5rem; }
.hero h1 { font-size: clamp(2.45rem, 1.5rem + 3.6vw, 4rem); letter-spacing: -0.05em; line-height: 1.08; }
.hero-lead { color: var(--text-muted); font-size: clamp(1rem, 0.96rem + 0.25vw, 1.12rem); max-width: 66ch; margin: 0 auto 1.8rem; line-height: 1.75; }
.eyebrow {
  display: inline-block;
  margin-bottom: 1.2rem;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--result-border);
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 0.78rem;
  letter-spacing: 0.025em;
  font-weight: 650;
}
.hero .tool-search { max-width: 600px; margin: 0 auto; text-align: left; }

.cat-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--cat-soft);
  color: var(--cat);
}
.cat-tile--sm { width: 36px; height: 36px; border-radius: 10px; }
.cat-tile--sm .cat-icon { width: 20px; height: 20px; }
.cat-tile--lg { width: 56px; height: 56px; border-radius: 16px; }
.cat-tile--lg .cat-icon { width: 28px; height: 28px; }
.cat-icon { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.categories h2 { margin-top: 0; }
.categories > h2 { margin-bottom: 1rem; font-size: 1.55rem; }
.cat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 1rem;
}
.cat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 100%;
  padding: 1.2rem 1.25rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), border-color 0.15s var(--ease);
}
.cat-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.cat-name { font-weight: 680; font-size: 1rem; letter-spacing: -0.015em; }
.cat-desc { color: var(--text-muted); font-size: 0.86rem; line-height: 1.5; }
.cat-count {
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 650;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
}

.cat-section { margin-top: 3.5rem; }
.cat-section h2 { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.4rem; }

/* Hub pages */
.hub-head { display: flex; align-items: center; gap: 1rem; margin: 0.25rem 0 0.6rem; }
.hub-head h1 { margin: 0; }
.wide > p, .wide > section > p { max-width: 75ch; }

/* Ad slots: reserve space to avoid layout shift. Place outside the calculator card.
 * Hidden until ads are live so visitors don't see empty gaps. WHEN ADSENSE IS
 * APPROVED: change "display: none" below to "display: block". */
.ad-slot {
  display: none;
  width: 100%;
  min-height: 250px;
  margin: 1.5rem 0;
  background: transparent;
  text-align: center;
  overflow: hidden;
}
.ad-slot--banner { min-height: 100px; }

/* Header & Footer */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .site-header { background: var(--header-bg); -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px); }
}

.site-header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 1rem;
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.site-name {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: var(--touch);
}
.site-name:hover { color: var(--text); }
.logo-mark { width: 30px; height: 30px; flex-shrink: 0; }
.logo-bg { fill: var(--primary); }
.logo-calc { fill: none; stroke: var(--on-primary); stroke-width: 1.8; }
.logo-display { fill: var(--on-primary); }
.logo-c { fill: none; stroke: var(--primary); stroke-width: 1.5; stroke-linecap: round; }
.logo-key { fill: var(--on-primary); }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  width: 100%;
  margin: 0;
  padding: 0.5rem 0 0.25rem;
}
.header-actions { display: flex; align-items: center; gap: 0.45rem; }
.nav-toggle, .theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}
.nav-toggle:hover, .theme-toggle:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-strong); }
.nav-toggle svg, .theme-icon { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav-toggle { display: none; }
.js .nav-toggle { display: inline-flex; }
.js .site-nav { display: none; }
.js .site-nav.is-open { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.site-nav a { white-space: nowrap; }
.theme-icon--sun { display: none; }
html[data-theme="dark"] .theme-icon--moon { display: none; }
html[data-theme="dark"] .theme-icon--sun { display: block; }
@media (min-width: 720px) {
  .site-header .container { flex-wrap: nowrap; gap: 0 0.75rem; }
  .header-actions { order: 3; }
  .js .nav-toggle { display: none; }
  .site-nav, .site-nav.is-open, .js .site-nav, .js .site-nav.is-open {
    display: flex;
    width: auto;
    margin: 0 auto 0 1rem;
    padding: 0;
    flex-wrap: wrap;
    justify-content: center;
  }
}
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  margin: 2px 0;
  padding: 0 0.8rem;
  border-radius: 999px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.site-nav a:hover { color: var(--text); background: var(--surface-2); }
/* Current category, from the hub page URL or the tool page breadcrumb (no JS needed) */
html:has(link[rel="canonical"][href$="/everyday-math/"]) .site-nav a[href="/everyday-math/"],
html:has(.breadcrumb a[href="/everyday-math/"]) .site-nav a[href="/everyday-math/"],
html:has(link[rel="canonical"][href$="/time-date/"]) .site-nav a[href="/time-date/"],
html:has(.breadcrumb a[href="/time-date/"]) .site-nav a[href="/time-date/"],
html:has(link[rel="canonical"][href$="/finance/"]) .site-nav a[href="/finance/"],
html:has(.breadcrumb a[href="/finance/"]) .site-nav a[href="/finance/"],
html:has(link[rel="canonical"][href$="/health/"]) .site-nav a[href="/health/"],
html:has(.breadcrumb a[href="/health/"]) .site-nav a[href="/health/"],
html:has(link[rel="canonical"][href$="/conversions/"]) .site-nav a[href="/conversions/"],
html:has(.breadcrumb a[href="/conversions/"]) .site-nav a[href="/conversions/"],
html:has(link[rel="canonical"][href$="/productivity/"]) .site-nav a[href="/productivity/"],
html:has(.breadcrumb a[href="/productivity/"]) .site-nav a[href="/productivity/"],
html:has(link[rel="canonical"][href$="/home-diy/"]) .site-nav a[href="/home-diy/"],
html:has(.breadcrumb a[href="/home-diy/"]) .site-nav a[href="/home-diy/"],
html:has(link[rel="canonical"][href$="/school/"]) .site-nav a[href="/school/"],
html:has(.breadcrumb a[href="/school/"]) .site-nav a[href="/school/"] { color: var(--primary-strong); background: var(--primary-soft); }

main.container { padding-top: 1.75rem; }
main.container.wide { padding-top: 1.25rem; }
main.reading-column { max-width: 760px; }

.hub-search { max-width: 560px; margin: 1.25rem 0 1.5rem; }
.hub-search label { display: block; margin-bottom: 0.4rem; color: var(--text-muted); font-size: 0.9rem; font-weight: 650; }
.hub-search input {
  width: 100%;
  min-height: 48px;
  padding: 0.7rem 1rem;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  color: var(--text);
  font: inherit;
}
.hub-search input:focus { border-color: var(--primary); outline: 3px solid var(--primary-soft); outline-offset: 1px; }
.hub-search-status { min-height: 1.5em; margin: 0.35rem 0 0; color: var(--text-muted); font-size: 0.88rem; }
.hub-empty { padding: 1rem; border: 1px dashed var(--border); border-radius: var(--radius-sm); color: var(--text-muted); }
.hub-tools > h2 { margin-top: 1.75rem; }
.hub-tools .tool-grid { gap: 0.85rem; }
.hub-tools .tool-grid a { min-height: 60px; padding: 0.9rem 1.1rem; border-radius: 14px; }
.cat-section { scroll-margin-top: 6.5rem; border-top: 1px solid var(--border); padding-top: 1.4rem; }
.cat-section .cluster-desc { max-width: 74ch; }
.tool-grid a, .cat-card, .related-tools a { box-shadow: 0 1px 2px rgb(25 45 39 / 0.035), 0 6px 18px -14px rgb(25 45 39 / 0.2); }

.site-footer {
  margin-top: 4rem;
  padding: 3rem 0 1.5rem;
  background: var(--footer-bg);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.92rem;
}
.footer-grid { display: grid; grid-template-columns: 1fr; gap: 1.75rem 2rem; }
.footer-brand p { max-width: 36ch; margin: 0.25rem 0 0; }
.footer-links { display: flex; flex-direction: column; align-items: flex-start; }
.footer-heading { margin: 0 0 0.35rem; color: var(--text); font-weight: 700; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; }
.site-footer .footer-links a { display: inline-flex; align-items: center; min-height: 36px; color: var(--text-muted); text-decoration: none; }
.site-footer .footer-links a:hover { color: var(--primary); text-decoration: underline; }
.footer-copy { grid-column: 1 / -1; margin: 0; padding-top: 1.25rem; border-top: 1px solid var(--border); font-size: 0.85rem; }
@media (min-width: 800px) {
  .footer-grid { grid-template-columns: minmax(220px, 1.4fr) minmax(300px, 2fr) minmax(150px, 0.8fr); }
  .footer-links--categories { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1rem; }
  .footer-links--categories .footer-heading { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

@media (min-width: 600px) {
  .tool-grid { grid-template-columns: repeat(2, 1fr); }
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 900px) {
  .container { padding: 1.5rem; }
  .site-header .container { padding-top: 0.5rem; padding-bottom: 0.5rem; }
  .wide .tool-grid, .cat-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Phase 2: Everyday Math */
.quick-tips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.quick-tips .btn { min-height: var(--touch); padding: 0.5rem 1rem; background: var(--surface-2); background-image: none; color: var(--text); border: 1px solid var(--border); box-shadow: none; font-weight: 600; }
.quick-tips .btn:hover { border-color: var(--primary); color: var(--primary-strong); background: var(--primary-soft); filter: none; }
.result-box .result-label, .result-box .result-detail { margin: 0.25rem 0 0; color: var(--text-muted); }
.calc-inputs [hidden] { display: none; }

/* Phase 2: Time & Date */
.input-group .check-label { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; min-height: var(--touch); }
.input-group .check-label input { width: 1.25rem; min-height: 0; height: 1.25rem; padding: 0; }
.result-box .time-list { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.result-box .time-list li { padding: 0.35rem 0; }
.result-box .time-list .value { font-size: 1.5rem; }
.result-box p { margin: 0.25rem 0; }

/* Phase 3: SEO content */
.breadcrumb {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
  overflow-wrap: anywhere;
}
.breadcrumb a {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch);
  padding: 0 0.1rem;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb [aria-current="page"] { color: var(--text); }

.faq h3 { font-size: 1.05rem; margin: 1.1rem 0 0.25rem; }
.faq h3:first-of-type { margin-top: 0.5rem; }

.formula {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1.1rem;
  margin: 0 0 1rem;
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---- Shared components for the Finance, Health, Conversions and Productivity clusters ---- */

/* Disclaimer note under results (finance and health pages) */
.disclaimer {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--accent);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.9rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.disclaimer p { margin: 0; }

/* Metric / imperial toggle */
.unit-toggle {
  border: 0;
  padding: 0;
  margin: 0 0 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.unit-toggle legend { font-weight: 600; margin-bottom: 0.35rem; width: 100%; }
.unit-toggle label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: var(--touch);
  padding: 0 0.9rem;
  border: 1px solid var(--input-border);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600; /* same weight checked or not, so switching units never shifts the row */
}
.unit-toggle input { width: 1.1rem; height: 1.1rem; margin: 0; }
.unit-toggle label { transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease); }
.unit-toggle label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-strong); }
.unit-toggle input { accent-color: var(--primary); }
[data-units][hidden] { display: none; }

/* Two inputs side by side (feet + inches, start + end) */
.input-pair { display: flex; gap: 0.5rem; }
.input-pair > * { flex: 1 1 0; min-width: 0; }

/* Data tables (amortization, conversion references) */
.table-wrap { overflow-x: auto; margin: 0.75rem 0 1rem; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { text-align: left; white-space: normal; min-width: 7rem; }
.data-table thead th { color: var(--text-muted); font-weight: 600; }
.data-table caption { text-align: left; font-weight: 600; padding-bottom: 0.35rem; }

details.more { margin-top: 1rem; }
details.more summary { cursor: pointer; font-weight: 600; min-height: var(--touch); display: flex; align-items: center; color: var(--primary); }
details.more summary:hover { color: var(--primary-dark); }

/* Inline SVG bar chart */
.chart-wrap { margin-top: 1rem; }
.chart { width: 100%; height: auto; display: block; }
.chart-a { fill: var(--primary); }
.chart-b { fill: var(--accent); }
.chart-label { fill: var(--text-muted); font-size: 14px; }
.chart-legend { list-style: none; padding: 0; margin: 0.5rem 0 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.9rem; color: var(--text-muted); }
.chart-legend .swatch { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 2px; margin-right: 0.35rem; vertical-align: -1px; }
.chart-legend .swatch.chart-a { background: var(--primary); }
.chart-legend .swatch.chart-b { background: var(--accent); }

/* Sources list on health pages */
.sources { font-size: 0.9rem; color: var(--text-muted); }
.sources li { margin-bottom: 0.35rem; }

/* Cluster hub intro */
.hub-intro { color: var(--text-muted); max-width: 60ch; }

/* Repeating row groups (billable hours days, project tasks) */
.day-row, .task-row { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.75rem; margin: 0 0 0.75rem; min-width: 0; }
.day-row legend, .task-row legend { font-weight: 600; padding: 0 0.25rem; }
.task-row .task-remove { margin-top: 0.5rem; min-height: var(--touch); background: transparent; background-image: none; border: 1px solid var(--input-border); color: var(--text); box-shadow: none; }
.task-row .task-remove:hover { border-color: var(--accent); color: var(--text); filter: none; }
.btn:disabled, .btn:disabled:hover { background: var(--border); background-image: none; box-shadow: none; filter: none; transform: none; color: var(--text-muted); cursor: not-allowed; } /* no opacity: keeps text at 4.5:1+ */
@media (max-width: 400px) {
  .card { padding: 1rem; }
  .day-row, .task-row { padding: 0.5rem 0.6rem 0.6rem; }
  .day-row .input-pair { flex-wrap: wrap; }
  .day-row .input-pair > * { flex-basis: 45%; }
}

/* Unstyled radio group (fieldset/legend for screen readers, same look as .input-group) */
.plain-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.plain-fieldset legend { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.35rem; padding: 0; }
.task-row > .input-group { margin-bottom: 0.5rem; }
.day-row input[type="time"] { padding-left: 0.5rem; padding-right: 0.4rem; }

/* ---- Shareable result links ---- */
.btn-secondary {
  background: transparent;
  background-image: none;
  color: var(--primary-strong);
  border: 1px solid var(--primary);
  box-shadow: none;
}
.btn-secondary:hover { background: var(--primary-soft); color: var(--primary-strong); box-shadow: none; filter: none; }
.share-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-top: 0.75rem;
}
.share-status { color: var(--text-muted); font-size: 0.9rem; flex: 1 1 12rem; }
.share-url {
  width: 100%;
  min-height: var(--touch);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--card-bg);
  color: var(--text);
}

/* ---- Home page tool search ---- */
.tool-search { margin: 1rem 0 0.5rem; }
.tool-search label { display: block; font-weight: 600; margin-bottom: 0.4rem; }
.search-field { position: relative; }
.search-icon { position: absolute; left: 1.1rem; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; fill: none; stroke: var(--text-muted); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.tool-search input {
  width: 100%;
  min-height: 56px;
  padding: 0.85rem 1.25rem 0.85rem 3rem;
  border: 1px solid var(--input-border);
  border-radius: 999px;
  font-size: 1.05rem;
  font-family: inherit;
  background: var(--card-bg);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.tool-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft), var(--shadow); }
.tool-search-status { color: var(--text-muted); font-size: 0.9rem; min-height: 1.5rem; margin: 0.35rem 0 0; }

/* ---- Print: keep the calculator and its result, drop site chrome ---- */
@media print {
  :root {
    --bg: #fff; --card-bg: #fff; --text: #000; --text-muted: #333;
    --primary: #000; --border: #999; --result-bg: #fff; --result-border: #999;
  }
  body { background-image: none; }
  .site-header, .site-footer, .skip-link, .breadcrumb, .ad-slot, .share-row,
  .calc-form-actions, button, .btn, noscript, .tool-search, .related-tools,
  section[aria-labelledby="related-h"] { display: none !important; }
  body { font-size: 11pt; }
  .card { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
  .result-box { break-inside: avoid; }
  a { color: #000; text-decoration: none; }
  main.container { max-width: none; padding: 0; }
  table { break-inside: auto; }
  tr { break-inside: avoid; }
}

/* ---- GPA calculator: grade + credits side by side ---- */
.course-row { display: grid; grid-template-columns: 3fr 2fr; gap: 0.75rem; }
.gpa-earlier { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.75rem 1rem 1rem; display: grid; gap: 0.75rem; }
.gpa-earlier legend { font-weight: 600; padding: 0 0.35rem; }
.time-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
#calc-form > .quick-tips { margin: 0 0 1rem; }

/* Reserve room for the "Copy link" row that utils.js adds under the result,
 * so the content below does not shift when it appears (48px button + gap). */
#calc-form:not([data-share="off"]):not(:has(.share-row)) .result-box { margin-bottom: calc(48px + 0.75rem); }
/* The row stops the next block's 1rem top margin from collapsing into this one */
#calc-form:not([data-share="off"]):not(:has(.share-row)) .result-box:has(+ .disclaimer, + .chart-wrap, + details.more) { margin-bottom: calc(48px + 1.75rem); }
/* Each result line takes its height before the calculator script fills it in. */
.result-box .result-label { min-height: 1.6em; }

/* Reserved result heights. The calculators fill the result box after the page
 * first paints, so each tool page reserves the height its default result takes
 * (rb-m* below 640px, rb-d* from 640px up). This keeps layout shift at zero
 * now that the two-column form brings the result above the fold. If a tool's
 * default result gets taller or shorter, update its class. */
@media (max-width: 639.98px) {
  .rb-m140 { min-height: 140px; }
  .rb-m144 { min-height: 144px; }
  .rb-m148 { min-height: 148px; }
  .rb-m152 { min-height: 152px; }
  .rb-m168 { min-height: 168px; }
  .rb-m172 { min-height: 172px; }
  .rb-m176 { min-height: 176px; }
  .rb-m180 { min-height: 180px; }
  .rb-m188 { min-height: 188px; }
  .rb-m196 { min-height: 196px; }
  .rb-m204 { min-height: 204px; }
  .rb-m208 { min-height: 208px; }
  .rb-m220 { min-height: 220px; }
  .rb-m228 { min-height: 228px; }
  .rb-m256 { min-height: 256px; }
  .rb-m280 { min-height: 280px; }
  .rb-m328 { min-height: 328px; }
  .rb-m332 { min-height: 332px; }
  .rb-m404 { min-height: 404px; }
  .rb-m432 { min-height: 432px; }
  .rb-m480 { min-height: 480px; }
  .rb-m536 { min-height: 536px; }
}
@media (min-width: 640px) {
  .rb-d128 { min-height: 128px; }
  .rb-d132 { min-height: 132px; }
  .rb-d152 { min-height: 152px; }
  .rb-d156 { min-height: 156px; }
  .rb-d164 { min-height: 164px; }
  .rb-d168 { min-height: 168px; }
  .rb-d180 { min-height: 180px; }
  .rb-d196 { min-height: 196px; }
  .rb-d252 { min-height: 252px; }
  .rb-d316 { min-height: 316px; }
  .rb-d388 { min-height: 388px; }
  .rb-d392 { min-height: 392px; }
  .rb-d444 { min-height: 444px; }
}
