﻿/* ========================================================
   《論語·心靈微縮群島》樣式表 (styles.css)
   美學風格：新中式宣紙水墨 (Neo-Chinese Cozy Ink)
   無純黑、雙層紙質毛玻璃、手機自適應抽屜與全套互動
   ======================================================== */

@import url('https://fonts.googleapis.com/css2?family=Ma+Shan+Zheng&family=Noto+Serif+TC:wght@400;600;900&display=swap');

:root {
  /* 新中式宣紙色譜 */
  --bg-day: #ebf3f5;
  --bg-night: #0b1320;
  --paper: rgba(254, 252, 248, 0.94);
  --paper-solid: #fcf9f2;
  --paper-border: rgba(184, 169, 154, 0.35);
  --ink: #2b2623;
  --ink-secondary: #6e655f;
  --ink-muted: #9c9189;
  --seal-red: #b93826;
  --seal-red-bg: rgba(185, 56, 38, 0.08);
  --cinnabar: #c44536;
  --gold: #b38728;
  --gold-bg: rgba(179, 135, 40, 0.1);
  --pine-green: #3f684c;
  --lake-blue: #346077;
  --shadow-sm: 0 4px 12px rgba(43, 38, 35, 0.06);
  --shadow-lg: 0 16px 40px rgba(43, 38, 35, 0.16);
  --shadow-drawer: -12px 0 40px rgba(43, 38, 35, 0.14);
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  --font-serif: "Noto Serif TC", "Songti TC", "Source Han Serif TC", "PMingLiU", serif;
  --font-brush: "Ma Shan Zheng", "Noto Serif TC", cursive, serif;
}

body.night-mode {
  --paper: rgba(21, 29, 44, 0.94);
  --paper-solid: #172030;
  --paper-border: rgba(100, 120, 150, 0.25);
  --ink: #ede6dc;
  --ink-secondary: #a8a096;
  --ink-muted: #727c8d;
  --seal-red: #e05d4b;
  --seal-red-bg: rgba(224, 93, 75, 0.15);
  --gold: #e2ba55;
  --gold-bg: rgba(226, 186, 85, 0.15);
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  --shadow-drawer: -12px 0 40px rgba(0, 0, 0, 0.6);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-serif);
  color: var(--ink);
  background-color: var(--bg-day);
  transition: background-color 0.8s ease;
  user-select: none;
}

#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* ========================================================
   頂部導覽列 (Header & Brand Bar)
   ======================================================== */
.top-bar {
  position: absolute;
  top: 16px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

.brand-badge {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--paper);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 10px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--paper-border);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: var(--transition);
}

.brand-badge:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.seal-stamp {
  width: 36px;
  height: 36px;
  background: var(--seal-red);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-brush);
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 2px 6px rgba(185, 56, 38, 0.4);
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.explore-progress-pill {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--seal-red);
  background: var(--seal-red-bg);
  border: 1px solid rgba(185, 56, 38, 0.22);
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.brand-info h1 {
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--ink);
  line-height: 1.2;
}

.brand-info p {
  font-size: 0.75rem;
  color: var(--ink-secondary);
  letter-spacing: 0.05em;
}

.top-actions {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.cluster-scroll-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.cluster-scroll-cue {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  height: calc(100% - 6px);
  display: none; /* 桌面端寬敞完整顯示，小螢幕才自動啟用 */
  align-items: center;
  justify-content: flex-end;
  padding: 0 4px 0 16px;
  background: linear-gradient(to right, transparent 0%, rgba(252, 249, 242, 0.92) 45%, rgba(252, 249, 242, 0.98) 100%);
  border: none;
  border-radius: 0 16px 16px 0;
  color: var(--seal-red);
  font-size: 1.25rem;
  font-weight: 900;
  cursor: pointer;
  pointer-events: auto;
  transition: opacity 0.3s ease, transform 0.2s ease;
  z-index: 2;
  animation: bounceCue 1.5s ease-in-out infinite alternate;
}

body.night-mode .cluster-scroll-cue {
  background: linear-gradient(to right, transparent 0%, rgba(21, 29, 42, 0.92) 45%, rgba(21, 29, 42, 0.98) 100%);
  color: var(--gold);
}

@keyframes bounceCue {
  0% { transform: translateY(-50%) translateX(0); }
  100% { transform: translateY(-50%) translateX(3px); }
}

.cluster-scroll-cue.hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.cluster-pills {
  display: flex;
  gap: 6px;
  background: var(--paper);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 6px 10px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--paper-border);
  box-shadow: var(--shadow-sm);
}

