/* ==========================================================================
   Design System: 溫暖大地現代風 (Warm Organic & Playful Modern)
   架構對齊 UI/UX Pro Max 官方精選：pet-adoption 系統
   ========================================================================== */

:root {
  /* 核心溫暖大地色盤 (Pet Adoption Colors) */
  --primary: #E07A5F;             /* 陶土粉橘 (A 核心主體) */
  --primary-hover: #D0694E;
  --primary-light: #FDF2EE;
  --primary-glow: rgba(224, 122, 95, 0.25);

  --secondary: #81B29A;           /* 鼠尾草灰綠 (B 修飾狀態) */
  --secondary-hover: #6FA289;
  --secondary-light: #F0F6F3;
  --secondary-glow: rgba(129, 178, 154, 0.25);

  --accent: #F2CC8F;              /* 暖杏金色 */
  --accent-light: #FEF9EF;

  --bg-page: #FDF8F4;             /* 柔和溫暖米白底紙 */
  --bg-card: #FFFFFF;             /* 卡片純白 */
  --bg-subtle: #F7EFE9;           /* 柔和次級背景 */
  --bg-input: #FFFFFF;

  --text-main: #3D405B;           /* 深石板藍灰主要文字 */
  --text-muted: #6B6E8A;          /* 輔助說明文字 */
  --text-subtle: #9A9CB8;         /* 淺灰次級文字 */

  --border: #EFE4DC;              /* 柔和現代細邊框 */
  --border-hover: #DFCFC5;

  /* 柔和環境層次陰影 (Soft Ambient Shadows) */
  --shadow-sm: 0 2px 8px -2px rgba(61, 64, 91, 0.05), 0 1px 4px -1px rgba(61, 64, 91, 0.03);
  --shadow-card: 0 12px 32px -8px rgba(61, 64, 91, 0.08), 0 4px 12px -2px rgba(61, 64, 91, 0.04);
  --shadow-card-hover: 0 20px 40px -10px rgba(61, 64, 91, 0.12), 0 8px 16px -4px rgba(61, 64, 91, 0.06);
  --shadow-btn: 0 6px 18px -4px rgba(224, 122, 95, 0.35);
  --shadow-btn-hover: 0 10px 24px -4px rgba(224, 122, 95, 0.45);

  /* 圓潤幾何族系 (Organic Radii) */
  --radius-card: 28px;
  --radius-inner: 20px;
  --radius-btn: 18px;
  --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;
}

/* ==========================================================================
   全域重設與環境氛圍 (Ambient Reset & Blur Glow Orbs)
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

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

/* 頂部原生 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;
}

/* 頂部極細暖色漸層 */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 50%, var(--secondary) 100%);
  z-index: 100;
}

/* 柔和發光漸層球 (Blur Glow Orbs) */
.glow-orb {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(85px);
  z-index: -1;
  opacity: 0.6;
}

.glow-orb-1 {
  width: 480px;
  height: 480px;
  top: -80px;
  right: -80px;
  background: radial-gradient(circle, rgba(242, 204, 143, 0.4) 0%, transparent 70%);
}

.glow-orb-2 {
  width: 520px;
  height: 520px;
  bottom: 40px;
  left: -120px;
  background: radial-gradient(circle, rgba(129, 178, 154, 0.3) 0%, transparent 70%);
}

.glow-orb-3 {
  width: 400px;
  height: 400px;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(224, 122, 95, 0.2) 0%, transparent 70%);
}

