/* ==========================================================================
   1. 设计系统与根变量 (Design System & Variables)
   ========================================================================== */
:root {
  /* 自然简约主题色 (Natural theme - Light Sage) */
  --bg-color: #F7F9F6;
  --panel-bg: #FFFFFF;
  --primary-color: #2D5A27;
  --primary-light: #E1ECE2;
  --primary-hover: #1E3F19;
  --accent-color: #4F8549;
  --text-main: #233322;
  --text-muted: #5F745E;
  --border-color: #E2EBE2;
  --danger-color: #A34E36;
  --danger-light: #FCECE8;
  --success-color: #3B7A57;
  --success-light: #E8F4EE;
  
  /* 苹果玻璃质感变量 (Sage Green Style) */
  --glass-bg: rgba(247, 249, 246, 0.55);
  --glass-border: rgba(45, 90, 39, 0.12);
  --blur-radius: 20px;
  --saturate-amount: 190%;
  
  /* 阴影与圆角 (Shadows & Border Radius) */
  --shadow-sm: 0 2px 4px rgba(45, 90, 39, 0.04);
  --shadow-md: 0 8px 16px rgba(45, 90, 39, 0.06);
  --shadow-lg: 0 16px 32px rgba(45, 90, 39, 0.08);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  
  /* 字体与间距 (Typography & Spacing) */
  --font-main: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-title: 'Outfit', 'Noto Sans SC', sans-serif;
  --transition-speed: 0.3s;
}

/* 深色模式变量 (Dark Sage Theme) */
body.dark-theme {
  --bg-color: #111A10;
  --panel-bg: #1A2519;
  --primary-color: #4F8549;
  --primary-light: #243522;
  --primary-hover: #67AB5E;
  --accent-color: #83B67C;
  --text-main: #E2ECE1;
  --text-muted: #8E9F8D;
  --border-color: #283726;
  
  /* 苹果玻璃质感深色变量 */
  --glass-bg: rgba(22, 33, 21, 0.65);
  --glass-border: rgba(255, 255, 255, 0.08);
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   1.1 动态流光背景样式 (Dynamic Glow Background)
   ========================================================================== */
.glow-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.glow-ball {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  mix-blend-mode: multiply;
  animation: float 25s infinite alternate ease-in-out;
}

body.dark-theme .glow-ball {
  opacity: 0.22;
  mix-blend-mode: screen;
}

.glow-ball-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--primary-color) 0%, transparent 70%);
  top: -10%;
  left: -10%;
  animation-duration: 20s;
}

.glow-ball-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent-color) 0%, transparent 70%);
  bottom: -10%;
  right: -10%;
  animation-duration: 28s;
  animation-delay: -5s;
}

.glow-ball-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #83b67c 0%, transparent 70%);
  top: 40%;
  left: 50%;
  animation-duration: 22s;
  animation-delay: -10s;
}

@keyframes float {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
  }
  50% {
    transform: translate(80px, 50px) scale(1.15) rotate(180deg);
  }
  100% {
    transform: translate(-40px, 80px) scale(0.9) rotate(360deg);
  }
}

/* ==========================================================================
   2. 基础重置与布局 (Reset & Global Styles)
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
  font-family: var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-main);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 按钮与表单重置 */
button, input {
  font-family: inherit;
}

/* ==========================================================================
   3. 布局结构 (App Layout)
   ========================================================================== */
.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* 侧边栏样式 */
.sidebar {
  width: 320px;
  height: 100%;
  background-color: var(--glass-bg);
  backdrop-filter: blur(var(--blur-radius)) saturate(var(--saturate-amount));
  -webkit-backdrop-filter: blur(var(--blur-radius)) saturate(var(--saturate-amount));
  border-right: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm), inset -1px 0 0 rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1), margin-left var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  position: relative;
}

/* 玻璃质感噪点叠加 */
.sidebar::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 99;
  filter: url(#noise-filter);
  opacity: 0.08;
}

.sidebar-header {
  padding: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-img {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.logo-text h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-color);
  font-family: var(--font-title);
  letter-spacing: 0.5px;
}

.logo-text span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* 搜索栏 */
.search-bar {
  padding: 16px 24px;
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: 12px 16px 12px 40px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-color);
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition-speed);
}

.search-bar input:focus {
  border-color: var(--accent-color);
}

.search-icon {
  position: absolute;
  left: 36px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* 章节列表 */
.chapter-list-container {
  flex-grow: 1;
  overflow-y: auto;
  padding: 8px 16px 24px;
}

.list-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-bottom: 12px;
  padding-left: 12px;
}

.chapter-list {
  list-style: none;
}

.chapter-item {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.92rem;
  color: var(--text-main);
  margin-bottom: 4px;
  transition: all var(--transition-speed) ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.chapter-item:hover {
  background-color: var(--bg-color);
  transform: translateX(4px);
}

.chapter-item.active {
  background-color: var(--primary-light);
  color: var(--primary-color);
  font-weight: 500;
}

/* 章节列表中的状态标签 */
.status-badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 500;
}

.status-badge.done {
  background-color: var(--success-light);
  color: var(--success-color);
}

.status-badge.pending {
  background-color: #ECECEC;
  color: #777777;
}

.sidebar-badges {
  display: flex;
  gap: 4px;
  align-items: center;
}

.status-badge.custom-badge {
  background-color: #FFF3E0;
  color: #E65100;
  border: 1px solid #FFE0B2;
}

body.dark-theme .status-badge.custom-badge {
  background-color: #3E2723;
  color: #FFB74D;
  border: 1px solid #5D4037;
}

/* 侧边栏遮罩 */
.sidebar-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 90;
}

/* 主内容区域 */
.main-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 顶部导航栏 */
.top-bar {
  height: 70px;
  padding: 0 24px;
  background-color: var(--glass-bg);
  backdrop-filter: blur(var(--blur-radius)) saturate(var(--saturate-amount));
  -webkit-backdrop-filter: blur(var(--blur-radius)) saturate(var(--saturate-amount));
  border-bottom: 1px solid var(--glass-border);
  box-shadow: var(--shadow-sm), inset 0 -1px 0 rgba(255, 255, 255, 0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  position: relative;
}

.top-bar::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 99;
  filter: url(#noise-filter);
  opacity: 0.08;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.current-chapter-info h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.current-chapter-info span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.toggle-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-main);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  width: 44px;
  min-width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-speed);
}

.toggle-btn:hover {
  background-color: var(--bg-color);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-mode-tabs {
  position: relative;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding: 4px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-color);
}

.top-mode-tab {
  display: inline-flex;
  min-width: 0;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color var(--transition-speed), background-color var(--transition-speed), color var(--transition-speed);
}

.top-mode-tab:hover,
.top-mode-tab:focus-visible {
  border-color: var(--border-color);
  color: var(--primary-color);
}

.top-mode-tab.is-active {
  border-color: var(--primary-color);
  background: var(--primary-light);
  color: var(--primary-color);
}

.top-mode-tab[hidden] {
  display: none;
}

.theme-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  width: 44px;
  min-width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-color);
  transition: transform var(--transition-speed);
}

.theme-btn:hover {
  transform: rotate(30deg);
}

.sync-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  width: 44px;
  min-width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-color);
  transition: transform var(--transition-speed), background-color var(--transition-speed);
}

.sync-btn:hover {
  transform: rotate(180deg);
  background-color: var(--primary-color-light, rgba(59, 130, 246, 0.15));
}

.sync-btn svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

/* ==========================================================================
   4. 标签页组件 (Tab Layout)
   ========================================================================== */
.tab-container {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tab-nav {
  display: flex;
  padding: 0 24px;
  background-color: var(--panel-bg);
  border-bottom: 1px solid var(--border-color);
  gap: 8px;
}

.tab-link {
  background: none;
  border: none;
  padding: 16px 20px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all var(--transition-speed);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-link:hover {
  color: var(--primary-color);
}

.tab-link.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  font-weight: 600;
}

.tab-content-container {
  flex-grow: 1;
  overflow: hidden;
  position: relative;
}

.tab-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  padding: 24px;
  overflow-y: auto;
}

.tab-content.active {
  display: block;
}

/* ==========================================================================
   5. 思维导图面板 (Mindmap Tab)
   ========================================================================== */
.mindmap-container {
  width: 100%;
  flex: 1;
  min-height: 0;
  position: relative;
  background-color: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#mindmap-iframe {
  width: 100%;
  flex: 1;
  min-height: 0;
  border: none;
}

.mindmap-actions {
  flex: 0 0 auto;
  flex-shrink: 0;
  position: relative;
  padding: 10px 16px;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.mindmap-level-controls {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-right: auto;
  padding: 3px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--panel-bg);
}

.mindmap-level-btn {
  min-height: 32px;
  padding: 5px 9px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
}

.mindmap-level-btn:hover,
.mindmap-level-btn:focus-visible {
  background: var(--primary-light);
  color: var(--primary-color);
}

.mindmap-level-btn[aria-pressed="true"] {
  background: var(--primary-light);
  color: var(--primary-color);
  box-shadow: inset 0 0 0 1px var(--primary-color);
}

.mindmap-actions .btn {
  min-height: 40px;
  padding: 8px 12px;
}

.mindmap-actions svg,
.top-mode-tab svg,
.theme-btn svg,
.settings-btn svg,
.toggle-btn svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.tool-menu {
  position: relative;
}

.tool-menu > summary {
  min-width: 88px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 5px;
  background: var(--primary-light);
  color: var(--primary-color);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.tool-menu > summary::-webkit-details-marker {
  display: none;
}

.tool-menu > summary svg,
.tool-menu-item svg {
  width: 17px;
  height: 17px;
}

.tool-menu-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 30;
  width: 210px;
  padding: 6px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--panel-bg);
  box-shadow: var(--shadow-md);
}