.pill-btn {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 20px;
  font-family: var(--font-serif);
  font-size: 0.8rem;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.pill-btn:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.04);
}

.pill-btn.active {
  background: var(--ink);
  color: #fff;
  font-weight: 600;
}

body.night-mode .pill-btn.active {
  background: var(--gold);
  color: #172030;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  width: 220px;
  padding: 9px 16px 9px 36px;
  background: var(--paper);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--paper-border);
  border-radius: 20px;
  font-family: var(--font-serif);
  font-size: 0.85rem;
  color: var(--ink);
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.search-input:focus {
  width: 280px;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-bg);
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--ink-muted);
  font-size: 14px;
  pointer-events: none;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  max-height: 420px;
  overflow-y: auto;
  background: var(--paper-solid);
  border: 1px solid var(--paper-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 100;
  animation: fadeIn 0.2s ease;
}

.search-dropdown::-webkit-scrollbar {
  width: 5px;
}

.search-dropdown::-webkit-scrollbar-track {
  background: transparent;
}

.search-dropdown::-webkit-scrollbar-thumb {
  background: var(--paper-border);
  border-radius: 4px;
}

.search-dropdown::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
}

.search-item {
  padding: 11px 14px;
  border-bottom: 1px solid var(--paper-border);
  cursor: pointer;
  transition: var(--transition);
}

.search-item:last-child {
  border-bottom: none;
}

.search-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

body.night-mode .search-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* 搜尋關鍵字高亮 (Search Highlight) */
.search-hl {
  background: rgba(199, 62, 58, 0.18);
  color: var(--seal-red, #c73e3a);
  font-weight: 700;
  border-radius: 2px;
  padding: 0 2px;
}

body.night-mode .search-hl {
  background: rgba(229, 131, 83, 0.28);
  color: #ff9f73;
}

/* 抽屜內章句暫時高亮淡出動畫 */
.search-hl-temp {
  background: rgba(199, 62, 58, 0.28);
  color: var(--seal-red, #c73e3a);
  font-weight: 700;
  border-radius: 3px;
  padding: 1px 3px;
  box-shadow: 0 0 6px rgba(199, 62, 58, 0.35);
  transition: background-color 0.8s ease, color 0.8s ease, box-shadow 0.8s ease;
}

.search-hl-temp.fade-out {
  background-color: transparent !important;
  color: inherit !important;
  box-shadow: none !important;
}

body.night-mode .search-hl-temp {
  background: rgba(229, 131, 83, 0.35);
  color: #ff9f73;
  box-shadow: 0 0 6px rgba(229, 131, 83, 0.4);
}

/* 命中類型微縮徽章 (Search Match Badges) */
.search-match-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.search-match-badge.badge-original {
  background: rgba(46, 107, 99, 0.12);
  color: #245851;
  border: 1px solid rgba(46, 107, 99, 0.28);
}

body.night-mode .search-match-badge.badge-original {
  background: rgba(80, 160, 150, 0.2);
  color: #6edbca;
  border-color: rgba(80, 160, 150, 0.4);
}

.search-match-badge.badge-vernacular {
  background: rgba(184, 115, 23, 0.12);
  color: #9c6000;
  border: 1px solid rgba(184, 115, 23, 0.28);
}

body.night-mode .search-match-badge.badge-vernacular {
  background: rgba(220, 150, 50, 0.2);
  color: #f5b041;
  border-color: rgba(220, 150, 50, 0.4);
}

.search-match-badge.badge-tag {
  background: rgba(112, 70, 160, 0.12);
  color: #6b3fa0;
  border: 1px solid rgba(112, 70, 160, 0.28);
}

body.night-mode .search-match-badge.badge-tag {
  background: rgba(160, 120, 220, 0.2);
  color: #bb99ee;
  border-color: rgba(160, 120, 220, 0.4);
}

.search-match-badge.badge-chapter {
  background: var(--gold-bg);
  color: var(--gold);
  border: 1px solid rgba(179, 131, 56, 0.3);
}

/* 今釋上下文摘錄區塊 */
.search-snippet {
  font-size: 0.8rem;
  color: var(--ink-secondary);
  margin-top: 5px;
  line-height: 1.48;
  background: rgba(0, 0, 0, 0.025);
  border-left: 2px solid var(--gold);
  padding: 4px 8px;
  border-radius: 0 4px 4px 0;
  word-break: break-all;
}

body.night-mode .search-snippet {
  background: rgba(255, 255, 255, 0.04);
}

/* 下拉選單底部提示列 */
.search-footer {
  padding: 8px 14px;
  font-size: 0.75rem;
  color: var(--ink-muted);
  background: rgba(0, 0, 0, 0.02);
  border-top: 1px solid var(--paper-border);
  text-align: center;
  letter-spacing: 0.5px;
}

body.night-mode .search-footer {
  background: rgba(255, 255, 255, 0.02);
}

.search-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--seal-red-bg);
  color: var(--seal-red);
  margin-right: 6px;
}

