/* ============================================================
   CalcHub — Design system & layout
   1. Tokens          5. Cards
   2. Base            6. Calculator UI
   3. Header          7. Content sections
   4. Hero/sections   8. Footer & pages
   ============================================================ */

/* ---------------- 1. Tokens ---------------- */
:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #5b6b84;
  --border: #e4e9f2;
  --border-strong: #d3dae7;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --primary-text: #4338ca;
  --on-primary: #ffffff;

  --success: #0f9f6e;
  --warning: #c2740a;
  --danger: #dc2626;
  --sky: #0284c7;
  --rose: #e11d48;
  --violet: #7c3aed;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 3px rgba(15, 23, 42, .05), 0 14px 34px -18px rgba(15, 23, 42, .28);
  --shadow-lg: 0 28px 70px -28px rgba(15, 23, 42, .38);

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --container: 1180px;
  --header-h: 72px;
}

[data-theme="dark"] {
  --bg: #0a0f1d;
  --surface: #111a2e;
  --surface-2: #0d1526;
  --text: #e8edf7;
  --muted: #94a3b8;
  --border: #1f2b44;
  --border-strong: #2c3c5c;

  --primary: #818cf8;
  --primary-hover: #a5b4fc;
  --primary-soft: #1a2340;
  --primary-text: #c7d2fe;
  --on-primary: #0b1226;

  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .45);
  --shadow: 0 1px 3px rgba(0, 0, 0, .5), 0 18px 44px -20px rgba(0, 0, 0, .75);
  --shadow-lg: 0 34px 80px -30px rgba(0, 0, 0, .85);
}

/* ---------------- 2. Base ---------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

h1, h2, h3, h4, p, figure, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--primary-text); text-decoration: none; }
img, svg { vertical-align: middle; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--primary); color: var(--on-primary); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }

.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 200;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
  transition: top .2s;
}
.skip-link:focus { top: 12px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Shared text helpers */
.muted { color: var(--muted); }
.section { margin-top: 60px; }
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.section-head h2 {
  font-size: clamp(1.35rem, 2.4vw, 1.7rem);
  letter-spacing: -.025em;
  line-height: 1.2;
}
.section-sub {
  color: var(--muted);
  font-size: 14.5px;
  margin-top: 4px;
}
.section-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-text);
  white-space: nowrap;
  padding-bottom: 2px;
}
.section-link:hover { color: var(--primary-hover); }

/* ---------------- 3. Header ---------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
@supports (background: color-mix(in srgb, red 50%, transparent)) {
  .site-header {
    background: color-mix(in srgb, var(--surface) 84%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 26px;
  height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  flex: none;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #4f46e5, #0ea5e9);
  box-shadow: 0 8px 18px -8px rgba(79, 70, 229, .7);
}
.brand-name {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.03em;
}
.brand-name span { color: var(--primary-text); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.is-active { color: var(--primary-text); background: var(--primary-soft); }

.nav-dropdown { position: relative; }
.nav-dropdown-toggle svg { transition: transform .2s; }
.nav-dropdown.is-open .nav-dropdown-toggle svg { transform: rotate(180deg); }

.nav-dropdown-panel {
  position: absolute;
  top: calc(100% + 14px);
  left: 50%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 8px;
  width: min(640px, calc(100vw - 32px));
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(-6px);
  transition: opacity .18s, transform .18s, visibility .18s;
}
.nav-dropdown.is-open .nav-dropdown-panel {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 12px;
  color: var(--text);
  transition: background .15s;
}
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-item-text { display: flex; flex-direction: column; line-height: 1.25; }
.dropdown-item-text strong { font-size: 14px; font-weight: 600; }
.dropdown-item-text small { font-size: 12px; color: var(--muted); }
.dropdown-all {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding: 11px 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-text);
}

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

/* ---------------- Language switcher ---------------- */
.lang-dropdown { position: relative; }
.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: color .15s, background .15s, border-color .15s;
}
.lang-toggle:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}
.lang-toggle > svg:last-child {
  color: var(--muted);
  transition: transform .2s;
}
.lang-dropdown.is-open .lang-toggle > svg:last-child { transform: rotate(180deg); }
.lang-toggle-name { max-width: 92px; overflow: hidden; text-overflow: ellipsis; }

/* Flags are decorative: the native language name is always shown beside them. */
.lang-flag {
  display: inline-block;
  width: 20px;
  height: 15px;
  flex: none;
  border-radius: 3px;
  object-fit: cover;
  object-position: center;
  background: var(--surface-2);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, .12);
}
.lang-flag--toggle { width: 22px; height: 16px; }
.lang-flag--chip { width: 18px; height: 14px; border-radius: 2.5px; }
.lang-flag--footer { width: 16px; height: 12px; border-radius: 2px; }

.lang-dropdown-panel {
  position: absolute;
  top: calc(100% + 10px);
  inset-inline-end: 0;
  z-index: 60;
  display: grid;
  gap: 2px;
  min-width: 210px;
  max-height: min(60vh, 380px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity .18s, transform .18s, visibility .18s;
}
.lang-dropdown.is-open .lang-dropdown-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  transition: color .15s, background .15s;
}
.lang-option-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-option:hover { background: var(--surface-2); }
.lang-option.is-active {
  color: var(--primary-text);
  background: var(--primary-soft);
  font-weight: 600;
}
.lang-option-code {
  margin-inline-start: auto;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--muted);
}
.lang-option.is-active .lang-option-code { color: var(--primary-text); }

