/* Aether Calc Studio — Mobile-First Design System */
:root {
  --surface: #f5fafc;
  --surface-dim: #d6dbdd;
  --surface-bright: #f5fafc;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #eff4f6;
  --surface-container: #eaeff1;
  --surface-container-high: #e4e9eb;
  --surface-container-highest: #dee3e5;
  --on-surface: #171c1e;
  --on-surface-variant: #44474b;
  --inverse-surface: #2c3133;
  --inverse-on-surface: #ecf1f3;
  --outline: #75777b;
  --outline-variant: #c5c6cb;
  --primary: #000000;
  --on-primary: #ffffff;
  --primary-container: #141c24;
  --on-primary-container: #7c858f;
  --secondary: #4b6176;
  --on-secondary: #ffffff;
  --secondary-container: #cbe2fc;
  --on-secondary-container: #4f657b;
  --tertiary-container: #001e2e;
  --error: #ba1a1a;
  --error-container: #ffdad6;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-pill: 9999px;
  --shadow-sm: 0 2px 8px rgba(23, 28, 30, 0.04);
  --shadow-md: 0 8px 24px rgba(23, 28, 30, 0.06);
  --shadow-float: 0 12px 32px rgba(23, 28, 30, 0.12);
  --nav-height-mobile: 64px;
  --bottom-nav-height: 76px;
}

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

html {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--surface);
  color: var(--on-surface);
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  background: var(--surface);
  color: var(--on-surface);
  padding-bottom: calc(var(--bottom-nav-height) + 16px);
  min-height: 100vh;
}

.tabular { font-variant-numeric: tabular-nums; }

a { color: inherit; text-decoration: none; }

button, input, select {
  font-family: inherit;
  color: inherit;
}

/* Container */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Top Header (Mobile-First App Bar) */
.top-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(245, 250, 252, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(197, 198, 203, 0.35);
}

.top-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-height-mobile);
  gap: 12px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--primary);
  color: var(--on-primary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-kicker {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
}

.brand-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--on-surface);
}

.desktop-nav {
  display: none;
  align-items: center;
  gap: 6px;
}

.desktop-nav a {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  color: var(--on-surface-variant);
  transition: background 0.15s, color 0.15s;
}

.desktop-nav a:hover {
  background: var(--surface-container);
  color: var(--on-surface);
}

.desktop-nav a.active {
  background: var(--primary);
  color: var(--on-primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(197, 198, 203, 0.45);
  background: var(--surface-container-lowest);
  color: var(--on-surface);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s;
}

.icon-btn:hover { background: var(--surface-container); }

.icon-btn.dark {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}

/* Segmented Control */
.segmented {
  display: flex;
  background: var(--surface-container);
  padding: 4px;
  border-radius: var(--radius-pill);
  gap: 4px;
}

.segmented button, .segmented a {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface-variant);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.segmented button.active, .segmented a.active {
  background: var(--surface-container-lowest);
  color: var(--on-surface);
  box-shadow: var(--shadow-sm);
}

/* Cards */
.card {
  background: var(--surface-container-lowest);
  border-radius: var(--radius-lg);
  padding: 18px;
  border: 1px solid rgba(197, 198, 203, 0.35);
  box-shadow: var(--shadow-sm);
}

.card-subtle {
  background: var(--surface-container-low);
  border-radius: var(--radius-md);
  padding: 14px;
}

/* Calculator Display & Keypad (Mobile Inspo Priority) */
.calc-display-card {
  background: var(--surface-container-lowest);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  border: 1px solid rgba(197, 198, 203, 0.35);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 138px;
}

.calc-display-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tape-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  background: var(--surface-container-low);
  font-size: 12px;
  font-weight: 600;
  color: var(--on-surface-variant);
  border: none;
  cursor: pointer;
}

.calc-expr {
  text-align: right;
  font-size: 14px;
  color: var(--on-surface-variant);
  min-height: 20px;
  margin-top: 10px;
}

.calc-value {
  text-align: right;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--on-surface);
  overflow: hidden;
  text-overflow: ellipsis;
}

.keypad-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 0.76fr;
  gap: 10px;
  margin-top: 14px;
}

.key-btn {
  height: 58px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(197, 198, 203, 0.35);
  background: var(--surface-container-lowest);
  color: var(--on-surface);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.08s, background 0.12s;
  user-select: none;
}

.key-btn:active { transform: scale(0.96); }

.key-btn.fn {
  background: var(--surface-container-low);
  font-size: 16px;
  font-weight: 600;
}

.key-btn.op {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
  font-size: 22px;
}

.key-btn.span-2 {
  grid-column: span 2;
  justify-content: start;
  padding-left: 24px;
}

/* Horizontal Quick Tools Strip */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px 0 12px;
}

.section-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.h-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}

.h-scroll::-webkit-scrollbar { display: none; }

.quick-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-container-lowest);
  border: 1px solid rgba(197, 198, 203, 0.4);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  min-width: 158px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.quick-chip:hover { border-color: var(--primary); }

.quick-chip-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

/* Search Input */
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-container-lowest);
  border: 1px solid rgba(197, 198, 203, 0.55);
  border-radius: var(--radius-pill);
  padding: 10px 16px;
  box-shadow: var(--shadow-sm);
}

.search-box input {
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  font-size: 14px;
}

/* Filter Pills */
.pill-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: none;
}
.pill-row::-webkit-scrollbar { display: none; }

.pill {
  flex: 0 0 auto;
  padding: 8px 15px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(197, 198, 203, 0.45);
  background: var(--surface-container-lowest);
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface-variant);
  cursor: pointer;
  transition: all 0.15s;
}

.pill.active {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}

/* Tool List Row (Mobile Directory & Finance Hub) */
.tool-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.tool-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-container-lowest);
  border: 1px solid rgba(197, 198, 203, 0.35);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  transition: transform 0.12s, border-color 0.15s;
}

.tool-row:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.tool-row-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.tool-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface-container-low);
  color: var(--secondary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-weight: 700;
}

.tool-meta {
  min-width: 0;
}

.tool-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--on-surface);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tool-desc {
  font-size: 12px;
  color: var(--on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-container);
  color: var(--on-surface-variant);
}