/* ========================================================
   右側抽屜 (Chapter Drawer)
   ======================================================== */
.drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 20, 28, 0.25);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 45;
  display: none;
  transition: opacity 0.3s ease;
}

.drawer-backdrop.active {
  display: block;
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: -520px;
  width: 480px;
  max-width: 90vw;
  height: 100%;
  background: var(--paper);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid var(--paper-border);
  box-shadow: var(--shadow-drawer);
  z-index: 50;
  transition: right 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  user-select: text;
}

.drawer-panel.open {
  right: 0;
}

.drawer-header {
  padding: 24px 60px 16px 24px;
  border-bottom: 1px solid var(--paper-border);
  position: relative;
  background: linear-gradient(180deg, var(--paper-solid) 0%, transparent 100%);
}

.drawer-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--paper-border);
  background: var(--paper-solid);
  color: var(--ink);
  font-size: 20px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 999 !important;
  pointer-events: auto !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.drawer-close:hover {
  background: var(--seal-red);
  color: #fff;
  border-color: var(--seal-red);
  transform: scale(1.1);
}

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

.chapter-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--seal-red-bg);
  color: var(--seal-red);
  letter-spacing: 0.05em;
}

.cluster-tag {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--gold-bg);
  color: var(--gold);
}

.drawer-title {
  font-size: 1.55rem;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.drawer-landmark {
  font-size: 0.82rem;
  color: var(--ink-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.drawer-summary {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.025);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--seal-red);
}

body.night-mode .drawer-summary {
  background: rgba(255, 255, 255, 0.04);
}

/* 抽屜內部章句列表 */
.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px 30px;
  scroll-behavior: smooth;
}

.drawer-content::-webkit-scrollbar {
  width: 6px;
}

.drawer-content::-webkit-scrollbar-thumb {
  background: rgba(184, 169, 154, 0.4);
  border-radius: 3px;
}

.section-label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin: 16px 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* 章句卡片 (Verse Card) */
.verse-card {
  background: var(--paper-solid);
  border: 1px solid var(--paper-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
  transition: var(--transition);
  position: relative;
}

.verse-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: rgba(185, 56, 38, 0.35);
}

.verse-card.is-highlight {
  border-color: rgba(179, 135, 40, 0.4);
  background: linear-gradient(135deg, var(--paper-solid) 0%, rgba(252, 245, 227, 0.4) 100%);
}

body.night-mode .verse-card.is-highlight {
  background: linear-gradient(135deg, var(--paper-solid) 0%, rgba(226, 186, 85, 0.06) 100%);
}

.verse-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.verse-id-badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--seal-red);
  background: var(--seal-red-bg);
  padding: 2px 8px;
  border-radius: 6px;
}

.verse-star-badge {
  font-size: 0.72rem;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
}

