/* ===== 思弈云 OAuth 开放平台 全局样式 =====
 * 依据 Welao 设计规范（黑百极简 / Claude 风格）重构。
 * 纯灰阶，无彩色；强调色统一为近黑 #1a1a1a；暗色模式经 html.dark 切换。
 */

/* ---------- 设计令牌 · 明亮模式 ---------- */
:root {
  /* 色板 */
  --bg-body: #fafafa;
  --bg-card: #ffffff;
  --bg-sidebar: #f5f5f5;
  --bg-input: #f0f0f0;
  --text-primary: #1a1a1a;
  --text-secondary: #525252;
  --text-muted: #8a8a8a;
  --border-color: #e6e6e6;
  --border-strong: #d6d6d6;

  /* 品牌（渐变已退化为单色黑） */
  --brand-1: #1a1a1a;
  --brand-2: #1a1a1a;
  --brand-3: #1a1a1a;
  --brand-grad: #1a1a1a;
  --brand-grad-soft: rgba(0,0,0,.04);
  --accent-color: #1a1a1a;
  --accent-hover: #000000;
  --accent-soft: rgba(0,0,0,.05);
  --bg-soft: var(--bg-body);

  /* 语义（强制黑白，不用红绿） */
  --ok: #1a1a1a;
  --warn: #525252;
  --danger: #1a1a1a;

  /* 别名（兼容早期引用） */
  --line: var(--border-color);
  --ink: var(--text-primary);
  --ink-2: var(--text-secondary);
  --muted: var(--text-muted);
  --brand: var(--accent-color);
  --brand-2: var(--brand-1);

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.03);
  --shadow-md: 0 4px 16px rgba(0,0,0,.06), 0 12px 32px rgba(0,0,0,.05);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.10), 0 24px 60px rgba(0,0,0,.08);
  --shadow-brand: 0 1px 3px rgba(0,0,0,.16), 0 4px 12px rgba(0,0,0,.08);
  --shadow: var(--shadow-md);

  /* 圆角 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --radius: var(--radius-md);

  /* 过渡 */
  --transition: .28s cubic-bezier(.32,.72,0,1);
  --ease-out-expo: cubic-bezier(.16,1,.3,1);

  /* 字体 */
  --font-sans: 'Styrene B','Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',
               'PingFang SC','Noto Sans SC','Hiragino Sans GB','Microsoft YaHei',sans-serif;
  --font-serif: 'Tiempos Text','Source Serif 4','Source Serif Pro',Georgia,
               'Times New Roman','Songti SC','Noto Serif SC','STSong',SimSun,serif;
}

/* ---------- 设计令牌 · 暗色模式 ---------- */
html.dark {
  --bg-body: #0a0a0a;
  --bg-card: #161616;
  --bg-sidebar: #101010;
  --bg-input: #1f1f1f;
  --text-primary: #f2f2f2;
  --text-secondary: #a6a6a6;
  --text-muted: #6f6f6f;
  --border-color: #262626;
  --border-strong: #3a3a3a;
  --brand-grad: #1a1a1a;
  --brand-grad-soft: rgba(255,255,255,.04);
  --accent-color: #f2f2f2;
  --accent-hover: #ffffff;
  --accent-soft: rgba(255,255,255,.07);
  --bg-soft: var(--bg-body);
  --ok: #f2f2f2;
  --warn: #a6a6a6;
  --danger: #f2f2f2;
  --line: var(--border-color);
  --ink: var(--text-primary);
  --ink-2: var(--text-secondary);
  --muted: var(--text-muted);
  --brand: var(--accent-color);
  --brand-2: var(--accent-color);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.55), 0 2px 8px rgba(0,0,0,.5);
  --shadow-md: 0 4px 16px rgba(0,0,0,.5), 0 12px 32px rgba(0,0,0,.45);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.55), 0 24px 60px rgba(0,0,0,.5);
  --shadow-brand: 0 1px 3px rgba(0,0,0,.55), 0 4px 12px rgba(0,0,0,.5);
  --shadow: var(--shadow-md);
}
html.dark .logo-mark,
html.dark .topbar .brand .logo-mark,
html.dark .avatar { background: var(--text-primary); color: var(--bg-card); }

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg-body);
  color: var(--text-primary);
  font-size: 14.5px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}
