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

:root {
  --bg-gradient-start: #bce3fb;
  --bg-gradient-mid: #cdeafc;
  --bg-gradient-end: #e6f5ff;
  --card-bg: rgba(255, 255, 255, 0.94);
  --primary-blue: #40a0ff;
  --accent-purple: #7a5df4;
  --accent-purple-light: #ece9fe;
  --accent-teal: #22c197;
  --text-main: #1f2937;
  --text-sub: #6b7280;
  --progress-bg: #80c4f8;
  --progress-fill: #3b82f6;
  --star-gold: #fbc02d;
  --danger-red: #ef4444;
  --success-green: #10b981;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", Roboto, "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: linear-gradient(180deg, #99d2f8 0%, #b8e0fb 30%, #e0f2fe 75%, #ffffff 100%);
  min-height: 100vh;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: stretch;
  color: var(--text-main);
  overflow-x: hidden;
}

/* 滿版自適應佈局 (網頁版滿版體驗) */
.app-wrapper {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  height: 100vh;
  max-height: 100vh;
  background: linear-gradient(180deg, #9fd5fa 0%, #bde1fb 35%, #def0fe 70%, #edf7ff 100%);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: none;
  border-radius: 0;
  overflow: hidden;
  border: none;
}

/* 頂部導航與進度列 (寬螢幕自動置中並限制最大寬度保持優雅) */
.top-nav {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  user-select: none;
}

/* 即時答題統計記錄橫幅 */
.stats-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 4px 0;
  gap: 8px;
}

.stat-pill {
  flex: 1;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(4px);
  border-radius: 12px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.stat-pill .stat-label {
  color: #64748b;
  font-weight: 600;
}

.stat-pill.correct strong {
  color: #10b981;
  font-size: 14px;
}

.stat-pill.wrong strong {
  color: #ef4444;
  font-size: 14px;
}

.stat-pill.streak strong {
  color: #f59e0b;
  font-size: 14px;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  background: transparent;
  border: none;
  font-size: 22px;
  color: #2b5683;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  transition: transform 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.9);
}

.progress-track-container {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
}

.water-drop-icon {
  width: 32px;
  height: 32px;
  background: #4ea8f6;
  border-radius: 50% 50% 50% 10%;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(59, 130, 246, 0.35);
  position: absolute;
  left: 0;
  z-index: 3;
}

.water-drop-icon svg {
  transform: rotate(45deg);
  fill: #ffffff;
  width: 16px;
  height: 16px;
}

.progress-pill {
  width: 100%;
  height: 24px;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 12px;
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 10px 0 36px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.progress-fill-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 70%;
  background: linear-gradient(90deg, #5bb4ff 0%, #3692eb 100%);
  border-radius: 12px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-text {
  position: relative;
  z-index: 2;
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.star-milestone {
  position: absolute;
  right: 18px;
  font-size: 18px;
  color: #fff9c4;
  filter: drop-shadow(0 0 4px #fbbf24);
  z-index: 2;
  display: flex;
  align-items: center;
}

/* 主卡片區域 */
.main-content {
  flex: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-y: auto;
}

.question-card {
  background: #ffffff;
  border-radius: 30px;
  box-shadow: 0 16px 36px rgba(45, 96, 148, 0.12);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.9);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* 卡片上方標籤 */
.card-tags-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px 0;
}

.level-badge {
  background: #60a5fa;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.level-badge .help-q {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.new-badge {
  background: #ff5264;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 14px;
  letter-spacing: 0.5px;
  box-shadow: 0 3px 8px rgba(255, 82, 100, 0.35);
}

/* 中文題目區 */
.chinese-section {
  padding: 16px 20px 12px;
}

.chinese-sentence {
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
  letter-spacing: 0.3px;
  line-height: 1.5;
}

.highlight-keyword {
  color: #16a34a; /* 綠色關鍵字 */
  position: relative;
  text-decoration: underline;
  text-decoration-color: #86efac;
  text-underline-offset: 3px;
}

.chinese-subnote {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 8px;
  text-align: right;
  font-weight: 500;
}

/* 分隔線 */
.card-divider {
  height: 1px;
  background: #f1f5f9;
  margin: 0 16px;
}

/* 英文挖空填空區 */
.english-section {
  padding: 16px 20px 14px;
  background: #fafcff;
  border-radius: 0 0 24px 24px;
}

.english-sentence-container {
  font-size: 18px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* 填空槽 Slot */
.blank-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  height: 36px;
  background: #e2e8f0;
  border-radius: 10px;
  padding: 0 10px;
  border: 2px dashed #94a3b8;
  transition: all 0.2s ease;
  font-weight: 700;
  color: #1e3a8a;
  cursor: pointer;
  font-size: 17px;
}

.blank-slot.has-input {
  border-style: solid;
  border-color: #60a5fa;
  background: #eff6ff;
}

.blank-slot.correct {
  background: #dcfce7;
  border-color: #22c55e;
  color: #15803d;
}

.blank-slot.near {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #b45309;
}

.blank-slot.wrong {
  background: #fee2e2;
  border-color: #ef4444;
  color: #b91c1c;
  animation: shake 0.3s ease;
}

.blank-slot.speech-filled {
  background: #e0e7ff;
  border-color: #6366f1;
  border-style: solid;
  color: #3730a3;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.28);
  animation: pulse-slot 0.8s ease-in-out infinite alternate;
  transform: scale(1.05);
}

@keyframes pulse-slot {
  0% { transform: scale(1.02); box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2); }
  100% { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.35); }
}

.user-answer-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.user-answer-label {
  font-size: 14px;
  font-weight: 600;
  color: #475569;
}
.user-answer-value {
  font-size: 16px;
  font-weight: 700;
  color: #1e3a8a;
  background: #ffffff;
  padding: 3px 12px;
  border-radius: 8px;
  border: 1px solid #94a3b8;
  letter-spacing: 0.5px;
}

.source-credit {
  font-size: 13px;
  color: #b0b9c5;
  margin-top: 18px;
  text-align: right;
  font-weight: 500;
}

/* 側邊輔助按鈕 */
.floating-side-action {
  position: absolute;
  right: 18px;
  bottom: 180px;
}

.circle-side-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #c7d2fe;
  color: #6366f1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.circle-side-btn:active {
  transform: scale(0.9);
}

/* 底部操作控制區 (麥克風 / 查看提示 / 鍵盤模式) */
.bottom-controls-container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 10px 24px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  background: transparent;
}