.badge.blue {
  background: var(--secondary-container);
  color: var(--on-secondary-container);
}

/* Primary CTA Button */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--radius-pill);
  padding: 13px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.9; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface-container-low);
  color: var(--on-surface);
  border: 1px solid rgba(197, 198, 203, 0.45);
  border-radius: var(--radius-pill);
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* Dark Analytical Banner */
.dark-banner {
  background: var(--primary-container);
  color: var(--on-primary);
  border-radius: var(--radius-xl);
  padding: 28px 22px;
  margin-top: 28px;
}

.dark-banner p { color: #b7c2cc; line-height: 1.55; }

/* Footer */
.site-footer {
  margin-top: 40px;
  padding: 28px 0 20px;
  border-top: 1px solid rgba(197, 198, 203, 0.45);
  color: var(--on-surface-variant);
  font-size: 13px;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.footer-col h4 {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--on-surface);
}

.footer-col a {
  display: block;
  padding: 4px 0;
  font-size: 13px;
  color: var(--on-surface-variant);
}

.footer-col a:hover { color: var(--on-surface); }

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid rgba(197, 198, 203, 0.35);
  font-size: 12px;
}

/* Sticky Mobile Bottom Navigation (Exact Inspo Match) */
.bottom-nav {
  position: fixed;
  bottom: 12px;
  left: 12px;
  right: 12px;
  z-index: 50;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(197, 198, 203, 0.45);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-float);
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.bottom-nav a, .bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: 18px;
  border: none;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  color: var(--on-surface-variant);
  cursor: pointer;
}

.bottom-nav a.active, .bottom-nav button.active {
  background: var(--primary);
  color: var(--on-primary);
}

/* Responsive Desktop Enhancements */
@media (min-width: 768px) {
  body { padding-bottom: 32px; }
  .bottom-nav { display: none; }
  .desktop-nav { display: flex; }
  .tool-list { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: repeat(4, 1fr); }
  .two-col-desktop {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 20px;
    align-items: start;
  }
}

@media (min-width: 1024px) {
  .tool-list.three-col { grid-template-columns: repeat(3, 1fr); }
}

/* Quick Tools Stacked Grid (No Horizontal Scroll) */
.quick-tools-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
@media (min-width: 640px) {
  .quick-tools-grid { grid-template-columns: repeat(3, 1fr); }
}
.quick-chip-clean {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  background: var(--surface-container-lowest);
  border: 1px solid rgba(197, 198, 203, 0.45);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  text-align: left;
}
.quick-chip-clean:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}
.tool-row {
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.tool-row:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

/* 13-Domain Category Sub-Nav Bar (Mobile & PC) */
.cat-nav-bar {
  background: rgba(255, 255, 255, 0.72);
  border-bottom: 1px solid rgba(197, 198, 203, 0.35);
  overflow-x: auto;
  scrollbar-width: none;
}
.cat-nav-bar::-webkit-scrollbar { display: none; }
.cat-nav-inner {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  max-width: 1200px;
  margin: 0 auto;
}
.cat-nav-link {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--on-surface-variant);
  padding: 5px 11px;
  border-radius: var(--radius-pill);
  background: var(--surface-container-low);
  transition: background 0.15s, color 0.15s;
}
.cat-nav-link:hover {
  background: var(--primary);
  color: var(--on-primary);
}

