/* ==========================================================================
   Design System: 柔和新擬物與呼吸感 (Soft Neumorphism & Clean Pastel)
   參考 UI/UX Pro Max 官方精選：health-wellness 系統
   特徵：雙向光影浮雕凸起 (neu-card)、凹陷內嵌槽 (neu-inset)、柔和天空藍與薄荷粉彩、Lora 與 Raleway 優雅字型
   ========================================================================== */

:root {
  /* 身心靈柔和新擬物色盤 (Pure & Breathing Neumorphism) */
  --primary-accent: #7EB8DA;       /* 晨曦清澈粉藍 */
  --secondary-accent: #95C7A5;     /* 靜謐鼠尾草青綠 */
  
  --neu-base: #EBEEF2;            /* 經典純淨白藍灰基底 */
  --neu-surface: #EBEEF2;
  --neu-card: #EBEEF2;

  --text-main: #2C3E50;           /* 深冷石板灰主文字 */
  --text-muted: #6B7C93;          /* 靜謐灰次級文字 */
  --text-subtle: #9AA7B7;

  /* 完美的左上柔光與右下軟影 (Pure Light Sculpting) */
  --shadow-neu-card: 10px 10px 24px rgba(166, 180, 200, 0.45), -10px -10px 24px #FFFFFF;
  --shadow-neu-card-hover: 14px 14px 28px rgba(166, 180, 200, 0.55), -14px -14px 28px #FFFFFF;
  
  --shadow-neu-pill: 5px 5px 12px rgba(166, 180, 200, 0.38), -5px -5px 12px #FFFFFF;
  --shadow-neu-btn: 6px 6px 14px rgba(166, 180, 200, 0.4), -6px -6px 14px #FFFFFF;
  --shadow-neu-btn-hover: 3px 3px 8px rgba(166, 180, 200, 0.45), -3px -3px 8px #FFFFFF;
  
  --shadow-neu-inset: inset 5px 5px 10px rgba(166, 180, 200, 0.38), inset -5px -5px 10px #FFFFFF;
  --shadow-neu-inset-subtle: inset 2px 2px 5px rgba(166, 180, 200, 0.25), inset -2px -2px 5px #FFFFFF;

  /* 幾何圓角 */
  --radius-card: 28px;
  --radius-inner: 20px;
  --radius-btn: 20px;
  --radius-pill: 9999px;

  /* 字型配對：英文 Inter ＋ 中文思源黑體 Noto Sans TC */
  --font-heading: "Inter", "Noto Sans TC", -apple-system, BlinkMacSystemFont, "PingFang TC", sans-serif;
  --font-body: "Inter", "Noto Sans TC", -apple-system, BlinkMacSystemFont, "PingFang TC", sans-serif;
}

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

body {
  background-color: var(--neu-base);
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
  padding: 52px 20px 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

/* 頂部原生 App 視窗拖曳區 (Window Drag Region) */
.window-drag-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  -webkit-app-region: drag;
  z-index: 999;
  pointer-events: auto;
}

/* 確保所有按鈕與可操作元件不會觸發視窗拖曳，保持互動靈敏 */
button, a, input, select, textarea, .modal, .card-item, .history-drawer {
  -webkit-app-region: no-drag;
}

/* 風格切換導覽列 */
.style-switcher-bar {
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-pill);
  padding: 10px 24px;
  border-radius: var(--radius-pill);
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 860px;
  width: 100%;
  flex-wrap: wrap;
}

.style-indicator {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.style-indicator strong {
  color: var(--text-main);
  font-weight: 700;
}

.style-links-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.style-nav-btn {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  background: var(--neu-surface);
  box-shadow: 2px 2px 5px rgba(166, 180, 200, 0.35), -2px -2px 5px #FFFFFF;
  transition: all 0.2s ease;
}

.style-nav-btn:hover {
  color: var(--text-main);
  transform: translateY(-1px);
}

.style-nav-btn.current {
  color: var(--text-main);
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-inset-subtle);
  font-weight: 700;
}

.app-container {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
}

/* ==========================================================================
   頁首：優雅大標與極簡新擬物語意膠囊
   ========================================================================== */
.app-header {
  text-align: center;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 38px;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 0;
  letter-spacing: -0.01em;
}

.rule-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-pill);
  padding: 8px 24px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.rule-unit {
  color: var(--text-main);
}

.rule-symbol {
  color: var(--text-subtle);
}

