@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --text: #141b22;
  --muted: #52606d;
  --border: #dce3ea;
  --accent: #0f4c75;
  --accent-hover: #0a3857;
  --accent-soft: #e8f1f8;
  --g1: #8a5300;
  --g1-soft: #fef6e7;
  --g1-border: #edd29f;
  --g2: #16653e;
  --g2-soft: #e7f6ee;
  --g2-border: #a9dfc0;
  --bad: #b3261e;
  --bad-soft: #fbeae9;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, .07), 0 2px 6px rgba(15, 23, 42, .04);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  font-size: 16.5px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
img, svg { max-width: 100%; }

/* Header */
.site-header {
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.site-header .inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 11px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--text);
}
.brand:hover { color: var(--text); }
.brand-logo { display: block; border-radius: 7px; flex-shrink: 0; }
.brand small {
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 99px;
  font-size: .72rem;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.site-nav { display: flex; gap: 6px; flex-wrap: wrap; font-size: .92rem; }
.site-nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 6px 11px;
  border-radius: 8px;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.site-nav a:hover { background: #eef2f6; color: var(--text); }
.site-nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Main layout & typography */
main { max-width: 920px; margin: 0 auto; padding: 28px 20px 68px; }
h1 { font-size: clamp(1.65rem, 3.2vw, 2.15rem); line-height: 1.2; letter-spacing: -0.025em; margin: .2em 0 .45em; }
h2 { font-size: 1.35rem; letter-spacing: -0.015em; margin-top: 2.2em; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
h3 { font-size: 1.08rem; margin-top: 1.4em; letter-spacing: -0.01em; }
.lead { font-size: 1.08rem; color: var(--muted); line-height: 1.6; }

/* Hero (Home) */
.hero {
  background:
    radial-gradient(circle at 92% 12%, rgba(56, 189, 248, .12), transparent 45%),
    linear-gradient(180deg, #ffffff 0%, #f9fbfd 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 26px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 99px;
  margin-bottom: 10px;
}
.hero h1 { margin-top: 4px; }
.hero .lead { margin-bottom: 18px; max-width: 68ch; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.hero-meta {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: .86rem;
  color: var(--muted);
}
.hero-meta strong { color: var(--text); font-weight: 600; }

/* Banners */
.banner {
  background: var(--accent-soft);
  border: 1px solid #c5d9ea;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: .92rem;
  margin: 16px 0;
}
.banner.warn { background: #fff8ea; border-color: #eed6a4; }
.meta { font-size: .85rem; color: var(--muted); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin: 16px 0;
  box-shadow: var(--shadow-sm);
}
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.cards .card {
  margin: 0;
  display: flex;
  flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.cards .card.ready:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #b7cadb;
}
.cards .card.soon { background: #fafbfc; opacity: .88; }
.cards .card h3 { margin-top: 0; font-size: 1.04rem; line-height: 1.35; }
.cards .card .spacer { flex: 1; min-height: 10px; }
.cards .card p:last-child { margin-bottom: 0; margin-top: 12px; }
.tag {
  display: inline-block;
  font-size: .74rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 99px;
  background: var(--g2-soft);
  color: var(--g2);
  margin-right: 6px;
}
.tag.soon { background: #e9edf2; color: var(--muted); }
.done-badge { color: var(--g2); font-weight: 600; font-size: .84rem; }

/* G1 vs G2 comparison */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0; }
@media (max-width: 640px) { .compare { grid-template-columns: 1fr; } }
.g1, .g2 { border-radius: var(--radius); padding: 14px 16px; border: 1px solid; }
.g1 { background: var(--g1-soft); border-color: var(--g1-border); border-top: 3px solid var(--g1); }
.g2 { background: var(--g2-soft); border-color: var(--g2-border); border-top: 3px solid var(--g2); }
.g1 h4, .g2 h4 { margin: 0 0 8px; font-size: .95rem; }
.g1 h4 { color: var(--g1); } .g2 h4 { color: var(--g2); }

/* Tables */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin: 14px 0;
}
table { border-collapse: collapse; width: 100%; font-size: .93rem; margin: 0; }
th, td { border-bottom: 1px solid var(--border); padding: 10px 12px; text-align: left; vertical-align: top; }
th { background: #f1f5f9; font-weight: 600; font-size: .86rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
.table-wrap tr.highlight td { background: #fffaf0; font-weight: 500; }

/* Calculators */
.calc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 20px 0;
  box-shadow: var(--shadow-sm);
}
.calc h3 { margin-top: 0; }
.inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px 14px; margin-bottom: 14px; }
.inputs label { font-size: .84rem; font-weight: 500; color: var(--muted); display: block; }
.inputs input, .inputs select {
  display: block;
  margin-top: 4px;
  font: inherit;
  font-size: .98rem;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.inputs input:focus, .inputs select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.results { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .results { grid-template-columns: 1fr; } }
.results dl { margin: 0; display: grid; grid-template-columns: auto auto; gap: 4px 10px; font-size: .92rem; }
.results dt { color: var(--muted); }
.results dd { margin: 0; text-align: right; font-family: var(--mono); font-weight: 500; }
.verdict { margin-top: 10px; font-weight: 600; }
.verdict.ok { color: var(--g2); } .verdict.bad { color: var(--bad); }
.chart { width: 100%; height: auto; display: block; margin-top: 12px; }

/* Step-by-step worked examples */
.steps { counter-reset: step; padding: 0; list-style: none; }
.steps > li {
  counter-increment: step;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px 12px 52px;
  margin: 10px 0;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.steps > li::before {
  content: counter(step);
  position: absolute;
  left: 14px;
  top: 12px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: .8rem;
  font-weight: 600;
  display: grid;
  place-items: center;
}
.steps > li.hidden-step { display: none; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: .93rem;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #fff; color: var(--accent); }
.btn.secondary:hover { background: var(--accent-soft); color: var(--accent-hover); border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }

/* Quiz */
.quiz {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 20px 0;
  box-shadow: var(--shadow-sm);
}
.q { border-top: 1px solid var(--border); padding: 16px 0; }
.q:first-of-type { border-top: 0; }
.q p.question { font-weight: 600; margin: 0 0 8px; }
.q label.opt { display: flex; gap: 9px; align-items: flex-start; padding: 7px 10px; border-radius: 8px; cursor: pointer; transition: background .12s; }
.q label.opt:hover { background: #f2f5f8; }
.q input[type="number"] {
  font: inherit;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 170px;
}
.q .feedback { margin-top: 8px; padding: 9px 12px; border-radius: 8px; font-size: .92rem; display: none; }
.q.correct .feedback { display: block; background: var(--g2-soft); }
.q.wrong .feedback { display: block; background: var(--bad-soft); }
.score { font-weight: 700; font-size: 1.05rem; }

.feedback-box {
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-top: 32px;
  background: var(--accent-soft);
}
.lesson-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 32px; flex-wrap: wrap; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); font-size: .85rem; color: var(--muted); }
.site-footer .inner { max-width: 920px; margin: 0 auto; padding: 20px; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

@media (max-width: 600px) {
  .hero { padding: 20px 18px; }
  .site-header .inner { padding: 10px 16px; }
  main { padding: 20px 16px 56px; }
}