.app-container {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* 風格切換導覽列 */
.style-switcher-bar {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
  padding: 10px 24px;
  border-radius: var(--radius-pill);
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 860px;
  width: 100%;
  flex-wrap: wrap;
  z-index: 10;
}

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

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

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

.style-nav-btn {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-decoration: none;
  padding: 5px 13px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.style-nav-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: #FFFFFF;
  transform: translateY(-1px);
}

.style-nav-btn.current {
  color: #FFFFFF;
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* ==========================================================================
   全站模式與後台切換導覽 (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(--bg-card);
  padding: 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  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(--bg-subtle);
  color: var(--text-main);
  border: 1px solid var(--border);
  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(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.app-switcher-admin:hover {
  color: var(--primary);
  border-color: var(--border-hover);
}

/* ==========================================================================
   頁首：品牌標題與核心語意提示
   ========================================================================== */
.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: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
  margin-bottom: 0;
}

.rule-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 8px 22px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.plus-sign {
  color: var(--text-subtle);
  font-weight: 700;
}

.divider {
  color: var(--border);
  margin: 0 4px;
}

.rule-highlight {
  color: var(--primary);
  font-weight: 800;
  background: var(--primary-light);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 13px;
}

/* ==========================================================================
   模式切換：圓潤膠囊導覽 (Pill Segmented Navigation)
   ========================================================================== */
.mode-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.mode-pill-group {
  display: inline-flex;
  background: var(--bg-card);
  padding: 5px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  gap: 6px;
}

/* 手帳微音效切換膠囊按鈕 */
.btn-sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.btn-sound-toggle:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.btn-sound-toggle.muted {
  color: var(--text-subtle);
  opacity: 0.75;
  background: rgba(0, 0, 0, 0.03);
}

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

.mode-pill {
  border: none;
  background: transparent;
  padding: 9px 26px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

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

.mode-pill.active {
  background: var(--text-main);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(61, 64, 91, 0.2);
}

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

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

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

.card-item:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--border-hover);
}

/* 卡片頭部：角色識別標籤與鎖定按鈕 */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.role-tag {
  font-size: 13px;
  font-weight: 800;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.02em;
}

.tag-a {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(224, 122, 95, 0.25);
}

.tag-b {
  background: var(--secondary-light);
  color: var(--secondary);
  border: 1px solid rgba(129, 178, 154, 0.25);
}

.btn-lock {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.btn-lock:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
  transform: scale(1.04);
}

.btn-lock.pinned {
  background: var(--accent);
  color: var(--text-main);
  border-color: #E2BC7F;
  box-shadow: 0 2px 8px rgba(242, 204, 143, 0.5);
}

/* 卡片本體容器與老虎機視窗 */
.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); }
}

/* 按鈕滾動鎖定狀態 */
.btn-main:disabled,
.btn-sub:disabled,
.btn-swap:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.graphic-showcase {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-radius: var(--radius-inner);
  border: none;
  padding: 20px 12px;
  margin-bottom: 16px;
  position: relative;
}

.card-number {
  position: absolute;
  top: 10px;
  left: 14px;
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.88);
  padding: 3px 9px;
  border-radius: 8px;
  letter-spacing: 0.04em;
  border: 1px solid var(--border);
  z-index: 5;
}

