/* diffusioncalculator.com — base styles */
:root {
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --text: #0f1b2d;
  --muted: #536179;
  --border: #dbe3ee;
  --primary: #0b6bcb;
  --primary-ink: #ffffff;
  --primary-soft: #e3f0fd;
  --accent: #0f9d8a;
  --accent-soft: #dff5f1;
  --chem: #8a4fd8;
  --chem-soft: #f1e9fd;
  --phys: #d9622b;
  --phys-soft: #fdeee6;
  --danger: #c62f3b;
  --danger-soft: #fdeaec;
  --shadow: 0 1px 2px rgba(15, 27, 45, 0.06), 0 8px 24px rgba(15, 27, 45, 0.06);
  --radius: 14px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --math: 'Cambria Math', 'STIX Two Math', 'Latin Modern Math', Cambria, 'Times New Roman', serif;
  --mono: ui-monospace, 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0b1220;
    --surface: #111a2c;
    --surface-2: #17233a;
    --text: #e6edf7;
    --muted: #9aa8bf;
    --border: #24324c;
    --primary: #4ba3f5;
    --primary-ink: #04121f;
    --primary-soft: #132c48;
    --accent: #3cc9b4;
    --accent-soft: #10302d;
    --chem: #b48af0;
    --chem-soft: #261a3d;
    --phys: #f08a5a;
    --phys-soft: #36200f;
    --danger: #f2727c;
    --danger-soft: #3a1519;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0b1220;
  --surface: #111a2c;
  --surface-2: #17233a;
  --text: #e6edf7;
  --muted: #9aa8bf;
  --border: #24324c;
  --primary: #4ba3f5;
  --primary-ink: #04121f;
  --primary-soft: #132c48;
  --accent: #3cc9b4;
  --accent-soft: #10302d;
  --chem: #b48af0;
  --chem-soft: #261a3d;
  --phys: #f08a5a;
  --phys-soft: #36200f;
  --danger: #f2727c;
  --danger-soft: #3a1519;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -0.015em; margin: 1.6em 0 0.6em; }
h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); margin-top: 0.3em; }
h2 { font-size: clamp(1.35rem, 2.6vw, 1.7rem); }
h3 { font-size: 1.15rem; }
p, ul, ol { margin: 0 0 1em; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 5px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--primary); color: var(--primary-ink); padding: 8px 14px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 8px; }

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .container { padding: 0 24px; } }