/* Scientific Extra Keys */
.sci-row {
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
}
.sci-row.visible { display: grid; }
.sci-btn {
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(197, 198, 203, 0.4);
  background: var(--surface-container-low);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.sci-btn:hover { background: var(--primary); color: var(--on-primary); }

/* Hide tool monogram icons */
.tool-icon { display: none !important; }

/* Spacing polish & 13-Category Pre-Footer Section */
.section-header { margin: 28px 0 14px; }
.tool-list { gap: 12px; }
.quick-tools-grid { gap: 10px; }

.cat-footer-section {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid rgba(197, 198, 203, 0.35);
}
.cat-footer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.cat-footer-grid .cat-nav-link {
  padding: 8px 14px;
  font-size: 13px;
}

/* Premium Bottom Anchor Bar & Dark Mode */
[data-theme="dark"] {
  --surface: #0d1117;
  --surface-dim: #090c10;
  --surface-bright: #161b22;
  --surface-container-lowest: #161b22;
  --surface-container-low: #1c222b;
  --surface-container: #222933;
  --surface-container-high: #2a323e;
  --on-surface: #f0f6fc;
  --on-surface-variant: #9aa6b2;
  --primary: #ffffff;
  --on-primary: #0d1117;
  --secondary: #8ab4f8;
  --secondary-container: #1f334d;
  --on-secondary-container: #cbe2fc;
  --outline-variant: #30363d;
}

[data-theme="dark"] .top-header {
  background: rgba(13, 17, 23, 0.88);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .bottom-nav {
  background: rgba(22, 27, 34, 0.92);
  border-color: rgba(255, 255, 255, 0.1);
}

.bottom-nav {
  max-width: 420px;
  margin: 0 auto;
  padding: 6px;
  border-radius: 26px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.14);
}

.bottom-nav a, .bottom-nav button {
  padding: 9px 6px;
  border-radius: 20px;
  transition: transform 0.12s ease, background 0.15s ease, color 0.15s ease;
}

.bottom-nav a:active, .bottom-nav button:active {
  transform: scale(0.95);
}

/* Full pill / circular bottom anchor bar */
.bottom-nav { border-radius: 9999px !important; }
.bottom-nav a, .bottom-nav button { border-radius: 9999px !important; }

/* Smooth Theme Mode Transition */
html, body, .card, .top-header, .bottom-nav, .tool-row, .key-btn, .calc-display-card, .quick-chip-clean, .search-box, .segmented {
  transition: background-color 0.28s ease, color 0.28s ease, border-color 0.28s ease;
}

/* Compact width for mobile anchor menu */
.bottom-nav {
  max-width: 340px !important;
  padding: 5px 8px !important;
}

/* View Transitions API Circular Theme Reveal (Slower for Smoothness) */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

::view-transition-new(root) {
  animation: theme-circle-reveal 0.85s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes theme-circle-reveal {
  from {
    clip-path: circle(0% at var(--reveal-x, 50%) var(--reveal-y, 50%));
  }
  to {
    clip-path: circle(150% at var(--reveal-x, 50%) var(--reveal-y, 50%));
  }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-new(root) {
    animation: none;
  }
}

/* Restore bottom-nav width & make active item a true circle */
.bottom-nav {
  max-width: 420px !important;
  padding: 6px !important;
  align-items: center;
}
.bottom-nav a.active, .bottom-nav button.active {
  width: 56px;
  height: 56px;
  border-radius: 50% !important;
  margin: 0 auto;
  padding: 0;
}

/* Clean proportional active pill in bottom-nav */
.bottom-nav a.active, .bottom-nav button.active {
  width: 100% !important;
  height: 48px !important;
  border-radius: 9999px !important;
  padding: 6px 12px !important;
}

/* Slate-blue operator keys & icon-only mobile anchor menu */
.key-btn.op {
  background: #4b6176 !important;
  border-color: #4b6176 !important;
  color: #ffffff !important;
}
.key-btn.op:hover {
  background: #33495e !important;
}
.bottom-nav span {
  display: none !important;
}
.bottom-nav a, .bottom-nav button {
  padding: 10px 6px !important;
}

/* Wrap category filter pills naturally without clipping */
.pill-row {
  flex-wrap: wrap !important;
  overflow-x: visible !important;
}

/* Stack calculator title and category badge on separate lines */
.tool-name {
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 6px !important;
}

/* Logo: Calculators.Life only, larger, no subtitle */
.brand-title { display: none !important; }
.brand-kicker {
  font-size: 18px !important;
  font-weight: 700 !important;
  letter-spacing: -0.02em !important;
  text-transform: none !important;
  color: var(--on-surface) !important;
}

/* Experimental Glassmorphism Effect (Light & Dark Mode) */
body {
  background-image:
    radial-gradient(at 15% 15%, rgba(169, 203, 228, 0.45) 0px, transparent 50%),
    radial-gradient(at 85% 30%, rgba(203, 226, 252, 0.5) 0px, transparent 50%),
    radial-gradient(at 50% 85%, rgba(219, 227, 239, 0.4) 0px, transparent 55%) !important;
  background-attachment: fixed;
}

[data-theme="dark"] body {
  background-image:
    radial-gradient(at 15% 15%, rgba(38, 72, 112, 0.38) 0px, transparent 50%),
    radial-gradient(at 85% 30%, rgba(24, 52, 84, 0.35) 0px, transparent 50%),
    radial-gradient(at 50% 85%, rgba(19, 34, 56, 0.35) 0px, transparent 55%) !important;
}

.calc-display-card,
.tool-row,
.quick-chip-clean,
.card,
.key-btn:not(.op) {
  background: rgba(255, 255, 255, 0.62) !important;
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.65) !important;
  box-shadow: 0 8px 24px rgba(23, 28, 30, 0.05) !important;
}

[data-theme="dark"] .calc-display-card,
[data-theme="dark"] .tool-row,
[data-theme="dark"] .quick-chip-clean,
[data-theme="dark"] .card,
[data-theme="dark"] .key-btn:not(.op) {
  background: rgba(22, 27, 34, 0.58) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28) !important;
}

/* Boost Light Mode Glassmorphism visibility */
html:not([data-theme="dark"]) body {
  background-image:
    radial-gradient(at 10% 10%, rgba(125, 185, 232, 0.42) 0px, transparent 50%),
    radial-gradient(at 90% 25%, rgba(169, 203, 228, 0.48) 0px, transparent 50%),
    radial-gradient(at 45% 85%, rgba(185, 212, 238, 0.42) 0px, transparent 55%) !important;
}

html:not([data-theme="dark"]) .calc-display-card,
html:not([data-theme="dark"]) .tool-row,
html:not([data-theme="dark"]) .quick-chip-clean,
html:not([data-theme="dark"]) .card,
html:not([data-theme="dark"]) .key-btn:not(.op) {
  background: rgba(255, 255, 255, 0.48) !important;
  border: 1px solid rgba(255, 255, 255, 0.8) !important;
}

/* Unified Glassmorphic Button & Pill Palette */
.cat-nav-link,
.pill:not(.active),
.btn-secondary,
.tape-pill,
.sci-btn,
.icon-btn {
  background: rgba(255, 255, 255, 0.52) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.78) !important;
  color: var(--on-surface) !important;
}

.cat-nav-link:hover,
.pill.active,
.sci-btn:hover {
  background: #4b6176 !important;
  border-color: #4b6176 !important;
  color: #ffffff !important;
}

[data-theme="dark"] .cat-nav-link,
[data-theme="dark"] .pill:not(.active),
[data-theme="dark"] .btn-secondary,
[data-theme="dark"] .tape-pill,
[data-theme="dark"] .sci-btn,
[data-theme="dark"] .icon-btn {
  background: rgba(22, 27, 34, 0.58) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  color: var(--on-surface) !important;
}

/* Premium Custom Glassmorphic Select Dropdown */
.custom-select-wrap {
  position: relative;
  width: 100%;
}
.custom-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 15px;
  font-weight: 600;
  color: var(--on-surface);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.custom-select-trigger:hover {
  border-color: #4b6176;
}
.custom-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 80;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 16px;
  box-shadow: 0 14px 36px rgba(23, 28, 30, 0.14);
  padding: 6px;
  display: none;
  max-height: 240px;
  overflow-y: auto;
}
.custom-select-wrap.open .custom-select-menu { display: block; }
.custom-select-opt {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--on-surface);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.custom-select-opt:hover, .custom-select-opt.selected {
  background: #4b6176;
  color: #ffffff;
}

[data-theme="dark"] .custom-select-trigger {
  background: rgba(22, 27, 34, 0.62);
  border-color: rgba(255, 255, 255, 0.14);
}
[data-theme="dark"] .custom-select-menu {
  background: rgba(22, 27, 34, 0.92);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
}

