@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;900&family=Inter:wght@400;600;700&display=swap');

/* 默认夜间模式变量 */
:root { 
  --bg: #0d0f12; 
  --card: #1a1d24; 
  --accent: #10b981; 
  --border: #2a2f3a; 
  --danger: #ef4444; 
  --gold: #F59E0B; 
  --text-main: #E2E8F0;
  --text-sub: #94a3b8;
  --btn-bg: #222630;
  --nav-bg: rgba(13,15,18,0.9);
  --modal-bg: rgba(22, 25, 30, 0.85);
  --overlay-bg: rgba(0,0,0,0.6);
  --mono: 'JetBrains Mono', monospace; 
  --sans: 'Inter', sans-serif; 
}

/* 自动监听系统日间模式，无缝覆写变量 */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f8fafc; 
    --card: #ffffff; 
    --border: #e2e8f0; 
    --text-main: #0f172a;
    --text-sub: #64748b;
    --btn-bg: #f1f5f9;
    --nav-bg: rgba(255,255,255,0.9);
    --modal-bg: rgba(255, 255, 255, 0.85);
    --overlay-bg: rgba(0,0,0,0.3);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: var(--sans); }

/* 加入 transition 让主题切换时有丝滑的渐变 */
body { background-color: var(--bg); color: var(--text-main); height: 100dvh; display: flex; flex-direction: column; overflow: hidden; transition: background-color 0.3s, color 0.3s; }

