:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #fbfaf8;
  --border: #e4e1da;
  --text: #1c1b19;
  --muted: #5d5a54;
  --faint: #8a867e;
  --accent: #e06c00;
  --accent-text: #b45300;
  --accent-soft: #fff1e3;
  --good: #1f8a4c;
  --good-soft: #e6f5ec;
  --warn: #9a6400;
  --warn-soft: #fff6dc;
  --bad: #b3261e;
  --bad-soft: #fdecea;
  --code-bg: #1d1c1a;
  --code-text: #f1efe9;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --side: 290px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131312; --surface: #1b1b19; --surface-2: #171716; --border: #2e2d2a;
    --text: #ecebe7; --muted: #b3b0a8; --faint: #85827b;
    --accent-text: #ffa24d; --accent-soft: #3a2410;
    --good-soft: #13291c; --warn-soft: #2e240c; --bad-soft: #321614;
    --good: #58c98a; --warn: #e7b547; --bad: #f08076;
  }
}
:root[data-theme="dark"] {
  --bg: #131312; --surface: #1b1b19; --surface-2: #171716; --border: #2e2d2a;
  --text: #ecebe7; --muted: #b3b0a8; --faint: #85827b;
  --accent-text: #ffa24d; --accent-soft: #3a2410;
  --good-soft: #13291c; --warn-soft: #2e240c; --bad-soft: #321614;
  --good: #58c98a; --warn: #e7b547; --bad: #f08076;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 20px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15.5px/1.7 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); }
img { max-width: 100%; }
code, kbd { font-family: var(--mono); font-size: .88em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; overflow-wrap: anywhere; }
kbd { border-bottom-width: 2px; }

/* ---- layout ---- */
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side); background: #161513; color: #d9d6cf;
  display: flex; flex-direction: column; border-top: 3px solid var(--accent); z-index: 20;
}
.side-head { padding: 20px 20px 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 600; font-size: 16px; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; inset: 6px; border-radius: 2px; background: #161513; }
.brand small { display: block; font-weight: 400; font-size: 12px; color: #9c988f; }
.search { margin-top: 14px; width: 100%; padding: 8px 11px; border-radius: 8px; border: 1px solid #34322e; background: #1f1e1b; color: #fff; font: inherit; font-size: 14px; }
.search::placeholder { color: #85827b; }
.toc { overflow-y: auto; padding: 4px 12px 24px; flex: 1; }
.toc p { margin: 16px 8px 4px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #85827b; }
.toc a { display: block; padding: 5px 10px; border-radius: 7px; color: #d9d6cf; text-decoration: none; font-size: 14px; line-height: 1.4; }
.toc a.sub { padding-left: 22px; font-size: 13.2px; color: #b3b0a8; }
.toc a:hover { background: #24231f; color: #fff; }
.toc a.active { background: #2b2118; color: #ffb36b; }
.toc .hidden { display: none; }
.side-foot { padding: 12px 20px 18px; border-top: 1px solid #2a2926; font-size: 12px; color: #85827b; }

main { margin-left: var(--side); padding: 36px 48px 80px; }
.content { max-width: 940px; margin: 0 auto; }
.topbar { display: none; }

/* ---- type ---- */
h1 { font-size: 34px; line-height: 1.2; margin: 6px 0 12px; letter-spacing: -.01em; }
h2 { font-size: 26px; line-height: 1.25; margin: 64px 0 12px; padding-top: 22px; border-top: 1px solid var(--border); }
h3 { font-size: 19px; margin: 36px 0 8px; }
h4 { font-size: 16px; margin: 24px 0 6px; }
p { margin: 10px 0; }
.lede { font-size: 17.5px; color: var(--muted); }
.eyebrow { font-family: var(--mono); font-size: 12.5px; color: var(--accent-text); letter-spacing: .04em; }
ul, ol { padding-left: 22px; margin: 10px 0; }
li { margin: 4px 0; }
.muted { color: var(--muted); }
.anchor { color: var(--faint); text-decoration: none; margin-left: 8px; font-weight: 400; opacity: 0; }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }

/* ---- blocks ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin: 18px 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.card h4 { margin: 0 0 4px; }
.card p { margin: 4px 0 0; color: var(--muted); font-size: 14.5px; }
.card a.more { display: inline-block; margin-top: 8px; font-size: 14px; font-weight: 500; }

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

.steps { counter-reset: step; list-style: none; padding: 0; }
.steps > li { counter-increment: step; position: relative; padding: 2px 0 10px 44px; margin: 0; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 600; font-size: 14px; display: grid; place-items: center; }
.steps > li::after { content: ""; position: absolute; left: 13.5px; top: 32px; bottom: 2px; width: 1px; background: var(--border); }
.steps > li:last-child::after { display: none; }

.table-wrap { overflow-x: auto; margin: 14px 0; 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 13px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; font-size: 13.5px; }
tr:last-child td { border-bottom: 0; }
td code { white-space: nowrap; }

pre { position: relative; background: var(--code-bg); color: var(--code-text); border-radius: 10px; padding: 14px 16px; overflow-x: auto; font: 13.2px/1.6 var(--mono); margin: 14px 0; }
pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; overflow-wrap: normal; }
pre .c { color: #9c988f; }
.copy { position: absolute; top: 8px; right: 8px; font: 12px var(--sans); padding: 3px 9px; border-radius: 6px; border: 1px solid #45423d; background: #2a2926; color: #e8e5de; cursor: pointer; }
.copy:hover { background: #36342f; }

figure { margin: 18px 0 26px; }
figure a.zoom { display: block; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 20px rgba(0,0,0,.05); cursor: zoom-in; }
figure img { display: block; width: 100%; height: auto; }
figure.phone { max-width: 300px; }
figure.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
figcaption { font-size: 13.5px; color: var(--muted); margin-top: 8px; }
figcaption b { color: var(--text); }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-text); vertical-align: 2px; }

.lightbox { position: fixed; inset: 0; background: rgba(10,10,9,.88); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 50; cursor: zoom-out; }
.lightbox img { max-height: 100%; max-width: 100%; border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.lightbox[hidden] { display: none; }

.nohit { display: none; padding: 20px; color: var(--muted); }
.backtop { position: fixed; right: 18px; bottom: 18px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 18px; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,.1); }

/* ---- small screens ---- */
@media (max-width: 960px) {
  .side { transform: translateX(-100%); transition: transform .2s; width: min(86vw, 320px); }
  body.menu-open .side { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  main { margin-left: 0; padding: 0 16px 60px; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 10; background: #161513; color: #fff; margin: 0 -16px 18px; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; border-top: 3px solid var(--accent); }
  .topbar button { background: #26241f; color: #fff; border: 1px solid #3a3833; border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 14px; }
  .topbar .brand { font-size: 15px; }
  h1 { font-size: 27px; }
  h2 { font-size: 22px; margin-top: 44px; }
  figure.pair { grid-template-columns: 1fr; }
}
.cap { margin-top: -14px; font-size: 13.5px; }
.foot { margin-top: 48px; font-size: 13px; }
