* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-size: var(--font-body-size);
  line-height: var(--font-body-lh);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
}

a { color: inherit; }

:root {
  --site-logo-height: 5.5rem;
  --site-topbar-height: calc(var(--site-logo-height) + 2rem);
}

/* Topbar */
.topbar {
  position: relative;
  z-index: 1102;
  padding: 1rem var(--gutter);
  background: var(--topbar-bg);
  color: var(--topbar-text);
  border-bottom: 1px solid var(--topbar-border);
  min-height: var(--site-topbar-height);
}

.topbar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: var(--container-max);
  min-width: 0;
  margin: 0 auto;
}

.topbar-start {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.topbar-brand {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 0;
}

.topbar-brand a {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.site-logo {
  display: block;
  height: var(--site-logo-height);
  width: auto;
  max-width: min(440px, 90vw);
  object-fit: contain;
}

.topbar-subtitle {
  font-weight: 500;
  color: var(--muted);
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar-link {
  padding: 0.35rem 0.65rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.topbar-link:hover,
.topbar-link:focus-visible {
  color: var(--text);
  background: var(--surface-alt);
  outline: none;
}

.topbar-link-label-short {
  display: none;
}

.theme-toggle-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  min-width: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease;
}

.theme-toggle-btn:hover,
.theme-toggle-btn:focus-visible {
  background: var(--surface-alt);
  outline: none;
}

.theme-toggle-btn svg {
  width: 22px;
  height: 22px;
  display: block;
  margin: auto;
}

.reading-toggle-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  min-width: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.reading-toggle-btn:hover,
.reading-toggle-btn:focus-visible {
  background: var(--surface-alt);
  outline: none;
}

.reading-toggle-btn svg {
  width: 22px;
  height: 22px;
  display: block;
}

.reading-toggle-btn[aria-expanded="true"] {
  border-color: var(--border-strong);
  background: var(--surface-alt);
}

.reading-toggle-btn.has-active::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-secondary);
  border: 1px solid var(--panel);
}

.drive-sync-toggle-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  min-width: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.drive-sync-toggle-btn:hover,
.drive-sync-toggle-btn:focus-visible {
  background: var(--surface-alt);
  outline: none;
}

.drive-sync-toggle-btn svg {
  width: 22px;
  height: 22px;
  display: block;
}

.drive-sync-toggle-btn[aria-expanded="true"] {
  border-color: var(--border-strong);
  background: var(--surface-alt);
}

.drive-sync-toggle-btn.is-synced::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-secondary);
  border: 1px solid var(--panel);
}

.drive-sync-toggle-btn.is-error {
  color: var(--error);
}

.drive-sync-toggle-btn.is-offline {
  color: var(--muted);
}

.drive-sync-popover {
  position: fixed;
  top: calc(var(--site-topbar-height) + 0.5rem);
  right: calc(var(--gutter) + 3rem);
  z-index: 1200;
  width: min(22rem, calc(100vw - 2 * var(--gutter)));
  padding: 0.85rem 1rem 1rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
}

.drive-sync-popover[hidden] {
  display: none;
}

.drive-sync-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.drive-sync-popover-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.drive-sync-popover-close {
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.drive-sync-popover-close:hover,
.drive-sync-popover-close:focus-visible {
  background: var(--surface-alt);
  color: var(--text);
  outline: none;
}

.drive-sync-popover-desc,
.drive-sync-popover-meta,
.drive-sync-popover-note {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.drive-sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.drive-sync-btn {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--text);
  font-size: 0.8125rem;
  cursor: pointer;
}

.drive-sync-btn:hover,
.drive-sync-btn:focus-visible {
  background: var(--surface-alt);
  outline: none;
}

.drive-sync-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.drive-sync-btn-primary {
  border-color: var(--accent-secondary);
  background: var(--accent-secondary);
  color: var(--panel);
}

.drive-sync-toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.8125rem;
  cursor: pointer;
}

.drive-sync-banner {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1300;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
}

.drive-sync-banner-text {
  margin: 0;
  font-size: 0.875rem;
}

.drive-sync-banner-btn {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.8125rem;
  cursor: pointer;
}