.tool-menu-item {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-main);
  font: inherit;
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
}

.tool-menu-item:hover,
.tool-menu-item:focus-visible {
  background: var(--primary-light);
  color: var(--primary-color);
}

/* ==========================================================================
   6. 3D 闪卡背诵面板 (Flashcard Tab)
   ========================================================================== */
.flashcards-container {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 18px 20px 24px;
  overflow-y: auto;
  box-sizing: border-box;
}

.flashcards-active-area {
  width: 100%;
  max-width: 760px;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 12px;
  box-sizing: border-box;
}

/* 闪卡顶部进度 */
.flashcard-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 0 auto;
  flex-shrink: 0;
}

.flashcard-header-row {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.flashcard-control-group {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.flashcard-tool-btn,
.flashcard-save-btn,
.flashcard-cancel-btn {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 7px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  background: var(--panel-bg);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 650;
  cursor: pointer;
}

.flashcard-tool-btn svg,
.flashcard-save-btn svg,
.flashcard-cancel-btn svg {
  width: 15px;
  height: 15px;
}

.flashcard-tool-btn:hover,
.flashcard-tool-btn:focus-visible,
.flashcard-cancel-btn:hover,
.flashcard-cancel-btn:focus-visible {
  background: var(--primary-light);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.flashcard-tool-danger:hover,
.flashcard-tool-danger:focus-visible {
  color: var(--danger-color);
  border-color: var(--danger-color);
}

.flashcard-save-btn {
  color: white;
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.flashcard-save-btn:hover,
.flashcard-save-btn:focus-visible {
  filter: brightness(0.94);
}

.flashcard-edit-local {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  background: var(--panel-bg);
  color: var(--primary-color);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 650;
  cursor: pointer;
}

.flashcard-edit-local:hover,
.flashcard-edit-local:focus-visible {
  background: var(--primary-light);
  border-color: var(--primary-color);
}

.flashcard-edit-local svg {
  width: 15px;
  height: 15px;
}

/* Question-book cards retain their original ① / （1） numbering. */
.card-answer-text .question-book-answer-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.card-answer-text .question-book-answer-list > li {
  margin: 0 0 0.7em;
  padding: 0;
}

.card-answer-text .question-book-answer-list > li:last-child {
  margin-bottom: 0;
}

.flashcard-enter-immersive,
.flashcard-exit-immersive {
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.flashcard-enter-immersive {
  display: grid;
}

.flashcard-exit-immersive {
  display: none;
}

.flashcard-enter-immersive:hover,
.flashcard-enter-immersive:focus-visible,
.flashcard-exit-immersive:hover,
.flashcard-exit-immersive:focus-visible {
  background: var(--primary-light);
  color: var(--primary-color);
}

.flashcard-enter-immersive svg,
.flashcard-exit-immersive svg {
  width: 18px;
  height: 18px;
}

.progress-info {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px;
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 500;
}

.progress-info strong {
  color: var(--primary-color);
  font-size: 0.9rem;
}

.progress-bar-outer {
  width: 100%;
  height: 4px;
  background-color: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-inner {
  height: 100%;
  width: 0%;
  background-color: var(--primary-color);
  border-radius: 4px;
  transition: width var(--transition-speed) ease;
}

/* 3D 翻转卡片容器 */
.card-scene {
  width: 100%;
  flex: 1;
  min-height: 200px;
  max-height: 560px;
  height: auto;
  perspective: 1000px; /* 3D 透视深度 */
}

.flashcard {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.42s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.flashcard:focus-visible {
  outline: 3px solid var(--accent-color);
  outline-offset: 4px;
}

.flashcard.is-flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden; /* 隐藏背面以防止重叠 */
  border-radius: 8px;
  padding: 26px 28px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  background-color: var(--panel-bg);
  overflow: hidden;
}

/* 卡片正面与背面配色 */
.card-front {
  justify-content: space-between;
}

.card-back {
  transform: rotateY(180deg); /* 背面翻转 180 度 */
  justify-content: space-between;
}

.card-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.card-tag {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  padding: 4px 10px;
  background-color: var(--primary-light);
  color: var(--primary-color);
  border-radius: 12px;
  align-self: flex-start;
  white-space: nowrap;
}

.card-back .card-tag {
  background-color: var(--success-light);
  color: var(--success-color);
}

.card-question-text {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.6;
  color: var(--text-main);
  text-align: left;
  flex-grow: 1;
  display: flex;
  align-items: center;
  width: 100%;
  padding: 8px 12px;
  overflow: visible;
}

.card-answer-text-container {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: block;
  padding: 12px 0;
  /* 固定高度卡片内部滚动 */
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.card-answer-text {
  font-size: 0.98rem;
  line-height: 1.7;
  color: var(--text-main);
  width: 100%;
  text-align: justify;
}

.card-answer-text ul {
  list-style-type: disc;
  padding-left: 20px;
  margin: 10px 0;
}

.card-answer-text ul ul {
  list-style-type: disc; /* Fixed: Enforce solid disc bullet to prevent browser default hollow circle 'o' looking like a Chinese period '。' */
  padding-left: 20px;
  margin: 5px 0;
}

.card-answer-text ol {
  padding-left: 20px;
  margin: 10px 0;
}

.card-answer-text li {
  margin-bottom: 10px;
  line-height: 1.6;
}

.card-answer-text table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.92rem;
  line-height: 1.5;
  background: var(--panel-bg, #fff);
  border-radius: var(--radius-sm, 6px);
  overflow: hidden;
  border: 1px solid var(--border-color, #e2e8f0);
}

.card-answer-text th,
.card-answer-text td {
  border: 1px solid var(--border-color, #e2e8f0);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}

.card-answer-text th,
.card-answer-text tr:first-child td {
  background: var(--bg-secondary, rgba(0, 0, 0, 0.04));
  font-weight: 600;
  color: var(--primary-color, #0284c7);
}

.card-answer-text .answer-section-title {
  margin: 14px 0 6px;
  font-size: 1rem;
  line-height: 1.5;
}

.card-answer-text .answer-section-title:first-child {
  margin-top: 2px;
}

.card-answer-text .answer-hierarchy > .answer-section-title {
  margin: 15px 0 7px;
  padding-bottom: 5px;
  border-bottom: 1px solid color-mix(in srgb, var(--border-color) 78%, transparent);
}

.card-answer-text .answer-hierarchy > .answer-section-title:first-child {
  margin-top: 0;
}

.card-answer-text .answer-section-list {
  margin: 5px 0 12px;
  padding-left: 23px;
}

.card-answer-text .answer-section-list > li {
  margin-bottom: 8px;
}

.card-answer-text .answer-section-list > li.answer-example {
  list-style: none;
  margin: 7px 0 9px 3px;
  padding: 7px 9px;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--text-muted) 6%, transparent);
  border-left: 2px solid color-mix(in srgb, var(--accent-color) 28%, transparent);
  border-radius: 0 4px 4px 0;
}

.card-answer-text .answer-structure-label {
  display: inline;
  margin-right: 3px;
}

.card-answer-text .answer-summary {
  margin: 2px 0 12px;
  padding: 9px 11px;
  border-left: 3px solid var(--accent-color);
  background: color-mix(in srgb, var(--accent-color) 7%, transparent);
  border-radius: 0 4px 4px 0;
  line-height: 1.65;
}

.card-answer-text .answer-major-list {
  margin: 6px 0 0;
  padding-left: 24px;
}

.card-answer-text .answer-major-list > li {
  margin-bottom: 14px;
  padding-left: 3px;
}

.card-answer-text .answer-subpoint,
.card-answer-text .answer-detail,
.card-answer-text .answer-example {
  margin: 6px 0 0;
  line-height: 1.65;
}

.card-answer-text .answer-subpoint {
  padding-left: 10px;
  border-left: 2px solid color-mix(in srgb, var(--accent-color) 22%, transparent);
}

.card-answer-text .answer-example {
  margin-left: 10px;
  padding: 6px 9px;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--text-muted) 6%, transparent);
  border-radius: 4px;
}

.card-answer-text li.answer-example {
  list-style: none;
}

.card-answer-text .answer-subexample,
.card-answer-text li.answer-example,
.card-answer-text p.answer-example,
.card-answer-text div.answer-example {
  border-left: 2px solid color-mix(in srgb, var(--accent-color) 28%, transparent);
}

@media (max-width: 430px) {
  .card-answer-text .answer-summary {
    padding: 8px 9px;
  }

  .card-answer-text .answer-major-list {
    padding-left: 21px;
  }

  .card-answer-text .answer-section-list {
    padding-left: 20px;
  }

  .card-answer-text .answer-subpoint,
  .card-answer-text .answer-example {
    margin-left: 0;
    padding-left: 8px;
  }
}

/* Premium Highlight Badges for Study Key Points */
.card-answer-text span[style*="#0284c7"],
.card-answer-text span[style*="#0d9488"],
.card-answer-text span[style*="#e11d48"],
.card-answer-text span[style*="#ea580c"] {
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 4px;
  display: inline;
  margin: 0 2px;
}

/* Light Theme Backgrounds */
.card-answer-text span[style*="#0284c7"] {
  background-color: rgba(2, 132, 199, 0.07);
}
.card-answer-text span[style*="#0d9488"] {
  background-color: rgba(13, 148, 136, 0.07);
}
.card-answer-text span[style*="#e11d48"] {
  background-color: rgba(225, 29, 72, 0.07);
}
.card-answer-text span[style*="#ea580c"] {
  background-color: rgba(234, 88, 12, 0.07);
}

/* Dark Theme Backgrounds */
body.dark-theme .card-answer-text span[style*="#0284c7"] {
  background-color: rgba(2, 132, 199, 0.18);
}
body.dark-theme .card-answer-text span[style*="#0d9488"] {
  background-color: rgba(13, 148, 136, 0.18);
}
body.dark-theme .card-answer-text span[style*="#e11d48"] {
  background-color: rgba(225, 29, 72, 0.18);
}
body.dark-theme .card-answer-text span[style*="#ea580c"] {
  background-color: rgba(234, 88, 12, 0.18);
}

.card-answer-text.textbook-answer span[style*="color"] {
  color: inherit !important;
  background: transparent !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 0 !important;
}

.card-answer-text.textbook-answer strong {
  color: var(--text-main);
  font-weight: 820;
}

.card-answer-text.textbook-answer .answer-structure-label,
.card-answer-text.textbook-answer .material-point-title {
  color: var(--primary-color);
  font-weight: 820;
}

.tap-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
  border-top: 1px dashed var(--border-color);
  padding-top: 10px;
}

.tap-hint svg,
.card-page-source svg,
.card-nav svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.card-nav,
.flashcards-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 0;
  flex: 0 0 auto;
  flex-shrink: 0;
}

.card-nav .btn {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border-color);
  background: var(--panel-bg);
}

/* ==========================================================================
   7. 指南与说明面板 (About Tab)
   ========================================================================== */
.guide-container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.guide-section {
  background-color: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.guide-section h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.guide-section p {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* 数据看板 */
.stats-panel {
  display: flex;
  gap: 16px;
  margin: 24px 0 8px;
}

.stat-card {
  flex: 1;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
  font-family: var(--font-title);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* 步骤指南 */
.steps-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--primary-light);
  color: var(--primary-color);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-info {
  font-size: 0.95rem;
  line-height: 1.6;
}

.anki-import-tip {
  background-color: var(--bg-color);
  border-left: 4px solid var(--accent-color);
  padding: 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.9rem;
  margin-top: 16px;
}

.anki-import-tip ol {
  margin-left: 20px;
  margin-top: 8px;
}

.anki-import-tip li {
  margin-bottom: 6px;
  line-height: 1.5;
}

.code-box {
  background-color: #1E251D;
  color: #C8E6C9;
  font-family: 'Courier New', Courier, monospace;
  padding: 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 12px 0 20px;
  overflow-x: auto;
}

/* ==========================================================================
   8. 公用 UI 组件 (Button, Status MSG)
   ========================================================================== */
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

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

.btn-secondary {
  background-color: var(--primary-light);
  color: var(--primary-color);
}

.btn-secondary:hover {
  background-color: var(--border-color);
}

.btn-danger {
  background-color: var(--danger-light);
  color: var(--danger-color);
}

.btn-danger:hover {
  filter: brightness(0.95);
}

.btn-success {
  background-color: var(--success-light);
  color: var(--success-color);
}

.btn-success:hover {
  filter: brightness(0.95);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
}

/* 未生成提示层 */
.status-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  flex-grow: 1;
  background-color: var(--panel-bg);
}

.status-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
}

.status-msg h3 {
  font-size: 1.25rem;
  margin-bottom: 8px;
}

.status-msg p {
  color: var(--text-muted);
  font-size: 0.92rem;
  max-width: 380px;
  line-height: 1.6;
}

/* 正在加载骨架 */
.loading-placeholder {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 20px;
}

/* ==========================================================================
   9. 响应式布局媒体查询 (Responsive CSS)
   ========================================================================== */

/* 手机和平板 (屏幕宽度小于 768px) */
@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    top: 0;
    left: 0;
    transform: translateX(-100%); /* 隐藏侧边栏 */
    height: 100%;
    box-shadow: var(--shadow-lg);
  }
  
  .sidebar.open {
    transform: translateX(0); /* 展开侧边栏 */
  }
  
  .sidebar-overlay.open {
    display: block; /* 展示遮罩层 */
  }
  
  .top-bar {
    padding: 0 10px;
    height: 52px;
  }

  .top-bar .logo-text h2,
  .top-bar .current-chapter-info h2 {
    font-size: 0.92rem;
    margin: 0;
    line-height: 1.2;
  }

  .top-bar .current-chapter-info span {
    font-size: 0.68rem;
    display: none;
  }

  .top-mode-tabs {
    display: flex !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: 58vw;
    padding: 2px 4px;
    gap: 3px;
  }

  .top-mode-tabs::-webkit-scrollbar {
    display: none;
  }

  .top-mode-tab {
    flex-shrink: 0 !important;
    padding: 4px 8px !important;
    min-height: 30px !important;
    font-size: 0.75rem !important;
  }

  .main-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .mindmap-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  #mindmap-iframe {
    flex: 1;
    min-height: 0;
  }

  .mindmap-actions {
    flex: 0 0 auto;
    flex-shrink: 0;
    padding: 6px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    gap: 4px;
    overflow-x: auto;
    white-space: nowrap;
  }

  .mindmap-level-btn,
  .mindmap-actions .btn {
    padding: 4px 8px;
    font-size: 0.74rem;
    height: 30px;
    flex-shrink: 0;
  }
  
  .tab-nav {
    padding: 0 16px;
    overflow-x: auto; /* 支持横向滑动 */
    scrollbar-width: none; /* 隐藏 Firefox 滚动条 */
  }
  
  .tab-nav::-webkit-scrollbar {
    display: none; /* 隐藏 Webkit 滚动条 */
  }
  
  .tab-link {
    white-space: nowrap;
    padding: 14px 16px;
  }
  
  .tab-content {
    padding: 16px;
  }
  
  .card-scene {
    flex: 1;
    min-height: 180px;
    max-height: 560px;
    height: auto;
  }
  
  .card-face {
    padding: 16px 18px;
  }
  
  .card-question-text {
    font-size: 1.25rem;
  }
  
  .card-answer-text {
    font-size: 0.95rem;
  }
  
  .stats-panel {
    flex-direction: column;
    gap: 12px;
  }
  
}

/* 手机端收纳顶部模式 (Compact Mobile Header) */
body.compact-header .top-bar {
  height: 38px !important;
  padding: 0 8px !important;
}

body.compact-header .top-bar .logo-img,
body.compact-header .top-bar .current-chapter-info span {
  display: none !important;
}

body.compact-header .top-mode-tab {
  min-height: 26px !important;
  padding: 2px 6px !important;
  font-size: 0.7rem !important;
}

/* 大屏幕电脑适配 (提升视觉留白) */
@media (min-width: 1200px) {
  .flashcards-active-area {
    max-width: 720px;
  }
  
  .card-scene {
    height: 500px;
    min-height: 500px;
    max-height: 500px;
  }
}

/* 隐藏移动端专用元素 */
.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  .mobile-only {
    display: block;
  }
}