/* 大麥克風語音輸入按鈕 */
.mic-btn-wrapper {
  position: relative;
  margin-bottom: 8px;
}

.mic-pulse-ring {
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
  border-radius: 50%;
  border: 3px solid rgba(139, 92, 246, 0.4);
  animation: pulse 1.8s infinite;
  pointer-events: none;
  display: none;
}

.mic-btn {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: #ffffff;
  border: 4px solid #e0e7ff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.22);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
}

.mic-btn svg {
  width: 46px;
  height: 46px;
  transition: transform 0.2s ease;
}

.mic-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(124, 58, 237, 0.3);
}

.mic-btn:active {
  transform: scale(0.92);
}

.mic-btn.listening {
  background: #8b5cf6;
  border-color: #c4b5fd;
}

.mic-btn.listening svg {
  fill: #ffffff;
  animation: bounce 0.6s infinite alternate;
}

.mic-btn.listening + .mic-pulse-ring {
  display: block;
}

/* 底部左右功能鍵 */
.bottom-actions-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
}

.bottom-action-btn {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #7c3aed;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: opacity 0.2s ease;
}

.bottom-action-btn .btn-icon-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ede9fe;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: #7c3aed;
}

.bottom-action-btn:active {
  opacity: 0.7;
}

/* 鍵盤輸入彈出抽屜 / 面板 */
.input-drawer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ffffff;
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.15);
  padding: 20px 20px 24px;
  transform: translateY(105%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 10;
}

.input-drawer.open {
  transform: translateY(0);
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.drawer-title {
  font-size: 16px;
  font-weight: 700;
  color: #1f2937;
}

.close-drawer-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  color: #94a3b8;
  cursor: pointer;
}

.custom-input-box {
  width: 100%;
  padding: 12px 16px;
  font-size: 18px;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  outline: none;
  transition: border-color 0.2s ease;
  font-weight: 600;
}

.custom-input-box:focus {
  border-color: #7c3aed;
}

.submit-answer-btn {
  width: 100%;
  margin-top: 14px;
  padding: 14px;
  background: #7c3aed;
  color: #ffffff;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease;
}

.submit-answer-btn:active {
  background: #6d28d9;
}

/* 解析與回饋彈出層 */
.result-modal {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ffffff;
  border-radius: 30px 30px 0 0;
  box-shadow: 0 -12px 35px rgba(0, 0, 0, 0.18);
  padding: 24px 20px 28px;
  transform: translateY(105%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 20;
}

.result-modal.open {
  transform: translateY(0);
}

.result-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.result-icon-badge {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #ffffff;
}

.result-icon-badge.correct {
  background: #10b981;
}

.result-icon-badge.near {
  background: #f59e0b;
}

.result-icon-badge.wrong {
  background: #ef4444;
}

.result-status-title {
  font-size: 19px;
  font-weight: 800;
}

.result-status-title.correct {
  color: #059669;
}

.result-status-title.near {
  color: #d97706;
}

.result-status-title.wrong {
  color: #dc2626;
}

.result-body {
  font-size: 15px;
  color: #374151;
  line-height: 1.6;
  margin-bottom: 18px;
}

.near-match-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #b45309;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
  margin-bottom: 8px;
}