.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;
}

/* Reading-comfort popover */
.reading-popover {
  position: fixed;
  top: calc(var(--site-topbar-height) + 0.5rem);
  right: var(--gutter);
  z-index: 1200;
  width: min(20rem, calc(100vw - 2 * var(--gutter)));
  padding: 0.85rem 1rem 1rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
}

.reading-popover[hidden] {
  display: none;
}

.reading-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.reading-popover-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.reading-popover-close {
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.reading-popover-close:hover,
.reading-popover-close:focus-visible {
  background: var(--surface-alt);
  color: var(--text);
  outline: none;
}

.reading-popover-desc {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.4;
}

.reading-off-btn {
  display: block;
  width: 100%;
  margin-bottom: 0.65rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.reading-off-btn:hover,
.reading-off-btn:focus-visible {
  background: var(--surface-alt);
  outline: none;
}

.reading-off-btn[aria-pressed="true"] {
  background: var(--accent-secondary);
  border-color: var(--accent-secondary);
  color: var(--on-primary);
}

.reading-swatch-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.reading-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.reading-swatch:hover,
.reading-swatch:focus-visible {
  border-color: var(--border-strong);
  outline: none;
}

.reading-swatch[aria-pressed="true"] {
  border-color: var(--accent-secondary);
  box-shadow: 0 0 0 2px var(--accent-secondary) inset;
}

.reading-swatch-color {
  width: 100%;
  height: 1.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.reading-popover-note {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Layout */
.container {
  flex: 1;
  max-width: var(--container-max);
  width: 100%;
  min-width: 0;
  margin: 0 auto;
  padding: 2rem var(--gutter) 3rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.muted { color: var(--muted); }

/* Hero */
.hero { margin-bottom: 2rem; }

.hero-badge {
  display: inline-block;
  margin-bottom: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  background: var(--accent-mint);
  color: var(--accent-secondary);
  font-size: var(--font-label-sm-size);
  font-weight: var(--font-label-sm-weight);
  letter-spacing: var(--font-label-sm-spacing);
  text-transform: uppercase;
}

.hero h1 {
  margin: 0 0 0.35rem;
  font-size: var(--font-headline-size);
  font-weight: var(--font-headline-weight);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.hero-accent { color: var(--accent-secondary); }

.hero p {
  margin: 0 0 0.75rem;
  line-height: 1.625;
  color: var(--muted);
}

.hero-lede {
  margin: 0;
  line-height: 1.4;
  color: var(--muted);
}

.hero-highlights {
  margin: 0 0 0.75rem;
  line-height: 1.55;
  color: var(--text);
  font-size: 0.9375rem;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--btn-primary);
  color: var(--on-primary);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

:root[data-theme="dark"] .btn-primary {
  background: var(--btn-primary);
  color: var(--on-primary);
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: color-mix(in srgb, var(--btn-primary) 85%, #000);
  outline: none;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-outline:hover,
.btn-outline:focus-visible {
  background: var(--surface-alt);
  border-color: var(--accent);
  outline: none;
}

/* Home articles carousel */
.home-articles {
  margin: 1.25rem 0 0;
}

.home-articles-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.home-articles-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.home-articles-all {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent-secondary);
  text-decoration: none;
  white-space: nowrap;
}

.home-articles-all:hover,
.home-articles-all:focus-visible {
  text-decoration: underline;
  outline: none;
}

.home-articles-carousel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  padding: 0.65rem 0.5rem;
}

.home-articles-viewport {
  overflow: hidden;
  min-width: 0;
}

.home-articles-track {
  display: flex;
  width: 100%;
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.home-articles-slide {
  flex: 0 0 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0.55rem 0.65rem 0.7rem;
}

.home-articles-slide h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
}

.home-articles-slide h3 a {
  color: var(--text);
  text-decoration: none;
}

.home-articles-slide h3 a:hover,
.home-articles-slide h3 a:focus-visible {
  color: var(--btn-primary);
  text-decoration: underline;
  outline: none;
}

.home-articles-meta {
  margin: 0 0 0.45rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.home-articles-snippet {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text);
}

.home-articles-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

.home-articles-actions a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent-secondary);
  text-decoration: none;
}

.home-articles-actions a:hover,
.home-articles-actions a:focus-visible {
  text-decoration: underline;
  outline: none;
}

.home-articles-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  min-height: 2.25rem;
  align-self: center;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.home-articles-nav:hover,
.home-articles-nav:focus-visible {
  border-color: var(--btn-primary);
  outline: 2px solid var(--btn-primary);
  outline-offset: 1px;
}

.home-articles-noscript {
  margin: 1rem 0 0;
  font-size: 0.9375rem;
}

@media (max-width: 640px) {
  .home-articles-carousel {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.65rem;
    padding: 0.75rem;
  }

  .home-articles-viewport {
    flex: 1 1 100%;
    order: 1;
  }

  .home-articles-prev {
    order: 2;
  }

  .home-articles-next {
    order: 3;
    margin-left: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .home-articles-track {
    transition: none;
  }
}

.disclaimer {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(45, 90, 39, 0.2);
  background: var(--accent-mint);
  font-size: 0.875rem;
  color: var(--text);
}

:root[data-theme="dark"] .disclaimer {
  border-color: rgba(161, 212, 148, 0.2);
}

/* Tool grid */
.tools-section { margin-top: 2rem; }

.tools-section h2 {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-items: stretch;
}

@media (max-width: 900px) {
  .tool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .tool-grid {
    grid-template-columns: 1fr;
  }
}

.tool-card {
  display: flex;
  flex-direction: column;
  min-height: 8.5rem;
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  background: var(--panel);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.tools-section .tool-card {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.tools-section .tool-card--wash-profile {
  --tool-card-wash: var(--accent-secondary);
}

.tools-section .tool-card--wash-cat-1 {
  --tool-card-wash: var(--chart-category-1);
}

.tools-section .tool-card--wash-cat-2 {
  --tool-card-wash: var(--chart-category-2);
}

.tools-section .tool-card--wash-cat-3 {
  --tool-card-wash: var(--chart-category-3);
}

.tools-section .tool-card--wash-cat-4 {
  --tool-card-wash: var(--chart-category-4);
}

.tools-section .tool-card--wash-cat-5 {
  --tool-card-wash: var(--chart-category-5);
}

.tools-section .tool-card--wash-cat-6 {
  --tool-card-wash: var(--chart-category-6);
}

.tools-section .tool-card--wash-cat-7 {
  --tool-card-wash: var(--chart-category-7);
}

.tools-section .tool-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 88% 78% at 100% 0%, color-mix(in srgb, var(--tool-card-wash) 20%, transparent) 0%, transparent 62%),
    radial-gradient(ellipse 70% 58% at 0% 100%, color-mix(in srgb, var(--tool-card-wash) 12%, transparent) 0%, transparent 52%);
  opacity: 0.85;
  transition: opacity 0.15s ease;
}

.tools-section .tool-card-watermark {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  z-index: 0;
  width: 4.25rem;
  height: 4.25rem;
  color: var(--tool-card-wash);
  opacity: 0.09;
  pointer-events: none;
}

.tools-section .tool-card-watermark .me-icon {
  width: 100%;
  height: 100%;
}

.tools-section .tool-card > h3,
.tools-section .tool-card > p,
.tools-section .tool-card > .tool-card-chart {
  position: relative;
  z-index: 1;
}

.tools-section .tool-card-chart {
  background: transparent;
}

.tools-section .tool-card > h3 {
  padding-right: 3.5rem;
}

.tools-section .tool-card:hover::before,
.tools-section .tool-card:focus-visible::before {
  opacity: 1;
}

.tools-section .tool-card:hover .tool-card-watermark,
.tools-section .tool-card:focus-visible .tool-card-watermark {
  opacity: 0.12;
}

:root[data-theme="dark"] .tools-section .tool-card::before {
  opacity: 0.95;
}

:root[data-theme="dark"] .tools-section .tool-card-watermark {
  opacity: 0.11;
}

:root[data-theme="dark"] .tools-section .tool-card:hover .tool-card-watermark,
:root[data-theme="dark"] .tools-section .tool-card:focus-visible .tool-card-watermark {
  opacity: 0.14;
}

.tool-card--has-chart {
  min-height: 11.5rem;
}

.tool-card--featured {
  display: block;
  grid-column: 1 / -1;
  margin-bottom: 1.25rem;
  border-color: color-mix(in srgb, var(--ok) 35%, var(--border));
  background: var(--accent-mint);
  text-decoration: none;
  color: var(--text);
}

.tool-card--featured:hover,
.tool-card--featured:focus-visible {
  border-color: color-mix(in srgb, var(--ok) 55%, var(--border));
  box-shadow: var(--shadow-float);
  outline: none;
}

.tool-card-chart {
  display: block;
  width: 100%;
  height: 4rem;
  margin-top: auto;
  padding-top: 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--chart-bg);
}

.tool-card:hover,
.tool-card:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  background: var(--surface-container-low);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  outline: none;
}

.tools-section .tool-card:hover,
.tools-section .tool-card:focus-visible {
  background: var(--panel);
  box-shadow: var(--shadow-float);
}

:root[data-theme="dark"] .tool-card:hover,
:root[data-theme="dark"] .tool-card:focus-visible {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.info-panel {
  margin-top: 1.5rem;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-lg);
  background: var(--accent-secondary);
  border: 1px solid var(--accent-secondary);
  color: var(--on-primary);
}

.info-panel h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--on-primary);
}

.info-panel p {
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.9);
  max-width: 52rem;
}