.verse-original {
  font-size: 1.05rem;
  line-height: 1.75;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.verse-vernacular {
  font-size: 0.88rem;
  line-height: 1.68;
  color: var(--ink-secondary);
  background: rgba(43, 38, 35, 0.025);
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  border-left: 3px solid rgba(203, 153, 126, 0.5);
}

.verse-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px dashed var(--paper-border);
}

.action-btn-group {
  display: flex;
  gap: 8px;
}

.text-btn {
  border: none;
  background: transparent;
  font-family: var(--font-serif);
  font-size: 0.78rem;
  color: var(--ink-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: var(--transition);
}

.text-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--ink);
}

body.night-mode .text-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.speak-toggle-btn.is-speaking {
  background: var(--seal-red-bg);
  color: var(--seal-red);
  font-weight: 700;
  border: 1px solid rgba(185, 56, 38, 0.28);
}

.speak-toggle-btn.is-paused {
  background: var(--gold-bg);
  color: var(--gold);
  font-weight: 700;
  border: 1px solid rgba(176, 134, 66, 0.32);
}

.speak-stop-btn {
  background: rgba(43, 38, 35, 0.07);
  color: var(--ink);
  font-weight: 600;
  border: 1px solid var(--paper-border);
}

.speak-stop-btn:hover {
  background: var(--seal-red);
  color: #fff;
  border-color: var(--seal-red);
}

.deep-read-btn {
  background: var(--seal-red);
  color: #fff;
  border: none;
  font-family: var(--font-serif);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(185, 56, 38, 0.25);
}

.deep-read-btn:hover {
  background: var(--cinnabar);
  transform: scale(1.03);
}

/* ========================================================
   深層智慧彈窗卡片 (Deep Insight Modal)
   ======================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 20, 28, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 20000; /* 最高優先層級，確保絕對不被任何抽屜或 HUD 遮擋 */
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.insight-modal-card {
  width: 640px;
  max-width: 95vw;
  max-height: 90vh;
  background: var(--paper-solid);
  border: 1px solid var(--paper-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow-y: auto;
  position: relative;
  padding: 36px 32px;
  animation: scaleUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: text;
}

@keyframes scaleUp {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--paper-border);
  background: var(--paper);
  color: var(--ink-secondary);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close-btn:hover {
  background: var(--seal-red);
  color: #fff;
  border-color: var(--seal-red);
}

.modal-header-row {
  padding-right: 46px; /* 為右上角 ✕ 圓形按鈕留出絕對安全避讓空間 */
  margin-bottom: 12px;
  display: flex;
  align-items: center;
}

.modal-seal-badge {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 12px;
  background: var(--seal-red-bg);
  color: var(--seal-red);
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.4;
  max-width: 100%;
  word-break: break-word;
}

.modal-seal-badge.fortune-badge {
  background: linear-gradient(135deg, rgba(185, 56, 38, 0.16) 0%, rgba(212, 160, 23, 0.24) 100%);
  border: 1px solid rgba(212, 160, 23, 0.45);
  color: #a82e20;
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 10px rgba(212, 160, 23, 0.2);
}

.fortune-explore-btn {
  color: var(--seal-red) !important;
  font-weight: 700 !important;
  background: rgba(185, 56, 38, 0.08) !important;
  border: 1px solid rgba(185, 56, 38, 0.22) !important;
  border-radius: 14px !important;
  padding: 4px 10px !important;
  transition: var(--transition);
}

.fortune-explore-btn:hover {
  background: var(--seal-red) !important;
  color: #fff !important;
}

.modal-theme-title {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--ink);
  line-height: 1.4;
  margin-bottom: 16px;
}

.modal-original-quote {
  font-size: 1.15rem;
  line-height: 1.8;
  font-weight: 600;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.03);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  border-left: 4px solid var(--seal-red);
  margin-bottom: 24px;
}

body.night-mode .modal-original-quote {
  background: rgba(255, 255, 255, 0.05);
}

/* 四大維度排版 */
.insight-dimensions {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 24px;
}

