:root {
  color-scheme: light dark;
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-2: #edf3fb;
  --text: #172033;
  --muted: #53627a;
  --line: #d6dfeb;
  --accent: #1359c5;
  --accent-strong: #0a4099;
  --accent-soft: #e2eeff;
  --result: #0b6b55;
  --warning: #8b3e00;
  --shadow: 0 12px 34px rgba(27, 48, 82, 0.09);
  --radius: 1rem;
  --shell: 74rem;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent-strong); text-decoration-thickness: 0.08em; text-underline-offset: 0.16em; }
a:hover { color: var(--accent); }
button, input, select { font: inherit; }
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }

h1, h2, h3 {
  margin: 0;
  color: var(--text);
  line-height: 1.15;
  letter-spacing: -0.025em;
}

h1 { max-width: 18ch; font-size: clamp(2rem, 8vw, 4rem); }
h2 { font-size: clamp(1.35rem, 4.5vw, 1.85rem); }
h3, .card-title { font-size: 1.08rem; }
p { margin: 0 0 1rem; }

.page-shell {
  width: min(100% - 2rem, var(--shell));
  margin-inline: auto;
}

.narrow { max-width: 48rem; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.65rem 0.9rem;
  border-radius: 0.5rem;
  background: var(--text);
  color: var(--surface);
  transform: translateY(-160%);
}

.skip-link:focus { transform: translateY(0); }

.site-header {
  position: relative;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
}

.header-inner {
  display: flex;
  min-height: 4rem;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.brand {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 800;
  text-decoration: none;
}

.brand-icon svg circle,
.brand-icon svg path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.6;
}

.main-nav {
  order: 3;
  display: flex;
  width: 100%;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 0.7rem;
  overflow: visible;
}

.main-nav > a,
.main-nav summary,
.language-menu summary {
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
}

.nav-categories,
.language-menu { position: relative; }
.nav-categories summary,
.language-menu summary { list-style: none; }
.nav-categories summary::-webkit-details-marker,
.language-menu summary::-webkit-details-marker { display: none; }
.nav-categories summary::after,
.language-menu summary::after { content: "⌄"; display: inline-block; margin-left: 0.35rem; }

.nav-menu,
.language-links {
  position: absolute;
  z-index: 30;
  top: calc(100% + 0.6rem);
  right: 0;
  display: grid;
  width: min(18rem, calc(100vw - 2rem));
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.nav-menu { right: auto; left: 0; }

.nav-menu a,
.language-links a {
  padding: 0.6rem 0.75rem;
  border-radius: 0.45rem;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 650;
  text-decoration: none;
}

.nav-menu a:hover,
.language-links a:hover { background: var(--surface-2); }

.home-hero,
.page-hero,
.calculator-hero,
.language-hero {
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 88% 20%, color-mix(in srgb, var(--accent-soft) 85%, transparent), transparent 28rem),
    var(--surface);
}

.home-hero { padding: 1.8rem 0 1.5rem; }
.page-hero { padding: 1.8rem 0 1.4rem; }
.calculator-hero { padding: 1.15rem 0 1rem; }
.language-hero { min-height: 60vh; padding: 3rem 0; }

.home-hero-grid,
.language-layout { display: grid; gap: 1.25rem; align-items: center; }

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.eyebrow a { text-decoration: none; }

.lede {
  max-width: 68ch;
  margin: 0.65rem 0 0;
  color: var(--muted);
  font-size: clamp(1.02rem, 2.5vw, 1.2rem);
  line-height: 1.55;
}

.search-panel {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.search-panel label { display: block; margin-bottom: 0.45rem; font-weight: 750; }
.search-panel input { width: 100%; }
.search-status { min-height: 0; margin: 0; }
.quick-search-results { display: grid; margin-top: 0.5rem; border: 1px solid var(--line); border-radius: 0.65rem; overflow: hidden; }
.quick-search-results a { padding: 0.48rem 0.65rem; border-bottom: 1px solid var(--line); color: var(--text); font-size: 0.88rem; font-weight: 650; text-decoration: none; }
.quick-search-results a:last-child { border-bottom: 0; }
.quick-search-results a:hover { background: var(--surface-2); }
.search-panel > .search-empty { margin-top: 0.5rem; }

input,
select {
  min-height: 2.85rem;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: var(--surface);
  color: var(--text);
  padding: 0.65rem 0.75rem;
}

select {
  appearance: none;
  padding-right: 2.4rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 1rem) 1.2rem, calc(100% - 0.72rem) 1.2rem;
  background-repeat: no-repeat;
  background-size: 0.3rem 0.3rem;
}

