/* ============================================================
   SBTI 主题样式 - 浅色 + 深色模式
   使用 CSS 变量 + data-theme 切换
   ============================================================ */

/* ---------- 变量定义 ---------- */
:root {
  /* 浅色主题 */
  --bg: #f6faf6;
  --panel: #ffffff;
  --text: #1e2a22;
  --muted: #6a786f;
  --line: #dbe8dd;
  --soft: #edf6ef;
  --accent: #6c8d71;
  --accent-strong: #4d6a53;
  --shadow: 0 16px 40px rgba(47, 73, 55, 0.08);
  --radius: 22px;
  --radius-sm: 14px;
  --radius-xs: 999px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --overlay: rgba(0, 0, 0, 0.5);
  --card-bg: linear-gradient(180deg, #ffffff, #fbfdfb);
}

[data-theme="dark"] {
  /* 深色主题 */
  --bg: #0f1a12;
  --panel: #1a2e1f;
  --text: #d4e8d8;
  --muted: #8aa88e;
  --line: #2a4030;
  --soft: #1e2e20;
  --accent: #7fa882;
  --accent-strong: #9fc4a0;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
  --card-bg: linear-gradient(180deg, #1e3020, #162818);
  --overlay: rgba(0, 0, 0, 0.7);
}

/* ---------- 基础重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: radial-gradient(circle at top left, var(--bg) 0%, var(--bg) 36%, color-mix(in srgb, var(--bg) 90%, var(--accent)) 100%);
  color: var(--text);
  min-height: 100vh;
}

/* ---------- 布局容器 ---------- */
.shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 56px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- Banner ---------- */
.banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.banner-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
}
.banner-brand .emoji { font-size: 24px; }
.banner-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.banner-actions a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: color 0.2s;
}
.banner-actions a:hover { color: var(--accent-strong); }

/* ---------- Hero ---------- */
.hero {
  padding: 36px 28px;
  margin-top: 20px;
  overflow: hidden;
  position: relative;
}
.hero::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -60px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(127, 165, 134, 0.18), rgba(127, 165, 134, 0.02));
  pointer-events: none;
}
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--accent-strong);
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: var(--radius-xs);
  padding: 8px 12px;
  margin-bottom: 16px;
}
.hero h1 {
  font-size: clamp(28px, 5vw, 52px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  max-width: 680px;
  margin: 0;
}
.hero-sub {
  margin-top: 14px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
  max-width: 720px;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}
.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 24px;
}
.stat-item {
  text-align: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--soft);
}
.stat-item .num {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent-strong);
}
.stat-item .label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ---------- 人格卡片网格 ---------- */
.section-title {
  font-size: 20px;
  font-weight: 700;
  margin: 28px 0 16px;
  color: var(--text);
}
.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.type-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--panel);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.type-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.type-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.type-card .prob {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.type-card .tag {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
  white-space: nowrap;
}
.tag-normal { background: var(--soft); color: var(--accent-strong); border: 1px solid var(--line); }
.tag-special { background: #fff3e0; color: #e65100; border: 1px solid #ffe0b2; }
[data-theme="dark"] .tag-special { background: #3d2000; color: #ffb74d; border-color: #5d3000; }
.type-card .code {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent-strong);
}
.type-card .cn {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.type-card .desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

/* ---------- 按钮 ---------- */
button {
  border: 0;
  cursor: pointer;
  font: inherit;
  transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease;
}
button:hover:not(:disabled) { transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: 0.5; transform: none; }

.btn-primary {
  background: var(--accent-strong);
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(77, 106, 83, 0.2);
  font-weight: 700;
}
.btn-primary:hover { box-shadow: 0 12px 30px rgba(77, 106, 83, 0.25); }
.btn-secondary {
  background: var(--panel);
  color: var(--accent-strong);
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  font-weight: 700;
}
.btn-ghost {
  background: transparent;
  color: var(--accent-strong);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
}

/* ---------- 弹窗 Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}
.modal-header h2 { margin: 0; font-size: 18px; }
.modal-close {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-strong);
}
.modal-body { padding: 20px; }
.modal-poster {
  width: 100%;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  background: var(--soft);
  display: block;
}
.modal-type-code {
  font-size: 12px;
  color: var(--accent-strong);
  letter-spacing: .06em;
  margin-bottom: 6px;
}
.modal-type-name {
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 800;
}
.modal-type-intro {
  margin-top: 10px;
  color: var(--muted);
  font-size: 15px;
}
.modal-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius-xs);
  padding: 8px 14px;
  background: var(--soft);
  border: 1px solid var(--line);
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 13px;
  margin-top: 14px;
}
.modal-section { margin-top: 20px; }
.modal-section h3 {
  font-size: 15px;
  margin: 0 0 12px;
  color: var(--text);
}
.modal-section p {
  margin: 0;
  color: var(--text);
  font-size: 14px;
  line-height: 1.9;
  white-space: pre-wrap;
}
.modal-dims {
  display: grid;
  gap: 10px;
}
.dim-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--card-bg);
}
.dim-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}
.dim-name { font-size: 13px; font-weight: 700; color: var(--text); }
.dim-level {
  font-size: 13px;
  font-weight: 800;
  color: var(--accent-strong);
  white-space: nowrap;
}
.dim-item p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.7; }
.modal-model-group {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* ---------- Footer ---------- */
.footer {
  margin-top: 40px;
  padding: 20px 24px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
  line-height: 1.8;
}
.footer a { color: var(--accent-strong); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* ---------- 响应式 ---------- */
@media (max-width: 600px) {
  .shell { padding: 12px 12px 42px; }
  .hero { padding: 20px 16px; }
  .hero h1 { font-size: 30px; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .type-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-item { padding: 8px; }
  .stat-item .num { font-size: 18px; }
}
@media (max-width: 400px) {
  .type-grid { grid-template-columns: 1fr; }
}

/* ---------- 主题切换按钮 ---------- */
.theme-toggle {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-strong);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s;
}
.theme-toggle:hover { background: var(--line); }