/* ========================================
   各路老炮和你破直男聊天 - Styles
   Mobile-first, flat design
   ======================================== */

:root {
  --bg-page: #f5f4f0;
  --bg-card: #ffffff;
  --bg-input: #f5f4f0;
  --text-primary: #1a1a1a;
  --text-secondary: #555;
  --text-tertiary: #999;
  --border: #e0ddd5;
  --border-hover: #c5c2b8;
  --radius: 12px;
  --radius-sm: 8px;

  --c-diagnostic-bg: #ffffff;
  --c-diagnostic-border: #e0ddd5;
  --c-coach-bg: #fdf6e9;
  --c-coach-border: #f0d9a0;
  --c-coach-text: #6b4d10;
  --c-coach-title: #8a5e15;
  --c-summary-bg: #edf8f2;
  --c-summary-border: #a8dcc4;
  --c-summary-text: #0a4d33;
  --c-summary-title: #0d6644;

  --c-green: #1d9e75;
  --c-green-bg: #e1f5ee;
  --c-red: #e24b4a;
  --c-red-bg: #fcebeb;
  --c-amber: #ef9f27;
  --c-amber-bg: #faeeda;
  --c-blue: #378add;
  --c-blue-bg: #e6f1fb;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 16px;
}

/* ========== Screen switching ========== */
.screen {
  display: none;
  animation: fadeIn 0.3s ease;
}
.screen.active {
  display: block;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== Header ========== */
.app-header {
  text-align: center;
  margin-bottom: 20px;
  padding-top: 20px;
}
.app-header h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.app-header p {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ========== Privacy badge ========== */
.privacy-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--c-green-bg);
  color: #0a4d33;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 20px;
  font-size: 12px;
}
.privacy-badge svg {
  flex-shrink: 0;
}

/* ========== Input cards ========== */
.input-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.input-card label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.auto-tag {
  font-size: 11px;
  color: var(--c-green);
}
input[type="text"], textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
  resize: vertical;
}
input[type="text"]:focus, textarea:focus {
  border-color: var(--c-green);
}
textarea {
  min-height: 120px;
  line-height: 1.5;
}
.format-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 8px;
  line-height: 1.5;
}

/* ========== Buttons ========== */
.btn-row {
  display: flex;
  gap: 8px;
}
.btn-primary {
  flex: 1;
  padding: 14px;
  background: var(--c-green);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}
.btn-primary:active {
  transform: scale(0.98);
  opacity: 0.9;
}
.btn-secondary {
  padding: 14px 20px;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  white-space: nowrap;
}
.btn-secondary:active {
  transform: scale(0.98);
  opacity: 0.8;
}
.btn-text {
  background: none;
  border: none;
  color: var(--c-green);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
}

/* ========== Loading ========== */
.loading-steps {
  margin-bottom: 24px;
}
.loading-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
  color: var(--text-tertiary);
  transition: color 0.3s;
}
.loading-step.done {
  color: var(--c-green);
}
.loading-step.active {
  color: var(--c-amber);
}
.step-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  transition: all 0.3s;
}
.loading-step.done .step-icon {
  background: var(--c-green);
  color: #fff;
}
.loading-step.active .step-icon {
  background: var(--c-amber);
  color: #fff;
  animation: pulse 1.2s infinite;
}
.loading-step.pending .step-icon {
  background: var(--border);
  color: var(--text-tertiary);
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.loading-fun {
  text-align: center;
  padding: 40px 20px;
  font-size: 13px;
  color: var(--text-tertiary);
  line-height: 1.8;
  animation: fadeChange 4s infinite;
}
@keyframes fadeChange {
  0%, 90%, 100% { opacity: 1; }
  93%, 97% { opacity: 0.3; }
}

/* ========== Results ========== */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-top: 20px;
}
.results-header h2 {
  font-size: 18px;
  font-weight: 600;
}

/* ========== Score card ========== */
.card-score {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  margin-bottom: 12px;
}
.score-num {
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}
.score-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
}
.score-bar {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 24px;
}
.score-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.score-tag {
  display: inline-block;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 4px;
  margin-top: 10px;
  font-weight: 500;
}