.result-explanation-box {
  background: #f8fafc;
  border-left: 4px solid #7c3aed;
  padding: 10px 14px;
  border-radius: 6px;
  margin-top: 8px;
  font-size: 14px;
  color: #475569;
}

/* AI 專屬深度診斷卡片樣式 */
.ai-analysis-card {
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  border: 1.5px solid #c4b5fd;
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 14px;
  animation: popIn 0.3s ease;
}

.ai-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #6d28d9;
  margin-bottom: 8px;
}

.ai-card-header .ai-spark-icon {
  font-size: 16px;
}

.ai-card-header .ai-model-tag {
  margin-left: auto;
  font-size: 11px;
  background: #7c3aed;
  color: #ffffff;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 700;
}

.ai-card-content {
  font-size: 14px;
  color: #374151;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 8px;
}

.ai-ask-btn {
  padding: 13px 14px;
  background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
  color: #ffffff;
  border: none;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
  transition: transform 0.15s ease, opacity 0.2s ease;
  white-space: nowrap;
}

.ai-ask-btn:active {
  transform: scale(0.95);
  opacity: 0.9;
}

.ai-ask-btn.loading {
  background: #a78bfa;
  cursor: wait;
}

.next-q-btn {
  flex: 1;
  padding: 13px;
  background: #1e293b;
  color: #ffffff;
  border: none;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(30, 41, 59, 0.2);
  white-space: nowrap;
}

