@import url("https://fonts.googleapis.com/css2?family=Ruda:wght@500;600;700&family=Source+Sans+Pro:ital,wght@0,300;0,400;0,600;0,700;1,400&display=swap");

:root {
  --vm-green: #5cbc40;
  --vm-green-hover: #52ae39;
  --vm-green-dark: #3f8f31;
  --vm-green-soft: #eaf7e5;
  --vm-dark: #383e42;
  --vm-gray: #50595f;
  --vm-muted: #737b80;
  --vm-orange: #f29400;
  --vm-orange-soft: #fff3df;
  --vm-light: #f4f4f2;
  --vm-surface-subtle: #f7f8f7;
  --vm-white: #ffffff;
  --vm-border: #d5d9db;
  --vm-border-strong: #9ca4a8;
  --vm-code: #272d31;
  --vm-heading: "Ruda", Arial, sans-serif;
  --vm-body: "Source Sans Pro", "Source Sans 3", Arial, sans-serif;
  --vm-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --vm-content: 1180px;
  --vm-reading: 860px;
  --vm-radius-sm: 2px;
  --vm-radius-md: 4px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--vm-white); }
body {
  margin: 0;
  background: var(--vm-white);
  color: var(--vm-dark);
  font-family: var(--vm-body);
  font-size: 16px;
  line-height: 1.58;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
::selection { background: var(--vm-green); color: var(--vm-dark); }

/* Velometrik header */
.site-header { background: var(--vm-white); }
.topbar {
  min-height: 72px;
  border-bottom: 1px solid var(--vm-border);
}
.topbar-inner {
  width: min(calc(100% - 40px), var(--vm-content));
  min-height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--vm-dark);
  text-decoration: none;
}
.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: var(--vm-radius-md);
}
.brand-copy { display: flex; flex-direction: column; line-height: 1; }
.brand-word {
  font-family: var(--vm-body);
  font-size: 1.42rem;
  font-weight: 600;
  letter-spacing: -.025em;
}
.brand-v { color: var(--vm-green); font-size: 1.12em; font-weight: 700; }
.brand-sub {
  margin-top: 5px;
  color: var(--vm-muted);
  font-size: .72rem;
  font-weight: 400;
  letter-spacing: .025em;
}
.header-meta {
  color: var(--vm-gray);
  font-size: .88rem;
  text-align: right;
}
.header-meta strong { color: var(--vm-dark); font-weight: 600; }

.hero {
  width: min(calc(100% - 40px), var(--vm-content));
  margin: 0 auto;
  padding: 68px 0 62px;
}
.kicker,
.chapter {
  color: var(--vm-green-dark);
  font-family: var(--vm-body);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.hero h1 {
  max-width: 980px;
  margin: 10px 0 20px;
  color: var(--vm-dark);
  font-family: var(--vm-heading);
  font-size: clamp(2.25rem, 5vw, 4.5rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -.025em;
}
.hero p {
  max-width: 880px;
  margin: 0;
  color: var(--vm-gray);
  font-size: 1.2rem;
  line-height: 1.55;
}

nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,.97);
  border-top: 1px solid var(--vm-border);
  border-bottom: 1px solid var(--vm-border);
  backdrop-filter: blur(8px);
}
nav .inner {
  width: min(calc(100% - 40px), var(--vm-content));
  margin: 0 auto;
  display: flex;
  gap: 24px;
  overflow-x: auto;
  scrollbar-width: thin;
}
nav a {
  position: relative;
  flex: 0 0 auto;
  padding: 16px 0 14px;
  color: var(--vm-gray);
  font-family: var(--vm-body);
  font-size: .91rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: transparent;
}
nav a:hover,
nav a:focus-visible { color: var(--vm-dark); }
nav a:hover::after,
nav a:focus-visible::after { background: var(--vm-green); }
nav a:focus-visible { outline: 2px solid transparent; }

main {
  width: min(calc(100% - 40px), var(--vm-content));
  margin: 0 auto;
  padding: 72px 0 88px;
}
section {
  scroll-margin-top: 74px;
  margin: 0;
  padding: 0 0 76px;
}
section + section {
  padding-top: 72px;
  border-top: 1px solid var(--vm-border);
}
section > p,
section > ul,
section > ol,
section > .formula,
section > .note,
section > .warning,
section > .source-note,
section > pre { max-width: var(--vm-reading); }

h2, h3, h4 {
  color: var(--vm-dark);
  font-family: var(--vm-heading);
  line-height: 1.18;
  letter-spacing: -.018em;
}
h2 {
  max-width: 980px;
  margin: 7px 0 24px;
  padding: 0 0 16px;
  border-bottom: 3px solid var(--vm-green);
  font-size: clamp(1.8rem, 3.4vw, 3rem);
  font-weight: 600;
}
h3 {
  margin: 42px 0 13px;
  font-size: 1.42rem;
  font-weight: 600;
}
h4 {
  margin: 20px 0 9px;
  font-size: 1.08rem;
  font-weight: 600;
}
p { margin: 0 0 1.05em; }
.lead {
  max-width: 900px;
  margin-bottom: 26px;
  color: var(--vm-gray);
  font-size: 1.19rem;
  line-height: 1.58;
}
strong { font-weight: 600; }

