/* BASE — база знаний. Светлая «бумага», тёмные чернила, у каждого понятия свой цвет. */
:root {
  --paper: #faf7f0;
  --card: #ffffff;
  --ink: #17202e;
  --ink-2: #4a5466;
  --line: #e4dfd2;
  --navy: #14213d;
  --gold: #e0a21b;
  --gold-soft: #fdf1d3;
  --c-segments: #0f8b8d;
  --c-step: #6c4bd8;
  --c-dh: #d9573b;
  --c-golden-trend: #c98b00;
  --c-glossary: #2f6fdd;
  --up: #1c9a5a;
  --down: #d24545;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 6px 20px rgba(20, 33, 61, .06);
  --serif: "PT Serif", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "PT Sans", Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --top: 60px;
}
* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top) + 16px); }
body { margin: 0; background: var(--paper); color: var(--ink); font: 18px/1.65 var(--sans); }
a { color: var(--c-glossary); }
img, svg { max-width: 100%; height: auto; }
code { font: .86em var(--mono); background: #f0ece2; padding: .1em .35em; border-radius: 5px; overflow-wrap: anywhere; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 99; background: #fff; padding: 8px 12px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* шапка */
.top { position: sticky; top: 0; z-index: 20; height: var(--top); display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 20px; background: rgba(250, 247, 240, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--navy); text-decoration: none; font-weight: 800; letter-spacing: .06em; }
.brand small { display: block; font-weight: 500; letter-spacing: 0; color: var(--ink-2); font-size: 12px; line-height: 1; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--navy); color: var(--gold); display: grid; place-items: center; font-family: var(--serif); font-size: 20px; }
.controls { display: flex; align-items: center; gap: 10px; }
.seg { display: inline-flex; background: #ece7da; border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; font: 600 15px var(--sans); color: var(--ink-2); padding: 6px 14px; border-radius: 999px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.lang { font: 700 14px var(--sans); color: var(--navy); text-decoration: none; border: 1.5px solid var(--navy); border-radius: 8px; padding: 4px 9px; }
.menu-btn { display: none; border: 0; background: none; font-size: 24px; cursor: pointer; }

/* раскладка */
.side { position: fixed; top: var(--top); left: 0; bottom: 0; width: 230px; padding: 24px 14px; overflow-y: auto; border-right: 1px solid var(--line); }
.side a { display: block; padding: 8px 12px; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.side a:hover { background: #efeadf; color: var(--ink); }
.side a[aria-current="page"] { background: var(--navy); color: #fff; }
main { margin-left: 230px; padding: 32px clamp(18px, 4vw, 56px) 40px; max-width: 1060px; }
.foot { margin-left: 230px; padding: 24px clamp(18px, 4vw, 56px) 48px; color: var(--ink-2); font-size: 15px; border-top: 1px solid var(--line); }
.muted { color: var(--ink-2); font-size: 14px; }

/* уровень объяснения */
.lvl-simple .lv-pro, .lvl-pro .lv-simple { display: none !important; }

/* заголовки */
.hero { padding: 8px 0 20px; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .12em; font-size: 13px; font-weight: 700; color: var(--ink-2); }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; color: var(--navy); }
h1 { font-size: clamp(34px, 5vw, 52px); margin: 6px 0 12px; }
h1 .aka { font: 500 .45em var(--sans); color: var(--ink-2); }
h2 { font-size: 30px; margin: 44px 0 12px; }
h3 { font-size: 22px; margin: 28px 0 8px; }
.lead { font-size: 21px; color: var(--ink-2); max-width: 46em; margin: 0 0 10px; }
.prose { max-width: 46em; }
.prose p, .prose li { max-width: 42em; }

.hero-segments h1 { color: var(--c-segments); }
.hero-step h1 { color: var(--c-step); }
.hero-dh h1 { color: var(--c-dh); }
.hero-golden-trend h1 { color: var(--c-golden-trend); }

/* бейджи, чипы, теги */
.badge { display: inline-block; font: 600 13px var(--sans); padding: 2px 10px; border-radius: 999px; }
.badge-stable { background: #e2f4ea; color: #146c40; }
.badge-refining { background: #fff1d6; color: #8a5a00; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 6px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 500; }
.chip:hover { border-color: var(--navy); }
.tag { display: inline-block; font: 600 12px var(--mono); padding: 1px 8px; border-radius: 6px; margin-right: 6px; background: #eef1f6; color: var(--ink-2); }
.tag-mamba { background: #e5f4f1; color: #0b6b5c; }
.tag-cryptotrader { background: #ece8fb; color: #4a33a8; }
a.term { color: inherit; text-decoration: underline dotted 2px; text-decoration-color: var(--gold); text-underline-offset: 3px; }
a.term:hover { background: var(--gold-soft); }

/* карточки на главной */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; margin: 24px 0; }
.card { display: block; background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); text-decoration: none; color: var(--ink);
  border-top: 5px solid var(--navy); transition: transform .15s ease; }
.card:hover { transform: translateY(-3px); }
.card h3 { margin: 8px 0 6px; }
.card p { font-size: 16px; color: var(--ink-2); margin: 0 0 12px; }
.card-icon { font-size: 30px; }
.card-segments { border-color: var(--c-segments); } .card-step { border-color: var(--c-step); }
.card-dh { border-color: var(--c-dh); } .card-golden-trend { border-color: var(--c-golden-trend); }
.card-glossary { border-color: var(--c-glossary); }

/* блоки текста */
.note { border-radius: 12px; padding: 14px 18px; margin: 18px 0; background: var(--card); border-left: 5px solid var(--navy); box-shadow: var(--shadow); max-width: 46em; }
.note-warn { border-color: var(--gold); background: #fffaf0; }
.note-idea { border-color: var(--c-segments); }
.note-example { border-color: var(--c-step); }
.note-risk { border-color: var(--down); }
.note > :first-child { margin-top: 0; } .note > :last-child { margin-bottom: 0; }
.analogy { display: grid; grid-template-columns: 64px 1fr; gap: 16px; align-items: start; background: var(--gold-soft); border-radius: var(--radius); padding: 18px 20px; margin: 22px 0; max-width: 46em; }
.analogy .emoji { font-size: 46px; line-height: 1; }
.analogy p { margin: 0 0 8px; } .analogy p:last-child { margin: 0; }
.big-idea { font-family: var(--serif); font-size: 26px; line-height: 1.35; color: var(--navy); border-left: 6px solid var(--gold); padding: 4px 0 4px 20px; margin: 26px 0; max-width: 34em; }

.steps { counter-reset: s; list-style: none; padding: 0; max-width: 46em; }
.steps > li { counter-increment: s; position: relative; padding: 0 0 18px 56px; }
.steps > li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 38px; height: 38px; border-radius: 50%; background: var(--navy); color: #fff;
  display: grid; place-items: center; font-weight: 700; }
.steps > li strong:first-child { display: block; }

.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin: 18px 0; }
.kv div { background: var(--card); border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow); }
.kv b { display: block; font-size: 24px; font-family: var(--serif); color: var(--navy); }
.kv span { font-size: 14px; color: var(--ink-2); }

table { border-collapse: collapse; width: 100%; margin: 16px 0; font-size: 16px; background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f3efe5; font-weight: 700; }
.tablewrap { overflow-x: auto; }

figure { margin: 24px 0; background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
figure img { display: block; border-radius: 8px; border: 1px solid var(--line); }
figcaption { font-size: 15px; color: var(--ink-2); margin-top: 10px; }
figure svg { display: block; width: 100%; }
figure.real figcaption::before { content: "📷 "; }
figure.scheme figcaption::before { content: "✏️ "; }
pre { background: #1b2433; color: #e8edf5; padding: 14px 18px; border-radius: 12px; overflow-x: auto; font: 14px/1.5 var(--mono); }
pre code { background: none; padding: 0; color: inherit; }

details.sources { margin: 30px 0 0; background: var(--card); border-radius: 12px; padding: 12px 18px; border: 1px dashed var(--line); font-size: 15px; }
details.sources summary { cursor: pointer; font-weight: 700; }
details.sources li { margin: 4px 0; }
.related { margin-top: 40px; }
.related h2 { font-size: 22px; }

/* словарь */
.gtools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 20px 0 8px; position: sticky; top: var(--top); background: var(--paper); padding: 10px 0; z-index: 5; }
#gsearch { flex: 1 1 260px; font: 17px var(--sans); padding: 10px 16px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); }
#gsearch:focus { border-color: var(--navy); outline: none; }
.letters { display: flex; flex-wrap: wrap; gap: 6px; color: var(--ink-2); font-weight: 700; font-size: 14px; }
.glist { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.gcard { background: var(--card); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.gcard h3 { margin: 0; font-size: 21px; }
.gcard h3 a { color: var(--navy); text-decoration: none; }
.gcard .aliases { margin: 2px 0 6px; font-size: 14px; color: var(--ink-2); font-family: var(--mono); }
.gcard .tags { margin: 0 0 8px; }
.gcard p { font-size: 16px; margin: 8px 0; }
.gcard .diff { background: #fffaf0; border-radius: 8px; padding: 8px 10px; font-size: 15px; }
.gcard details.sources { margin-top: 10px; padding: 8px 12px; font-size: 13px; }
.gcard.flash { outline: 3px solid var(--gold); }
.more { font-weight: 600; }

/* мобильные */
@media (max-width: 860px) {
  body { font-size: 17px; }
  .menu-btn { display: block; }
  .side { transform: translateX(-100%); background: var(--paper); transition: transform .2s; z-index: 15; width: 260px; box-shadow: var(--shadow); }
  .nav-open .side { transform: none; }
  main, .foot { margin-left: 0; }
  .brand small { display: none; }
  .seg button { padding: 6px 10px; font-size: 14px; }
  .analogy { grid-template-columns: 1fr; }
  .glist { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .top, .side, .gtools { display: none; } main, .foot { margin: 0; } .lv-simple, .lv-pro { display: block !important; } }
