:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-muted: #eef2f7;
  --text: #0f172a;
  --text-muted: #475569;
  --border: #e2e8f0;
  --accent: #0d9488;
  --accent-strong: #0f766e;
  --accent-soft: #ccfbf1;
  --danger: #b91c1c;
  --warning: #b45309;
  --success: #047857;
  --info: #1d4ed8;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-strong: 0 2px 6px rgba(15, 23, 42, 0.08), 0 18px 40px rgba(15, 23, 42, 0.12);
  --maxw: 1100px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ---------------- header ---------------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 14px;
  padding-bottom: 14px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-icon { font-size: 22px; }
.primary-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.primary-nav a {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
}
.primary-nav a:hover {
  background: var(--surface-muted);
  color: var(--text);
  text-decoration: none;
}

/* ---------------- hero ---------------- */
.hero {
  background:
    radial-gradient(1200px 400px at 80% -10%, rgba(13, 148, 136, 0.12), transparent 60%),
    radial-gradient(800px 300px at 0% 0%, rgba(29, 78, 216, 0.08), transparent 60%);
  padding: 56px 0 32px;
  border-bottom: 1px solid var(--border);
}
.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(32px, 5vw, 48px);
  letter-spacing: -0.02em;
}
.lede { font-size: 18px; color: var(--text-muted); max-width: 680px; }
.small { font-size: 13px; }
.muted { color: var(--text-muted); }

/* ---------------- sections ---------------- */
.section-title {
  margin: 48px 0 20px;
  font-size: 22px;
  letter-spacing: -0.01em;
}

/* ---------------- cards ---------------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-bottom: 56px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-strong);
  border-color: #cbd5e1;
  text-decoration: none;
}
.card h3 { margin: 4px 0 0; font-size: 18px; letter-spacing: -0.01em; }
.card p { margin: 0; color: var(--text-muted); font-size: 14.5px; }
.card-icon { font-size: 28px; line-height: 1; }
.card-cta { margin-top: auto; padding-top: 14px; color: var(--accent-strong); font-weight: 600; font-size: 14px; }

/* ---------------- calculator pages ---------------- */
.page-header {
  padding: 40px 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.breadcrumb a { color: var(--text-muted); }
.page-header h1 { margin: 0; font-size: 30px; letter-spacing: -0.01em; }
.page-header p { color: var(--text-muted); max-width: 720px; }

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 22px;
  padding: 28px 0 64px;
}
.calc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.calc h2 {
  margin: 0 0 4px;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.calc .desc { color: var(--text-muted); font-size: 14px; margin: 0 0 14px; }

.calc form { display: grid; gap: 12px; }
.field {
  display: grid;
  gap: 4px;
}
.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.field .hint { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.field input[type="number"],
.field input[type="text"],
.field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
}
.field input:focus, .field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

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

.radio-group, .check-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.radio-group label, .check-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
}
.radio-group input, .check-group input { accent-color: var(--accent-strong); }

button.primary {
  margin-top: 4px;
  background: var(--accent-strong);
  color: white;
  border: none;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: var(--font);
}
button.primary:hover { background: var(--accent); }
button.ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font);
}
button.ghost:hover { background: var(--surface-muted); color: var(--text); }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 6px; }