.dimension-block {
  background: var(--paper);
  border: 1px solid var(--paper-border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.dim-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 6px;
}

.dim-text {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--ink);
}

.dim-practice .dim-tag {
  color: var(--pine-green);
}

.dim-reflection .dim-tag {
  color: var(--lake-blue);
}

.dim-reflection {
  background: rgba(52, 96, 119, 0.06);
  border-left: 3px solid var(--lake-blue);
}

.modal-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.modal-tag-chip {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--paper-border);
  color: var(--ink-secondary);
}

/* ========================================================
   NPC 先賢對話氣泡卡 (Dialogue Modal)
   ======================================================== */
.npc-dialogue-card {
  width: 480px;
  max-width: 90vw;
  background: var(--paper-solid);
  border: 1px solid var(--paper-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  position: relative;
  padding: 32px 28px;
  text-align: center;
  animation: scaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.npc-avatar-badge {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--seal-red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-brush);
  font-size: 28px;
  box-shadow: 0 4px 14px rgba(185, 56, 38, 0.35);
}

.npc-name {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}

.npc-quote {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.03);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  border-left: 4px solid var(--seal-red);
  margin-bottom: 22px;
  text-align: left;
}

body.night-mode .npc-quote {
  background: rgba(255, 255, 255, 0.05);
}

.npc-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* ========================================================
   浮動操控群 (Bottom Floating Island HUD)
   ======================================================== */
.bottom-controls {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 20;
  background: var(--paper);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 8px 16px;
  border-radius: 30px;
  border: 1px solid var(--paper-border);
  box-shadow: var(--shadow-lg);
}

/* 音樂按鈕動態音波 */
.sound-wave {
  display: inline-flex;
  align-items: center;
  gap: 2.5px;
  height: 14px;
  margin-left: 4px;
}

.sound-wave .bar {
  width: 2.5px;
  height: 4px;
  background: currentColor;
  border-radius: 2px;
  transition: height 0.2s ease;
}

.sound-wave.playing .bar:nth-child(1) {
  animation: bounceBar 0.75s ease-in-out infinite alternate;
}
.sound-wave.playing .bar:nth-child(2) {
  animation: bounceBar 1.1s ease-in-out infinite alternate 0.2s;
}
.sound-wave.playing .bar:nth-child(3) {
  animation: bounceBar 0.85s ease-in-out infinite alternate 0.4s;
}

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

.hud-btn {
  border: none;
  background: transparent;
  font-family: var(--font-serif);
  font-size: 0.85rem;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 20px;
  transition: var(--transition);
  font-weight: 600;
  white-space: nowrap; /* 核心防線：全平台禁止任何單字折行 */
}

.hud-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.hud-label {
  display: inline-block;
  white-space: nowrap;
}

.hud-label .label-long {
  display: inline;
}

.hud-label .label-short {
  display: none;
}

.hud-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

body.night-mode .hud-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.hud-btn.primary {
  background: var(--seal-red);
  color: #fff;
  box-shadow: 0 4px 12px rgba(185, 56, 38, 0.3);
}

.hud-btn.primary:hover {
  background: var(--cinnabar);
}

.hud-btn.active {
  background: rgba(199, 62, 58, 0.16);
  border-color: var(--seal-red, #c44536);
  color: var(--seal-red, #c44536);
  font-weight: 700;
  box-shadow: 0 0 14px rgba(199, 62, 58, 0.35);
  animation: pulseFollow 2s infinite ease-in-out;
}

body.night-mode .hud-btn.active {
  background: rgba(245, 158, 11, 0.22);
  border-color: #f59e0b;
  color: #fcd34d;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.45);
}

@keyframes pulseFollow {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

/* 3D 懸停微光預覽膠囊 (大師級互動細節) */
.hover-preview-pill {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--paper);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--ink);
  border: 1px solid var(--gold);
  padding: 7px 18px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  font-family: var(--font-serif);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 35;
  white-space: nowrap;
}

.hover-preview-pill.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 浮動提示 Toast */
.toast-msg {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(43, 38, 35, 0.9);
  color: #fff;
  padding: 10px 22px;
  border-radius: 24px;
  font-size: 0.85rem;
  font-family: var(--font-serif);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 200;
}

.toast-msg.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ========================================================
   CSS2DRenderer 雙層 3D 名牌與二級穿透號碼針 (標竿工藝升級)
   ======================================================== */
.island-3d-label {
  pointer-events: auto;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 6px;
  border-radius: 999px;
  background: var(--paper);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--paper-border);
  box-shadow: 0 6px 18px rgba(43, 38, 35, 0.15);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  transition: transform 0.22s ease, opacity 0.22s ease, background 0.22s ease, color 0.22s ease;
}