.rule-divider {
  color: var(--text-subtle);
  margin: 0 4px;
}

.rule-axiom {
  color: var(--primary-accent);
  font-weight: 700;
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-inset-subtle);
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
}

/* ==========================================================================
   模式切換：純粹新擬物滑動槽 (Pill Segmented Slider) ＋ 音效開關
   ========================================================================== */
.mode-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-bottom: 36px;
  flex-wrap: wrap;
}

.btn-sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--neu-surface);
  border: none;
  box-shadow: var(--shadow-neu-btn);
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.25s ease;
  user-select: none;
}

.btn-sound-toggle:hover {
  color: var(--text-main);
  box-shadow: var(--shadow-neu-card);
  transform: translateY(-1px);
}

.btn-sound-toggle.muted {
  color: var(--text-subtle);
  opacity: 0.7;
  box-shadow: var(--shadow-neu-inset-subtle);
}

.btn-sound-toggle.muted .sound-icon {
  filter: grayscale(1);
}

.mode-pill-group {
  display: inline-flex;
  background: var(--neu-surface);
  padding: 6px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-neu-inset);
  gap: 6px;
}

.mode-pill {
  border: none;
  background: transparent;
  padding: 9px 26px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.pill-icon {
  font-size: 15px;
}

.mode-pill.active {
  background: var(--neu-surface);
  color: var(--text-main);
  box-shadow: var(--shadow-neu-pill);
  font-weight: 700;
}

.mode-pill:hover:not(.active) {
  color: var(--text-main);
}

/* ==========================================================================
   雙卡片展示舞台 (Pure Neumorphic Stage)
   ========================================================================== */
.trainer-stage {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 26px;
  margin-bottom: 34px;
  position: relative;
}

.card-item {
  flex: 1;
  max-width: 350px;
  min-height: 550px;
  background: var(--neu-surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-neu-card);
  padding: 24px 20px 22px;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  cursor: pointer;
}

.card-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-neu-card-hover);
}

/* 卡片頭部 */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.role-tag {
  font-size: 12.5px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.03em;
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-inset-subtle);
}

.tag-a {
  color: var(--primary-accent);
}

.tag-b {
  color: var(--secondary-accent);
}

.btn-lock {
  background: var(--neu-surface);
  border: none;
  border-radius: var(--radius-pill);
  padding: 5px 13px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: var(--shadow-neu-btn);
  transition: all 0.2s ease;
}

.btn-lock:hover {
  color: var(--text-main);
  box-shadow: var(--shadow-neu-btn-hover);
}

/* 鎖定狀態：如物理開關按壓向內凹陷 (Inset) */
.btn-lock.pinned {
  color: var(--primary-accent);
  box-shadow: var(--shadow-neu-inset-subtle);
  font-weight: 700;
}

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* 老虎機視窗與滾動軌道 (Slot Machine Viewport & Reel) - 370px 完美遮罩 */
.slot-viewport {
  position: relative;
  width: 100%;
  height: 370px;
  overflow: hidden;
  border-radius: var(--radius-inner);
  margin-bottom: 16px;
  mask-image: linear-gradient(to bottom, transparent 0%, black 7%, black 93%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 7%, black 93%, transparent 100%);
}

.slot-reel-strip {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.slot-reel-strip.spinning {
  will-change: transform;
}

.slot-item {
  width: 100%;
  height: 370px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.slot-item .graphic-showcase {
  margin-bottom: 0;
  height: 100%;
  padding: 16px 10px;
}

.slot-reel-strip.spinning .slot-item {
  filter: blur(0.7px);
}

/* 1:1 純粹主體大圖窗框 (Photo Window) */
.card-photo-window {
  width: 255px;
  height: 255px;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 10px;
  border: none;
  box-shadow: none;
  background: transparent;
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-photo-window img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: high-quality;
  transform: translateZ(0);
}

/* 卡片定格微彈跳動畫 (Landing Snap - 下沉再回彈的物理慣性) */
.card-item.landing-snap {
  animation: cardLandingSnap 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.25);
}

@keyframes cardLandingSnap {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(6px) scale(0.995); }
  65% { transform: translateY(-2px) scale(1.005); }
  100% { transform: translateY(0) scale(1); }
}

/* 凹陷內嵌展示台：大面積純淨留白與呼吸感 */
.graphic-showcase {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--neu-surface);
  border-radius: var(--radius-inner);
  box-shadow: var(--shadow-neu-inset);
  padding: 26px 16px;
  margin-bottom: 16px;
  position: relative;
}