/* Lighthouse Accessibility: 44px+ Touch Targets & sr-only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.bottom-nav a, .bottom-nav button, .icon-btn, .pill {
  min-height: 44px;
  min-width: 44px;
}
.cat-nav-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}

/* Dark Mode Premium Polish */
[data-theme="dark"] .card,
[data-theme="dark"] .calc-display-card,
[data-theme="dark"] .tool-row,
[data-theme="dark"] .quick-chip-clean {
  background: rgba(20, 25, 33, 0.68) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), 0 12px 32px rgba(0, 0, 0, 0.42) !important;
}

[data-theme="dark"] .hero-metric-card {
  background: linear-gradient(135deg, #1c2a3a 0%, #0e1621 100%) !important;
  border: 1px solid rgba(138, 180, 248, 0.24) !important;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35) !important;
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .custom-select-trigger,
[data-theme="dark"] .step-box {
  background: rgba(11, 15, 22, 0.75) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .custom-select-trigger:hover {
  border-color: #8ab4f8 !important;
}

/* Deeper Dark Mode Background + Richer Ambient Glows */
[data-theme="dark"] {
  --surface: #06080d;
}
[data-theme="dark"] body {
  background-color: #06080d !important;
  background-image:
    radial-gradient(at 15% 15%, rgba(56, 112, 178, 0.24) 0px, transparent 50%),
    radial-gradient(at 85% 30%, rgba(75, 97, 118, 0.26) 0px, transparent 50%),
    radial-gradient(at 50% 85%, rgba(42, 74, 112, 0.22) 0px, transparent 55%) !important;
}

/* Match input field and custom dropdown colors in Light Mode */
html:not([data-theme="dark"]) .form-group input,
html:not([data-theme="dark"]) .custom-select-trigger {
  background: rgba(255, 255, 255, 0.55) !important;
  border: 1px solid rgba(255, 255, 255, 0.78) !important;
}

/* Ultra-smooth 60fps View Transition (prevent per-element CSS transitions from fighting clip-path) */
html, body, .card, .top-header, .bottom-nav, .tool-row, .key-btn, .calc-display-card, .quick-chip-clean, .search-box, .segmented {
  transition: none !important;
}
::view-transition-new(root) {
  animation: theme-circle-reveal 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards !important;
  will-change: clip-path;
}

/* 120fps Scroll & Render Optimization (Keep glass look, remove heavy per-card blur & fixed bg) */
body {
  background-attachment: scroll !important;
}

.calc-display-card,
.tool-row,
.quick-chip-clean,
.card,
.key-btn:not(.op),
.cat-nav-link,
.pill:not(.active),
.btn-secondary,
.tape-pill,
.sci-btn,
.icon-btn,
.custom-select-trigger {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.top-header,
.bottom-nav,
.custom-select-menu {
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
}

/* Dark Mode Liquid Glass Effect (Specular Edge + Soft Glow, 120fps) */
[data-theme="dark"] .card,
[data-theme="dark"] .calc-display-card,
[data-theme="dark"] .tool-row,
[data-theme="dark"] .quick-chip-clean,
[data-theme="dark"] .key-btn:not(.op) {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%) !important;
  border: 1px solid rgba(255, 255, 255, 0.16) !important;
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.22),
    inset 0 -1px 1px rgba(0, 0, 0, 0.35),
    0 10px 30px rgba(0, 0, 0, 0.45),
    0 0 18px rgba(138, 180, 248, 0.06) !important;
}

[data-theme="dark"] .tool-row:hover,
[data-theme="dark"] .quick-chip-clean:hover {
  border-color: rgba(138, 180, 248, 0.42) !important;
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.28),
    0 12px 32px rgba(0, 0, 0, 0.5),
    0 0 22px rgba(138, 180, 248, 0.14) !important;
}

/* Pause backdrop-filter during View Transition for butter-smooth 120fps reveal */
html.vt-animating .top-header,
html.vt-animating .bottom-nav {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
::view-transition-new(root) {
  animation: theme-circle-reveal 0.42s cubic-bezier(0.22, 1, 0.36, 1) forwards !important;
}

/* Remove theme toggle from mobile bottom anchor bar (3 clean items: Home | Sitemap | Search) */
.bottom-nav [data-theme-toggle] {
  display: none !important;
}
.bottom-nav {
  grid-template-columns: repeat(3, 1fr) !important;
  max-width: 320px !important;
}

/* Larger, more readable footer typography */
.footer-col h4 {
  font-size: 13px !important;
  margin-bottom: 12px !important;
}
.footer-col a {
  font-size: 15px !important;
  padding: 6px 0 !important;
}
.footer-bottom {
  font-size: 14px !important;
}

/* Restore theme toggle in mobile bottom-nav; hide it in top-header on mobile only */
.bottom-nav [data-theme-toggle] {
  display: flex !important;
}
.bottom-nav {
  grid-template-columns: repeat(4, 1fr) !important;
  max-width: 420px !important;
}
@media (max-width: 767px) {
  .top-header [data-theme-toggle] {
    display: none !important;
  }
}

/* Light Mode Liquid Glass Effect (Experimental, 120fps) */
html:not([data-theme="dark"]) .calc-display-card,
html:not([data-theme="dark"]) .key-btn:not(.op),
html:not([data-theme="dark"]) .card,
html:not([data-theme="dark"]) .tool-row,
html:not([data-theme="dark"]) .quick-chip-clean {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.72) 0%, rgba(255, 255, 255, 0.36) 100%) !important;
  border: 1px solid rgba(255, 255, 255, 0.85) !important;
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.95),
    inset 0 -1px 1px rgba(169, 203, 228, 0.22),
    0 10px 28px rgba(75, 97, 118, 0.08) !important;
}

/* More transparency on Light Mode Liquid Glass */
html:not([data-theme="dark"]) .calc-display-card,
html:not([data-theme="dark"]) .key-btn:not(.op),
html:not([data-theme="dark"]) .card,
html:not([data-theme="dark"]) .tool-row,
html:not([data-theme="dark"]) .quick-chip-clean {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.48) 0%, rgba(255, 255, 255, 0.18) 100%) !important;
}