/* Flashcard tablets use the chapter list as a drawer so the study card keeps a usable width. */
@media (min-width: 769px) and (max-width: 900px) {
  body.flashcard-page .sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: min(88vw, 340px);
    height: 100%;
    margin-left: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

  body.flashcard-page .sidebar.open {
    transform: translateX(0);
  }

  body.flashcard-page .sidebar-overlay.open {
    display: block;
  }

  body.flashcard-page .sidebar-toggle-trigger {
    display: none !important;
  }

  body.flashcard-page .mobile-only {
    display: block;
  }

  body.flashcard-page .main-content {
    min-width: 0;
  }
}

/* ==========================================================================
   10. 编辑器样式 (Editor Styles)
   ========================================================================== */
.editor-area {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  flex-grow: 1;
  padding: 16px;
  background-color: var(--panel-bg);
}

.editor-area textarea {
  width: 100%;
  height: 100%;
  flex-grow: 1;
  min-height: 250px;
  resize: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: 'Consolas', 'Courier New', Courier, monospace;
  font-size: 0.95rem;
  line-height: 1.6;
  background-color: var(--bg-color);
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition-speed);
}

.editor-area textarea:focus {
  border-color: var(--accent-color);
}

.editor-help-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  background-color: var(--primary-light);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  line-height: 1.4;
  border-left: 4px solid var(--primary-color);
}

/* 侧边栏折叠规则 (Desktop sidebar collapse) */
@media (min-width: 769px) {
  .sidebar.collapsed {
    margin-left: -320px;
  }
}

/* 设置卡片样式 (Settings card) */
.settings-card {
  padding: 20px;
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-top: 16px;
}
.settings-card h4 {
  font-size: 1.05rem;
  color: var(--primary-color);
  margin-bottom: 8px;
}
.settings-card p {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* details / summary 折叠面板 */
details.guide-details {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--panel-bg);
  box-shadow: var(--shadow-sm);
  margin-top: 16px;
  overflow: hidden;
}
details.guide-details[open] {
  border-color: var(--primary-color);
}
summary.guide-summary {
  padding: 16px 24px;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--primary-color);
  background-color: var(--primary-light);
  cursor: pointer;
  outline: none;
  user-select: none;
}
summary.guide-summary:hover {
  background-color: var(--border-color);
}
.details-content {
  padding: 24px;
  border-top: 1px solid var(--border-color);
  background-color: var(--panel-bg);
}
.details-content h4 {
  color: var(--primary-color);
  margin-bottom: 12px;
  font-size: 1.05rem;
}
.details-content p {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 16px;
}

/* 设置模态框相关样式 (Global Settings Modal) */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.settings-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  background-color: var(--glass-bg);
  backdrop-filter: blur(var(--blur-radius)) saturate(var(--saturate-amount));
  -webkit-backdrop-filter: blur(var(--blur-radius)) saturate(var(--saturate-amount));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.settings-modal::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 99;
  filter: url(#noise-filter);
  opacity: 0.08;
}
.settings-modal.active {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

/* 旧设置项保留在源码中以兼容早期本地数据，但不再展示给学习者。 */
.settings-modal [hidden] {
  display: none !important;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bg-color);
}
.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-speed);
}
.modal-close-btn:hover {
  background-color: var(--border-color);
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex-grow: 1;
}

.settings-action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.settings-action-grid .btn {
  width: 100%;
  min-height: 42px;
  white-space: normal;
}

