/* ---- 原第 1 个 style 块 ---- */

:root {
  --purple: #6C5CE7;
  --purple-light: #a29bfe;
  --purple-dark: #5a4bd1;
  --orange: #F39C12;
  --orange-light: #fdcb6e;
  --blue: #3498DB;
  --blue-light: #74b9ff;
  --green: #27AE60;
  --green-light: #55efc4;
  --red: #e74c3c;
  --red-light: #ff7675;
  --bg: #f8f9ff;
  --card-bg: #ffffff;
  --text: #2d3436;
  --text-light: #636e72;
  --shadow: 0 4px 20px rgba(108,92,231,0.1);
  --shadow-lg: 0 8px 40px rgba(108,92,231,0.15);
  --radius: 16px;
  --radius-sm: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ========== Header ========== */
.app-header {
  background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 100%);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 20px rgba(108,92,231,0.3);
}

.tool-shell-header {
  position: sticky;
  top: 0;
  z-index: 110;
}

.tool-bridge {
  padding-top: 28px;
}

.tool-bridge-card {
  margin-bottom: 20px;
}

.tool-bridge-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.tool-bridge-card h2,
.tool-bridge-card h3 {
  margin-top: 10px;
}

.tool-bridge-card p {
  color: var(--text-light);
  line-height: 1.8;
}

.bridge-note {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(108,92,231,0.08);
  color: var(--text-light);
  font-size: 13px;
  line-height: 1.8;
}
.app-header .logo {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(243,156,18,0.4);
}
.app-header h1 {
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
}
.app-header .subtitle {
  color: rgba(255,255,255,0.8);
  font-size: 11px;
  font-weight: 400;
}

/* ========== Progress Bar ========== */
.progress-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 20px;
  gap: 0;
  background: var(--card-bg);
  border-bottom: 1px solid #eee;
}
.progress-step {
  display: flex;
  align-items: center;
  gap: 0;
}
.progress-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #e0e0e0;
  color: #999;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  transition: all 0.3s;
  flex-shrink: 0;
}
.progress-dot.active {
  background: var(--purple);
  color: #fff;
  box-shadow: 0 2px 10px rgba(108,92,231,0.4);
}
.progress-dot.done {
  background: var(--green);
  color: #fff;
}
.progress-line {
  width: 40px; height: 3px;
  background: #e0e0e0;
  transition: background 0.3s;
}
.progress-line.done { background: var(--green); }