.island-3d-label .num-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--island-theme, var(--seal-red));
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.island-3d-label:hover {
  transform: scale(1.07) translateY(-2px);
  border-color: var(--seal-red);
}

.island-3d-label.is-active {
  background: #2b2623;
  color: #ffd166;
  border-color: #ffd166;
  transform: scale(1.09);
  z-index: 30;
}

.island-3d-label.is-dim {
  opacity: 0.42;
}

.island-3d-label.is-compact {
  padding: 3px 8px 3px 4px;
  opacity: 0.88;
}

.island-3d-label.is-compact .label-text {
  font-size: 0.74rem;
}

.island-3d-label.is-occluded {
  opacity: 0 !important;
  transform: scale(0.82);
  pointer-events: none !important;
}

/* 抽屜頂部 Scissor 即時 3D 建築棚拍縮圖與 Bento 數據磚 */
.drawer-hero-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}

.drawer-3d-thumb {
  width: 68px;
  height: 68px;
  border-radius: 16px;
  object-fit: cover;
  border: 2px solid var(--paper-border);
  box-shadow: 0 6px 16px rgba(43, 38, 35, 0.14);
  flex-shrink: 0;
  background: var(--paper-solid);
}

.bento-facts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.bento-fact-tile {
  background: rgba(43, 38, 35, 0.035);
  border: 1px solid var(--paper-border);
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

body.night-mode .bento-fact-tile {
  background: rgba(255, 255, 255, 0.05);
}

.bento-fact-prefix {
  font-size: 0.68rem;
  color: var(--ink-muted);
}

.bento-fact-num {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--seal-red);
  line-height: 1.25;
}

.bento-fact-suffix {
  font-size: 0.7rem;
  color: var(--ink-secondary);
}

/* 第二層：點選島嶼後浮現的 ①②③ 重點名言細項圓形號碼針 */
.verse-3d-pin {
  pointer-events: auto;
  cursor: pointer;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--seal-red);
  color: #fff;
  border: 2px solid #fcf9f2;
  box-shadow: 0 4px 12px rgba(43, 38, 35, 0.28);
  font-family: var(--font-serif);
  font-size: 0.76rem;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, background 0.2s ease;
}

.verse-3d-pin:hover,
.verse-3d-pin.is-active {
  background: #2b2623;
  color: #ffd166;
  border-color: #ffd166;
  transform: scale(1.2);
}

/* ========================================================
   屏蔽第三方/Netlify 注入徽章 (防遮擋 3D 操作與抽屜章句)
   ======================================================== */
[data-netlify-badge],
.netlify-badge,
iframe#netlify-identity-widget,
div[style*="position: fixed"]:has(a[href*="netlify.com"]),
div[style*="position:fixed"]:has(a[href*="netlify.com"]),
a[href*="netlify.com"][style*="position: fixed"],
a[href*="netlify.com"][style*="position:fixed"],
#netlify-badge {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ========================================================
   行動裝置直立螢幕適配 (Mobile Responsive)
   ======================================================== */