/* Smart Visuals (Proportional Bar, Zone Gauge, Schedule Table) */
#smart-visual-slot { margin: 14px 0 6px; }
.sv-card {
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
[data-theme="dark"] .sv-card {
  background: rgba(11, 15, 22, 0.55);
  border-color: rgba(255, 255, 255, 0.1);
}
.sv-title { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--on-surface-variant); margin-bottom: 8px; }
.sv-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; gap: 2px; margin-bottom: 10px; }
.sv-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12px; }
.sv-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.sv-table-wrap { overflow-x: auto; max-height: 220px; }
.sv-table { width: 100%; border-collapse: collapse; font-size: 12px; text-align: left; }
.sv-table th { padding: 6px 8px; border-bottom: 1px solid rgba(197,198,203,0.4); color: var(--on-surface-variant); font-weight: 600; }
.sv-table td { padding: 6px 8px; border-bottom: 1px solid rgba(197,198,203,0.2); font-variant-numeric: tabular-nums; }

/* Richer, Non-Lean Visuals & Results Deck Polish */
.sv-card {
  padding: 16px 18px !important;
  border-radius: 16px !important;
  border-left: 3px solid #4b6176 !important;
  box-shadow: 0 6px 18px rgba(23, 28, 30, 0.06) !important;
}
.sv-bar {
  height: 14px !important;
  border-radius: 999px !important;
}
.sv-legend {
  font-size: 13px !important;
  font-weight: 500 !important;
}
.step-box {
  padding: 14px 16px !important;
  font-size: 14px !important;
  border: 1px solid rgba(255, 255, 255, 0.65) !important;
  transition: transform 0.14s ease, border-color 0.14s ease;
}
.step-box:hover {
  transform: translateY(-1px);
  border-color: #4b6176 !important;
}
[data-theme="dark"] .sv-card {
  border-left: 3px solid #8ab4f8 !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35) !important;
}

/* Production-Grade 16-Visual Suite Styles */
.sv-card {
  position: relative;
  overflow: hidden;
}
.sv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.sv-header .sv-title { margin-bottom: 0 !important; }
.sv-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(75, 97, 118, 0.14);
  color: var(--on-surface);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
[data-theme="dark"] .sv-pill {
  background: rgba(138, 180, 248, 0.16);
  color: #cbe2fc;
}
.sv-pill.pos { background: rgba(16, 185, 129, 0.16); color: #047857; }
.sv-pill.neg { background: rgba(239, 68, 68, 0.16); color: #b91c1c; }
[data-theme="dark"] .sv-pill.pos { color: #6ee7b7; }
[data-theme="dark"] .sv-pill.neg { color: #fca5a5; }

.sv-metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.sv-metric-box {
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(197, 198, 203, 0.35);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
[data-theme="dark"] .sv-metric-box {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}
.sv-metric-lbl {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--on-surface-variant);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sv-metric-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--on-surface);
  font-variant-numeric: tabular-nums;
}
.sv-svg {
  width: 100%;
  display: block;
  overflow: visible;
}
.sv-timeline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 4px;
}
.sv-tl-node {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #4b6176;
  border: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 2px rgba(75, 97, 118, 0.35);
  flex-shrink: 0;
}
[data-theme="dark"] .sv-tl-node {
  background: #8ab4f8;
  border-color: #0e1621;
  box-shadow: 0 0 0 2px rgba(138, 180, 248, 0.35);
}
.sv-tl-line {
  flex: 1;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #4b6176, #38bdf8);
  position: relative;
}
.sv-ruler-ticks {
  display: flex;
  justify-content: space-between;
  height: 10px;
  border-top: 1.5px solid var(--on-surface-variant);
  opacity: 0.45;
  margin-top: 4px;
}
.sv-ruler-ticks i {
  width: 1px;
  height: 6px;
  background: currentColor;
  display: block;
}
.sv-ruler-ticks i.major { height: 10px; width: 1.5px; }

/* Smart Visuals v2 Action Buttons (PNG, Copy CSV, Show All Rows) */
.sv-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.sv-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  min-height: 26px;
  border-radius: 999px;
  border: 1px solid rgba(197, 198, 203, 0.55);
  background: rgba(255, 255, 255, 0.55);
  color: var(--on-surface);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.sv-btn:hover {
  background: #4b6176;
  border-color: #4b6176;
  color: #ffffff;
}
[data-theme="dark"] .sv-btn {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.16);
  color: #e6edf3;
}
[data-theme="dark"] .sv-btn:hover {
  background: #8ab4f8;
  border-color: #8ab4f8;
  color: #06080d;
}

/* Premium Visual Suite Polish (Uniform Glass Borders, Refined Colors & Spacing) */
.sv-card {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.58) 0%, rgba(255, 255, 255, 0.28) 100%) !important;
  border: 1px solid rgba(255, 255, 255, 0.8) !important;
  border-left: 1px solid rgba(255, 255, 255, 0.8) !important;
  border-radius: 18px !important;
  padding: 16px 18px !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 8px 24px rgba(23, 28, 30, 0.05) !important;
  margin-bottom: 12px;
}

[data-theme="dark"] .sv-card {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.02) 100%) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-left: 1px solid rgba(255, 255, 255, 0.12) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 10px 28px rgba(0, 0, 0, 0.36) !important;
}

.sv-title {
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: 0.07em !important;
  text-transform: uppercase;
  color: var(--on-surface-variant) !important;
}

.sv-pill {
  font-size: 11px !important;
  font-weight: 600 !important;
  padding: 4px 10px !important;
  background: rgba(75, 97, 118, 0.12) !important;
  border: 1px solid rgba(75, 97, 118, 0.18);
}
[data-theme="dark"] .sv-pill {
  background: rgba(138, 180, 248, 0.12) !important;
  border-color: rgba(138, 180, 248, 0.22);
}
.sv-pill.pos {
  background: rgba(16, 185, 129, 0.12) !important;
  border-color: rgba(16, 185, 129, 0.25);
}
.sv-pill.neg {
  background: rgba(239, 68, 68, 0.12) !important;
  border-color: rgba(239, 68, 68, 0.25);
}

