:root {
  --claude: #D97757;
  --claude-light: #fdf2ed;
  --claude-border: rgba(217, 119, 87, 0.35);
  --codex: #10A37F;
  --codex-light: #e8f5f1;
  --codex-border: rgba(16, 163, 127, 0.35);
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #ffffff;
  --bg-subtle: #f9fafb;
  --code-bg: #1e2228;
  --code-text: #e6edf3;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.05);
  --radius: 10px;
  --radius-lg: 14px;
  --max-width: 1100px;
  --accent: var(--claude);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg-subtle);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei",
    "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

h1, h2, h3, h4, p { margin: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Topbar ────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

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

.topbar-links a {
  padding: 6px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  transition: background 150ms, color 150ms;
}

.topbar-links a:hover {
  background: var(--bg-subtle);
  color: var(--text);
  text-decoration: none;
}

.topbar-links a.active {
  background: var(--bg-subtle);
  color: var(--text);
  font-weight: 600;
}

/* ── Page wrapper ──────────────────────────────────────────── */

.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ── Product tabs ──────────────────────────────────────────── */

.product-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.product-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 150ms, color 150ms, background 150ms;
}

.product-tab:hover {
  border-color: #c9d1d9;
  color: var(--text);
}

.product-tab .tab-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.product-tab[data-product="claude"].active {
  border-color: var(--claude);
  color: var(--claude);
  background: var(--claude-light);
}

.product-tab[data-product="claude"].active .tab-icon path {
  fill: var(--claude);
}

.product-tab[data-product="codex"].active {
  border-color: var(--codex);
  color: var(--codex);
  background: var(--codex-light);
}

.product-tab[data-product="codex"].active .tab-icon path {
  fill: var(--codex);
}

/* ── Guide card ────────────────────────────────────────────── */

.guide-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.guide-card-head {
  padding: 28px 32px 24px;
  border-bottom: 1px solid var(--border);
}

.guide-card-title {
  font-size: 1.45rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.guide-card-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ── Selector row ──────────────────────────────────────────── */

.selector-row {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
  flex-wrap: wrap;
}

.selector-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.selector-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

.segmented {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.segmented button {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms, color 150ms;
  white-space: nowrap;
}

.segmented button:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.segmented button.active {
  background: var(--bg);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  font-weight: 600;
}

/* Product-specific active colors for segmented */
.theme-claude .segmented button.active {
  color: var(--claude);
}

.theme-codex .segmented button.active {
  color: var(--codex);
}

/* ── Content layout ────────────────────────────────────────── */

.content-grid {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.summary-panel {
  padding: 24px;
  border-right: 1px solid var(--border);
  background: var(--bg-subtle);
}

.summary-panel-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 12px;
}

.summary-panel h3 {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 10px;
}

.summary-panel p {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 14px;
}

.tag-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tag-list li {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
  width: fit-content;
}

.note-box {
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff8f0;
  border: 1px solid #f3d5b8;
  font-size: 0.85rem;
  color: #7a4a22;
  line-height: 1.6;
}

.theme-codex .note-box {
  background: #f0faf7;
  border-color: #b2dfd5;
  color: #1a5c47;
}

/* ── Guide content ─────────────────────────────────────────── */

.guide-content {
  padding: 28px 32px;
  display: grid;
  gap: 32px;
}

.guide-block h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Requirements ──────────────────────────────────────────── */

.check-list {
  display: grid;
  gap: 8px;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.5;
}

.check-item::before {
  content: "·";
  color: var(--muted);
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Steps ─────────────────────────────────────────────────── */

.steps {
  display: grid;
  gap: 12px;
}

.step-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 16px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
}

.step-index {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.theme-claude .step-index {
  background: var(--claude);
}

.theme-codex .step-index {
  background: var(--codex);
}

.step-content h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.step-copy {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 0;
}

/* ── Code blocks ───────────────────────────────────────────── */

pre, code {
  font-family: "SF Mono", "Fira Code", Consolas, "Liberation Mono", monospace;
}

.code-wrap {
  position: relative;
  margin-top: 12px;
  border-radius: var(--radius);
  background: var(--code-bg);
  overflow: hidden;
}

.code-wrap pre {
  margin: 0;
  padding: 16px 48px 16px 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--code-text);
}

.copy-inline {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 150ms;
}

.copy-inline:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.links-wrap {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.links-wrap a {
  font-size: 0.88rem;
  word-break: break-all;
}

/* ── Config items ──────────────────────────────────────────── */

.config-list, .extra-list {
  display: grid;
  gap: 10px;
}

.config-item {
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
}

.config-item strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.config-item p {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0;
  font-family: "SF Mono", Consolas, monospace;
}

.config-item pre {
  margin-top: 12px;
  padding: 14px;
  border-radius: 8px;
  background: var(--code-bg);
  color: var(--code-text);
  font-size: 0.82rem;
  line-height: 1.65;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.extra-item {
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
}

/* ── Copy all button ───────────────────────────────────────── */

.button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 150ms, border-color 150ms;
}

.button:hover {
  background: var(--bg-subtle);
  border-color: #c9d1d9;
  text-decoration: none;
}

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

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

/* ── FAQ ───────────────────────────────────────────────────── */

.faq-section {
  margin-top: 48px;
}

.section-head {
  margin-bottom: 20px;
}

.section-head h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.faq-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.faq-grid article {
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
}

.faq-grid article h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.faq-grid article p {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.65;
}

/* ── Token query page ──────────────────────────────────────── */

.query-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 32px;
}

.query-card-title {
  font-size: 1.45rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.query-card-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.query-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.query-field {
  display: grid;
  gap: 8px;
}

.query-field label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.query-field input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  transition: border-color 150ms, box-shadow 150ms;
}

.query-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 119, 87, 0.1);
}

