:root {
  --bg: #070a12;
  --card-bg: #0f172a;
  --card-border: #1e293b;
  --accent: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.25);
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.25);
  --warning: #facc15;
  --danger: #ef4444;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --header-h: 56px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  user-select: none;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

/* 頂部 Header */
header {
  height: var(--header-h);
  background: #0b1120;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
  z-index: 20;
}

.brand {
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 0.5px;
}

.brand .logo-icon {
  font-size: 1.35rem;
  filter: drop-shadow(0 0 8px var(--accent));
}

.brand span.highlight {
  color: var(--accent);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.speed-selector {
  display: flex;
  align-items: center;
  background: #1e293b;
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 2px;
  gap: 2px;
}

.speed-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.speed-btn.active {
  background: var(--accent);
  color: #04101e;
  box-shadow: 0 0 10px var(--accent-glow);
}

.badge {
  font-size: 0.8rem;
  background: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid rgba(56, 189, 248, 0.4);
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.btn-header {
  font-size: 0.82rem;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--card-border);
  background: #162032;
  color: #e2e8f0;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-header:hover {
  background: #1e293b;
  border-color: var(--accent);
  color: #ffffff;
}

.btn-present {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border-color: #a855f7;
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(124, 58, 237, 0.35);
}

.btn-present:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

/* 滿版零捲軸三欄式儀表板 */
#dashboard {
  display: grid;
  grid-template-columns: 240px 1.25fr 1.35fr;
  height: calc(100vh - var(--header-h));
  width: 100vw;
  background: var(--bg);
  transition: all 0.3s;
}

/* 欄位 1: 題號導航欄 */
#nav-panel {
  background: #090e1a;
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow: hidden;
}

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

.panel-title {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.q-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  overflow-y: auto;
  flex: 1;
  padding-right: 6px;
}

.q-grid::-webkit-scrollbar {
  width: 5px;
}

.q-grid::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}

.q-btn {
  aspect-ratio: 1;
  background: #111a2f;
  border: 1px solid var(--card-border);
  color: var(--text);
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.q-btn:hover {
  border-color: var(--accent);
  background: #1e293b;
  transform: translateY(-2px);
}

.q-btn.active {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}

.q-btn.answered-correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

/* 欄位 2: 慢速清晰詳解與選項 */
#content-panel {
  background: #080c16;
  border-right: 1px solid var(--card-border);
  padding: 22px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow-y: auto;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.q-tag {
  font-size: 0.8rem;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 700;
}

.analogy-pill {
  font-size: 0.8rem;
  background: rgba(250, 204, 21, 0.12);
  color: var(--warning);
  border: 1px solid rgba(250, 204, 21, 0.3);
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
}

.q-title {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.6;
  color: #ffffff;
  margin-bottom: 14px;
  transition: color 0.3s;
}

.q-title.reading {
  color: #38bdf8;
  text-shadow: 0 0 8px var(--accent-glow);
}

.opts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.opt-item {
  padding: 10px 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  position: relative;
}

.opt-item:hover {
  border-color: var(--accent);
  background: #17233d;
}

.opt-item.reading-highlight {
  border-color: #facc15;
  background: rgba(250, 204, 21, 0.1);
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.2);
}

.opt-item.correct {
  background: rgba(16, 185, 129, 0.2) !important;
  border-color: var(--success) !important;
  color: #34d399;
  font-weight: bold;
}

.opt-item.wrong {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: var(--danger) !important;
  color: #f87171;
}

/* 慢速引導卡片 */
.step-card {
  background: #0f172a;
  border: 1px solid var(--card-border);
  border-left: 5px solid var(--accent);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
}

.step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.step-title {
  font-size: 0.88rem;
  color: var(--warning);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-badge {
  font-size: 0.76rem;
  background: #1e293b;
  color: var(--accent);
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 700;
}

.step-body {
  font-size: 0.98rem;
  line-height: 1.7;
  color: #e2e8f0;
}

/* 語音波紋指示器 */
.audio-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 14px;
}

