:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f0f0ed;
  --text: #191919;
  --muted: #65655f;
  --line: #ddddda;
  --accent: #c7671a;
  --accent-strong: #9d4b0d;
  --accent-soft: #fff2e7;
  --good: #287a4a;
  --warning: #8b5a00;
  --warning-bg: #fff8e6;
  --danger-bg: #fff0ee;
  --code-bg: #1f2022;
  --code-text: #f4f4f4;
  --shadow: 0 16px 40px rgba(0, 0, 0, .06);
  --radius: 14px;
  --content: 760px;
}

:root[data-theme="dark"] {
  --bg: #111211;
  --surface: #181918;
  --surface-2: #20211f;
  --text: #f1f1ed;
  --muted: #a8a8a1;
  --line: #30312e;
  --accent: #e38a42;
  --accent-strong: #f0a66b;
  --accent-soft: #2c2017;
  --good: #6fc48f;
  --warning: #e6bd64;
  --warning-bg: #2c2618;
  --danger-bg: #2b1c1b;
  --code-bg: #090a0a;
  --code-text: #f5f5f2;
  --shadow: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 82px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
}
a { color: var(--accent-strong); text-underline-offset: 3px; }
button, select { font: inherit; }
code { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: .92em; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 91%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--text); font-weight: 680; letter-spacing: -.02em; }
.top-actions { display: flex; align-items: center; gap: 16px; }
.text-link { font-size: .9rem; text-decoration: none; color: var(--muted); }
.text-link:hover { color: var(--text); }
.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.page-shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 58px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 46px 28px 96px;
}
.sidebar { min-width: 0; }
.sidebar-inner { position: sticky; top: 94px; }
.sidebar-label, .eyebrow {
  margin: 0 0 10px;
  font-size: .74rem;
  font-weight: 760;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
#toc { display: flex; flex-direction: column; gap: 2px; }
#toc a {
  display: block;
  padding: 5px 0 5px 12px;
  color: var(--muted);
  text-decoration: none;
  font-size: .9rem;
  border-left: 2px solid transparent;
  transition: color .12s ease, border-color .12s ease;
}
#toc a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 700;
}

main { max-width: var(--content); width: 100%; min-width: 0; }
.hero { padding: 18px 0 44px; }
h1, h2, h3 { line-height: 1.16; letter-spacing: -.035em; margin-top: 0; }
h1 { font-size: clamp(2.35rem, 5vw, 4.4rem); max-width: 720px; margin-bottom: 20px; font-weight: 760; }
h2 { font-size: clamp(1.7rem, 3vw, 2.35rem); margin-bottom: 16px; font-weight: 720; }
h3 { font-size: 1.2rem; margin: 30px 0 10px; letter-spacing: -.02em; }
.lede { font-size: 1.14rem; color: var(--muted); max-width: 690px; margin: 0; }

.guide-section {
  position: relative;
  padding: 54px 0;
  border-top: 1px solid var(--line);
}
.step-number {
  display: block;
  color: var(--accent);
  font-size: .78rem;
  font-weight: 780;
  letter-spacing: .12em;
  margin-bottom: 10px;
}
.guide-section > p:first-of-type { margin-top: 0; }
.steps { padding-left: 1.25rem; }
.steps li { margin: 9px 0; padding-left: 5px; }
.compact-steps { margin-bottom: 0; }
.muted { color: var(--muted); }