/* 移除多余的标签导航之后，为主界面设置内边距修正 */
.single-mode-container {
  box-sizing: border-box;
  width: 100%;
  padding: 24px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* 在顶部工具栏的设置按钮样式 */
.settings-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  width: 44px;
  min-width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-color);
  transition: transform var(--transition-speed);
}
.settings-btn:hover {
  transform: rotate(45deg);
}

/* ==========================================================================
   11. 书籍选择器与视图切换按钮 (Book Selector & View Switcher Styles)
   ========================================================================== */
.study-navigation {
  padding: 14px 20px 16px;
  border-bottom: 1px solid var(--border-color);
  background: color-mix(in srgb, var(--panel-bg) 88%, transparent);
}

.study-navigation-label {
  display: block;
  margin: 0 0 7px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
}

.study-navigation .book-select {
  margin-bottom: 0;
}

/* 微信/苹果风双按钮分段学科切换器 */
.subject-toggle-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  background: var(--bg-color);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.subject-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  cursor: pointer;
  transition: all var(--transition-speed);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subject-toggle-btn:hover {
  color: var(--text-main);
  background: color-mix(in srgb, var(--primary-light) 40%, transparent);
}

.subject-toggle-btn.active,
.subject-toggle-btn[aria-selected="true"] {
  color: var(--primary-color);
  background: var(--panel-bg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

/* 全量知识库检索浮层 */
.search-bar {
  position: relative;
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 380px;
  overflow-y: auto;
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
}

.search-result-item {
  padding: 10px 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--border-color) 40%, transparent);
  cursor: pointer;
  transition: background var(--transition-speed);
}

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

.search-result-item:hover {
  background: var(--primary-light);
}

.search-result-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.search-result-badge {
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--primary-light);
  color: var(--primary-color);
}

.search-result-snippet {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.search-result-snippet mark {
  background: color-mix(in srgb, var(--accent-color) 35%, transparent);
  color: var(--text-main);
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 600;
}

/* 真题/模拟题双页模式 (Dual-Column Grid) */
.exam-scroll.dual-column #exam-question-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 18px;
  align-items: start;
}

@media (min-width: 900px) {
  .exam-scroll.dual-column #exam-question-groups {
    grid-template-columns: repeat(2, 1fr);
  }
}

.study-mode-menu {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.study-mode-link {
  display: flex;
  min-width: 0;
  min-height: 40px;
  align-items: center;
  gap: 6px;
  padding: 8px 9px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-color);
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
  transition: border-color var(--transition-speed), background-color var(--transition-speed), color var(--transition-speed);
}

.study-mode-link:hover,
.study-mode-link:focus-visible {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.study-mode-link.is-active {
  border-color: var(--primary-color);
  background: var(--primary-light);
  color: var(--primary-color);
}

.study-mode-link[hidden] {
  display: none;
}

body.dark-theme .study-navigation {
  background: color-mix(in srgb, var(--panel-bg) 92%, transparent);
}

body.dark-theme .top-mode-tabs {
  background: var(--panel-bg);
}

.book-selector-container {
  position: relative;
  width: 100%;
  margin-top: 8px;
}

.book-select {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-color);
  background-color: var(--primary-light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='6' fill='%232D5A27'><path d='M0 0h12L6 6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 28px;
  transition: all var(--transition-speed);
}

body.dark-theme .book-select {
  color: var(--text-main);
  background-color: var(--primary-light);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='6' fill='%23E2ECE1'><path d='M0 0h12L6 6z'/></svg>");
}

.book-select:hover {
  background-color: var(--border-color);
}

.view-switch-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background-color: var(--primary-light);
  color: var(--primary-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-speed);
  margin-right: 8px;
  min-height: 44px;
}

.pwa-status {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 1000001;
  max-width: min(520px, calc(100vw - 32px));
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--panel-bg);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  font-size: 0.78rem;
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity var(--transition-speed), transform var(--transition-speed);
}

.pwa-status.is-visible {
  opacity: 0.96;
  transform: translate(-50%, 0);
}

.pwa-status[data-state="warning"] {
  border-color: #B7791F;
}

.view-switch-btn:hover {
  background-color: var(--primary-color);
  color: white;
  transform: translateY(-1px);
}

body.dark-theme .view-switch-btn {
  background-color: var(--primary-light);
  color: var(--text-main);
  border-color: var(--border-color);
}

body.dark-theme .view-switch-btn:hover {
  background-color: var(--primary-color);
  color: white;
}
/* ==========================================================================
   Inline Editor Panel (紧凑编辑弹窗)
   ========================================================================== */