.audio-bar {
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
  animation: soundBars 0.8s ease-in-out infinite alternate;
}

.audio-bar:nth-child(2) { animation-delay: 0.2s; }
.audio-bar:nth-child(3) { animation-delay: 0.4s; }
.audio-bar:nth-child(4) { animation-delay: 0.1s; }
.audio-bar:nth-child(5) { animation-delay: 0.3s; }

@keyframes soundBars {
  0% { height: 3px; }
  100% { height: 14px; }
}

/* 控制列與按鈕 */
.action-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-play {
  background: linear-gradient(135deg, #0284c7, #2563eb);
  color: white;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.btn-play:hover {
  filter: brightness(1.15);
  transform: translateY(-2px);
}

.btn-ask {
  background: #8b5cf6;
  color: white;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
}

.btn-ask:hover {
  filter: brightness(1.15);
  transform: translateY(-2px);
}

.btn-ask.recording {
  background: var(--danger);
  animation: pulse 1s infinite;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.6);
}

.btn-sub {
  background: #1e293b;
  color: var(--text-muted);
  border: 1px solid var(--card-border);
}

.btn-sub:hover {
  background: #334155;
  color: #ffffff;
}

/* 欄位 3: 高畫質細節動畫舞台 */
#anim-panel {
  background: #060913;
  display: flex;
  flex-direction: column;
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.stage-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.stage-phase-tag {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 700;
}

.canvas-container {
  flex: 1;
  width: 100%;
  height: 100%;
  background: #050811;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.7);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* 動態文字字幕條 (Sync Banner) */
.caption-banner {
  position: absolute;
  bottom: 16px;
  left: 18px;
  right: 18px;
  background: rgba(11, 17, 33, 0.94);
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.96rem;
  color: #fde047;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  min-height: 48px;
  display: flex;
  align-items: center;
  line-height: 1.5;
  transition: all 0.3s;
}

/* 語音問答彈窗 / 抽屜 (Voice Modal) */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #0f172a;
  border: 1px solid var(--accent);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6), 0 0 24px var(--accent-glow);
  width: 520px;
  max-width: 90vw;
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-input {
  width: 100%;
  padding: 12px 14px;
  background: #1e293b;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: #ffffff;
  font-size: 0.95rem;
  outline: none;
}

.modal-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.modal-select {
  width: 100%;
  padding: 10px 12px;
  background: #1e293b;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: #ffffff;
  font-size: 0.95rem;
  outline: none;
}

.modal-quick-queries {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-chip {
  font-size: 0.8rem;
  background: #1e293b;
  border: 1px solid #334155;
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-chip:hover {
  border-color: var(--accent);
  color: #ffffff;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* =========================================================
   🎬 簡報演示模式 (Presentation Mode)
   ========================================================= */
body.in-presentation #dashboard {
  grid-template-columns: 0px 1fr 1.6fr;
}

body.in-presentation #nav-panel {
  display: none;
}

body.in-presentation .q-title {
  font-size: 1.35rem;
  line-height: 1.7;
}

body.in-presentation .opt-item {
  font-size: 1.05rem;
  padding: 14px 18px;
}

body.in-presentation .step-body {
  font-size: 1.15rem;
  line-height: 1.8;
}

body.in-presentation .caption-banner {
  font-size: 1.15rem;
  padding: 16px 24px;
}

.presenter-floating-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.5);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6), 0 0 20px var(--accent-glow);
  backdrop-filter: blur(12px);
  padding: 8px 16px;
  border-radius: 40px;
  display: none;
  align-items: center;
  gap: 12px;
  z-index: 90;
}

body.in-presentation .presenter-floating-bar {
  display: flex;
}

.present-btn {
  background: transparent;
  border: none;
  color: #e2e8f0;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.present-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
}

.present-btn.primary {
  background: var(--accent);
  color: #050b17;
}

.present-btn.danger {
  color: #f87171;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}
