/* ============================================================
   Design tokens
============================================================ */
:root {
  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-muted: #f1f5f9;
  --bg-dark: #0b1020;

  --text: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --text-on-dark: #e2e8f0;

  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --primary: #6366f1;
  --primary-600: #4f46e5;
  --primary-700: #4338ca;
  --primary-soft: #eef2ff;
  --accent: #8b5cf6;
  --accent-pink: #ec4899;

  --gradient-primary: linear-gradient(135deg, #6366f1 0%, #8b5cf6 60%, #ec4899 100%);
  --gradient-soft: linear-gradient(135deg, #eef2ff 0%, #fdf2f8 100%);
  --gradient-hero: radial-gradient(1200px 600px at 10% -10%, #e0e7ff 0%, transparent 60%),
                   radial-gradient(900px 500px at 100% 0%, #fce7f3 0%, transparent 55%),
                   linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);

  --success: #10b981;
  --danger: #ef4444;
  --warn: #f59e0b;

  --radius-sm: 0.5rem;
  --radius: 0.875rem;
  --radius-lg: 1.25rem;
  --radius-xl: 1.75rem;

  --shadow-xs: 0 1px 2px rgb(15 23 42 / 0.04);
  --shadow-sm: 0 2px 6px -1px rgb(15 23 42 / 0.06);
  --shadow: 0 8px 24px -6px rgb(15 23 42 / 0.08);
  --shadow-lg: 0 20px 45px -12px rgb(15 23 42 / 0.18);
  --shadow-primary: 0 10px 30px -8px rgb(99 102 241 / 0.45);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  --header-h: 64px;
}

/* ============================================================
   Reset & base
============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-y: scroll;
  /* `clip` instead of `hidden` so it doesn't create a scroll container,
     which would silently break `position: sticky` on the header. */
  overflow-x: clip;
}
body {
  margin: 0;
  min-width: 0;
  overflow-x: clip;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  line-height: 1.6;
  background: var(--bg);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}
img, svg { max-width: 100%; height: auto; display: block; }
a { color: var(--primary-600); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--primary-700); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--primary-soft); color: var(--primary-700); }

h1, h2, h3, h4 { line-height: 1.2; color: var(--text); margin: 0 0 .5em; letter-spacing: -0.02em; font-weight: 700; }
h1 { font-size: clamp(1.85rem, 2.5vw + 1rem, 2.75rem); letter-spacing: -0.03em; }
h2 { font-size: clamp(1.4rem, 1.2vw + 1rem, 1.85rem); margin-top: 1.25em; }
h3 { font-size: 1.15rem; }
p  { margin: 0 0 1em; }
code, pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.92em; }

.muted { color: var(--text-muted); }
.small { font-size: 0.875em; }
.lead  { font-size: clamp(1rem, 0.4vw + 0.95rem, 1.15rem); color: var(--text-muted); max-width: 65ch; }

main { display: block; width: 100%; }
.container { width: 100%; max-width: 1180px; margin-left: auto; margin-right: auto; padding-left: 20px; padding-right: 20px; }
.section { margin-top: clamp(28px, 4vw, 48px); margin-bottom: clamp(28px, 4vw, 48px); }
.hero + .section { margin-top: clamp(20px, 3vw, 36px); }

/* Accessibility */
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--primary-600); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ============================================================
   Buttons
============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 10px; cursor: pointer; font: inherit; font-weight: 600; text-decoration: none;
  transition: all .15s var(--ease);
}
.btn:hover { border-color: var(--primary); color: var(--primary-600); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--gradient-primary); color: #fff; border-color: transparent;
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 14px 34px -6px rgb(99 102 241 / 0.55); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-muted); border-color: transparent; transform: none; box-shadow: none; }
.btn-lg { padding: 14px 22px; font-size: 1rem; border-radius: 12px; }

/* ============================================================
   Header (2-row: brand+search on top, nav on bottom)
============================================================ */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: #ffffff;
  border-bottom: 1px solid rgb(226 232 240 / 0.7);
}
/* On desktop, use the frosted-glass effect (translucent + blur). Skipped on
   mobile because backdrop-filter would create a containing block for the
   position:fixed .main-nav drawer and clip it inside the header. */
@media (min-width: 769px) {
  .site-header {
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
  }
}
.header-top { border-bottom: 1px solid rgb(226 232 240 / 0.55); }
.header-top-inner {
  display: flex; align-items: center; gap: 24px;
  max-width: 1180px; margin-left: auto; margin-right: auto;
  padding: 14px 20px;
}
.header-bottom {
  max-width: 1180px; margin-left: auto; margin-right: auto;
  padding: 0 20px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 800; color: var(--text); font-size: 1.1rem; letter-spacing: -0.02em;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px;
  border-radius: 9px;
  background: var(--gradient-primary);
  color: #fff; font-size: 1.05rem; font-weight: 800;
  box-shadow: var(--shadow-primary);
}
.header-search { display: flex; flex: 1; max-width: 520px; margin-left: auto; }
.header-search input {
  width: 100%;
  padding: 10px 14px 10px 40px; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; background: var(--bg-subtle) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.3-4.3'/></svg>") 14px center no-repeat;
  transition: all .15s var(--ease);
}
.header-search input:focus { border-color: var(--primary); background-color: #fff; outline: 3px solid rgb(99 102 241 / 0.15); outline-offset: 0; }

.main-nav {
  display: flex; gap: 2px; justify-content: center; align-items: center;
  min-height: 52px; flex-wrap: wrap;
}
.main-nav a {
  color: var(--text-muted); font-weight: 500;
  padding: 10px 14px; border-radius: 8px; transition: all .15s var(--ease);
  white-space: nowrap;
}
.main-nav a:hover { color: var(--primary-700); background: var(--primary-soft); text-decoration: none; }

/* "All Calculators" mega menu */
.nav-all { position: relative; }
.nav-all-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--text-muted); font-weight: 500; font-family: inherit; font-size: inherit;
  padding: 10px 14px; border-radius: 8px; transition: all .15s var(--ease);
  white-space: nowrap;
}
.nav-all-toggle:hover,
.nav-all[aria-expanded="true"] .nav-all-toggle,
.nav-all-toggle[aria-expanded="true"] { color: var(--primary-700); background: var(--primary-soft); }
.nav-all-toggle svg { transition: transform .2s var(--ease); }
.nav-all-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.nav-all-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 24px 48px -12px rgba(0,0,0,0.18);
  width: 240px;
  padding: 6px; z-index: 100;
}
.nav-all-panel[hidden] { display: none; }
.nav-all-list { list-style: none; padding: 0; margin: 0; }
.nav-all-list li { margin: 0; }
.nav-all-list li a {
  display: block; padding: 5px 10px; border-radius: 6px;
  color: var(--text); font-weight: 500; font-size: 0.9rem;
  transition: all .12s var(--ease);
}
.nav-all-list li a:hover {
  background: var(--primary-soft); color: var(--primary-700); text-decoration: none;
}
.nav-all-foot {
  display: block; margin-top: 4px; padding: 8px 10px;
  border-top: 1px solid var(--border);
  text-align: center; color: var(--primary-700);
  font-weight: 600; font-size: 0.85rem;
  border-radius: 0 0 6px 6px;
  transition: background .12s var(--ease);
}
.nav-all-foot:hover { background: var(--primary-soft); text-decoration: none; }