.info-panel p:last-child {
  margin-bottom: 0;
}

.info-panel-note {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.75);
}

.info-panel-note a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.info-panel-note a:hover,
.info-panel-note a:focus-visible {
  color: var(--on-primary);
}

:root[data-theme="dark"] .info-panel {
  background: color-mix(in srgb, var(--accent-secondary) 70%, #141b2b);
  border-color: color-mix(in srgb, var(--accent-secondary) 50%, transparent);
}

.tool-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 600;
  color: inherit;
}

.tool-card p {
  margin: 0;
  flex: 1;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.5;
}

.tool-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
  color: var(--accent-secondary);
  line-height: 0;
}

.me-icon {
  display: block;
  width: 1.5rem;
  height: 1.5rem;
  stroke: currentColor;
  fill: none;
  color: inherit;
}

.tool-footer-link-icon {
  position: absolute;
  top: 50%;
  right: 0.55rem;
  z-index: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  color: var(--tool-card-wash, var(--accent-secondary));
  opacity: 0.1;
  pointer-events: none;
  line-height: 0;
  transform: translateY(calc(-50% - 0.08rem));
}

.tool-footer-link-icon .me-icon {
  width: 88%;
  height: 88%;
}

.tool-card:hover .tool-icon,
.tool-card:focus-visible .tool-icon {
  color: var(--accent);
}