.inline-choice { margin: 22px 0 14px; }
.inline-choice label { display: block; margin-bottom: 7px; color: var(--muted); font-size: .85rem; font-weight: 650; }
.inline-choice select {
  width: 100%;
  min-height: 46px;
  padding: 0 42px 0 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.path-panel {
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}
.path-panel[hidden] { display: none; }
.path-panel > strong { display: block; margin-bottom: 8px; }

.inline-branch {
  margin: 26px 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  overflow: hidden;
}
.inline-branch > summary {
  cursor: pointer;
  padding: 15px 18px;
  font-weight: 700;
  color: var(--accent-strong);
  list-style-position: inside;
}
.inline-branch[open] > summary { border-bottom: 1px solid var(--line); }
.inline-branch-body { padding: 2px 18px 20px; }
.inline-branch-body > :last-child { margin-bottom: 0; }

.notice, .warning, .do-not {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: 14px 16px;
  border-radius: 0 9px 9px 0;
  margin: 22px 0;
}
.warning { border-left-color: var(--warning); background: var(--warning-bg); }
.do-not { background: var(--danger-bg); border-left-color: #a44435; }

.trouble { margin-top: 28px; border-top: 1px dashed var(--line); padding-top: 15px; }
.trouble summary, .faq-list summary { cursor: pointer; font-weight: 650; color: var(--muted); }
.trouble[open] summary, .faq-list details[open] summary { color: var(--text); }
.trouble p { margin-bottom: 0; color: var(--muted); }
.faq-list details { padding: 15px 0; border-bottom: 1px solid var(--line); }
.faq-list p { color: var(--muted); margin-bottom: 2px; }

.code-block {
  position: relative;
  margin: 18px 0 24px;
  background: var(--code-bg);
  border-radius: 11px;
  overflow: hidden;
  border: 1px solid #303235;
}
.code-block pre { margin: 0; padding: 20px 88px 20px 20px; overflow-x: auto; color: var(--code-text); line-height: 1.55; }
.copy-button {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  border: 1px solid #4b4d51;
  background: #292b2e;
  color: #e9e9e9;
  border-radius: 7px;
  padding: 6px 10px;
  font-size: .78rem;
  cursor: pointer;
}
.copy-button.copied { border-color: #759a82; color: #a8dfba; }

.mock-window, .mock-settings, .mock-app-row {
  margin: 24px 0;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.mock-titlebar { height: 38px; display: flex; align-items: center; gap: 6px; padding: 0 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .78rem; }
.mock-titlebar span { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.mock-titlebar em { margin-left: 8px; font-style: normal; }
.mock-body { padding: 18px; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.mock-body.stacked { grid-template-columns: 1fr; }
.mock-label { grid-column: 1 / -1; color: var(--muted); font-size: .78rem; }
.mock-input, .mock-textarea { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--muted); overflow: hidden; }
.mock-textarea { min-height: 72px; font-family: monospace; }
.mock-button { background: var(--text); color: var(--bg); border-radius: 8px; padding: 10px 14px; font-weight: 650; width: fit-content; }
.mock-settings { padding: 5px 18px; }
.mock-setting { display: flex; justify-content: space-between; gap: 20px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.mock-setting:last-child { border-bottom: 0; }
.mock-setting span { color: var(--muted); }
.mock-setting strong { text-align: right; font-size: .92rem; max-width: 55%; overflow-wrap: anywhere; }
.mock-app-row { display: flex; align-items: center; gap: 12px; padding: 16px; }
.mock-app-icon { width: 42px; height: 42px; display: grid; place-items: center; background: var(--text); color: var(--bg); border-radius: 11px; font-weight: 800; }
.mock-app-row div:nth-child(2) { display: flex; flex-direction: column; flex: 1; }
.mock-app-row div:nth-child(2) span { color: var(--muted); font-size: .82rem; }
.mock-installed { color: var(--good); font-size: .82rem; font-weight: 700; }

.status-example { display: flex; align-items: flex-start; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); margin: 22px 0; }
.status-example span:last-child { color: var(--muted); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; flex: 0 0 auto; }
.status-dot.good { background: var(--good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--good) 15%, transparent); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 11px; margin: 22px 0; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
tr:last-child td { border-bottom: 0; }

.repo-callout { margin-top: 28px; padding: 18px; background: var(--surface-2); border-radius: 10px; }
.sources { padding-bottom: 18px; }
.source-list { padding-left: 1.15rem; }
.source-list li { margin: 6px 0; }
footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 28px 42px;
  color: var(--muted);
  font-size: .85rem;
  border-top: 1px solid var(--line);
}

@media (max-width: 900px) {
  .page-shell { grid-template-columns: 1fr; gap: 24px; padding-top: 20px; }
  .sidebar { position: sticky; top: 62px; z-index: 40; margin: 0 -28px; background: var(--bg); border-bottom: 1px solid var(--line); }
  .sidebar-inner { position: static; display: flex; overflow-x: auto; gap: 8px; padding: 9px 28px; scrollbar-width: none; }
  .sidebar-inner::-webkit-scrollbar { display: none; }
  .sidebar-label { display: none; }
  #toc { flex-direction: row; gap: 6px; }
  #toc a { white-space: nowrap; border-left: 0; border-bottom: 2px solid transparent; padding: 5px 7px; }
  #toc a.active { border-left: 0; border-bottom-color: var(--accent); color: var(--accent); }
  main { margin: 0 auto; }
}

@media (max-width: 620px) {
  .topbar { padding: 0 16px; }
  .brand { font-size: .92rem; max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .text-link { display: none; }
  .page-shell { padding-left: 16px; padding-right: 16px; }
  .sidebar { margin: 0 -16px; }
  .sidebar-inner { padding-left: 16px; padding-right: 16px; }
  h1 { font-size: 2.4rem; }
  .guide-section { padding: 42px 0; }
  .inline-branch-body { padding-left: 14px; padding-right: 14px; }
  .mock-setting { flex-direction: column; gap: 4px; }
  .mock-setting strong { text-align: left; max-width: none; }
  .mock-body { grid-template-columns: 1fr; }
  .code-block pre { padding-right: 20px; padding-top: 54px; }
  footer { flex-direction: column; padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