a { color: var(--accent-color); text-decoration: none; transition: color var(--transition); }
a:hover { text-decoration: underline; }
code, pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}
::selection { background: rgba(0,0,0,.12); }
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 登录页 ---------- */
.auth-body {
  min-height: 100vh;
  display: grid!important;
  place-items: center;
  background: var(--bg-body);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 36px 34px;
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.logo-mark {
  width: 58px; height: 58px; margin: 0 auto 14px;
  border-radius: var(--radius-md);
  display: grid; place-items: center;
  font-size: 26px; color: var(--bg-card); font-weight: 800;
  background: var(--brand-grad);
  box-shadow: var(--shadow-brand);
}
.auth-brand h1 { font-size: 20px; margin: 0 0 6px; font-weight: 600; }
.auth-brand p { font-size: 13px; color: var(--text-muted); margin: 0; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }
.field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=url], .field textarea, .field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 14px;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}
.field .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 42px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: none; background: none; cursor: pointer; font-size: 16px; padding: 6px;
  color: var(--text-muted);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border: 1px solid var(--border-strong); border-radius: 10px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  background: var(--bg-card); color: var(--text-primary);
  transition: all var(--transition);
}
.btn:hover { background: var(--accent-soft); border-color: var(--border-strong); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary {
  background: var(--brand-grad); color: var(--bg-card);
  border-color: var(--brand-grad); box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: scale(.98); }
.btn-danger { background: var(--brand-grad); color: var(--bg-card); border-color: var(--brand-grad); }
.btn-danger:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-warn { background: var(--bg-card); color: var(--text-primary); border-color: var(--border-strong); }
.btn-warn:hover { background: var(--accent-soft); }
.btn-ghost { background: transparent; border-color: var(--border-color); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 6px; }
.spinner {
  width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
.spinner.on-dark { border-color: rgba(0,0,0,.2); border-top-color: var(--text-primary); }
@keyframes spin { to { transform: rotate(360deg); } }
.login-hint { margin-top: 18px; font-size: 12px; color: var(--text-muted); text-align: center; }
.login-hint code { background: var(--brand-grad-soft); color: var(--text-primary); padding: 1px 5px; border-radius: 5px; }
.login-err { margin-top: 16px; padding: 10px 14px; font-size: 13px; color: var(--text-primary); background: var(--accent-soft); border: 1px solid var(--border-strong); border-radius: 10px; text-align: left; }
.muted { opacity: .75; }

/* ---------- 顶部导航 ---------- */
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; gap: 18px;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; color: var(--text-primary); }
.topbar .brand .logo-mark { width: 34px; height: 34px; font-size: 16px; border-radius: var(--radius-sm); margin: 0; }
.topbar nav { display: flex; gap: 4px; margin-left: 12px; flex: 1; }
.topbar nav a { padding: 7px 12px; border-radius: 8px; color: var(--text-secondary); font-weight: 500; font-size: 14px; }
.topbar nav a:hover { background: rgba(0,0,0,.045); text-decoration: none; color: var(--text-primary); }
html.dark .topbar nav a:hover { background: rgba(255,255,255,.05); }
.topbar nav a.active { background: var(--accent-soft); color: var(--text-primary); font-weight: 600; }
.topbar .user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-secondary); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--text-primary); color: var(--bg-card);
  display: grid; place-items: center; font-weight: 600; font-size: 14px;
}
.theme-toggle {
  width: 34px; height: 34px; border-radius: 10px; border: none; background: transparent;
  color: var(--text-muted); font-size: 15px; cursor: pointer; transition: all var(--transition);
}
.theme-toggle:hover { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border-color); }
.topbar .user .avatar { width: 26px; height: 26px; font-size: 12px; }
.topbar .user .nav-userlink { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-weight: 500; }
.topbar .user .nav-userlink:hover { color: var(--text-primary); text-decoration: none; }
.topbar .user .nav-userlink.active { color: var(--text-primary); }
.topbar .user .nav-out { color: var(--text-muted); font-size: 13px; }
.topbar .user .nav-out:hover { color: var(--text-primary); text-decoration: none; }

/* ---------- 页面容器 ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h2 { margin: 0 0 4px; font-size: 22px; font-weight: 650; }

/* ---------- 卡片 & 统计 ---------- */
.card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.stat .num { font-size: 24px; font-weight: 600; color: var(--text-primary); font-family: var(--font-sans); }
.stat .lbl { font-size: 12px; color: var(--text-muted); margin-top: 2px; font-weight: 500; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, 1fr); } }