@media (max-width: 900px) {
  .nav-all-panel {
    position: static; width: 100%; max-height: none;
    box-shadow: none; border: 0; padding: 0; margin-top: 8px;
  }
  .nav-all-toggle { width: 100%; justify-content: space-between; padding: 14px 18px; }
}

/* "All Calculators" page */
.all-jumpnav {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  margin-top: 18px;
}
.all-jumpnav a {
  background: rgba(255,255,255,0.6); border: 1px solid rgba(255,255,255,0.5);
  padding: 6px 12px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 500; color: var(--text);
}
.all-jumpnav a:hover { background: #fff; text-decoration: none; }
.all-cats { display: flex; flex-direction: column; gap: 48px; }
.all-cat-block { scroll-margin-top: 80px; }
.all-cat-head { margin-bottom: 18px; }
.all-cat-head h2 {
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 6px; font-size: 1.6rem;
}
.all-cat-head h2 a { color: inherit; }
.all-cat-head h2 a:hover { color: var(--primary-700); text-decoration: none; }
.all-cat-icon { font-size: 1.6rem; }
.all-cat-count {
  font-size: 0.75rem; font-weight: 600;
  background: var(--primary-soft); color: var(--primary-700);
  border-radius: 999px; padding: 3px 10px;
}

.nav-toggle {
  display: none; background: #fff; border: 1px solid var(--border); border-radius: 10px;
  width: 40px; height: 40px; cursor: pointer; font-size: 1.2rem; color: var(--text);
  align-items: center; justify-content: center; flex-shrink: 0;
}
.nav-toggle .nav-toggle-close { display: none; }
body.nav-open .nav-toggle .nav-toggle-open { display: none; }
body.nav-open .nav-toggle .nav-toggle-close { display: inline; }

.nav-backdrop {
  display: none; position: fixed; inset: 0; background: rgb(15 23 42 / 0.45);
  /* Must sit BELOW .site-header (z-index 50) so the drawer — which is trapped
     inside the header's stacking context — stays clickable above the backdrop. */
  z-index: 40; animation: fade-in .2s var(--ease);
}
body.nav-open .nav-backdrop { display: block; }

@keyframes fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-in { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* ============================================================
   Hero
============================================================ */
.hero {
  background: var(--gradient-hero);
  padding: clamp(32px, 5vw, 56px) 0 clamp(32px, 5vw, 52px);
  text-align: center; position: relative; overflow: hidden;
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 999px;
  background: rgb(255 255 255 / 0.75); border: 1px solid var(--border);
  font-size: 0.825rem; font-weight: 600; color: var(--primary-700);
  margin-bottom: 20px; box-shadow: var(--shadow-xs);
}
.hero-eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgb(16 185 129 / 0.2); }
.hero h1 {
  font-size: clamp(2rem, 4vw + 1rem, 3.5rem); letter-spacing: -0.035em;
  margin: 0 auto .4em; max-width: 16ch;
}
.hero h1 .grad {
  background: var(--gradient-primary);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .lead { margin: 0 auto 32px; max-width: 50ch; font-size: clamp(1rem, 0.4vw + 1rem, 1.2rem); }
.hero-search {
  max-width: 620px; margin: 0 auto;
  display: flex; gap: 10px; padding: 8px;
  background: #fff; border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg);
}
.hero-search input {
  flex: 1; padding: 12px 16px; border: 0; border-radius: 10px;
  font-size: 1rem; background: transparent; outline: none;
}
.hero-search button {
  padding: 12px 22px; background: var(--gradient-primary); color: #fff; border: 0; border-radius: 10px;
  font: inherit; font-weight: 600; cursor: pointer; transition: all .15s var(--ease);
  box-shadow: var(--shadow-primary);
}
.hero-search button:hover { transform: translateY(-1px); }

.hero-stats {
  display: flex; justify-content: center; gap: 32px; flex-wrap: wrap;
  margin-top: 28px; color: var(--text-muted); font-size: 0.9rem;
}
.hero-stats strong { display: block; color: var(--text); font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }

/* ============================================================
   Cards (calculators + blog)
============================================================ */
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px;
}
.card-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .card-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .card-grid-3 { grid-template-columns: 1fr; } }
.card {
  display: block; position: relative; padding: 24px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: #fff;
  color: inherit; transition: all .2s var(--ease); overflow: hidden;
}
.card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--gradient-primary); opacity: 0; transition: opacity .2s var(--ease);
}
.card:hover {
  text-decoration: none; border-color: transparent;
  box-shadow: var(--shadow-lg); transform: translateY(-4px);
}
.card:hover::before { opacity: 1; }
.card h3 { margin: 0 0 6px; color: var(--text); }
.card p { color: var(--text-muted); margin: 0 0 12px; font-size: 0.95rem; }
.card .tag {
  display: inline-block; padding: 3px 10px; font-size: 0.72rem; font-weight: 600;
  background: var(--primary-soft); color: var(--primary-700); border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* ============================================================
   Category cards (homepage)
============================================================ */
.cat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px;
}
.cat-card {
  display: flex; flex-direction: column; padding: 24px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: #fff;
  color: inherit; transition: all .2s var(--ease); overflow: hidden; position: relative;
  min-height: 180px;
}
.cat-card:hover { text-decoration: none; border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-3px); }
.cat-card__head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.cat-card .cat-icon {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  width: 48px; height: 48px;
  font-size: 1.8rem; line-height: 1;
}
.cat-card h3 { margin: 0; color: var(--text); }
.cat-card p { color: var(--text-muted); margin: 0 0 14px; font-size: 0.92rem; }
.cat-card small {
  margin-top: auto; font-weight: 600; color: var(--primary-700); font-size: 0.82rem;
  display: inline-flex; align-items: center; gap: 4px;
}
.cat-card small::after { content: "→"; transition: transform .15s var(--ease); }
.cat-card:hover small::after { transform: translateX(3px); }