input:focus,
select:focus,
button:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}

input[aria-invalid="true"] { border-color: #c43d32; }

.compact-section { padding: 1.35rem 0; }
.section { padding: 2rem 0; }
.section-heading { margin-bottom: 0.9rem; }
.section-heading p { max-width: 68ch; margin: 0.35rem 0 0; color: var(--muted); }

.popular-grid,
.category-grid,
.calculator-grid,
.related-grid { display: grid; gap: 0.8rem; }

.popular-card,
.category-card,
.calculator-card,
.related-card {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: var(--surface);
}

.popular-card { border-top: 3px solid var(--accent); }
.category-card { background: linear-gradient(145deg, var(--surface), var(--surface-2)); }
.popular-card p,
.category-card p,
.calculator-card p,
.related-card p { margin: 0.45rem 0 0.85rem; color: var(--muted); font-size: 0.92rem; line-height: 1.5; }

.card-category { margin-bottom: 0.35rem; color: var(--accent-strong); font-size: 0.75rem; font-weight: 800; text-transform: uppercase; }
.card-link { margin-top: auto; font-size: 0.9rem; font-weight: 750; }
.search-empty { padding: 1rem; border-radius: 0.75rem; background: var(--accent-soft); }

.article-summary { border-top: 1px solid var(--line); background: var(--surface); }
.prose { max-width: 49rem; }
.prose > h2 { margin-bottom: 1rem; }
.prose p { color: var(--muted); }

.breadcrumbs { margin-bottom: 0.65rem; }
.breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0; padding: 0; list-style: none; }
.breadcrumbs li { color: var(--muted); font-size: 0.8rem; }
.breadcrumbs li:not(:last-child)::after { content: "/"; margin-left: 0.3rem; color: var(--line); }
.breadcrumbs a { color: inherit; }