.card-number {
  position: absolute;
  top: 12px;
  left: 16px;
  font-family: var(--font-heading);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-subtle);
  background: var(--neu-surface);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-neu-pill);
}

/* 移除多餘的多層嵌套圓球：讓 Emoji 直接優雅呼吸懸浮 */
.emoji-circle-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.card-item:hover .emoji-circle-badge {
  transform: scale(1.1);
}

.symbol-emoji {
  font-size: 64px;
  line-height: 1;
  filter: drop-shadow(0 4px 10px rgba(166, 180, 200, 0.3));
}

.card-title {
  font-family: var(--font-heading);
  font-size: 27px;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 2px;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* 底部語意詮釋框 (Pure Soft Neumorphic Pill) */
.semantics-pill {
  background: var(--neu-surface);
  border-radius: var(--radius-inner);
  box-shadow: var(--shadow-neu-pill);
  padding: 14px 18px;
  text-align: center;
  border: none;
  transition: box-shadow 0.2s ease;
}

.semantics-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}

.card-theme-a .semantics-title {
  color: var(--primary-accent);
}

.card-theme-b .semantics-title {
  color: var(--secondary-accent);
}

.semantics-desc {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.45;
}

/* ==========================================================================
   中間對調按鈕 (Neu Floating Swap)
   ========================================================================== */
.swap-controller {
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-swap {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--neu-surface);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-neu-btn);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-swap:hover {
  transform: scale(1.1) rotate(180deg);
  box-shadow: var(--shadow-neu-card);
  color: var(--primary-accent);
}

.btn-swap:active {
  box-shadow: var(--shadow-neu-inset);
  transform: scale(0.96) rotate(180deg);
}

.swap-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--neu-surface);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-neu-pill);
  white-space: nowrap;
}

/* ==========================================================================
   學生作答提示區（固定置中出現於牌卡下方）
   ========================================================================== */
.student-turn-row {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: -14px 0 26px;
  width: 100%;
}

.student-turn-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-inset-subtle);
  padding: 12px 38px;
  border-radius: var(--radius-pill);
  font-size: 18px;
  font-weight: 700;
  color: #E05A2B;
  letter-spacing: 0.03em;
  user-select: none;
  cursor: pointer;
  transition: all 0.25s ease;
}

.student-turn-pill:hover {
  box-shadow: var(--shadow-neu-pill);
  transform: translateY(-2px);
}

.student-turn-pill:active {
  box-shadow: var(--shadow-neu-inset);
  transform: translateY(1px);
}

.student-turn-pill .turn-name {
  font-size: 34px;
  font-weight: 800;
  color: #111111;
  letter-spacing: 0.04em;
  margin: 0 8px;
  display: inline-block;
  line-height: 1.1;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 🎯 中獎定格時微彈跳強調動畫 */
.student-turn-pill.is-winner {
  animation: winnerPop 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes winnerPop {
  0% { transform: scale(0.92); }
  45% { transform: scale(1.10); box-shadow: var(--shadow-neu-card-hover); }
  100% { transform: scale(1); box-shadow: var(--shadow-neu-inset-subtle); }
}

/* 全螢幕紙花 Canvas */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
  display: none;
}

/* ==========================================================================
   操作按鈕列 (Pure Neumorphic Action Bar)
   ========================================================================== */
.action-bar {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 34px;
  flex-wrap: wrap;
}

.btn-main {
  background: var(--neu-surface);
  color: var(--text-main);
  border: none;
  border-radius: var(--radius-btn);
  padding: 14px 38px;
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-neu-btn);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
}

.btn-main:hover {
  box-shadow: var(--shadow-neu-card);
  transform: translateY(-2px);
  color: var(--primary-accent);
}

.btn-main:active {
  box-shadow: var(--shadow-neu-inset);
  transform: translateY(1px);
}

.btn-sub {
  background: var(--neu-surface);
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-btn);
  padding: 14px 30px;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-neu-btn);
  display: inline-flex;
  align-items: center;
  gap: 9px;
  transition: all 0.2s ease;
}

.btn-sub:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-neu-card);
  color: var(--text-main);
}

.btn-sub:active {
  box-shadow: var(--shadow-neu-inset);
  transform: translateY(1px);
}

.btn-icon {
  font-size: 18px;
}

/* ==========================================================================
   教師互動版專屬視覺 (Teacher Classroom Mode UI)
   ========================================================================== */
