/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 260px;
  --bg: #ffffff;
  --bg-alt: #f8f9fa;
  --bg-code: #f5f6f8;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-muted: #86868b;
  --border: #e5e5e7;
  --accent: #0071e3;
  --accent-light: #e8f4fd;
  --tag-get: #34c759;
  --tag-get-bg: #e8f8ee;
  --tag-post: #ff9500;
  --tag-post-bg: #fff5e6;
  --tag-limited: #ff3b30;
  --tag-limited-bg: #ffebeb;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 14px rgba(0,0,0,0.08);
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Consolas", "Monaco", "Menlo", monospace;
  --transition: 0.2s ease;
}

html { scroll-behavior: smooth; font-size: 15px; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo {
  width: 32px; height: 32px;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.sidebar-section {
  padding: 8px 0;
}

.sidebar-section-title {
  padding: 6px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px 7px 24px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  cursor: pointer;
}

.sidebar-link:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.sidebar-link.active {
  color: var(--accent);
  background: var(--accent-light);
  font-weight: 500;
}

.sidebar-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
}

.sidebar-section .sidebar-link[data-limited="true"]::after {
  content: "限时";
  font-size: 10px;
  color: var(--tag-limited);
  background: var(--tag-limited-bg);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  margin-left: auto;
  font-weight: 500;
}

/* ===== Overlay (mobile) ===== */
.overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.3);
  z-index: 99;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}

.overlay.show { opacity: 1; visibility: visible; }

/* ===== Main ===== */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin var(--transition);
}

.topbar {
  position: sticky;
  top: 0;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 50;
}

.menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 4px;
}

.menu-btn svg { width: 20px; height: 20px; }

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.topbar-link {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  margin-left: auto;
  font-weight: 500;
}

.topbar-link:hover { text-decoration: underline; }

.content {
  max-width: 820px;
  padding: 32px 24px 60px;
  margin: 0 auto;
}

/* ===== Page Sections ===== */
.page { animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}

.page-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 32px;
  line-height: 1.5;
}

.section {
  margin-bottom: 32px;
}

.section-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ===== Home Hero ===== */
.hero-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 32px;
}

.hero-card-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.hero-card-desc {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 16px;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.hero-stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  text-align: center;
}

.hero-stat-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

.hero-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ===== Feature Cards ===== */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.feature-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: box-shadow var(--transition);
}

.feature-card:hover { box-shadow: var(--shadow-lg); }

.feature-card-icon {
  width: 36px; height: 36px;
  margin-bottom: 12px;
  color: var(--accent);
}

.feature-card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.feature-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.feature-card-method {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

/* ===== Method Tags ===== */
.method-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
}

.method-tag.get { color: var(--tag-get); background: var(--tag-get-bg); }
.method-tag.post { color: var(--tag-post); background: var(--tag-post-bg); }

.limited-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--tag-limited);
  background: var(--tag-limited-bg);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  margin-left: 8px;
}

.limited-badge svg { width: 12px; height: 12px; }

/* ===== Endpoint Header ===== */
.endpoint-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.endpoint-url {
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
}

/* ===== Tables ===== */
.table-wrapper {
  overflow-x: auto;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead { background: var(--bg-alt); }

th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}

tr:last-child td { border-bottom: none; }

td.required {
  color: var(--tag-limited);
  font-weight: 600;
}

td.optional {
  color: var(--text-muted);
}

td.type {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 12px;
}