/* 外圍圈圈完全拿掉：轉為乾淨無拘束的大圖示展示容器 */
.emoji-circle-badge {
  width: 100%;
  height: 220px;
  border-radius: 0;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* 圖案放更大：118px 巨大魄力 */
.symbol-emoji {
  font-size: 118px;
  line-height: 1;
  filter: drop-shadow(0 8px 18px rgba(61, 64, 91, 0.16));
  user-select: none;
}

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

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

/* 卡片底部語意詮釋框 */
.semantics-pill {
  background: var(--bg-subtle);
  border-radius: var(--radius-inner);
  border: 1px solid var(--border);
  padding: 12px 16px;
  text-align: center;
}

.card-theme-a .semantics-pill {
  background: #FCF6F2;
  border-color: rgba(224, 122, 95, 0.25);
}

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

.card-theme-b .semantics-pill {
  background: #F4F8F5;
  border-color: rgba(129, 178, 154, 0.3);
}

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

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

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

/* ==========================================================================
   中間一鍵對調控制器 (Swap Controller)
   ========================================================================== */
.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: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(61, 64, 91, 0.08);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-swap:hover {
  transform: scale(1.15) rotate(180deg);
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
  box-shadow: 0 8px 20px var(--primary-glow);
}

.btn-swap:active {
  transform: scale(0.95) rotate(180deg);
}

.swap-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  background: #FFFFFF;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}

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

.btn-main {
  background: var(--primary);
  color: #FFFFFF;
  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-btn);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.btn-main:active {
  transform: translateY(1px);
  box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-sub {
  background: #FFFFFF;
  color: var(--text-main);
  border: 1px solid var(--border);
  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-sm);
  display: inline-flex;
  align-items: center;
  gap: 9px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-sub:hover {
  background: var(--bg-subtle);
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.btn-sub:active {
  transform: translateY(1px);
}

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

/* ==========================================================================
   解讀靈感抽屜 (Insight Accordion Card)
   ========================================================================== */
.insight-card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  padding: 22px 26px;
  margin-bottom: 28px;
  transition: all 0.3s ease;
}

.insight-card:hover {
  border-color: var(--border-hover);
}

.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: #8C5618;
  background: var(--accent-light);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(242, 204, 143, 0.5);
}

.toggle-btn {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  transition: all 0.2s ease;
}

.insight-header:hover .toggle-btn {
  color: var(--text-main);
  background: #EFE6DE;
}

.insight-content {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px dashed var(--border);
  display: none;
}

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

.formula-box {
  background: var(--bg-page);
  padding: 20px 22px;
  border-radius: var(--radius-inner);
  margin-bottom: 22px;
  border: 1px solid var(--border);
  line-height: 1.6;
}

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

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

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

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

/* A + B 語意結構對比網格 */
.reading-structure-grid {
  display: flex;
  align-items: stretch;
  gap: 14px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.structure-card {
  flex: 1;
  min-width: 200px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(61, 64, 91, 0.04);
}

.card-a-focus {
  border-left: 4px solid var(--primary);
}

.card-b-modifier {
  border-left: 4px solid var(--secondary);
}

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

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

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

.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: 800;
  color: var(--text-muted);
}

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

/* 牌序對比提醒 */
.order-contrast-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(242, 204, 143, 0.22);
  border: 1px solid rgba(242, 204, 143, 0.6);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  color: #70420E;
  flex-wrap: wrap;
}

.order-badge {
  font-weight: 800;
  background: #FFFFFF;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11.5px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.examples-heading {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 12px;
  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(--bg-subtle);
  padding: 16px 20px;
  border-radius: var(--radius-inner);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.example-row-card:hover {
  background: #FFFFFF;
  border-color: var(--border-hover);
  box-shadow: 0 4px 14px rgba(61, 64, 91, 0.05);
}

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

.insight-type-tag {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--primary);
  background: rgba(211, 84, 58, 0.1);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.02em;
}

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

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

/* ==========================================================================
   歷史紀錄橫條 (History Bar - Pure Wrap, No Scrollbar)
   ========================================================================== */
.history-bar {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 18px 24px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  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: 800;
  color: var(--text-main);
}

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

.btn-clear-history {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-clear-history:hover {
  background: #FFFFFF;
  color: var(--primary);
  border-color: var(--primary);
}

.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-muted);
  padding: 6px 4px;
  font-weight: 500;
}

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

.history-item {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  font-family: var(--font-body);
}

.history-item:hover {
  background: #FFFFFF;
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

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

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

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

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

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

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

.chip-time {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--border-soft, rgba(0,0,0,0.05));
  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(61, 64, 91, 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: #FFFFFF;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  box-shadow: 0 25px 50px -12px rgba(61, 64, 91, 0.25);
  width: 100%;
  max-width: 660px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-top {
  padding: 20px 26px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #FFFFFF;
}

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

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

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

.modal-search {
  padding: 14px 26px;
  background: var(--bg-page);
  border-bottom: 1px solid var(--border);
}

.search-input {
  width: 100%;
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: #FFFFFF;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: inset 0 1px 3px rgba(61, 64, 91, 0.04);
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

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

.grid-option-card {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-inner);
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: var(--shadow-sm);
}

.grid-option-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow-card);
}

.grid-option-card.disabled {
  opacity: 0.35;
  pointer-events: none;
  filter: grayscale(1);
}

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

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

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

/* ==========================================================================
   手機版響應式調校 (Mobile Responsive)
   ========================================================================== */