/* ========== Steps Container ========== */
.steps-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  min-height: calc(100vh - 120px);
}
.step {
  display: none;
  animation: fadeIn 0.4s ease;
}
.step.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== Step 1: Welcome ========== */
.welcome-card {
  text-align: center;
  padding: 60px 30px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 40px;
}
.welcome-logo {
  width: 120px; height: 120px;
  margin: 0 auto 24px;
  display: flex; align-items: center; justify-content: center;
  animation: pulse 2s infinite;
}
.welcome-logo img {
  width: 100%; height: 100%; object-fit: contain;
}
.welcome-card h2 {
  font-size: 24px;
  color: var(--purple);
  margin-bottom: 4px;
}
.welcome-card .brand-en {
  font-size: 13px;
  color: var(--orange);
  font-weight: 700;
  letter-spacing: 3px;
  margin-bottom: 8px;
}
.welcome-card .tagline {
  color: var(--text-light);
  font-size: 15px;
  margin-bottom: 8px;
}
.welcome-card .desc {
  color: var(--text-light);
  font-size: 13px;
  margin-bottom: 32px;
  line-height: 1.8;
}
.welcome-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}
.feature-item {
  padding: 20px 12px;
  background: linear-gradient(135deg, #f8f9ff, #f0f0ff);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  transition: transform 0.2s;
}
.feature-item:hover { transform: translateY(-2px); }
.feature-item .icon { font-size: 28px; margin-bottom: 8px; }
.feature-item .feat-title { font-weight: 600; margin-bottom: 4px; }
.feature-item .feat-desc { font-size: 11px; color: var(--text-light); }

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 36px;
  border: none;
  border-radius: 50px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  color: #fff;
  box-shadow: 0 4px 15px rgba(108,92,231,0.4);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(108,92,231,0.5);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn-orange {
  background: linear-gradient(135deg, var(--orange), #e67e22);
  color: #fff;
  box-shadow: 0 4px 15px rgba(243,156,18,0.4);
}
.btn-orange:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(243,156,18,0.5);
}
.btn-outline {
  background: transparent;
  color: var(--purple);
  border: 2px solid var(--purple);
}
.btn-outline:hover { background: var(--purple); color: #fff; }
.btn-sm { padding: 10px 24px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 12px; margin-top: 24px; }

/* ========== Step 2: Age Selection ========== */
.age-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 30px;
}
.age-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  border: 3px solid transparent;
  box-shadow: var(--shadow);
  transition: all 0.3s;
}
.age-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.age-card.selected {
  border-color: var(--purple);
  background: linear-gradient(135deg, #f8f7ff, #f0eeff);
}
.age-card .icon { font-size: 48px; margin-bottom: 12px; }
.age-card h3 { font-size: 18px; color: var(--purple); margin-bottom: 6px; }
.age-card p { font-size: 13px; color: var(--text-light); }

/* ========== Step 3: Form ========== */
.form-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 30px;
  box-shadow: var(--shadow);
  margin-top: 20px;
}
.form-card h3 {
  font-size: 18px;
  color: var(--purple);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #f0f0ff;
}
.form-group {
  margin-bottom: 18px;
}
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-group label .required {
  color: var(--red);
  margin-left: 2px;
}
.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e8e8e8;
  border-radius: var(--radius-sm);
  font-size: 15px;
  transition: border-color 0.3s;
  outline: none;
  background: #fafafa;
}
.form-control:focus {
  border-color: var(--purple);
  background: #fff;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.gender-select {
  display: flex; gap: 12px;
}
.gender-option {
  flex: 1;
  padding: 12px;
  border: 2px solid #e8e8e8;
  border-radius: var(--radius-sm);
  text-align: center;
  cursor: pointer;
  font-size: 15px;
  transition: all 0.3s;
  background: #fafafa;
}
.gender-option.selected {
  border-color: var(--purple);
  background: #f8f7ff;
  color: var(--purple);
  font-weight: 600;
}
.age-inputs {
  display: flex; align-items: center; gap: 8px;
}
.age-inputs input {
  width: 80px;
  text-align: center;
}
.age-inputs span {
  color: var(--text-light);
  font-size: 14px;
}

/* ========== Collapsible Sections ========== */
.collapsible-section {
  margin-top: 20px;
  border: 1px solid #eee;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.2s;
}
.collapsible-header:hover { background: #fafbff; }
.collapsible-header .toggle-icon {
  font-size: 12px;
  transition: transform 0.3s;
  color: var(--text-light);
}
.collapsible-header .toggle-icon.open {
  transform: rotate(180deg);
}
.collapsible-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.3s ease;
  padding: 0 18px;
}
.collapsible-body.open {
  max-height: 3000px;
  padding: 18px;
}