/* Footer keeps a compact inline switcher */
.lang-switch {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.lang-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  color: var(--muted);
  transition: color .15s, background .15s;
}
.lang-link:hover { color: var(--text); background: var(--surface); }
.lang-link.is-active {
  color: var(--primary-text);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.mobile-lang {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.mobile-lang .mobile-label { padding-left: 0; }
.mobile-lang .chip { margin: 0 6px 6px 0; }
.mobile-lang .chip.is-active {
  border-color: var(--primary);
  color: var(--primary-text);
  background: var(--primary-soft);
}

.header-search { width: 268px; transition: width .22s ease; }
.header-search:focus-within { width: 320px; }

.search-wrap { position: relative; }
.search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  transition: border-color .18s, box-shadow .18s;
}
.search-form:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.search-icon { display: flex; color: var(--muted); flex: none; }
.search-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 14px;
}
.search-input::placeholder { color: var(--muted); }
.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration { -webkit-appearance: none; }
.search-kbd {
  flex: none;
  padding: 1px 6px 2px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-2);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.search-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 120;
  max-height: 360px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.suggestion {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--text);
}
.suggestion:hover,
.suggestion.is-focused { background: var(--surface-2); }
.suggestion .tile { font-size: 12px; font-weight: 700; }
.suggestion-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.suggestion-text strong { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggestion-text small { font-size: 11.5px; color: var(--muted); }
.suggestion-empty { padding: 14px 12px; font-size: 13px; color: var(--muted); }

.icon-btn {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  transition: color .15s, border-color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }

.theme-icon { display: none; }
.theme-icon-moon { display: inline-flex; }
[data-theme="dark"] .theme-icon-moon { display: none; }
[data-theme="dark"] .theme-icon-sun { display: inline-flex; }

.nav-toggle { display: none; }
.nav-toggle-close { display: none; }
body.nav-open .nav-toggle-open { display: none; }
body.nav-open .nav-toggle-close { display: inline-flex; }

.mobile-nav {
  border-top: 1px solid var(--border);
  background: var(--surface);
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
}
.mobile-nav-inner { padding-top: 16px; padding-bottom: 24px; }
.mobile-links {
  display: grid;
  gap: 2px;
  margin-top: 14px;
}
.mobile-links a {
  padding: 11px 10px;
  border-radius: 10px;
  color: var(--text);
  font-weight: 500;
}
.mobile-links a:hover { background: var(--surface-2); }
.mobile-label {
  margin: 18px 0 10px;
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.mobile-cats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.mobile-cats a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
}
.mobile-cats a:hover { background: var(--surface-2); }

/* ---------------- 4. Hero & home sections ---------------- */
.hero {
  position: relative;
  overflow: hidden;
  padding: 76px 0 44px;
}
.hero::before {
  content: "";
  position: absolute;
  inset: -55% -12% auto;
  height: 620px;
  pointer-events: none;
  background:
    radial-gradient(42% 60% at 18% 32%, rgba(79, 70, 229, .16), transparent 70%),
    radial-gradient(38% 55% at 82% 22%, rgba(14, 165, 233, .15), transparent 70%),
    radial-gradient(30% 50% at 55% 4%, rgba(16, 185, 129, .10), transparent 70%);
  filter: blur(8px);
}
[data-theme="dark"] .hero::before { opacity: .5; }

.hero-inner {
  position: relative;
  max-width: 780px;
  margin: 0 auto;
  text-align: center;
}
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.hero-eyebrow svg { color: var(--primary-text); }
.hero h1 {
  font-size: clamp(2.2rem, 4.6vw, 3.5rem);
  line-height: 1.06;
  letter-spacing: -.035em;
}
.hero h1 .accent {
  background: linear-gradient(95deg, #4f46e5 10%, #0ea5e9 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
[data-theme="dark"] .hero h1 .accent {
  background: linear-gradient(95deg, #a5b4fc 10%, #7dd3fc 90%);
  -webkit-background-clip: text;
  background-clip: text;
}
.hero-lede {
  max-width: 600px;
  margin: 18px auto 0;
  font-size: clamp(15px, 1.6vw, 17px);
  line-height: 1.65;
  color: var(--muted);
}

.hero-search { max-width: 620px; margin: 30px auto 0; }
.hero-search .search-form {
  height: 60px;
  padding: 0 7px 0 20px;
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.hero-search .search-form:focus-within {
  box-shadow: var(--shadow), 0 0 0 4px var(--primary-soft);
}
.hero-search .search-input { font-size: 16px; }
.search-submit {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: none;
  height: 46px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 14px;
  font-weight: 600;
  transition: background .18s;
}
.search-submit:hover { background: var(--primary-hover); }
.hero-search .search-kbd { display: none; }

.hero-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
  font-size: 12.5px;
  color: var(--muted);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: transform .15s, border-color .15s, color .15s;
}
.chip:hover { transform: translateY(-1px); border-color: var(--primary); color: var(--primary-text); }

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin-top: 30px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.hero-badge { display: inline-flex; align-items: center; gap: 7px; }
.hero-badge svg { color: var(--success); }

/* ---------------- 5. Cards ---------------- */
.tile {
  width: 44px;
  height: 44px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 13px;
}
.tile--sm { width: 32px; height: 32px; border-radius: 9px; }
.tile--lg { width: 56px; height: 56px; border-radius: 16px; }
.tile--indigo { background: #eef2ff; color: #4f46e5; }
.tile--emerald { background: #e7f8f1; color: #0f9f6e; }
.tile--rose { background: #ffe9ee; color: #e11d48; }
.tile--amber { background: #fdf3e3; color: #b45309; }
.tile--sky { background: #e6f4fe; color: #0284c7; }
.tile--violet { background: #f3e8ff; color: #7c3aed; }
.tile--teal { background: #e6fbf7; color: #0d9488; }
.tile--orange { background: #fff1e6; color: #ea580c; }
.tile--cyan { background: #e5f9ff; color: #0891b2; }
.tile--slate { background: #eef2f7; color: #475569; }
.tile--lime { background: #f3fbe4; color: #65a30d; }

[data-theme="dark"] .tile--indigo { background: rgba(129, 140, 248, .15); color: #a5b4fc; }
[data-theme="dark"] .tile--emerald { background: rgba(52, 211, 153, .14); color: #6ee7b7; }
[data-theme="dark"] .tile--rose { background: rgba(251, 113, 133, .14); color: #fda4af; }
[data-theme="dark"] .tile--amber { background: rgba(251, 191, 36, .14); color: #fcd34d; }
[data-theme="dark"] .tile--sky { background: rgba(56, 189, 248, .14); color: #7dd3fc; }
[data-theme="dark"] .tile--violet { background: rgba(167, 139, 250, .15); color: #c4b5fd; }
[data-theme="dark"] .tile--teal { background: rgba(45, 212, 191, .14); color: #5eead4; }
[data-theme="dark"] .tile--orange { background: rgba(251, 146, 60, .14); color: #fdba74; }
[data-theme="dark"] .tile--cyan { background: rgba(34, 211, 238, .14); color: #67e8f9; }
[data-theme="dark"] .tile--slate { background: rgba(148, 163, 184, .15); color: #cbd5e1; }
[data-theme="dark"] .tile--lime { background: rgba(163, 230, 53, .13); color: #bef264; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.pill--indigo { background: #eef2ff; border-color: transparent; color: #4338ca; }
.pill--emerald { background: #e7f8f1; border-color: transparent; color: #0b7d57; }
.pill--rose { background: #ffe9ee; border-color: transparent; color: #be123c; }
.pill--amber { background: #fdf3e3; border-color: transparent; color: #a16207; }
.pill--sky { background: #e6f4fe; border-color: transparent; color: #0369a1; }
.pill--violet { background: #f3e8ff; border-color: transparent; color: #6d28d9; }
.pill--teal { background: #e6fbf7; border-color: transparent; color: #0f766e; }
.pill--orange { background: #fff1e6; border-color: transparent; color: #c2410c; }
.pill--cyan { background: #e5f9ff; border-color: transparent; color: #0e7490; }
.pill--slate { background: #eef2f7; border-color: transparent; color: #334155; }
.pill--lime { background: #f3fbe4; border-color: transparent; color: #4d7c0f; }

[data-theme="dark"] .pill--indigo { background: rgba(129, 140, 248, .16); color: #c7d2fe; }
[data-theme="dark"] .pill--emerald { background: rgba(52, 211, 153, .16); color: #a7f3d0; }
[data-theme="dark"] .pill--rose { background: rgba(251, 113, 133, .16); color: #fecdd3; }
[data-theme="dark"] .pill--amber { background: rgba(251, 191, 36, .16); color: #fde68a; }
[data-theme="dark"] .pill--sky { background: rgba(56, 189, 248, .16); color: #bae6fd; }
[data-theme="dark"] .pill--violet { background: rgba(167, 139, 250, .16); color: #ddd6fe; }
[data-theme="dark"] .pill--teal { background: rgba(45, 212, 191, .16); color: #99f6e4; }
[data-theme="dark"] .pill--orange { background: rgba(251, 146, 60, .16); color: #fed7aa; }
[data-theme="dark"] .pill--cyan { background: rgba(34, 211, 238, .16); color: #a5f3fc; }
[data-theme="dark"] .pill--slate { background: rgba(148, 163, 184, .16); color: #e2e8f0; }
[data-theme="dark"] .pill--lime { background: rgba(163, 230, 53, .15); color: #d9f99d; }

.soon-pill {
  display: inline-flex;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  vertical-align: middle;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(296px, 1fr));
  gap: 14px;
}

.calc-card {
  position: relative;
  display: flex;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.calc-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow);
}
.calc-card-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.calc-card-title {
  font-size: 15px;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -.01em;
}
.calc-card-desc {
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.calc-card-meta { margin-top: 4px; }
.calc-card-arrow {
  position: absolute;
  top: 14px;
  right: 14px;
  color: var(--border-strong);
  opacity: 0;
  transform: translate(-3px, 3px);
  transition: opacity .18s, transform .18s, color .18s;
}
.calc-card:hover .calc-card-arrow {
  opacity: 1;
  transform: translate(0, 0);
  color: var(--primary-text);
}
.calc-card--compact { padding: 14px; align-items: center; }
.calc-card--compact .calc-card-title { font-size: 14px; }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.cat-card {
  position: relative;
  display: flex;
  gap: 16px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.cat-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow);
}
.cat-card-body { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.cat-card-title { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.cat-card-desc { font-size: 13px; line-height: 1.55; color: var(--muted); }
.cat-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-text);
}
.cat-card-built {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.cat-card-arrow {
  position: absolute;
  right: 20px;
  bottom: 20px;
  color: var(--border-strong);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity .18s, transform .18s, color .18s;
}
.cat-card:hover .cat-card-arrow { opacity: 1; transform: translateX(0); color: var(--primary-text); }

/* Browse by category */
.browse-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.browse-col {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.browse-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}
.browse-list { display: grid; gap: 1px; }
.browse-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 4px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 13.5px;
  transition: color .15s, background .15s, padding .15s;
}
.browse-list a:hover { color: var(--text); background: var(--surface-2); padding-left: 8px; }
.browse-list a span { font-size: 10.5px; color: var(--border-strong); }
.browse-more {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--primary-text);
}

/* Features */
.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.feature-card {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.feature-card h3 { margin: 14px 0 6px; font-size: 15.5px; letter-spacing: -.01em; }
.feature-card p { font-size: 13.5px; line-height: 1.6; color: var(--muted); }

/* Ad slots */
.ad-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 100px;
  margin: 34px auto;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}
.ad-slot-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.ad-slot-size { font-size: 12px; opacity: .6; }
.ad-slot--leaderboard { width: 100%; max-width: 728px; height: 90px; min-height: 90px; }
.ad-slot--box { width: 300px; height: 250px; min-height: 250px; }
.ad-slot--inline { width: 100%; max-width: 336px; height: 280px; min-height: 280px; margin: 26px auto; }

.ad-slot--live { overflow: hidden; padding: 0; border-style: solid; }
.ad-slot--live .ad-slot-label {
  position: absolute;
  top: 2px;
  left: 6px;
  z-index: 2;
  font-size: 8px;
  opacity: .55;
  pointer-events: none;
}
.ad-slot-unit,
.ad-slot-custom,
.ad-slot-link,
.ad-slot-image { display: block; width: 100%; height: 100%; }
.ad-slot-image { object-fit: cover; }
.ad-slot--awaiting-consent .ad-slot-unit,
.ad-slot--awaiting-consent .ad-slot-custom,
.ad-slot--awaiting-consent .ad-slot-link { visibility: hidden; }

/* Consent banner */
.consent-banner {
  position: fixed;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: 880px;
  margin: 0 auto;
  padding: 16px 18px;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(15, 23, 42, .2);
}
.consent-banner[hidden] { display: none; }
.consent-banner p { margin: 0; font-size: 13px; line-height: 1.55; color: var(--muted); }
.consent-banner a { color: var(--primary-text); text-decoration: underline; }
.consent-actions { display: flex; gap: 8px; flex-wrap: wrap; }


/* ---------------- 6. Breadcrumb & page heads ---------------- */
.breadcrumb { padding-top: 22px; }
.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
}
.breadcrumb li { display: inline-flex; align-items: center; gap: 5px; }
.breadcrumb a { color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.breadcrumb a:hover { color: var(--primary-text); }
.breadcrumb-sep { color: var(--border-strong); }
.breadcrumb [aria-current="page"] { color: var(--text); font-weight: 600; }

.page-head { padding: 28px 0 6px; max-width: 780px; }
.page-head h1 {
  font-size: clamp(1.85rem, 3.4vw, 2.55rem);
  line-height: 1.12;
  letter-spacing: -.03em;
}
.page-head p {
  margin-top: 12px;
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--muted);
}
.page-head-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.count-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------------- 7. Calculator UI ---------------- */
.calc-page { padding-top: 4px; }
.calc-head { max-width: 780px; padding: 20px 0 6px; }
.calc-head h1 {
  font-size: clamp(1.85rem, 3.4vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -.03em;
}
.calc-head p {
  margin-top: 10px;
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--muted);
}
.calc-head-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
}
.calc-head-meta .dot { color: var(--border-strong); }

.calculator {
  margin-top: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 20px 24px 0;
}
.mode-tab {
  padding: 8px 15px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  transition: color .15s, background .15s, border-color .15s;
}
.mode-tab:hover { color: var(--text); border-color: var(--border-strong); }
.mode-tab.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.calc-body {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(300px, .92fr);
}
.calc-inputs { padding: 24px 26px 28px; min-width: 0; }
.calc-result {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  border-left: 1px solid var(--border);
  background: var(--surface-2);
  min-width: 0;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}
.segmented button {
  padding: 7px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  transition: background .15s, color .15s, box-shadow .15s;
}
.segmented button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.calc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.calc-toolbar-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

.fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
}
.fields--stack { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .01em;
}
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input,
.input-wrap select {
  width: 100%;
  height: 46px;
  padding: 0 52px 0 13px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  transition: border-color .15s, box-shadow .15s;
}
.input-wrap select { padding-right: 34px; cursor: pointer; }
.input-wrap textarea {
  width: 100%;
  min-height: 140px;
  padding: 12px 13px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.55;
  resize: vertical;
  transition: border-color .15s, box-shadow .15s;
}
.input-wrap input:hover, .input-wrap select:hover, .input-wrap textarea:hover { border-color: var(--muted); }
.input-wrap input:focus, .input-wrap select:focus, .input-wrap textarea:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.input-wrap input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.input-wrap input[type="number"]::-webkit-outer-spin-button,
.input-wrap input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-wrap input.has-prefix { padding-left: 32px; }
.input-prefix {
  position: absolute;
  left: 13px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--muted);
  pointer-events: none;
}
.input-unit {
  position: absolute;
  right: 13px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  pointer-events: none;
}
.field-hint { font-size: 11.5px; color: var(--muted); line-height: 1.4; }

.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Currency converter ---------- */
.fx-pair {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 10px;
  margin-top: 15px;
}
.fx-swap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border: 1.5px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, color .15s, transform .15s;
}
.fx-swap:hover { border-color: var(--primary); color: var(--primary); }
.fx-swap:active { transform: scale(.94); }
.fx-swap:focus-visible { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
#fx-rate, #fx-inverse { font-size: 12.5px; line-height: 1.45; }

/* ---------- Scientific calculator ---------- */
.sci-display { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.sci-display input {
  width: 100%;
  height: 52px;
  padding: 0 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 17px;
  letter-spacing: .02em;
}
.sci-display input:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.sci-keypad { display: flex; flex-direction: column; gap: 8px; }
.sci-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.sci-key {
  height: 46px;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .12s;
}
.sci-key:hover { border-color: var(--border-strong); background: var(--surface-2); }
.sci-key:active { transform: translateY(1px); }
.sci-key:focus-visible { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.sci-key--fn { font-size: 13.5px; color: var(--muted); }
.sci-key--fn.is-active { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }
.sci-key--op { color: var(--primary-text); background: var(--primary-soft); border-color: transparent; }
.sci-key--op:hover { background: var(--primary-soft); border-color: var(--primary); }
.sci-key--eq { color: var(--on-primary); background: var(--primary); border-color: var(--primary); }
.sci-key--eq:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.sci-mode {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}
.sci-mode button {
  border: 0;
  background: transparent;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.sci-mode button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}


.calc-note {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}
.calc-note svg { flex: none; margin-top: 1px; color: var(--primary-text); }

/* Result panel */
.result-main {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(150deg, var(--primary-soft), var(--surface) 78%);
}
.result-main::after {
  content: "";
  position: absolute;
  pointer-events: none;
  top: -42px;
  right: -42px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--primary);
  opacity: .07;
}
.result-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.result-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.result-value {
  position: relative;
  margin: 8px 0 4px;
  font-size: clamp(1.9rem, 3.4vw, 2.55rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -.035em;
  color: var(--primary-text);
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}
.result-value.is-long {
  font-size: 1.05rem;
  line-height: 1.5;
  font-weight: 600;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}
.result-value .unit {
  font-size: .46em;
  font-weight: 700;
  letter-spacing: 0;
  margin-left: 3px;
  color: var(--muted);
}
.result-note { font-size: 13px; line-height: 1.55; color: var(--muted); }

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  transition: color .15s, border-color .15s;
}
.copy-btn:hover { color: var(--primary-text); border-color: var(--primary); }
.copy-btn.is-copied { color: var(--success); border-color: var(--success); }
.copy-btn.is-error { color: var(--danger); border-color: var(--danger); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
}
.stat-label { display: block; font-size: 11px; font-weight: 600; color: var(--muted); }
.stat-value {
  display: block;
  margin-top: 3px;
  font-size: 15.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}
.result-badge--green { background: rgba(16, 185, 129, .14); color: var(--success); }
.result-badge--blue { background: rgba(14, 165, 233, .14); color: var(--sky); }
.result-badge--amber { background: rgba(245, 158, 11, .16); color: var(--warning); }
.result-badge--red { background: rgba(239, 68, 68, .14); color: var(--danger); }

/* BMI scale */
.bmi-scale { margin-top: 2px; }
.bmi-track {
  position: relative;
  margin-bottom: 9px;
  padding-top: 5px;
}
.bmi-bar {
  display: flex;
  gap: 3px;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
}
.bmi-bar span { display: block; height: 100%; border-radius: 2px; }
.bmi-bar .b-under { flex: 1; background: #38bdf8; }
.bmi-bar .b-normal { flex: 1.45; background: #22c55e; }
.bmi-bar .b-over { flex: 1; background: #f59e0b; }
.bmi-bar .b-obese { flex: 1.15; background: #ef4444; }
.bmi-marker {
  position: absolute;
  top: -1px;
  left: 50%;
  width: 4px;
  height: 21px;
  border-radius: 3px;
  background: var(--text);
  box-shadow: 0 0 0 2px var(--surface-2);
  transform: translateX(-50%);
  transition: left .4s cubic-bezier(.4, 0, .2, 1);
}
.bmi-labels {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
}
.bmi-labels span:nth-child(1) { flex: 1; }
.bmi-labels span:nth-child(2) { flex: 1.45; color: var(--success); font-weight: 600; }
.bmi-labels span:nth-child(3) { flex: 1; }
.bmi-labels span:nth-child(4) { flex: 1.15; }

/* Split bar */
.split-box { display: flex; flex-direction: column; gap: 8px; }
.split-bar {
  display: flex;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}
.split-bar span { display: block; height: 100%; }
.split-principal { background: var(--primary); }
.split-interest { background: #f59e0b; }
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 11.5px;
  color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  display: inline-block;
}
.legend .dot-principal { background: var(--primary); }
.legend .dot-interest { background: #f59e0b; }

/* Amortization */
.amort {
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  overflow: hidden;
}
.amort summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 15px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  list-style: none;
}
.amort summary::-webkit-details-marker { display: none; }
.amort summary::after {
  content: "+";
  font-size: 17px;
  line-height: 1;
  color: var(--muted);
}
.amort[open] summary::after { content: "\2212"; }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--border); }
table.schedule {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  white-space: nowrap;
}
table.schedule th,
table.schedule td {
  padding: 8px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
table.schedule th {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
}
table.schedule th:first-child,
table.schedule td:first-child { text-align: left; }
table.schedule tbody tr:last-child td { border-bottom: 0; }
table.schedule tbody tr:hover { background: var(--surface-2); }

/* Calculator content */
.calc-content { max-width: 840px; margin-top: 46px; }
.prose h2 {
  margin: 34px 0 10px;
  font-size: clamp(1.3rem, 2.3vw, 1.55rem);
  letter-spacing: -.02em;
}
.prose h2:first-child { margin-top: 0; }
.prose h3 { margin: 22px 0 8px; font-size: 1.08rem; }
.prose p { margin: 10px 0; font-size: 15px; line-height: 1.75; color: var(--muted); }
.prose p strong, .prose li strong { color: var(--text); }
.prose ul, .prose ol { margin: 12px 0; padding-left: 22px; display: grid; gap: 6px; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li { font-size: 15px; line-height: 1.65; color: var(--muted); }
.prose a { text-decoration: underline; text-underline-offset: 2px; }

/* In-content related links: useful internal linking without another card grid. */
.inline-related {
  margin: 28px 0 6px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}
.inline-related h2 { margin: 0 0 10px; font-size: 1rem; }
.inline-related ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.inline-related li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: 14px; }
.inline-related li a { font-weight: 700; color: var(--primary-text); text-decoration: none; }
.inline-related li a:hover { text-decoration: underline; }
.inline-related li span { color: var(--muted); font-size: 13px; }

.cite-box {
  margin: 24px 0 6px;
  padding: 16px 18px;
  border-left: 3px solid var(--primary);
  border-radius: 0 12px 12px 0;
  background: var(--surface);
}
.cite-box strong { display: block; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.cite-box p { margin: 6px 0 10px; font-size: 13px; color: var(--muted); }
.prose code {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  font-size: .9em;
}

.formula {
  margin: 16px 0;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  color: var(--text);
  overflow-x: auto;
}
.formula strong { color: var(--primary-text); }

.example-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.example-card {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}
.example-card h3 { margin: 0 0 6px; font-size: 13.5px; }
.example-card p { margin: 0; font-size: 13px; line-height: 1.6; color: var(--muted); }
.example-card .answer { color: var(--primary-text); font-weight: 700; }

.faq { display: grid; gap: 9px; margin-top: 16px; }
.faq-item {
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  overflow: hidden;
}
.faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 18px;
  font-size: 14px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  flex: none;
  font-size: 18px;
  color: var(--muted);
}
.faq-item[open] summary::after { content: "\2212"; }
.faq-item p {
  margin: 0;
  padding: 0 18px 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--muted);
}

/* CTA band */
.cta-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 26px 30px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background:
    radial-gradient(70% 160% at 0% 0%, var(--primary-soft), transparent 70%),
    var(--surface);
}
.cta-band h2 { font-size: 1.15rem; letter-spacing: -.01em; }
.cta-band p { margin-top: 4px; font-size: 13.5px; color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .18s, color .18s, border-color .18s, transform .18s;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary-text); }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 9px; }

/* ---------------- 8. Search, directory, static pages, footer ---------------- */
.search-head { padding: 26px 0 4px; }
.search-head h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); letter-spacing: -.03em; }
.search-head p { margin-top: 8px; color: var(--muted); font-size: 14.5px; }
.search-form--page {
  max-width: 640px;
  height: 52px;
  margin-top: 18px;
  border-radius: 14px;
  padding: 0 8px 0 16px;
}
.search-form--page .search-input { font-size: 15.5px; }

.result-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: 26px 0 16px;
  font-size: 13.5px;
  color: var(--muted);
}
.result-summary strong { color: var(--text); }

.empty-state {
  padding: 48px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}
.empty-state .tile { margin: 0 auto 14px; }
.empty-state h2 { font-size: 1.15rem; }
.empty-state p { max-width: 420px; margin: 6px auto 18px; font-size: 13.5px; color: var(--muted); }

/* A-Z directory */
.az-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 22px 0 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}
.az-nav a {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.az-nav a:hover { background: var(--primary-soft); color: var(--primary-text); }
.az-nav span {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--border-strong);
}

.az-group { margin-top: 30px; scroll-margin-top: 100px; }
.az-group h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 1.05rem;
  letter-spacing: .02em;
  color: var(--primary-text);
}
.az-group h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.az-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0 28px;
}
.az-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 2px;
  border-bottom: 1px dashed var(--border);
  color: var(--text);
  font-size: 13.5px;
}
.az-list a:hover { color: var(--primary-text); }
.az-list .az-cat {
  flex: none;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Static / prose pages */
.page-narrow { max-width: 800px; margin: 0 auto; }
.page-hero { padding: 40px 0 10px; text-align: center; }
.page-hero .tile { margin: 0 auto 16px; }
.page-hero h1 { font-size: clamp(1.9rem, 3.6vw, 2.6rem); letter-spacing: -.03em; }
.page-hero p { max-width: 620px; margin: 12px auto 0; font-size: 15.5px; line-height: 1.7; color: var(--muted); }
.page-body { padding: 8px 0 20px; }
.page-body .prose h2:first-child { margin-top: 20px; }

.info-box {
  display: flex;
  gap: 12px;
  margin: 20px 0;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--muted);
}
.info-box svg { flex: none; color: var(--primary-text); margin-top: 1px; }

.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin: 24px 0;
}
.contact-card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.contact-card h3 { margin: 12px 0 4px; font-size: 15px; }
.contact-card p { font-size: 13.5px; line-height: 1.6; color: var(--muted); }
.contact-card a { font-weight: 600; }

.static-form { display: grid; gap: 14px; margin-top: 22px; }
.static-form .input-wrap input,
.static-form .input-wrap textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.static-form textarea { min-height: 130px; resize: vertical; }
.static-form .input-wrap input:focus,
.static-form .input-wrap textarea:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.form-note { font-size: 12px; color: var(--muted); }
.form-success {
  display: flex;
  gap: 10px;
  padding: 13px 15px;
  border-radius: 12px;
  background: rgba(16, 185, 129, .12);
  color: var(--success);
  font-size: 13.5px;
  font-weight: 500;
}

/* Coming soon */
.soon-wrap {
  max-width: 700px;
  margin: 40px auto 20px;
  padding: 44px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}
.soon-wrap .tile { margin: 0 auto 18px; }
.soon-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-text);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.soon-wrap h1 { margin: 14px 0 8px; font-size: clamp(1.7rem, 3.4vw, 2.3rem); letter-spacing: -.03em; }
.soon-wrap > p { max-width: 480px; margin: 0 auto; font-size: 14.5px; line-height: 1.7; color: var(--muted); }
.soon-features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 26px 0;
  text-align: left;
}
.soon-feature {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-2);
  font-size: 12.5px;
  color: var(--muted);
}
.soon-feature svg { color: var(--success); flex: none; }

.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  margin-top: 72px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr 1fr 1fr;
  gap: 40px;
  padding: 54px 0 38px;
}
.footer-brand p {
  max-width: 300px;
  margin-top: 14px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--muted);
}
.footer-badges { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.footer-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.footer-badge svg { color: var(--success); }
.footer-col h3 {
  margin-bottom: 14px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.footer-col ul { display: grid; gap: 8px; }
.footer-col a { font-size: 13.5px; color: var(--muted); }
.footer-col a:hover { color: var(--primary-text); }
.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 0 26px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}
.footer-note { font-size: 11.5px; opacity: .8; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1100px) {
  .header-search { width: 230px; }
  .header-search:focus-within { width: 270px; }
  .browse-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1000px) {
  .nav-links { display: none; }
  .header-search { display: none; }
  .nav-toggle { display: inline-flex; }
  .header-inner { gap: 14px; }
  .mobile-nav:not([hidden]) { display: block; }
  .calc-body { grid-template-columns: 1fr; }
  .calc-result {
    border-left: 0;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    align-items: start;
  }
  .calc-result > .result-main { grid-row: span 2; }
}

@media (min-width: 1001px) {
  .mobile-nav { display: none !important; }
}

@media (max-width: 900px) {
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 32px; }
  .features-grid { grid-template-columns: 1fr; }
  .cta-band { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 760px) {
  :root { --header-h: 64px; }
  .container { padding: 0 18px; }
  .hero { padding: 52px 0 36px; }
  .hero-badges { gap: 14px; }
  .section { margin-top: 46px; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .calc-grid, .cat-grid { grid-template-columns: 1fr; }
  .browse-grid { grid-template-columns: 1fr; }
  .calc-result { grid-template-columns: 1fr; }
  .calc-inputs, .calc-result { padding: 20px; }
  .mode-tabs { padding: 16px 18px 0; }
  .footer-grid { grid-template-columns: 1fr; gap: 26px; }
  .calc-card-arrow, .cat-card-arrow { opacity: 1; transform: none; }
  .ad-slot { margin: 26px auto; }
  .ad-slot--leaderboard { max-width: 320px; height: 100px; min-height: 100px; }
  .soon-wrap { padding: 34px 22px; }
  .soon-features { grid-template-columns: 1fr; }
  .page-head { padding-top: 22px; }
  .calc-head { padding-top: 16px; }
}

@media (max-width: 520px) {
  .brand-name { font-size: 18px; }
  .lang-dropdown { display: none; }
  .hero h1 { letter-spacing: -.03em; }
  .calc-head-meta .dot { display: none; }
  .hero-search .search-form { height: 54px; padding-left: 15px; }
  .hero-search .search-submit { height: 42px; padding: 0 16px; font-size: 13px; }
  .chip { font-size: 12px; padding: 6px 11px; }
  .stats { grid-template-columns: 1fr; }
  .az-list { grid-template-columns: 1fr; }
  .az-nav a { width: 29px; height: 29px; }
  .result-value { font-size: 1.85rem; }
  .mobile-cats { grid-template-columns: 1fr; }
}

/* ---------------- Calculator helpers (Phase 2) ---------------- */
.calc-sources {
  margin-top: 34px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
}
.calc-sources h3 { margin-bottom: 8px; font-size: 14px; color: var(--text); }
.calc-sources ul { margin: 0 0 12px; padding-left: 18px; }
.calc-sources li { margin-bottom: 5px; line-height: 1.55; }
.calc-disclaimer { font-size: 12px; line-height: 1.6; opacity: .85; }

/* GPA rows */
.gpa-rows { display: flex; flex-direction: column; gap: 10px; }
.gpa-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, .8fr) 38px;
  gap: 8px;
  align-items: center;
}
.gpa-row input,
.gpa-row select {
  width: 100%;
  height: 42px;
  padding: 0 10px;
  border: 1.5px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  font-size: 14px;
}
.gpa-row input:focus,
.gpa-row select:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.gpa-remove {
  display: grid;
  place-items: center;
  width: 38px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.gpa-remove:hover { color: var(--danger); border-color: var(--danger); }
.gpa-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 9px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: transparent;
  color: var(--primary-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.gpa-add:hover { background: var(--primary-soft); }

/* Time card rows */
.timecard-head,
.timecard-row {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, .8fr);
  gap: 8px;
  align-items: center;
}
.timecard-head {
  padding: 0 2px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.timecard-rows { display: flex; flex-direction: column; gap: 8px; }
.timecard-day { font-size: 13px; font-weight: 600; }
.timecard-row input {
  width: 100%;
  height: 40px;
  padding: 0 8px;
  border: 1.5px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.timecard-row input:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
@media (max-width: 520px) {
  .timecard-head { display: none; }
  .timecard-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
  }
  .timecard-day { grid-column: 1 / -1; }
}

/* Password generator */
.pw-display {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pw-display input {
  width: 100%;
  height: 52px;
  padding: 0 12px;
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  letter-spacing: .04em;
}
.pw-copy {
  flex: none;
  height: 52px;
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.pw-copy:hover { background: var(--primary-hover); }
.pw-strength { margin-top: 14px; }
.pw-strength-bar {
  height: 7px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.pw-strength-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--success);
  transition: width .2s, background .2s;
}
.pw-strength-label {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.pw-options { display: grid; gap: 10px; margin-top: 16px; }
.pw-option {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
}
.pw-option input { width: 17px; height: 17px; accent-color: var(--primary); }
.pw-range { width: 100%; accent-color: var(--primary); }

/* Ohms law field grid */
.ohm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
@media (max-width: 520px) { .ohm-grid { grid-template-columns: 1fr; } }

/* ---------------- Motion & print ---------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .site-header, .site-footer, .ad-slot, .related-section, .cta-band, .copy-btn, .breadcrumb { display: none !important; }
  body { background: #fff; color: #000; }
  .calculator { box-shadow: none; border: 1px solid #ccc; }
}

/* ---------------- Language-specific typography ---------------- */
html[lang="th"] {
  --font: "Noto Sans Thai", "Sarabun", "Leelawadee UI", "Tahoma", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
html[lang="ar"] {
  --font: "Noto Naskh Arabic", "Segoe UI", "Tahoma", "Arial", sans-serif;
}
html[dir="rtl"] body { text-align: right; }
html[dir="rtl"] .search-suggestions { text-align: right; }
html[dir="rtl"] .header-actions { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .footer-badges,
html[dir="rtl"] .hero-badges { justify-content: flex-start; }
html[dir="rtl"] .breadcrumbs ol,
html[dir="rtl"] .breadcrumb ol { padding-right: 0; }

/* Copy fallback for insecure origins */
body.copy-dialog-open { overflow: hidden; }
.copy-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, .55);
}
.copy-dialog.is-open { display: flex; }
.copy-dialog__box {
  position: relative;
  width: min(520px, 100%);
  padding: 24px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .25);
}
.copy-dialog__title { margin: 0 0 6px; font-size: 18px; }
.copy-dialog__hint { margin: 0 0 12px; color: #475569; font-size: 13px; }
.copy-dialog__text {
  width: 100%;
  min-height: 92px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  resize: vertical;
}
.copy-dialog__close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.copy-dialog__close:hover { background: #f1f5f9; color: #0f172a; }

/* All-calculators pagination */
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin: 36px 0 8px;
}
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: border-color .18s ease, color .18s ease;
}
.page-link:hover { border-color: var(--primary); color: var(--primary-text); }
.page-link.is-current { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