/* ============================================================
   Category page hero (compact version of home hero)
============================================================ */
.cat-hero {
  background: var(--gradient-hero);
  padding: 0 0 clamp(16px, 2vw, 24px);
  position: relative; overflow: hidden;
}
.cat-hero-crumb { padding: 10px 0 0; }
.cat-head {
  text-align: center;
  padding: clamp(8px, 1.2vw, 14px) 0 0;
  display: flex; flex-direction: column; align-items: center;
}
.cat-head-icon {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; border-radius: 12px;
  background: #fff; color: var(--primary-700);
  font-size: 1.4rem; margin-bottom: 8px;
  box-shadow: 0 6px 18px -10px rgba(99,102,241,.35);
}
.cat-head h1 { margin: 0 0 6px; font-size: clamp(1.4rem, 1.6vw + 1rem, 2rem); }
.cat-head .lead { margin: 0 auto; max-width: 58ch; font-size: clamp(0.9rem, 0.2vw + 0.9rem, 1rem); }
.cat-head-pill {
  margin-top: 10px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px;
  background: rgb(255 255 255 / 0.8); border: 1px solid var(--border);
  font-size: 0.8rem; color: var(--text-muted);
}
.cat-head-pill strong { color: var(--primary-700); }
.cat-hero + .section { margin-top: clamp(16px, 2vw, 28px); }
@media (max-width: 640px) {
  .cat-hero { padding-bottom: 14px; }
  .cat-head-icon { width: 40px; height: 40px; font-size: 1.25rem; }
}

/* ============================================================
   Pills & chips
============================================================ */
.pill-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pill-list a {
  display: inline-block; padding: 8px 16px; background: var(--bg-muted); color: var(--text);
  border-radius: 999px; font-size: 0.9rem; font-weight: 500; border: 1px solid transparent;
  transition: all .15s var(--ease);
}
.pill-list a:hover { background: var(--primary-soft); color: var(--primary-700); border-color: var(--primary); text-decoration: none; }
.pill-list a.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pill-list a.active:hover { background: var(--primary-700); color: #fff; border-color: var(--primary-700); }
.blog-cats { margin-bottom: 24px; }
.card .tag { margin-bottom: 10px; }

/* ============================================================
   Breadcrumbs
============================================================ */
.breadcrumb { padding: 20px 20px 0; color: var(--text-subtle); font-size: 0.875rem; }
.breadcrumb a { color: var(--primary-600); }
.breadcrumb .sep { margin: 0 8px; color: var(--border-strong); }

/* ============================================================
   Calculator page
============================================================ */
.calc-page { padding: 8px 0 64px; }
.calc-head { margin-bottom: 12px; }
.calc-head h1 { margin: 8px 0 10px; }
.calc-head .lead { max-width: none; }

.calc-widget {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px;
  padding: clamp(20px, 3vw, 32px);
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-xl);
  box-shadow: var(--shadow); margin-top: 24px;
  position: relative; overflow: hidden;
}
.calc-widget::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--gradient-primary);
}

.calc-inputs { display: flex; flex-direction: column; gap: 18px; }
.calc-inputs .field { display: flex; flex-direction: column; gap: 6px; }
.calc-inputs label { font-weight: 600; color: var(--text); font-size: 0.92rem; }
.calc-inputs .unit { color: var(--text-subtle); font-weight: 500; font-size: 0.82rem; }

.calc-inputs input[type=number],
.calc-inputs input[type=text],
.calc-inputs input[type=date],
.calc-inputs select,
.calc-inputs textarea {
  padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 10px;
  font: inherit; background: #fff; transition: all .15s var(--ease);
  color: var(--text);
}
.calc-inputs textarea { resize: vertical; min-height: 96px; font-family: inherit; line-height: 1.5; }
.calc-inputs input:focus,
.calc-inputs select:focus,
.calc-inputs textarea:focus {
  border-color: var(--primary); outline: 3px solid rgb(99 102 241 / 0.15);
}

.radio-group { display: flex; gap: 8px; flex-wrap: wrap; }
.radio {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border: 1.5px solid var(--border); border-radius: 10px; cursor: pointer;
  background: #fff; font-size: 0.92rem; font-weight: 500; color: var(--text-muted);
  transition: all .15s var(--ease);
}
.radio:hover { border-color: var(--primary); color: var(--primary-700); }
.radio input { accent-color: var(--primary-600); }
.radio:has(input:checked) {
  background: var(--primary-soft); border-color: var(--primary); color: var(--primary-700);
}

.btn-row { margin-top: 8px; display: flex; justify-content: flex-end; }

.btn-reset {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border: 1.5px solid var(--border); background: #fff;
  color: var(--text-muted); border-radius: 10px; font: inherit; font-weight: 600;
  font-size: 0.88rem; cursor: pointer; transition: all .15s var(--ease);
}
.btn-reset:hover {
  border-color: var(--danger); color: var(--danger); background: #fef2f2;
  transform: translateY(-1px); box-shadow: var(--shadow-sm);
}
.btn-reset:active { transform: translateY(0); }
.btn-reset svg { transition: transform .4s var(--ease); }
.btn-reset:hover svg { transform: rotate(-180deg); }

