:root {
  --bg: #f5f7fa;
  --sidebar-bg: #1f2a44;
  --sidebar-text: #dbe2f0;
  --sidebar-active: #2f4a7a;
  --primary: #2f6fed;
  --primary-dark: #1f55c9;
  --text: #26303e;
  --muted: #6b7686;
  --border: #e3e8f0;
  --card: #ffffff;
  --ok: #1a9d5c;
  --warn: #d98b0b;
  --bad: #d64545;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.7;
}

.app {
  display: flex;
  min-height: 100vh;
}

/* ============ 侧边栏 ============ */
.sidebar {
  flex: 0 0 auto;
  width: max-content;
  min-width: 220px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.sidebar-header {
  width: 0;
  min-width: 100%;
  padding: 22px 20px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-header h1 {
  margin: 0;
  font-size: 20px;
  color: #fff;
  letter-spacing: 1px;
}

.sidebar-header .subtitle {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: #93a1bd;
}

.scale-list {
  flex: 1 1 auto;
  min-height: 0;
  width: max-content;
  padding: 12px 10px;
  overflow-y: auto;
}

.scale-item {
  display: block;
  text-decoration: none;
  color: var(--sidebar-text);
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 6px;
  transition: background 0.15s;
}

.scale-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.scale-item.active {
  background: var(--sidebar-active);
  color: #fff;
}

.scale-name {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  white-space: nowrap;
}

.scale-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.cat-badge {
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 500;
  white-space: nowrap;
}

.cat-self { background: rgba(72, 148, 255, 0.2); color: #9ec5ff; }
.cat-parent { background: rgba(255, 178, 66, 0.18); color: #ffcf8a; }
.cat-pro { background: rgba(255, 122, 122, 0.18); color: #ffb3b3; }

.item-count {
  font-size: 11.5px;
  color: #8b98b4;
}

.sidebar-footer {
  width: 0;
  min-width: 100%;
  padding: 14px 20px;
  font-size: 12px;
  color: #7d8aa3;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ============ 主内容区 ============ */
.content {
  flex: 1;
  padding: 32px 40px 60px;
  max-width: 880px;
}

/* ---------- 详情页 ---------- */
.detail-header {
  margin-bottom: 22px;
}

.detail-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.35;
  color: #17203a;
}

.en-title {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 14px;
}

.tag {
  display: inline-block;
  background: #eef3fd;
  color: var(--primary);
  font-size: 13px;
  padding: 2px 10px;
  border-radius: 999px;
  white-space: nowrap;
  width: max-content;
}

.meta-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 999px;
  background: #eef1f6;
  color: #49566b;
  white-space: nowrap;
  width: max-content;
  vertical-align: middle;
}

.badge.cat-self { background: #e7f0ff; color: #2f6fed; }
.badge.cat-parent { background: #fff3e0; color: #c07c10; }
.badge.cat-pro { background: #fdeaea; color: #c04444; }
.badge-count { background: #f0f2f5; color: #49566b; }

.badge.risk-high { background: #fdeaea; color: #c04444; }
.badge.risk-mid { background: #fff3e0; color: #c07c10; }
.badge.risk-low { background: #e8f6ef; color: #1a9d5c; }

.detail-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-bottom: 16px;
}

.detail-section h2 {
  margin: 0;
  font-size: 17px;
  color: #17203a;
}

/* 标题行：左侧标题，右侧可放操作按钮（如「查看量表题目」） */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.section-action { flex: 0 0 auto; }

.section-action .quiz-btn {
  padding: 7px 16px;
  font-size: 13.5px;
  border-radius: 6px;
  white-space: nowrap;
}

.section-body {
  font-size: 14.5px;
}

.section-body p { margin: 8px 0; }

.note {
  color: #9a5a12;
  background: #fff8ec;
  border-left: 3px solid #f0b344;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13.5px;
  margin: 12px 0;
}

.cutoff-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13.5px;
}

.cutoff-table th, .cutoff-table td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.cutoff-table td:has(.badge) {
  width: 1%;
  white-space: nowrap;
}

.cutoff-table th {
  background: #f3f6fb;
  color: #39445a;
}

.quiz-btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  padding: 12px 26px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.15s;
}

.quiz-btn:hover { background: var(--primary-dark); }

/* ---------- 问卷页 ---------- */
.quiz-top { margin-bottom: 10px; }

.back-btn {
  display: inline-block;
  text-decoration: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
}

.back-btn:hover { text-decoration: underline; }

.quiz-header {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 26px;
  margin-bottom: 18px;
}

.quiz-header h1 {
  margin: 0 0 6px;
  font-size: 21px;
  color: #17203a;
}

.quiz-instruction {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13.5px;
}

.progress-wrap {
  height: 8px;
  background: #e8ecf3;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.2s;
}

.progress-text {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

.quiz-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.quiz-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
}

.quiz-item.answered {
  border-left: 4px solid var(--ok);
}

.item-text {
  font-size: 14.5px;
  font-weight: 500;
  margin-bottom: 12px;
}

.item-num {
  display: inline-block;
  min-width: 26px;
  color: var(--muted);
  font-weight: 400;
}

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  font-size: 13.5px;
  color: #39445a;
  transition: all 0.12s;
  user-select: none;
}

.opt:hover {
  border-color: var(--primary);
  background: #f4f8ff;
}

.opt input { cursor: pointer; }

.opt input:checked + span {
  color: var(--primary);
  font-weight: 600;
}

.opt:has(input:checked) {
  border-color: var(--primary);
  background: #eef4ff;
}

.quiz-footer {
  margin: 20px 0;
  display: flex;
  gap: 12px;
}

.submit-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 30px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.submit-btn:hover { background: var(--primary-dark); }

.reset-btn {
  background: #fff;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 12px 22px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

.reset-btn:hover { background: #f3f6fb; }

/* ---------- 结果 ---------- */
.result-box {
  background: #fbfdff;
  border: 1px solid #d6e4f5;
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-top: 8px;
}

.result-box h3 {
  margin: 0 0 14px;
  font-size: 17px;
  color: #17203a;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13.5px;
}

.result-table th, .result-table td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.result-table th { background: #f3f6fb; }

.total-line {
  margin: 14px 0 6px;
  font-size: 15px;
}

.big-score {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.range { color: var(--muted); font-size: 13px; }

.band {
  display: inline-block;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 6px;
  white-space: nowrap;
  width: max-content;
  vertical-align: middle;
}

p.band {
  display: block;
  white-space: normal;
  width: auto;
}

.band.ok { background: #e8f6ef; color: #1a9d5c; }
.band.warn { background: #fff3e0; color: #c07c10; }
.band.bad { background: #fdeaea; color: #c04444; }

.result-note { margin: 10px 0; font-size: 14px; }

.risk-result { margin: 6px 0 10px; }

.total-score { margin: 4px 0; }

/* ============ 响应式 ============ */
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar {
    flex: none;
    width: 100%;
    min-width: 0;
    height: auto;
    position: static;
    overflow: visible;
  }
  .sidebar-header,
  .sidebar-footer {
    width: auto;
    min-width: 0;
  }
  .scale-list {
    display: block;
    width: 100%;
    padding: 10px;
    overflow: visible;
    min-height: 0;
  }
  .scale-item {
    width: auto;
    min-width: 0;
  }
  .scale-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .content { padding: 20px 16px 50px; }
  .detail-header h1 { font-size: 22px; }
}