.page-intro { margin-bottom: 1rem; }

.page-intro h1 {
  font-size: var(--font-headline-size);
  font-weight: var(--font-headline-weight);
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
}

/* Footer */
.site-footer {
  background: var(--footer-bg);
  color: var(--footer-text);
  margin-top: auto;
}

.site-footer-disclaimer {
  padding: 0.75rem var(--gutter);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.8125rem;
  text-align: center;
  color: var(--footer-muted);
}

.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 1.5rem var(--gutter);
}

.site-footer-brand {
  font-weight: 700;
  font-size: 0.9375rem;
}

.site-footer-copy {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--footer-muted);
}

.site-footer-contact {
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
}

.site-footer-contact a {
  color: var(--footer-muted);
  text-decoration: none;
}

.site-footer-contact a:hover,
.site-footer-contact a:focus-visible {
  color: var(--footer-text);
  outline: none;
}

.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-footer-links a {
  font-size: 0.8125rem;
  color: var(--footer-muted);
  text-decoration: none;
}

.site-footer-links a:hover,
.site-footer-links a:focus-visible {
  color: var(--footer-text);
  outline: none;
}

/* Privacy page */
.privacy-page-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 2rem;
}

.privacy-page-logo {
  display: block;
  height: clamp(8rem, 18vw, 13rem);
  width: auto;
  max-width: 100%;
  margin-bottom: 1rem;
  object-fit: contain;
}