.calc-results {
  display: flex; flex-direction: column; gap: 16px; justify-content: center;
  background: linear-gradient(180deg, #fafbff 0%, #f5f3ff 100%);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: clamp(20px, 3vw, 28px);
}
.result { display: flex; flex-direction: column; gap: 4px; padding: 2px 0; }
.result-label {
  font-size: 0.78rem; color: var(--text-subtle); text-transform: uppercase;
  letter-spacing: 0.08em; font-weight: 600;
}
.result-value {
  font-size: 1.4rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.result-big {
  padding: 18px 20px; background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  position: relative;
}
.result-big .result-label { color: var(--primary-700); }
.result-big .result-value {
  font-size: clamp(1.75rem, 2vw + 1rem, 2.25rem);
  background: var(--gradient-primary);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ============================================================
   Prose / articles
============================================================ */
.prose {
  max-width: 780px; margin: 40px auto 0;
  color: var(--text); font-size: 1rem;
}
.prose h2 { margin-top: 1.6em; }
.prose p, .prose li { color: var(--text); }
.prose ul, .prose ol { padding-left: 22px; margin-bottom: 1.1em; }
.prose li { margin-bottom: 6px; }
.prose strong { color: var(--text); }
.prose blockquote {
  border-left: 3px solid var(--primary); padding: 10px 18px; margin: 20px 0;
  color: var(--text-muted); background: var(--primary-soft); border-radius: 0 10px 10px 0;
}
.prose code {
  background: var(--bg-muted); padding: 2px 8px; border-radius: 6px;
  color: var(--primary-700); font-size: 0.9em;
}

/* ============================================================
   FAQ
============================================================ */
.faq details {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px;
  margin-bottom: 10px; background: #fff; transition: all .15s var(--ease);
}
.faq details[open] { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.faq summary { font-weight: 600; cursor: pointer; list-style: none; color: var(--text); padding-right: 28px; position: relative; }
.faq summary::marker, .faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ""; position: absolute; right: 0; top: 50%;
  width: 10px; height: 10px; border-right: 2px solid var(--primary); border-bottom: 2px solid var(--primary);
  transform: translateY(-75%) rotate(45deg); transition: transform .2s var(--ease);
}
.faq details[open] summary::after { transform: translateY(-25%) rotate(-135deg); }
.faq-answer { padding-top: 12px; color: var(--text-muted); }
.faq-answer p:last-child { margin-bottom: 0; }

/* ============================================================
   Search
============================================================ */
.search-inline { display: flex; gap: 8px; margin-bottom: 24px; }
.search-inline input {
  flex: 1; padding: 12px 16px; border: 1.5px solid var(--border); border-radius: 10px;
}
.search-inline input:focus { border-color: var(--primary); outline: 3px solid rgb(99 102 241 / 0.15); }
.search-inline button {
  padding: 12px 22px; background: var(--gradient-primary); color: #fff; border: 0; border-radius: 10px;
  cursor: pointer; font-weight: 600; box-shadow: var(--shadow-primary);
}

/* ============================================================
   Article
============================================================ */
.article { padding: 20px 20px 60px; max-width: 780px; margin: 0 auto; }
.article header { margin-bottom: 24px; }

/* ============================================================
   Footer
============================================================ */
.site-footer {
  background: var(--bg-dark); color: var(--text-on-dark); margin-top: 80px;
  padding: 56px 0 24px;
}
.site-footer h3, .site-footer h4 { color: #fff; margin-bottom: 14px; }
.site-footer a { color: #cbd5e1; }
.site-footer a:hover { color: #fff; }
.footer-grid {
  display: grid; grid-template-columns: 2fr 3fr 1fr; gap: 36px;
}
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin-bottom: 8px; }
.footer-grid .brand { color: #fff; }
.footer-cats { column-count: 2; column-gap: 24px; }
.footer-cats li { break-inside: avoid; }
.footer-bottom {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px;
  border-top: 1px solid #1e293b;
  margin-top: 36px; padding-top: 20px; font-size: 0.875rem; color: #94a3b8;
}
.footer-legal { display: flex; flex-wrap: wrap; align-items: center; gap: 0; }
.footer-legal a { color: #cbd5e1; padding: 0 12px; border-left: 1px solid #334155; line-height: 1; }
.footer-legal a:first-child { border-left: 0; padding-left: 0; }
.footer-legal a:last-child  { padding-right: 0; }
.footer-legal a:hover { color: #fff; }

/* ============================================================
   Not-found / empty states
============================================================ */
.empty {
  text-align: center; padding: 80px 20px; color: var(--text-muted);
}
.empty h1 { font-size: clamp(3rem, 8vw, 5rem); margin: 0 0 12px; background: var(--gradient-primary); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ============================================================
   Responsive
============================================================ */
@media (max-width: 960px) {
  .calc-widget { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 28px; }
}

@media (max-width: 768px) {
  .header-top-inner { gap: 10px; padding: 10px 14px; flex-wrap: nowrap; }
  .header-search { max-width: none; margin-left: 0; flex: 1 1 auto; min-width: 0; }
  .header-search input { min-width: 0; width: 100%; }
  .brand { min-width: 0; }
  .brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
  .nav-toggle { position: relative; z-index: 80; }
  .header-bottom { display: contents; }
  .main-nav {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(320px, 82vw);
    background: #fff; flex-direction: column; justify-content: flex-start;
    padding: 80px 20px 20px;
    box-shadow: -20px 0 50px -10px rgb(15 23 42 / 0.25);
    transform: translateX(100%); transition: transform .28s var(--ease);
    z-index: 70; gap: 2px; min-height: 0; flex-wrap: nowrap;
    overflow-y: auto; align-items: stretch;
  }
  body.nav-open .main-nav { transform: translateX(0); }
  .main-nav a {
    width: 100%; padding: 14px 16px; border-radius: 10px; font-size: 1.02rem;
    color: var(--text);
  }
  .nav-toggle { display: inline-flex; flex-shrink: 0; }

  .hero { padding: 32px 0 32px; }
  .hero-search { flex-direction: column; padding: 10px; }
  .hero-search input { padding: 12px 16px; }
  .hero-search button { width: 100%; }
  .hero-stats { gap: 20px; }
  .hero-stats strong { font-size: 1.25rem; }

  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
  .footer-bottom { flex-direction: column; align-items: flex-start; }

  .card-grid, .cat-grid { grid-template-columns: 1fr; gap: 14px; }
  .card, .cat-card { padding: 20px; }

  .prose { padding: 0 4px; }
}

@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .hero h1 { font-size: clamp(1.8rem, 8vw, 2.4rem); }
  .btn { padding: 10px 16px; }
}

/* Prefers-reduced-motion: keep it kind */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .card:hover, .cat-card:hover, .btn:hover { transform: none; }
}

/* Print */
@media print {
  .site-header, .site-footer, .nav-toggle, .btn-row, .nav-backdrop { display: none !important; }
  a { text-decoration: none; color: #000; }
  .calc-widget { border: 1px solid #999; box-shadow: none; page-break-inside: avoid; }
  .calc-widget::before { display: none; }
}

/* ============================================================
   TI-84 Style Calculator
============================================================ */
.ti84-stage {
  display: flex; justify-content: center; padding: 32px 0 16px;
}
.ti84-device {
  width: 100%; max-width: 360px;
  background: linear-gradient(180deg, #2c2f36 0%, #1a1d22 100%);
  border-radius: 26px;
  padding: 22px 18px 24px;
  box-shadow: 0 24px 48px -12px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(255,255,255,0.04);
  user-select: none;
  position: relative;
}
.ti84-brand {
  display: flex; align-items: baseline; gap: 8px; justify-content: center;
  color: #cfd2d6; font-weight: 600; letter-spacing: 0.5px;
  margin-bottom: 14px; font-size: 0.85rem;
}
.ti84-logo { color: #e8eaed; font-size: 1rem; letter-spacing: 1.5px; }
.ti84-sub { color: #a0a4aa; font-size: 0.75rem; }

.ti84-screen-frame {
  background: #14161a; border-radius: 8px; padding: 8px;
  margin-bottom: 16px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.6);
}
.ti84-screen {
  background: #abc7a3;
  background: linear-gradient(180deg, #b9d3a8 0%, #9fbf90 100%);
  border-radius: 4px;
  padding: 12px 12px 14px;
  font-family: 'Courier New', 'Roboto Mono', monospace;
  color: #0d2614;
  min-height: 120px;
  position: relative;
  display: flex; flex-direction: column;
}
.ti84-screen-mode {
  position: absolute; top: 6px; right: 10px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 1px;
  color: #2a4a2a;
}
.ti84-screen-history {
  font-size: 0.85rem; opacity: 0.55; min-height: 16px;
  text-align: right; margin-bottom: 4px; word-break: break-all;
}
.ti84-screen-expr {
  font-size: 1.1rem; line-height: 1.3; min-height: 24px;
  text-align: right; flex: 1; word-break: break-all;
}
.ti84-screen-result {
  text-align: right; font-size: 1.4rem; font-weight: 700;
  margin-top: 6px; min-height: 24px; word-break: break-all;
}

.ti84-keys { display: flex; flex-direction: column; gap: 8px; }
.ti84-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.ti84-row.ti84-extras { grid-template-columns: repeat(6, 1fr); margin-top: 4px; }

.key {
  background: linear-gradient(180deg, #45494f 0%, #2e3137 100%);
  color: #e8eaed;
  border: none;
  border-radius: 6px;
  padding: 12px 4px;
  font-size: 0.8rem; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 2px 0 rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.08);
  transition: transform .08s ease, box-shadow .08s ease, background .15s ease;
  text-align: center;
}
.key:hover { background: linear-gradient(180deg, #525660 0%, #353940 100%); }
.key:active {
  transform: translateY(1px);
  box-shadow: 0 0 0 rgba(0,0,0,0.4), inset 0 1px 4px rgba(0,0,0,0.4);
}
.key-num {
  background: linear-gradient(180deg, #f5f6f8 0%, #d6d9dd 100%);
  color: #1a1d22;
  font-size: 1rem;
}
.key-num:hover { background: linear-gradient(180deg, #ffffff 0%, #e2e5e9 100%); }
.key-op {
  background: linear-gradient(180deg, #f5f6f8 0%, #d6d9dd 100%);
  color: #1a1d22;
  font-size: 1.1rem; font-weight: 700;
}
.key-op:hover { background: linear-gradient(180deg, #ffffff 0%, #e2e5e9 100%); }
.key-yellow {
  background: linear-gradient(180deg, #f0c244 0%, #c89422 100%);
  color: #2a2400;
}
.key-yellow:hover { background: linear-gradient(180deg, #ffd45e 0%, #d8a233 100%); }
.key-clear {
  background: linear-gradient(180deg, #2779e6 0%, #1957b3 100%);
  color: #fff;
}
.key-clear:hover { background: linear-gradient(180deg, #3a8af0 0%, #2667c8 100%); }
.key-enter {
  background: linear-gradient(180deg, #2779e6 0%, #1957b3 100%);
  color: #fff;
  font-weight: 700;
}
.key-enter:hover { background: linear-gradient(180deg, #3a8af0 0%, #2667c8 100%); }
.key-power {
  background: linear-gradient(180deg, #6ea84e 0%, #4d7d33 100%);
  color: #fff;
}
.key-extra {
  background: linear-gradient(180deg, #38454f 0%, #21282e 100%);
  font-size: 0.95rem;
}
.key-extra:hover { background: linear-gradient(180deg, #455461 0%, #2a323a 100%); }

.ti84-hint {
  text-align: center; color: #a0a4aa; font-size: 0.75rem;
  margin: 14px 0 0; line-height: 1.5;
}
.ti84-hint kbd {
  background: #45494f; color: #fff; border-radius: 3px;
  padding: 1px 6px; font-size: 0.7rem; font-family: inherit;
}

@media (max-width: 420px) {
  .ti84-device { max-width: 100%; padding: 18px 14px 20px; }
  .key { padding: 10px 2px; font-size: 0.72rem; }
  .key-num, .key-op { font-size: 0.95rem; }
  .ti84-screen { min-height: 100px; }
  .ti84-screen-expr { font-size: 1rem; }
  .ti84-screen-result { font-size: 1.2rem; }
}
/* ============================================================
   Desk Calculator (Percentage)
============================================================ */
.desk-stage { display: flex; justify-content: center; padding: 32px 0 16px; }
.desk-device {
  width: 100%; max-width: 360px;
  background: linear-gradient(180deg, #f0f1f3 0%, #d8dadd 100%);
  border-radius: 24px; padding: 22px 18px 18px;
  box-shadow: 0 24px 48px -12px rgba(0,0,0,0.25), inset 0 0 0 1px rgba(0,0,0,0.04);
  user-select: none;
}
.desk-screen {
  background: #1d2228; color: #d8e0d4;
  border-radius: 12px; padding: 18px 20px 14px;
  margin-bottom: 16px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.5);
  font-family: "Roboto Mono", "Courier New", monospace;
  position: relative; min-height: 80px;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.desk-mem-flag {
  position: absolute; top: 8px; left: 14px;
  font-size: 0.7rem; font-weight: 700; color: #f0c244;
  visibility: hidden;
}
.desk-history {
  font-size: 0.85rem; opacity: 0.55; min-height: 16px;
  text-align: right; word-break: break-all;
}
.desk-display {
  font-size: 2rem; text-align: right;
  font-weight: 600; word-break: break-all;
  line-height: 1.2;
}
.desk-keys {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.desk-key {
  background: linear-gradient(180deg, #ffffff 0%, #e3e6ea 100%);
  color: #1a1d22; border: none; border-radius: 12px;
  padding: 16px 8px; font-size: 1.1rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 2px 0 rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.8);
  transition: transform .08s ease, box-shadow .08s ease, background .15s ease;
}
.desk-key:hover { background: linear-gradient(180deg, #ffffff 0%, #ecf0f4 100%); }
.desk-key:active {
  transform: translateY(1px);
  box-shadow: 0 0 0 rgba(0,0,0,0.1), inset 0 1px 4px rgba(0,0,0,0.15);
}
.desk-key-num { font-weight: 500; }
.desk-mem-key {
  background: linear-gradient(180deg, #54a0ff 0%, #3782e3 100%);
  color: #fff; font-size: 0.85rem;
}
.desk-mem-key:hover { background: linear-gradient(180deg, #6cb0ff 0%, #4690ec 100%); }
.desk-key-clear {
  background: linear-gradient(180deg, #ff6b6b 0%, #db4a4a 100%);
  color: #fff;
}
.desk-key-clear:hover { background: linear-gradient(180deg, #ff8585 0%, #e96060 100%); }
.desk-key-percent {
  background: linear-gradient(180deg, #f0c244 0%, #c89422 100%);
  color: #2a2400;
}
.desk-key-op {
  background: linear-gradient(180deg, #ff9f43 0%, #ee7c1f 100%);
  color: #fff; font-size: 1.3rem; font-weight: 700;
}
.desk-key-op:hover { background: linear-gradient(180deg, #ffa959 0%, #f48a30 100%); }
.desk-key-equals {
  background: linear-gradient(180deg, #2779e6 0%, #1957b3 100%);
  color: #fff; font-size: 1.3rem; font-weight: 700;
}
.desk-key-equals:hover { background: linear-gradient(180deg, #3a8af0 0%, #2667c8 100%); }
.desk-key-zero { grid-column: span 2; }
.desk-hint {
  text-align: center; color: #6b7280; font-size: 0.8rem;
  margin: 14px 0 0;
}
.desk-hint code { background: #fff; padding: 2px 6px; border-radius: 3px; font-size: 0.75rem; }

.calc-divider {
  display: flex; align-items: center;
  text-align: center; color: var(--text-subtle, #6b7280);
  font-size: 0.85rem; font-weight: 500;
  margin: 24px 0 16px; gap: 12px;
  text-transform: uppercase; letter-spacing: 1px;
}
.calc-divider::before, .calc-divider::after {
  content: ''; flex: 1; height: 1px; background: #e5e7eb;
}

/* Article header (blog post) */
.article-header { margin-bottom: 28px; }
.article-header h1 { margin: 0 0 12px; }
.article-header .lead { font-size: 1.15rem; color: var(--text-muted, #4b5563); margin: 0 0 16px; }
.article-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  font-size: 0.9rem; color: var(--text-subtle, #6b7280);
}
.article-meta-sep { opacity: 0.5; }
.article-byline { font-weight: 500; }
.article-date, .article-updated, .article-reading { color: inherit; }

/* ============================================================
   Tip Calculator
============================================================ */
.tip-stage { display: flex; justify-content: center; padding: 32px 0 16px; }
.tip-device {
  width: 100%; max-width: 420px;
  background: linear-gradient(180deg, #ffffff 0%, #f4f5f7 100%);
  border-radius: 24px; padding: 24px;
  box-shadow: 0 24px 48px -12px rgba(0,0,0,0.18), inset 0 0 0 1px rgba(0,0,0,0.04);
  user-select: none;
}
.tip-bill {
  text-align: center; margin-bottom: 16px;
  background: linear-gradient(180deg, #4f46e5 0%, #3b34c4 100%);
  color: #fff; padding: 18px; border-radius: 16px;
  box-shadow: 0 8px 16px -4px rgba(79, 70, 229, 0.4);
}
.tip-bill-label {
  font-size: 0.8rem; opacity: 0.85; margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: 1px;
}
.tip-bill-value {
  font-size: 2.4rem; font-weight: 700;
  font-family: "Roboto Mono", monospace;
}
.tip-keys {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-bottom: 18px;
}
.tip-key {
  background: linear-gradient(180deg, #ffffff 0%, #e3e6ea 100%);
  color: #1a1d22; border: none; border-radius: 12px;
  padding: 16px 8px; font-size: 1.2rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 2px 0 rgba(0,0,0,0.08);
  transition: transform .08s ease, background .15s ease;
}
.tip-key:hover { background: linear-gradient(180deg, #ffffff 0%, #ecf0f4 100%); }
.tip-key:active { transform: translateY(1px); }
.tip-key-clear {
  background: linear-gradient(180deg, #ff6b6b 0%, #db4a4a 100%);
  color: #fff;
}
.tip-key-back { background: linear-gradient(180deg, #94a3b8 0%, #6b7280 100%); color: #fff; }
.tip-section { margin-bottom: 18px; }
.tip-section-label {
  font-size: 0.85rem; font-weight: 600; color: #4b5563;
  margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px;
}
.tip-pills {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.tip-pill {
  background: #f4f5f7; border: 2px solid transparent;
  color: #1a1d22; border-radius: 12px; padding: 10px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  font-family: inherit;
  transition: all .15s ease;
}
.tip-pill:hover { background: #eaeaef; }
.tip-pill.active {
  background: #4f46e5; color: #fff; border-color: #4f46e5;
}
.tip-pill-custom { font-style: italic; }
.tip-custom-input {
  width: 100%; margin-top: 8px; padding: 10px 12px;
  border: 2px solid #4f46e5; border-radius: 12px;
  font-size: 1rem; font-family: inherit; box-sizing: border-box;
}
.tip-split {
  display: flex; align-items: center; gap: 12px;
  background: #f4f5f7; border-radius: 16px; padding: 8px;
}
.tip-split-btn {
  background: #fff; border: none; border-radius: 10px;
  width: 44px; height: 44px; font-size: 1.4rem; font-weight: 700;
  cursor: pointer; color: #4f46e5; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.tip-split-btn:hover { background: #eef0ff; }
.tip-split-value {
  flex: 1; text-align: center; font-size: 1.1rem;
  font-weight: 600; color: #1a1d22;
}
.tip-results {
  background: #f9fafb; border-radius: 16px; padding: 14px 18px;
}
.tip-result-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid #e5e7eb;
}
.tip-result-row:last-child { border-bottom: none; }
.tip-result-label { color: #6b7280; font-size: 0.95rem; }
.tip-result-value {
  font-size: 1.2rem; font-weight: 700; font-family: "Roboto Mono", monospace;
}
.tip-result-total .tip-result-value { color: #4f46e5; font-size: 1.4rem; }

/* ============================================================
   Programmer (Binary/Decimal/Hex) Calculator
============================================================ */
.prog-stage { display: flex; justify-content: center; padding: 32px 0 16px; }
.prog-device {
  width: 100%; max-width: 540px;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border-radius: 16px; padding: 22px;
  box-shadow: 0 24px 48px -12px rgba(0,0,0,0.4);
  color: #e2e8f0; user-select: none;
}
.prog-modes {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  background: #0a0f1c; border-radius: 8px; padding: 4px;
  margin-bottom: 14px;
}
.prog-mode {
  background: transparent; border: none; color: #94a3b8;
  padding: 8px; font-size: 0.85rem; font-weight: 700; letter-spacing: 1px;
  cursor: pointer; border-radius: 6px; font-family: inherit;
  transition: all .15s ease;
}
.prog-mode:hover { color: #cbd5e1; }
.prog-mode.active { background: #3b82f6; color: #fff; }
.prog-display {
  background: #0a0f1c; color: #38bdf8;
  font-family: "Roboto Mono", "Courier New", monospace;
  font-size: 1.8rem; font-weight: 600;
  padding: 14px 18px; border-radius: 8px; margin-bottom: 12px;
  text-align: right; word-break: break-all; min-height: 32px;
  border: 1px solid #1e2a3e;
}
.prog-equivalents {
  background: #0a0f1c; border-radius: 8px; padding: 8px 14px;
  margin-bottom: 12px; border: 1px solid #1e2a3e;
}
.prog-eq-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0; border-bottom: 1px solid #1e2a3e;
  font-family: "Roboto Mono", monospace; font-size: 0.85rem;
}
.prog-eq-row:last-child { border-bottom: none; }
.prog-eq-label {
  color: #64748b; font-weight: 700; letter-spacing: 1px;
  font-size: 0.7rem; min-width: 40px;
}
.prog-eq-val {
  color: #cbd5e1; word-break: break-all; text-align: right;
  flex: 1;
}
.prog-eq-bin { font-size: 0.7rem; }
.prog-bits {
  display: grid; grid-template-columns: repeat(16, 1fr); gap: 1px;
  background: #0a0f1c; padding: 8px; border-radius: 6px;
  margin-bottom: 14px; border: 1px solid #1e2a3e;
}
.prog-bit {
  background: #1e293b; color: #475569;
  font-family: "Roboto Mono", monospace; font-size: 0.7rem;
  padding: 4px 0; text-align: center; border-radius: 2px;
  cursor: pointer; transition: all .1s ease;
}
.prog-bit:hover { background: #2d3a52; }
.prog-bit-on { background: #1e3a8a; color: #38bdf8; font-weight: 700; }
.prog-bit-divider { margin-right: 4px; }

.prog-keys {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
}
.prog-key {
  background: linear-gradient(180deg, #475569 0%, #334155 100%);
  color: #f1f5f9; border: none; border-radius: 8px;
  padding: 14px 4px; font-size: 0.95rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 2px 0 rgba(0,0,0,0.3);
  transition: all .1s ease;
}
.prog-key:hover { background: linear-gradient(180deg, #5b6b80 0%, #3e4a60 100%); }
.prog-key:active { transform: translateY(1px); box-shadow: 0 0 0 rgba(0,0,0,0.3); }
.prog-key-disabled {
  opacity: 0.3; cursor: not-allowed; pointer-events: none;
}
.prog-key-hex { background: linear-gradient(180deg, #6366f1 0%, #4338ca 100%); }
.prog-key-hex:hover { background: linear-gradient(180deg, #7c7ff5 0%, #5046d3 100%); }
.prog-key-op {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  color: #fff; font-size: 0.85rem;
}
.prog-key-op:hover { background: linear-gradient(180deg, #fbbf24 0%, #e08c12 100%); }
.prog-key-clear { background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%); }
.prog-key-clear:hover { background: linear-gradient(180deg, #f87171 0%, #dc2626 100%); }
.prog-key-back { background: linear-gradient(180deg, #6b7280 0%, #4b5563 100%); }
.prog-key-equals {
  background: linear-gradient(180deg, #10b981 0%, #047857 100%);
  grid-row: span 2; font-size: 1.2rem;
}
.prog-key-equals:hover { background: linear-gradient(180deg, #14d99e 0%, #069168 100%); }
.prog-key-zero { grid-column: span 3; }

/* ============================================================
   Fraction Calculator (Casio fx style)
============================================================ */
.frac-stage { display: flex; justify-content: center; padding: 32px 0 16px; }
.frac-device {
  width: 100%; max-width: 360px;
  background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
  border-radius: 22px; padding: 22px;
  box-shadow: 0 24px 48px -12px rgba(0,0,0,0.4);
  user-select: none;
}
.frac-screen-frame {
  background: #0a0f1c; padding: 8px; border-radius: 8px;
  margin-bottom: 16px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.5);
}
.frac-screen {
  background: linear-gradient(180deg, #dde0b3 0%, #c4ca99 100%);
  color: #1d2410; border-radius: 4px; padding: 12px 14px;
  font-family: "Roboto Mono", "Courier New", monospace;
  min-height: 110px;
  display: flex; flex-direction: column;
  position: relative;
}
.frac-screen-mode {
  position: absolute; top: 6px; right: 10px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 1px;
}
.frac-screen-history {
  font-size: 0.8rem; opacity: 0.6; min-height: 16px;
  text-align: right; margin-bottom: 4px;
}
.frac-screen-expr {
  font-size: 1.4rem; line-height: 1.3; min-height: 28px;
  text-align: right; flex: 1; word-break: break-all;
  font-weight: 600;
}
.frac-screen-result {
  text-align: right; font-size: 1.6rem; font-weight: 700;
  margin-top: 8px; min-height: 28px;
}

.frac-keys {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px;
}
.frac-key {
  background: linear-gradient(180deg, #4b5563 0%, #374151 100%);
  color: #e5e7eb; border: none; border-radius: 8px;
  padding: 14px 4px; font-size: 1rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 2px 0 rgba(0,0,0,0.3);
  transition: all .1s ease;
}
.frac-key:hover { background: linear-gradient(180deg, #5b6b80 0%, #475263 100%); }
.frac-key:active { transform: translateY(1px); box-shadow: 0 0 0 rgba(0,0,0,0.3); }
.frac-key-op {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  color: #fff; font-size: 1.1rem; font-weight: 700;
}
.frac-key-op:hover { background: linear-gradient(180deg, #fbbf24 0%, #e08c12 100%); }
.frac-key-clear { background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%); color: #fff; }
.frac-key-clear:hover { background: linear-gradient(180deg, #f87171 0%, #dc2626 100%); }
.frac-key-equals {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff; font-size: 1.2rem; font-weight: 700;
}
.frac-key-equals:hover { background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%); }
.frac-key-special {
  background: linear-gradient(180deg, #7c3aed 0%, #5b21b6 100%);
  color: #fff; font-size: 0.85rem;
}
.frac-key-special:hover { background: linear-gradient(180deg, #8b5cf6 0%, #6d28d9 100%); }
.frac-key-back { background: linear-gradient(180deg, #6b7280 0%, #4b5563 100%); }
.frac-hint {
  text-align: center; color: #94a3b8; font-size: 0.75rem;
  margin: 14px 0 0;
}
.frac-hint kbd {
  background: #45494f; color: #fff; border-radius: 3px;
  padding: 1px 6px; font-size: 0.7rem; font-family: inherit;
}

@media (max-width: 480px) {
  .desk-device, .frac-device { max-width: 100%; padding: 16px; }
  .desk-key, .frac-key { padding: 12px 4px; font-size: 0.9rem; }
  .desk-display { font-size: 1.6rem; }
  .frac-screen-expr { font-size: 1.2rem; }
  .tip-device { padding: 16px; }
  .prog-device { max-width: 100%; padding: 14px; }
  .prog-key { padding: 10px 2px; font-size: 0.8rem; }
  .prog-bit { font-size: 0.6rem; padding: 2px 0; }
  .prog-display { font-size: 1.4rem; }
}

/* ========== Static legal pages (about, privacy, terms, disclaimer) ========== */
.legal-page { max-width: 820px; }
.legal-page h2 { font-size: 1.45rem; margin-top: 32px; margin-bottom: 12px; color: #111827; }
.legal-page h3 { font-size: 1.1rem; margin-top: 20px; margin-bottom: 8px; color: #1f2937; }
.legal-page p { line-height: 1.7; margin: 0 0 14px; color: #374151; }
.legal-page ul, .legal-page ol { line-height: 1.7; margin: 0 0 14px; padding-left: 24px; color: #374151; }
.legal-page li { margin-bottom: 6px; }
.legal-page a { color: #4f46e5; text-decoration: underline; text-underline-offset: 3px; }
.legal-page a:hover { color: #3730a3; }
.legal-page code { background: #f3f4f6; padding: 1px 6px; border-radius: 4px; font-size: 0.92em; }
.legal-page blockquote { margin: 16px 0; }

/* ========== Contact page ========== */
.contact-grid {
  display: grid; grid-template-columns: minmax(0,1.5fr) minmax(0,1fr); gap: 32px;
}
@media (max-width: 820px) { .contact-grid { grid-template-columns: 1fr; } }
.contact-form-wrap { min-width: 0; }
.contact-form label { display: block; margin-bottom: 14px; font-weight: 500; color: #1f2937; }
.contact-form input[type=text],
.contact-form input[type=email],
.contact-form textarea {
  width: 100%; padding: 10px 14px; margin-top: 4px;
  border: 1px solid #d1d5db; border-radius: 8px; font: inherit; background: #fff;
}
.contact-form textarea { resize: vertical; min-height: 160px; }
.contact-form .field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.contact-flash {
  padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 0.95rem;
}
.contact-flash-ok  { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.contact-flash-err { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.contact-aside h3 { font-size: 1rem; margin-top: 24px; margin-bottom: 8px; color: #111827; }
.contact-aside h3:first-child { margin-top: 0; }
.contact-aside p, .contact-aside ul { font-size: 0.95rem; line-height: 1.6; color: #4b5563; }
.contact-aside ul { padding-left: 22px; }