.tts-replay-btn {
  padding: 13px 14px;
  background: #ede9fe;
  color: #6d28d9;
  border: none;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

/* 提示 Modal */
.hint-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.hint-modal-overlay.open {
  display: flex;
}

.hint-card {
  background: #ffffff;
  width: 100%;
  max-width: 340px;
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
  text-align: center;
  animation: popIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.hint-card h3 {
  font-size: 18px;
  color: #1e293b;
  margin-bottom: 12px;
}

.hint-text {
  font-size: 15px;
  color: #475569;
  line-height: 1.6;
  margin-bottom: 20px;
}

.hint-close-btn {
  width: 100%;
  padding: 12px;
  background: #3b82f6;
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

/* 動畫設定 */
@keyframes pulse {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.22); opacity: 0; }
  100% { transform: scale(1.22); opacity: 0; }
}

@keyframes bounce {
  0% { transform: translateY(0); }
  100% { transform: translateY(-4px); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* 狀態訊息 Toast */
.speech-toast {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 41, 59, 0.9);
  color: #ffffff;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  z-index: 50;
  display: none;
  white-space: nowrap;
}

/* ====================================================
   設定選項彈窗 (Settings Modal) 樣式
==================================================== */
.settings-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 60;
  padding: 20px;
}

.settings-modal-overlay.open {
  display: flex;
}

.settings-card {
  background: #ffffff;
  width: 100%;
  max-width: 375px;
  border-radius: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  overflow: hidden;
  animation: popIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #f1f5f9;
}

.settings-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-icon {
  font-size: 20px;
}

.settings-header h3 {
  font-size: 17px;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
}

.settings-close-btn {
  background: #f1f5f9;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 14px;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.settings-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.settings-body {
  padding: 16px 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-group {
  background: #f8fafc;
  border-radius: 16px;
  padding: 14px 16px;
  border: 1px solid #edf2f7;
}

.group-title {
  font-size: 13px;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.settings-row:not(:last-child) {
  border-bottom: 1px dashed #e2e8f0;
}

.row-label {
  font-size: 14px;
  font-weight: 600;
  color: #334155;
}

/* 快速跳題輸入群組 */
.jump-input-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.jump-input-group input {
  width: 60px;
  padding: 6px 8px;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
  outline: none;
}

.jump-input-group input:focus {
  border-color: #7c3aed;
}

.jump-btn {
  background: #7c3aed;
  color: #ffffff;
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.jump-btn:hover {
  background: #6d28d9;
}

/* 下拉選單 */
.settings-select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  outline: none;
  cursor: pointer;
}

/* 開關切換 Slider */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
  background-color: #7c3aed;
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* AI 狀態標籤 */
.ai-status-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
}

.ai-status-pill.online {
  background: #dcfce7;
  color: #15803d;
}

/* 重置按鈕 */
.reset-stats-btn {
  width: 100%;
  padding: 10px;
  background: #ffffff;
  color: #e11d48;
  border: 1.5px solid #fecdd3;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.reset-stats-btn:hover {
  background: #ffe4e6;
}

/* ====================================================
   模式切換分頁 (Mode Tabs Bar)
==================================================== */
.mode-tabs-bar {
  display: flex;
  background: rgba(241, 245, 249, 0.85);
  padding: 4px;
  border-radius: 14px;
  margin-top: 10px;
  gap: 4px;
}

.mode-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.mode-tab.active {
  background: #ffffff;
  color: #7c3aed;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.12);
}

/* ====================================================
   情境對話視圖 (Roleplay View)
==================================================== */
.roleplay-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 6px 16px 14px;
  overflow: hidden;
  height: 100%;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

.roleplay-scenario-card {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #ffffff;
  border-radius: 14px;
  padding: 8px 12px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.15);
  margin-bottom: 6px;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.scenario-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.scenario-badge-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.scenario-tag {
  background: #7c3aed;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
}

.scenario-title-inline {
  font-size: 13.5px;
  font-weight: 700;
  color: #f8fafc;
  margin-left: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}

.scenario-mini-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.scenario-persuasion-badge {
  background: rgba(236, 72, 153, 0.25);
  color: #f472b6;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
}

.scenario-chapters-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}

.scenario-chapters-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.scenario-expand-arrow {
  font-size: 10px;
  color: #94a3b8;
  transition: transform 0.2s ease;
}

.scenario-expand-arrow.open {
  transform: rotate(180deg);
}

.scenario-details-drawer {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  animation: fadeIn 0.2s ease;
}

.scenario-level {
  background: rgba(255, 255, 255, 0.15);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
}

.scenario-step-badge {
  margin-left: auto;
  font-size: 11px;
  color: #94a3b8;
  font-weight: 600;
}

.scenario-mission-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.persuasion-container {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.persuasion-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #94a3b8;
  font-weight: 600;
}

.persuasion-track {
  height: 5px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 5px;
  overflow: hidden;
}

.persuasion-fill {
  height: 100%;
  background: linear-gradient(90deg, #ec4899, #8b5cf6);
  border-radius: 5px;
  transition: width 0.4s ease;
}

/* 對話串流紀錄區 (極大化閱讀與互動空間) */
.roleplay-chat-stream {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 6px 4px;
  margin-bottom: 6px;
}

.chat-bubble {
  display: flex;
  flex-direction: column;
  max-width: 90%;
  animation: popIn 0.22s ease-out;
}

.chat-bubble.npc {
  align-self: flex-start;
}

.chat-bubble.user {
  align-self: flex-end;
}

.bubble-sender {
  font-size: 11.5px;
  color: #64748b;
  font-weight: 700;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-bubble.user .bubble-sender {
  justify-content: flex-end;
}

.bubble-content {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15.5px;
  line-height: 1.48;
  font-weight: 500;
  letter-spacing: 0.2px;
}

.chat-bubble.npc .bubble-content {
  background: #ffffff;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  border: 1px solid #f1f5f9;
}

.chat-bubble.user .bubble-content {
  background: #7c3aed;
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
}

.bubble-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
}

.bubble-btn {
  background: #f1f5f9;
  border: none;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 12px;
  color: #475569;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s;
}

.bubble-btn:hover {
  background: #e2e8f0;
}

.bubble-chinese-trans {
  margin-top: 6px;
  font-size: 13px;
  color: #64748b;
  padding: 6px 8px;
  background: #f8fafc;
  border-radius: 8px;
  display: none;
}

.bubble-better-tip {
  margin-top: 6px;
  font-size: 12.5px;
  color: #7c3aed;
  background: #f5f3ff;
  border-left: 3px solid #7c3aed;
  padding: 6px 10px;
  border-radius: 0 8px 8px 0;
}

/* 靈感建議標籤欄 (Suggestion Chips Drawer) */
.suggestion-chips-drawer {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  scrollbar-width: none;
  animation: fadeIn 0.2s ease;
}

.suggestion-chips-drawer::-webkit-scrollbar {
  display: none;
}

.suggestion-chip {
  flex-shrink: 0;
  background: #f3e8ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
  padding: 5px 11px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.suggestion-chip:hover {
  background: #e9d5ff;
}

/* 對話底部輸入列 (極簡單行整合) */
.roleplay-bottom-bar {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  padding: 6px 8px;
  border-radius: 18px;
  box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.05);
  border: 1px solid #f1f5f9;
}

.roleplay-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.roleplay-mic-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #7c3aed;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(124, 58, 237, 0.3);
  transition: transform 0.15s, background 0.15s;
}

.roleplay-mic-btn:active, .roleplay-mic-btn.recording {
  transform: scale(0.92);
  background: #ef4444;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.5);
}

.roleplay-text-input {
  flex: 1;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s;
  min-width: 0;
}

.roleplay-text-input:focus {
  border-color: #7c3aed;
}

.roleplay-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.roleplay-icon-btn:active {
  transform: scale(0.92);
  background: #f1f5f9;
}

.roleplay-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: #3b82f6;
  color: #ffffff;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.roleplay-send-btn:hover {
  background: #2563eb;
}