.calculator-zone { padding: 0.85rem 0 0; }
.calculator-shell { display: grid; gap: 0.85rem; }
.calculator-panel,
.result-panel {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.calculator-panel > h2,
.result-panel > h2 { margin-bottom: 0.8rem; font-size: 1.2rem; }
.calculator-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.field { min-width: 0; }
.field label { display: block; margin-bottom: 0.25rem; font-size: 0.88rem; font-weight: 720; }
.field input,
.field select { width: 100%; }
.field-hint { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.35; }
.button-row { display: flex; flex-wrap: wrap; gap: 0.55rem; grid-column: 1 / -1; }

.primary-button,
.secondary-button,
.primary-link {
  min-height: 2.65rem;
  padding: 0.62rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: 0.65rem;
  cursor: pointer;
  font-weight: 760;
}

.primary-button,
.primary-link { background: var(--accent); color: #fff; text-decoration: none; }
.secondary-button { background: var(--surface); color: var(--accent-strong); }
.primary-button:hover,
.primary-link:hover { background: var(--accent-strong); color: #fff; }

.result-list { display: grid; margin: 0; }
.result-item { min-width: 0; padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.result-item:last-child { border-bottom: 0; }
.result-item dt { color: var(--muted); font-size: 0.78rem; font-weight: 700; }
.result-item dd { min-width: 0; margin: 0.05rem 0 0; color: var(--result); font-size: clamp(1.25rem, 5vw, 1.8rem); font-variant-numeric: tabular-nums; font-weight: 820; line-height: 1.3; overflow-wrap: anywhere; }

.calculation-step {
  margin: 0.8rem 0;
  padding: 0.7rem;
  border-radius: 0.65rem;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.form-message { min-height: 1.4rem; margin: 0.5rem 0 0; color: var(--warning); font-size: 0.88rem; font-weight: 700; }
.notice { margin: 0.75rem 0 0; padding: 0.7rem; border-left: 4px solid var(--warning); background: color-mix(in srgb, var(--accent-soft) 65%, var(--surface)); font-size: 0.88rem; }

/* Empty advertising placeholders intentionally consume no space until populated. */
.ad-slot:empty { display: none; width: 0; height: 0; margin: 0; padding: 0; border: 0; }

.article-zone { margin-top: 1.25rem; padding: 2rem 0; border-top: 1px solid var(--line); background: var(--surface); }
.article-layout { display: grid; gap: 1.4rem; }
.toc { align-self: start; padding: 1rem; border: 1px solid var(--line); border-radius: 0.8rem; background: var(--bg); }
.toc h2 { font-size: 1.05rem; }
.toc ol { display: grid; gap: 0.35rem; margin: 0.65rem 0 0; padding-left: 1.2rem; }
.toc a { color: var(--muted); font-size: 0.82rem; line-height: 1.35; }
.long-article { min-width: 0; max-width: 49rem; }
.article-section { margin-bottom: 2rem; scroll-margin-top: 1rem; }
.article-section h2 { margin-bottom: 0.75rem; font-size: clamp(1.35rem, 4vw, 1.75rem); }
.article-section p { color: var(--muted); }
.steps { display: grid; gap: 0.55rem; margin: 0; padding-left: 1.35rem; }
.steps li { padding-left: 0.2rem; color: var(--muted); }
.how-to { padding: 1rem; border: 1px solid var(--line); border-radius: 0.75rem; background: var(--bg); }
.example-section { padding: 1rem; border-left: 4px solid var(--accent); border-radius: 0.5rem; background: var(--accent-soft); }
.example-section p:last-child { margin-bottom: 0; }

.table-wrap,
.result-table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 0.7rem; }
table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 0.9rem; }
th, td { min-width: 8rem; padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--surface-2); color: var(--text); font-size: 0.8rem; }
tr:last-child td { border-bottom: 0; }
.result-table-wrap { margin-top: 0.5rem; }
.result-table-wrap table { font-size: 0.78rem; }
.result-table-wrap th,
.result-table-wrap td { min-width: 7.5rem; padding: 0.5rem; }

.faq-list { display: grid; gap: 0.6rem; }
.faq-list details { border: 1px solid var(--line); border-radius: 0.7rem; background: var(--surface); }
.faq-list summary { padding: 0.8rem 0.9rem; cursor: pointer; color: var(--text); font-weight: 750; }
.faq-list details div { padding: 0 0.9rem 0.8rem; }
.faq-list details p { margin: 0; }
.related-section { background: var(--bg); }
.updated { margin-top: 2rem; color: var(--muted); font-size: 0.85rem; }

.language-grid { display: grid; gap: 0.75rem; }
.language-choice { display: grid; gap: 0.2rem; padding: 1rem; border: 1px solid var(--line); border-radius: 0.8rem; background: var(--surface); text-decoration: none; }
.language-choice strong { color: var(--text); }
.language-choice span { color: var(--muted); font-size: 0.9rem; }

.site-footer { border-top: 1px solid var(--line); background: #0d1830; color: #dfe8f7; }
.site-footer .brand { color: #fff; }
.site-footer .brand-icon svg circle,
.site-footer .brand-icon svg path { stroke: #8fbfff; }
.footer-inner { display: grid; gap: 1.5rem; padding-block: 2rem; }
.footer-brand p { max-width: 34rem; margin: 0.65rem 0 0; color: #aebbd0; font-size: 0.9rem; }
.site-footer h2 { color: #fff; font-size: 0.92rem; }
.site-footer ul { display: grid; gap: 0.3rem; margin: 0.6rem 0 0; padding: 0; list-style: none; }
.site-footer a { color: #dfe8f7; font-size: 0.86rem; }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; padding-block: 0.8rem; border-top: 1px solid #293754; color: #aebbd0; font-size: 0.78rem; }

@media (min-width: 34rem) {
  .popular-grid,
  .category-grid,
  .calculator-grid,
  .related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calculator-panel,
  .result-panel { padding: 1.2rem; }
}

@media (min-width: 52rem) {
  .header-inner { flex-wrap: nowrap; }
  .main-nav { order: initial; width: auto; padding-bottom: 0; }
  .home-hero { padding: 2.4rem 0 2rem; }
  .home-hero-grid,
  .language-layout { grid-template-columns: minmax(0, 1.2fr) minmax(18rem, 0.8fr); }
  .popular-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .category-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .calculator-shell { grid-template-columns: minmax(0, 1.05fr) minmax(20rem, 0.95fr); }
  .result-panel { position: sticky; top: 1rem; align-self: start; }
  .article-layout { grid-template-columns: 15rem minmax(0, 1fr); align-items: start; }
  .toc { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; }
  .footer-inner { grid-template-columns: 1.4fr 1fr 1fr; }
}

@media (min-width: 70rem) {
  .calculator-grid,
  .related-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1424;
    --surface: #131f34;
    --surface-2: #1a2a44;
    --text: #edf3ff;
    --muted: #b4c0d5;
    --line: #30405d;
    --accent: #7eb1ff;
    --accent-strong: #a9caff;
    --accent-soft: #1b365d;
    --result: #78e0bf;
    --warning: #ffb06e;
    --shadow: 0 14px 36px rgba(0, 0, 0, 0.26);
  }
  .site-footer { background: #080e1b; }
  .primary-button,
  .primary-link { color: #07111f; }
  .primary-button:hover,
  .primary-link:hover { color: #07111f; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
