:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5b6676;
  --line: #e2e6ec;
  --accent: #0f6cbd;
  --accent-soft: #e8f1fb;
  --ok: #1a7f37;
  --ok-soft: #e6f4ea;
  --warn: #9a6700;
  --warn-soft: #fff6dd;
  --bad: #c62828;
  --bad-soft: #fdecec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1a2029;
    --text: #e6eaf0;
    --muted: #9aa5b4;
    --line: #2c3440;
    --accent: #5aa7f0;
    --accent-soft: #1b2c40;
    --ok: #57c27a;
    --ok-soft: #173023;
    --warn: #e0b341;
    --warn-soft: #33290f;
    --bad: #f08080;
    --bad-soft: #3a1c1c;
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
a { color: var(--accent); }
header.top {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
header.top .inner {
  max-width: 1280px; margin: 0 auto; padding: 10px 20px;
  display: flex; gap: 18px; align-items: center; flex-wrap: wrap;
}
header.top .brand { font-weight: 700; color: var(--text); text-decoration: none; margin-right: auto; }
header.top .brand span { color: var(--muted); font-weight: 400; }
header.top nav a {
  text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: 15px;
}
header.top nav a:hover { background: var(--accent-soft); color: var(--accent); }
header.top nav a.active { background: var(--accent); color: #fff; }

.layout { max-width: 1280px; margin: 0 auto; padding: 24px 20px 60px; display: grid; grid-template-columns: 250px 1fr; gap: 28px; }
.toc { position: sticky; top: 70px; align-self: start; font-size: 14px; }
.toc h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.toc ol { margin: 0; padding-left: 20px; }
.toc li { margin: 4px 0; }
.toc a { color: var(--text); text-decoration: none; }
.toc a:hover { color: var(--accent); }
main { min-width: 0; }
h1 { font-size: 30px; line-height: 1.25; margin: 0 0 6px; overflow-wrap: anywhere; }
main, .steps > li, .card { overflow-wrap: break-word; }
.lead { color: var(--muted); margin: 0 0 24px; font-size: 17px; }
h2 { font-size: 22px; margin: 40px 0 12px; padding-top: 8px; scroll-margin-top: 80px; }
h3 { font-size: 18px; margin: 26px 0 8px; scroll-margin-top: 80px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 22px; margin: 14px 0;
}
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps > li {
  counter-increment: step; position: relative; padding: 14px 18px 14px 58px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  margin: 12px 0; box-shadow: var(--shadow);
}
.steps > li::before {
  content: counter(step); position: absolute; left: 16px; top: 14px;
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff;
  font-weight: 700; font-size: 14px; display: grid; place-items: center;
}
.steps > li p { margin: 6px 0; }
.path {
  display: inline-block; background: var(--accent-soft); color: var(--accent);
  border-radius: 6px; padding: 1px 8px; font-weight: 600; font-size: 14.5px;
}
kbd, .btn {
  display: inline-block; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px;
  padding: 0 7px; font: 600 14px/1.6 inherit; background: var(--surface); white-space: nowrap;
}
.btn.yellow { background: #ffd84d; color: #1c2430; border-color: #e0b400; }

figure { margin: 12px 0 4px; }
figure img {
  width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; cursor: zoom-in; display: block;
  background: #fff;
}
figcaption { color: var(--muted); font-size: 13.5px; margin-top: 6px; }

.note, .warn, .tip, .bad {
  border-radius: var(--radius); padding: 12px 16px; margin: 14px 0; border-left: 4px solid;
}
.note { background: var(--accent-soft); border-color: var(--accent); }
.tip { background: var(--ok-soft); border-color: var(--ok); }
.warn { background: var(--warn-soft); border-color: var(--warn); }
.bad { background: var(--bad-soft); border-color: var(--bad); }
.note b:first-child, .tip b:first-child, .warn b:first-child, .bad b:first-child { display: block; margin-bottom: 2px; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; font-size: 15px; }
th, td { border-bottom: 1px solid var(--line); padding: 9px 12px; text-align: left; vertical-align: top; }
th { background: var(--accent-soft); font-weight: 600; }
.tbl { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); margin: 12px 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 18px 0; }
.tile {
  display: block; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); transition: border-color .15s, transform .15s;
}
.tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.tile .ico { font-size: 28px; }
.tile h3 { margin: 8px 0 4px; }
.tile p { margin: 0; color: var(--muted); font-size: 14.5px; }

.flow { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; margin: 16px 0; }
.flow .st {
  flex: 1 1 150px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; font-size: 14px; box-shadow: var(--shadow); position: relative;
}
.flow .st b { display: block; font-size: 14.5px; }
.flow .st small { color: var(--muted); }
.flow .st.r { border-top: 4px solid #0f6cbd; }
.flow .st.k { border-top: 4px solid #9a6700; }
.flow .st.d { border-top: 4px solid #1a7f37; }
.legend { font-size: 13px; color: var(--muted); display: flex; gap: 16px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; }
.pager a { flex: 1; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; color: var(--text); }
.pager a:hover { border-color: var(--accent); }
.pager a small { color: var(--muted); display: block; }
.pager a.next { text-align: right; }

#lightbox {
  position: fixed; inset: 0; background: rgba(10, 14, 20, .88); display: none; z-index: 100;
  align-items: center; justify-content: center; padding: 20px; cursor: zoom-out;
}
#lightbox.on { display: flex; }
#lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; background: #fff; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .toc { position: static; }
}
@media print {
  header.top, .toc, .pager, #lightbox { display: none !important; }
  .layout { display: block; padding: 0; }
  body { background: #fff; }
  .steps > li, .card { box-shadow: none; break-inside: avoid; }
  figure img { max-height: 120mm; object-fit: contain; }
}

@media (max-width: 420px) {
  .btn { white-space: normal; }
}