.sv-bar {
  height: 10px !important;
  border-radius: 999px !important;
  gap: 3px !important;
  margin: 4px 0 12px !important;
}

.sv-legend {
  gap: 8px 16px !important;
  font-size: 12.5px !important;
  color: var(--on-surface-variant);
}
.sv-legend strong { color: var(--on-surface); }

.sv-table-wrap {
  border-radius: 12px;
  border: 1px solid rgba(197, 198, 203, 0.3);
}
[data-theme="dark"] .sv-table-wrap {
  border-color: rgba(255, 255, 255, 0.08);
}
.sv-table th {
  background: rgba(75, 97, 118, 0.08);
  padding: 8px 10px !important;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sv-table td {
  padding: 8px 10px !important;
}
.sv-table tbody tr:hover {
  background: rgba(75, 97, 118, 0.05);
}

.sv-metric-box {
  padding: 10px 12px !important;
  border-radius: 12px !important;
}

/* Zone Gauge Track & Thumb */
.sv-gauge-wrap { padding: 6px 2px 2px; }
.sv-gauge-track {
  position: relative;
  display: flex;
  height: 8px;
  border-radius: 999px;
  overflow: visible;
  gap: 3px;
  margin: 10px 0 8px;
}
.sv-gauge-seg {
  flex: 1;
  height: 100%;
  border-radius: 999px;
  opacity: 0.88;
}
.sv-gauge-thumb {
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #141c24;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.32);
  transition: left 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
[data-theme="dark"] .sv-gauge-thumb {
  border-color: #8ab4f8;
  box-shadow: 0 0 0 3px rgba(6, 8, 13, 0.7), 0 2px 10px rgba(0, 0, 0, 0.5);
}
.sv-gauge-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 500;
  color: var(--on-surface-variant);
}

/* =========================================================
   Lego Builder Production Suite (Breadcrumbs, Controls,
   Compare, History, SEO, Embed, Print, Command Palette)
   ========================================================= */

/* Below-the-fold performance */
.seo-content-section,
.defs-section,
.related-section,
.cat-footer-section,
.site-footer {
  content-visibility: auto;
  contain-intrinsic-size: auto 320px;
}

/* Breadcrumbs */
.breadcrumb-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12.5px;
  color: var(--on-surface-variant);
  margin-bottom: 10px;
}
.breadcrumb-nav a:hover { color: var(--on-surface); text-decoration: underline; }
.breadcrumb-sep { opacity: 0.45; }

/* YMYL Micro-Disclaimer */
.ymyl-note {
  font-size: 12px;
  line-height: 1.45;
  color: var(--on-surface-variant);
  background: rgba(75, 97, 118, 0.08);
  border: 1px solid rgba(75, 97, 118, 0.18);
  border-radius: 12px;
  padding: 8px 12px;
  margin-bottom: 14px;
}
[data-theme="dark"] .ymyl-note {
  background: rgba(138, 180, 248, 0.08);
  border-color: rgba(138, 180, 248, 0.18);
}

/* Quick Presets / Verified Scenarios */
.preset-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(197, 198, 203, 0.35);
}
.preset-label {
  grid-column: 1 / -1;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--on-surface-variant);
  margin-bottom: 2px;
}
.preset-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(197, 198, 203, 0.5);
  background: var(--surface-container-low);
  color: var(--on-surface);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.preset-chip::after {
  content: "→";
  font-size: 12px;
  opacity: 0.45;
  flex-shrink: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.preset-chip:hover {
  background: rgba(75, 97, 118, 0.1);
  border-color: var(--secondary);
  color: var(--on-surface);
}
.preset-chip:hover::after {
  opacity: 0.9;
  transform: translateX(2px);
}
.preset-chip.is-active,
.preset-chip.is-active:hover {
  background: #141c24;
  border-color: #141c24;
  color: #ffffff;
}
.preset-chip.is-active::after {
  opacity: 0.9;
}
.preset-chip:focus-visible {
  outline: 2px solid var(--secondary);
  outline-offset: 2px;
}
[data-theme="dark"] .preset-row {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .preset-chip {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.14);
}
[data-theme="dark"] .preset-chip:hover {
  background: rgba(138, 180, 248, 0.12);
  border-color: var(--secondary);
}
[data-theme="dark"] .preset-chip.is-active,
[data-theme="dark"] .preset-chip.is-active:hover {
  background: var(--secondary);
  border-color: var(--secondary);
  color: #0d1117;
}

/* Input Adornments, Sliders, Toggles & Guardrails */
.input-affix-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-affix {
  position: absolute;
  font-size: 14px;
  font-weight: 700;
  color: var(--on-surface-variant);
  pointer-events: none;
}
.input-affix.prefix { left: 13px; }
.input-affix.suffix { right: 13px; }
.form-group .input-affix-wrap input.has-prefix { padding-left: 32px !important; }
.form-group .input-affix-wrap input.has-suffix { padding-right: 34px !important; }

.calc-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  margin: 10px 0 4px;
  height: 6px;
  border-radius: 999px;
  background: rgba(75, 97, 118, 0.22);
  outline: none;
  cursor: pointer;
}
.calc-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--secondary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.calc-slider::-webkit-slider-thumb:hover { transform: scale(1.12); }
.calc-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid var(--secondary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
  cursor: pointer;
}
[data-theme="dark"] .calc-slider { background: rgba(255, 255, 255, 0.16); }
[data-theme="dark"] .calc-slider::-webkit-slider-thumb { border-color: #8ab4f8; background: #0f172a; }
[data-theme="dark"] .calc-slider::-moz-range-thumb { border-color: #8ab4f8; background: #0f172a; }
.input-hint {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--on-surface-variant);
  margin-top: 4px;
}
.form-group.is-invalid input {
  border-color: var(--error) !important;
  box-shadow: 0 0 0 2px rgba(186, 26, 26, 0.14);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(197, 198, 203, 0.45);
  background: var(--surface-container-low);
}
[data-theme="dark"] .toggle-row {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.14);
}
.toggle-switch {
  position: relative;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(117, 119, 123, 0.35);
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.25);
  transition: transform 0.2s ease;
}
.toggle-switch input:checked + .toggle-track { background: var(--secondary); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(20px); }
.toggle-switch input:focus-visible + .toggle-track { outline: 2px solid var(--secondary); outline-offset: 2px; }