.privacy-page-intro h1 {
  margin: 0 0 0.5rem;
  font-size: var(--font-headline-size);
  font-weight: var(--font-headline-weight);
  letter-spacing: -0.01em;
}

.privacy-page-intro p {
  margin: 0;
  max-width: 42rem;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.privacy-page-content {
  max-width: 52rem;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}

.privacy-page-content > h2 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.privacy-page-content > h2:first-of-type {
  margin-top: 1.25rem;
}

.privacy-page-content p,
.privacy-page-content ul {
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text);
}

.privacy-page-content ul {
  padding-left: 1.25rem;
}

.privacy-page-content li + li {
  margin-top: 0.25rem;
}

.privacy-page-content a {
  color: var(--accent-secondary);
  font-weight: 500;
}

.privacy-data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0.9rem 0 0.65rem;
}

.privacy-data-btn {
  min-height: 2.75rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.privacy-data-btn-primary {
  border-color: var(--btn-primary);
  background: var(--btn-primary);
  color: var(--on-primary);
}

.privacy-data-btn:hover:not(:disabled) {
  background: var(--surface-alt);
}

.privacy-data-btn-primary:hover:not(:disabled) {
  background: var(--btn-primary-hover);
}

.privacy-data-btn:focus-visible,
.privacy-reset-btn:focus-visible,
.clear-local-data-dialog-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.privacy-data-btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

.privacy-data-status {
  margin: 0.5rem 0 0;
}

.privacy-data-status[hidden] {
  display: none;
}

.privacy-data-status.is-error,
.clear-local-data-dialog-desc .is-older {
  color: var(--error);
  font-weight: 600;
}

.privacy-reset-btn {
  display: inline-flex;
  align-items: center;
  margin-top: 0.25rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--error);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--error);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
}

.privacy-reset-btn:hover,
.privacy-reset-btn:focus-visible {
  background: color-mix(in srgb, var(--error) 10%, transparent);
}

.clear-local-data-dialog {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gutter);
  background: color-mix(in srgb, var(--text) 45%, transparent);
}

.clear-local-data-dialog[hidden] {
  display: none;
}

.clear-local-data-dialog-panel {
  width: min(28rem, 100%);
  padding: 1.25rem 1.35rem 1.15rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
}

.clear-local-data-dialog-title {
  margin: 0 0 0.65rem;
  font-size: 1.0625rem;
  font-weight: 600;
}

.clear-local-data-dialog-desc {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--muted);
}

.clear-local-data-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
}

.clear-local-data-dialog-btn {
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--text);
  font-size: 0.8125rem;
  cursor: pointer;
}

.clear-local-data-dialog-btn:hover,
.clear-local-data-dialog-btn:focus-visible {
  background: var(--surface-alt);
}

.privacy-import-confirm-btn {
  border-color: var(--btn-primary);
  background: var(--btn-primary);
  color: var(--on-primary);
}

.privacy-import-confirm-btn:hover,
.privacy-import-confirm-btn:focus-visible {
  background: var(--btn-primary-hover);
}

.clear-local-data-dialog-btn-danger {
  border-color: var(--error);
  background: var(--error);
  color: var(--panel);
}

.clear-local-data-dialog-btn-danger:hover,
.clear-local-data-dialog-btn-danger:focus-visible {
  background: color-mix(in srgb, var(--error) 88%, var(--text));
}

html.has-modal-open {
  overflow: hidden;
}

/* SEO guide and FAQ blocks — docs/SEO_PLAN.md */
.seo-content {
  margin-top: 2rem;
  display: grid;
  gap: 1.25rem;
}