.inline-editor-panel {
  position: fixed;
  background: rgba(255,255,255,0.98);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  padding: 14px;
  z-index: 10000002;
  width: 380px;
  max-width: calc(100vw - 16px);
  transform: translate(-50%, 8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
body.dark-theme .inline-editor-panel {
  background: rgba(30,41,59,0.98);
  border-color: rgba(255,255,255,0.1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.iep-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
}
.iep-btn {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: rgba(0,0,0,0.05);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--text-main, #2d3748);
  transition: background 0.12s ease;
}
.iep-btn:hover { background: rgba(0,0,0,0.1); }
body.dark-theme .iep-btn { background: rgba(255,255,255,0.08); color: #e2e8f0; }
body.dark-theme .iep-btn:hover { background: rgba(255,255,255,0.14); }
.iep-color-red { background: rgba(239,68,68,0.22) !important; color: #dc2626 !important; }
.iep-color-green { background: rgba(16,185,129,0.22) !important; color: #059669 !important; }
.iep-color-blue { background: rgba(59,130,246,0.22) !important; color: #2563eb !important; }
.iep-color-yellow { background: rgba(245,158,11,0.22) !important; color: #d97706 !important; }
.iep-editor {
  width: 100%;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  background: rgba(0,0,0,0.02);
  color: var(--text-main, #2d3748);
  outline: none;
  box-sizing: border-box;
  min-height: 80px;
  max-height: 200px;
  overflow-y: auto;
  line-height: 1.6;
  word-break: break-word;
}
.iep-editor:focus { border-color: var(--primary-color, #2b6cb0); }
.iep-editor:empty::before {
  content: attr(placeholder);
  color: rgba(0,0,0,0.3);
}
.iep-editor strong { font-weight: 700; }
body.dark-theme .iep-editor { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.12); color: #e2e8f0; }
body.dark-theme .iep-editor:empty::before { color: rgba(255,255,255,0.3); }
.iep-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.iep-action-btn {
  padding: 8px 20px;
  border: none;
  border-radius: 10px;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.12s ease;
}
.iep-save { background: #3b82f6; color: #fff; }
.iep-save:hover { background: #2563eb; }
.iep-cancel { background: rgba(0,0,0,0.06); color: var(--text-main, #2d3748); }
.iep-cancel:hover { background: rgba(0,0,0,0.1); }
body.dark-theme .iep-cancel { background: rgba(255,255,255,0.08); color: #e2e8f0; }

/* ==========================================================================
   Floating Unified Toolbar (统一浮动工具栏：格式 + 节点操作)
   ========================================================================== */
.floating-format-bar {
  position: fixed;
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 5px 8px;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 22px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15), 0 0 0 0.5px rgba(0,0,0,0.05);
  z-index: 10000001;
  transform: translate(-50%, -8px);
  transition: opacity 0.15s ease, transform 0.2s cubic-bezier(0.16,1,0.3,1);
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
  max-width: calc(100vw - 16px);
  overflow-x: auto;
  scrollbar-width: none;
}
.floating-format-bar::-webkit-scrollbar { display: none; }
.floating-format-bar.show {
  display: flex;
  opacity: 1;
}
body.dark-theme .floating-format-bar {
  background: rgba(30,41,59,0.97);
  border-color: rgba(255,255,255,0.12);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.fmt-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text-main, #2d3748);
  transition: background 0.12s ease, transform 0.12s ease;
  flex-shrink: 0;
  line-height: 1;
}
.fmt-btn { position: relative; }
.fmt-btn:hover { background: rgba(0,0,0,0.07); }
.fmt-btn:hover::after {
  content: attr(title);
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: #fff;
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}
.fmt-btn:active { background: rgba(0,0,0,0.13); transform: scale(0.9); }
.fmt-btn:active::after { display: none; }
body.dark-theme .fmt-btn { color: #e2e8f0; }
body.dark-theme .fmt-btn:hover { background: rgba(255,255,255,0.08); }
body.dark-theme .fmt-btn:active { background: rgba(255,255,255,0.14); }
.fmt-btn-danger { color: #ef4444 !important; }
.fmt-btn-danger:hover { background: rgba(239,68,68,0.12) !important; }
.fmt-divider {
  width: 1px;
  height: 16px;
  background: rgba(0,0,0,0.12);
  margin: 0 3px;
  flex-shrink: 0;
}
body.dark-theme .fmt-divider { background: rgba(255,255,255,0.15); }
.fmt-color-red { color: #dc2626 !important; background: rgba(239,68,68,0.50) !important; }
.fmt-color-green { color: #059669 !important; background: rgba(16,185,129,0.50) !important; }
.fmt-color-blue { color: #2563eb !important; background: rgba(59,130,246,0.50) !important; }
.fmt-color-yellow { color: #d97706 !important; background: rgba(245,158,11,0.50) !important; }
.fmt-color-red:hover { background: rgba(239,68,68,0.65) !important; }
.fmt-color-green:hover { background: rgba(16,185,129,0.65) !important; }
.fmt-color-blue:hover { background: rgba(59,130,246,0.65) !important; }
.fmt-color-yellow:hover { background: rgba(245,158,11,0.65) !important; }

/* ==========================================================================
   Bottom Sheet 底部抽屉样式
   ========================================================================== */
.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 800px; /* 平板和大屏限制宽度 */
  margin: 0 auto;   /* 居中对齐 */
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-bottom: none;
  border-top-left-radius: var(--radius-lg, 20px);
  border-top-right-radius: var(--radius-lg, 20px);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.18);
  z-index: 10000000 !important;
  transform: translateY(105%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 16px 20px 24px;
}

.bottom-sheet.active {
  transform: translateY(0) !important;
}

body.dark-theme .bottom-sheet {
  background: rgba(15, 23, 42, 0.96);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
}

/* 顶部把手 */
.bottom-sheet-drag-handle {
  width: 40px;
  height: 4px;
  background-color: var(--text-muted);
  opacity: 0.3;
  border-radius: 2px;
  margin: 0 auto 12px;
}

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

.bottom-sheet-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.bottom-sheet-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.bottom-sheet-close:hover {
  opacity: 1;
}

.bottom-sheet-body {
  position: relative;
}

/* 操作组按钮 */
.bs-action-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.bs-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  min-width: 110px;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--panel-bg);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.bs-btn:active {
  transform: scale(0.96);
}

.bs-btn:hover {
  border-color: var(--accent-color);
  background-color: var(--primary-light);
  color: var(--primary-color);
}

.bs-btn-danger {
  color: var(--danger-color);
  border-color: rgba(163, 78, 54, 0.2);
}

.bs-btn-danger:hover {
  background-color: var(--danger-light);
  border-color: var(--danger-color);
  color: var(--danger-color);
}

/* 输入编辑区 */
.bs-input-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bs-input-area textarea {
  width: 100%;
  height: 90px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--panel-bg);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  resize: none;
  transition: border-color 0.2s;
}

.bs-input-area textarea:focus {
  border-color: var(--accent-color);
}

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

/* 颜色面板 */
.bs-color-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.bs-color-title {
  font-size: 0.9rem;
  color: var(--text-main);
  font-weight: 500;
}

.bs-color-palette {
  display: flex;
  gap: 16px;
  margin: 8px 0;
}

.color-dot {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}

.color-dot:active {
  transform: scale(0.9);
}

.color-dot.selected {
  transform: scale(1.1);
  border-color: var(--accent-color);
}

.color-dot-default { background-color: var(--text-main); }
.color-dot-red { background-color: #ef4444; }
.color-dot-green { background-color: #10b981; }
.color-dot-blue { background-color: #3b82f6; }
.color-dot-yellow { background-color: #f59e0b; }

/* CSS-based Simulated Fullscreen Mode */
body.fullscreen-mode-active {
  overflow: hidden !important;
}

body.fullscreen-mode-active .app-container {
  overflow: hidden !important;
}

body.fullscreen-mode-active .mindmap-container {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 999999 !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background-color: var(--bg-color) !important;
}

body.fullscreen-mode-active #mindmap-iframe {
  height: 100% !important;
  width: 100% !important;
}



/* Sidebar Toggle Trigger (Floating handle) */
.sidebar-toggle-trigger {
  position: absolute;
  top: 50%;
  right: -20px;
  transform: translateY(-50%);
  width: 20px;
  height: 60px;
  background-color: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-left: none;
  border-top-right-radius: 10px;
  border-bottom-right-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.05);
  z-index: 101;
  color: var(--text-muted);
  font-size: 0.75rem;
  transition: all var(--transition-speed);
  user-select: none;
}

.sidebar-toggle-trigger:hover {
  background-color: var(--primary-light);
  color: var(--primary-color);
}

.sidebar.collapsed .sidebar-toggle-trigger {
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.15);
}

/* Hide toggle handle on mobile since sidebar is a drawer overlay there */
@media (max-width: 768px) {
  .sidebar-toggle-trigger {
    display: none !important;
  }
}

/* CSS-based Simulated Fullscreen Mode for Flashcards */
body.fullscreen-mode-active .flashcards-container {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 999999 !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background-color: var(--bg-color) !important;
  padding: 24px !important;
  overflow-y: auto !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
}

body.fullscreen-mode-active .flashcards-active-area {
  width: 100% !important;
  max-width: 680px !important;
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  gap: 16px !important;
}

/* ========================================================================== 
   v22 手机 / iPad 学习界面与来源状态
   ========================================================================== */
.glow-container {
  display: none;
}

.card-source-badge {
  align-self: flex-start;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.source-official {
  color: #166534;
  background: #dcfce7;
  border-color: #86efac;
}

.source-recall {
  color: #1d4ed8;
  background: #dbeafe;
  border-color: #93c5fd;
}

.source-simulation {
  color: #7c2d12;
  background: #ffedd5;
  border-color: #fdba74;
}

.source-textbook {
  color: #374151;
  background: #f3f4f6;
  border-color: #d1d5db;
}

.source-pending {
  color: #854d0e;
  background: #fef9c3;
  border-color: #fde047;
}

.completion-message {
  max-width: 30rem;
  margin: 0 auto;
  text-align: center;
  color: var(--text-muted);
  line-height: 1.7;
}

@supports (height: 100dvh) {
  .app-container {
    height: 100dvh;
  }
}

@media (max-width: 768px) {
  .app-container,
  .main-content {
    min-width: 0;
  }

  .sidebar {
    width: min(88vw, 340px);
    padding-top: env(safe-area-inset-top);
  }

  .top-bar {
    box-sizing: border-box;
    height: calc(116px + env(safe-area-inset-top));
    min-height: calc(116px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 10px 6px;
    gap: 8px;
    flex-wrap: wrap;
    align-content: center;
  }

  .top-bar-left {
    order: 1;
    flex: 1;
    min-width: 0;
    gap: 8px;
  }

  .current-chapter-info {
    min-width: 0;
  }

  .current-chapter-info h2 {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.95rem;
  }

  .current-chapter-info span {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.68rem;
  }

  .top-bar-right {
    order: 2;
    flex: 0 0 auto;
    gap: 4px;
  }

  .top-mode-tabs {
    order: 3;
    flex: 0 0 100%;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    gap: 3px;
    padding: 3px;
  }

  .top-mode-tab {
    flex: 1 1 0;
    min-height: 38px;
    padding: 6px 4px;
    gap: 4px;
    font-size: 0.72rem;
  }

  .view-switch-btn,
  .install-btn,
  .theme-btn,
  .settings-btn,
  .toggle-btn {
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
    margin: 0;
    border-radius: 6px;
  }

  .view-switch-btn {
    justify-content: center;
    font-size: 1rem;
  }

  .view-label,
  .install-label {
    display: none;
  }

  .single-mode-container {
    box-sizing: border-box;
    width: 100%;
    flex: 1;
    min-height: 0;
    padding: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .mindmap-container {
    border-radius: 6px;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .mindmap-actions {
    flex: 0 0 auto;
    flex-shrink: 0;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    overflow-x: auto;
    scrollbar-width: none;
  }

  .mindmap-actions::-webkit-scrollbar {
    display: none;
  }

  .mindmap-level-controls {
    margin-right: 0;
  }

  .mindmap-level-btn {
    min-height: 36px;
    padding: 6px 10px;
  }

  .mindmap-actions .btn {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 9px 12px;
    white-space: nowrap;
    font-size: 0.82rem;
  }

  .flashcards-container {
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0;
    overflow-y: auto;
    box-sizing: border-box;
  }

  .flashcards-active-area {
    width: 100%;
    max-width: none;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: env(safe-area-inset-bottom);
    box-sizing: border-box;
  }

  .card-scene {
    flex: 1;
    min-height: 180px;
    max-height: 520px;
    height: auto;
  }

  .card-face {
    padding: 16px;
    border-radius: 6px;
  }

  .card-question-text {
    padding: 8px 2px;
    font-size: 1.08rem;
    line-height: 1.55;
  }

  .flashcard-header-row {
    min-height: 30px;
  }

  .flashcard-enter-immersive,
  .flashcard-exit-immersive {
    width: 32px;
    height: 32px;
  }

  .flashcard-edit-local {
    min-height: 32px;
    padding: 5px 7px;
  }

  .card-answer-text-container {
    padding: 6px 0;
  }

  .card-answer-text {
    font-size: 0.9rem;
    line-height: 1.55;
  }

  .card-nav,
  .flashcards-actions {
    flex: 0 0 auto;
    flex-shrink: 0;
    gap: 6px !important;
    margin: 0 0 8px !important;
  }

  .card-nav .btn {
    min-height: 44px;
    padding: 8px 10px;
  }

  .card-nav .btn span {
    font-size: 0.78rem;
  }

  .settings-modal {
    top: calc(50% + env(safe-area-inset-top) / 2);
    width: calc(100% - 20px);
    max-height: calc(100dvh - 28px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    border-radius: 6px;
  }

  .modal-header,
  .modal-body {
    padding: 16px;
  }

  .bottom-sheet {
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 430px) {
  .install-btn {
    display: none;
  }

  .card-nav #edit-csv-btn,
  .card-nav #delete-fc-btn,
  .card-nav #add-fc-btn {
    display: none;
  }

  .card-nav .btn span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

body.fullscreen-mode-active .card-scene {
  flex-grow: 1 !important;
  height: 500px !important;
  min-height: 500px !important;
  max-height: 500px !important;
}

body.fullscreen-mode-active #fullscreen-fc-btn {
  display: inline-flex !important; /* Show only fullscreen button */
  position: fixed !important;
  top: 20px !important;
  right: 20px !important;
  z-index: 1000000 !important;
  background-color: var(--primary-color) !important;
  color: white !important;
  border: 1px solid var(--border-color) !important;
  box-shadow: var(--shadow-md) !important;
  border-radius: var(--radius-sm) !important;
  pointer-events: auto !important;
}

/* Flashcards use an independent immersive state so mind-map fullscreen remains isolated. */
body.flashcard-immersive {
  overflow-x: hidden;
  overflow-y: auto;
}

body.flashcard-immersive .app-container,
body.flashcard-immersive .main-content {
  width: 100vw;
  height: auto;
  min-height: 100dvh;
  overflow: visible;
}

body.flashcard-immersive .sidebar,
body.flashcard-immersive .sidebar-overlay,
body.flashcard-immersive .top-bar,
body.flashcard-immersive .glow-container,
body.flashcard-immersive #feedback-trigger-btn,
body.flashcard-immersive #pwa-status {
  display: none !important;
}

body.flashcard-immersive .single-mode-container {
  width: 100%;
  height: auto;
  min-height: 100dvh;
  padding: 0;
  overflow: visible !important;
}

body.flashcard-immersive .flashcards-container {
  height: auto;
  min-height: 100dvh;
  padding: max(8px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left));
  overflow: visible;
  align-items: flex-start;
}

body.flashcard-immersive .flashcards-active-area {
  position: relative;
  max-width: 920px;
  height: auto;
  min-height: 100%;
  margin: 0 auto;
  gap: 8px;
}

body.flashcard-immersive .flashcard-header {
  flex: 0 0 auto;
  gap: 4px;
}

body.flashcard-immersive .flashcard-header-row {
  min-height: 34px;
  justify-content: space-between;
}

body.flashcard-immersive .flashcard-exit-immersive {
  display: grid;
}

body.flashcard-immersive .flashcard-enter-immersive {
  display: none;
}

body.flashcard-immersive .flashcard-exit-immersive:hover,
body.flashcard-immersive .flashcard-exit-immersive:focus-visible {
  background: var(--primary-light);
  color: var(--primary-color);
}

body.flashcard-immersive .progress-info {
  margin-left: auto;
}

body.flashcard-immersive .card-scene {
  flex: 1;
  min-height: 240px;
  max-height: 680px;
  height: auto;
}

body.flashcard-immersive .card-face {
  padding: clamp(16px, 3vw, 32px);
}

body.flashcard-immersive .card-question-text {
  font-size: clamp(1.08rem, 2.2vw, 1.4rem);
}

body.flashcard-immersive .card-answer-text {
  font-size: clamp(0.92rem, 1.6vw, 1.04rem);
}

body.flashcard-immersive .card-nav {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: block !important;
  margin: 0 !important;
  pointer-events: none;
}

body.flashcard-immersive .card-nav .btn {
  position: absolute;
  top: 50%;
  width: 44px;
  height: 72px;
  min-height: 44px;
  padding: 0;
  transform: translateY(-50%) !important;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--primary-color);
  box-shadow: none;
  pointer-events: auto;
}

body.flashcard-immersive .card-nav #card-prev-btn {
  left: max(0px, env(safe-area-inset-left));
}

body.flashcard-immersive .card-nav #card-next-btn {
  right: max(0px, env(safe-area-inset-right));
}

body.flashcard-immersive .card-nav .btn:hover,
body.flashcard-immersive .card-nav .btn:focus-visible {
  background: var(--primary-light);
}

body.flashcard-immersive .card-nav .btn span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

body.flashcard-immersive .card-nav .btn svg {
  width: 22px;
  height: 22px;
  stroke-width: 2.2;
}

@media (max-width: 768px) {
  body.flashcard-immersive .flashcards-container {
    padding: max(6px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  }

  body.flashcard-immersive .flashcards-active-area {
    padding-bottom: 0;
  }

  body.flashcard-immersive .card-face {
    padding: 16px;
  }

  body.flashcard-immersive .card-question-text {
    font-size: 1.1rem;
    line-height: 1.6;
  }

  body.flashcard-immersive .card-answer-text {
    font-size: 0.92rem;
    line-height: 1.62;
  }

  body.flashcard-immersive .card-nav .btn {
    width: 40px;
    height: 68px;
  }
}

@media (max-width: 430px) {
  .settings-action-grid {
    grid-template-columns: 1fr;
  }
}

/* Visual Editor Layout Styles */
#flashcard-visual-editor {
  display: flex;
  flex-direction: column;
  background-color: var(--panel-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  gap: 16px;
  width: 100%;
}

.visual-editor-item-row {
  animation: fadeIn 0.2s ease;
}

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

.format-toolbar button {
  transition: all 0.2s;
}

.format-toolbar button:hover {
  transform: translateY(-1px);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .glow-container {
    display: none !important;
  }
}

/* --- New Flashcard Layout Styles --- */
.floating-nav-btn {
  background: var(--panel-bg);
  color: var(--primary-color);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  flex-shrink: 0;
  z-index: 10;
}
.floating-nav-btn:hover {
  background: var(--primary-color);
  color: #fff;
  transform: scale(1.05);
}
.floating-nav-btn:active {
  transform: scale(0.95);
}
@media (max-width: 600px) {
  .floating-nav-btn {
    width: 36px;
    height: 36px;
  }
}

/* --- New Top Mode Tabs Styles --- */
.top-mode-tabs {
  display: flex;
  overflow-x: auto; /* sliding function */
  white-space: nowrap;
  scrollbar-width: none; /* Hide scrollbar for Firefox */
  -ms-overflow-style: none; /* Hide scrollbar for IE/Edge */
  gap: 12px;
  padding-bottom: 2px;
}
.top-mode-tabs::-webkit-scrollbar {
  display: none; /* Hide scrollbar for Chrome/Safari */
}
.top-mode-tab {
  border-radius: 50%; /* 圆润的图形 */
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}
.top-mode-tab i {
  margin: 0;
}

/* Floating nav fixes */
.flashcard-active-area {
  position: relative;
  width: 100%;
}
.card-scene-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}
.card-scene {
  flex-grow: 1;
  max-width: 500px;
  width: 100%;
}
@media (max-width: 600px) {
  #floating-prev-btn {
    position: absolute;
    left: -15px;
    z-index: 100;
  }
  #floating-next-btn {
    position: absolute;
    right: -15px;
    z-index: 100;
  }
  .card-scene-wrapper {
    gap: 0;
  }
}

.logo-text .app-brand-title {
  max-width: 190px;
  font-size: 0.98rem;
  line-height: 1.35;
  white-space: normal;
}
.logo-text .app-brand-title span {
  display: block;
  white-space: nowrap;
}

/* ========================================================================
   平板优先的界面收束：保留模块文字，避免后加样式把导航压成纯图标。
   ======================================================================== */
.top-mode-tabs {
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
}

.top-mode-tab {
  width: auto;
  height: auto;
  min-width: max-content;
  min-height: 38px;
  padding: 7px 11px;
  border-radius: 9px;
}

.top-mode-tab i {
  margin: 0;
}

.top-mode-tab span {
  display: inline;
}

.flashcards-container {
  width: min(100%, 900px);
  margin-inline: auto;
}

.flashcards-active-area {
  position: relative;
  width: 100%;
  max-width: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card-scene-wrapper {
  width: 100%;
  min-height: 0;
  padding-inline: 58px;
}

.card-scene {
  flex: 0 1 720px;
  width: min(100%, 720px);
  max-width: 720px;
  min-height: 470px;
  max-height: none;
  margin: 0;
}

.card-inline-progress {
  position: static;
  z-index: auto;
  display: grid;
  justify-items: stretch;
  gap: 6px;
  width: 100%;
  margin: 4px 0 14px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.card-inline-counter strong {
  color: var(--primary-color);
}

.card-inline-counter,
#card-inline-counter { justify-self: end; }

.card-inline-progress .progress-bar-outer {
  height: 3px;
}

.source-study-reference {
  color: #9a5b13;
  background: #fff4df;
  border-color: #f0c27b;
}

.flashcards-active-area.is-editing .card-scene-wrapper,
.flashcards-active-area.is-editing .card-bottom-controls {
  display: none;
}

.flashcard-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  width: min(100%, 720px);
  margin: 14px auto 0;
}

.bs-rich-editor {
  min-height: 96px;
  max-height: 38vh;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--panel-bg);
  color: var(--text-main);
  line-height: 1.65;
  white-space: pre-wrap;
}

.bs-rich-editor:focus {
  outline: 2px solid var(--primary-light);
  border-color: var(--primary-color);
}

.floating-nav-btn {
  position: absolute;
  top: 50%;
  z-index: 6;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  transform: translateY(-50%);
}

.floating-nav-btn:hover {
  transform: translateY(-50%) scale(1.05);
}

.floating-nav-prev { left: 4px; }
.floating-nav-next { right: 4px; }

.card-page-source {
  display: none;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin: 8px 0;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.card-bottom-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 0;
}

#flashcard-visual-editor {
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--panel-bg);
}

#flashcard-visual-editor label,
#flashcard-visual-editor #visual-editor-list-area,
#flashcard-visual-editor #visual-editor-text-area {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 650;
}

#flashcard-visual-editor textarea,
#flashcard-visual-editor input {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-color);
  color: var(--text-main);
  font: inherit;
}

#visual-editor-question { min-height: 82px !important; }
#visual-editor-answer-text { min-height: 180px !important; }

.format-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  font-size: 0.82rem;
}

.mastery-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 1001;
  display: none;
  width: min(620px, calc(100% - 32px));
  max-height: min(720px, calc(100dvh - 36px));
  overflow: hidden auto;
  transform: translate(-50%, -50%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--panel-bg);
  box-shadow: var(--shadow-lg);
}

.mastery-modal.active { display: block; }

.mastery-overview {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary-color);
}

.mastery-overview span,
.mastery-empty { color: var(--text-muted); font-size: 0.86rem; }
.mastery-subject-group { margin-top: 20px; }
.mastery-subject-group h4 { margin: 0 0 8px; color: var(--text-main); }
.mastery-card-list { display: grid; gap: 7px; }
.mastery-card-item {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-color);
  color: var(--text-main);
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
}
.mastery-card-item:hover { border-color: var(--primary-color); color: var(--primary-color); }

@media (min-width: 769px) and (max-width: 1180px) {
  .top-bar {
    height: auto;
    min-height: 72px;
    padding: 8px 16px;
    flex-wrap: wrap;
    align-content: center;
  }

  .top-bar-left { flex: 1 1 360px; min-width: 0; }
  .top-bar-right { flex: 0 0 auto; }
  .top-mode-tabs {
    order: 3;
    flex: 0 0 100%;
    width: 100%;
    margin: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .top-mode-tabs::-webkit-scrollbar { display: none; }
  .top-mode-tab { flex: 0 0 auto; }
  body.flashcard-page .sidebar { width: min(42vw, 310px); }
}

@media (max-width: 768px) {
  .top-mode-tabs {
    overflow-x: auto;
    justify-content: flex-start;
    scrollbar-width: none;
  }
  .top-mode-tab {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 6px 10px;
    border-radius: 9px;
  }
  .top-mode-tab span { display: inline; }
  .flashcards-container { width: 100%; }
  .card-scene-wrapper { padding-inline: 38px; }
  .card-scene { width: 100%; min-height: 440px; }
  .floating-nav-btn { width: 34px; height: 34px; }
  .floating-nav-prev { left: 0; }
  .floating-nav-next { right: 0; }
  .card-face { padding: 18px; }
  .card-question-text { padding: 8px 0; font-size: 1.15rem; }
  .card-inline-progress { inset: auto; width: 100%; margin-bottom: 12px; }
}

/* ========================================================================
   手机端统一学习栏：所有模块共用，不保留被截断的章节标题。
   ======================================================================== */
@media (max-width: 768px) {
  .top-bar {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: center;
    align-content: center;
    gap: 6px;
    height: calc(60px + env(safe-area-inset-top)) !important;
    min-height: calc(60px + env(safe-area-inset-top)) !important;
    padding: calc(6px + env(safe-area-inset-top)) 8px 6px !important;
    flex-wrap: nowrap !important;
  }

  .top-bar-left,
  .top-bar-right {
    display: contents;
  }

  .top-bar .current-chapter-info,
  .top-bar .exam-page-heading {
    display: none !important;
  }

  .top-bar .toggle-btn {
    grid-column: 1;
    grid-row: 1;
  }

  .top-bar .top-mode-tabs {
    grid-column: 2;
    grid-row: 1;
    order: initial;
    width: auto !important;
    max-width: none !important;
    min-width: 0;
    margin: 0 !important;
    padding: 3px !important;
    gap: 2px !important;
    overflow-x: auto !important;
    justify-content: flex-start;
  }

  .top-bar .top-mode-tab {
    flex: 0 0 auto;
    min-height: 34px !important;
    padding: 5px 7px !important;
    gap: 3px;
    font-size: 0.74rem !important;
  }

  .top-bar .theme-btn,
  .top-bar .settings-btn {
    grid-row: 1;
    width: 36px !important;
    min-width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    border-radius: 8px !important;
  }

  .top-bar .theme-btn { grid-column: 3; }
  .top-bar .settings-btn { grid-column: 4; }

  .single-mode-container {
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  }

  .mindmap-actions {
    min-height: 52px;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    scroll-padding-inline: 12px;
  }

  .flashcards-container {
    padding: 8px 12px calc(12px + env(safe-area-inset-bottom));
    overflow-y: auto;
  }

  .flashcards-active-area {
    flex: 0 0 auto;
    min-height: 0;
    padding-bottom: 0;
  }

  .card-scene-wrapper {
    padding-inline: 0;
  }

  .card-scene {
    flex: 0 0 auto;
    width: 100%;
    min-height: clamp(320px, calc(100dvh - 220px), 520px);
    height: clamp(320px, calc(100dvh - 220px), 520px);
    max-height: 520px;
  }

  .card-face {
    padding: 18px 28px;
  }

  .floating-nav-btn {
    width: 32px;
    height: 32px;
  }

  .floating-nav-prev { left: 8px; }
  .floating-nav-next { right: 8px; }

  .card-bottom-controls {
    min-height: 48px;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
  }
}

/* iPad 与小平板也使用紧凑学习栏，避免原有的标题 + 模块双行布局。 */
@media (min-width: 769px) and (max-width: 1180px) {
  .top-bar {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    height: 64px !important;
    min-height: 64px !important;
    padding: 8px 12px !important;
    flex-wrap: nowrap !important;
  }

  .top-bar-left,
  .top-bar-right {
    display: contents;
  }

  .top-bar .current-chapter-info,
  .top-bar .exam-page-heading {
    display: none !important;
  }

  .top-bar .toggle-btn {
    grid-column: 1;
    grid-row: 1;
  }

  .top-bar .top-mode-tabs {
    grid-column: 2;
    grid-row: 1;
    order: initial;
    width: auto !important;
    min-width: 0;
    margin: 0 !important;
    overflow-x: auto;
    justify-content: flex-start;
  }

  .top-bar .theme-btn,
  .top-bar .settings-btn {
    grid-row: 1;
    width: 40px;
    min-width: 40px;
    height: 40px;
    padding: 0;
  }

  .top-bar .theme-btn { grid-column: 3; }
  .top-bar .settings-btn { grid-column: 4; }
}


/* Pure Icon Mindmap Actions & Collapsible Styles */
.mindmap-actions {
  position: absolute;
  bottom: 16px;
  right: 16px;
  top: auto;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 26px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  transition: all 0.25s ease;
}

body.dark-theme .mindmap-actions {
  background: rgba(30, 41, 59, 0.92);
  border-color: rgba(255, 255, 255, 0.15);
  color: #f8fafc;
}

.mindmap-actions .btn {
  padding: 10px;
  width: 46px;
  height: 46px;
  min-width: 46px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-main, #334155);
  transition: background 0.18s ease, transform 0.18s ease;
}

.mindmap-actions .btn svg {
  width: 22px !important;
  height: 22px !important;
  stroke-width: 2.2px !important;
}

body.dark-theme .mindmap-actions .btn {
  color: #e2e8f0;
}

.mindmap-actions .btn:hover {
  background: rgba(0, 0, 0, 0.08);
  transform: scale(1.12);
}

body.dark-theme .mindmap-actions .btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.mindmap-actions .btn.is-active {
  background: rgba(47, 107, 47, 0.14);
  color: var(--primary-color, #2f6b2f);
  box-shadow: inset 0 0 0 1px rgba(47, 107, 47, 0.28);
}

body.dark-theme .mindmap-actions .btn.is-active {
  background: rgba(134, 191, 125, 0.18);
  color: #c7f1c2;
  box-shadow: inset 0 0 0 1px rgba(199, 241, 194, 0.28);
}

.mindmap-handwriting-toolbar {
  position: absolute;
  right: 18px;
  bottom: 82px;
  z-index: 105;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px;
  border: 1px solid rgba(47, 107, 47, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(14px);
}

.mindmap-handwriting-toolbar[hidden] {
  display: none !important;
}

body.dark-theme .mindmap-handwriting-toolbar {
  border-color: rgba(199, 241, 194, 0.18);
  background: rgba(30, 41, 59, 0.94);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.26);
}

.hw-tool-btn {
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main, #263824);
  background: transparent;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.hw-tool-btn:hover,
.hw-tool-btn.is-active {
  background: rgba(47, 107, 47, 0.13);
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(47, 107, 47, 0.22);
}

body.dark-theme .hw-tool-btn {
  color: #e2e8f0;
}

body.dark-theme .hw-tool-btn:hover,
body.dark-theme .hw-tool-btn.is-active {
  background: rgba(199, 241, 194, 0.14);
  box-shadow: inset 0 0 0 1px rgba(199, 241, 194, 0.22);
}

.hw-tool-btn.hw-danger {
  color: #dc2626;
}

.hw-swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14);
}

.hw-swatch-wide {
  width: 22px;
  height: 12px;
  border-radius: 8px;
}

.mindmap-actions.actions-collapsed .action-item {
  display: none !important;
}

.mindmap-actions.actions-collapsed {
  padding: 6px !important;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.92) !important;
}

.mindmap-actions.actions-collapsed #toggle-actions-collapse-btn svg {
  transform: rotate(180deg);
}

body.dark-theme .mindmap-actions.actions-collapsed {
  background: rgba(30, 41, 59, 0.92) !important;
}

/* Fullscreen Mindmap Actions Floating Toolbar */
body.fullscreen-mode-active .mindmap-actions {
  position: fixed !important;
  bottom: 24px !important;
  right: 24px !important;
  top: auto !important;
  background: rgba(15, 23, 42, 0.92) !important;
  backdrop-filter: blur(14px) !important;
  border: 1px solid rgba(255, 255, 255, 0.22) !important;
  border-radius: 30px !important;
  padding: 8px 14px !important;
  z-index: 1000000 !important;
}

body.fullscreen-mode-active .mindmap-actions .btn {
  color: #ffffff !important;
  width: 50px !important;
  height: 50px !important;
  min-width: 50px !important;
}

body.fullscreen-mode-active .mindmap-actions .btn svg {
  width: 24px !important;
  height: 24px !important;
}

body.fullscreen-mode-active .mindmap-handwriting-toolbar {
  position: fixed !important;
  right: 24px !important;
  bottom: 92px !important;
}

/* v130: cleaner iOS-like study controls */
.study-navigation {
  gap: 8px;
}

.subject-toggle-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border: 1px solid color-mix(in srgb, var(--border-color) 80%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--bg-color) 72%, #ffffff 28%);
  box-shadow: inset 0 1px 1px rgba(31, 54, 38, 0.04);
}

.subject-toggle-btn {
  min-width: 0;
  min-height: 32px;
  gap: 4px;
  padding: 6px 5px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: color-mix(in srgb, var(--text-muted) 86%, var(--primary-color) 14%);
  font-size: 0.76rem;
  font-weight: 680;
  letter-spacing: 0;
}

.subject-toggle-btn i,
.subject-toggle-btn svg {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

.subject-toggle-btn span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subject-toggle-btn:hover {
  background: color-mix(in srgb, var(--primary-light) 56%, transparent);
  color: var(--primary-color);
}

.subject-toggle-btn.active,
.subject-toggle-btn[aria-selected="true"] {
  border-color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.92);
  color: var(--primary-color);
  box-shadow: 0 1px 5px rgba(31, 54, 38, 0.12);
}

.subbook-toggle-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  margin-top: 7px;
  padding: 3px;
  border: 1px solid color-mix(in srgb, var(--border-color) 72%, transparent);
  border-radius: 11px;
  background: color-mix(in srgb, var(--primary-light) 34%, transparent);
}

.subbook-toggle-group[hidden] {
  display: none !important;
}

.subbook-toggle-btn {
  min-height: 28px;
  padding: 5px 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 680;
  white-space: nowrap;
  cursor: pointer;
}

.subbook-toggle-btn:hover {
  color: var(--primary-color);
}

.subbook-toggle-btn.active,
.subbook-toggle-btn[aria-selected="true"] {
  border-color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.9);
  color: var(--primary-color);
  box-shadow: 0 1px 4px rgba(31, 54, 38, 0.1);
}

.mastery-bank-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 38px;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--primary-color) 34%, var(--border-color));
  border-radius: 12px;
  background: color-mix(in srgb, var(--primary-light) 76%, #ffffff 24%);
  color: var(--primary-color);
  font-size: 0.84rem;
  font-weight: 720;
  text-decoration: none;
  box-shadow: 0 1px 4px rgba(31, 54, 38, 0.08);
}

.mastery-bank-btn i,
.mastery-bank-btn svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

.mastery-bank-btn:hover {
  background: color-mix(in srgb, var(--primary-light) 64%, #ffffff 36%);
  box-shadow: 0 3px 10px rgba(31, 54, 38, 0.12);
}

body.dark-theme .subject-toggle-group,
body.dark-theme .subbook-toggle-group,
body.dark-theme .card-quick-controls {
  background: rgba(15, 23, 42, 0.38);
  border-color: rgba(148, 163, 184, 0.24);
}

body.dark-theme .subject-toggle-btn.active,
body.dark-theme .subject-toggle-btn[aria-selected="true"],
body.dark-theme .subbook-toggle-btn.active,
body.dark-theme .subbook-toggle-btn[aria-selected="true"] {
  border-color: rgba(148, 163, 184, 0.26);
  background: rgba(30, 41, 59, 0.92);
  color: #d9f99d;
}

body.dark-theme .mastery-bank-btn,
body.dark-theme .card-quick-controls .card-immersive-full-btn,
body.dark-theme .flashcard-exit-immersive {
  background: rgba(30, 41, 59, 0.88);
  border-color: rgba(148, 163, 184, 0.24);
  color: #d9f99d;
}

.card-scene-wrapper {
  position: relative;
}

.flashcard-immersive-controls {
  position: absolute;
  top: 12px;
  right: 70px;
  z-index: 12;
  display: none;
}

body.flashcard-immersive .flashcard-immersive-controls {
  display: block;
}

.flashcard-enter-immersive,
.flashcard-exit-immersive {
  border-radius: 999px;
}

body.flashcard-immersive .flashcard-exit-immersive {
  display: grid;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.92);
  color: var(--primary-color);
  box-shadow: 0 5px 16px rgba(31, 54, 38, 0.12);
  backdrop-filter: blur(12px);
}

.card-bottom-controls {
  align-items: center;
}

.card-quick-controls {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--primary-light) 48%, transparent);
}

.card-quick-controls .btn {
  min-height: 40px;
  border-radius: 12px;
  padding: 0 14px;
}

.card-quick-controls .btn svg {
  width: 18px;
  height: 18px;
}

.card-quick-controls .card-immersive-full-btn {
  width: 40px;
  min-width: 40px;
  padding: 0 !important;
  border: 0;
  background: color-mix(in srgb, var(--primary-light) 72%, #ffffff 28%);
  color: var(--primary-color);
}

.card-quick-controls .card-immersive-full-btn:hover,
.card-quick-controls .card-immersive-full-btn:focus-visible {
  background: color-mix(in srgb, var(--primary-light) 58%, #ffffff 42%);
}

@media (max-width: 720px) {
  .subject-toggle-btn {
    font-size: 0.74rem;
    gap: 3px;
    padding-inline: 4px;
  }

  .subject-toggle-btn i,
  .subject-toggle-btn svg {
    width: 13px;
    height: 13px;
  }

  .flashcard-immersive-controls {
    top: 10px;
    right: 46px;
  }
}

/* v131: readable sidebar hierarchy and flashcard answer rhythm */
.logo-text .app-brand-title {
  max-width: 150px;
  line-height: 1.16;
}

.logo-text .app-brand-title span:first-child {
  font-size: 1rem;
  font-weight: 820;
  letter-spacing: 0;
}

.logo-text .app-brand-title span:last-child {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 680;
  letter-spacing: 0;
}

.subject-toggle-group {
  gap: 4px;
  padding: 4px;
  border-radius: 13px;
}

.subject-toggle-btn {
  flex-direction: column;
  min-height: 48px;
  gap: 3px;
  padding: 6px 3px;
  font-size: 0.73rem;
  line-height: 1.12;
}

.subject-toggle-btn i,
.subject-toggle-btn svg {
  width: 18px;
  height: 18px;
}

.subject-toggle-btn span {
  max-width: 100%;
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.subbook-toggle-group {
  gap: 4px;
  padding: 3px;
  border-radius: 12px;
}

.subbook-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  gap: 4px;
  padding: 4px 6px;
  font-size: 0.72rem;
  line-height: 1.1;
}

.subbook-toggle-btn i,
.subbook-toggle-btn svg {
  width: 12px;
  height: 12px;
  stroke-width: 2;
}

.card-answer-text.regulation-answer {
  line-height: 1.9;
  text-align: left;
}

.card-answer-text.regulation-answer p {
  margin: 0 0 0.82em;
}

.card-answer-text.regulation-answer p + p {
  margin-top: 0.22em;
}

.card-answer-text .answer-paragraph-point {
  position: relative;
  display: block;
  margin-bottom: 0.78em;
}

.card-answer-text .answer-paragraph-level-1 {
  padding-left: 36px;
}

.card-answer-text .answer-paragraph-level-2 {
  margin-left: 18px;
  padding-left: 34px;
}

.card-answer-text .answer-paragraph-level-3 {
  margin-left: 34px;
  padding-left: 32px;
}

.card-answer-text .answer-inline-marker {
  position: absolute;
  left: 0;
  top: 0.2em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 8px;
  background: color-mix(in srgb, #ffedd5 82%, #ffffff 18%);
  color: #ea580c;
  font-size: 0.82rem;
  font-weight: 820;
  line-height: 1;
}

.card-answer-text .answer-inline-marker-level-2 {
  min-width: 22px;
  height: 22px;
  background: color-mix(in srgb, var(--primary-light) 80%, #ffffff 20%);
  color: var(--primary-color);
  font-size: 0.78rem;
}

.card-answer-text .answer-inline-marker-level-3 {
  min-width: 20px;
  height: 20px;
  background: color-mix(in srgb, var(--border-color) 70%, #ffffff 30%);
  color: var(--text-muted);
  font-size: 0.74rem;
}

.card-answer-text.regulation-answer b,
.card-answer-text.regulation-answer strong {
  color: var(--primary-color);
  font-weight: 820;
}

body.dark-theme .card-answer-text .answer-inline-marker {
  background: rgba(154, 52, 18, 0.28);
  color: #fed7aa;
}

body.dark-theme .card-answer-text .answer-inline-marker-level-2 {
  background: rgba(20, 83, 45, 0.34);
  color: #bbf7d0;
}

body.dark-theme .card-answer-text .answer-inline-marker-level-3 {
  background: rgba(148, 163, 184, 0.16);
  color: #cbd5e1;
}

@media (max-width: 720px) {
  .subject-toggle-btn {
    min-height: 46px;
    font-size: 0.7rem;
  }

  .subject-toggle-btn i,
  .subject-toggle-btn svg {
    width: 17px;
    height: 17px;
  }

  .subbook-toggle-btn {
    font-size: 0.7rem;
  }

  .card-answer-text .answer-paragraph-level-2 {
    margin-left: 10px;
  }

  .card-answer-text .answer-paragraph-level-3 {
    margin-left: 20px;
  }
}

/* === 药理学思维导图新旧版本切换 === */
.mindmap-version-toggle {
  display: flex;
  gap: 2px;
  margin-top: 6px;
  padding: 2px;
  border: 1px solid color-mix(in srgb, var(--border-color) 72%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--primary-light) 34%, transparent);
}

.mindmap-version-toggle[hidden] {
  display: none !important;
}

.mindmap-version-btn {
  flex: 1;
  min-height: 26px;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 680;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mindmap-version-btn:hover {
  color: var(--primary-color);
}

.mindmap-version-btn.active,
.mindmap-version-btn[aria-selected="true"] {
  border-color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.9);
  color: var(--primary-color);
  box-shadow: 0 1px 4px rgba(31, 54, 38, 0.1);
}

body.dark-theme .mindmap-version-toggle {
  background: rgba(15, 23, 42, 0.38);
  border-color: rgba(148, 163, 184, 0.24);
}

body.dark-theme .mindmap-version-btn.active,
body.dark-theme .mindmap-version-btn[aria-selected="true"] {
  border-color: rgba(148, 163, 184, 0.26);
  background: rgba(30, 41, 59, 0.92);
  color: #d9f99d;
}

@media (max-width: 768px) {
  .mindmap-version-btn {
    font-size: 0.7rem;
    padding: 3px 8px;
  }
}