@media (max-width: 680px) {
  body {
    padding: 24px 14px 60px;
  }

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

  .rule-badge {
    font-size: 12px;
    padding: 6px 14px;
    gap: 6px;
  }

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

  .card-item {
    max-width: 100%;
    width: 100%;
    min-height: auto;
    padding: 20px 16px;
  }

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

  .btn-swap {
    width: 46px;
    height: 46px;
  }

  .action-bar {
    gap: 10px;
  }

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

  .insight-card {
    padding: 18px 16px;
  }

  .history-bar {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 16px;
  }
}

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

.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(150, 140, 130, 0.3);
  padding-bottom: 1px;
  transition: all 0.2s ease;
}

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

/* ==========================================================================
   學員專屬身分徽章 (Student Cohort Badge)
   ========================================================================== */
.student-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 6px 14px 6px 12px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  font-size: 13px;
  color: var(--text-main);
  animation: fadeInBadge 0.3s ease;
}

@keyframes fadeInBadge {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.badge-icon {
  font-size: 15px;
  line-height: 1;
}

.badge-title {
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.02em;
}

.badge-divider {
  color: var(--border-hover);
  font-size: 11px;
}

.badge-cohort {
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  letter-spacing: 0.03em;
}

.badge-logout-btn {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  font-size: 11.5px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: all 0.2s ease;
  margin-left: 2px;
}

.badge-logout-btn:hover {
  color: var(--primary);
  background: var(--bg-subtle);
}

/* ==========================================================================
   課程通關碼門禁 Overlay (Passcode Gatekeeper)
   ========================================================================== */
body.app-locked {
  overflow: hidden !important;
}

body.app-locked .app-container {
  filter: blur(8px);
  pointer-events: none;
  user-select: none;
  transition: filter 0.3s ease;
}

.gatekeeper-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(45, 48, 71, 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.gatekeeper-card {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: 0 24px 60px -12px rgba(61, 64, 91, 0.28), 0 10px 24px -4px rgba(61, 64, 91, 0.1);
  padding: 44px 36px 36px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  position: relative;
  animation: gatekeeperPopIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes gatekeeperPopIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.gatekeeper-icon-wrap {
  width: 68px;
  height: 68px;
  margin: 0 auto 20px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--primary-light) 0%, #FBECE5 100%);
  border: 1px solid rgba(224, 122, 95, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 16px -4px var(--primary-glow);
}

.gatekeeper-key-icon {
  width: 36px;
  height: 36px;
  color: var(--primary);
  fill: currentColor;
  display: block;
}

.gatekeeper-title {
  font-family: var(--font-heading);
  font-size: 23px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}

.gatekeeper-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 26px;
}

.gatekeeper-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gatekeeper-input-wrap {
  position: relative;
  width: 100%;
}

.gatekeeper-input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border-radius: var(--radius-btn);
  border: 2px solid var(--border);
  background: var(--bg-page);
  color: var(--text-main);
  font-family: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: all 0.2s ease;
}

.gatekeeper-input:focus {
  border-color: var(--primary);
  background: #FFFFFF;
  outline: none;
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.gatekeeper-input::placeholder {
  color: var(--text-subtle);
  font-size: 13.5px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.input-shake {
  animation: gatekeeperShake 0.5s ease;
  border-color: #E57373 !important;
}

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

.gatekeeper-error {
  background: #FFF5F5;
  color: #D32F2F;
  border: 1px solid #FFCDD2;
  border-radius: 12px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
}

.gatekeeper-btn {
  width: 100%;
  height: 50px;
  background: var(--primary);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-btn);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
  transition: all 0.2s ease;
  margin-top: 6px;
}

.gatekeeper-btn:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-btn-hover);
  transform: translateY(-1px);
}

.gatekeeper-btn:active {
  transform: translateY(1px);
}

.gatekeeper-btn .btn-arrow {
  font-size: 17px;
  transition: transform 0.2s ease;
}

.gatekeeper-btn:hover .btn-arrow {
  transform: translateX(4px);
}

.gatekeeper-btn.loading {
  opacity: 0.75;
  pointer-events: none;
}

.gatekeeper-footer-hint {
  margin-top: 22px;
  font-size: 12px;
  color: var(--text-subtle);
  line-height: 1.5;
}