/* ── Header ───────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 16px; height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 1.08rem; color: var(--text); text-decoration: none; white-space: nowrap; }
.logo svg { width: 32px; height: 32px; flex: none; }
.logo .tld { color: var(--muted); font-weight: 500; }
.main-nav { display: flex; gap: 2px; margin-left: 8px; }
.main-nav a { color: var(--muted); text-decoration: none; font-weight: 550; font-size: 0.94rem; padding: 8px 12px; border-radius: 8px; }
.main-nav a:hover, .main-nav a[aria-current='page'] { color: var(--text); background: var(--surface-2); }
.header-tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }
.theme-toggle .moon { display: none; }
:root[data-theme='dark'] .theme-toggle .sun { display: none; }
:root[data-theme='dark'] .theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .theme-toggle .sun { display: none; }
  :root:not([data-theme='light']) .theme-toggle .moon { display: block; }
}
.nav-toggle { display: none; }

/* ── Search ───────────────────────────────── */
.search { position: relative; }
.search input {
  width: 260px; height: 40px; padding: 0 14px 0 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: 0.94rem;
}
.search input:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--primary-soft); }
.search .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; min-width: 300px; margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); z-index: 60; max-height: 70vh; overflow: auto;
}
.search-results a { display: block; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--text); line-height: 1.35; }
.search-results a span { display: block; font-size: 0.82rem; color: var(--muted); }
.search-results a:hover, .search-results a.active { background: var(--primary-soft); }
.search-results .empty { padding: 10px; color: var(--muted); font-size: 0.9rem; }
.search-lg input { width: 100%; height: 54px; font-size: 1.05rem; padding-left: 46px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.search-lg .search-icon { left: 16px; width: 20px; height: 20px; }

@media (max-width: 960px) {
  .site-header .search input { width: 180px; }
}
@media (max-width: 820px) {
  .nav-toggle { display: grid; }
  .main-nav {
    display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; margin: 0;
    background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 16px 16px; box-shadow: var(--shadow);
  }
  .nav-open .main-nav { display: flex; }
  .main-nav a { padding: 12px; }
  .site-header .search { display: none; }
}

/* ── Hero ─────────────────────────────────── */
.hero { position: relative; overflow: hidden; padding: 64px 0 56px; border-bottom: 1px solid var(--border); background:
  radial-gradient(900px 400px at 85% -10%, var(--primary-soft), transparent 70%),
  radial-gradient(700px 360px at 0% 110%, var(--accent-soft), transparent 70%), var(--bg); }
.hero-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 48px; align-items: center; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); margin: 0 0 16px; letter-spacing: -0.03em; }
.hero h1 em { font-style: normal; color: var(--primary); }
.hero .lead { font-size: 1.15rem; color: var(--muted); max-width: 560px; margin-bottom: 26px; }
.hero .search { max-width: 520px; }
.hero-stats { display: flex; gap: 28px; margin-top: 26px; color: var(--muted); font-size: 0.92rem; flex-wrap: wrap; }
.hero-stats strong { display: block; color: var(--text); font-size: 1.4rem; }
.hero-art { width: 100%; aspect-ratio: 1.15; border-radius: 22px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
@media (max-width: 860px) { .hero-grid { grid-template-columns: minmax(0, 1fr); } .hero-art { display: none; } .hero { padding: 40px 0; } }

/* ── Sections & cards ─────────────────────── */
.section { padding: 56px 0; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-head p { margin: 4px 0 0; color: var(--muted); }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card {
  display: flex; flex-direction: column; gap: 6px; padding: 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.card h3 { margin: 0; font-size: 1.04rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
.card .formula-mini { font-family: var(--math); font-size: 1.05rem; color: var(--text); margin-top: auto; padding-top: 10px; }
.tag { display: inline-block; align-self: flex-start; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; }
.tag-diffusion { color: var(--primary); background: var(--primary-soft); }
.tag-chemistry { color: var(--chem); background: var(--chem-soft); }
.tag-physics { color: var(--phys); background: var(--phys-soft); }

.cat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 860px) { .cat-cards { grid-template-columns: 1fr; } }
.cat-card { padding: 26px; border-radius: 18px; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--border); position: relative; overflow: hidden; }
.cat-card:hover { box-shadow: var(--shadow); }
.cat-card .ico { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 14px; }
.cat-card .ico svg { width: 26px; height: 26px; }
.cat-card h3 { margin: 0 0 6px; font-size: 1.25rem; }
.cat-card p { color: var(--muted); margin: 0 0 12px; }
.cat-card .count { font-weight: 650; font-size: 0.9rem; }
.cat-diffusion .ico { background: var(--primary-soft); color: var(--primary); }
.cat-chemistry .ico { background: var(--chem-soft); color: var(--chem); }
.cat-physics .ico { background: var(--phys-soft); color: var(--phys); }

/* ── Page layout ──────────────────────────── */
.page-head { padding: 28px 0 8px; }
.breadcrumb { font-size: 0.86rem; color: var(--muted); margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.breadcrumb li + li::before { content: '›'; margin-right: 6px; color: var(--border); }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary); }
.page-head .lead { color: var(--muted); font-size: 1.08rem; max-width: 760px; margin-bottom: 0; }

.calc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; padding: 20px 0 64px; align-items: start; }
@media (max-width: 980px) { .calc-layout { grid-template-columns: minmax(0, 1fr); } }
.sidebar { display: flex; flex-direction: column; gap: 18px; position: sticky; top: 84px; }
@media (max-width: 980px) { .sidebar { position: static; } }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.panel h2, .panel h3 { margin: 0 0 12px; font-size: 1rem; }
.panel ul { list-style: none; padding: 0; margin: 0; }
.panel li a { display: block; padding: 7px 0; text-decoration: none; border-bottom: 1px dashed var(--border); font-size: 0.94rem; }
.panel li:last-child a { border-bottom: 0; }

