:root {
  --bg: #f3f6f9;
  --surface: #ffffff;
  --surface-2: #eef3f7;
  --text: #13202e;
  --muted: #5a6b7c;
  --border: #d9e2ea;
  --brand: #0a95a0;
  --brand-ink: #087881;
  --brand-soft: #e1f4f5;
  --side: #0c2a3d;
  --side-text: #c9d8e3;
  --side-active: #0f6f79;
  --ok: #1f8a4c; --ok-soft: #e3f4ea;
  --warn: #9a6b00; --warn-soft: #fff4d6;
  --bad: #c0392b; --bad-soft: #fbe7e5;
  --shadow: 0 1px 2px rgba(16,32,48,.06), 0 4px 16px rgba(16,32,48,.06);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1620; --surface: #15202c; --surface-2: #1b2836; --text: #e4ecf3; --muted: #93a5b6;
    --border: #2a3a4b; --brand: #23b7c2; --brand-ink: #4fd0d9; --brand-soft: #123a40;
    --side: #0a131c; --side-text: #a9bccb; --side-active: #13525a;
    --ok: #4cc27f; --ok-soft: #133524; --warn: #e5b543; --warn-soft: #3a2f12; --bad: #ef7a6d; --bad-soft: #3d1c19;
    --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1620; --surface: #15202c; --surface-2: #1b2836; --text: #e4ecf3; --muted: #93a5b6;
  --border: #2a3a4b; --brand: #23b7c2; --brand-ink: #4fd0d9; --brand-soft: #123a40;
  --side: #0a131c; --side-text: #a9bccb; --side-active: #13525a;
  --ok: #4cc27f; --ok-soft: #133524; --warn: #e5b543; --warn-soft: #3a2f12; --bad: #ef7a6d; --bad-soft: #3d1c19;
  --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 16px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-ink); }
img { max-width: 100%; }

/* layout */
.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-text); padding: 20px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; text-decoration: none; }
.brand img { width: 40px; height: 40px; }
.brand b { display: block; font-size: 17px; line-height: 1.2; }
.brand small { color: var(--side-text); font-size: 12.5px; }
.side h4 { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: #7f9bb0; margin: 18px 10px 6px; }
.side a.nav { display: block; color: var(--side-text); text-decoration: none; padding: 7px 10px; border-radius: 8px; font-size: 14.5px; }
.side a.nav:hover { background: rgba(255,255,255,.06); color: #fff; }
.side a.nav.active { background: var(--side-active); color: #fff; font-weight: 600; }
.side .toc a { display: block; color: var(--side-text); text-decoration: none; font-size: 13.5px; padding: 4px 10px 4px 22px; border-left: 2px solid transparent; }
.side .toc a:hover, .side .toc a.current { color: #fff; border-left-color: var(--brand); }
.theme-btn { margin: 22px 10px 0; background: transparent; color: var(--side-text); border: 1px solid #2c4659; border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 13px; cursor: pointer; }

.main { padding: 36px clamp(16px, 4vw, 56px) 80px; max-width: 1080px; width: 100%; }
.topbar-m { display: none; }

/* typography */
.eyebrow { color: var(--brand-ink); font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
h1 { font-size: clamp(28px, 4vw, 38px); line-height: 1.15; margin: 6px 0 10px; letter-spacing: -.01em; }
h2 { font-size: 24px; margin: 52px 0 12px; padding-top: 8px; border-top: 1px solid var(--border); letter-spacing: -.005em; }
h2:first-of-type { border-top: 0; }
h3 { font-size: 18.5px; margin: 30px 0 8px; }
p.lead { font-size: 18px; color: var(--muted); max-width: 70ch; margin-top: 0; }
p, li { max-width: 78ch; }
.muted { color: var(--muted); }
kbd { background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 0 6px; font-size: .88em; }
.btnref { display: inline-block; background: var(--brand-soft); color: var(--brand-ink); border: 1px solid color-mix(in srgb, var(--brand) 35%, transparent); border-radius: 6px; padding: 0 7px; font-weight: 600; font-size: .92em; white-space: nowrap; }
.path { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }

/* cards & callouts */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 22px 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block; }
a.card:hover { border-color: var(--brand); }
.card h3 { margin: 0 0 6px; font-size: 17px; }
.card p { margin: 0; color: var(--muted); font-size: 14.5px; }
.card .tag { display: inline-block; font-size: 12px; font-weight: 600; color: var(--brand-ink); margin-bottom: 6px; }

.note { border-radius: 10px; padding: 12px 16px; margin: 16px 0; border: 1px solid var(--border); background: var(--surface); }
.note.tip { background: var(--brand-soft); border-color: transparent; }
.note.warn { background: var(--warn-soft); border-color: transparent; }
.note.bad { background: var(--bad-soft); border-color: transparent; }
.note > b:first-child { display: block; margin-bottom: 2px; }

/* steps */
ol.steps { counter-reset: s; list-style: none; padding: 0; margin: 14px 0; }
ol.steps > li { counter-increment: s; position: relative; padding: 2px 0 12px 44px; }
ol.steps > li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center;
}

/* figures */
figure.shot { margin: 18px 0 26px; }
figure.shot img {
  display: block; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  background: #fff; cursor: zoom-in; height: auto;
}
figure.shot.phone img { max-width: min(340px, 100%); border-radius: 22px; border: 6px solid #1b2733; }
figure.shot.part img { max-width: min(560px, 100%); }
figure.shot figcaption { font-size: 14px; color: var(--muted); margin-top: 8px; max-width: 70ch; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; align-items: start; }
.gallery figure.shot { margin: 0; }
.gallery figure.shot.phone img { max-width: 100%; }

/* tables */
.table-wrap { overflow-x: auto; margin: 14px 0 22px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.y { color: var(--ok); font-weight: 700; text-align: center; }
td.n { color: var(--muted); text-align: center; }
td.p { color: var(--warn); font-weight: 600; text-align: center; }
table.matrix th:not(:first-child) { text-align: center; }

.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: 13px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.info { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }

/* flow diagram */
.flow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 12px 0 6px; }
.flow .arrow { color: var(--muted); }
.flow-side { font-size: 14px; color: var(--muted); margin: 4px 0 18px; }

/* lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(5,12,18,.88); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50; cursor: zoom-out; overflow: auto; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; background: #fff; }

footer.doc { margin-top: 70px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13.5px; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin-top: 50px; flex-wrap: wrap; }
.pager a { flex: 1 1 220px; border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; text-decoration: none; background: var(--surface); }
.pager a small { display: block; color: var(--muted); }
.pager a.next { text-align: right; }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 280px; transform: translateX(-100%); transition: transform .2s; z-index: 40; }
  body.menu-open .side { transform: none; box-shadow: 0 0 0 100vw rgba(0,0,0,.4); }
  .topbar-m { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30; background: var(--side); color: #fff; padding: 10px 16px; }
  .topbar-m button { background: transparent; color: #fff; border: 1px solid #2c4659; border-radius: 8px; padding: 4px 10px; font-size: 18px; }
  .topbar-m img { width: 28px; height: 28px; }
  .main { padding: 24px 16px 60px; }
  figure.shot.phone img { max-width: 100%; }
}
@media print {
  .side, .topbar-m, .theme-btn, .pager { display: none !important; }
  .layout { display: block; }
  figure.shot { break-inside: avoid; }
}