@media (max-width: 768px) {
  /* 1. 雙模式短標籤切換 */
  .hud-label .label-long {
    display: none !important;
  }
  .hud-label .label-short {
    display: inline !important;
  }

  /* 2. 頂部導覽列：極致瘦身單行化，釋放 3D 舞台視野 */
  .top-bar {
    top: 8px;
    left: 8px;
    right: 8px;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    pointer-events: none;
  }

  .brand-badge {
    pointer-events: auto;
    padding: 5px 10px;
    border-radius: 16px;
    gap: 8px;
    align-items: center;
    background: var(--paper);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .seal-stamp {
    width: 26px;
    height: 26px;
    font-size: 0.95rem;
    border-radius: 6px;
    flex-shrink: 0;
  }

  .brand-info {
    flex: 1;
    min-width: 0;
  }

  .brand-title-row {
    gap: 6px;
    flex-wrap: nowrap;
    align-items: center;
  }

  .brand-info h1 {
    font-size: 0.92rem;
    font-weight: 900;
    white-space: nowrap;
    letter-spacing: 0.04em;
  }

  .explore-progress-pill {
    font-size: 0.65rem;
    padding: 1px 6px;
    margin-left: auto;
    flex-shrink: 0;
  }

  /* 隱藏手機上佔據大量垂直高度的次要副標題 */
  .brand-info p {
    display: none !important;
  }

  .top-actions {
    pointer-events: auto;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: visible;
    padding-bottom: 0;
  }

  .cluster-scroll-wrapper {
    flex: 1;
    min-width: 0;
  }

  .cluster-scroll-cue {
    display: flex; /* 手機端自動啟動滑動呼吸指引指示器 */
  }

  .cluster-pills {
    width: 100%;
    padding: 3px 26px 3px 6px;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
    border-radius: 16px;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .cluster-pills::-webkit-scrollbar {
    display: none;
  }

  .pill-btn {
    padding: 4px 10px;
    font-size: 0.72rem;
    flex-shrink: 0;
  }

  .search-box {
    flex-shrink: 0;
  }

  .search-input {
    width: 110px;
    padding: 5px 10px 5px 26px;
    font-size: 0.75rem;
    border-radius: 16px;
  }

  .search-input:focus {
    width: 155px;
  }

  .search-icon {
    left: 8px;
    font-size: 11px;
  }

  .search-dropdown {
    width: 290px;
    max-width: calc(100vw - 20px);
    right: 0;
    max-height: 50vh;
  }

  /* 3. 底部操控群：現代 App 底部導覽欄 (Bottom Dock) 徹底杜絕擠壓折行 */
  .bottom-controls {
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100vw - 16px);
    max-width: 430px;
    padding: 5px 4px;
    gap: 2px;
    border-radius: 18px;
    justify-content: space-between;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(43, 38, 35, 0.22);
  }

  .hud-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 4px 2px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border-radius: 10px;
  }

  .hud-btn .hud-icon {
    font-size: 1.12rem;
    line-height: 1;
  }

  .hud-btn .hud-label {
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: 0.5px;
    white-space: nowrap;
    text-align: center;
  }

  .sound-wave {
    display: none; /* 手機端節省寬度，改由圖示色彩呼吸 */
  }

  /* 4. 手機抽屜改為現代 Bottom Sheet，附帶頂部質感把手 */
  .drawer-panel {
    top: auto;
    bottom: -110%;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 93vh;
    border-left: none;
    border-top: 1px solid var(--paper-border);
    border-radius: 24px 24px 0 0;
    transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 10001;
    display: flex;
    flex-direction: column;
  }

  /* 抽屜頂部防呆拖曳拉桿 */
  .drawer-panel::before {
    content: '';
    display: block;
    width: 38px;
    height: 4px;
    background: rgba(43, 38, 35, 0.22);
    border-radius: 2px;
    margin: 8px auto 2px auto;
    flex-shrink: 0;
  }

  body.night-mode .drawer-panel::before {
    background: rgba(255, 255, 255, 0.28);
  }

  .drawer-panel.open {
    bottom: 0;
    right: 0;
  }

  .drawer-header {
    padding: 10px 52px 10px 16px;
  }

  .drawer-close {
    top: 10px;
    right: 12px;
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  .drawer-title {
    font-size: 1.35rem;
  }

  .drawer-content {
    padding: 12px 14px;
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 24px));
  }

  /* Bento 數據卡手機端整齊 3 欄等寬 */
  .bento-facts-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 14px;
  }

  .bento-fact-card {
    padding: 8px 4px;
    border-radius: 10px;
  }

  .bento-fact-num {
    font-size: 1.05rem;
  }

  .bento-fact-suffix, .bento-fact-prefix {
    font-size: 0.62rem;
  }

  /* 手機端抽屜頭部極致輕量化，釋放寶貴的閱讀高度 */
  .drawer-header {
    padding: 8px 46px 8px 14px;
  }

  .drawer-hero-row {
    margin-bottom: 4px;
    gap: 10px;
  }

  .drawer-3d-thumb {
    width: 52px;
    height: 52px;
    border-radius: 12px;
  }

  .drawer-meta-tags {
    margin-bottom: 2px;
    gap: 4px;
  }

  .chapter-badge, .cluster-tag {
    font-size: 0.68rem;
    padding: 2px 7px;
  }

  .drawer-title {
    font-size: 1.22rem;
    margin-bottom: 2px;
  }

  .drawer-landmark {
    font-size: 0.74rem;
    margin-bottom: 6px;
    line-height: 1.35;
  }

  .drawer-summary {
    font-size: 0.8rem;
    line-height: 1.45;
    padding: 6px 10px;
  }

  .bento-facts-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-top: 6px;
    margin-bottom: 8px;
  }

  .bento-fact-tile {
    padding: 5px 6px;
    border-radius: 8px;
  }

  .bento-fact-num {
    font-size: 0.96rem;
  }

  .drawer-content {
    padding: 10px 12px;
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 24px));
  }

  .verse-card {
    padding: 12px 14px;
    margin-bottom: 12px;
  }

  .verse-original {
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 8px;
  }

  /* 5. 深層解析彈窗手機適配 */
  .insight-modal-card {
    width: 95vw;
    max-height: 86vh;
    padding: 20px 14px;
    border-radius: 20px;
  }

  .modal-close-btn {
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    font-size: 18px;
  }

  .modal-header-row {
    padding-right: 44px; /* 手機端嚴格避讓右上角 ✕ 圓形按鈕 */
  }

  .modal-seal-badge {
    font-size: 0.72rem;
    padding: 3px 9px;
  }

  .modal-theme-title {
    font-size: 1.15rem;
  }

  .modal-original-quote {
    font-size: 1rem;
    padding: 10px 12px;
  }

  /* 3D 名牌在手機直螢幕上完整顯示「數字 篇名」（如：01學而、05公冶長、20堯曰） */
  .island-3d-label {
    padding: 2px 7px 2px 3px;
    gap: 4px;
    font-size: 0.72rem;
  }

  .island-3d-label .num-dot {
    min-width: 19px;
    height: 18px;
    padding: 0 4px;
    font-size: 0.65rem;
    border-radius: 5px;
  }

  .island-3d-label .label-text {
    display: inline !important;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.3px;
  }
}