.section-a .collapsible-header { background: #f8f9ff; color: var(--purple); }
.section-b .collapsible-header { background: #fff8f0; color: var(--orange); }
.section-c .collapsible-header { background: #f0fff4; color: var(--green); }
.section-d .collapsible-header { background: #f5f5f5; color: var(--text-light); }

/* ========== Multi-select Tags (Capsule Style) ========== */
.tag-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.tag-capsule {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  background: #fff;
  user-select: none;
}
.tag-capsule:hover {
  border-color: var(--purple-light);
  background: #fafbff;
}
.tag-capsule.selected {
  border-color: var(--purple);
  background: linear-gradient(135deg, #f8f7ff, #f0eeff);
  color: var(--purple);
  font-weight: 600;
}

/* ========== Step 4: Test Data ========== */
.test-items {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}
.test-item {
  background: #fafbff;
  border-radius: var(--radius-sm);
  padding: 16px;
  border-left: 4px solid var(--purple-light);
  transition: all 0.3s;
}
.test-item:hover { background: #f5f3ff; }
.test-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.test-item-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}
.test-item-tag {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 20px;
  background: #f0eeff;
  color: var(--purple);
}
.test-item-input {
  display: flex;
  align-items: center;
  gap: 8px;
}
.test-item-input input {
  flex: 1;
  max-width: 160px;
  padding: 10px 14px;
  border: 2px solid #e8e8e8;
  border-radius: 8px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.3s;
}
.test-item-input input:focus { border-color: var(--purple); }
.test-item-input .unit {
  color: var(--text-light);
  font-size: 14px;
  min-width: 30px;
}
.test-item-ref {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}
.test-item-rating {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  min-height: 20px;
}

/* ========== Step 5: Report ========== */
.loading-overlay {
  display: none;
  text-align: center;
  padding: 80px 20px;
}
.loading-overlay.active { display: block; }
.spinner {
  width: 60px; height: 60px;
  border: 4px solid #f0eeff;
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}
.loading-text {
  font-size: 18px;
  color: var(--purple);
  font-weight: 600;
}
.loading-sub {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 8px;
}

.report-container { display: none; }
.report-container.active { display: block; }

/* Report Header */
.report-header {
  background: linear-gradient(135deg, var(--purple), #4834d4);
  color: #fff;
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.report-header::before {
  content: '';
  position: absolute;
  top: -50%; right: -20%;
  width: 200px; height: 200px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}
.report-header::after {
  content: '';
  position: absolute;
  bottom: -30%; left: -10%;
  width: 150px; height: 150px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}
.report-header h2 { font-size: 22px; margin-bottom: 4px; position: relative; z-index: 1; }
.report-header .report-subtitle { font-size: 13px; opacity: 0.9; position: relative; z-index: 1; }
.report-header .ace-badge {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 16px;
  background: rgba(255,255,255,0.15);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  position: relative;
  z-index: 1;
}

/* Report Card */
.report-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.report-card h3 {
  font-size: 16px;
  color: var(--purple);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.report-card h3 .icon { font-size: 20px; }

/* Info Grid */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}
.info-item {
  background: #f8f9ff;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
}
.info-item .label { font-size: 12px; color: var(--text-light); margin-bottom: 4px; }
.info-item .value { font-size: 16px; font-weight: 700; color: var(--text); }

/* Current Situation Summary */
.situation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.situation-item {
  background: #fafbff;
  padding: 14px;
  border-radius: 8px;
  border-left: 3px solid var(--purple-light);
}
.situation-item .sit-label { font-size: 12px; color: var(--text-light); margin-bottom: 4px; }
.situation-item .sit-value { font-size: 14px; font-weight: 600; color: var(--text); }

/* Analysis Section */
.ai-analysis {
  background: linear-gradient(135deg, #f8f9ff, #f0eeff);
  border-radius: var(--radius-sm);
  padding: 20px;
  line-height: 1.8;
  font-size: 14px;
}
.ai-analysis strong { color: var(--purple); }
.ai-analysis h4 { color: var(--purple); margin: 16px 0 8px; }
.ai-analysis p { margin-bottom: 10px; }
.ai-analysis ul, .ai-analysis ol { padding-left: 20px; margin-bottom: 10px; }
.ai-analysis li { margin-bottom: 4px; }

.ai-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin: 2px 4px 2px 0;
}
.ai-tag.green { background: #e8f8f0; color: var(--green); }
.ai-tag.orange { background: #fef9e7; color: var(--orange); }
.ai-tag.red { background: #fdedec; color: var(--red); }
.ai-tag.blue { background: #ebf5fb; color: var(--blue); }

/* Footer */
.report-footer {
  text-align: center;
  padding: 30px;
  color: var(--text-light);
  font-size: 12px;
  line-height: 1.8;
}
.report-footer .brand {
  font-size: 16px;
  font-weight: 700;
  color: var(--purple);
  margin-bottom: 4px;
}

/* ========== Responsive ========== */
@media (max-width: 600px) {
  .tool-bridge-grid { grid-template-columns: 1fr; }
  .app-header h1 { font-size: 14px; }
  .progress-line { width: 24px; }
  .progress-dot { width: 28px; height: 28px; font-size: 12px; }
  .steps-container { padding: 12px; }
  .welcome-card { padding: 40px 20px; margin-top: 20px; }
  .welcome-card h2 { font-size: 20px; }
  .welcome-features { grid-template-columns: 1fr; }
  .form-card { padding: 20px; }
  .form-row { grid-template-columns: 1fr; }
  .age-cards { grid-template-columns: 1fr; }
  .report-header { padding: 20px; }
  .report-header h2 { font-size: 18px; }
  .info-grid { grid-template-columns: repeat(2, 1fr); }
  .btn { padding: 12px 28px; font-size: 15px; }
  .btn-group { flex-direction: column; }
  .test-item-input input { max-width: 120px; }
  .situation-grid { grid-template-columns: 1fr; }
}

/* Print styles */
@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  .app-header, .progress-bar, .btn-group, .no-print, .loading-overlay, .stats-page { display: none !important; }
  #step5 { display: block !important; }
  .report-container { display: block !important; }
  .steps-container { max-width: 100%; padding: 0; }
  .report-header {
    background: linear-gradient(135deg, var(--purple), #4834d4) !important;
    color: #fff !important;
    box-shadow: none;
  }
  .report-header .report-subtitle,
  .report-header .ace-badge,
  .report-header h2 {
    color: #fff !important;
  }
  .report-header .ace-badge {
    background: rgba(255,255,255,0.15) !important;
  }
  .report-card {
    box-shadow: none;
    border: 1px solid #e6e1ff;
    page-break-inside: avoid;
  }
  .report-card h3,
  .ai-analysis h4,
  .report-footer .brand,
  .ai-analysis strong {
    color: var(--purple) !important;
  }
  .info-item {
    background: #f8f9ff !important;
  }
  .situation-item {
    background: #fafbff !important;
    border-left: 3px solid var(--purple-light) !important;
  }
  .ai-analysis {
    background: linear-gradient(135deg, #f8f9ff, #f0eeff) !important;
  }
  #testSummary strong {
    font-weight: 700;
  }
  body { background: #fff; }
}

html.pdf-export-mode body {
  background: #ffffff;
}

html.pdf-export-mode .app-header,
html.pdf-export-mode .progress-bar,
html.pdf-export-mode .btn-group,
html.pdf-export-mode .no-print,
html.pdf-export-mode .loading-overlay,
html.pdf-export-mode .stats-page {
  display: none !important;
}

html.pdf-export-mode .steps-container {
  max-width: 100%;
  padding: 0;
}

html.pdf-export-mode .report-container {
  display: block !important;
  padding: 0;
  background: #ffffff;
  box-shadow: none;
}

html.pdf-export-mode .pdf-export-stage {
  position: fixed;
  left: -20000px;
  top: 0;
  width: 960px;
  padding: 24px;
  background: #ffffff;
  z-index: -1;
}

html.pdf-export-mode .pdf-export-stage .report-card,
html.pdf-export-mode .pdf-export-stage .report-header,
html.pdf-export-mode .pdf-export-stage .report-footer {
  width: 100%;
}

html.pdf-export-mode .report-header,
html.pdf-export-mode .report-card,
html.pdf-export-mode .report-footer,
html.pdf-export-mode .info-item,
html.pdf-export-mode .situation-item,
html.pdf-export-mode .ai-analysis,
html.pdf-export-mode .ai-analysis h4,
html.pdf-export-mode .ai-analysis p,
html.pdf-export-mode .ai-analysis ul,
html.pdf-export-mode .ai-analysis ol,
html.pdf-export-mode .ai-analysis li {
  break-inside: avoid;
  page-break-inside: avoid;
}

html.pdf-export-mode .report-header::before,
html.pdf-export-mode .report-header::after {
  display: none;
}