/* ===== Code Blocks ===== */
.code-block {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  overflow-x: auto;
  margin-bottom: 20px;
  position: relative;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.code-block-lang {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.code-copy {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 11px;
  color: var(--text-muted);
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.code-copy:hover { color: var(--text); border-color: var(--text-muted); }
.code-copy.copied { color: var(--tag-get); border-color: var(--tag-get); }

pre {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre;
  margin: 0;
}

/* JSON syntax highlighting */
.json-key { color: #a855f7; }
.json-string { color: #22c55e; }
.json-number { color: #3b82f6; }
.json-bool { color: #f59e0b; }
.json-null { color: var(--text-muted); }
.json-brace { color: var(--text-secondary); }
.url-key { color: #a855f7; }
.url-val { color: #22c55e; }
.url-base { color: var(--text-muted); }
.url-path { color: var(--accent); }

/* ===== Note/Warning Cards ===== */
.note-card {
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.5;
}

.note-card.info {
  background: var(--accent-light);
  border: 1px solid #b3d9f2;
  color: #1a5276;
}

.note-card.warning {
  background: var(--tag-limited-bg);
  border: 1px solid #f2b8b8;
  color: #7a1a1a;
}

.note-card.tip {
  background: var(--tag-get-bg);
  border: 1px solid #b8e6c8;
  color: #1a6b3a;
}

.note-card-title {
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.note-card-title svg { width: 16px; height: 16px; }

/* ===== Sub-struct ===== */
.sub-struct {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.sub-struct-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sub-struct-title svg { width: 14px; height: 14px; color: var(--accent); }

/* ===== Platform & Type Reference ===== */
.ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.ref-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.ref-card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

.ref-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}

.ref-item-code {
  font-family: var(--font-mono);
  color: var(--accent);
  font-weight: 500;
}

.ref-item-desc { color: var(--text-secondary); }

/* ===== About Section ===== */
.about-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.about-link-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  transition: box-shadow var(--transition);
}

.about-link-card:hover { box-shadow: var(--shadow-lg); }

.about-link-card svg {
  width: 24px; height: 24px;
  color: var(--accent);
  flex-shrink: 0;
}

.about-link-card-title { font-weight: 600; font-size: 14px; }
.about-link-card-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.qrcode-section {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 20px;
}

.qrcode-img {
  width: 160px; height: 160px;
  border-radius: var(--radius);
  flex-shrink: 0;
}

.qrcode-info-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.qrcode-info-desc { font-size: 13px; color: var(--text-secondary); }

/* ===== Error Table ===== */
.error-table td:first-child {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
  width: 60px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  :root { --sidebar-w: 240px; }

  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
  }

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

  .main { margin-left: 0; }

  .menu-btn { display: block; }

  .content { padding: 20px 16px 48px; }

  .page-title { font-size: 22px; }

  .hero-card { padding: 20px; }
  .hero-card-title { font-size: 20px; }

  .hero-stats { grid-template-columns: repeat(2, 1fr); }

  .feature-grid { grid-template-columns: 1fr; }

  .qrcode-section {
    flex-direction: column;
    text-align: center;
  }

  .about-links { grid-template-columns: 1fr; }

  .ref-grid { grid-template-columns: 1fr; }

  .endpoint-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  html { font-size: 14px; }
  .hero-stats { grid-template-columns: 1fr; }
}

/* ===== Scrollbar ===== */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ===== Print ===== */
@media print {
  .sidebar, .topbar, .overlay, .menu-btn { display: none !important; }
  .main { margin-left: 0 !important; }
  .content { max-width: 100%; padding: 0; }
  .feature-card, .hero-card, .ref-card, .note-card { break-inside: avoid; }
}

/* ===== URL Display ===== */
.url-display {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-family: var(--font-mono);
  font-size: 14px;
  word-break: break-all;
  line-height: 1.5;
}

/* ===== Tab Switcher ===== */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
}

.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Search Highlight ===== */
.param-name {
  font-family: var(--font-mono);
  color: var(--text);
  font-weight: 500;
}

/* ===== Description List ===== */
.desc-list dt {
  font-weight: 600;
  font-size: 14px;
  margin-top: 8px;
  color: var(--text);
}

.desc-list dd {
  font-size: 13px;
  color: var(--text-secondary);
  margin-left: 0;
  margin-bottom: 4px;
}