/* Action Bar, Compare, History & Chaining */
.calc-actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.action-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(197, 198, 203, 0.5);
  background: var(--surface-container-low);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--on-surface);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.action-pill-btn:hover {
  background: var(--secondary);
  border-color: var(--secondary);
  color: #fff;
}
[data-theme="dark"] .action-pill-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
}

.math-guard-alert {
  display: none;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--error-container);
  color: var(--error);
}

.compare-panel,
.history-strip,
.chain-strip,
.embed-box {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-container-low);
  border: 1px solid rgba(197, 198, 203, 0.35);
  font-size: 12.5px;
}
[data-theme="dark"] .compare-panel,
[data-theme="dark"] .history-strip,
[data-theme="dark"] .chain-strip,
[data-theme="dark"] .embed-box {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
}
.compare-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.history-chips,
.chain-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.chain-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--secondary-container);
  color: var(--on-secondary-container);
  font-size: 12px;
  font-weight: 600;
}
[data-theme="dark"] .chain-link {
  background: rgba(138, 180, 248, 0.15);
  color: #cbe2fc;
}

/* Ad Slots (CLS = 0.00 reserved space) */
.ad-slot {
  min-height: 90px;
  margin: 14px 0;
  border-radius: 14px;
  border: 1px dashed rgba(197, 198, 203, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--on-surface-variant);
  opacity: 0.7;
}

/* Definitions Table & SEO Section */
.defs-section,
.seo-content-section,
.related-section {
  margin-top: 24px;
}
.defs-table-wrap {
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid rgba(197, 198, 203, 0.4);
  background: var(--surface-container-lowest);
}
[data-theme="dark"] .defs-table-wrap {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.12);
}
.defs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.defs-table th,
.defs-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(197, 198, 203, 0.25);
}
.defs-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--on-surface-variant);
  background: rgba(75, 97, 118, 0.06);
}
.seo-demo-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
  margin-bottom: 8px;
}
[data-theme="dark"] .seo-demo-badge { color: #fbbf24; }

/* Google Preferred Source Pill & Social Links */
.g-pref-under-scenarios {
  margin: -6px 0 14px;
}
.g-pref-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(75, 97, 118, 0.3);
  font-size: 12px;
  font-weight: 600;
  color: var(--on-surface);
  background: var(--surface-container-low);
}
.g-pref-pill:hover { background: var(--secondary); color: #fff; border-color: var(--secondary); }
.social-links-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}
.author-social-links {
  margin-top: 12px;
}
.social-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(197, 198, 203, 0.55);
  background: var(--surface-container-lowest);
  color: var(--on-surface-variant);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(23, 28, 30, 0.04);
  transition: transform 0.12s ease, background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.social-pill svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.78;
  transition: opacity 0.15s ease;
}
.social-pill:hover {
  transform: translateY(-1px);
  background: var(--surface-container-low);
  border-color: var(--secondary);
  color: var(--on-surface);
}
.social-pill:hover svg {
  opacity: 1;
  color: var(--secondary);
}
.footer-social-col a {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
}
.footer-social-col svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.75;
}
.footer-social-col a:hover svg {
  opacity: 1;
  color: var(--secondary);
}
[data-theme="dark"] .g-pref-pill,
[data-theme="dark"] .social-pill {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.14);
}
[data-theme="dark"] .g-pref-pill:hover {
  background: var(--secondary);
  border-color: var(--secondary);
  color: #0d1117;
}
[data-theme="dark"] .social-pill:hover {
  background: rgba(138, 180, 248, 0.12);
  border-color: var(--secondary);
  color: var(--on-surface);
}

/* Domain Sub-Topic Clusters */
.hub-cluster { margin-bottom: 24px; }
.hub-cluster-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Global Ctrl+K Command Palette */
.cmdk-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(10, 14, 20, 0.56);
  backdrop-filter: blur(6px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
}
.cmdk-backdrop.open { display: flex; }
.cmdk-modal {
  width: 100%;
  max-width: 580px;
  background: var(--surface-container-lowest);
  border: 1px solid rgba(197, 198, 203, 0.5);
  border-radius: 20px;
  box-shadow: var(--shadow-float);
  overflow: hidden;
}
[data-theme="dark"] .cmdk-modal {
  background: #10161e;
  border-color: rgba(255, 255, 255, 0.16);
}
.cmdk-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(197, 198, 203, 0.3);
}
.cmdk-input-row input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 15px;
  font-weight: 500;
}
.cmdk-results {
  max-height: 360px;
  overflow-y: auto;
}
.cmdk-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid rgba(197, 198, 203, 0.2);
}
.cmdk-item:hover, .cmdk-item.active {
  background: rgba(75, 97, 118, 0.1);
}
.cmdk-math-row {
  padding: 12px 16px;
  background: rgba(75, 97, 118, 0.08);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
}

/* Embeddable Widget Mode (?embed=1) */
html.embed-mode .top-header,
html.embed-mode .breadcrumb-nav,
html.embed-mode .ymyl-note,
html.embed-mode .ad-slot,
html.embed-mode .defs-section,
html.embed-mode .seo-content-section,
html.embed-mode .related-section,
html.embed-mode .cat-footer-section,
html.embed-mode .site-footer,
html.embed-mode .bottom-nav,
html.embed-mode .embed-hide {
  display: none !important;
}
html.embed-mode body { padding-bottom: 12px; }
.embed-attribution { display: none; text-align: center; font-size: 12px; color: var(--on-surface-variant); margin-top: 8px; }
html.embed-mode .embed-attribution { display: block; }