/* ==========================================================================
   全站模式與後台切換導覽 (Global App Switcher)
   ========================================================================== */
.app-switcher-bar {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  user-select: none;
}

.app-switcher-modes {
  display: inline-flex;
  align-items: center;
  background: var(--neu-surface);
  padding: 4px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-neu-inset);
  gap: 4px;
}

.app-switcher-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-pill);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.app-switcher-item:hover:not(.active) {
  color: var(--text-main);
}

.app-switcher-item.active {
  background: var(--neu-surface);
  color: var(--text-main);
  box-shadow: var(--shadow-neu-pill);
  font-weight: 700;
  cursor: default;
  pointer-events: none;
}

.app-switcher-admin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-pill);
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-pill);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.app-switcher-admin:hover {
  color: var(--text-main);
  box-shadow: 2px 2px 6px rgba(166, 180, 200, 0.45), -2px -2px 6px #FFFFFF;
}

.app-switcher-admin.active {
  background: var(--neu-surface);
  color: var(--text-main);
  box-shadow: var(--shadow-neu-inset);
  font-weight: 700;
  cursor: default;
  pointer-events: none;
}

.header-badge-row {
  margin-bottom: 10px;
}

.teacher-mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-pill);
  padding: 5px 16px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary-accent);
  letter-spacing: 0.04em;
}

/* 教師版操作按鈕 */
.btn-reveal {
  background: var(--neu-surface);
  color: #D9822B;
  border: none;
  border-radius: var(--radius-btn);
  padding: 14px 34px;
  font-family: var(--font-heading);
  font-size: 16.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 4px 4px 12px rgba(217, 130, 43, 0.25), -4px -4px 12px #FFFFFF;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: all 0.25s ease;
}

.btn-reveal:hover {
  transform: translateY(-2px);
  box-shadow: 6px 6px 16px rgba(217, 130, 43, 0.35), -6px -6px 16px #FFFFFF;
  color: #B56717;
}

.btn-reveal:active {
  box-shadow: inset 3px 3px 6px rgba(217, 130, 43, 0.3), inset -3px -3px 6px #FFFFFF;
  transform: translateY(1px);
}

.btn-reveal.is-revealed {
  color: var(--text-muted);
  box-shadow: var(--shadow-neu-btn);
}

.btn-hint {
  color: #5C7080;
}

.btn-hint:hover {
  color: #D9822B;
}

/* 課堂提問引導卡片 (Classroom Guiding Framework Board) */
.classroom-guide-banner {
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-card);
  border-radius: var(--radius-inner);
  padding: 22px 28px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn 0.3s ease;
}

.guide-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
}

.guide-badge {
  font-size: 12px;
  font-weight: 700;
  color: #D9822B;
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-pill);
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.04em;
  display: inline-block;
}

.guide-status {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-inset-subtle);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.teacher-mode .formula-box {
  display: none !important;
}



/* 思考提示懸浮氣泡 */
.hint-toast-banner {
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-card);
  border-radius: var(--radius-inner);
  padding: 14px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: fadeIn 0.3s ease;
  font-size: 14.5px;
  color: var(--text-main);
}

.hint-toast-tag {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-accent);
  white-space: nowrap;
}

/* ==========================================================================
   解讀靈感抽屜 (Neumorphic Accordion Card)
   ========================================================================== */
.insight-card {
  background: var(--neu-surface);
  border-radius: var(--radius-inner);
  box-shadow: var(--shadow-neu-card);
  padding: 22px 28px;
  margin-bottom: 24px;
  transition: all 0.3s ease;
}

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

.insight-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

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

.insight-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.insight-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-accent);
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-pill);
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.04em;
}

.toggle-btn {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-inset-subtle);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  transition: all 0.2s ease;
}

.insight-header:hover .toggle-btn {
  color: var(--text-main);
  box-shadow: var(--shadow-neu-pill);
}

.insight-content {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(166, 180, 200, 0.25);
  display: none;
}

.insight-content.open {
  display: block;
}

.formula-box {
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-inset);
  padding: 22px 24px;
  border-radius: var(--radius-inner);
  margin-bottom: 24px;
  line-height: 1.6;
}

