/* ===== YMZ API - 描线简约风格 ===== */
/* 主题变量：浅色为默认，深色跟随系统，也可由右上角按钮手动锁定 */
:root {
  color-scheme: light;

  --bg: #fafafa;
  --bg-card: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #666666;
  --text-muted: #999999;
  --border: #1a1a1a;
  --border-light: #e0e0e0;
  --accent: #1a1a1a;
  --accent-hover: #333333;
  --success: #16a34a;
  --error: #dc2626;
  --warning: #d97706;

  /* 派生色（原先散落在各页面里的硬编码值统一收口到这里） */
  --on-accent: #ffffff;          /* 主色块上的文字 */
  --overlay: rgba(0, 0, 0, 0.4); /* 弹窗遮罩 */
  --focus-ring: rgba(26, 26, 26, 0.08);
  --tint-success: #f0fdf4;
  --terminal-bg: #1a1a1a;        /* 在线调试输出区，两个主题下都保持终端观感 */
  --terminal-fg: #22dd66;
  --terminal-error: #ff6b6b;

  --radius: 2px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Consolas", monospace;
}

/* 跟随系统深色 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #121316;
    --bg-card: #191a1e;
    --text: #ededed;
    --text-secondary: #a2a6ad;
    --text-muted: #71757c;
    --border: #43474e;
    --border-light: #2a2d33;
    --accent: #f0f0f0;
    --accent-hover: #d4d4d4;
    --success: #2fbf63;
    --error: #f0726f;
    --warning: #e0a03a;

    --on-accent: #121316;
    --overlay: rgba(0, 0, 0, 0.65);
    --focus-ring: rgba(255, 255, 255, 0.16);
    --tint-success: rgba(47, 191, 99, 0.12);
    --terminal-bg: #0b0c0e;
    --terminal-fg: #3ee07a;
    --terminal-error: #ff8a8a;
  }
}

/* 手动锁定深色（覆盖系统设置） */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #121316;
  --bg-card: #191a1e;
  --text: #ededed;
  --text-secondary: #a2a6ad;
  --text-muted: #71757c;
  --border: #43474e;
  --border-light: #2a2d33;
  --accent: #f0f0f0;
  --accent-hover: #d4d4d4;
  --success: #2fbf63;
  --error: #f0726f;
  --warning: #e0a03a;

  --on-accent: #121316;
  --overlay: rgba(0, 0, 0, 0.65);
  --focus-ring: rgba(255, 255, 255, 0.16);
  --tint-success: rgba(47, 191, 99, 0.12);
  --terminal-bg: #0b0c0e;
  --terminal-fg: #3ee07a;
  --terminal-error: #ff8a8a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.25s ease;
}

a { color: var(--text); text-decoration: none; transition: opacity 0.2s; }
a:hover { opacity: 0.6; }

/* ===== 导航栏 ===== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.navbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.navbar-brand {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  white-space: nowrap;
}
.navbar-brand .logo-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
}
.navbar-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 24px;
  font-size: 14px;
  flex-wrap: nowrap;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.navbar-links::-webkit-scrollbar { display: none; }
.navbar-links a {
  color: var(--text-secondary);
  position: relative;
  white-space: nowrap;
  flex: 0 0 auto;
}
.navbar-links a:hover,
.navbar-links a.active {
  color: var(--text);
}
.navbar-links a.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

/* ===== 主容器 ===== */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 24px;
}
.container-narrow {
  max-width: 480px;
  margin: 0 auto;
  padding: 64px 24px;
}

/* ===== 卡片（描线风格） ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 24px;
}
.card-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}
.card-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}
.card-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ===== 表单 ===== */
.form-group {
  margin-bottom: 20px;
}
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}
.form-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus-ring);
}
.form-input::placeholder { color: var(--text-muted); }
.form-textarea {
  resize: vertical;
  min-height: 100px;
  font-family: var(--font);
}
.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}
.form-error {
  font-size: 12px;
  color: var(--error);
  margin-top: 6px;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  line-height: 1.4;
}
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  opacity: 1;
}
.btn-outline {
  background: transparent;
  color: var(--text);
}
.btn-outline:hover {
  background: var(--text);
  color: var(--on-accent);
  opacity: 1;
}
.btn-danger {
  background: var(--error);
  color: var(--on-accent);
  border-color: var(--error);
}
.btn-danger:hover { opacity: 0.85; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 提示消息 ===== */
.alert {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { border-color: var(--success); color: var(--success); }
.alert-error { border-color: var(--error); color: var(--error); }
.alert-warning { border-color: var(--warning); color: var(--warning); }

/* ===== Hero 区域 ===== */
.hero {
  text-align: center;
  padding: 80px 24px 64px;
}
.hero-title {
  font-size: 42px;
  font-weight: 800;
  letter-spacing: -1.5px;
  margin-bottom: 16px;
  line-height: 1.2;
}
.hero-title .underline {
  position: relative;
  display: inline-block;
}
.hero-title .underline::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  z-index: -1;
}
.hero-desc {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto 32px;
}
.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ===== 特性网格 ===== */
.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin: 48px 0;
}
.feature {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  background: var(--bg-card);
  transition: transform 0.2s;
}
.feature:hover { transform: translateY(-2px); }
.feature-icon {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 16px;
}
.feature-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}
.feature-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ===== API Key 展示 ===== */
.apikey-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 13px;
  word-break: break-all;
}
.apikey-box .key-text {
  flex: 1;
  color: var(--text);
  user-select: all;
}
.apikey-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ===== 统计卡片 ===== */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--bg-card);
}
.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
}