/* ---------- 应用列表 ---------- */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.app-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 20px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow-sm); transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition); }
.app-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-strong); }
.app-card .app-top { display: flex; align-items: center; gap: 12px; }
.app-icon {
  width: 48px; height: 48px; border-radius: var(--radius-md); object-fit: cover;
  background: var(--bg-input); display: grid; place-items: center;
  font-size: 22px; color: var(--text-primary); font-weight: 600; flex-shrink: 0;
}
.app-card .t { font-weight: 600; font-size: 16px; }
.app-card .sub { font-size: 12.5px; color: var(--text-muted); }
.app-id { font-size: 12px; font-family: monospace; background: var(--bg-input); color: var(--text-secondary); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
.app-card .actions { display: flex; gap: 8px; margin-top: auto; }

/* ---------- 徽章（黑白，无彩色） ---------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-ok { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border-strong); }
.badge-off { background: var(--bg-input); color: var(--text-muted); border: 1px solid var(--border-color); }
.badge-warn { background: var(--accent-soft); color: var(--text-secondary); border: 1px solid var(--border-strong); }

/* ---------- 表格（§9 规范） ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border-color); font-size: 14px; }
.table th { color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--accent-soft); }

/* ---------- Alert（黑白） ---------- */
.alert { padding: 12px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; }
.alert-error { background: var(--accent-soft); color: var(--text-primary); border: 1px solid var(--border-strong); }
.alert-warn { background: var(--accent-soft); color: var(--text-secondary); border: 1px solid var(--border-color); }
.alert-ok { background: var(--accent-soft); color: var(--text-primary); border: 1px solid var(--border-strong); }
.alert-info { background: var(--accent-soft); color: var(--text-primary); border: 1px solid var(--border-color); }

/* ---------- Modal（§9 规范） ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); max-width: 520px; width: 100%;
  padding: 28px; box-shadow: var(--shadow-lg); max-height: 90vh; overflow: auto;
}
.modal h3 { margin: 0 0 16px; font-size: 18px; font-weight: 600; }
.modal .close { float: right; border: none; background: none; font-size: 22px; cursor: pointer; color: var(--text-muted); }
.modal .close:hover { color: var(--text-primary); }
.modal .modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- 密钥展示 ---------- */
.secret-box {
  position: relative; margin: 12px 0;
  background: var(--text-primary); color: var(--bg-card); font-family: monospace;
  padding: 14px; border-radius: 10px; font-size: 13.5px; word-break: break-all;
  border: 1px solid var(--border-strong);
}
.secret-copy { position: absolute; top: 8px; right: 8px; font-size: 12px; padding: 3px 8px; }
.only-once { font-size: 12px; color: var(--text-secondary); font-weight: 600; }

/* ---------- 图标上传 ---------- */
.icon-drop {
  border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 18px; text-align: center;
  color: var(--text-muted); cursor: pointer; font-size: 13px; transition: all var(--transition);
  background: var(--bg-body);
}
.icon-drop:hover { border-color: var(--text-primary); color: var(--text-primary); background: var(--bg-input); }
.icon-preview { width: 72px; height: 72px; border-radius: var(--radius-md); object-fit: cover; margin: 0 auto 8px; display: block; border: 1px solid var(--border-color); }

/* ---------- 授权页 ---------- */
.authz-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg-body); }
.authz-card { width: 100%; max-width: 460px; background: var(--bg-card); border-radius: var(--radius-lg); border: 1px solid var(--border-color); box-shadow: var(--shadow-sm); padding: 36px 34px; text-align: center; }
.authz-app-icon { width: 84px; height: 84px; border-radius: var(--radius-lg); object-fit: cover; margin: 0 auto 14px; display: block; background: var(--bg-input); }
.authz-app-name { font-size: 20px; font-weight: 650; margin: 0; }
.authz-host { display: inline-block; margin-top: 6px; font-size: 12.5px; color: var(--text-primary); background: var(--accent-soft); border: 1px solid var(--border-color); padding: 3px 10px; border-radius: 999px; }
.authz-desc { color: var(--text-muted); font-size: 14px; margin-top: 12px; }
.authz-scopes { text-align: left; background: var(--bg-body); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 14px 16px; margin-top: 20px; }
.authz-scopes h4 { margin: 0 0 8px; font-size: 12.5px; color: var(--text-secondary); }
.authz-scopes ul { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--text-secondary); }
.authz-as { margin-top: 16px; font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; justify-content: center; gap: 8px; }
.authz-as .avatar { width: 26px; height: 26px; font-size: 12px; }
.authz-actions { display: flex; gap: 12px; margin-top: 26px; }
.authz-actions .btn { flex: 1; padding: 12px; }