.query-submit {
  justify-self: start;
}

.query-helper {
  margin-top: 10px;
  font-size: 0.83rem;
  color: var(--muted);
}

.query-result {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.query-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
}

.query-empty p {
  font-size: 0.88rem;
  margin-top: 6px;
  line-height: 1.6;
}

.query-error {
  padding: 14px 16px;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.query-error strong {
  display: block;
  font-size: 0.9rem;
  color: #991b1b;
  margin-bottom: 4px;
}

.query-error p {
  font-size: 0.85rem;
  color: #b91c1c;
}

.query-loading {
  padding: 16px 0;
}

.query-loading p {
  font-size: 0.88rem;
  color: var(--muted);
  margin-top: 14px;
}

.skeleton-row,
.skeleton-grid span {
  display: block;
  border-radius: 6px;
  background: linear-gradient(90deg, #f0f0f0, #e8e8e8, #f0f0f0);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

.skeleton-row {
  width: 42%;
  height: 16px;
  margin-bottom: 14px;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.skeleton-grid span {
  height: 72px;
  border-radius: 8px;
}

.result-overview {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-card {
  padding: 16px 20px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
}

.metric-card span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 8px;
  white-space: nowrap;
}

.metric-card strong {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
}

.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--muted);
}

.result-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  font-size: 0.88rem;
}

.result-table th,
.result-table td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.result-table th {
  background: var(--bg-subtle);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.result-table td {
  color: var(--text);
}

.result-table tbody tr:last-child td {
  border-bottom: 0;
}

/* ── Misc ──────────────────────────────────────────────────── */

.hidden { display: none !important; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Responsive ────────────────────────────────────────────── */

@media (max-width: 900px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
  .summary-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .faq-grid {
    grid-template-columns: 1fr;
  }
  .result-overview {
    grid-template-columns: repeat(3, 1fr);
  }
  .skeleton-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .page {
    padding: 20px 16px 60px;
  }
  .topbar-inner {
    padding: 0 16px;
  }
  .guide-card-head,
  .selector-row,
  .guide-content {
    padding-left: 18px;
    padding-right: 18px;
  }
  .step-card {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .product-tab {
    padding: 8px 14px;
    font-size: 0.875rem;
  }
  .product-tab .tab-icon {
    width: 16px;
    height: 16px;
  }
  .result-overview, .skeleton-grid {
    grid-template-columns: 1fr;
  }
  .selector-row {
    gap: 14px;
  }
  .query-card {
    padding: 20px 18px;
  }
}