/* 核心原則展示卡 */
.reading-core-principle {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.principle-eyebrow {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.principle-headline {
  font-family: var(--font-heading);
  font-size: 19px;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.principle-headline strong {
  color: var(--primary-accent);
  font-weight: 700;
}

/* A + B 語意結構對比網格 (新擬物浮雕卡片) */
.reading-structure-grid {
  display: flex;
  align-items: stretch;
  gap: 16px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.structure-card {
  flex: 1;
  min-width: 200px;
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-card);
  border-radius: var(--radius-inner);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: none;
}

.card-a-focus {
  border: none;
  background: linear-gradient(145deg, rgba(126, 184, 218, 0.16) 0%, var(--neu-surface) 75%);
  box-shadow: 8px 8px 20px rgba(126, 184, 218, 0.25), -8px -8px 20px #FFFFFF;
}

.card-b-modifier {
  border: none;
  background: linear-gradient(145deg, rgba(149, 199, 165, 0.18) 0%, var(--neu-surface) 75%);
  box-shadow: 8px 8px 20px rgba(149, 199, 165, 0.25), -8px -8px 20px #FFFFFF;
}

.card-a-focus .structure-tag {
  color: #266487;
  background: rgba(126, 184, 218, 0.22);
  box-shadow: var(--shadow-neu-inset-subtle);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  display: inline-block;
  align-self: flex-start;
  font-weight: 700;
}

.card-b-modifier .structure-tag {
  color: #2D693F;
  background: rgba(149, 199, 165, 0.24);
  box-shadow: var(--shadow-neu-inset-subtle);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  display: inline-block;
  align-self: flex-start;
  font-weight: 700;
}

.structure-tag {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.structure-name {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-main);
}

.structure-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}

.structure-operator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0 4px;
}

.op-icon {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-subtle);
}

.op-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

/* 牌序對比提醒 (柔和凹嵌提示框) */
.order-contrast-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-inset-subtle);
  padding: 12px 18px;
  border-radius: var(--radius-inner);
  font-size: 13px;
  color: var(--text-main);
  flex-wrap: wrap;
}

.order-badge {
  font-weight: 700;
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-pill);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: #D9822B;
}

.examples-heading {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.examples-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 8 大維度解析行卡片 (精緻新擬物柔光凸起) */
.example-row-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-card);
  padding: 16px 20px;
  border-radius: var(--radius-inner);
  transition: all 0.25s ease;
  border: none;
}

.example-row-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-neu-card-hover);
}

.insight-row-top {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.insight-type-tag {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--primary-accent);
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-inset-subtle);
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.02em;
}

.insight-concept-text {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.insight-body-text {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ==========================================================================
   歷史紀錄橫條 (Neumorphic History Section - Pure Wrap, No Scrollbar)
   ========================================================================== */
.history-bar {
  background: var(--neu-surface);
  border-radius: var(--radius-inner);
  box-shadow: var(--shadow-neu-card);
  padding: 22px 28px;
  margin-bottom: 24px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: visible;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  flex-wrap: wrap;
  gap: 8px;
}

.history-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.history-icon {
  font-size: 16px;
}

.history-label {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.history-hint {
  font-size: 12px;
  color: var(--text-subtle);
  font-weight: 500;
}

.btn-clear-history {
  background: var(--neu-surface);
  border: none;
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-subtle);
  box-shadow: var(--shadow-neu-pill);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-clear-history:hover {
  color: #E06C75;
  box-shadow: var(--shadow-neu-btn-hover);
}

.btn-clear-history:active {
  box-shadow: var(--shadow-neu-inset-subtle);
}

.history-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  width: 100%;
  overflow: visible; /* 徹底告別橫向捲軸，自然向下換行 */
}

.history-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-subtle);
  padding: 6px 4px;
  font-weight: 500;
}

.empty-icon {
  font-size: 15px;
  opacity: 0.7;
}

.history-item {
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-btn);
  border: none;
  border-radius: var(--radius-pill);
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  text-decoration: none;
  font-family: var(--font-body);
}

.history-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-neu-card-hover);
  color: var(--primary-accent);
}

.history-item:active {
  transform: translateY(0);
  box-shadow: var(--shadow-neu-inset);
}

.chip-mode {
  font-size: 13px;
  opacity: 0.85;
}