/* ========================================================
   宣紙水墨開門載入遮罩 (Loading Overlay)
   ======================================================== */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: radial-gradient(circle at center, #fcf9f2 0%, #ebf2f5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.65s;
}

#loading-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  padding: 30px;
}

.loading-seal {
  width: 54px;
  height: 54px;
  background: var(--seal-red);
  color: #fff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-seal, 'Ma Shan Zheng', cursive);
  font-size: 1.85rem;
  box-shadow: 0 8px 24px rgba(185, 56, 38, 0.28);
  margin-bottom: 20px;
  position: relative;
  z-index: 2;
}

.loading-spinner {
  width: 78px;
  height: 78px;
  border: 2px dashed rgba(179, 135, 40, 0.2);
  border-top: 2px solid var(--gold);
  border-radius: 50%;
  position: absolute;
  top: 18px;
  z-index: 1;
  animation: spinGold 2s linear infinite;
}

@keyframes spinGold {
  to { transform: rotate(360deg); }
}

.loading-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.12em;
  margin-bottom: 8px;
}

.loading-subtitle {
  font-size: 0.82rem;
  color: var(--ink-secondary);
  letter-spacing: 0.08em;
  animation: pulseGlow 1.8s ease-in-out infinite alternate;
}

@keyframes pulseGlow {
  from { opacity: 0.55; }
  to { opacity: 1; }
}
