:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #1f2937;
  --text-2: #4b5563;
  --text-3: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-soft: #eff6ff;
  --primary-dark: #1d4ed8;
  --accent: #059669;
  --accent-soft: #ecfdf5;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(0,0,0,0.06);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
}
.brand h1 { margin: 0; font-size: 18px; font-weight: 700; }
.status { display: flex; gap: 10px; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
}
.badge.theory { background: var(--primary-soft); color: var(--primary-dark); border-color: #bfdbfe; }
.badge.stage { background: var(--surface-2); color: var(--text-2); }

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr 340px;
  gap: 22px;
  padding: 22px 28px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

.case-panel { overflow-y: auto; }
.case-card { padding: 22px; }
.card-header { margin-bottom: 18px; }
.tag {
  display: inline-block;
  padding: 4px 10px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
}
.card-header h2 { margin: 0; font-size: 18px; line-height: 1.45; color: var(--text); }

.case-meta {
  display: grid;
  gap: 12px;
  margin: 0 0 20px 0;
}
.case-meta > div { display: grid; gap: 2px; }
.case-meta dt { font-size: 12px; color: var(--text-3); font-weight: 500; }
.case-meta dd { margin: 0; font-size: 14px; color: var(--text); font-weight: 500; }

.data-sheet h3 {
  font-size: 14px;
  margin: 0 0 10px 0;
  color: var(--text);
}
.data-sheet table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-sheet td { padding: 8px 10px; border: 1px solid var(--border); }
.data-sheet td:first-child { background: var(--surface-2); color: var(--text-2); width: 46%; }
.data-sheet td:last-child { font-weight: 500; }

.stage-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.progress-track {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 18px;
  flex-shrink: 0;
}
.progress-bar {
  position: absolute;
  top: 28px;
  left: 52px;
  right: 52px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  z-index: 0;
}
.progress-bar::after {
  content: "";
  display: block;
  height: 100%;
  width: var(--progress, 0%);
  background: linear-gradient(90deg, var(--primary), #4f46e5);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.steps {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  list-style: none;
  margin: 0;
  padding: 0;
}
.steps li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s ease;
}
.steps li:hover { color: var(--primary-dark); }
.steps li.locked { opacity: 0.45; cursor: not-allowed; }
.steps li.locked:hover { color: var(--text-3); }
.steps li::before {
  content: attr(data-step);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text-3);
  font-size: 12px;
  font-weight: 700;
  transition: all 0.3s ease;
}
.steps li.active::before {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.steps li.done::before {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  content: "✓";
}
.steps li.active { color: var(--primary-dark); }

.scene {
  flex: 1;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 28px 32px;
  overflow-y: auto;
  min-height: 0;
}

.controls {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(37,99,235,0.25); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #eef2f7; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #047857; }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.feedback-panel { display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }
.feedback-card { padding: 20px; }
.feedback-card h3 { margin: 0 0 14px 0; font-size: 15px; }
.feedback-empty {
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  padding: 26px 10px;
  border: 1px dashed var(--border);
  border-radius: 10px;
}
.feedback-body { display: grid; gap: 12px; }
.metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 8px;
}
.metric-label { font-size: 13px; color: var(--text-2); }
.metric-value { font-size: 14px; font-weight: 700; color: var(--text); }
.metric-value.positive { color: var(--accent); }
.metric-value.negative { color: var(--danger); }
.insight {
  margin-top: 6px;
  padding: 12px;
  background: var(--primary-soft);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.7;
}

.hint-card { padding: 18px; }
.hint-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 8px;
}
.timer {
  font-variant-numeric: tabular-nums;
  color: var(--warning);
  background: var(--warning-soft);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
}
.hint-desc { margin: 0 0 12px 0; font-size: 12px; color: var(--text-3); }
.kb-upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.kb-upload-row .btn { padding: 8px 14px; font-size: 12px; }
.kb-file-name {
  font-size: 12px;
  color: var(--text-3);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hint-content {
  margin-top: 12px;
  padding: 12px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.7;
}

.hidden { display: none !important; }

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* 移动端导航与抽屉 */
.mobile-nav-btn { display: none; }
.panel-close-mobile { display: none; }
.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 140;
}
.panel-close-mobile {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  padding: 4px 0 14px 0;
  cursor: pointer;
}

.case-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.case-toolbar .btn { flex: 1; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.modal-dialog {
  position: relative;
  width: min(680px, 92vw);
  max-height: 86vh;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 17px; }
.modal-close {
  border: none;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--text-3);
  cursor: pointer;
}
.modal-close:hover { color: var(--text); }
.modal-body {
  padding: 22px;
  overflow-y: auto;
}

.case-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
.case-pick {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: var(--surface-2);
  cursor: pointer;
  transition: all 0.18s ease;
}
.case-pick:hover { border-color: var(--primary); background: var(--primary-soft); }
.case-pick.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.case-pick h4 { margin: 0 0 6px 0; font-size: 15px; }
.case-pick p { margin: 0 0 10px 0; font-size: 12px; color: var(--text-3); }
.case-pick .tag-line { font-size: 11px; color: var(--primary-dark); font-weight: 600; }
.case-pick-actions { display: flex; gap: 8px; margin-top: 8px; }