.note,
.warning,
.source-note {
  margin: 24px 0;
  padding: 17px 20px;
  border-left: 4px solid var(--vm-green);
  border-radius: 0 var(--vm-radius-sm) var(--vm-radius-sm) 0;
  background: var(--vm-green-soft);
}
.warning {
  border-left-color: var(--vm-orange);
  background: var(--vm-orange-soft);
}
.source-note {
  border-left-color: var(--vm-gray);
  background: var(--vm-light);
  color: var(--vm-gray);
}

figure {
  margin: 30px 0;
  padding: 18px;
  border: 1px solid var(--vm-border);
  border-radius: var(--vm-radius-md);
  background: var(--vm-white);
}
figure img {
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}
figcaption {
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--vm-border);
  color: var(--vm-muted);
  font-size: .91rem;
  line-height: 1.45;
}
.grid2,
.grid3 {
  display: grid;
  gap: 20px;
  margin: 26px 0;
}
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid2 > figure,
.grid3 > figure,
.grid2 > div,
.grid3 > div { margin: 0; }
.grid2 > div,
.grid3 > div {
  padding: 20px;
  border: 1px solid var(--vm-border);
  background: var(--vm-surface-subtle);
}

.table-wrap { width: 100%; overflow-x: auto; }
table {
  width: 100%;
  margin: 25px 0 30px;
  border-collapse: collapse;
  border-top: 2px solid var(--vm-dark);
  border-bottom: 1px solid var(--vm-border-strong);
  font-size: .95rem;
}
th, td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--vm-border);
  text-align: left;
  vertical-align: top;
}
th {
  background: var(--vm-light);
  color: var(--vm-dark);
  font-weight: 600;
}
tbody tr:hover { background: #fbfcfb; }

ul, ol { padding-left: 1.35rem; }
li { margin: .32rem 0; }
li::marker { color: var(--vm-green-dark); }

code {
  padding: .08rem .28rem;
  border-radius: var(--vm-radius-sm);
  background: var(--vm-light);
  color: var(--vm-dark);
  font-family: var(--vm-mono);
  font-size: .9em;
}
pre {
  margin: 22px 0 30px;
  padding: 18px 20px;
  overflow: auto;
  border-left: 4px solid var(--vm-green);
  border-radius: 0 var(--vm-radius-md) var(--vm-radius-md) 0;
  background: var(--vm-code);
  color: #f7f8f7;
  line-height: 1.48;
}
pre code { padding: 0; background: transparent; color: inherit; }
.formula {
  margin: 18px 0;
  padding: 15px 17px;
  border: 1px solid var(--vm-border);
  border-left: 4px solid var(--vm-green);
  background: var(--vm-surface-subtle);
  font-family: var(--vm-body);
  font-size: 1.04rem;
  font-weight: 600;
}
.tag {
  display: inline-block;
  margin: 3px 5px 3px 0;
  padding: 3px 8px;
  border: 1px solid var(--vm-border-strong);
  border-radius: var(--vm-radius-sm);
  background: var(--vm-white);
  color: var(--vm-gray);
  font-size: .86rem;
}
.footer {
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid var(--vm-border);
  color: var(--vm-muted);
  font-size: .9rem;
}

@media (max-width: 800px) {
  .topbar-inner { min-height: 64px; }
  .brand-mark { width: 38px; height: 38px; flex-basis: 38px; }
  .brand-word { font-size: 1.28rem; }
  .header-meta { display: none; }
  .hero { padding: 48px 0 44px; }
  nav .inner { gap: 18px; }
  main { padding-top: 52px; }
  section { padding-bottom: 58px; }
  section + section { padding-top: 54px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  figure { padding: 12px; }
}

@media (max-width: 520px) {
  .topbar-inner,
  .hero,
  nav .inner,
  main { width: min(calc(100% - 28px), var(--vm-content)); }
  .brand-sub { display: none; }
  .hero h1 { font-size: 2.35rem; }
  .hero p, .lead { font-size: 1.08rem; }
  h2 { font-size: 1.9rem; }
  th, td { padding: 9px 8px; }
}

@media print {
  @page { margin: 16mm 15mm; }
  nav { display: none; }
  .topbar { position: static; }
  .header-meta { display: block; }
  .hero { padding: 24px 0 32px; }
  main { width: 100%; padding: 0; }
  section { padding-bottom: 28px; }
  section + section { padding-top: 28px; }
  figure, table, pre, .note, .warning, .source-note { break-inside: avoid; }
  a { text-decoration: none; }
}

@media (max-width: 800px) {
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
