:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #f1f4f6;
  --text: #182126;
  --muted: #637078;
  --line: #dce2e6;
  --line-strong: #c8d1d7;
  --accent: #0a88a6;
  --accent-strong: #08718a;
  --accent-soft: #e4f5f8;
  --green: #137a5a;
  --green-soft: #e6f6ef;
  --amber: #99650e;
  --amber-soft: #fff4d9;
  --red: #b43a3a;
  --red-soft: #fdecec;
  --code: #10181d;
  --code-text: #e8f0f3;
  --shadow: 0 16px 44px rgba(27, 44, 52, 0.08);
  --topbar-height: 64px;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #121719;
  --surface: #182024;
  --surface-soft: #202a2f;
  --text: #e7edef;
  --muted: #a5b1b7;
  --line: #334047;
  --line-strong: #46565e;
  --accent: #55bfd5;
  --accent-strong: #83d5e5;
  --accent-soft: #19363d;
  --green: #69c8a4;
  --green-soft: #19352b;
  --amber: #edbd60;
  --amber-soft: #3a2d17;
  --red: #f08b8b;
  --red-soft: #402222;
  --code: #0b0f11;
  --code-text: #e8f0f3;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #121719;
    --surface: #182024;
    --surface-soft: #202a2f;
    --text: #e7edef;
    --muted: #a5b1b7;
    --line: #334047;
    --line-strong: #46565e;
    --accent: #55bfd5;
    --accent-strong: #83d5e5;
    --accent-soft: #19363d;
    --green: #69c8a4;
    --green-soft: #19352b;
    --amber: #edbd60;
    --amber-soft: #3a2d17;
    --red: #f08b8b;
    --red-soft: #402222;
    --code: #0b0f11;
    --code-text: #e8f0f3;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-height) + 24px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 16px;
  line-height: 1.75;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