#startOverlay { position: fixed; inset: 0; background: rgba(0,0,0,0.95); z-index: 9999; display: flex; flex-direction: column; justify-content: center; align-items: center; cursor: pointer; }
.start-btn { padding: 15px 35px; background: var(--accent); color: #000; font-size: 20px; font-weight: 700; border-radius: 50px; animation: breathe 2s infinite; }
@keyframes breathe { 0%, 100% { transform: scale(1); box-shadow: 0 0 15px rgba(16,185,129,0.2); } 50% { transform: scale(1.05); box-shadow: 0 0 30px rgba(16,185,129,0.6); } }

.top-nav { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; background: var(--nav-bg); border-bottom: 1px solid var(--border); z-index: 10; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: background 0.3s, border-color 0.3s; }
.back-btn { color: var(--text-sub); text-decoration: none; font-size: 15px; font-weight: 600;}
.nav-title { font-weight: 600; font-size: 15px; color: var(--text-main); letter-spacing: 1px; }
.settings-btn { background: transparent; border: none; color: var(--text-sub); font-size: 22px; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center;}
.settings-btn:active { transform: scale(0.9); color: var(--accent); }

.workspace { flex: 1; display: flex; flex-direction: column; width: 100%; max-width: 1600px; margin: 0 auto; padding: 12px 20px; gap: 12px; min-height: 0; align-items: center; }
.control-row { flex-shrink: 0; display: flex; gap: 8px; width: 100%; max-width: 1000px; }
select { flex: 1; background: var(--btn-bg); color: var(--text-main); border: 1px solid var(--border); padding: 10px; border-radius: 8px; font-weight: 600; outline: none; font-size: 13px; appearance: none; transition: background 0.3s, color 0.3s, border-color 0.3s; }

.player-section { flex: 1 1 auto; min-height: 0; width: 100%; background: #000; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); border-bottom: 3px solid var(--accent); box-shadow: 0 5px 20px rgba(0,0,0,0.2); display: flex; align-items: center; justify-content: center; position: relative; }
video { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: contain; }

.sub-card { flex-shrink: 0; width: 100%; max-width: 1000px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px 25px; text-align: center; display: flex; flex-direction: column; justify-content: center; gap: 8px; position: relative; overflow: hidden; min-height: 90px; transition: background 0.3s, border-color 0.3s; }
.progress-line { position: absolute; bottom: 0; left: 0; height: 3px; background: var(--accent); width: 0%; transition: width 0.3s; }
.sub-en { font-size: 20px; font-weight: 700; color: var(--text-main); line-height: 1.3; transition: color 0.3s; }
.sub-cn { font-size: 14px; color: var(--text-sub); line-height: 1.3; display: none; transition: color 0.3s; }
.sub-cn.visible { display: block; }

.bottom-dock { width: 100%; max-width: 1000px; display: flex; flex-direction: column; gap: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); flex-shrink: 0; }
.nav-button-group { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.nav-btn { background: var(--btn-bg); color: var(--text-main); border: 1px solid var(--border); padding: 15px 0; border-radius: 10px; font-size: 20px; cursor: pointer; transition: 0.2s; display: flex; justify-content: center; align-items: center; }
.nav-btn:active { transform: scale(0.92); opacity: 0.8; }
.nav-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.nav-btn.primary { background: rgba(16,185,129,0.1); border-color: var(--accent); color: var(--accent); }

.action-button-matrix { width: 100%; display: flex; }
.action-btn { width: 100%; padding: 16px 0; border: none; border-radius: 12px; font-size: 18px; font-weight: 700; cursor: pointer; transition: 0.2s; background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: #000; box-shadow: 0 4px 15px rgba(16,185,129,0.2); }
.action-btn:active { transform: scale(0.97); }
.action-btn.recording { background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%); color: #fff; box-shadow: 0 4px 20px rgba(239,68,68,0.4); animation: recPulse 1s infinite alternate; }
.action-btn:disabled { background: var(--btn-bg); color: var(--text-sub); box-shadow: none; cursor: not-allowed; border: 1px solid var(--border); }
@keyframes recPulse { 0% { transform: scale(1); } 100% { transform: scale(1.02); } }

@media (min-width: 768px) {
  .bottom-dock { flex-direction: row; align-items: stretch; }
  .nav-button-group { flex: 0 0 auto; display: flex; gap: 12px; width: auto; }
  .nav-btn { width: 75px; padding: 0; font-size: 24px; }
  .action-button-matrix { flex: 1; }
  .action-btn { height: 100%; font-size: 20px; }
  .sub-card { min-height: 110px; }
  .sub-en { font-size: 24px; }
  .sub-cn { font-size: 15px; }
}

.modal-overlay { position: fixed; inset: 0; background: var(--overlay-bg); display: none; justify-content: center; align-items: center; z-index: 1000; opacity: 0; transition: opacity 0.2s, background 0.3s; padding: 20px; }
.modal-overlay.show { display: flex; opacity: 1; }
.modal-content { background: var(--modal-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid var(--border); border-radius: 20px; width: 100%; max-width: 300px; padding: 25px 20px; text-align: center; transform: scale(0.95); transition: 0.2s; box-shadow: 0 15px 50px rgba(0,0,0,0.3); display: flex; flex-direction: column; align-items: center; }
.modal-overlay.show .modal-content { transform: scale(1); }

.eval-loader { display: none; flex-direction: column; align-items: center; gap: 15px; padding: 20px 0; }
.spinner { width: 40px; height: 40px; border: 4px solid rgba(16,185,129,0.2); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

.score-view { display: none; flex-direction: column; width: 100%; }
.score-huge { font-size: 56px; font-weight: 900; font-family: var(--mono); line-height: 1; margin-bottom: 5px; transition: color 0.3s; }
.chart-container { width: 100%; max-width: 140px; margin: 0 auto 10px auto; aspect-ratio: 1; }

.feedback-section { margin-bottom: 15px; width: 100%; }
.word-highlight-box { background: var(--btn-bg); padding: 10px; border-radius: 8px; border: 1px solid var(--border); font-size: 14px; line-height: 1.6; font-weight: 600; margin-bottom: 8px; text-align: center; word-wrap: break-word; color: var(--text-main); }
.word-highlight-box span { margin: 0 2px; }
.w-good { color: var(--accent); }
.w-warn { color: var(--gold); border-bottom: 2px solid var(--gold); }
.w-bad { color: var(--danger); text-decoration: line-through; opacity: 0.8; }
.advice-text { background: var(--btn-bg); color: var(--text-sub); font-size: 11px; padding: 10px; border-radius: 6px; text-align: left; }

.modal-btn-group { display: flex; gap: 8px; width: 100%; }
.modal-btn { flex: 1; padding: 12px 0; border-radius: 10px; border: none; font-size: 14px; font-weight: 700; cursor: pointer; transition: 0.2s; }
.modal-btn.primary { color: #fff; } /* 动态评分按钮默认给白字，如果是淡色背景JS可调 */
.modal-btn.secondary { background: var(--btn-bg); color: var(--text-main); border: 1px solid var(--border); }
.modal-btn:active { transform: scale(0.95); }

.report-header { font-size: 20px; color: var(--text-main); font-weight: 700; margin-bottom: 15px; }
.report-stats { display: flex; justify-content: space-around; background: var(--btn-bg); padding: 15px; border-radius: 12px; margin-bottom: 15px; border: 1px solid var(--border); width: 100%; }
.stat-item { display: flex; flex-direction: column; align-items: center; }
.stat-val { font-size: 24px; font-family: var(--mono); font-weight: 900; }
.stat-lbl { font-size: 11px; color: var(--text-sub); }
.btn-sync { background: var(--btn-bg); color: var(--text-main); border: 1px solid var(--border); margin-bottom: 8px; width: 100%; }

.settings-panel { text-align: left; width: 100%; display: none; flex-direction: column; gap: 15px; }
.settings-title { font-weight: bold; color: var(--text-main); font-size: 18px; margin-bottom: 5px; text-align: center; }
.setting-item label { font-size: 12px; color: var(--text-sub); display: block; margin-bottom: 5px; }
