/*
 * responsive-overrides.css
 * Three-end (PC + Tablet + Mobile) responsive, interaction & accessibility overrides.
 * Loaded AFTER styles.css — wins by specificity only where needed.
 */
/* 1. TABLET (≤ 1024px) */
@media (max-width: 1024px) {
  .app-shell { width: min(100% - 24px, 1180px); padding-top: var(--space-lg); }
  .hero h1 { font-size: var(--font-xl); }
  .hero p  { max-width: 100%; }
  .calc-highlights { gap: 14px; }
  .highlight-card { padding: 18px; }
  .tool-card { padding: 18px; }
  .tool-card label, .tool-card .field { gap: 10px; }
  #slope-canvas, #palbreeding-canvas { max-width: 100%; height: auto; }
  .pw-grid, .pc-result, .pc-wrap, .pc-iv-grid { gap: 12px; grid-template-columns: 1fr; }
  .pw-offspring-grid { grid-template-columns: 1fr 1fr; }
  .pc-card { padding: 16px; }
  .site-header .search-container { display: none; }
  .calc-content { padding: var(--space-md); }
  .faq-item summary { padding: 12px var(--space-md); }
  .footer-nav { gap: 12px; }
}
/* 2. MOBILE LARGE / TABLET PORTRAIT (≤ 768px) */
@media (max-width: 768px) {
  .brand    { font-size: 1.12rem; }
  .theme-toggle { padding: 6px 12px; font-size: 0.82rem; }
  .site-nav { gap: var(--space-sm); font-size: 0.85rem; }
  .hero { padding: var(--space-md) 0; }
  .hero h1 { font-size: var(--font-lg); }
  .hero p  { font-size: var(--font-sm); }
  .eyebrow { font-size: 0.75rem; }
  .breadcrumb-nav { font-size: 0.8rem; padding: 4px 0; margin-bottom: 10px; }
  .calc-highlights { grid-template-columns: 1fr; gap: 12px; }
  .highlight-card  { min-height: 0; padding: 16px; }
  .tool-card { padding: 16px; gap: var(--space-sm); }
  .tool-card label { gap: 6px; }
  .tool-card label > span { font-size: 0.85rem; }
  .tool-card input, .tool-card select { padding: 10px 12px; font-size: 0.95rem; }
  .primary-button, .secondary-button { width: 100%; min-height: 48px; padding: 12px 16px; font-size: 0.95rem; }
  .primary-button.small, .secondary-button.small { width: auto; min-height: 44px; }
  .pw-grid, .pc-result, .pc-wrap, .pw-offspring-grid, .pc-iv-grid { grid-template-columns: 1fr; }
  .calc-content { padding: var(--space-sm); }
  .calc-content h2 { font-size: var(--font-md); }
  .faq-section h2 { font-size: var(--font-md); }
  .faq-item summary { padding: 10px var(--space-md); font-size: 0.92rem; }
  .faq-item p { font-size: 0.88rem; }
  .related-links { gap: 6px; }
  .related-links a { padding: 5px 10px; font-size: 0.85rem; }
  .site-footer { padding: var(--space-md); font-size: 0.85rem; }
  .footer-nav { gap: 10px; flex-wrap: wrap; }
}
/* 3. SMALL MOBILE (≤ 480px) */
@media (max-width: 480px) {
  .app-shell { width: calc(100% - 16px); padding-top: var(--space-md); }
  .brand { font-size: 1.05rem; }
  .hero h1 { font-size: var(--font-md); }
  .hero p  { font-size: var(--font-xs); }
  .tool-card { padding: 14px; }
  .highlight-card { padding: 14px; }
  .calc-highlights { gap: 10px; }
  .pw-btn-row, .pc-btn-row { flex-direction: column; }
  .pw-btn-row .primary-button, .pw-btn-row .secondary-button,
  .pc-btn-row .primary-button, .pc-btn-row .secondary-button { width: 100%; }
  .pw-chip { padding: 8px 12px; font-size: 0.8rem; }
  .pc-card { padding: 12px; }
  .pc-row { padding: 6px 0; font-size: 0.82rem; }
  .pc-card-title { font-size: 0.95rem; }
  .pc-uplift-val { font-size: 1.1rem; }
  .pw-batch-name { width: 90px; min-width: 90px; font-size: 0.78rem; }
  .faq-item summary { padding: 8px var(--space-sm); font-size: 0.88rem; }
  .faq-item p { padding: 0 var(--space-sm) var(--space-xs); font-size: 0.84rem; }
  .ad-section { margin-top: var(--space-md); }
  .ad-card { padding: var(--space-sm); }
}
/* 4. HOVER ISOLATION (desktop only) */
@media (hover: hover) and (pointer: fine) {
  .tool-card:hover { transform: translateY(-3px); box-shadow: 0 24px 60px rgba(0,0,0,.30); border-color: rgba(255,255,255,.18); }
  .highlight-card:hover { border-color: rgba(255,255,255,.18); transform: translateY(-2px); }
  .primary-button:hover { filter: brightness(1.08); transform: translateY(-1px); }
  .secondary-button:hover { background: rgba(255,255,255,.10); }
  .pw-chip:hover { border-color: #5ac8fa; background: rgba(90,200,250,.12); }
  .pc-toggle:hover { border-color: #5ac8fa; color: #f5f7fb; }
  .related-links a:hover { opacity: 1; text-decoration: underline; }
}
/* 5. TOUCH / COARSE POINTER (bigger tap targets + press feedback) */
@media (hover: none) and (pointer: coarse) {
  .primary-button, .secondary-button, .calc-btn, .tab-button,
  .pw-chip, .pc-toggle, .menu-toggle { min-height: 48px; }
  .theme-toggle { min-width: 48px; min-height: 48px; }
  .menu-toggle { min-width: 48px; min-height: 48px; }
  .primary-button:active, .secondary-button:active { transform: scale(0.97); opacity: 0.9; }
  .tool-card:active { transform: scale(0.99); }
  .pw-chip:active, .pc-toggle:active { transform: scale(0.96); }
  .search-input-wrapper input { min-height: 48px; }
}
/* 6. FOCUS-VISIBLE (keyboard/assisted nav) */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
:not(:focus-visible) { outline: none; }
.pw-chip:focus-visible, .pc-toggle:focus-visible, .primary-button:focus-visible,
.secondary-button:focus-visible, .menu-toggle:focus-visible, .theme-toggle:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
/* 7. SAFARI / iOS */
@supports (-webkit-touch-callout: none) {
  body { -webkit-text-size-adjust: 100%; }
  .workspace { -webkit-overflow-scrolling: touch; }
}
/* 8. REDUCED MOTION (tighter than base sheet) */
@media (prefers-reduced-motion: reduce) {
  .tool-card, .highlight-card, .primary-button, .secondary-button,
  .pw-chip, .pc-toggle { transition: none !important; transform: none !important; }
}


/* === Homepage IA P0 === */
.anchor-target{
  position:relative;
  top:0;
  height:0;width:0;overflow:hidden;
}
.hero-compact{text-align:center;margin-bottom:1.25rem;padding:0.25rem 0 0.5rem;}
.hero-compact .hero-topbar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:0.75rem;}
.hero-compact h1{font-size:clamp(1.55rem,2.6vw,2.15rem);line-height:1.2;letter-spacing:-0.03em;margin:0 auto 0.65rem;max-width:20ch;}
.hero-compact .hero-lead{max-width:52ch;margin:0 auto 1rem;color:var(--muted,rgba(255,255,255,.72));font-size:1rem;line-height:1.55;}
.hero-cta-row{display:flex;flex-wrap:wrap;gap:10px;justify-content:center;margin-bottom:1rem;}
.hero-cta,.hero-cta-secondary{min-height:44px;display:inline-flex;align-items:center;justify-content:center;padding:0.7rem 1.15rem;text-decoration:none;border-radius:14px;font-weight:700;}
.trust-strip{list-style:none;display:flex;flex-wrap:wrap;gap:8px 12px;justify-content:center;margin:0;padding:0;}
.trust-strip li{padding:0.5rem 1rem;border-radius:999px;background:var(--panel,rgba(255,255,255,.06));border:1px solid var(--glass-border,rgba(255,255,255,.1));font-size:0.86rem;color:var(--text);transition:transform .2s ease,box-shadow .2s ease;}
.trust-strip li:hover{transform:translateY(-1px);box-shadow:0 4px 12px rgba(0,0,0,.1);}
.trust-strip strong{margin-right:0.25rem;color:var(--accent);}

.quick-access-featured{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin:0 0 1.25rem;}
.quick-access-featured .quick-link{display:flex;flex-direction:column;gap:0.35rem;text-decoration:none;padding:1rem 1.05rem;min-height:88px;border:1px solid var(--glass-border,rgba(255,255,255,.1));border-radius:16px;transition:transform .15s ease,border-color .15s ease,box-shadow .15s ease;}
.quick-access-featured .quick-link strong{font-size:1rem;color:var(--text);}
.quick-access-featured .quick-link span{font-size:0.86rem;color:var(--muted,rgba(255,255,255,.65));line-height:1.35;}
.quick-access-featured .quick-link:hover{transform:translateY(-2px);border-color:var(--accent,#5ac8fa);box-shadow:0 8px 24px rgba(90,200,250,.12);}
.quick-access-featured .quick-link-accent{border-color:rgba(90,200,250,.35);box-shadow:inset 0 0 0 1px rgba(90,200,250,.12);}

/* Keep workspace as the visual priority */
#workspace{scroll-margin-top:12px;}
.ad-section{margin-top:1.25rem;margin-bottom:1.25rem;}
.ad-card{grid-template-columns:0.9fr 1.1fr;}
.ad-copy h2{font-size:1.05rem;margin:0.4rem 0;}
.ad-copy p{font-size:0.9rem;opacity:.85;}

/* Light mode readability for new homepage chips */
[data-theme="light"] .hero-compact .hero-lead{color:rgba(16,32,58,.78);}
[data-theme="light"] .trust-strip li{background:rgba(16,32,58,.04);border-color:rgba(16,32,58,.12);}
[data-theme="light"] .quick-access-featured .quick-link span{color:rgba(16,32,58,.68);}

@media (max-width: 900px){
  .quick-access-featured{grid-template-columns:repeat(2,minmax(0,1fr));}
  .hero-compact h1{max-width:none;}
}
@media (max-width: 560px){
  .quick-access-featured{grid-template-columns:1fr;}
  .hero-cta-row{flex-direction:column;}
  .hero-cta,.hero-cta-secondary{width:100%;}
  .ad-card{grid-template-columns:1fr;}
}


/* === All calculators filter P1 === */
.all-calc-toolbar{margin:0 0 1rem;display:flex;flex-direction:column;gap:0.75rem;}
.all-calc-toolbar-top{display:flex;flex-wrap:wrap;align-items:center;gap:0.65rem;}
.all-calc-search-label{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0;}
.all-calc-filter-input{
  flex:1 1 240px;min-height:44px;padding:0.65rem 0.9rem;border-radius:12px;
  border:1px solid var(--glass-border,rgba(255,255,255,.14));
  background:var(--panel,rgba(255,255,255,.05));color:var(--text);
  font-size:0.95rem;
}
.all-calc-filter-input:focus{outline:2px solid var(--accent,#5ac8fa);outline-offset:2px;}
.all-calc-count{font-size:0.86rem;opacity:.8;white-space:nowrap;}
.all-calc-chips{display:flex;flex-wrap:wrap;gap:8px;}
.all-calc-chip{
  min-height:38px;padding:0.4rem 0.85rem;border-radius:999px;cursor:pointer;
  border:1px solid var(--glass-border,rgba(255,255,255,.14));
  background:transparent;color:var(--text);font-weight:600;font-size:0.88rem;
}
.all-calc-chip.is-active,
.all-calc-chip[aria-pressed="true"]{
  background:var(--accent,#3b6dff);border-color:transparent;color:#fff;
}
.all-calc-grid-filterable{display:flex;flex-direction:column;gap:1.1rem;}
.all-calc-group h3{margin:0 0 0.55rem;font-size:1rem;}
.all-calc-links{display:flex;flex-wrap:wrap;gap:8px;}
.all-calc-grid-filterable .all-calc-link{
  display:inline-flex;align-items:center;min-height:40px;padding:0.45rem 0.75rem;
  border-radius:10px;text-decoration:none;color:var(--text);
  background:var(--panel,rgba(255,255,255,.05));
  border:1px solid var(--glass-border,rgba(255,255,255,.1));
  font-size:0.9rem;
}
.all-calc-grid-filterable .all-calc-link:hover{border-color:var(--accent,#5ac8fa);}
.all-calc-empty{margin:0.5rem 0 0;opacity:.85;}
.all-calc-footnote{margin:0.85rem 0 0;font-size:0.9rem;}
.all-calc-footnote a{color:var(--accent,#7c9cff);}
[data-theme="light"] .all-calc-filter-input{background:#fff;border-color:rgba(16,32,58,.14);color:#10203a;}
[data-theme="light"] .all-calc-chip{border-color:rgba(16,32,58,.14);}
[data-theme="light"] .all-calc-chip.is-active{color:#fff;}
[data-theme="light"] .all-calc-grid-filterable .all-calc-link{background:#fff;border-color:rgba(16,32,58,.12);color:#10203a;}
@media (max-width:560px){
  .all-calc-chip{flex:1 1 auto;}
}


/* === Light mode readability P1b === */
/* Goal: stronger text/border contrast on light backgrounds (Edge/Chrome desktop). */

body[data-theme="light"],
html[data-theme="light"] body {
  color: #10203a;
}

body[data-theme="light"] {
  /* Stronger tokens for components that still use semi-transparent white */
  --panel: rgba(255, 255, 255, 0.92);
  --panel-border: rgba(15, 23, 42, 0.12);
  --muted: #4b5c76;
  --text-secondary: #3d4f6a;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

/* Header / search */
body[data-theme="light"] .site-header {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(15, 23, 42, 0.1);
}
body[data-theme="light"] .site-header.scrolled {
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}
body[data-theme="light"] .search-input-wrapper input {
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.16);
  color: #10203a;
}
body[data-theme="light"] .search-input-wrapper input::placeholder {
  color: #6b7c95;
  opacity: 1;
}
body[data-theme="light"] .search-results {
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  color: #10203a;
}
body[data-theme="light"] .search-result-item:hover,
body[data-theme="light"] .search-result-item:focus {
  background: rgba(42, 123, 191, 0.08);
}
body[data-theme="light"] .header-actions .language-select,
body[data-theme="light"] .header-actions .secondary-button,
body[data-theme="light"] .theme-toggle,
body[data-theme="light"] .help-trigger {
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.14);
  color: #10203a;
}
body[data-theme="light"] .nav-cta,
body[data-theme="light"] .primary-button,
body[data-theme="light"] .hero-cta {
  color: #fff;
}
body[data-theme="light"] .site-nav a {
  color: #1a2b45;
}
body[data-theme="light"] .site-nav a:hover {
  color: #0b1730;
  background: rgba(42, 123, 191, 0.08);
}

/* Workspace / tabs / cards */
body[data-theme="light"] .workspace,
body[data-theme="light"] .glass-panel,
body[data-theme="light"] .glass-inner {
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(15, 23, 42, 0.1);
}
body[data-theme="light"] .tab-button {
  background: #f3f6fb;
  border: 1px solid rgba(15, 23, 42, 0.12);
  color: #1a2b45;
}
body[data-theme="light"] .tab-button.active,
body[data-theme="light"] .tab-button[aria-selected="true"] {
  background: #2a7bbf;
  border-color: #2a7bbf;
  color: #fff;
}
body[data-theme="light"] .tool-card,
body[data-theme="light"] .history-card,
body[data-theme="light"] .display-card,
body[data-theme="light"] .highlight-card,
body[data-theme="light"] .feature-card,
body[data-theme="light"] .metric-card {
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.1);
  color: #10203a;
}
body[data-theme="light"] .tool-card h3,
body[data-theme="light"] .panel-header h2,
body[data-theme="light"] .display-main {
  color: #0b1730;
}
body[data-theme="light"] .display-history,
body[data-theme="light"] .display-hint,
body[data-theme="light"] .message,
body[data-theme="light"] .result-note,
body[data-theme="light"] .panel-header p {
  color: #4b5c76;
}
body[data-theme="light"] .message.success {
  color: #17632a;
}
body[data-theme="light"] .message.error {
  color: #b42318;
}

/* Forms */
body[data-theme="light"] .tool-card input,
body[data-theme="light"] .tool-card select,
body[data-theme="light"] .input-card input,
body[data-theme="light"] .input-card select,
body[data-theme="light"] textarea,
body[data-theme="light"] .calc-textarea {
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.16);
  color: #10203a;
}
body[data-theme="light"] .tool-card input::placeholder,
body[data-theme="light"] .input-card input::placeholder {
  color: #6b7c95;
  opacity: 1;
}
body[data-theme="light"] .tool-card label span,
body[data-theme="light"] label span {
  color: #3d4f6a;
}

/* Calculator keypad */
body[data-theme="light"] .calc-btn {
  background: #eef3fb;
  color: #10203a;
  border: 1px solid rgba(15, 23, 42, 0.08);
}
body[data-theme="light"] .calc-btn.operator {
  background: #e7eefc;
  color: #184f8f;
}
body[data-theme="light"] .calc-btn.utility {
  background: #e8edf5;
  color: #31445f;
}
body[data-theme="light"] .calc-btn.accent,
body[data-theme="light"] .primary-button.small {
  background: #2a7bbf;
  color: #fff;
}
body[data-theme="light"] .secondary-button {
  background: #fff;
  color: #10203a;
  border: 1px solid rgba(15, 23, 42, 0.14);
}

/* Status chips / tags */
body[data-theme="light"] .status-chip {
  background: rgba(42, 123, 191, 0.1);
  color: #184f8f;
  border: 1px solid rgba(42, 123, 191, 0.18);
}

/* Footer / about */
body[data-theme="light"] .site-footer,
body[data-theme="light"] .about-cs-inner,
body[data-theme="light"] .highlight-copy p {
  color: #3d4f6a;
}
body[data-theme="light"] .site-footer a,
body[data-theme="light"] .footer-nav a {
  color: #184f8f;
}

/* Quick access / trust / ad */
body[data-theme="light"] .quick-access-featured .quick-link {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.1);
}
body[data-theme="light"] .quick-access-featured .quick-link strong {
  color: #0b1730;
}
body[data-theme="light"] .trust-strip li {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.1);
  color: #1a2b45;
}
body[data-theme="light"] .ad-card {
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.1);
}
body[data-theme="light"] .ad-copy h2 {
  color: #0b1730;
}
body[data-theme="light"] .ad-copy p,
body[data-theme="light"] .ad-head .eyebrow {
  color: #4b5c76;
}

/* Reduce decorative white sheen on light cards */
body[data-theme="light"] .tool-card::before,
body[data-theme="light"] .feature-card::before,
body[data-theme="light"] .highlight-card::before,
body[data-theme="light"] .history-card::before,
body[data-theme="light"] .display-card::before,
body[data-theme="light"] .metric-card::before {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.03), transparent 30%);
}

/* Mobile menu in light mode */
body[data-theme="light"] .menu-toggle {
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.14);
  color: #10203a;
}

body[data-theme="light"]{color-scheme:light;}
body[data-theme="dark"]{color-scheme:dark;}

/* Network ad (effectivecpmnetwork) — non-intrusive partner slot */
.network-ad-slot {
  margin-top: 12px;
  min-height: 0;
  padding: 12px;
  border-radius: var(--radius-lg, 16px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}
.network-ad-slot[aria-hidden="true"],
.network-ad-slot.is-hidden {
  display: none !important;
}
.network-ad-slot > div {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
/* Keep ads stacked under copy on narrow screens; avoid pushing calculator UI */
@media (max-width: 960px) {
  .ad-card .network-ad-slot {
    grid-column: 1 / -1;
  }
}
/* Prefer reduced data / print: hide network ads */
@media print {
  .network-ad-slot {
    display: none !important;
  }
}

/* === Header layout cleanup (desktop + mobile) ===
 * Single clean row on desktop; compact brand/theme/menu row on mobile.
 * Header is not sticky — scrolls with the page.
 */
.site-header {
  position: relative !important;
  top: auto !important;
  z-index: 20;
  max-width: 100%;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px 14px;
  padding: 10px 16px;
  margin-bottom: clamp(14px, 2.2vw, 24px);
  border-radius: 16px;
  transition:
    background var(--transition-normal, 0.25s ease),
    border-color var(--transition-normal, 0.25s ease),
    box-shadow var(--transition-normal, 0.25s ease);
}

/* Keep header visible during reveal animation (no translate jump) */
.site-header.reveal,
.site-header.reveal.visible,
.js-ready .site-header.reveal {
  opacity: 1 !important;
  transform: none !important;
}

.site-header .brand {
  flex: 0 0 auto;
  text-decoration: none;
  white-space: nowrap;
}

.site-header .search-container {
  flex: 1 1 180px;
  max-width: 260px;
  min-width: 0;
}

.site-header .site-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
  flex-shrink: 0;
}

.site-header .site-nav a {
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 500;
}

.site-header .header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  margin-left: auto;
}

.site-header .header-actions > * {
  min-height: 40px;
}

.site-header .header-actions .theme-toggle {
  padding: 8px 12px;
  font-size: 0.82rem;
  white-space: nowrap;
  border-radius: 999px;
}

.site-header .header-actions .language-select {
  min-width: 58px;
  width: auto;
  max-width: 72px;
  padding: 6px 26px 6px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.site-header .header-actions .help-trigger {
  padding: 8px 12px;
  font-size: 0.82rem;
  white-space: nowrap;
  border-radius: 999px;
}

.site-header .header-more-link {
  display: none !important; /* demoted to footer */
}

/* Expanded mobile menu: panel scrolls if tall */
.site-header.menu-open {
  max-height: min(92vh, 100dvh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

body.menu-open-lock {
  overflow: hidden !important;
  touch-action: none;
}

/* Hero topbar: centered eyebrow only (theme moved into header) */
.hero-compact .hero-topbar {
  justify-content: center;
  margin-bottom: 0.65rem;
}

@media (max-width: 1100px) {
  .site-header .search-container {
    max-width: 200px;
  }
  .site-header .site-nav a {
    padding: 0.4rem 0.55rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 1024px) {
  .site-header {
    padding: 10px 14px;
    margin-bottom: 16px;
  }

  .site-header .search-container {
    display: none !important;
  }
}

@media (max-width: 900px) {
  /* Collapse primary nav into hamburger; keep theme on the top row */
  .site-header {
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 8px 12px !important;
    margin-bottom: 12px !important;
    border-radius: 14px;
  }

  .site-header .brand {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 1.08rem !important;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .site-header .menu-toggle {
    order: 3;
    display: inline-flex !important;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    margin-left: 0;
  }

  /* Theme always visible on top row (homepage: inside actions; tool pages: direct child) */
  .site-header > .theme-toggle {
    order: 2;
    flex: 0 0 auto;
    padding: 8px 12px;
    font-size: 0.8rem;
    min-height: 40px;
    white-space: nowrap;
  }

  .site-header .header-actions {
    order: 2;
    display: flex !important;
    flex: 0 0 auto;
    width: auto;
    margin-left: 0;
    padding: 0;
    gap: 6px;
    border: 0;
  }

  .site-header .header-actions .language-select,
  .site-header .header-actions .help-trigger,
  .site-header .header-actions .nav-cta,
  .site-header .header-actions .back-link,
  .site-header .header-actions .header-more-link {
    display: none !important;
  }

  .site-header .header-actions .theme-toggle {
    display: inline-flex !important;
    min-height: 40px;
    padding: 8px 12px;
    font-size: 0.8rem;
  }

  .site-header .site-nav {
    order: 4;
    display: none;
  }

  .site-header.menu-open .site-nav {
    display: flex;
    flex-direction: column;
    width: 100%;
    flex-basis: 100%;
    gap: 2px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  body[data-theme="light"] .site-header.menu-open .site-nav {
    border-top-color: rgba(15, 23, 42, 0.08);
  }

  .site-header.menu-open .site-nav a {
    width: 100%;
    border-radius: 12px;
    padding: 12px 14px;
    min-height: 44px;
  }

  /* Second row of actions when menu open: language + shortcuts */
  .site-header.menu-open .header-actions {
    order: 5;
    width: 100%;
    flex-basis: 100%;
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding-top: 8px;
  }

  .site-header.menu-open .header-actions .theme-toggle {
    display: none !important; /* already on top row */
  }

  .site-header.menu-open .header-actions .language-select,
  .site-header.menu-open .header-actions .help-trigger {
    display: inline-flex !important;
    width: 100%;
    min-height: 44px;
    max-width: none;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
  }

  .site-header.menu-open .header-actions .language-select {
    display: block !important;
  }

  .hero,
  .hero-compact {
    margin-bottom: 1rem;
    padding-top: 0;
  }

  .hero h1,
  .hero-compact h1 {
    line-height: 1.25;
  }

  .breadcrumb-nav {
    margin-bottom: 10px;
  }

  .workspace {
    padding: 14px;
  }
}

@media (max-width: 480px) {
  .site-header {
    padding: 8px 10px !important;
    gap: 6px 8px;
    margin-bottom: 10px !important;
    border-radius: 12px;
  }

  .site-header .brand {
    font-size: 1.02rem !important;
  }

  .site-header > .theme-toggle,
  .site-header .header-actions .theme-toggle {
    padding: 6px 10px;
    font-size: 0.75rem;
    min-height: 38px;
  }

  .site-header .menu-toggle {
    width: 42px;
    height: 42px;
  }
}

/* ==========================================================================
   Visual polish + UX (layout rhythm, cards, forms, tabs, footer)
   Loaded last in this file — refine look without changing sticky behavior.
   ========================================================================== */

/* --- Page rhythm --- */
.app-shell {
  padding-top: clamp(18px, 2.8vw, 36px);
  padding-bottom: clamp(32px, 5vw, 56px);
}

.site-header {
  border: 1px solid var(--panel-border, rgba(255, 255, 255, 0.1));
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.14);
}

body[data-theme="light"] .site-header {
  box-shadow: 0 6px 22px rgba(15, 23, 42, 0.05);
}

.site-nav a {
  transition: background 0.18s ease, color 0.18s ease;
}

.site-nav a:hover {
  background: rgba(90, 200, 250, 0.1);
  color: var(--text);
}

body[data-theme="light"] .site-nav a:hover {
  background: rgba(42, 123, 191, 0.08);
  color: #0b1730;
}

.nav-cta {
  text-decoration: none;
  white-space: nowrap;
}

.menu-toggle {
  border-radius: 12px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.menu-toggle:active {
  transform: scale(0.96);
}

/* --- Hero (home + detail) --- */
.hero {
  margin-bottom: clamp(1rem, 2.5vw, 1.75rem);
}

.hero.hero-compact {
  margin-bottom: 1.1rem;
  padding: 0.15rem 0 0.35rem;
}

.hero:not(.hero-compact) {
  text-align: left;
  padding: 0.15rem 0 0.35rem;
}

.hero:not(.hero-compact) h1 {
  margin: 0.55rem 0 0.55rem;
  font-size: clamp(1.65rem, 3.4vw, 2.35rem);
  line-height: 1.18;
  letter-spacing: -0.03em;
  max-width: 22ch;
}

.hero:not(.hero-compact) p {
  width: min(52ch, 100%);
  margin: 0;
  font-size: clamp(0.95rem, 1.6vw, 1.08rem);
  line-height: 1.6;
  color: var(--muted, rgba(255, 255, 255, 0.72));
}

body[data-theme="light"] .hero:not(.hero-compact) p {
  color: rgba(16, 32, 58, 0.78);
}

.hero-compact h1 {
  font-size: clamp(1.5rem, 2.8vw, 2.2rem);
  max-width: 20ch;
}

.hero-compact .hero-lead {
  font-size: clamp(0.95rem, 1.5vw, 1.05rem);
  line-height: 1.6;
  opacity: 0.92;
}

.eyebrow {
  letter-spacing: 0.06em;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  font-size: 0.72rem;
}

.trust-strip {
  gap: 8px;
  margin-top: 0.15rem;
}

.trust-strip li {
  font-size: 0.84rem;
  padding: 0.4rem 0.7rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.hero-cta-row {
  gap: 10px;
  margin-bottom: 0.95rem;
}

.hero-cta,
.hero-cta-secondary {
  border-radius: 14px;
  min-height: 46px;
  padding: 0.72rem 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* --- Quick access cards --- */
.quick-access-featured {
  gap: 12px;
  margin: 0 0 1.35rem;
}

.quick-access-featured .quick-link {
  position: relative;
  min-height: 92px;
  padding: 1.05rem 1.1rem;
  border-radius: 16px;
  background: var(--panel, rgba(255, 255, 255, 0.05));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.quick-access-featured .quick-link strong {
  font-size: 1.02rem;
  letter-spacing: -0.02em;
}

.quick-access-featured .quick-link span {
  line-height: 1.4;
}

.quick-access-featured .quick-link-accent {
  background: linear-gradient(
    145deg,
    rgba(90, 200, 250, 0.12),
    rgba(47, 124, 246, 0.08)
  );
}

body[data-theme="light"] .quick-access-featured .quick-link {
  background: #fff;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.05);
}

body[data-theme="light"] .quick-access-featured .quick-link-accent {
  background: linear-gradient(145deg, rgba(42, 123, 191, 0.08), #fff);
}

/* --- Workspace / calculator shell --- */
.workspace.glass-panel {
  border-radius: clamp(16px, 2vw, 28px);
  padding: clamp(14px, 2vw, 22px);
  border: 1px solid var(--panel-border, rgba(255, 255, 255, 0.1));
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
}

body[data-theme="light"] .workspace.glass-panel {
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.06);
}

.panel-header {
  margin-bottom: 1.1rem;
  gap: 12px;
  align-items: center;
}

.panel-header h2 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.15rem, 2vw, 1.4rem);
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.panel-header p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--muted, rgba(255, 255, 255, 0.7));
}

.status-chip {
  font-weight: 600;
  font-size: 0.8rem;
  padding: 8px 12px;
  letter-spacing: 0.02em;
}

/* Tabs: horizontal scroll pills feel more modern */
.tab-list {
  gap: 8px;
  margin-bottom: 1rem;
  padding-bottom: 2px;
}

.tab-button {
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: -0.01em;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.12s ease;
}

.tab-button.active,
.tab-button[aria-selected="true"] {
  background: linear-gradient(135deg, var(--accent, #5ac8fa), var(--accent-strong, #2f7cf6));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 22px rgba(47, 124, 246, 0.28);
}

body[data-theme="light"] .tab-button {
  background: #f3f6fb;
  border-color: rgba(15, 23, 42, 0.1);
  color: #1a2b45;
}

body[data-theme="light"] .tab-button.active,
body[data-theme="light"] .tab-button[aria-selected="true"] {
  background: linear-gradient(135deg, #3d8fd6, #2a7bbf);
  color: #fff;
  border-color: transparent;
}

/* Display + keypad */
.display-card {
  border-radius: 18px;
  padding: clamp(14px, 2vw, 20px);
  gap: 8px;
}

.display-main {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.display-history,
.display-hint {
  font-size: 0.88rem;
  opacity: 0.85;
}

.button-grid {
  gap: 10px;
}

.calc-btn {
  border-radius: 16px;
  font-weight: 600;
  transition: transform 0.1s ease, filter 0.12s ease, background 0.12s ease;
}

.calc-btn:active {
  transform: scale(0.97);
  filter: brightness(1.08);
}

/* --- Tool cards / forms (detail pages) --- */
.tool-card {
  gap: 14px;
  border-radius: 18px;
  padding: clamp(16px, 2.2vw, 22px);
}

.tool-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tool-card label > span,
.tool-card .field > span {
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text-secondary, var(--muted, rgba(255, 255, 255, 0.72)));
}

.tool-card input,
.tool-card select,
.input-card input,
.input-card select,
.calc-textarea {
  min-height: 46px;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 1rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.tool-card input:focus,
.tool-card select:focus,
.input-card input:focus,
.input-card select:focus,
.calc-textarea:focus,
.all-calc-filter-input:focus {
  outline: none;
  border-color: var(--accent, #5ac8fa);
  box-shadow: 0 0 0 3px rgba(90, 200, 250, 0.22);
}

.primary-button,
.secondary-button {
  border-radius: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition:
    transform 0.12s ease,
    filter 0.15s ease,
    background 0.15s ease,
    box-shadow 0.15s ease;
}

.primary-button {
  min-height: 46px;
}

.primary-button.small {
  min-height: 44px;
  border-radius: 12px;
  padding: 10px 16px;
}

.message {
  margin: 0.35rem 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.message.success {
  background: rgba(126, 231, 135, 0.1);
  border-color: rgba(126, 231, 135, 0.28);
  color: var(--success, #7ee787);
  font-weight: 600;
}

.message.error {
  background: rgba(255, 123, 114, 0.1);
  border-color: rgba(255, 123, 114, 0.28);
  color: var(--danger, #ff7b72);
  font-weight: 600;
}

body[data-theme="light"] .message {
  background: rgba(15, 23, 42, 0.03);
  border-color: rgba(15, 23, 42, 0.08);
}

body[data-theme="light"] .message.success {
  background: rgba(23, 99, 42, 0.08);
  border-color: rgba(23, 99, 42, 0.18);
  color: #17632a;
}

body[data-theme="light"] .message.error {
  background: rgba(180, 35, 24, 0.06);
  border-color: rgba(180, 35, 24, 0.16);
  color: #b42318;
}

.result-note,
.calc-disclaimer {
  font-size: 0.84rem !important;
  line-height: 1.45;
  opacity: 0.8 !important;
}

/* --- Highlights / content / FAQ --- */
.calc-highlights {
  gap: 12px;
  margin-top: 1.15rem;
}

.highlight-card {
  border-radius: 16px;
  padding: clamp(14px, 2vw, 20px);
  border: 1px solid var(--panel-border, rgba(255, 255, 255, 0.1));
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.highlight-card h3 {
  margin: 0 0 0.45rem;
  font-size: 1.02rem;
  letter-spacing: -0.015em;
}

.highlight-card p {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--muted, rgba(255, 255, 255, 0.75));
}

.related-links {
  gap: 8px;
}

.related-links a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.related-links a:hover {
  border-color: var(--accent, #5ac8fa);
  background: rgba(90, 200, 250, 0.1);
  text-decoration: none;
  opacity: 1;
}

body[data-theme="light"] .related-links a {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.12);
  color: #10203a;
}

.calc-content {
  margin-top: 1.35rem;
  padding: clamp(4px, 1vw, 8px) 2px;
  line-height: 1.7;
}

.calc-content h2 {
  margin: 0 0 0.65rem;
  font-size: clamp(1.15rem, 2vw, 1.4rem);
  letter-spacing: -0.02em;
}

.calc-content p {
  margin: 0 0 0.85rem;
  color: var(--text-secondary, var(--muted, rgba(255, 255, 255, 0.78)));
}

.calc-content a {
  color: var(--accent, #7c9cff);
  text-underline-offset: 2px;
}

.faq-section {
  margin-top: 1.5rem;
}

.faq-item {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.faq-item summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

body[data-theme="light"] .faq-item {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.1);
}

/* --- Breadcrumb --- */
.breadcrumb-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  margin-bottom: 12px;
  font-size: 0.86rem;
  line-height: 1.3;
}

.breadcrumb-nav a {
  min-height: 36px;
  padding: 4px 2px;
  border-radius: 6px;
}

.breadcrumb-nav a:hover {
  color: var(--accent, #5ac8fa);
}

.breadcrumb-current {
  font-weight: 600;
  opacity: 0.95;
}

/* --- All calculators filter --- */
.all-calc-filter-input {
  border-radius: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.all-calc-chip {
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, transform 0.1s ease;
}

.all-calc-chip:active {
  transform: scale(0.97);
}

.all-calc-grid-filterable .all-calc-link {
  border-radius: 12px;
  transition: border-color 0.12s ease, transform 0.12s ease, background 0.12s ease;
}

.all-calc-grid-filterable .all-calc-link:hover {
  transform: translateY(-1px);
}

/* --- Footer --- */
.site-footer {
  margin-top: clamp(28px, 4vw, 44px);
  padding-top: clamp(18px, 3vw, 28px);
  gap: 16px;
  border-top: 1px solid var(--panel-border, rgba(255, 255, 255, 0.1));
}

.site-footer p {
  margin: 0;
  line-height: 1.55;
  font-size: 0.9rem;
  color: var(--muted, rgba(255, 255, 255, 0.7));
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.footer-nav a {
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  opacity: 0.88;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  transition: opacity 0.12s ease, color 0.12s ease;
}

.footer-nav a:hover {
  opacity: 1;
  color: var(--accent, #5ac8fa);
}

/* --- Ads less intrusive --- */
.ad-section {
  margin-top: 1.4rem;
  margin-bottom: 1.4rem;
}

.ad-card {
  border-radius: 16px;
  overflow: hidden;
}

/* --- Selection + text rendering --- */
::selection {
  background: rgba(90, 200, 250, 0.35);
  color: inherit;
}

body {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Mobile polish refinements --- */
@media (max-width: 768px) {
  .hero:not(.hero-compact) h1 {
    max-width: none;
    font-size: clamp(1.45rem, 6.2vw, 1.85rem);
  }

  .hero:not(.hero-compact) p {
    width: 100%;
    font-size: 0.95rem;
  }

  .workspace.glass-panel {
    padding: 12px;
    border-radius: 18px;
  }

  .tab-list {
    margin-left: -2px;
    margin-right: -2px;
    padding-left: 2px;
    padding-right: 2px;
  }

  .tab-button {
    padding: 10px 14px;
    font-size: 0.9rem;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .display-card {
    min-height: 0 !important;
  }

  .calc-btn {
    min-height: 52px;
    font-size: 1.15rem;
    border-radius: 14px;
  }

  .tool-card {
    padding: 14px;
    gap: 12px;
  }

  .primary-button,
  .secondary-button {
    border-radius: 12px;
  }

  .quick-access-featured .quick-link {
    min-height: 80px;
    padding: 0.9rem 1rem;
  }

  .highlight-card {
    padding: 14px;
  }

  .message {
    padding: 11px 12px;
    font-size: 0.92rem;
  }

  /* Menu open: nicer stacked list */
  .site-header.menu-open .site-nav a {
    border-radius: 12px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.04);
    margin-bottom: 4px;
  }

  body[data-theme="light"] .site-header.menu-open .site-nav a {
    background: rgba(15, 23, 42, 0.04);
  }
}

@media (max-width: 480px) {
  .app-shell {
    padding-top: 14px;
    padding-bottom: 28px;
  }

  .hero-compact h1 {
    font-size: 1.4rem;
    line-height: 1.22;
  }

  .hero-compact .hero-lead {
    font-size: 0.92rem;
  }

  .trust-strip li {
    font-size: 0.8rem;
    padding: 0.35rem 0.6rem;
  }

  .calc-btn {
    min-height: 52px;
    font-size: 1.08rem;
    border-radius: 12px;
  }

  .button-grid {
    gap: 8px;
  }

  .site-footer {
    margin-top: 24px;
    padding-top: 16px;
  }

  .tab-list {
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  .tab-button {
    scroll-snap-align: start;
    min-height: 44px;
  }

  .tool-card input,
  .tool-card select,
  .input-card input {
    min-height: 48px;
    padding: 14px 16px;
  }

  .primary-button,
  .secondary-button {
    min-height: 48px;
  }
}

/* Desktop hover polish (already gated, extend slightly) */
@media (hover: hover) and (pointer: fine) {
  .quick-access-featured .quick-link:hover {
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
  }

  body[data-theme="light"] .quick-access-featured .quick-link:hover {
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.1);
  }

  .highlight-card:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
  }

  .tab-button:hover:not(.active):not([aria-selected="true"]) {
    border-color: rgba(90, 200, 250, 0.35);
    background: rgba(90, 200, 250, 0.08);
    border-bottom: 3px solid rgba(90, 200, 250, 0.2);
  }

  .nav-cta:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
  }

  .tool-card:hover {
    transform: translateY(-2px);
  }

  .history-item:hover {
    transform: translateY(-1px);
    border-color: rgba(90, 200, 250, 0.3);
  }

  .brand:hover {
    filter: brightness(1.1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .quick-access-featured .quick-link,
  .highlight-card,
  .calc-btn,
  .tab-button,
  .primary-button,
  .secondary-button,
  .all-calc-chip,
  .all-calc-link {
    transition: none !important;
    transform: none !important;
  }
}

/* === Homepage clarity: catalog cards + examples === */
.examples-strip{
  display:flex;flex-wrap:wrap;align-items:center;gap:8px;
  margin:0 0 1rem;padding:0.65rem 0.85rem;
  border-radius:14px;
  background:var(--panel,rgba(255,255,255,.05));
  border:1px solid var(--panel-border,rgba(255,255,255,.1));
}
.examples-label{font-size:0.82rem;font-weight:700;color:var(--muted);margin-right:2px;}
.example-chip{
  appearance:none;border:1px solid var(--panel-border,rgba(255,255,255,.12));
  background:rgba(255,255,255,.06);color:var(--text);
  border-radius:999px;padding:0.4rem 0.75rem;min-height:36px;
  font-size:0.86rem;font-weight:600;cursor:pointer;
  text-decoration:none;display:inline-flex;align-items:center;
  transition:transform .15s ease,border-color .15s ease,background .15s ease;
}
.example-chip:hover{transform:translateY(-1px);border-color:var(--accent);background:rgba(90,200,250,.12);}
.example-chip-link{background:rgba(90,200,250,.12);border-color:rgba(90,200,250,.35);color:var(--accent-strong,var(--accent));}
body[data-theme="light"] .examples-strip{background:rgba(16,32,58,.03);border-color:rgba(16,32,58,.1);}
body[data-theme="light"] .example-chip{background:#fff;border-color:rgba(16,32,58,.12);box-shadow:0 1px 0 rgba(16,32,58,.04);}
body[data-theme="light"] .example-chip:hover{background:rgba(47,124,246,.06);}

.catalog-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:14px;
}
.catalog-card{
  display:flex;flex-direction:column;gap:0.45rem;
  text-decoration:none;color:var(--text);
  padding:1.05rem 1.1rem;min-height:132px;
  border-radius:16px;
  border:1px solid var(--panel-border,rgba(255,255,255,.1));
  background:var(--panel,rgba(15,23,42,.55));
  box-shadow:var(--shadow-sm,0 8px 24px rgba(0,0,0,.08));
  transition:transform .15s ease,border-color .15s ease,box-shadow .15s ease;
}
.catalog-card:hover{
  transform:translateY(-2px);
  border-color:var(--accent);
  box-shadow:0 12px 28px rgba(47,124,246,.14);
}
.catalog-card h3{margin:0;font-size:1.02rem;letter-spacing:-.02em;line-height:1.25;}
.catalog-card p{margin:0;flex:1;font-size:0.88rem;line-height:1.45;color:var(--muted);}
.catalog-tag{
  align-self:flex-start;
  font-size:0.72rem;font-weight:700;letter-spacing:.04em;text-transform:uppercase;
  padding:0.22rem 0.55rem;border-radius:999px;
  background:rgba(90,200,250,.14);color:var(--accent);
}
.catalog-cta{
  margin-top:0.25rem;font-size:0.86rem;font-weight:700;color:var(--accent);
}
.catalog-footnote{margin:1rem 0 0;font-size:0.9rem;color:var(--muted);}
.catalog-footnote a{color:var(--accent);font-weight:600;}

body[data-theme="light"] .catalog-card{
  background:#fff;
  border-color:rgba(16,32,58,.1);
  box-shadow:0 8px 20px rgba(16,32,58,.06);
}
body[data-theme="light"] .catalog-card:hover{
  border-color:rgba(47,124,246,.45);
  box-shadow:0 14px 28px rgba(47,124,246,.12);
}
body[data-theme="light"] .catalog-card p{color:rgba(16,32,58,.68);}
body[data-theme="light"] .catalog-tag{background:rgba(47,124,246,.1);color:#1a5fa0;}

/* Workspace: keep basic calc as hero product */
#workspace .tab-list{margin-bottom:1rem;}
#workspace .panel-header p{max-width:62ch;}
#tool-directory,#all-calculators{scroll-margin-top:88px;}

/* Stronger light-mode surfaces for first-visit clarity */
body[data-theme="light"] .workspace.glass-panel,
body[data-theme="light"] .site-header.glass-panel{
  background:rgba(255,255,255,.9);
  border-color:rgba(16,32,58,.08);
}
body[data-theme="light"] .display-card,
body[data-theme="light"] .history-card{
  background:#fff;
  border:1px solid rgba(16,32,58,.08);
}

@media (max-width: 960px){
  .catalog-grid{grid-template-columns:repeat(2,minmax(0,1fr));}
}
@media (max-width: 560px){
  .catalog-grid{grid-template-columns:1fr;}
  .examples-strip{padding:0.55rem 0.65rem;}
  .example-chip{font-size:0.8rem;padding:0.35rem 0.65rem;}
  .catalog-card{min-height:0;}
}

/* === Tool page guide panels === */
.tool-guide{margin:1.25rem 0 1.5rem;}
.tool-guide-grid{
  display:grid;
  grid-template-columns:1.1fr 0.9fr;
  gap:14px;
}
.tool-guide-card{
  padding:1.15rem 1.2rem;
  border-radius:16px;
  border:1px solid var(--panel-border,rgba(255,255,255,.1));
  background:var(--panel,rgba(15,23,42,.55));
}
.tool-guide-card h2{
  margin:0 0 0.45rem;
  font-size:1.15rem;
  letter-spacing:-.02em;
}
.tool-guide-lead{
  margin:0 0 0.75rem;
  color:var(--muted);
  font-size:0.92rem;
  line-height:1.5;
}
.example-fill-row{
  display:flex;flex-wrap:wrap;gap:8px;
  margin-bottom:0.9rem;
}
.example-fill{
  appearance:none;cursor:pointer;
  border:1px solid var(--panel-border,rgba(255,255,255,.12));
  background:rgba(255,255,255,.06);
  color:var(--text);
  border-radius:999px;
  padding:0.45rem 0.8rem;
  min-height:40px;
  font-size:0.86rem;
  font-weight:600;
  transition:transform .15s ease,border-color .15s ease,background .15s ease;
}
.example-fill:hover{
  transform:translateY(-1px);
  border-color:var(--accent);
  background:rgba(90,200,250,.12);
}
.formula-box{
  margin-top:0.35rem;
  padding:0.85rem 0.95rem;
  border-radius:12px;
  border:1px dashed rgba(90,200,250,.35);
  background:rgba(90,200,250,.08);
}
.formula-box h3{margin:0 0 0.35rem;font-size:0.95rem;color:var(--accent);}
.formula-box p{margin:0 0 0.35rem;font-size:0.9rem;line-height:1.5;color:var(--text-secondary,var(--muted));}
.formula-box p:last-child{margin-bottom:0;}
.mistake-list{
  margin:0 0 0.85rem;
  padding-left:1.15rem;
  color:var(--text-secondary,var(--muted));
  line-height:1.55;
  font-size:0.92rem;
}
.mistake-list li{margin-bottom:0.4rem;}
.mistake-list a{color:var(--accent);font-weight:600;}
.scope-note{
  margin:0;
  padding:0.75rem 0.85rem;
  border-radius:12px;
  background:rgba(255,123,114,.08);
  border:1px solid rgba(255,123,114,.18);
  color:var(--text-secondary,var(--muted));
  font-size:0.88rem;
  line-height:1.5;
}
.scope-note a{color:var(--accent);font-weight:600;}
.tool-hero-trust{
  margin:0.65rem 0 0 !important;
  font-size:0.86rem !important;
  color:var(--muted) !important;
  letter-spacing:.02em;
}

body[data-theme="light"] .tool-guide-card{
  background:#fff;
  border-color:rgba(16,32,58,.1);
  box-shadow:0 8px 20px rgba(16,32,58,.05);
}
body[data-theme="light"] .example-fill{
  background:#fff;
  border-color:rgba(16,32,58,.12);
}
body[data-theme="light"] .example-fill:hover{
  background:rgba(47,124,246,.06);
}
body[data-theme="light"] .formula-box{
  background:rgba(47,124,246,.06);
  border-color:rgba(47,124,246,.25);
}
body[data-theme="light"] .scope-note{
  background:rgba(217,64,64,.06);
  border-color:rgba(217,64,64,.15);
}

@media (max-width: 900px){
  .tool-guide-grid{grid-template-columns:1fr;}
}
@media (max-width: 560px){
  .example-fill{width:100%;justify-content:center;}
  .tool-guide-card{padding:1rem;}
}

/* === Header / page cleanliness (final overrides) === */
.site-header .search-input-wrapper input {
  min-height: 40px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.hero-compact {
  margin-bottom: 1.1rem;
}

.hero-compact .hero-topbar {
  justify-content: center;
}

.hero-compact .eyebrow {
  margin: 0 auto;
}

.quick-access-featured {
  margin-bottom: 1.15rem;
}

.site-footer {
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.site-footer > div strong {
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.footer-also-try {
  font-size: 0.84rem;
  line-height: 1.55;
  opacity: 0.9;
}

.footer-also-try a {
  white-space: nowrap;
}

/* ==========================================================================
   Homepage directory + section polish (less "Word doc", more product UI)
   ========================================================================== */

/* Shared section heads */
.section-head {
  margin: 0 0 1.15rem;
  max-width: 40rem;
}

.section-head-center {
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.section-head .eyebrow {
  display: inline-block;
  margin-bottom: 0.55rem;
}

.section-head h2 {
  margin: 0 0 0.45rem;
  font-size: clamp(1.45rem, 2.4vw, 1.85rem);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.section-lead {
  margin: 0;
  color: var(--muted, rgba(255, 255, 255, 0.72));
  font-size: 0.98rem;
  line-height: 1.55;
}

body[data-theme="light"] .section-lead {
  color: rgba(16, 32, 58, 0.72);
}

/* Value props (Why CalcSolver) */
.value-section {
  margin: 1.75rem 0 1.5rem;
}

.value-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.value-card {
  padding: 1.15rem 1.2rem;
  border-radius: 16px;
  border: 1px solid var(--panel-border, rgba(255, 255, 255, 0.1));
  min-height: 140px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.value-card:hover {
  transform: translateY(-2px);
  border-color: rgba(90, 200, 250, 0.35);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
}

.value-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent, #5ac8fa);
  background: rgba(90, 200, 250, 0.12);
  margin-bottom: 0.25rem;
}

.value-card h3 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.value-card p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted, rgba(255, 255, 255, 0.7));
}

body[data-theme="light"] .value-card {
  background: #fff;
  border-color: rgba(16, 32, 58, 0.1);
  box-shadow: 0 6px 18px rgba(16, 32, 58, 0.04);
}

body[data-theme="light"] .value-card p {
  color: rgba(16, 32, 58, 0.68);
}

body[data-theme="light"] .value-icon {
  background: rgba(42, 123, 191, 0.1);
  color: #1a5fa0;
}

/* All Calculators directory */
.directory-section {
  margin: 1.75rem 0 1.25rem;
  padding: 1.35rem 1.4rem 1.25rem;
  border-radius: 20px;
  border: 1px solid var(--panel-border, rgba(255, 255, 255, 0.1));
  background: var(--panel, rgba(15, 23, 42, 0.45));
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

body[data-theme="light"] .directory-section {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(16, 32, 58, 0.08);
  box-shadow: 0 12px 36px rgba(16, 32, 58, 0.06);
}

.directory-section .section-head {
  margin-bottom: 1rem;
}

.directory-section .all-calc-toolbar {
  margin: 0 0 1.15rem;
  padding: 0.85rem 0.95rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  gap: 0.7rem;
}

body[data-theme="light"] .directory-section .all-calc-toolbar {
  background: rgba(16, 32, 58, 0.03);
  border-color: rgba(16, 32, 58, 0.08);
}

.directory-section .all-calc-filter-input {
  flex: 1 1 240px;
  min-height: 44px;
  border-radius: 12px;
  font-size: 0.95rem;
}

.directory-section .all-calc-count {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(90, 200, 250, 0.12);
  color: var(--accent, #5ac8fa);
  opacity: 1;
}

body[data-theme="light"] .directory-section .all-calc-count {
  background: rgba(42, 123, 191, 0.1);
  color: #1a5fa0;
}

.directory-section .all-calc-chips {
  gap: 6px;
}

.directory-section .all-calc-chip {
  min-height: 36px;
  padding: 0.35rem 0.85rem;
  font-size: 0.84rem;
  border-radius: 999px;
}

.directory-section .all-calc-grid-filterable {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.directory-section .all-calc-group {
  padding: 0;
  border: 0;
  background: transparent;
}

.directory-section .all-calc-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 0.7rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

body[data-theme="light"] .directory-section .all-calc-group-head {
  border-bottom-color: rgba(16, 32, 58, 0.08);
}

.directory-section .all-calc-group-head h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

.directory-section .all-calc-group-count {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted, rgba(255, 255, 255, 0.55));
  white-space: nowrap;
}

/* Card-style tool tiles in a responsive grid */
.directory-section .all-calc-links {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.directory-section .all-calc-grid-filterable .all-calc-link {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  text-decoration: none;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: none;
  transition:
    transform 0.12s ease,
    border-color 0.12s ease,
    background 0.12s ease,
    box-shadow 0.12s ease;
}

.directory-section .all-calc-grid-filterable .all-calc-link:hover {
  transform: translateY(-1px);
  border-color: var(--accent, #5ac8fa);
  background: rgba(90, 200, 250, 0.1);
  box-shadow: 0 8px 20px rgba(90, 200, 250, 0.08);
}

.directory-section .all-calc-grid-filterable .all-calc-link:focus-visible {
  outline: 2px solid var(--accent, #5ac8fa);
  outline-offset: 2px;
}

body[data-theme="light"] .directory-section .all-calc-grid-filterable .all-calc-link {
  background: #fff;
  border-color: rgba(16, 32, 58, 0.1);
  color: #10203a;
  box-shadow: 0 2px 8px rgba(16, 32, 58, 0.03);
}

body[data-theme="light"] .directory-section .all-calc-grid-filterable .all-calc-link:hover {
  background: rgba(47, 124, 246, 0.05);
  border-color: rgba(42, 123, 191, 0.45);
  box-shadow: 0 8px 18px rgba(42, 123, 191, 0.08);
}

.directory-section .all-calc-empty {
  margin: 0.25rem 0 0;
  padding: 1rem;
  text-align: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.92rem;
}

.directory-section .all-calc-footnote {
  margin: 1.1rem 0 0;
  text-align: center;
  font-size: 0.9rem;
}

.directory-section .all-calc-footnote a {
  font-weight: 600;
  text-decoration: none;
  color: var(--accent, #7c9cff);
}

.directory-section .all-calc-footnote a:hover {
  text-decoration: underline;
}

/* About: compact cards instead of long essay */
.about-calcSolver {
  margin: 1.5rem 0 1.25rem;
}

.about-cs-inner {
  padding: 1.35rem 1.4rem 1.25rem;
  border-radius: 20px;
}

.about-cs-inner .eyebrow {
  display: inline-block;
  margin-bottom: 0.5rem;
}

.about-cs-inner h2 {
  margin: 0 0 0.4rem;
  font-size: clamp(1.35rem, 2.2vw, 1.7rem);
  letter-spacing: -0.03em;
}

.about-lead {
  margin: 0 0 1rem;
  max-width: 48ch;
  color: var(--muted, rgba(255, 255, 255, 0.72));
  font-size: 0.98rem;
  line-height: 1.55;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 1rem;
}

.about-card {
  padding: 0.9rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  min-height: 96px;
}

.about-card strong {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
}

.about-card p {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--muted, rgba(255, 255, 255, 0.68));
}

.about-card a {
  color: var(--accent, #5ac8fa);
  font-weight: 600;
  text-decoration: none;
}

.about-card a:hover {
  text-decoration: underline;
}

.about-more {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.about-more a {
  color: var(--accent, #5ac8fa);
  font-weight: 600;
  text-decoration: none;
}

.about-more a:hover {
  text-decoration: underline;
}

body[data-theme="light"] .about-lead {
  color: rgba(16, 32, 58, 0.72);
}

body[data-theme="light"] .about-card {
  background: #fff;
  border-color: rgba(16, 32, 58, 0.1);
  box-shadow: 0 4px 12px rgba(16, 32, 58, 0.04);
}

body[data-theme="light"] .about-card p {
  color: rgba(16, 32, 58, 0.68);
}

/* Footer: clean product footer, no outbound promo links */
.site-footer {
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  margin-top: clamp(24px, 4vw, 40px);
  padding: 1.25rem 0 0.5rem;
  border-top: 1px solid var(--panel-border, rgba(255, 255, 255, 0.1));
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.footer-brand strong {
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.footer-brand span {
  font-size: 0.88rem;
  color: var(--muted, rgba(255, 255, 255, 0.65));
}

.site-footer .footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 4px;
  justify-content: flex-start;
  margin: 0;
}

.site-footer .footer-nav a {
  min-height: 36px;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  opacity: 0.9;
}

.site-footer .footer-nav a:hover {
  opacity: 1;
  background: rgba(90, 200, 250, 0.08);
}

.footer-copy {
  margin: 0 !important;
  font-size: 0.8rem !important;
  color: var(--muted, rgba(255, 255, 255, 0.55)) !important;
}

.footer-also-try,
.footer-url {
  display: none !important;
}

@media (max-width: 1024px) {
  .directory-section .all-calc-links {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .about-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .directory-section {
    padding: 1.1rem 1rem 1rem;
    border-radius: 16px;
  }

  .directory-section .all-calc-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .about-cs-inner {
    padding: 1.1rem 1rem;
  }

  .about-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .directory-section .all-calc-links {
    grid-template-columns: 1fr;
  }

  .directory-section .all-calc-toolbar-top {
    flex-direction: column;
    align-items: stretch;
  }

  .directory-section .all-calc-count {
    align-self: flex-start;
  }

  .about-grid {
    grid-template-columns: 1fr;
  }
}

/* Desktop header: prevent action buttons from wrapping awkwardly */
@media (min-width: 901px) {
  .site-header {
    flex-wrap: nowrap;
  }

  .site-header .menu-toggle {
    display: none !important;
  }

  .site-header .site-nav {
    display: flex !important;
  }

  .site-header .header-actions {
    display: flex !important;
    flex-wrap: nowrap;
  }

  .site-header .header-actions .theme-toggle,
  .site-header .header-actions .language-select,
  .site-header .header-actions .help-trigger {
    display: inline-flex !important;
  }

  .site-header .header-actions .language-select {
    display: block !important;
  }
}