/* ========== Result cards ========== */
.card {
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
}
.card-diagnostic {
  background: var(--c-diagnostic-bg);
  border: 1px solid var(--c-diagnostic-border);
}
.card-coach {
  background: var(--c-coach-bg);
  border: 1px solid var(--c-coach-border);
}
.card-summary {
  background: var(--c-summary-bg);
  border: 1px solid var(--c-summary-border);
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-diagnostic .card-title { color: var(--text-primary); }
.card-coach .card-title { color: var(--c-coach-title); }
.card-summary .card-title { color: var(--c-summary-title); }
.card-body {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
}
.card-coach .card-body { color: var(--c-coach-text); }
.card-summary .card-body { color: var(--c-summary-text); }

/* ========== Tags ========== */
.tag {
  display: inline-block;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}
.tag-d { background: var(--bg-input); color: var(--text-secondary); }
.tag-c { background: var(--c-coach-border); color: var(--c-coach-title); }
.tag-s { background: var(--c-summary-border); color: var(--c-summary-title); }

/* ========== Collapsible ========== */
.collapse-toggle {
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
  padding: 8px;
  cursor: pointer;
  transition: color 0.2s;
}
.collapse-toggle:hover { color: var(--c-green); }
.collapse-content {
  display: none;
}
.collapse-content.open {
  display: block;
}

/* ========== Report content ========== */
.report-section {
  margin-bottom: 10px;
}
.report-section-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.report-list {
  list-style: none;
  padding: 0;
}
.report-list li {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
  padding: 4px 0;
  padding-left: 16px;
  position: relative;
}
.report-list li::before {
  content: "\00b7";
  position: absolute;
  left: 4px;
  color: var(--text-tertiary);
}
.report-paragraph {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 8px;
}
.coach-inline {
  background: var(--c-coach-bg);
  border: 1px solid var(--c-coach-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 8px 0;
  font-size: 13px;
  color: var(--c-coach-text);
  line-height: 1.6;
}
.coach-inline-label {
  font-weight: 600;
  color: var(--c-coach-title);
  font-size: 12px;
  margin-bottom: 4px;
}

/* ========== Error toast ========== */
.error-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #2c2c2a;
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  z-index: 100;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateX(-50%) translateY(20px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ========== Responsive ========== */
@media (min-width: 600px) {
  #app {
    max-width: 520px;
    padding: 24px;
  }
  .app-header h1 { font-size: 22px; }
}

/* ========== Tab navigation ========== */
.tab-nav {
  display: flex;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0 4px;
}
.tab-btn {
  flex: 1;
  padding: 12px 6px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.tab-btn.active {
  color: var(--c-green);
  border-bottom-color: var(--c-green);
}
.tab-panel {
  display: none;
  padding: 0 16px 24px;
  min-height: 60vh;
}
.tab-panel.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

/* ========== Training mode ========== */
.train-scenario-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.train-scenario-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.train-scenario-context {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 10px;
  line-height: 1.5;
}
.train-result {
  margin-top: 12px;
}
.train-stats {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 12px;
}

/* ========== Status dashboard ========== */
.status-bar {
  display: flex;
  align-items: center;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin: 8px 0;
  background: var(--bg-input);
}
.status-bar-fill {
  height: 100%;
  transition: width 0.5s;
}

/* ========== Adjust for tabs ========== */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0;
}

/* ========== Mode toggle ========== */
.mode-toggle {
  display: flex;
  gap: 6px;
}
.mode-btn {
  flex: 1;
  padding: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.mode-btn.active {
  background: var(--c-green);
  color: #fff;
  border-color: var(--c-green);
}
.mode-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 6px;
  transition: color 0.3s;
}

/* ========== Coach table ========== */
.coach-table-wrap {
  overflow-x: auto;
  margin: -8px -8px 0;
  padding: 0 4px;
}
.coach-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  line-height: 1.5;
}
.coach-table th, .coach-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.coach-table th {
  font-weight: 500;
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
}
.coach-table td {
  color: var(--text-secondary);
}
.coach-table tr:last-child th,
.coach-table tr:last-child td {
  border-bottom: none;
}

/* ========== Chat bubble preview ========== */
.chat-preview {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}
.chat-preview-header {
  font-size: 11px;
  color: var(--text-tertiary);
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-input);
}
.chat-preview-body {
  padding: 12px 14px;
  max-height: 300px;
  overflow-y: auto;
}
.bubble-row {
  display: flex;
  align-items: flex-start;
  margin-bottom: 10px;
  gap: 8px;
}
.bubble-row-left {
  justify-content: flex-start;
}
.bubble-row-right {
  justify-content: flex-end;
}
.bubble-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
}
.bubble-avatar-male {
  background: var(--c-blue);
}
.bubble-avatar-female {
  background: var(--c-coral, #d85a30);
}
.bubble-wrap {
  max-width: 75%;
}
.bubble-name {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-bottom: 2px;
  padding-left: 4px;
}
.bubble {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}
.bubble-me {
  background: var(--c-blue-bg);
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
}
.bubble-other {
  background: #f5f4f0;
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}
.bubble-time {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 3px;
  text-align: center;
}

/* ========== Quiz overlay & training game ========== */
.quiz-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.quiz-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 32px 24px;
  text-align: center;
  max-width: 320px;
  width: 90%;
  animation: popIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes popIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.quiz-emoji { font-size: 48px; margin-bottom: 8px; }
.quiz-title { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.quiz-grade { font-size: 56px; font-weight: 700; color: var(--c-green); margin-bottom: 12px; }
.quiz-detail { font-size: 13px; color: var(--text-secondary); line-height: 1.6; }
.quiz-badges { margin-top: 8px; display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.badge-chip { display: inline-block; font-size: 11px; background: var(--c-amber-bg); color: #854f0b; padding: 3px 10px; border-radius: 12px; font-weight: 500; }
.train-level-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); }
.train-level-badge { padding: 4px 12px; border-radius: 12px; font-size: 12px; font-weight: 600; color: #fff; background: var(--c-blue); white-space: nowrap; min-width: 48px; text-align: center; }
.train-xp-wrap { flex: 1; }
.train-xp-bar { height: 8px; background: var(--bg-input); border-radius: 4px; overflow: hidden; }
.train-xp-fill { height: 100%; background: var(--c-green); border-radius: 4px; transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1); }
.train-xp-text { font-size: 10px; color: var(--text-tertiary); margin-top: 3px; }
.train-streak { font-size: 14px; padding: 2px 8px; background: var(--c-amber-bg); border-radius: 8px; white-space: nowrap; }

/* ========== MCQ options ========== */
.mcq-options { margin-top: 8px; }
.mcq-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  line-height: 1.5;
}
.mcq-option:hover { border-color: var(--c-green); background: var(--c-green-bg); }
.mcq-label {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg-input);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  flex-shrink: 0;
}
.mcq-text { flex: 1; }