/* ---------- 授权记录列表（用户中心） ---------- */
.auth-log-list { display: flex; flex-direction: column; gap: 10px; max-height: 340px; overflow: auto; }
.auth-log-item { border: 1px solid var(--border-color); background: var(--bg-body); border-radius: var(--radius-md); padding: 11px 13px; }
.auth-log-main { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.auth-log-main b { font-size: 13.5px; }
.auth-log-sub { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 7px; font-size: 12px; color: var(--text-muted); }
.auth-log-sub span { white-space: nowrap; }

/* ---------- 文档页 ---------- */
.docs-layout { display: grid; grid-template-columns: 240px 1fr; gap: 28px; align-items: start; }
.docs-nav { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 2px; }
.docs-nav a { padding: 8px 12px; border-radius: 8px; color: var(--text-secondary); font-size: 14px; }
.docs-nav a:hover { background: rgba(0,0,0,.045); color: var(--text-primary); text-decoration: none; }
html.dark .docs-nav a:hover { background: rgba(255,255,255,.05); }
.docs-nav a.on { background: var(--accent-soft); color: var(--text-primary); font-weight: 600; }
.docs-nav .group { font-size: 11px; text-transform: uppercase; color: var(--text-muted); letter-spacing: .05em; margin: 14px 8px 4px; font-weight: 600; }
.docs-body .doc-section { scroll-margin-top: 90px; }
.docs-body h3 { font-size: 19px; margin: 0 0 8px; font-weight: 650; }
.docs-body h4 { font-size: 15px; margin: 22px 0 8px; color: var(--text-primary); font-weight: 600; }
.docs-body p, .docs-body li { color: var(--text-secondary); }
.endpoint { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border-color); border-radius: 10px; padding: 4px 12px; font-family: monospace; font-size: 12.5px; display: inline-flex; gap: 10px; align-items: center; margin: 10px 0; }
.endpoint .m { color: var(--text-primary); font-weight: 700; }
pre.code {
  background: #161616; color: #e6e6e6; border: 1px solid #262626;
  padding: 16px; border-radius: 10px; overflow: auto; font-size: 12.8px; line-height: 1.55;
}
pre.code .cm { color: #6f6f6f; }
pre.code .c-key { color: #d6d6d6; }
table.api-table { width: 100%; border-collapse: collapse; margin: 10px 0; }
table.api-table th, table.api-table td { border: 1px solid var(--border-color); padding: 9px 11px; font-size: 13px; text-align: left; }
table.api-table th { background: var(--bg-input); color: var(--text-secondary); font-weight: 600; }
@media (max-width: 820px) { .docs-layout { grid-template-columns: 1fr; } .docs-nav { position: static; flex-direction: row; flex-wrap: wrap; } }

/* ---------- 空状态（§9 规范） ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty .big { font-size: 30px; margin-bottom: 8px; }
.empty p { font-size: 13px; }

/* ---------- Toast（§4.9 规范：顶部居中黑底白字） ---------- */
.toast {
  position: fixed; left: 50%; top: 24px; transform: translate(-50%, -16px);
  display: flex; align-items: center; gap: 8px;
  background: var(--text-primary); color: var(--bg-body);
  padding: 11px 18px; border-radius: var(--radius-md); font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); z-index: 99; opacity: 0;
  transition: opacity .3s var(--ease-out-expo), transform .3s var(--ease-out-expo);
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-ok::before, .toast-error::before, .toast-warn::before {
  content: '✓'; font-weight: 600;
}
.toast-error::before { content: '!'; }
.toast-warn::before { content: '•'; }

/* ---------- 入场动画（riseIn） ---------- */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.rise { animation: riseIn .6s var(--ease-out-expo) both; }
.rise-1 { animation-delay: 0s; }
.rise-2 { animation-delay: .08s; }
.rise-3 { animation-delay: .16s; }
.rise-4 { animation-delay: .24s; }

/* ---------- 无障碍：关闭动效 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}