.roleplay-hint-btn:hover, .roleplay-reset-btn:hover {
  background: #f1f5f9;
  color: #1e293b;
}

/* 任務通關慶祝卡片 */
.victory-card {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border: 2px solid #6ee7b7;
  border-radius: 18px;
  padding: 16px;
  text-align: center;
  margin: 10px 0;
  animation: popIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.victory-title {
  font-size: 18px;
  font-weight: 800;
  color: #065f46;
  margin-bottom: 6px;
}

.victory-desc {
  font-size: 13.5px;
  color: #047857;
  line-height: 1.5;
}

/* 查看全部章節按鈕 */
.scenario-chapters-btn {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.scenario-chapters-btn:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* 30 個情境選單列表 */
.scenarios-list-container {
  padding: 14px 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scenario-list-card {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.scenario-list-card:hover {
  border-color: #7c3aed;
  background: #f5f3ff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.1);
}

.scenario-list-card.active {
  border-color: #7c3aed;
  background: #f5f3ff;
  border-width: 2px;
}

.scenario-list-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.scenario-card-num {
  font-size: 11px;
  font-weight: 800;
  color: #7c3aed;
  background: #ede9fe;
  padding: 2px 6px;
  border-radius: 6px;
}

.scenario-card-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #1e293b;
  flex: 1;
}

.scenario-card-lvl {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: #e2e8f0;
  color: #475569;
}

.scenario-card-goal {
  font-size: 12px;
  color: #64748b;
  line-height: 1.4;
}

/* ====================================================
   API Key 設定區塊精緻樣式
==================================================== */
.api-key-field {
  margin-bottom: 12px;
}

.field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.field-label {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.field-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #64748b;
}

.field-badge.configured {
  background: #dcfce7;
  color: #15803d;
}

.input-with-toggle {
  display: flex;
  position: relative;
  align-items: center;
}

.api-input {
  width: 100%;
  padding: 10px 42px 10px 12px;
  font-size: 13.5px;
  font-family: monospace;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  color: #0f172a;
  outline: none;
  transition: all 0.2s ease;
}

.api-input:focus {
  background: #ffffff;
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.toggle-pwd-btn {
  position: absolute;
  right: 8px;
  background: transparent;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  opacity: 0.65;
  transition: opacity 0.2s;
}

.toggle-pwd-btn:hover {
  opacity: 1;
}

.save-api-btn {
  flex: 1;
  padding: 10px 14px;
  background: #7c3aed;
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(124, 58, 237, 0.25);
  transition: all 0.15s ease;
}

.save-api-btn:active {
  transform: scale(0.97);
  background: #6d28d9;
}

.test-api-btn {
  padding: 10px 14px;
  background: #f1f5f9;
  color: #334155;
  font-size: 13.5px;
  font-weight: 700;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.test-api-btn:active {
  background: #e2e8f0;
}

/* ====================================================
   錄音中呼吸燈與波形脈衝動畫 (Android/Web 語音辨識)
==================================================== */
.mic-btn.recording,
.roleplay-mic-btn.recording {
  background: #ef4444 !important;
  border-color: #fca5a5 !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  animation: pulse-recording 1.2s infinite cubic-bezier(0.66, 0, 0, 1) !important;
}

.mic-btn.recording svg .wave-bar {
  animation: wave-bounce 0.6s infinite ease-in-out alternate !important;
}

.mic-btn.recording svg .wb-1 { animation-delay: 0.1s !important; }
.mic-btn.recording svg .wb-2 { animation-delay: 0.3s !important; }
.mic-btn.recording svg .wb-3 { animation-delay: 0.2s !important; }
.mic-btn.recording svg .wb-4 { animation-delay: 0.4s !important; }

@keyframes wave-bounce {
  0% { transform: scaleY(0.4); transform-origin: center; }
  100% { transform: scaleY(1.35); transform-origin: center; }
}

@keyframes pulse-recording {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 0 0 16px rgba(239, 68, 68, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}