.seo-guide,
.seo-faq {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.seo-guide h2,
.seo-faq h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.seo-guide h3,
.seo-faq-item h3 {
  margin: 1rem 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.seo-guide h3:first-of-type,
.seo-faq-item:first-child h3 {
  margin-top: 0;
}

.seo-guide p,
.seo-faq-item p {
  margin: 0 0 0.75rem;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.9rem;
}

.seo-guide p:last-child,
.seo-faq-item p:last-child {
  margin-bottom: 0;
}

.seo-guide a {
  color: var(--accent-secondary);
  font-weight: 500;
}

.seo-howto-steps {
  margin: 0.5rem 0 0.75rem;
  padding-left: 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.seo-howto-steps li + li {
  margin-top: 0.35rem;
}

.seo-faq-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 769px) {
  .seo-faq-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.seo-faq-item {
  margin: 0;
}

/* Footer tool navigation */
.tool-footer-nav {
  margin-top: auto;
  padding: 2rem var(--gutter) 2.5rem;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}

.tool-footer-nav-inner {
  max-width: var(--container-max);
  margin: 0 auto;
}

.tool-footer-nav-title {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.tool-footer-nav-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.tool-footer-link {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: flex;
  align-items: center;
  min-height: 3rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--panel);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.tool-footer-link::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 88% 78% at 100% 0%, color-mix(in srgb, var(--tool-card-wash, var(--accent-secondary)) 20%, transparent) 0%, transparent 62%),
    radial-gradient(ellipse 70% 58% at 0% 100%, color-mix(in srgb, var(--tool-card-wash, var(--accent-secondary)) 12%, transparent) 0%, transparent 52%);
  opacity: 0.85;
  transition: opacity 0.15s ease;
}

.tool-footer-link[href="index.html"] {
  --tool-card-wash: var(--accent);
}

.tool-footer-link[href="financialprofile.html"] {
  --tool-card-wash: var(--accent-secondary);
}

.tool-footer-link[href="retirementplanner.html"] {
  --tool-card-wash: var(--chart-category-1);
}

.tool-footer-link[href="takehomesalary.html"] {
  --tool-card-wash: var(--chart-category-2);
}

.tool-footer-link[href="compoundinterest.html"] {
  --tool-card-wash: var(--chart-category-3);
}

.tool-footer-link[href="budgetplanner.html"] {
  --tool-card-wash: var(--chart-category-4);
}

.tool-footer-link[href="mortgageoverpayment.html"] {
  --tool-card-wash: var(--chart-category-6);
}

.tool-footer-link[href="emergencyfund.html"] {
  --tool-card-wash: var(--chart-category-2);
}

.tool-footer-link[href="debtpayoff.html"] {
  --tool-card-wash: var(--chart-category-5);
}

.tool-footer-link[href="studentloan.html"] {
  --tool-card-wash: var(--chart-category-3);
}

.tool-footer-link[href="stampduty.html"] {
  --tool-card-wash: var(--chart-category-7);
}

.tool-footer-link:hover,
.tool-footer-link:focus-visible {
  border-color: color-mix(in srgb, var(--tool-card-wash, var(--accent)) 35%, var(--border));
  background: var(--panel);
  box-shadow: var(--shadow-float);
  outline: none;
}

.tool-footer-link:hover::before,
.tool-footer-link:focus-visible::before {
  opacity: 1;
}

.tool-footer-link:hover .tool-footer-link-icon,
.tool-footer-link:focus-visible .tool-footer-link-icon {
  opacity: 0.14;
}

:root[data-theme="dark"] .tool-footer-link::before {
  opacity: 0.95;
}

:root[data-theme="dark"] .tool-footer-link-icon {
  opacity: 0.11;
}

:root[data-theme="dark"] .tool-footer-link:hover .tool-footer-link-icon,
:root[data-theme="dark"] .tool-footer-link:focus-visible .tool-footer-link-icon {
  opacity: 0.15;
}

:root[data-theme="dark"] .tool-footer-link:hover,
:root[data-theme="dark"] .tool-footer-link:focus-visible {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.tool-footer-link-label {
  position: relative;
  z-index: 1;
  min-width: 0;
  padding-right: 1.85rem;
}

@media (max-width: 900px) {
  .tool-footer-nav-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .tool-footer-nav-grid {
    grid-template-columns: 1fr;
  }
}

/* Privacy dialog */
.privacy-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--modal-overlay-bg);
  backdrop-filter: blur(1.5px);
}

.privacy-overlay[hidden] {
  display: none;
}

.privacy-dialog {
  position: relative;
  width: min(100%, 560px);
  max-height: min(85vh, 720px);
  overflow: auto;
  padding: 1.25rem 1.25rem 1rem;
  border: 1px solid var(--modal-panel-border);
  border-radius: var(--radius-lg);
  background: var(--modal-panel-bg);
  color: var(--text);
  box-shadow: var(--modal-panel-shadow);
}

.privacy-dialog h2 {
  margin: 0 2rem 0.75rem 0;
  font-size: 1.15rem;
}

.privacy-dialog h3 {
  margin: 1rem 0 0.35rem;
  font-size: 0.95rem;
}

.privacy-dialog p,
.privacy-dialog ul {
  margin: 0 0 0.75rem;
  font-size: 0.92rem;
  line-height: 1.5;
}

.privacy-dialog ul {
  padding-left: 1.25rem;
}

.privacy-dialog li + li {
  margin-top: 0.35rem;
}

.privacy-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.privacy-close:hover,
.privacy-close:focus-visible {
  background: var(--surface-alt);
  color: var(--text);
  outline: none;
}

.privacy-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--btn-secondary);
  color: var(--on-primary);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