.result {
  margin-top: 14px;
  padding: 14px;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid #99f6e4;
  display: none;
}
.result.show { display: block; }
.result .value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-strong);
  letter-spacing: -0.01em;
}
.result .unit { font-size: 14px; color: var(--text-muted); margin-left: 4px; font-weight: 500; }
.result .values-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 0; }
.result .value-sep {
  color: var(--text-muted);
  font-size: 18px;
  font-weight: 400;
  padding: 0 10px;
  align-self: center;
}
.result .interp { margin-top: 6px; font-size: 14px; color: var(--text); }
.result.warn { background: #fef3c7; border-color: #fde68a; }
.result.warn .value { color: var(--warning); }
.result.danger { background: #fee2e2; border-color: #fecaca; }
.result.danger .value { color: var(--danger); }
.result.ok { background: #d1fae5; border-color: #a7f3d0; }
.result.ok .value { color: var(--success); }
.result .error { color: var(--danger); font-weight: 600; }

.result.missing {
  background: var(--surface-muted);
  border: 1px dashed #cbd5e1;
}
.result.missing .missing-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.result.missing .missing-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.result.missing .missing-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12.5px;
  color: var(--text);
  font-weight: 500;
}
.result.missing .missing-hint {
  font-size: 12.5px;
  color: var(--text-muted);
}
.result.missing .missing-hint a { color: var(--accent-strong); font-weight: 600; }

.result .recommendation {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 8px;
  line-height: 1.45;
}
.result .recommendation .rec-icon {
  font-size: 14px;
  flex-shrink: 0;
}
.result .recommendation strong {
  color: var(--accent-strong);
  font-weight: 700;
  white-space: nowrap;
}
.result.ok .recommendation { background: rgba(255, 255, 255, 0.7); }

.source {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.source strong { color: var(--text); font-weight: 600; }

/* ---------------- footer ---------------- */
.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 0;
  margin-top: 0;
  box-shadow: 0 -2px 8px rgba(15, 23, 42, 0.05);
  transition: padding 180ms ease;
}
.footer-inner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.footer-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.footer-disclaimer {
  margin: 0;
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.45;
}
.footer-disclaimer strong { color: var(--danger); font-weight: 700; }
.footer-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  font-size: 12.5px;
}
.footer-meta span { display: inline-block; }
.footer-extra {
  margin: 4px 0 0;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  font-size: 12.5px;
}
.footer-links { margin: 8px 0 0; font-size: 12.5px; }
.footer-links a {
  color: var(--text-muted);
  margin: 0 2px;
}
.footer-links a:hover { color: var(--text); }

/* ---------------- prose (legal / about / contact) ---------------- */
.prose {
  max-width: 720px;
  margin: 24px auto 64px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  box-shadow: var(--shadow);
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
}
.prose h2 {
  margin: 28px 0 8px;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.prose h2:first-child { margin-top: 0; }
.prose p { margin: 0 0 12px; }
.prose ul { margin: 0 0 16px; padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.prose code {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 13.5px;
}
.prose strong { color: var(--text); }
.prose a { color: var(--accent-strong); }

@media (max-width: 720px) {
  .prose { padding: 18px; margin: 16px auto 40px; font-size: 14.5px; }
}

.footer-toggle {
  flex-shrink: 0;
  align-self: center;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font);
  font-weight: 500;
  display: none;          /* desktop: not needed */
  align-items: center;
  gap: 6px;
  line-height: 1;
}
.footer-toggle:hover { background: var(--surface); color: var(--text); }
.footer-toggle .when-collapsed { display: none; }

/* Reserve room at the bottom of the page so content doesn't hide under the fixed footer. */
body { padding-bottom: var(--footer-pad, 110px); }

/* ---------------- header tools (unit switches + lang selector) ---------------- */
.header-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

/* language flag selector */
.lang-selector {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.lang-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  font-size: 16px;
  text-decoration: none;
  opacity: 0.5;
  transition: opacity 100ms, background 100ms;
  line-height: 1;
}
.lang-flag:hover { opacity: 1; background: var(--surface-muted); text-decoration: none; }
.lang-flag.active { opacity: 1; background: var(--surface-muted); }

/* divider between lang selector and unit switches */
.header-tools-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
}

/* ---------------- unit switch ---------------- */
.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.unit-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}
.unit-switch button {
  background: transparent;
  border: none;
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.unit-switch button + button { border-left: 1px solid var(--border); }
.unit-switch button.active {
  background: var(--accent-strong);
  color: white;
}
.unit-switch button:hover:not(.active) { background: var(--surface-muted); color: var(--text); }
.unit-switch button .muted-inline {
  font-size: 11.5px;
  font-weight: 500;
  opacity: 0.85;
  margin-left: 4px;
}

.unit-pair {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.unit-control { min-width: 220px; }
.unit-control-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.primary-nav a.profile-link {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.primary-nav a.profile-link:hover { background: #99f6e4; color: var(--accent-strong); }
.primary-nav a.active { background: var(--surface-muted); color: var(--text); }

/* ---------------- compound input (ft+in) ---------------- */
.compound-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.compound-row input[type="number"] {
  flex: 1 1 0;
  min-width: 0;
}
.compound-row .suffix {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  padding-right: 6px;
}
.unit-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 4px;
}

/* ---------------- profile page ---------------- */
.profile-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 20px 0;
}
.profile-intro .save-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--success);
  background: #d1fae5;
  border: 1px solid #a7f3d0;
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 600;
}
.profile-intro .save-pill::before {
  content: "";
  width: 7px; height: 7px; border-radius: 999px; background: var(--success);
}
.profile-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.profile-section h2 {
  margin: 0 0 4px;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.profile-section .section-desc {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 0 0 16px;
}
.profile-section .fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}
.profile-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 14px 0 60px;
}