a {
  color: var(--accent-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

code,
pre {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
}

code {
  overflow-wrap: anywhere;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  background: var(--text);
  color: var(--bg);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.topbar {
  position: fixed;
  z-index: 100;
  inset: 0 0 auto;
  height: var(--topbar-height);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1440px;
  height: 100%;
  margin: 0 auto;
  padding: 0 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-size: 19px;
  font-weight: 800;
}

.brand > span:last-child {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand strong {
  font-size: 14px;
}

.brand small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.text-button,
.icon-button,
.copy-field button,
.code-toolbar button,
.dialog-close {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.text-button {
  display: none;
  padding: 0 12px;
}

.icon-button {
  display: grid;
  width: 44px;
  place-content: center;
  gap: 4px;
}

.menu-button span {
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
}

.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.primary-button.compact {
  min-height: 40px;
  padding-inline: 14px;
  font-size: 13px;
}

.secondary-button {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--text);
}

.secondary-button:hover {
  border-color: var(--accent);
}

.page-shell {
  min-height: 100vh;
  padding-top: var(--topbar-height);
}

.sidebar {
  position: fixed;
  z-index: 90;
  top: var(--topbar-height);
  bottom: 0;
  left: 0;
  width: min(82vw, 290px);
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 26px 18px;
  transform: translateX(-104%);
  transition: transform 180ms ease;
}

body.menu-open .sidebar {
  transform: translateX(0);
}

.backdrop {
  position: fixed;
  z-index: 80;
  inset: var(--topbar-height) 0 0;
  display: none;
  background: rgba(7, 15, 19, 0.52);
}

body.menu-open .backdrop {
  display: block;
}

.sidebar-title {
  margin: 0 10px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sidebar nav {
  display: grid;
  gap: 3px;
}

.sidebar nav a {
  min-height: 42px;
  padding: 8px 10px;
  border-left: 2px solid transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.sidebar-help {
  display: grid;
  gap: 5px;
  margin-top: 28px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
}

.sidebar-help strong {
  margin-bottom: 4px;
  color: var(--text);
}

.content {
  width: min(100% - 32px, 940px);
  margin: 0 auto;
  padding: 42px 0 72px;
}

.hero {
  padding: 20px 0 52px;
  border-bottom: 1px solid var(--line);
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.hero h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(36px, 9vw, 62px);
  line-height: 1.12;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 710px;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.progress-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 38px 0 0;
  padding: 1px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  list-style: none;
  overflow: hidden;
}

.progress-list li {
  display: grid;
  gap: 3px;
  min-height: 86px;
  align-content: center;
  padding: 15px;
  background: var(--surface);
}

.progress-list li:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.progress-list span {
  color: var(--accent);
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
}

.progress-list strong {
  font-size: 14px;
}

.notice {
  display: grid;
  gap: 8px;
  margin-top: 26px;
  padding: 18px;
  border: 1px solid;
  border-radius: 8px;
}

.notice p {
  margin: 0;
}

.notice-label {
  font-size: 13px;
  font-weight: 800;
}

.notice.info {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  background: var(--accent-soft);
}

.notice.warning {
  border-color: color-mix(in srgb, var(--amber) 35%, var(--line));
  background: var(--amber-soft);
}

.notice.danger {
  border-color: color-mix(in srgb, var(--red) 35%, var(--line));
  background: var(--red-soft);
}

.doc-section {
  padding: 56px 0;
  border-bottom: 1px solid var(--line);
}

.doc-section > p {
  max-width: 780px;
  color: var(--muted);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 20px;
}

.section-heading.simple {
  gap: 0;
}

.step-number {
  display: grid;
  flex: 0 0 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 7px;
  color: var(--accent-strong);
  font-size: 18px;
  font-weight: 850;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(26px, 7vw, 38px);
  line-height: 1.25;
}

.section-kicker {
  margin-bottom: 3px;
}

.check-list {
  display: grid;
  gap: 10px;
  margin: 24px 0;
}

.check-list div {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.check-list span,
.numbered-steps > article > span {
  display: grid;
  flex: 0 0 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.screenshot {
  margin: 24px 0 0;
}

.screenshot button {
  display: block;
  width: 100%;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: zoom-in;
}

.screenshot img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 5px;
}

.screenshot figcaption {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.choice-grid,
.client-grid,
.result-grid,
.rule-grid {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.choice-card,
.client-grid article,
.result-grid article,
.rule-grid article {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.choice-card h3,
.client-grid h3,
.numbered-steps h3 {
  margin: 8px 0 5px;
  font-size: 18px;
}

.choice-card p,
.client-grid p,
.result-grid p,
.rule-grid p,
.numbered-steps p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.choice-card strong {
  display: block;
  margin-top: 14px;
  color: var(--text);
  font-size: 13px;
}

.choice-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.choice-tag.green {
  background: var(--green-soft);
  color: var(--green);
}

.choice-tag.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.two-column {
  display: grid;
  gap: 22px;
  margin-top: 26px;
}

.instruction-panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.instruction-panel h3 {
  margin-top: 0;
}

.decision-list {
  margin: 0;
}

.decision-list > div {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.decision-list dt {
  font-weight: 800;
}

.decision-list dd {
  margin: 4px 0 0;
  color: var(--muted);
}

.mini-notice {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
}

.endpoint-table {
  margin-top: 26px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}

.endpoint-row {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid var(--line);
}

.endpoint-row:first-child {
  border-top: 0;
}

.endpoint-head {
  display: none;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.endpoint-name {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.app-dot.claude { background: #c15f3c; }
.app-dot.codex { background: #10846c; }
.app-dot.compatible { background: #2d6fb3; }

.copy-field {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.copy-field code {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
}

.copy-field button,
.code-toolbar button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 5px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.copy-field button:hover,
.code-toolbar button:hover {
  background: var(--accent-soft);
}

.status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 800;
}

.status.yes {
  background: var(--green-soft);
  color: var(--green);
}

.status.no {
  background: var(--surface-soft);
  color: var(--muted);
}

.rule-grid article span {
  font-weight: 800;
}

.numbered-steps {
  display: grid;
  margin-top: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.numbered-steps.continuation {
  margin-top: 18px;
}

.numbered-steps article {
  display: flex;
  gap: 14px;
  padding: 18px;
  border-top: 1px solid var(--line);
}

.numbered-steps article:first-child {
  border-top: 0;
}

.numbered-steps h3 {
  margin-top: 0;
}

.image-pair {
  display: grid;
  gap: 18px;
  align-items: start;
}

.config-card {
  display: grid;
  margin-top: 24px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}

.config-card > div {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid var(--line);
}

.config-card > div:first-child {
  border-top: 0;
}

.config-card label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.field-guide {
  display: grid;
  margin-top: 24px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}

.field-guide > div {
  display: grid;
  gap: 7px;
  padding: 15px 16px;
  border-top: 1px solid var(--line);
}

.field-guide > div:first-child {
  border-top: 0;
}

.field-guide code {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.field-guide span {
  color: var(--muted);
}

.command-grid {
  display: grid;
  gap: 14px;
}

.source-note {
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
}

.compatibility-table {
  margin-top: 24px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
}

.compatibility-row {
  display: grid;
  gap: 8px;
  padding: 15px 16px;
  border-top: 1px solid var(--line);
}

.compatibility-row:first-child {
  border-top: 0;
}

.compatibility-row > span:last-child {
  color: var(--muted);
}

.compatibility-head {
  display: none;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.code-block {
  margin-top: 24px;
  overflow: hidden;
  border: 1px solid #27343b;
  border-radius: 8px;
  background: var(--code);
  color: var(--code-text);
}

.code-toolbar {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 16px;
  border-bottom: 1px solid #27343b;
  color: #9fb0b9;
  font-size: 12px;
}

.code-toolbar button {
  color: #74ccdf;
}

.code-block pre {
  margin: 0;
  overflow-x: auto;
  padding: 18px;
  font-size: 13px;
  line-height: 1.7;
}

.result-grid article strong {
  color: var(--red);
}

.faq-list {
  display: grid;
  gap: 10px;
}

.faq-list details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.faq-list summary {
  padding: 17px 18px;
  cursor: pointer;
  font-weight: 800;
}

.faq-list p {
  margin: 0;
  padding: 0 18px 18px;
  color: var(--muted);
}

.footer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 36px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.footer p {
  margin: 0;
}

.image-dialog {
  width: min(96vw, 1500px);
  max-height: 94vh;
  padding: 50px 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.image-dialog::backdrop {
  background: rgba(5, 10, 13, 0.84);
}

.image-dialog img {
  display: block;
  max-width: 100%;
  max-height: calc(94vh - 90px);
  margin: 0 auto;
}

.image-dialog p {
  margin: 10px 0 0;
  color: var(--muted);
  text-align: center;
}

.dialog-close {
  position: absolute;
  top: 6px;
  right: 10px;
  padding: 0 10px;
  font-weight: 800;
}

.toast {
  position: fixed;
  z-index: 200;
  right: 16px;
  bottom: 18px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 600px) {
  .text-button {
    display: inline-flex;
    align-items: center;
  }

  .progress-list {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .progress-list li:last-child:nth-child(odd) {
    grid-column: auto;
  }

  .choice-grid,
  .rule-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .client-grid,
  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .endpoint-row {
    grid-template-columns: minmax(120px, 0.6fr) minmax(300px, 1.8fr) minmax(110px, 0.5fr);
    align-items: center;
  }

  .endpoint-head {
    display: grid;
  }

  .image-pair {
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.86fr);
  }

  .config-card > div {
    grid-template-columns: 145px minmax(0, 1fr);
    align-items: center;
  }

  .field-guide > div {
    grid-template-columns: 165px minmax(0, 1fr);
    align-items: center;
  }

  .command-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .compatibility-row {
    grid-template-columns: minmax(180px, 0.8fr) minmax(150px, 0.55fr) minmax(240px, 1.2fr);
    align-items: center;
  }

  .compatibility-head {
    display: grid;
  }

  .footer {
    flex-direction: row;
    justify-content: space-between;
  }
}

@media (min-width: 900px) {
  .topbar-inner {
    padding: 0 28px;
  }

  .menu-button {
    display: none;
  }

  .page-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    z-index: 1;
    top: var(--topbar-height);
    width: 260px;
    height: calc(100vh - var(--topbar-height));
    transform: none;
  }

  .content {
    width: min(100% - 72px, 940px);
    margin-left: clamp(36px, 7vw, 110px);
    padding-top: 62px;
  }

  .hero {
    padding-top: 28px;
  }

  .two-column {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.8fr);
    align-items: start;
  }

  .compact-shot {
    margin-top: 0;
  }
}

@media (min-width: 1280px) {
  .page-shell {
    grid-template-columns: 290px minmax(0, 1fr);
  }

  .sidebar {
    width: 290px;
    padding-left: 34px;
  }
}

@media print {
  .topbar,
  .sidebar,
  .backdrop,
  .hero-actions,
  .copy-field button,
  .code-toolbar button,
  .toast {
    display: none !important;
  }

  .page-shell {
    display: block;
    padding: 0;
  }

  .content {
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .doc-section {
    break-inside: avoid;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