/* Print / Save-as-PDF Stylesheet */
@media print {
  .top-header,
  .bottom-nav,
  .breadcrumb-nav,
  .preset-row,
  .calc-actions-bar,
  .history-strip,
  .chain-strip,
  .embed-box,
  .ad-slot,
  .related-section,
  .cat-footer-section,
  .site-footer,
  .calc-slider,
  #btn_reset {
    display: none !important;
  }
  body { background: #fff !important; color: #000 !important; padding: 0 !important; }
  .card, .hero-metric-card { box-shadow: none !important; border: 1px solid #ccc !important; break-inside: avoid; }
  .hero-metric-card { background: #f4f6f8 !important; color: #000 !important; }
  .hero-label { color: #444 !important; }
}

/* Editorial SEO Guide Typography (v3 Formula Box, Tables, Lists, Scenarios) */
.seo-content-section.card {
  padding: clamp(18px, 3vw, 28px);
  overflow-wrap: break-word;
}
.seo-content-section > p:first-child {
  font-size: clamp(1rem, 0.96rem + 0.25vw, 1.075rem);
  line-height: 1.65;
  color: var(--on-surface);
  margin-bottom: 1rem;
  text-wrap: pretty;
}
.seo-content-section > p:has(> em:only-child) {
  background: var(--surface-container-low);
  border-left: 3px solid var(--secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 14px;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--on-surface-variant);
  margin: 0.25rem 0 1.25rem;
}
.seo-content-section h2 {
  font-size: clamp(1.15rem, 1.05rem + 0.45vw, 1.35rem);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--on-surface);
  margin: 1.75rem 0 0.65rem;
  padding-top: 1.35rem;
  border-top: 1px solid rgba(197, 198, 203, 0.35);
  text-wrap: balance;
}
.seo-content-section h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.seo-content-section h3 {
  font-size: clamp(0.98rem, 0.94rem + 0.2vw, 1.06rem);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--on-surface);
  margin: 1.3rem 0 0.45rem;
  text-wrap: balance;
}
.seo-content-section p {
  font-size: 0.95rem;
  line-height: 1.68;
  margin: 0 0 0.85rem;
  color: var(--on-surface-variant);
  text-wrap: pretty;
}
.seo-content-section strong {
  color: var(--on-surface);
  font-weight: 600;
}
.seo-content-section ul,
.seo-content-section ol {
  margin: 0.45rem 0 1.15rem;
  padding-left: 1.25rem;
  line-height: 1.62;
  font-size: 0.94rem;
  color: var(--on-surface-variant);
}
.seo-content-section li {
  margin-bottom: 0.45rem;
  padding-left: 0.2rem;
  text-wrap: pretty;
}
.seo-content-section ul li::marker,
.seo-content-section ol li::marker {
  color: var(--secondary);
  font-weight: 700;
}
.seo-content-section code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.86em;
  padding: 0.15em 0.42em;
  border-radius: 6px;
  background: var(--surface-container-low);
  border: 1px solid rgba(197, 198, 203, 0.4);
  color: var(--on-surface);
}
.formula-box {
  margin: 0.9rem 0 1.2rem;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--surface-container-low);
  border: 1px solid rgba(197, 198, 203, 0.45);
  border-left: 4px solid var(--secondary);
  overflow-x: auto;
  font-size: clamp(0.92rem, 0.88rem + 0.2vw, 1.02rem);
  font-weight: 600;
  line-height: 1.5;
  color: var(--on-surface);
  font-variant-numeric: tabular-nums;
}
.formula-box .formula {
  display: inline-block;
  min-width: 100%;
  letter-spacing: -0.005em;
}
.seo-content-section .table-wrapper,
.seo-content-section .table-container {
  overflow-x: auto;
  max-inline-size: 100%;
  margin: 0.9rem 0 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(197, 198, 203, 0.42);
}
.seo-content-section table,
.benchmark-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0.9rem 0 1.25rem;
  font-size: 0.875rem;
  line-height: 1.45;
  border: 1px solid rgba(197, 198, 203, 0.42);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-container-lowest);
  font-variant-numeric: tabular-nums;
}
.seo-content-section .table-wrapper table,
.seo-content-section .table-container table {
  margin: 0;
  border: none;
  border-radius: 0;
}
.seo-content-section th,
.seo-content-section td,
.benchmark-table th,
.benchmark-table td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(197, 198, 203, 0.28);
  vertical-align: top;
}
.seo-content-section th,
.benchmark-table th {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--on-surface-variant);
  background: rgba(75, 97, 118, 0.08);
  text-wrap: balance;
}
.seo-content-section tbody tr:last-child td,
.benchmark-table tbody tr:last-child td {
  border-bottom: none;
}
.seo-content-section tbody tr:hover td,
.benchmark-table tbody tr:hover td {
  background: rgba(75, 97, 118, 0.04);
}
@media (max-width: 640px) {
  .seo-content-section table,
  .benchmark-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}
[data-theme="dark"] .seo-content-section > p:has(> em:only-child) {
  background: rgba(255, 255, 255, 0.04);
}
[data-theme="dark"] .seo-content-section h2 {
  border-top-color: rgba(255, 255, 255, 0.12);
}
[data-theme="dark"] .seo-content-section code {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
}
[data-theme="dark"] .formula-box {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.14);
  border-left-color: var(--secondary);
}
[data-theme="dark"] .seo-content-section table,
[data-theme="dark"] .benchmark-table,
[data-theme="dark"] .seo-content-section .table-wrapper,
[data-theme="dark"] .seo-content-section .table-container {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.02);
}
[data-theme="dark"] .seo-content-section th,
[data-theme="dark"] .benchmark-table th {
  background: rgba(138, 180, 248, 0.09);
  border-bottom-color: rgba(255, 255, 255, 0.12);
}
[data-theme="dark"] .seo-content-section td,
[data-theme="dark"] .benchmark-table td {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

/* About the Author Box (Calculator Pages) */
.author-box {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(197, 198, 203, 0.35);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
[data-theme="dark"] .author-box { border-top-color: rgba(255, 255, 255, 0.12); }
.author-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(75, 97, 118, 0.25);
}
.author-box-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--on-surface-variant); margin: 0 0 4px; }
.author-name-link { font-size: 16px; font-weight: 700; color: var(--on-surface); text-decoration: underline; text-underline-offset: 3px; }
.author-name-link:hover { color: var(--secondary); }
.author-bio { margin: 6px 0 0; font-size: 13.5px; line-height: 1.55; color: var(--on-surface-variant); }