.form-field { margin-bottom: 14px; }
.form-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
}
.form-field input:focus,
.form-field textarea:focus { outline: none; border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint {
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface-2);
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
  line-height: 1.6;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}
.loading-spin {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* 场景内容样式 */
.scene-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 18px 0;
  color: var(--text);
}
.scene-subtitle {
  font-size: 14px;
  color: var(--text-3);
  margin-bottom: 20px;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 18px 0;
}
.role-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: var(--surface-2);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.role-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.role-name {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.role-icon { font-size: 20px; }
.role-stance {
  font-size: 12px;
  color: var(--primary-dark);
  font-weight: 600;
  margin-bottom: 10px;
}
.role-quote {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.7;
  font-style: italic;
}

.debate-list { display: grid; gap: 14px; margin: 18px 0; }
.debate-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.debate-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  background: var(--primary-soft);
  flex-shrink: 0;
}
.debate-bubble {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.debate-speaker { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.debate-text { font-size: 14px; color: var(--text); line-height: 1.7; }

.choice-list { display: grid; gap: 12px; margin: 18px 0; }
.choice-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.18s ease;
  background: var(--surface);
}
.choice-item:hover, .choice-item.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.choice-radio {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-radius: 50%;
  margin-top: 2px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.choice-item.selected .choice-radio { border-color: var(--primary); }
.choice-item.selected .choice-radio::after {
  content: "";
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary);
}
.choice-content { flex: 1; }
.choice-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.choice-desc { font-size: 13px; color: var(--text-2); line-height: 1.6; }

.report {
  display: grid;
  gap: 16px;
}
.report-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  background: var(--surface-2);
}
.report-section h4 {
  margin: 0 0 10px 0;
  font-size: 15px;
  color: var(--primary-dark);
}
.report-section p, .report-section li { font-size: 14px; color: var(--text); line-height: 1.8; }
.report-section ul { margin: 0; padding-left: 20px; }
.decision-log {
  display: grid;
  gap: 8px;
}
.log-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface);
  border-radius: 8px;
  font-size: 13px;
}
.log-label { color: var(--text-2); }
.log-value { font-weight: 700; }

.narrative {
  font-size: 15px;
  color: var(--text);
  line-height: 1.9;
  margin: 10px 0 18px 0;
}
.narrative p { margin: 0 0 12px 0; }

@media (max-width: 1200px) {
  .workspace { grid-template-columns: 280px 1fr 300px; padding: 16px; gap: 16px; }
}

/* ===== 移动端 / 平板（≤1024px）：单栏 + 抽屉式案例与反馈 ===== */
@media (max-width: 1024px) {
  .mobile-nav-btn { display: inline-flex; }
  .app {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }
  .topbar {
    flex-wrap: wrap;
    gap: 10px 14px;
    padding: 12px 16px;
  }
  .brand h1 { font-size: 15px; }
  .status { flex-wrap: wrap; gap: 8px; }

  .workspace {
    display: block;
    height: auto;
    overflow: visible;
    padding: 14px;
  }

  /* 案例面板与反馈面板默认隐藏，改为可滑出的全屏抽屉 */
  .case-panel, .feedback-panel {
    display: none;
  }
  .case-panel.mobile-open,
  .feedback-panel.mobile-open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 150;
    background: var(--bg);
    overflow-y: auto;
    padding: 14px 16px 40px 16px;
  }
  .panel-close-mobile { display: block; }

  .stage-panel { min-height: auto; }
  .scene { padding: 20px 16px; }
  .progress-track { padding: 16px 18px; }
  .progress-bar { left: 40px; right: 40px; top: 26px; }

  .role-grid { grid-template-columns: 1fr; }
  .case-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }

  .controls { flex-wrap: wrap; }
  .controls .btn { flex: 1 1 auto; min-width: 120px; }
  .feedback-panel { gap: 14px; }
}

/* ===== 小屏手机（≤480px） ===== */
@media (max-width: 480px) {
  .topbar { padding: 10px 12px; gap: 8px 10px; }
  .brand h1 { display: block; font-size: 14px; }
  .status .badge { display: none; }        /* 小屏隐藏 theory/stage badge，腾出空间 */
  .status .btn { padding: 6px 10px; font-size: 12px; }
  .workspace { padding: 10px; }
  .scene { padding: 16px 12px; }
  .progress-track { padding: 12px 8px; }
  .progress-bar { left: 30px; right: 30px; top: 22px; }
  .steps li { font-size: 10px; gap: 4px; }
  .steps li::before { width: 20px; height: 20px; font-size: 10px; }
  .scene-title { font-size: 19px; }
  .btn { padding: 10px 16px; font-size: 13px; }
  .controls .btn { min-width: 0; }
}