/* Shared form components */
.item-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.item-delete-btn svg {
  width: 1rem;
  height: 1rem;
  display: block;
}

.item-delete-btn:hover:not(:disabled),
.item-delete-btn:focus-visible:not(:disabled) {
  color: var(--error);
  background: color-mix(in srgb, var(--error) 10%, transparent);
  outline: none;
}

.item-delete-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.form-collapsible {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-container-low);
  overflow: hidden;
}

.form-collapsible > summary {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}

.form-collapsible > summary::-webkit-details-marker {
  display: none;
}

.form-collapsible > summary::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.form-collapsible[open] > summary::before {
  transform: rotate(-135deg);
}

.form-collapsible-body {
  display: grid;
  gap: 0.65rem;
  padding: 0 0.85rem 0.85rem;
  border-top: 1px solid var(--border);
}

/* Cookie notice */
.cookie-notice {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1100;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.65rem 1rem;
  padding: 0.55rem var(--gutter);
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 94%, var(--bg));
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--muted);
}

.cookie-notice[hidden] {
  display: none;
}

.cookie-notice-text {
  margin: 0;
  text-align: center;
}

.cookie-notice-link {
  margin-left: 0.25rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-secondary);
  font: inherit;
  font-size: inherit;
  font-weight: 500;
  text-decoration: underline;
  cursor: pointer;
}

a.cookie-notice-link:hover,
a.cookie-notice-link:focus-visible,
button.cookie-notice-link:hover,
button.cookie-notice-link:focus-visible {
  color: var(--text);
  outline: none;
}

.cookie-notice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}

.cookie-notice-btn {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
}

.cookie-notice-btn-accept {
  background: var(--btn-primary);
  border-color: var(--btn-primary);
  color: var(--on-primary);
}

.cookie-notice-btn:hover,
.cookie-notice-btn:focus-visible {
  outline: none;
  filter: brightness(0.95);
}

:root[data-theme="dark"] .cookie-notice {
  box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.35);
}

@media (max-width: 768px) {
  .topbar,
  .container,
  .tool-footer-nav,
  .site-footer-disclaimer,
  .site-footer-inner {
    padding-left: var(--gutter-mobile);
    padding-right: var(--gutter-mobile);
  }

  :root {
    --site-logo-height: 4.5rem;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .site-logo {
    max-width: min(360px, 96vw);
  }

  .topbar-nav {
    gap: 0.35rem;
    flex-shrink: 0;
  }

  .topbar-link {
    font-size: 0.8125rem;
    padding: 0.35rem 0.45rem;
  }

  .tool-card-chart {
    display: none;
  }
}

@media (max-width: 480px) {
  :root {
    --site-logo-height: 3.25rem;
  }

  .topbar-start {
    flex: 1;
    min-width: 0;
  }

  .site-logo {
    max-width: min(160px, 48vw);
  }

  .topbar-link-label-long {
    display: none;
  }

  .topbar-link-label-short {
    display: inline;
  }
}