/* ---------------- responsive ---------------- */
@media (max-width: 900px) {
  .calc-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
}

@media (max-width: 720px) {
  .container { padding: 0 16px; }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding-top: 10px;
    padding-bottom: 10px;
  }
  .primary-nav {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .primary-nav a { white-space: nowrap; flex-shrink: 0; padding: 6px 10px; font-size: 13.5px; }

  .header-tools {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    margin-left: 0;
    padding-bottom: 2px;
  }
  .header-tools .unit-switch button { padding: 5px 9px; font-size: 12px; }

  /* ---- footer: collapsible on mobile — starts collapsed ---- */
  .footer-toggle { display: inline-flex; }
  .footer-toggle .when-expanded { display: inline; }
  .site-footer.collapsed { padding: 6px 0; }
  .site-footer.collapsed .footer-body { display: none; }
  .site-footer.collapsed .footer-toggle .when-expanded { display: none; }
  .site-footer.collapsed .footer-toggle .when-collapsed { display: inline; }
  /* Collapsed footer only needs minimal body padding */
  body { padding-bottom: var(--footer-pad, 110px); }
  .footer-meta { gap: 4px 14px; }

  .hero { padding: 36px 0 24px; }
  .hero h1 { font-size: 28px; }
  .lede { font-size: 15.5px; }
  .section-title { margin: 32px 0 16px; font-size: 19px; }

  .page-header { padding: 24px 0 12px; }
  .page-header h1 { font-size: 24px; }
  .page-header p { font-size: 14px; }

  .card, .calc, .profile-section { padding: 16px; }
  .card-grid { gap: 14px; margin-bottom: 36px; }
  .calc-grid {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 20px 0 40px;
  }

  .field-row { grid-template-columns: 1fr; }
  .field input[type="text"],
  .field input[type="number"],
  .field select { font-size: 16px; }  /* avoid iOS auto-zoom */
  .compound-row input[type="text"],
  .compound-row input[type="number"] { font-size: 16px; }

  .result { padding: 12px; }
  .result .value { font-size: 20px; }
  .result .value-sep { padding: 0 6px; font-size: 16px; }
  .result .unit { font-size: 13px; }

  .unit-pair { flex-direction: column; gap: 14px; }
  .unit-control, .unit-switch { width: 100%; }
  .unit-switch button { flex: 1; padding: 8px 10px; }

  .profile-actions { padding-bottom: 40px; }
}

@media (max-width: 420px) {
  .unit-switch button .muted-inline { display: none; }
  .brand-text { font-size: 16px; }
  .hero h1 { font-size: 24px; }
  .page-header h1 { font-size: 21px; }
  .result .value { font-size: 18px; }
  .calc h2 { font-size: 16px; }
  .profile-section h2 { font-size: 16px; }
}

/* ---------------- individual calc pages ---------------- */
.calc-explainer {
  margin-top: 40px;
  max-width: 720px;
}
.calc-explainer h2 { font-size: 20px; margin: 0 0 12px; letter-spacing: -0.01em; }
.calc-explainer h3 { font-size: 16px; margin: 24px 0 8px; }
.calc-explainer p  { color: var(--text-muted); font-size: 15px; line-height: 1.7; margin: 0 0 12px; }

.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  margin: 0 0 16px;
}
.ref-table th {
  text-align: left;
  padding: 8px 12px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.ref-table td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}
.ref-table tr:nth-child(even) td { background: var(--surface-muted); }

.related-calcs h2 { font-size: 20px; margin: 40px 0 16px; letter-spacing: -0.01em; }

.calc-detail-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-strong);
}