/* ── Calculator ───────────────────────────── */
.calc {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 24px; box-shadow: var(--shadow);
}
@media (max-width: 520px) { .calc { padding: 16px; } }
.calc-solve { display: flex; align-items: center; gap: 12px; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.calc-solve label { font-weight: 650; }
.calc-solve select { flex: 1 1 220px; min-width: 0; max-width: 100%; }
.calc select, .calc input {
  height: 46px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; padding: 0 12px;
}
.calc select { cursor: pointer; padding-right: 8px; }
.calc input:focus, .calc select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.calc-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
@media (max-width: 640px) { .calc-fields { grid-template-columns: minmax(0, 1fr); } }
.field label { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; font-size: 0.92rem; font-weight: 600; }
.field .sym { font-family: var(--math); font-style: italic; font-size: 1.08rem; color: var(--primary); min-width: 1.2em; }
.field .fname { color: var(--text); }
.input-row { display: flex; }
.input-row input { flex: 1; min-width: 0; border-radius: 10px 0 0 10px; font-variant-numeric: tabular-nums; }
.input-row input:only-child, .input-row select.val { border-radius: 10px; width: 100%; }
.input-row .unit, .input-row .unit-static { border-radius: 0 10px 10px 0; border-left: 0; background: var(--surface-2); max-width: 48%; font-size: 0.9rem; }
.input-row .unit-static { display: flex; align-items: center; padding: 0 12px; border: 1px solid var(--border); border-left: 0; color: var(--muted); }
.hint { display: block; color: var(--muted); font-size: 0.78rem; min-height: 0; margin-top: 4px; line-height: 1.35; }
.hint:empty { display: none; }
.field.is-target input { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); font-weight: 700; color: var(--primary); cursor: default; }
.field.is-target label::after { content: 'result'; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: 1px 7px; border-radius: 999px; margin-left: auto; }
.field.is-invalid input { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

.calc-result { margin-top: 22px; padding: 18px 20px; border-radius: 14px; background: linear-gradient(135deg, var(--primary-soft), var(--accent-soft)); }
.result-label { display: block; font-size: 0.82rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.result-value { display: block; font-size: clamp(1.5rem, 4vw, 2.1rem); font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; word-break: break-word; }
.result-value .u { font-size: 0.6em; font-weight: 600; color: var(--muted); }
.calc-result.is-error { background: var(--surface-2); }
.calc-result.is-error .result-value { font-size: 1rem; font-weight: 550; color: var(--muted); }
.result-derived { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; }
.result-derived:empty { display: none; }
.result-derived li { display: flex; justify-content: space-between; gap: 12px; font-size: 0.92rem; padding-top: 6px; border-top: 1px solid color-mix(in srgb, var(--text) 10%, transparent); flex-wrap: wrap; }
.result-derived span { color: var(--muted); }
.result-derived strong { font-variant-numeric: tabular-nums; }
.calc-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 10px; font: inherit; font-weight: 600; font-size: 0.94rem; cursor: pointer; text-decoration: none; border: 1px solid transparent; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.calc-steps { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.calc-steps summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.steps ol { margin: 12px 0 0; padding-left: 20px; font-size: 0.93rem; }
.steps ul { margin: 4px 0; padding-left: 18px; list-style: disc; font-family: var(--mono); font-size: 0.86rem; }
.steps li { margin-bottom: 6px; }

/* ── Formula ──────────────────────────────── */
.formula {
  font-family: var(--math); font-size: clamp(1.25rem, 3vw, 1.6rem); text-align: center; padding: 22px 16px; margin: 0 0 1em;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; line-height: 1.4;
}
.panel .formula { font-size: 1.25rem; padding: 14px 8px; background: var(--surface-2); border: 0; }
.formula var, .formula i { font-style: italic; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 0.15em; }
.frac > span:first-child { border-bottom: 1px solid currentColor; padding: 0 0.2em; }
.frac > span:last-child { padding: 0 0.2em; }
.sqrt { white-space: nowrap; }
.sqrt > span { border-top: 1px solid currentColor; padding: 0 0.1em; }

/* ── Article content ─────────────────────── */
.prose { max-width: 820px; }
.prose h2 { padding-top: 8px; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: 0.35em; }
.prose blockquote { margin: 0 0 1em; padding: 14px 18px; border-left: 4px solid var(--primary); background: var(--primary-soft); border-radius: 0 10px 10px 0; }
.prose blockquote p:last-child { margin: 0; }
.table-wrap { overflow-x: auto; margin: 0 0 1.2em; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; background: var(--surface); }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 650; }
tr:last-child td { border-bottom: 0; }
td.sym { font-family: var(--math); font-style: italic; font-size: 1.05rem; white-space: nowrap; }
.example { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 1em; }
.example h3 { margin-top: 0; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; margin-bottom: 10px; }
.faq summary { cursor: pointer; font-weight: 650; }
.faq details[open] summary { margin-bottom: 8px; }
.faq details p:last-child { margin-bottom: 0; }
.note { font-size: 0.9rem; color: var(--muted); }

/* ── Laws library ─────────────────────────── */
.law { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 300px); gap: 18px; padding: 22px; margin-bottom: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); scroll-margin-top: 84px; }
.law h3 { margin: 6px 0 6px; }
.law p { margin: 0 0 10px; color: var(--muted); }
.law .formula { margin: 0; align-self: center; font-size: 1.25rem; background: var(--surface-2); border: 0; }
@media (max-width: 760px) { .law { grid-template-columns: minmax(0, 1fr); } }
.toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 24px; padding: 0; list-style: none; }
.toc a { display: inline-block; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); text-decoration: none; font-size: 0.88rem; color: var(--text); }
.toc a:hover { border-color: var(--primary); color: var(--primary); }