.chip-card {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.chip-sym {
  font-size: 14px;
}

.chip-card-a {
  color: var(--text-main);
  font-weight: 600;
}

.chip-plus {
  color: var(--text-subtle);
  font-weight: 500;
  font-size: 11px;
  margin: 0 1px;
}

.chip-card-b {
  color: var(--text-muted);
  font-weight: 600;
}

.chip-time {
  font-size: 11px;
  color: var(--text-subtle);
  background: rgba(166, 180, 200, 0.2);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  margin-left: 2px;
  font-weight: 500;
}

/* ==========================================================================
   彈窗 (Modal Backdrop & Box)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(45, 55, 72, 0.4);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

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

.modal-box {
  background: var(--neu-surface);
  border-radius: var(--radius-card);
  box-shadow: 20px 20px 40px rgba(166, 180, 200, 0.5), -20px -20px 40px rgba(255, 255, 255, 0.95);
  width: 100%;
  max-width: 660px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-top {
  padding: 20px 26px;
  border-bottom: 1px solid rgba(166, 180, 200, 0.25);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-heading {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-main);
}

.modal-btn-close {
  background: var(--neu-surface);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  box-shadow: var(--shadow-neu-btn);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.modal-btn-close:hover {
  color: var(--primary-dark);
}

.modal-search {
  padding: 14px 26px;
  border-bottom: 1px solid rgba(166, 180, 200, 0.25);
}

.search-input {
  width: 100%;
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  border: none;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--neu-surface);
  font-weight: 500;
  color: var(--text-main);
  box-shadow: var(--shadow-neu-inset);
}

.modal-card-grid {
  padding: 22px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
  gap: 14px;
}

.grid-option-card {
  background: var(--neu-surface);
  border-radius: var(--radius-inner);
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow-neu-btn);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.grid-option-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-neu-raised);
}

.grid-option-card.disabled {
  opacity: 0.4;
  pointer-events: none;
  box-shadow: none;
}

.grid-option-emoji {
  font-size: 36px;
  line-height: 1.1;
  margin-bottom: 4px;
}

.grid-option-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.grid-option-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* 響應式 */
@media (max-width: 680px) {
  body {
    padding: 16px 12px 60px;
  }

  .brand-title {
    font-size: 28px;
  }

  .trainer-stage {
    flex-direction: column;
    gap: 16px;
  }

  .card-item {
    max-width: 100%;
    width: 100%;
    min-height: auto;
  }

  .swap-controller {
    margin: -4px 0;
  }

  .btn-main, .btn-sub {
    width: 100%;
    justify-content: center;
  }
}

/* ==========================================================================
   頁尾 (Footer)
   ========================================================================== */
.app-footer {
  margin-top: 40px;
  padding: 24px 0 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-top: 1px dashed rgba(200, 205, 215, 0.6);
}

.footer-copyright {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  opacity: 0.85;
}

.footer-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid rgba(160, 170, 185, 0.3);
  padding-bottom: 1px;
  transition: all 0.2s ease;
}

.footer-link:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ==========================================================================
   學員名單 Modal (Roster Modal)
   ========================================================================== */
.roster-modal-box {
  max-width: 580px;
  width: 92%;
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.roster-hint {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  padding: 0 26px 14px;
  border-bottom: 1px solid rgba(166, 180, 200, 0.2);
}

.roster-textarea {
  margin: 18px 26px 0;
  width: calc(100% - 52px);
  border: none;
  border-radius: var(--radius-inner);
  padding: 16px 18px;
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 500;
  line-height: 1.9;
  color: var(--text-main);
  background: var(--neu-surface);
  box-shadow: var(--shadow-neu-inset);
  resize: vertical;
  outline: none;
  min-height: 180px;
}

.roster-textarea::placeholder {
  color: var(--text-subtle);
  font-weight: 400;
}

.roster-textarea.drag-over {
  box-shadow: 0 0 0 2px var(--primary-accent), var(--shadow-neu-inset);
  background: rgba(126, 184, 218, 0.08);
}

.roster-action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 26px 22px;
  flex-wrap: nowrap;
}

.roster-action-row .btn-sub,
.roster-action-row .btn-reveal {
  height: 38px;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-heading);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  min-width: 0;
  margin: 0;
  border-radius: var(--radius-btn);
  transition: all 0.2s ease;
}

.roster-action-row .btn-sub {
  flex: 1;
}

.roster-action-row .btn-reveal {
  flex: 1.15;
}

@media (max-width: 540px) {
  .roster-action-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 14px 18px 20px;
  }

  .roster-action-row .btn-sub {
    width: 100%;
  }

  .roster-action-row .btn-reveal {
    grid-column: 1 / -1;
    width: 100%;
    height: 40px;
    font-size: 13.5px;
  }
}