/* ===== 表格 ===== */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}
th {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  background: var(--bg);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ===== 标签 ===== */
.badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-success { color: var(--success); border-color: var(--success); }
.badge-warning { color: var(--warning); border-color: var(--warning); }
.badge-error { color: var(--error); border-color: var(--error); }
.badge-muted { color: var(--text-muted); border-color: var(--border-light); }

/* ===== 页脚 ===== */
.footer {
  border-top: 1px solid var(--border);
  padding: 32px 24px;
  margin-top: 64px;
}
.footer-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
}
.footer-links {
  display: flex;
  gap: 20px;
}

/* ===== 代码块 ===== */
code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
}
pre {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  line-height: 1.6;
}

/* ===== 分页 ===== */
.pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 24px;
}
.pagination a, .pagination span {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  text-decoration: none;
}
.pagination .current {
  background: var(--accent);
  color: var(--on-accent);
}

/* ===== 请求方式标签 ===== */
.method-badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  white-space: nowrap;
}
.m-get   { color: var(--success); border-color: var(--success); }
.m-post  { color: var(--warning); border-color: var(--warning); }
.m-mixed { color: var(--text);    border-color: var(--border); }

/* ===== API 卡片列表 ===== */
.api-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.api-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  padding: 16px 18px;
  transition: transform 0.2s;
}
.api-card:hover { transform: translateY(-2px); }
.api-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.api-card-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  word-break: break-word;
}
.api-card-url {
  display: block;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 6px 10px;
  margin-bottom: 12px;
  word-break: break-all;
}
.api-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-secondary);
}
.api-card-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.api-card-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.api-card-actions { display: flex; gap: 6px; flex-shrink: 0; }
.api-card.is-disabled { opacity: 0.55; }
.api-grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius);
  background: var(--bg-card);
  font-size: 14px;
}

/* ===== 接口参数展示表 ===== */
.param-view-table { font-size: 13px; }
.param-view-table code { font-size: 12px; }
.cell-empty { color: var(--text-muted); }

/* ===== 主题切换按钮（由 app.js 自动插入导航栏） ===== */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  font-family: var(--font);
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, transform 0.2s;
}
.theme-toggle:hover { background: var(--text); color: var(--on-accent); transform: rotate(-15deg); }
.theme-toggle:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--focus-ring); }

/* ===== 错误页 ===== */
.error-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.error-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px 24px;
}
.error-code {
  font-size: 96px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -4px;
  color: var(--text);
}
.error-code .slash { color: var(--text-muted); }
.error-title {
  font-size: 20px;
  font-weight: 700;
  margin: 20px 0 8px;
}
.error-desc {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 420px;
  margin-bottom: 32px;
}
.error-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.error-hint {
  margin-top: 28px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}
.error-page .footer { margin-top: 0; }
@media (max-width: 768px) {
  .error-code { font-size: 64px; letter-spacing: -2px; }
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .hero-title { font-size: 32px; }
  .features { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .card { padding: 20px; }
  .container { padding: 32px 16px; }
  .footer-inner { flex-direction: column; gap: 12px; text-align: center; }
  /* 平板/手机横屏：收紧间距，保持单行 */
  .navbar-inner { padding: 0 18px; gap: 14px; }
  .navbar-links { gap: 15px; font-size: 13px; }
}

/* ===== 动画 ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.4s ease-out; }

/* 复制按钮小动画 */
.copied {
  background: var(--success) !important;
  border-color: var(--success) !important;
  color: var(--on-accent) !important;
}

/* 窄屏手机：继续压缩字号与间距，把品牌、5 个链接、主题按钮全塞进一行，
   而不是让导航栏折成两行（导航高度始终固定 56px） */
@media (max-width: 430px) {
  .navbar-inner { height: 56px; padding: 0 12px; gap: 10px; }
  .navbar-brand { font-size: 16.5px; letter-spacing: -0.6px; gap: 6px; }
  .navbar-links { gap: 11px; font-size: 12.5px; }
  .theme-toggle { width: 27px; height: 27px; font-size: 14px; }
}

/* 极窄屏：把「首页」收起——左上角品牌本身就指向首页，不损失入口 */
@media (max-width: 360px) {
  .navbar-links { gap: 9px; font-size: 12px; }
  .navbar-links a[href="/"] { display: none; }
}