.filter-input { width: 100%; max-width: 520px; height: 48px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; margin-bottom: 8px; }
.filter-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

.callout { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; padding: 28px; border-radius: 18px; background: linear-gradient(135deg, var(--primary-soft), var(--accent-soft)); }
.callout h2 { margin: 0 0 6px; }
.callout p { margin: 0; color: var(--muted); }
@media (max-width: 640px) { .callout { grid-template-columns: 1fr; } }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; align-items: start; }
@media (max-width: 860px) { .two-col { grid-template-columns: minmax(0, 1fr); } }

/* ── Footer ───────────────────────────────── */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 48px 0 28px; margin-top: 24px; font-size: 0.92rem; }
.footer-grid { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 28px; }
@media (max-width: 900px) { .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.site-footer h4 { margin: 0 0 10px; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 6px; }
.site-footer a { color: var(--text); text-decoration: none; }
.site-footer a:hover { color: var(--primary); }
.site-footer .about-blurb { color: var(--muted); max-width: 320px; }
.footer-bottom { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.85rem; }

.not-found { text-align: center; padding: 96px 0; }
.not-found .big { font-size: 5rem; font-weight: 800; color: var(--primary); line-height: 1; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
@media print {
  .site-header, .site-footer, .sidebar, .calc-actions { display: none !important; }
  .calc-layout { grid-template-columns: 1fr; }
}

@media (max-width: 420px) {
  .header-inner { gap: 8px; }
  .logo { font-size: 1rem; gap: 8px; }
  .logo .tld { display: none; }
  .footer-grid > div:first-child { grid-column: 1 / -1; }
}
