/* ==========================================================================
   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: system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  --font-title: 'Outfit', -apple-system, "PingFang SC", "HarmonyOS Sans SC", "MiSans", 'Noto Sans SC', sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --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;
  transform: translate3d(0, 0, 0);
  will-change: transform;
  animation: float 25s infinite alternate ease-in-out;
}

.touch-study-device .glow-ball,
.ipad-study-device .glow-ball {
  filter: blur(40px);
  opacity: 0.35;
}

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

@media (prefers-reduced-motion: reduce) {
  .glow-ball {
    animation: none !important;
  }
}

.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: translate3d(0, 0, 0) scale(1) rotate(0deg);
  }
  50% {
    transform: translate3d(80px, 50px, 0) scale(1.15) rotate(180deg);
  }
  100% {
    transform: translate3d(-40px, 80px, 0) scale(0.9) rotate(360deg);
  }
}

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

[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;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

/* 针对移动设备与触控屏防止 iOS 输入框聚焦强制放大网页 */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  textarea,
  select {
    font-size: 16px !important;
  }
}

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

/* 侧边栏样式 */
.sidebar {
  width: 320px;
  height: 100%;
  min-height: 0;
  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: 36px;
  height: 36px;
  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);
}

/* 章节列表 */
.chapter-list-container {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 14px 20px;
  display: flex;
  flex-direction: column;
}

.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;
  flex: 1 1 auto;
  margin: 0;
  padding: 0;
}

.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;
}

.status-badge.custom-badge.flashcard-local-star {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #d97706;
}

.status-badge.custom-badge.flashcard-local-star svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

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

body.dark-theme .status-badge.custom-badge.flashcard-local-star {
  background: transparent;
  border: 0;
  color: #fbbf24;
}

/* 侧边栏遮罩 */
.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: 72px;
  min-height: 72px;
  padding: 0 14px;
  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.15rem;
  font-weight: 700;
  margin-bottom: 2px;
}

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

#current-chapter-pages {
  display: none !important;
}

.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: 3px;
  margin-left: 2px;
}

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

.top-mode-tab {
  display: inline-flex;
  min-width: 0;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 750;
  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],
.top-bar .top-mode-tab[hidden],
.top-mode-tabs [hidden],
.learning-square-top-tab,
[hidden] {
  display: none !important;
}

.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);
}

/* ==========================================================================
   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-version-toggle {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 110;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border: 1px solid rgba(47, 107, 47, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.10);
}

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

.mindmap-version-btn {
  min-width: 34px;
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 750;
  cursor: pointer;
}

.mindmap-version-btn:hover,
.mindmap-version-btn:focus-visible {
  background: rgba(47, 107, 47, 0.10);
  color: var(--primary-color);
}

.mindmap-version-btn.active {
  background: var(--primary-color);
  color: #fff;
  box-shadow: 0 4px 10px rgba(47, 107, 47, 0.22);
}

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

body.dark-theme .mindmap-version-btn.active {
  background: #86bf7d;
  color: #11210f;
}

.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: 5px 18px 6px;
  overflow-y: auto;
  box-sizing: border-box;
}

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

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

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* 闪卡顶部进度 */
.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.82em;
  padding: 0;
  line-height: 1.92;
}

.card-answer-text .question-book-answer-list > li.answer-list-level-1,
.card-answer-text .question-book-answer-list > li[data-answer-level="1"] {
  margin-top: 0.95em;
}

.card-answer-text .question-book-answer-list > li.answer-list-level-1:first-child,
.card-answer-text .question-book-answer-list > li[data-answer-level="1"]:first-child {
  margin-top: 0;
}

.card-answer-text .question-book-answer-list > li.answer-list-level-2,
.card-answer-text .question-book-answer-list > li[data-answer-level="2"] {
  margin-left: 1.05em;
  padding-left: 0.78em;
  border-left: 2px solid color-mix(in srgb, var(--primary-color) 24%, transparent);
}

.card-answer-text .question-book-answer-list > li.answer-list-level-3,
.card-answer-text .question-book-answer-list > li[data-answer-level="3"] {
  margin-left: 2em;
  padding-left: 0.72em;
  border-left: 1px dashed color-mix(in srgb, var(--text-muted) 28%, transparent);
}

.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: min(100%, 820px);
  margin-inline: auto;
  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 !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 10px !important;
  min-width: 0 !important;
  width: 100% !important;
  flex: 0 0 auto !important;
  margin-bottom: 2px !important;
}

.card-tag,
.card-front .card-tag,
.card-back .card-tag {
  display: none !important;
}

.card-front .card-meta-row {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100% !important;
}

.card-front .card-meta-row .card-source-badge {
  margin-left: auto !important;
  align-self: center !important;
  flex: 0 0 auto !important;
}

#card-inline-counter,
.card-inline-counter {
  display: inline-flex !important;
  align-items: baseline !important;
  gap: 3px !important;
  font-size: 0.94rem !important;
  color: var(--text-muted, #64748b) !important;
  font-weight: 500 !important;
  letter-spacing: 0.02em !important;
  flex: 0 0 auto !important;
}

#card-inline-counter strong,
.card-inline-counter strong {
  color: var(--text-main, #1e293b) !important;
  font-weight: 750 !important;
  font-size: 1.06rem !important;
}

body.dark-theme #card-inline-counter strong,
body.dark-theme .card-inline-counter strong {
  color: #f1f5f9 !important;
}

.flashcard-page .progress-bar-outer {
  display: block !important;
}

.card-inline-progress {
  display: grid !important;
  gap: 5px;
  width: 100%;
  flex: 0 0 auto;
}

.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-question-importance-label {
  color: #F59E0B !important;
  font-weight: 900;
  margin-left: 0.35em;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
}

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

.card-answer-text-container::-webkit-scrollbar {
  display: none;
}

.card-answer-text {
  font-size: 0.98rem;
  line-height: 1.96;
  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: 18px;
  margin: 5px 0;
}

.card-answer-text ul ul ul,
.card-answer-text ol ol ol,
.card-answer-text ul ol ul,
.card-answer-text ol ul ol {
  padding-left: 14px;
}

.card-answer-text ul ul ul ul,
.card-answer-text ol ol ol ol {
  padding-left: 8px;
}

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

.card-answer-text li {
  margin-bottom: 12px;
  line-height: 1.92;
}

.card-question-text sub,
.card-question-text sup,
.card-answer-text sub,
.card-answer-text sup {
  font-size: 0.72em;
  line-height: 0;
}

.card-answer-text p,
.card-answer-text .material-point,
.card-answer-text .material-point-body,
.card-answer-text .answer-subpoint,
.card-answer-text .answer-detail,
.card-answer-text .answer-example {
  line-height: 1.96;
}

.card-answer-text .material-point {
  margin-bottom: 0.72em;
}

.card-answer-text .material-point-level-1 {
  display: block;
  margin: 1.05em 0 0.48em;
}

.card-answer-text .material-point-level-1:first-child {
  margin-top: 0.12em;
}

.card-answer-text .material-point-level-2 {
  display: block;
  margin: 0.26em 0 0.2em 1.12em;
  padding-left: 0.82em;
  border-left: 2px solid color-mix(in srgb, var(--primary-color) 22%, transparent);
}

.card-answer-text .material-point-level-3 {
  display: block;
  margin: 0.22em 0 0.18em 2.05em;
  padding-left: 0.72em;
  border-left: 1px dashed color-mix(in srgb, var(--text-muted) 28%, transparent);
  color: color-mix(in srgb, var(--text-main) 86%, var(--text-muted) 14%);
}

.card-answer-text .material-point-no {
  display: inline-block;
  min-width: 1.7em;
  margin-right: 0.18em;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  background: transparent !important;
}

.card-answer-text .material-point-no-level-1 {
  color: #ea580c;
}

.card-answer-text .material-point-no-level-2 {
  color: var(--primary-color);
}

.card-answer-text .material-point-no-level-3 {
  color: var(--text-muted);
}

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

.card-answer-text li.answer-list-level-2:not(.answer-example) {
  margin-left: 1.08em;
  padding-left: 0.78em;
  border-left: 2px solid color-mix(in srgb, var(--primary-color) 22%, transparent);
}

.card-answer-text li.answer-list-level-3:not(.answer-example) {
  margin-left: 2em;
  padding-left: 0.72em;
  border-left: 1px dashed color-mix(in srgb, var(--text-muted) 28%, transparent);
}

.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);
}

.flashcard-answer-image-wrap {
  margin: 4px 0 10px;
  text-align: center;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

.flashcard-answer-image {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(100%, calc(var(--flashcard-card-height, 560px) - 150px));
  margin: 6px auto;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  background: #fff;
  object-fit: contain;
  box-shadow: 0 8px 22px rgba(15, 23, 42, .08);
}

.card-answer-text.has-answer-image {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card-answer-text.has-answer-image .flashcard-answer-image-wrap {
  flex: 1 1 auto;
  max-height: calc(var(--flashcard-card-height, 560px) - 150px);
  margin: 4px auto 8px;
}

.card-answer-text.has-answer-image .flashcard-answer-image {
  max-width: 100%;
  max-height: 100%;
}

.flashcard-answer-image-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 4;
  display: none;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(127, 29, 29, .18);
  border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  color: #b91c1c;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(15, 23, 42, .16);
  cursor: pointer;
}

.flashcards-active-area.is-inline-editing .flashcard-answer-image-delete {
  display: grid;
}

.flashcard-answer-image-delete:hover,
.flashcard-answer-image-delete:focus-visible {
  background: #fee2e2;
  outline: none;
}

.card-back {
  position: relative;
}

.flashcard-annotation-canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 8;
  width: 100%;
  min-height: 100%;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
  touch-action: pan-y;
}

.flashcard-annotation-canvas.has-annotations {
  opacity: 1;
}

.flashcard-annotation-canvas.is-active {
  pointer-events: auto;
  cursor: crosshair;
}

.flashcard-annotation-canvas.is-active.touch-draw-disabled {
  touch-action: pan-y;
}

.flashcard-annotation-canvas.is-active.touch-draw-enabled {
  touch-action: none;
}

body.flashcard-annotation-active .card-back,
body.mastery-annotation-active .card-back {
  touch-action: pan-y;
}

body.flashcard-annotation-active.flashcard-annotation-touch-draw .card-back,
body.mastery-annotation-active.mastery-annotation-touch-draw .card-back {
  touch-action: none;
}

/* 批注模式下严密封锁文本选择与高亮闪烁 (防止手写笔笔尖触发长按选词蓝色闪烁) */
body.flashcard-annotation-active .flashcard,
body.flashcard-annotation-active .card-face,
body.flashcard-annotation-active .card-back,
body.flashcard-annotation-active .card-answer-text-container,
body.flashcard-annotation-active .card-answer-text,
body.flashcard-annotation-active .card-answer-text *,
body.flashcard-annotation-active table,
body.flashcard-annotation-active th,
body.flashcard-annotation-active td,
body.flashcard-annotation-active tr,
body.flashcard-annotation-active p,
body.flashcard-annotation-active span,
body.mastery-annotation-active .mastery-review-card,
body.mastery-annotation-active .card-face,
body.mastery-annotation-active .card-back,
body.mastery-annotation-active .card-answer-text-container,
body.mastery-annotation-active .card-answer-text,
body.mastery-annotation-active .card-answer-text *,
body.mastery-annotation-active table,
body.mastery-annotation-active th,
body.mastery-annotation-active td,
body.mastery-annotation-active tr,
body.mastery-annotation-active p,
body.mastery-annotation-active span {
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
  -webkit-user-drag: none !important;
}

body.flashcard-annotation-active ::selection,
body.mastery-annotation-active ::selection {
  background: transparent !important;
  color: inherit !important;
}

body.flashcard-annotation-active .card-back .tap-hint,
body.mastery-annotation-active .card-back .tap-hint {
  display: none !important;
}

.flashcard-annotation-toolbar {
  position: relative;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  flex: 0 0 auto;
  width: min(100%, 560px);
  margin: 8px auto 0;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--primary-color) 16%, var(--border-color));
  border-radius: 18px;
  background: color-mix(in srgb, var(--panel-bg) 90%, var(--primary-light) 10%);
  box-shadow: 0 12px 28px rgba(31,54,38,.10);
}

.flashcard-annotation-toolbar .anno-eraser-btn.is-active {
  color: var(--primary-color);
  border-color: color-mix(in srgb, var(--primary-color) 34%, var(--border-color));
  background: color-mix(in srgb, var(--primary-light) 78%, #fff 22%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary-color) 14%, transparent);
}

.flashcard-annotation-toolbar[hidden] {
  display: none !important;
}

.anno-color {
  width: 30px;
  height: 30px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--anno-color);
  cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.72), 0 4px 10px rgba(15,23,42,.10);
}

.anno-color.is-active {
  border-color: var(--primary-color);
  transform: translateY(-1px);
}

.anno-width {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: .82rem;
  font-weight: 800;
}

.anno-width input {
  width: 92px;
}

.study-image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000003;
  display: grid;
  place-items: center;
  padding: max(20px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: rgba(5, 12, 8, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.study-image-lightbox[hidden] {
  display: none !important;
}

.study-image-lightbox img {
  display: block;
  max-width: min(96vw, 1180px);
  max-height: 88dvh;
  border-radius: 10px;
  background: #fff;
  object-fit: contain;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

.study-image-lightbox-close {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #1f2937;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.study-image-lightbox-delete {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  min-width: 116px;
  height: 42px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  background: rgba(220, 38, 38, 0.94);
  color: #fff;
  font-size: .95rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
}

.study-image-lightbox-delete:hover,
.study-image-lightbox-delete:focus-visible {
  background: rgba(185, 28, 28, 0.98);
}

.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-auto-heading {
  list-style: none;
  margin: 12px 0 7px;
  color: var(--primary-color);
  font-weight: 820;
}

.card-answer-text .answer-section-list > li.answer-auto-heading:first-child {
  margin-top: 2px;
}

.card-answer-text .answer-section-list > li.answer-auto-heading-level-2 {
  margin-left: 0.55em;
  color: color-mix(in srgb, var(--primary-color) 84%, var(--text-main) 16%);
}

.card-answer-text li.answer-auto-heading.answer-list-level-2:not(.answer-example),
.card-answer-text li.answer-auto-heading.answer-list-level-3:not(.answer-example) {
  padding-left: 0;
  border-left: 0;
}

.card-answer-text .answer-section-list > li.answer-auto-detail {
  margin-top: 4px;
  margin-bottom: 7px;
}

.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*="#10b981"],
.card-answer-text span[style*="#e11d48"],
.card-answer-text span[style*="#ea580c"] {
  font-weight: inherit;
  padding: 0;
  border-radius: 2px;
  display: inline;
  margin: 0;
}

.card-answer-text span[style*="#0284c7"],
.card-answer-text span[style*="#0d9488"],
.card-answer-text span[style*="#10b981"],
.card-answer-text span[style*="#e11d48"],
.card-answer-text span[style*="#ea580c"] {
  background: transparent !important;
}

body.dark-theme .card-answer-text span[style*="#0d9488"] {
  color: #2dd4bf !important;
}
body.dark-theme .card-answer-text span[style*="#0284c7"] {
  color: #38bdf8 !important;
}
body.dark-theme .card-answer-text span[style*="#10b981"] {
  color: #4ade80 !important;
}
body.dark-theme .card-answer-text span[style*="#e11d48"] {
  color: #fb7185 !important;
}
body.dark-theme .card-answer-text span[style*="#ea580c"] {
  color: #fb923c !important;
}

.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: #C71585;
  font-weight: 820;
}

@counter-style textbook-circled-decimal {
  system: fixed;
  symbols: ① ② ③ ④ ⑤ ⑥ ⑦ ⑧ ⑨ ⑩ ⑪ ⑫ ⑬ ⑭ ⑮ ⑯ ⑰ ⑱ ⑲ ⑳;
  suffix: " ";
}

.card-answer-text.textbook-answer .textbook-point-list,
.card-answer-text.textbook-answer .textbook-subpoint-list {
  list-style: none;
  padding-left: 0;
}

.card-answer-text.textbook-answer .textbook-point-list {
  counter-reset: textbook-level-1;
  margin: 0 0 8px;
}

.card-answer-text.textbook-answer .textbook-point-list > li {
  counter-increment: textbook-level-1;
  position: relative;
  margin: 7px 0;
  padding-left: 2.45em;
}

.card-answer-text.textbook-answer .textbook-point-list > li:first-child {
  margin-top: 0;
}

.card-answer-text.textbook-answer .textbook-point-list > li::before {
  content: counter(textbook-level-1, cjk-ideographic) "、";
  position: absolute;
  left: 0;
  top: 0;
  min-width: 2.1em;
  color: #C71585;
  font-weight: 850;
}

.card-answer-text.textbook-answer.textbook-answer-section-numbered {
  counter-reset: textbook-section-level;
}

.card-answer-text.textbook-answer.textbook-answer-section-numbered > .answer-section-block {
  counter-increment: textbook-section-level;
  margin: 10px 0 13px;
}

.card-answer-text.textbook-answer.textbook-answer-section-numbered > .answer-section-block > .answer-structure-label:first-child::before {
  content: counter(textbook-section-level, cjk-ideographic) "、";
  color: #C71585;
  font-weight: 850;
  margin-right: 1px;
}

.card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list,
.card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list {
  counter-reset: textbook-level-2;
  margin: 6px 0 2px;
}

.card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list > li,
.card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li {
  counter-increment: textbook-level-2;
  position: relative;
  margin: 6px 0;
  padding-left: 2.15em;
  border-left: 0;
}

.card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list > li::before,
.card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li::before {
  content: counter(textbook-level-2) ".";
  position: absolute;
  left: 0;
  top: 0;
  min-width: 1.75em;
  color: #C71585;
  font-weight: 780;
}

.card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list > li > .textbook-subpoint-list,
.card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li > .textbook-subpoint-list {
  counter-reset: textbook-level-3;
  margin: 5px 0 2px;
}

.card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list > li > .textbook-subpoint-list > li,
.card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li > .textbook-subpoint-list > li {
  counter-increment: textbook-level-3;
  position: relative;
  margin: 5px 0;
  padding-left: 1.85em;
  border-left: 0;
}

.card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list > li > .textbook-subpoint-list > li::before,
.card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li > .textbook-subpoint-list > li::before {
  content: counter(textbook-level-3, textbook-circled-decimal);
  position: absolute;
  left: 0;
  top: 0;
  min-width: 1.45em;
  color: #C71585;
  font-weight: 780;
}

.card-answer-text.textbook-answer {
  --textbook-level-top: #C71585;
  --textbook-level-mid: #7C3AED;
  --textbook-level-deep: #F59E0B;
}

.card-answer-text.textbook-answer.textbook-answer-section-numbered > .answer-section-block > .answer-structure-label:first-child,
.card-answer-text.textbook-answer.textbook-answer-section-numbered > .answer-section-block > .answer-structure-label:first-child::before,
.card-answer-text.textbook-answer.textbook-answer-direct-multi-level > .textbook-point-list > li > .answer-structure-label,
.card-answer-text.textbook-answer.textbook-answer-direct-multi-level > .textbook-point-list > li::before,
.card-answer-text.textbook-answer.textbook-answer-single-level-list > .textbook-point-list > li > .answer-structure-label,
.card-answer-text.textbook-answer.textbook-answer-single-level-list > .textbook-point-list > li::before,
.card-answer-text.textbook-answer.textbook-answer-single-section > .answer-section-block > .answer-structure-label:first-child {
  color: var(--textbook-level-top) !important;
}

.card-answer-text.textbook-answer.textbook-answer-single-level-list > .textbook-point-list > li {
  padding-left: 1.35em !important;
}

.card-answer-text.textbook-answer.textbook-answer-single-level-list > .textbook-point-list > li::before {
  content: counter(textbook-level-1) "." !important;
  min-width: 1.1em !important;
  letter-spacing: 0 !important;
}

.card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list > li > .answer-structure-label,
.card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li > .answer-structure-label,
.card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list > li::before,
.card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li::before {
  color: var(--textbook-level-mid) !important;
}

.card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list > li > .textbook-subpoint-list > li > .answer-structure-label,
.card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li > .textbook-subpoint-list > li > .answer-structure-label,
.card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list > li > .textbook-subpoint-list > li::before,
.card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li > .textbook-subpoint-list > li::before {
  color: var(--textbook-level-deep) !important;
}

@media (max-width: 768px) {
  .card-answer-text.textbook-answer .textbook-point-list > li {
    padding-left: 1.72em;
  }

  .card-answer-text.textbook-answer .textbook-point-list > li::before {
    min-width: 1.35em;
  }

  .card-answer-text.textbook-answer.textbook-answer-single-level-list > .textbook-point-list > li {
    padding-left: 1.25em !important;
  }

  .card-answer-text.textbook-answer.textbook-answer-single-level-list > .textbook-point-list > li::before {
    min-width: 1.02em !important;
  }

  .card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list > li,
  .card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li {
    padding-left: 1.52em;
  }

  .card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list {
    margin-left: -0.72em;
  }

  .card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list > li::before,
  .card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li::before {
    min-width: 1.18em;
  }

  .card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list > li > .textbook-subpoint-list > li,
  .card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li > .textbook-subpoint-list > li {
    padding-left: 1.28em;
  }

  .card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li > .textbook-subpoint-list {
    margin-left: -0.36em;
  }

  .card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list > li > .textbook-subpoint-list > li::before,
  .card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li > .textbook-subpoint-list > li::before {
    min-width: 1.05em;
  }
}

.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-page-source {
  align-self: center;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 10px auto 0;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(199, 21, 133, 0.08);
  color: #6b214f;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
}

.card-page-source svg,
.card-page-source i {
  display: none !important;
}

.card-page-source[hidden] {
  display: none !important;
}

.card-page-source:not([hidden]) {
  display: flex !important;
}

body.dark-theme .card-page-source {
  background: rgba(248, 113, 178, 0.16);
  color: #f9a8d4;
}

/* ==========================================================================
   名词解释专属同面自测模式 (Single-Surface Definition Self-Testing Mode)
   ========================================================================== */

/* ==========================================================================
   名词专同自测模式 - 无痕纯净遮挡 (Seamless Definition Self-Testing Mode)
   ========================================================================== */

/* ==========================================================================
   名词专同自测模式 - 纯粹无痕透明遮挡 (Ultra-Seamless Definition Mode)
   ========================================================================== */

.flashcard.is-definition-mode {
  transform: none !important;
  cursor: pointer;
}

.flashcard.is-definition-mode .card-face.card-back {
  display: none !important;
}

.flashcard.is-definition-mode .card-face.card-front,
body.flashcard-page .flashcard.is-definition-mode .card-front,
html.touch-study-device body.flashcard-page .flashcard.is-definition-mode .card-front {
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  gap: 14px !important;
  padding: 24px 22px !important;
  overflow: hidden !important;
}

.flashcard.is-definition-mode .card-front .tap-hint {
  display: none !important;
}

body.flashcard-page .flashcard.is-definition-mode .card-question-text,
.flashcard.is-definition-mode .card-question-text {
  flex: 0 0 auto !important;
  flex-grow: 0 !important;
  min-height: auto !important;
  height: auto !important;
  display: block !important;
  text-align: center !important;
  font-size: 1.44rem !important;
  font-weight: 800 !important;
  color: var(--text-main, #1e293b) !important;
  padding: 6px 12px 14px !important;
  margin: 4px 0 6px 0 !important;
  letter-spacing: 0.02em !important;
  border-bottom: 1px solid var(--border-color) !important;
  width: 100% !important;
}

.flashcard.is-definition-mode .definition-answer-box {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  width: 100% !important;
  position: relative !important;
  border-radius: 12px !important;
  overflow: hidden !important;
  margin-top: 0 !important;
  background: transparent !important;
  border: none !important;
}

/* 无痕遮挡触发区 - 纯透明极简 (Ultra-Clean Transparent Trigger) */
.definition-reveal-trigger {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0 !important;
  width: 100% !important;
  flex: 1 1 auto !important;
  min-height: 140px !important;
  border-radius: 14px !important;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  cursor: pointer !important;
  user-select: none !important;
  padding: 24px 16px !important;
  transition: all 0.2s ease !important;
}

/* 隐藏任何眼睛图标 */
.definition-reveal-trigger svg,
.definition-reveal-trigger i {
  display: none !important;
}

/* 极简半透明字样，无任何背景色与边框 */
.definition-reveal-trigger span {
  display: inline-block !important;
  padding: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--text-muted, #94a3b8) !important;
  opacity: 0.38 !important;
  font-size: 0.92rem !important;
  font-weight: 500 !important;
  letter-spacing: 0.08em !important;
  transition: opacity 0.2s ease, transform 0.2s ease !important;
}

.definition-reveal-trigger:hover span,
.definition-reveal-trigger:focus-visible span {
  opacity: 0.8 !important;
  transform: translateY(-1px) !important;
}

/* 释义内容区 - 清晰鲜明高对比度 (High-Contrast Vivid Answer) */
.flashcard.is-definition-mode .definition-answer-content,
.definition-answer-content {
  display: none;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  padding: 12px 4px 18px !important;
  background: transparent !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  font-size: 1.1rem !important;
  line-height: 1.95 !important;
  color: var(--text-main, #1e293b) !important;
  text-align: justify !important;
  scrollbar-width: thin !important;
  -webkit-overflow-scrolling: touch !important;
  overflow-wrap: break-word !important;
  word-break: break-word !important;
}

.flashcard.is-definition-mode .definition-answer-content::-webkit-scrollbar:horizontal,
.definition-answer-content::-webkit-scrollbar:horizontal {
  display: none !important;
  height: 0 !important;
}

.flashcard.is-definition-mode .definition-answer-content *,
.definition-answer-content * {
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow-wrap: break-word !important;
  word-break: break-word !important;
}

.flashcard.is-definition-mode .definition-answer-content ul,
.definition-answer-content ul {
  padding-left: 1.25em !important;
  margin: 0 0 10px 0 !important;
}

.flashcard.is-definition-mode .definition-answer-content p {
  text-indent: 2em !important;
  margin: 0 0 10px 0 !important;
  line-height: 1.95 !important;
  color: var(--text-main, #1e293b) !important;
}

.flashcard.is-definition-mode .definition-answer-content .flashcard-source-page,
.card-answer-text .flashcard-source-page {
  display: block !important;
  margin: 0.65em auto 0 !important;
  text-align: center !important;
  text-indent: 0 !important;
  color: var(--text-muted, #64748b) !important;
  font-size: 0.86em !important;
  line-height: 1.55 !important;
}

.flashcard.is-definition-mode .definition-answer-content p,
.definition-answer-content p {
  text-indent: 2em !important;
  margin: 0 0 10px 0 !important;
  line-height: 2.05 !important;
  color: var(--text-main, #1e293b) !important;
  letter-spacing: 0.015em;
}

/* 独立粗体 / 结构引导词（如“是指”、“包括”）的专属优雅深青色 */
.flashcard.is-definition-mode .definition-answer-content strong,
.flashcard.is-definition-mode .definition-answer-content b,
.definition-answer-content strong,
.definition-answer-content b {
  font-weight: 760 !important;
  color: #1e3a8a !important;
}

/* 彩色高亮标签内的粗体文字：强制继承外层专属彩色，禁止刷黑 */
.flashcard.is-definition-mode .definition-answer-content span[style*="color"] strong,
.flashcard.is-definition-mode .definition-answer-content span[style*="color"] b,
.definition-answer-content span[style*="color"] strong,
.definition-answer-content span[style*="color"] b {
  font-weight: 780 !important;
  color: inherit !important;
}

.definition-revealed-hint {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted, #94a3b8);
  margin-top: 8px;
  padding: 4px 0;
  cursor: pointer;
  user-select: none;
  opacity: 0.45;
  transition: opacity 0.2s ease;
}

.definition-revealed-hint svg,
.definition-revealed-hint i {
  display: none !important;
}

.definition-revealed-hint:hover {
  opacity: 0.85;
}

.definition-page-source {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted, #64748b);
  font-size: 0.95em;
  letter-spacing: 0;
}

.definition-page-source[hidden] {
  display: none !important;
}

/* 显现状态 */
.flashcard.is-definition-mode.is-revealed .definition-reveal-trigger {
  display: none !important;
}

.flashcard.is-definition-mode.is-revealed .definition-answer-content {
  display: block !important;
  animation: fadeInDefinition 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.flashcard.is-definition-mode.is-revealed .definition-revealed-hint {
  display: flex !important;
}

/* ========================================================================== */
/* 🌟 药事法规名词解释：高颜值通透果冻色块 + 显色字体规则 (Vivid Rich Badges) */
/* ========================================================================== */

/* 通用有色关键词色块基准 */
.flashcard.is-definition-mode .definition-answer-content span[style*="color"],
.definition-answer-content span[style*="color"] {
  display: inline !important;
  border-radius: 6px !important;
  padding: 1.5px 6px !important;
  margin: 0 2px !important;
  box-decoration-break: clone !important;
  -webkit-box-decoration-break: clone !important;
  font-weight: 750 !important;
  line-height: 1.85 !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important;
  transition: all 0.15s ease !important;
}

/* 🟠 落日暖橙系（核心定义 / 采分主干 / 关键条件 / 属性分类，含原绿色高亮）：饱满暖阳橙字体 + 香槟暖日色块 */
.flashcard.is-definition-mode .definition-answer-content span[style*="#10b981"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#059669"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#16a34a"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#22c55e"],
.flashcard.is-definition-mode .definition-answer-content span[style*="green"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#ea580c"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#f97316"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#fb923c"],
.flashcard.is-definition-mode .definition-answer-content span[style*="orange"],
.definition-answer-content span[style*="#10b981"],
.definition-answer-content span[style*="#059669"],
.definition-answer-content span[style*="#16a34a"],
.definition-answer-content span[style*="#22c55e"],
.definition-answer-content span[style*="green"],
.definition-answer-content span[style*="#ea580c"],
.definition-answer-content span[style*="#f97316"],
.definition-answer-content span[style*="#fb923c"],
.definition-answer-content span[style*="orange"] {
  color: #c2410c !important;
  background-color: rgba(249, 115, 22, 0.14) !important;
  border: 1px solid rgba(249, 115, 22, 0.30) !important;
  box-shadow: 0 1px 2px rgba(249, 115, 22, 0.06) !important;
}

/* 🔵 宝石蓝系（法律主体 / 监管机构 / 组织机构 / 核心概念）：湛蓝字体 + 清澈海蓝晶石色块 */
.flashcard.is-definition-mode .definition-answer-content span[style*="#0284c7"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#0891b2"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#0369a1"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#3b82f6"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#2563eb"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#1d4ed8"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#0ea5e9"],
.flashcard.is-definition-mode .definition-answer-content span[style*="blue"],
.definition-answer-content span[style*="#0284c7"],
.definition-answer-content span[style*="#0891b2"],
.definition-answer-content span[style*="#0369a1"],
.definition-answer-content span[style*="#3b82f6"],
.definition-answer-content span[style*="#2563eb"],
.definition-answer-content span[style*="#1d4ed8"],
.definition-answer-content span[style*="#0ea5e9"],
.definition-answer-content span[style*="blue"] {
  color: #0369a1 !important;
  background-color: rgba(14, 165, 233, 0.13) !important;
  border: 1px solid rgba(14, 165, 233, 0.28) !important;
  box-shadow: 0 1px 2px rgba(14, 165, 233, 0.06) !important;
}

/* 🔴 绯红玫瑰系（红线禁止 / 处分撤销 / 强制义务 / 警示）：绯红玫瑰字体 + 珊瑚微光色块 */
.flashcard.is-definition-mode .definition-answer-content span[style*="#e11d48"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#f43f5e"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#ef4444"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#dc2626"],
.flashcard.is-definition-mode .definition-answer-content span[style*="red"],
.definition-answer-content span[style*="#e11d48"],
.definition-answer-content span[style*="#f43f5e"],
.definition-answer-content span[style*="#ef4444"],
.definition-answer-content span[style*="#dc2626"],
.definition-answer-content span[style*="red"] {
  color: #be123c !important;
  background-color: rgba(244, 63, 94, 0.13) !important;
  border: 1px solid rgba(244, 63, 94, 0.28) !important;
  box-shadow: 0 1px 2px rgba(244, 63, 94, 0.06) !important;
}

/* 🟣 极光紫系（制度名称 / 学说概念 / 专用名词）：极光紫字体 + 薰衣草果冻色块 */
.flashcard.is-definition-mode .definition-answer-content span[style*="#8b5cf6"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#7c3aed"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#6366f1"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#9333ea"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#a855f7"],
.flashcard.is-definition-mode .definition-answer-content span[style*="purple"],
.definition-answer-content span[style*="#8b5cf6"],
.definition-answer-content span[style*="#7c3aed"],
.definition-answer-content span[style*="#6366f1"],
.definition-answer-content span[style*="#9333ea"],
.definition-answer-content span[style*="#a855f7"],
.definition-answer-content span[style*="purple"] {
  color: #6d28d9 !important;
  background-color: rgba(139, 92, 246, 0.13) !important;
  border: 1px solid rgba(139, 92, 246, 0.28) !important;
  box-shadow: 0 1px 2px rgba(139, 92, 246, 0.06) !important;
}

/* 🟡 暖金黄系（关键时限 / 年限 / 数量指标 / 比率）：亮丽琥珀金字体 + 暖金流光色块 */
.flashcard.is-definition-mode .definition-answer-content span[style*="#f59e0b"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#d97706"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#b45309"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#eab308"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#ca8a04"],
.flashcard.is-definition-mode .definition-answer-content span[style*="yellow"],
.flashcard.is-definition-mode .definition-answer-content span[style*="gold"],
.definition-answer-content span[style*="#f59e0b"],
.definition-answer-content span[style*="#d97706"],
.definition-answer-content span[style*="#b45309"],
.definition-answer-content span[style*="#eab308"],
.definition-answer-content span[style*="#ca8a04"],
.definition-answer-content span[style*="yellow"],
.definition-answer-content span[style*="gold"] {
  color: #b45309 !important;
  background-color: rgba(245, 158, 11, 0.14) !important;
  border: 1px solid rgba(245, 158, 11, 0.32) !important;
  box-shadow: 0 1px 2px rgba(245, 158, 11, 0.06) !important;
}

/* 💠 冰川青碧系（技术标准 / 检验指标 / 专有参数）：深邃松青字体 + 冰川透青色块 */
.flashcard.is-definition-mode .definition-answer-content span[style*="#0d9488"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#0f766e"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#14b8a6"],
.flashcard.is-definition-mode .definition-answer-content span[style*="#06b6d4"],
.flashcard.is-definition-mode .definition-answer-content span[style*="teal"],
.flashcard.is-definition-mode .definition-answer-content span[style*="cyan"],
.definition-answer-content span[style*="#0d9488"],
.definition-answer-content span[style*="#0f766e"],
.definition-answer-content span[style*="#14b8a6"],
.definition-answer-content span[style*="#06b6d4"],
.definition-answer-content span[style*="teal"],
.definition-answer-content span[style*="cyan"] {
  color: #0f766e !important;
  background-color: rgba(20, 184, 166, 0.13) !important;
  border: 1px solid rgba(20, 184, 166, 0.28) !important;
  box-shadow: 0 1px 2px rgba(20, 184, 166, 0.06) !important;
}

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

/* 深色模式鲜明高对比度适配 (Neon Glow Chips) */
body.dark-theme .definition-reveal-trigger {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

body.dark-theme .definition-reveal-trigger span {
  color: #94a3b8 !important;
  opacity: 0.42 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

body.dark-theme .definition-reveal-trigger:hover span {
  opacity: 0.85 !important;
}

body.dark-theme .definition-answer-content {
  background: transparent !important;
  border: none !important;
  color: #f1f5f9 !important;
}

body.dark-theme .flashcard.is-definition-mode .definition-answer-content p,
body.dark-theme .definition-answer-content p {
  color: #f1f5f9 !important;
}

body.dark-theme .flashcard.is-definition-mode .definition-answer-content strong,
body.dark-theme .flashcard.is-definition-mode .definition-answer-content b,
body.dark-theme .definition-answer-content strong,
body.dark-theme .definition-answer-content b {
  color: #93c5fd !important;
}

body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="color"] strong,
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="color"] b,
body.dark-theme .definition-answer-content span[style*="color"] strong,
body.dark-theme .definition-answer-content span[style*="color"] b {
  color: inherit !important;
}

body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="color"],
body.dark-theme .definition-answer-content span[style*="color"] {
  box-decoration-break: clone !important;
  -webkit-box-decoration-break: clone !important;
}

/* 🔵 深色模式·电光晴空蓝 */
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#0284c7"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#0891b2"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#0369a1"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#3b82f6"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#2563eb"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#1d4ed8"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#0ea5e9"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="blue"],
body.dark-theme .definition-answer-content span[style*="#0284c7"],
body.dark-theme .definition-answer-content span[style*="#0891b2"],
body.dark-theme .definition-answer-content span[style*="#0369a1"],
body.dark-theme .definition-answer-content span[style*="#3b82f6"],
body.dark-theme .definition-answer-content span[style*="#2563eb"],
body.dark-theme .definition-answer-content span[style*="#1d4ed8"],
body.dark-theme .definition-answer-content span[style*="#0ea5e9"],
body.dark-theme .definition-answer-content span[style*="blue"] {
  color: #38bdf8 !important;
  background-color: rgba(14, 165, 233, 0.20) !important;
  border: 1px solid rgba(56, 189, 248, 0.38) !important;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.16) !important;
}

/* 🟠 深色模式·明艳落日暖橙（含原绿色高亮） */
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#10b981"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#059669"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#16a34a"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#22c55e"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="green"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#ea580c"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#f97316"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#fb923c"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="orange"],
body.dark-theme .definition-answer-content span[style*="#10b981"],
body.dark-theme .definition-answer-content span[style*="#059669"],
body.dark-theme .definition-answer-content span[style*="#16a34a"],
body.dark-theme .definition-answer-content span[style*="#22c55e"],
body.dark-theme .definition-answer-content span[style*="green"],
body.dark-theme .definition-answer-content span[style*="#ea580c"],
body.dark-theme .definition-answer-content span[style*="#f97316"],
body.dark-theme .definition-answer-content span[style*="#fb923c"],
body.dark-theme .definition-answer-content span[style*="orange"] {
  color: #fb923c !important;
  background-color: rgba(249, 115, 22, 0.22) !important;
  border: 1px solid rgba(251, 146, 60, 0.40) !important;
  box-shadow: 0 0 8px rgba(251, 146, 60, 0.16) !important;
}

/* 🔴 深色模式·亮丽玫瑰红 */
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#e11d48"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#f43f5e"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#ef4444"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#dc2626"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="red"],
body.dark-theme .definition-answer-content span[style*="#e11d48"],
body.dark-theme .definition-answer-content span[style*="#f43f5e"],
body.dark-theme .definition-answer-content span[style*="#ef4444"],
body.dark-theme .definition-answer-content span[style*="#dc2626"],
body.dark-theme .definition-answer-content span[style*="red"] {
  color: #fb7185 !important;
  background-color: rgba(244, 63, 94, 0.20) !important;
  border: 1px solid rgba(251, 113, 133, 0.38) !important;
  box-shadow: 0 0 8px rgba(251, 113, 133, 0.16) !important;
}

/* 🟣 深色模式·幻彩电光紫 */
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#8b5cf6"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#7c3aed"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#6366f1"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#9333ea"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#a855f7"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="purple"],
body.dark-theme .definition-answer-content span[style*="#8b5cf6"],
body.dark-theme .definition-answer-content span[style*="#7c3aed"],
body.dark-theme .definition-answer-content span[style*="#6366f1"],
body.dark-theme .definition-answer-content span[style*="#9333ea"],
body.dark-theme .definition-answer-content span[style*="#a855f7"],
body.dark-theme .definition-answer-content span[style*="purple"] {
  color: #c084fc !important;
  background-color: rgba(139, 92, 246, 0.20) !important;
  border: 1px solid rgba(192, 132, 252, 0.38) !important;
  box-shadow: 0 0 8px rgba(192, 132, 252, 0.16) !important;
}

/* 🟡 深色模式·荧光金葵黄 */
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#f59e0b"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#d97706"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#b45309"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#eab308"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#ca8a04"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="yellow"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="gold"],
body.dark-theme .definition-answer-content span[style*="#f59e0b"],
body.dark-theme .definition-answer-content span[style*="#d97706"],
body.dark-theme .definition-answer-content span[style*="#b45309"],
body.dark-theme .definition-answer-content span[style*="#eab308"],
body.dark-theme .definition-answer-content span[style*="#ca8a04"],
body.dark-theme .definition-answer-content span[style*="yellow"],
body.dark-theme .definition-answer-content span[style*="gold"] {
  color: #fcd34d !important;
  background-color: rgba(245, 158, 11, 0.22) !important;
  border: 1px solid rgba(252, 211, 77, 0.40) !important;
  box-shadow: 0 0 8px rgba(252, 211, 77, 0.16) !important;
}

/* 💠 深色模式·清爽冰川青 */
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#0d9488"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#0f766e"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#14b8a6"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="#06b6d4"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="teal"],
body.dark-theme .flashcard.is-definition-mode .definition-answer-content span[style*="cyan"],
body.dark-theme .definition-answer-content span[style*="#0d9488"],
body.dark-theme .definition-answer-content span[style*="#0f766e"],
body.dark-theme .definition-answer-content span[style*="#14b8a6"],
body.dark-theme .definition-answer-content span[style*="#06b6d4"],
body.dark-theme .definition-answer-content span[style*="teal"],
body.dark-theme .definition-answer-content span[style*="cyan"] {
  color: #2dd4bf !important;
  background-color: rgba(20, 184, 166, 0.20) !important;
  border: 1px solid rgba(45, 212, 191, 0.38) !important;
  box-shadow: 0 0 8px rgba(45, 212, 191, 0.16) !important;
}

/* ========================================================================== */
/* 药事法规时政新规：同页长知识卡（不翻面） */
/* ========================================================================== */

body.flashcard-page .flashcard.is-current-affairs-guide-mode {
  cursor: default !important;
  transform: none !important;
}

body.flashcard-page .flashcard.is-current-affairs-guide-mode .card-face.card-back {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

body.flashcard-page .flashcard.is-current-affairs-guide-mode .card-face.card-front {
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  overflow: hidden !important;
  padding: 22px 26px !important;
}

body.flashcard-page .flashcard.is-current-affairs-guide-mode .card-question-text {
  flex: 0 0 auto !important;
  display: block !important;
  text-align: center !important;
  font-size: clamp(1.18rem, 2.2vw, 1.55rem) !important;
  font-weight: 850 !important;
  line-height: 1.45 !important;
  color: #0f3f2e !important;
  padding: 6px 8px 12px !important;
  margin: 0 !important;
  border-bottom: 1px solid rgba(22, 101, 52, 0.16) !important;
}

body.dark-theme.flashcard-page .flashcard.is-current-affairs-guide-mode .card-question-text,
body.dark-theme .flashcard.is-current-affairs-guide-mode .card-question-text {
  color: #dcfce7 !important;
  border-bottom-color: rgba(187, 247, 208, 0.18) !important;
}

body.flashcard-page .flashcard.is-current-affairs-guide-mode .definition-answer-box {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow: hidden !important;
  display: flex !important;
  border: none !important;
  background: transparent !important;
}

body.flashcard-page .flashcard.is-current-affairs-guide-mode .definition-reveal-trigger,
body.flashcard-page .flashcard.is-current-affairs-guide-mode .definition-revealed-hint,
body.flashcard-page .flashcard.is-current-affairs-guide-mode .tap-hint {
  display: none !important;
}

body.flashcard-page .flashcard.is-current-affairs-guide-mode .definition-answer-content {
  display: block !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  padding: 4px 8px 18px !important;
  font-size: 0.98rem !important;
  line-height: 1.78 !important;
  text-align: left !important;
  color: var(--text-main, #1e293b) !important;
}

body.flashcard-page .flashcard.is-current-affairs-guide-mode .definition-answer-content p {
  text-indent: 0 !important;
  margin: 0 0 8px !important;
  line-height: 1.78 !important;
}

.current-affairs-guide-card {
  display: grid;
  gap: 14px;
}

.current-affairs-guide-kicker {
  display: inline-flex;
  width: fit-content;
  color: #166534;
  background: rgba(34, 197, 94, 0.10);
  border: 1px solid rgba(22, 163, 74, 0.18);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.current-affairs-guide-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.current-affairs-guide-meta div {
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 10px;
  background: rgba(248, 250, 252, 0.72);
  padding: 8px 10px;
}

.current-affairs-guide-meta span {
  display: block;
  color: var(--text-muted, #64748b);
  font-size: 0.76rem;
  margin-bottom: 2px;
}

.current-affairs-guide-meta strong {
  display: block;
  color: var(--text-main, #1e293b);
  font-size: 0.88rem;
  line-height: 1.45;
}

.current-affairs-guide-section {
  border-top: 1px solid rgba(148, 163, 184, 0.22);
  padding-top: 12px;
}

.current-affairs-guide-section h4 {
  margin: 0 0 7px;
  color: #166534;
  font-size: 1rem;
  font-weight: 850;
}

.current-affairs-guide-section ul {
  margin: 0;
  padding-left: 1.2em;
}

.current-affairs-guide-section li {
  margin: 0 0 6px;
}

.current-affairs-guide-purpose {
  border-top: none;
  padding-top: 0;
}

.current-affairs-guide-hooks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  border-left: 3px solid #16a34a;
  background: rgba(240, 253, 244, 0.72);
  border-radius: 10px;
  padding: 10px 12px;
  color: #14532d;
}

.current-affairs-guide-hooks span {
  display: inline-flex;
  border: 1px solid rgba(22, 163, 74, 0.24);
  background: #ffffff;
  color: #166534;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.78rem;
  font-weight: 750;
}

body.flashcard-page .flashcards-active-area.is-current-affairs-guide-area #annotate-fc-btn,
body.flashcard-page .flashcards-active-area.is-current-affairs-guide-area #edit-fc-btn-bottom,
body.flashcard-page .flashcards-active-area.is-current-affairs-guide-area #add-fc-btn-bottom,
body.flashcard-page .flashcards-active-area.is-current-affairs-guide-area #reset-fc-btn,
body.flashcard-page .flashcards-active-area.is-current-affairs-guide-area #master-fc-btn {
  display: none !important;
}

body.dark-theme .current-affairs-guide-meta div,
body.dark-theme .current-affairs-guide-hooks {
  background: rgba(15, 23, 42, 0.72);
  border-color: rgba(148, 163, 184, 0.24);
}

body.dark-theme .current-affairs-guide-kicker,
body.dark-theme .current-affairs-guide-section h4,
body.dark-theme .current-affairs-guide-hooks,
body.dark-theme .current-affairs-guide-hooks span {
  color: #86efac;
}

body.dark-theme .current-affairs-guide-hooks span {
  background: rgba(22, 101, 52, 0.24);
}

@media (max-width: 768px) {
  body.flashcard-page .flashcard.is-current-affairs-guide-mode .card-face.card-front {
    padding: 16px 12px !important;
  }

  .current-affairs-guide-meta {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .flashcard.is-definition-mode .card-face.card-front {
    padding: 18px 10px !important;
    gap: 10px !important;
  }
  .flashcard.is-definition-mode .card-question-text {
    font-size: 1.25rem !important;
    padding-bottom: 8px !important;
  }
  .definition-reveal-trigger {
    min-height: 120px !important;
    padding: 16px 8px !important;
  }
  .definition-reveal-trigger span {
    font-size: 0.88rem !important;
  }
  .flashcard.is-definition-mode .definition-answer-content {
    font-size: 1rem !important;
    line-height: 1.85 !important;
    padding: 8px 0 14px !important;
  }
}



.card-page-source-icon {
  display: block;
  color: var(--text-muted);
}

.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: 920px;
  }
  
  .card-scene {
    height: 620px;
    min-height: 620px;
    max-height: 620px;
  }
}

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

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

/* ==========================================================================
   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);
}

.editor-title {
  font-weight: 750;
  color: var(--primary-color);
  margin-bottom: 12px;
}

#flashcard-visual-editor {
  gap: 14px;
  overflow: auto;
}

#flashcard-visual-editor label {
  display: grid;
  gap: 7px;
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 680;
}

#flashcard-visual-editor input,
#flashcard-visual-editor textarea,
.visual-editor-rich-input,
.visual-editor-rich-paragraph {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-color);
  color: var(--text-main);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.7;
  outline: none;
  transition: border-color var(--transition-speed), box-shadow var(--transition-speed), background-color var(--transition-speed);
}

#flashcard-visual-editor input,
#flashcard-visual-editor textarea {
  padding: 12px 14px;
}

#visual-editor-list-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#visual-editor-list-container {
  display: grid;
  gap: 9px;
}

.visual-editor-item-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: start;
}

.visual-editor-level-2 {
  padding-left: 28px;
}

.visual-editor-level-3 {
  padding-left: 54px;
}

.visual-editor-item-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  min-height: 34px;
  border-radius: 9px;
  background: var(--primary-light);
  color: var(--primary-color);
  font-size: 0.78rem;
  font-weight: 820;
}

.visual-editor-level-2 .visual-editor-item-no {
  background: color-mix(in srgb, #dcfce7 78%, #ffffff 22%);
  color: #047857;
}

.visual-editor-level-3 .visual-editor-item-no {
  background: color-mix(in srgb, #f1f5f9 85%, #ffffff 15%);
  color: var(--text-muted);
}

.visual-editor-rich-input,
.visual-editor-rich-paragraph {
  min-height: 42px;
  padding: 10px 12px;
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: none;
}

.visual-editor-rich-paragraph {
  min-height: 180px;
}

.visual-editor-rich-input:focus,
.visual-editor-rich-paragraph:focus,
#flashcard-visual-editor input:focus,
#flashcard-visual-editor textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-light) 75%, transparent);
}

.visual-editor-rich-input:empty::before,
.visual-editor-rich-paragraph:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  opacity: 0.72;
}

.visual-editor-row-actions {
  display: inline-flex;
  gap: 5px;
}

.visual-row-btn {
  width: 32px;
  min-width: 32px;
  height: 34px;
  padding: 0 !important;
  justify-content: center;
}

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

.format-toolbar > span {
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 680;
}

/* 侧边栏折叠规则 (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;
}

.settings-card[data-global-settings-hub] {
  margin-top: 0;
}

.settings-section-label {
  margin: 18px 0 8px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
}

/* 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: 10000100;
  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: 10000110;
  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);
}

.unified-settings-btn {
  flex: 0 0 auto;
}

.global-settings-trigger {
  border: 1px solid var(--border-color);
  background: var(--panel-bg);
  color: var(--text-main);
}

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

/* 当背诵库/工具栏紧跟在学科切换后时，去除中间多余分割线并让两组按钮无缝紧凑连接 */
.study-navigation:has(+ .study-navigation) {
  padding-top: 6px !important;
  padding-bottom: 2px !important;
  border-bottom: none !important;
}

.study-navigation + .study-navigation {
  padding-top: 2px !important;
  padding-bottom: 6px !important;
}

.study-navigation-label {
  display: none !important;
}

.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);
}

/* 真题/模拟题双页模式 (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;
}

.pwa-status[data-state="success"] {
  border-color: #2F855A;
}

.pwa-status[data-state="update"] {
  border-color: #2F855A;
}

.pwa-status[data-actionable="true"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  pointer-events: auto;
}

.pwa-status-text {
  min-width: 0;
}

.pwa-status-action {
  flex: 0 0 auto;
  border: 0;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--primary-color);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.pwa-status-action:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary-color) 45%, #ffffff);
  outline-offset: 2px;
}

.pwa-install-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-color: rgba(45, 90, 39, 0.18);
  background: linear-gradient(135deg, rgba(229, 241, 229, 0.78), rgba(255, 255, 255, 0.92));
}

.pwa-install-card-copy {
  min-width: 0;
}

.pwa-install-card-copy h4 {
  margin-bottom: 5px;
}

.pwa-install-card-copy p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.install-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}

.install-btn.is-installable {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #fff;
  box-shadow: 0 8px 18px rgba(45, 90, 39, 0.18);
}

.install-btn.is-installed {
  background: rgba(47, 133, 90, 0.1);
  border-color: rgba(47, 133, 90, 0.28);
  color: #2f6f45;
}

.pwa-install-guide {
  color: var(--text-main);
}

.pwa-install-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(45, 90, 39, 0.18);
  background: rgba(229, 241, 229, 0.9);
  color: var(--primary-color);
  font-size: 0.78rem;
  font-weight: 800;
}

.pwa-install-summary {
  margin: 0 0 13px;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

.pwa-install-steps {
  margin: 0;
  padding-left: 22px;
  color: var(--text-main);
  font-size: 0.94rem;
  line-height: 1.75;
}

.pwa-install-steps li::marker {
  color: var(--primary-color);
  font-weight: 800;
}

.pwa-install-tip {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 7px;
  background: rgba(247, 250, 247, 0.9);
  color: var(--text-muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.pwa-native-install-btn {
  width: 100%;
  margin-top: 14px;
}

.pwa-install-more {
  margin-top: 14px;
  border-top: 1px dashed var(--border-color);
  padding-top: 12px;
}

.pwa-install-more summary {
  cursor: pointer;
  color: var(--primary-color);
  font-size: 0.88rem;
  font-weight: 800;
}

.pwa-install-device-grid {
  display: grid;
  gap: 9px;
  margin-top: 10px;
}

.pwa-install-device-grid div {
  padding: 10px 11px;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.72);
}

.pwa-install-device-grid strong,
.pwa-install-device-grid span {
  display: block;
}

.pwa-install-device-grid strong {
  margin-bottom: 3px;
  color: var(--text-main);
  font-size: 0.86rem;
}

.pwa-install-device-grid span {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.global-settings-modal {
  max-width: min(460px, calc(100vw - 28px));
}

.export-format-card {
  transition: all 0.2s ease;
  user-select: none;
}
.export-format-card:hover {
  border-color: var(--primary-color) !important;
}
.export-format-card.is-active {
  border-color: var(--primary-color) !important;
  background: color-mix(in srgb, var(--primary-color) 8%, var(--card-bg, #fff)) !important;
}

.global-settings-card {
  margin-top: 14px;
}

.global-settings-card h4 {
  margin-bottom: 10px;
}

.global-settings-link-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.global-settings-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  background: var(--panel-bg);
  color: var(--text-main);
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
}

.global-settings-link:hover,
.global-settings-link.is-active {
  border-color: rgba(45, 90, 39, 0.28);
  background: rgba(229, 241, 229, 0.8);
  color: var(--primary-color);
}

.global-settings-link svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

body.dark-theme .pwa-install-card {
  background: linear-gradient(135deg, rgba(45, 90, 39, 0.16), rgba(17, 24, 39, 0.76));
}

body.dark-theme .install-btn.is-installed {
  color: #9AE6B4;
}

body.dark-theme .pwa-install-tip,
body.dark-theme .pwa-install-device-grid div {
  background: rgba(17, 24, 39, 0.62);
}

body.dark-theme .global-settings-link:hover,
body.dark-theme .global-settings-link.is-active {
  background: rgba(45, 90, 39, 0.22);
}

@media (max-width: 640px) {
  .pwa-install-card {
    align-items: stretch;
    flex-direction: column;
  }

  .pwa-install-card .install-btn {
    width: 100%;
  }

  .global-settings-link-grid {
    grid-template-columns: 1fr;
  }
}

.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-black { background: rgba(17,24,39,0.16) !important; color: #111827 !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-black { color: #111827 !important; background: rgba(17,24,39,0.50) !important; }
.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-black:hover { background: rgba(17,24,39,0.65) !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%;
  min-height: 96px;
  max-height: min(42vh, 300px);
  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;
  line-height: 1.58;
  outline: none;
  resize: vertical;
  overflow-y: auto;
  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-black { background-color: #111827; }
.color-dot-red { background-color: #ef4444; }
.color-dot-green { background-color: #10b981; }
.color-dot-blue { background-color: #3b82f6; }
.color-dot-yellow { background-color: #f59e0b; }

/* 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);
}

.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%;
  min-height: 96px;
  max-height: min(42vh, 300px);
  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;
  line-height: 1.58;
  outline: none;
  resize: vertical;
  overflow-y: auto;
  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-black { background-color: #111827; }
.color-dot-red { background-color: #ef4444; }
.color-dot-green { background-color: #10b981; }
.color-dot-blue { background-color: #3b82f6; }
.color-dot-yellow { background-color: #f59e0b; }

/* 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);
}

/* Mobile uses the top-left menu button; desktop keeps the side handle. */
@media (max-width: 768px) {
  .sidebar-toggle-trigger {
    display: none !important;
  }
}

/* Fullscreen / immersive chapter drawer keeps the original pill sidebar handle visible. */
body.fullscreen-mode-active .sidebar,
body.flashcard-immersive .sidebar {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  bottom: 0 !important;
  width: min(86vw, 320px) !important;
  height: 100dvh !important;
  margin-left: 0 !important;
  transform: translateX(-100%) !important;
  z-index: 1000002 !important;
  display: flex !important;
  overflow: visible !important;
}

body.fullscreen-mode-active .sidebar.open,
body.flashcard-immersive .sidebar.open {
  transform: translateX(0) !important;
}

body.fullscreen-mode-active .sidebar.collapsed,
body.flashcard-immersive .sidebar.collapsed {
  margin-left: 0 !important;
  transform: translateX(-100%) !important;
}

body.fullscreen-mode-active .sidebar-overlay,
body.flashcard-immersive .sidebar-overlay {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100dvh !important;
  z-index: 1000001 !important;
}

body.fullscreen-mode-active .sidebar-overlay.open,
body.flashcard-immersive .sidebar-overlay.open {
  display: block !important;
}

body.fullscreen-mode-active .sidebar-toggle-trigger,
body.flashcard-immersive .sidebar-toggle-trigger {
  display: flex !important;
  right: -22px;
  width: 30px;
  height: 54px;
  z-index: 1000003;
  pointer-events: auto;
}

/* ==========================================================================
   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-textbook-points {
  color: #075985;
  background: #e0f2fe;
  border-color: #7dd3fc;
}

.source-thinking-question {
  color: #0369a1;
  background: #e0f2fe;
  border-color: #7dd3fc;
}

.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,
  .global-settings-modal,
  .account-settings-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 100vw !important;
    height: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    min-height: 100dvh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    box-shadow: none !important;
    transform: none !important;
    background: var(--panel-bg, #ffffff) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    display: none !important;
    flex-direction: column !important;
    overflow: hidden !important;
    z-index: 10000120 !important;
  }

  .settings-modal.active,
  .global-settings-modal.active,
  .account-settings-modal.active {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: none !important;
  }

  .settings-modal .modal-header {
    padding-top: max(16px, env(safe-area-inset-top));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: 14px;
    flex: 0 0 auto;
  }

  .settings-modal .modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: 14px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }

  .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;
  }
}

/* Flashcards use an independent immersive state so mind-map fullscreen remains isolated. */
body.flashcard-immersive {
  overflow-x: hidden;
  overflow-y: hidden;
  background: var(--bg-color);
}

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

body.flashcard-immersive .app-container {
  position: fixed;
  inset: 0;
  height: 100dvh;
  min-height: 100dvh;
  z-index: 10000020;
  background: var(--bg-color);
  isolation: isolate;
}

body.flashcard-immersive .main-content {
  height: 100dvh;
  min-height: 100dvh;
}

body.flashcard-immersive .flashcards-container {
  min-height: 100dvh;
  padding: max(14px, env(safe-area-inset-top)) 20px max(16px, env(safe-area-inset-bottom));
  justify-content: center;
  overflow-y: auto;
}

body.flashcard-immersive .flashcards-active-area {
  flex: 0 1 auto;
  min-height: 0;
  justify-content: center;
}

body.flashcard-immersive .top-bar,
body.flashcard-immersive .glow-container,
body.flashcard-immersive #feedback-trigger-btn,
body.flashcard-immersive .modal-backdrop,
body.flashcard-immersive .mastery-modal,
body.flashcard-immersive .settings-modal,
body.flashcard-immersive .pwa-help-modal {
  display: none !important;
}

@media (max-width: 768px) {
  body.flashcard-immersive .card-scene { width: 100%; min-height: 440px; }
  body.flashcard-immersive .floating-nav-btn { width: 34px; height: 34px; }
  body.flashcard-immersive .floating-nav-prev { left: 0; }
  body.flashcard-immersive .floating-nav-next { right: 0; }
  body.flashcard-immersive .card-face { padding: 18px; }
  body.flashcard-immersive .card-question-text { padding: 8px 0; font-size: 1.15rem; }
  body.flashcard-immersive .card-inline-progress { inset: auto; width: 100%; margin-bottom: 12px; }
}

/* Unified mobile/tablet study navigation. Keep one layout source for the shared top bar. */
@media (max-width: 1400px) {
  .top-bar {
    display: grid !important;
    grid-template-columns: 34px minmax(0, 1fr) auto !important;
    align-items: stretch !important;
    align-content: stretch !important;
    gap: 2px !important;
    padding-inline: 4px !important;
    flex-wrap: nowrap !important;
    overflow: hidden !important;
  }

  .top-bar-left {
    display: contents !important;
  }

  .top-bar-right {
    grid-column: 3 !important;
    grid-row: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 2px !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: none !important;
    margin-left: 0 !important;
  }

  .top-bar .theme-toggle {
    display: contents !important;
  }

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

  .top-bar .toggle-btn,
  .top-bar #menu-btn,
  .top-bar #exam-menu-btn,
  .top-bar #open-prescription-sidebar,
  .top-bar #open-excipient-sidebar {
    grid-column: 1 !important;
    grid-row: 1 !important;
    justify-self: center !important;
    align-self: center !important;
    flex: 0 0 34px !important;
    width: 34px !important;
    min-width: 34px !important;
    height: 100% !important;
    padding: 0 !important;
    touch-action: manipulation !important;
    cursor: pointer !important;
  }

  .top-bar .top-mode-tabs {
    grid-column: 2 !important;
    grid-row: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
    align-self: stretch !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    margin-right: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    justify-content: flex-start !important;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

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

  .top-bar .top-mode-tab {
    flex: 0 0 auto !important;
    height: 100% !important;
    min-height: 100% !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
  }

  .top-bar .theme-btn,
  .top-bar .settings-btn,
  .top-bar .account-sync-btn,
  .top-bar .account-profile-trigger {
    grid-column: auto !important;
    grid-row: 1 !important;
    flex: 0 0 auto !important;
    width: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    padding: 0 !important;
    white-space: nowrap !important;
  }
}

@media (max-width: 768px) {
  :root {
    --study-topbar-height: calc(64px + env(safe-area-inset-top));
  }

  .top-bar {
    height: var(--study-topbar-height) !important;
    min-height: var(--study-topbar-height) !important;
    padding: calc(6px + env(safe-area-inset-top)) 6px 6px !important;
    grid-template-columns: 28px minmax(0, 1fr) auto !important;
    gap: 3px !important;
  }

  .top-bar .toggle-btn,
  .top-bar #menu-btn,
  .top-bar #exam-menu-btn,
  .top-bar #open-prescription-sidebar,
  .top-bar #open-excipient-sidebar {
    flex: 0 0 28px !important;
    width: 28px !important;
    min-width: 28px !important;
    height: 100% !important;
    padding: 0 !important;
  }

  .top-bar .top-mode-tabs {
    padding: 3px 4px !important;
    gap: 3px !important;
    margin-right: 0 !important;
    height: 100% !important;
    min-height: 100% !important;
    align-self: stretch !important;
    scroll-padding-inline: 4px;
  }

  .top-bar .top-mode-tab {
    height: 100% !important;
    min-height: 100% !important;
    padding: 0 11px !important;
    gap: 5px !important;
    font-size: 0.86rem !important;
    font-weight: 750 !important;
  }

  .top-bar .top-mode-tab svg,
  .top-bar .top-mode-tab i {
    width: 17.5px !important;
    height: 17.5px !important;
    stroke-width: 2.2px !important;
  }

  .top-bar .top-bar-right {
    gap: 3px !important;
  }

  .top-bar .theme-btn,
  .top-bar .settings-btn,
  .top-bar .account-sync-btn,
  .top-bar .account-profile-trigger {
    width: 38px !important;
    min-width: 38px !important;
    max-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    padding: 0 !important;
  }

  .top-bar #menu-btn i,
  .top-bar #menu-btn svg,
  .top-bar #exam-menu-btn i,
  .top-bar #exam-menu-btn svg,
  .top-bar #open-prescription-sidebar i,
  .top-bar #open-prescription-sidebar svg,
  .top-bar #open-excipient-sidebar i,
  .top-bar #open-excipient-sidebar svg {
    display: none !important;
  }

  .top-bar #menu-btn::before,
  .top-bar #exam-menu-btn::before,
  .top-bar #open-prescription-sidebar::before,
  .top-bar #open-excipient-sidebar::before {
    content: "" !important;
    display: block !important;
    width: 21px !important;
    height: 17px !important;
    border-radius: 1px;
    background:
      linear-gradient(currentColor, currentColor) 0 1px / 21px 2.2px no-repeat,
      linear-gradient(currentColor, currentColor) 0 7.5px / 15.5px 2.2px no-repeat,
      linear-gradient(currentColor, currentColor) 0 14px / 21px 2.2px no-repeat !important;
  }
}

@media (min-width: 769px) and (max-width: 1400px) {
  :root {
    --study-topbar-height: 66px;
  }

  .top-bar {
    height: var(--study-topbar-height) !important;
    min-height: var(--study-topbar-height) !important;
    padding: 8px 12px !important;
  }

  .top-bar .top-mode-tab {
    font-size: 0.9rem !important;
    padding: 0 13px !important;
    gap: 5px !important;
  }

  .top-bar .top-mode-tab svg,
  .top-bar .top-mode-tab i {
    width: 18px !important;
    height: 18px !important;
    stroke-width: 2.2px !important;
  }
}


/* 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: 4px;
  padding: 5px 7px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 22px;
  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: 8px;
  width: 38px;
  height: 38px;
  min-width: 38px;
  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: 19px !important;
  height: 19px !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.is-user-positioned {
  position: fixed !important;
  left: var(--hw-toolbar-left, 50%) !important;
  top: var(--hw-toolbar-top, 72px) !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
}

.mindmap-handwriting-toolbar.is-dragging {
  cursor: grabbing;
  user-select: none;
  -webkit-user-select: none;
}

.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-drag-handle {
  cursor: grab;
  touch-action: none;
  color: color-mix(in srgb, var(--text-muted, #5f7660) 84%, var(--primary-color, #2f6b2f) 16%);
}

.hw-drag-handle:active,
.mindmap-handwriting-toolbar.is-dragging .hw-drag-handle {
  cursor: grabbing;
}

.hw-tool-chip {
  width: auto;
  min-width: 48px;
  padding: 0 10px;
  border-radius: 999px;
  gap: 4px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
}

.hw-chip-main {
  color: var(--primary-color, #2f6b2f);
}

.hw-chip-sub {
  min-width: 1em;
  color: var(--text-muted, #5f7660);
}

.hw-size-popover {
  position: absolute;
  right: 54px;
  bottom: calc(100% + 10px);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border: 1px solid rgba(47, 107, 47, 0.18);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(14px);
  touch-action: none;
}

.hw-size-popover[hidden] {
  display: none !important;
}

.hw-width-popover {
  right: 8px;
}

.hw-step-btn {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(47, 107, 47, 0.1);
  color: var(--primary-color, #2f6b2f);
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.hw-size-input {
  width: 58px;
  height: 30px;
  border: 1px solid rgba(47, 107, 47, 0.22);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text-main, #263824);
  font: 700 0.85rem/1.1 inherit;
  text-align: center;
  outline: none;
  cursor: ns-resize;
}

@media (max-width: 768px) {
  .hw-size-popover {
    right: auto;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
  }

  .hw-width-popover {
    right: auto;
  }
}

.hw-unit {
  padding-right: 2px;
  color: var(--text-muted, #5f7660);
  font-size: 0.74rem;
  font-weight: 700;
}

body.dark-theme .hw-size-popover {
  border-color: rgba(199, 241, 194, 0.18);
  background: rgba(30, 41, 59, 0.98);
}

body.dark-theme .hw-size-input {
  border-color: rgba(199, 241, 194, 0.22);
  background: rgba(15, 23, 42, 0.9);
  color: #e2e8f0;
}

.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;
}

/* Mindmap fullscreen is a true viewport overlay, independent from page zoom. */
body.fullscreen-mode-active {
  width: 100vw !important;
  min-width: 100vw !important;
  max-width: 100vw !important;
  height: 100dvh !important;
  min-height: 100dvh !important;
  overflow: hidden !important;
  background: var(--bg-color) !important;
}

@supports (zoom: 1) {
  body.fullscreen-mode-active {
    zoom: 1 !important;
  }
}

body.fullscreen-mode-active .app-container,
body.fullscreen-mode-active .main-content {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  min-width: 100vw !important;
  max-width: 100vw !important;
  height: 100dvh !important;
  min-height: 100dvh !important;
  overflow: hidden !important;
  background: var(--bg-color) !important;
  isolation: isolate;
}

body.fullscreen-mode-active .top-bar,
body.fullscreen-mode-active .glow-container,
body.fullscreen-mode-active #feedback-trigger-btn,
body.fullscreen-mode-active .homepage-announcement-banner,
body.fullscreen-mode-active .study-pull-square-hit-zone,
body.fullscreen-mode-active #pwa-status {
  display: none !important;
}

body.fullscreen-mode-active .single-mode-container {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100dvh !important;
  padding: 0 !important;
  overflow: hidden !important;
  background: var(--bg-color) !important;
}

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

body.fullscreen-mode-active #mindmap-iframe {
  position: relative !important;
  z-index: 1 !important;
  width: 100vw !important;
  height: 100dvh !important;
  border: 0 !important;
}

body.fullscreen-mode-active .mindmap-actions {
  position: fixed !important;
  bottom: 18px !important;
  right: 18px !important;
  top: auto !important;
  background: rgba(255, 255, 255, 0.94) !important;
  backdrop-filter: blur(14px) !important;
  border: 1px solid rgba(47, 107, 47, 0.18) !important;
  border-radius: 24px !important;
  padding: 6px 8px !important;
  z-index: 10000070 !important;
}

body.fullscreen-mode-active .mindmap-version-toggle {
  top: calc(64px + env(safe-area-inset-top)) !important;
  right: calc(12px + env(safe-area-inset-right)) !important;
  z-index: 10000070 !important;
  pointer-events: auto !important;
  transform: translateZ(0);
}

body.fullscreen-mode-active .mindmap-actions .btn {
  color: var(--text-main, #263824) !important;
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
}

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

body.fullscreen-mode-active .mindmap-handwriting-toolbar {
  position: fixed !important;
  left: 50% !important;
  right: auto !important;
  bottom: 76px !important;
  transform: translateX(-50%) !important;
  max-width: calc(100vw - 20px) !important;
  overflow-x: auto !important;
  scrollbar-width: none !important;
}

body.fullscreen-mode-active .mindmap-handwriting-toolbar.is-user-positioned {
  left: var(--hw-toolbar-left, 50%) !important;
  top: var(--hw-toolbar-top, 72px) !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
}

body.fullscreen-mode-active .mindmap-handwriting-toolbar::-webkit-scrollbar {
  display: none;
}

@media (max-width: 768px) {
  .mindmap-version-toggle {
    top: 10px;
    right: 10px;
    padding: 3px;
  }

  .mindmap-version-btn {
    min-width: 30px;
    height: 26px;
    padding: 0 8px;
    font-size: 0.74rem;
  }

  .mindmap-actions {
    right: 10px;
    bottom: 10px;
    max-width: calc(100vw - 20px);
    gap: 6px;
    padding: 6px 8px;
    border-radius: 20px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .mindmap-actions .btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
  }

  .mindmap-actions .btn svg {
    width: 18px !important;
    height: 18px !important;
  }

  body.fullscreen-mode-active .mindmap-actions {
    right: 10px !important;
    bottom: calc(10px + env(safe-area-inset-bottom)) !important;
    max-width: calc(100vw - 20px) !important;
    padding: 5px 6px !important;
  }

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

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

  body.fullscreen-mode-active .mindmap-handwriting-toolbar {
    bottom: calc(70px + env(safe-area-inset-bottom)) !important;
    max-width: calc(100vw - 16px) !important;
    padding-inline: 6px !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: flex !important;
  gap: 4px !important;
  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 {
  flex: 1 1 0% !important;
  min-width: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 28px !important;
  gap: 3px !important;
  padding: 4px 4px !important;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}

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

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

.flashcards-active-area.is-inline-editing .card-scene {
  width: min(100%, 820px);
}

.flashcards-active-area.is-inline-editing .flashcard {
  height: 100% !important;
  min-height: 0 !important;
  cursor: text !important;
}

.flashcards-active-area.is-inline-editing .card-face {
  height: 100% !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
}

.flashcards-active-area.is-inline-editing .card-face.card-back {
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
  padding-bottom: calc(24px + env(safe-area-inset-bottom)) !important;
}

.flashcards-active-area.is-inline-editing .card-question-text[contenteditable="true"],
.flashcards-active-area.is-inline-editing .card-answer-text-container {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: 100% !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
}

.flashcards-active-area.is-inline-editing .tap-hint,
.flashcards-active-area.is-inline-editing .floating-nav-btn {
  display: none !important;
}

.card-question-text[contenteditable="true"],
.card-answer-text[contenteditable="true"] {
  outline: 2px dashed color-mix(in srgb, var(--primary-color) 42%, transparent);
  outline-offset: 4px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary-light) 20%, transparent);
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: none;
  touch-action: pan-y !important;
  flex: 1 1 auto !important;
  min-height: calc(100% - 12px) !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

.flashcards-active-area.is-inline-editing .flashcard-inline-toolbar,
.flashcards-active-area.is-inline-editing .card-source-badge,
.flashcards-active-area.is-inline-editing .tap-hint {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.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: 32px;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid color-mix(in srgb, var(--primary-color) 34%, var(--border-color));
  border-radius: 9px;
  background: color-mix(in srgb, var(--primary-light) 76%, #ffffff 24%);
  color: var(--primary-color);
  font-size: 0.81rem;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(31, 54, 38, 0.06);
}

.mastery-bank-btn i,
.mastery-bank-btn svg {
  width: 15px;
  height: 15px;
  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;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-inline: 54px;
  box-sizing: border-box;
}

.floating-nav-btn {
  position: absolute;
  top: 50%;
  z-index: 8;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(45, 90, 39, 0.42);
  box-shadow: none;
  transform: translateY(-50%);
  cursor: pointer;
}

.floating-nav-btn:hover,
.floating-nav-btn:focus-visible {
  background: transparent;
  color: rgba(45, 90, 39, 0.68);
}

.floating-nav-symbol {
  display: block;
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1;
}

body.dark-theme .floating-nav-btn {
  color: rgba(217, 249, 157, 0.5);
}

body.dark-theme .floating-nav-btn:hover,
body.dark-theme .floating-nav-btn:focus-visible {
  background: transparent;
  color: rgba(217, 249, 157, 0.76);
}

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

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

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

.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 {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.flashcard-editor-actions {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 1000005;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  width: max-content;
  max-width: calc(100vw - 28px);
  padding: 4px;
  border: 1px solid color-mix(in srgb, var(--primary-color) 14%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel-bg) 66%, transparent);
  box-shadow: 0 6px 18px rgba(31, 54, 38, 0.10);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transform: translateX(-50%);
  box-sizing: border-box;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.flashcard-editor-actions.is-dragging {
  cursor: grabbing;
}

.flashcard-editor-actions .btn {
  flex: 0 1 auto;
  width: auto;
  min-width: 74px;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 9px;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

.flashcard-editor-actions .flashcard-image-action-btn {
  min-width: 88px;
}

.flashcards-active-area.is-inline-editing,
.flashcards-active-area.is-csv-editing {
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}

.flashcard-edit-action-btn {
  flex: 1 1 0;
  min-height: 42px;
  border-radius: 14px;
  gap: 6px;
  font-weight: 760;
}

.flashcard-edit-action-btn svg,
.flashcard-edit-action-btn i {
  width: 18px;
  height: 18px;
}

.flashcard-save-action-btn {
  flex-basis: 1.25fr;
}

.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 {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 42px;
  min-width: 42px;
  min-height: 40px;
  border-radius: 12px;
  padding: 0 !important;
}

.card-quick-controls .flashcard-reset-btn {
  color: #b42318;
}

body.dark-theme .card-quick-controls .flashcard-reset-btn {
  color: #fca5a5;
}

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

.flashcard-icon-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 4;
  min-width: max-content;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(31, 54, 38, 0.92);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 720;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  box-shadow: 0 8px 18px rgba(31, 54, 38, 0.18);
}

.flashcard-icon-btn[data-tip]:hover::after,
.flashcard-icon-btn[data-tip]:focus-visible::after,
.flashcard-icon-btn[data-tip]:active::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.card-quick-controls .flashcard-master-btn {
  color: #fff;
  background: linear-gradient(135deg, var(--primary-color), color-mix(in srgb, var(--primary-color) 72%, #10b981 28%));
  box-shadow: 0 6px 16px color-mix(in srgb, var(--primary-color) 24%, transparent);
}

.card-quick-controls .flashcard-master-btn:hover,
.card-quick-controls .flashcard-master-btn:focus-visible {
  filter: brightness(0.98);
  transform: translateY(-1px);
}

.card-quick-controls .flashcard-master-btn svg {
  width: 21px;
  height: 21px;
  stroke-width: 2.4;
}

.card-quick-controls .card-immersive-full-btn {
  width: 42px;
  min-width: 42px;
  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%);
}

.flashcard-inline-toolbar {
  position: fixed;
  z-index: 1000001;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 7px 8px;
  border: 1px solid color-mix(in srgb, var(--primary-color) 24%, var(--border-color));
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 30px rgba(31, 54, 38, 0.16);
  backdrop-filter: blur(12px);
}

.flashcard-inline-toolbar.is-visible {
  display: inline-flex;
}

.flashcard-inline-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-color);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.flashcard-inline-toolbar button:hover,
.flashcard-inline-toolbar button:focus-visible {
  filter: brightness(0.96);
  transform: translateY(-1px);
}

.flashcard-inline-toolbar button span {
  display: block;
  width: 15px;
  height: 15px;
  border-radius: 999px;
}

@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;
  }
}

/* Modern unified sidebar typography */
.logo-text .app-brand-title {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 6px;
  line-height: 1.2;
}

.logo-text .app-brand-title span:first-child {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.2px;
}

.logo-text .app-brand-title span:last-child {
  margin-top: 0;
  color: var(--primary-color);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.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 {
  display: flex !important;
  gap: 4px !important;
  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-btn {
  flex: 1 1 0% !important;
  min-width: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 28px !important;
  gap: 3px !important;
  padding: 4px 4px !important;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}

.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.82em;
}

.card-answer-text .answer-paragraph-level-1 {
  margin-top: 1.05em;
  padding-left: 34px;
}

.card-answer-text .answer-paragraph-level-1:first-child {
  margin-top: 0;
}

.card-answer-text .answer-paragraph-level-2 {
  margin-left: 16px;
  padding-left: 32px;
  border-left: 2px solid color-mix(in srgb, var(--primary-color) 22%, transparent);
}

.card-answer-text .answer-paragraph-level-3 {
  margin-left: 30px;
  padding-left: 30px;
  border-left: 1px dashed color-mix(in srgb, var(--text-muted) 28%, transparent);
}

.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: auto;
  padding: 0;
  border-radius: 0;
  background: transparent !important;
  color: #ea580c;
  font-size: 0.82rem;
  font-weight: 820;
  line-height: inherit;
  font-variant-numeric: tabular-nums;
}

.card-answer-text .answer-inline-marker-level-2 {
  min-width: 22px;
  height: auto;
  background: transparent !important;
  color: var(--primary-color);
  font-size: 0.78rem;
}

.card-answer-text .answer-inline-marker-level-3 {
  min-width: 20px;
  height: auto;
  background: transparent !important;
  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: transparent !important;
  color: #fed7aa;
}

body.dark-theme .card-answer-text .answer-inline-marker-level-2 {
  background: transparent !important;
  color: #bbf7d0;
}

body.dark-theme .card-answer-text .answer-inline-marker-level-3 {
  background: transparent !important;
  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 {
  flex: 1 1 0% !important;
  min-width: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 28px !important;
  gap: 3px !important;
  padding: 4px 4px !important;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}

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

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

  .card-answer-text .material-point-level-2,
  .card-answer-text li.answer-list-level-2:not(.answer-example),
  .card-answer-text .question-book-answer-list > li.answer-list-level-2,
  .card-answer-text .question-book-answer-list > li[data-answer-level="2"] {
    margin-left: 0.82em;
    padding-left: 0.65em;
    border-left: 0 !important;
  }

  .card-answer-text .material-point-level-3,
  .card-answer-text li.answer-list-level-3:not(.answer-example),
  .card-answer-text .question-book-answer-list > li.answer-list-level-3,
  .card-answer-text .question-book-answer-list > li[data-answer-level="3"] {
    margin-left: 1.45em;
    padding-left: 0.6em;
    border-left: 0 !important;
  }
}

/* v138: mobile flashcard, mindmap toolbar, and floating control polish */
@media (max-width: 768px) {
  body.flashcard-page .single-mode-container {
    width: 100%;
    max-width: none;
  }

  body.flashcard-page .flashcards-container {
    width: 100%;
    max-width: none;
    padding: 6px max(2px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(2px, env(safe-area-inset-left));
    overflow-x: hidden;
    gap: 6px;
  }

  body.flashcard-page .flashcards-active-area {
    width: 100%;
    max-width: none;
    gap: 8px;
  }

  body.flashcard-page .card-scene-wrapper {
    width: 100%;
    padding-inline: 2px !important;
    overflow: visible;
  }

  body.flashcard-page .card-scene {
    width: min(100%, calc(100vw - 4px));
    max-width: none;
    max-height: none;
    min-height: clamp(500px, calc(100dvh - 138px), 820px);
    height: clamp(500px, calc(100dvh - 138px), 820px);
  }

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

  body.flashcard-page .card-answer-text-container,
  body.flashcard-page .card-question-text,
  body.flashcard-page .card-answer-text {
    max-width: none;
  }

  body.flashcard-page .card-bottom-controls {
    min-height: 42px;
    margin-top: 4px;
    padding-bottom: max(2px, env(safe-area-inset-bottom));
  }

  body.flashcard-page .card-quick-controls {
    gap: 5px;
    padding: 3px;
    border-radius: 14px;
  }

  body.flashcard-page .card-quick-controls .btn {
    width: 42px;
    min-width: 42px;
    min-height: 38px;
  }

  body.flashcard-page .card-quick-controls .card-immersive-full-btn {
    width: 42px;
    min-width: 42px;
  }

  body.flashcard-page .floating-nav-prev { left: -2px; }
  body.flashcard-page .floating-nav-next { right: -2px; }

  body.flashcard-page .floating-nav-btn {
    width: 36px;
    height: 36px;
  }

  body.flashcard-page .floating-nav-symbol {
    font-size: 1.55rem;
  }

  body.flashcard-immersive .flashcards-container {
    padding: max(4px, env(safe-area-inset-top)) max(2px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(2px, env(safe-area-inset-left)) !important;
    align-items: stretch;
  }

  body.flashcard-immersive .flashcards-active-area {
    width: 100%;
    max-width: none;
    margin-inline: 0;
  }

  body.flashcard-immersive .card-scene-wrapper {
    padding-inline: 0 !important;
  }

  body.flashcard-immersive .card-scene {
    width: calc(100vw - 4px);
    max-width: none;
    max-height: none;
  }

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

  .mindmap-actions {
    position: fixed !important;
    left: max(10px, env(safe-area-inset-left)) !important;
    right: max(10px, env(safe-area-inset-right)) !important;
    bottom: calc(10px + env(safe-area-inset-bottom)) !important;
    top: auto !important;
    width: auto !important;
    max-width: none !important;
    box-sizing: border-box !important;
    min-height: 0 !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    gap: 6px !important;
    padding: 6px 8px !important;
    border-radius: 999px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    scroll-snap-type: x proximity;
  }

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

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

  .mindmap-actions.actions-collapsed {
    position: fixed !important;
    left: auto !important;
    right: max(10px, env(safe-area-inset-right)) !important;
    bottom: calc(10px + env(safe-area-inset-bottom)) !important;
    width: auto !important;
    min-width: 48px !important;
    max-width: none !important;
    justify-content: center !important;
    padding: 4px !important;
    border-radius: 999px !important;
    background: rgba(255, 255, 255, 0.92) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15) !important;
    margin-left: auto !important;
    overflow: visible !important;
    touch-action: manipulation;
  }

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

  .mindmap-actions .btn,
  body.fullscreen-mode-active .mindmap-actions .btn {
    flex: 0 0 auto;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    padding: 0 !important;
    color: var(--text-main, #263824) !important;
    scroll-snap-align: center;
  }

  .mindmap-actions .btn svg,
  body.fullscreen-mode-active .mindmap-actions .btn svg {
    width: 18px !important;
    height: 18px !important;
    stroke-width: 2.15px !important;
  }

  body.fullscreen-mode-active .mindmap-actions {
    position: fixed !important;
    left: max(10px, env(safe-area-inset-left)) !important;
    right: max(10px, env(safe-area-inset-right)) !important;
    bottom: calc(10px + env(safe-area-inset-bottom)) !important;
    width: calc(100vw - max(10px, env(safe-area-inset-left)) - max(10px, env(safe-area-inset-right))) !important;
    max-width: calc(100vw - max(10px, env(safe-area-inset-left)) - max(10px, env(safe-area-inset-right))) !important;
    background: rgba(255, 255, 255, 0.9) !important;
    border-color: rgba(47, 107, 47, 0.16) !important;
  }

  body.fullscreen-mode-active .mindmap-actions.actions-collapsed {
    left: auto !important;
    right: max(10px, env(safe-area-inset-right)) !important;
    width: auto !important;
    min-width: 42px !important;
    max-width: none !important;
    justify-content: center !important;
    padding: 4px !important;
    overflow: visible !important;
  }

  body.dark-theme.fullscreen-mode-active .mindmap-actions {
    background: rgba(30, 41, 59, 0.9) !important;
  }

  body.dark-theme .mindmap-actions .btn,
  body.dark-theme.fullscreen-mode-active .mindmap-actions .btn {
    color: #e2e8f0 !important;
  }
}

@media (min-width: 769px) {
  .sidebar-toggle-trigger {
    right: -14px;
    width: 28px;
    height: 44px;
    border-left: 1px solid rgba(47, 107, 47, 0.08);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--primary-color);
    box-shadow: 0 8px 24px rgba(31, 54, 38, 0.1);
    backdrop-filter: blur(12px);
  }

  .sidebar-toggle-trigger:hover {
    background: rgba(232, 245, 233, 0.88);
    box-shadow: 0 10px 26px rgba(31, 54, 38, 0.16);
  }

  .sidebar-toggle-trigger svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.2;
  }

  body.dark-theme .sidebar-toggle-trigger {
    background: rgba(30, 41, 32, 0.78);
    border-left: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--accent-color);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  }

  body.dark-theme .sidebar-toggle-trigger:hover {
    background: rgba(43, 62, 45, 0.92);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
    color: #fff;
  }
}

/* Mobile sidebar entry button (#menu-btn) must be visible on mobile screen (max-width: 768px) */
@media (max-width: 768px) {
  .sidebar-toggle-trigger {
    display: none !important;
  }

  body.fullscreen-mode-active .sidebar-toggle-trigger,
  body.flashcard-immersive .sidebar-toggle-trigger {
    display: flex !important;
  }

  #menu-btn,
  #exam-menu-btn,
  #open-prescription-sidebar,
  #open-excipient-sidebar {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: center !important;
    justify-content: center !important;
    grid-column: 1 !important;
    grid-row: 1 !important;
    position: relative !important;
    z-index: 30 !important;
    flex: 0 0 36px !important;
    flex-shrink: 0 !important;
    width: 36px !important;
    min-width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    border-radius: 8px !important;
    background: var(--bg-card, rgba(255, 255, 255, 0.85)) !important;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.12)) !important;
    color: var(--primary-color, #2b6cb0) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  }
}

@media (min-width: 769px) {
  #menu-btn,
  #exam-menu-btn,
  #open-prescription-sidebar,
  #open-excipient-sidebar {
    display: none !important;
  }
}

/* v200: enlarge flashcards slightly on desktop and tablet without touching phone layout. */
@media (min-width: 769px) {
  body.flashcard-page .flashcards-container {
    padding: 22px 24px 28px;
  }

  body.flashcard-page .flashcards-active-area {
    max-width: 1040px;
    gap: 14px;
  }

  body.flashcard-page .card-scene {
    width: min(100%, 900px);
    min-height: clamp(600px, calc(100dvh - 190px), 700px);
    height: clamp(600px, calc(100dvh - 190px), 700px);
    max-height: 700px;
  }

  body.flashcard-page .card-face {
    padding: 30px 34px;
  }

  body.flashcard-page .card-question-text {
    font-size: clamp(1.32rem, 1.8vw, 1.72rem);
  }

  body.flashcard-page .card-answer-text {
    font-size: 1.03rem;
  }
}

@media (min-width: 769px) and (max-width: 1180px) {
  body.flashcard-page .flashcards-container {
    padding: 14px 18px 20px;
  }

  body.flashcard-page .flashcards-active-area {
    max-width: min(100%, 940px);
  }

  body.flashcard-page .card-scene {
    width: min(100%, 860px);
    min-height: clamp(560px, calc(100dvh - 150px), 680px);
    height: clamp(560px, calc(100dvh - 150px), 680px);
    max-height: 680px;
  }

  body.flashcard-page .card-face {
    padding: 24px 30px;
  }
}

/* v199: glass navigation and mindmap controls polish. */
.top-bar {
  background: rgba(250, 252, 249, 0.72) !important;
  border-bottom: 1px solid rgba(47, 107, 47, 0.12) !important;
  box-shadow: 0 10px 30px rgba(31, 54, 38, 0.08), inset 0 -1px 0 rgba(255, 255, 255, 0.62) !important;
  backdrop-filter: blur(18px) saturate(1.35) !important;
  -webkit-backdrop-filter: blur(18px) saturate(1.35) !important;
}

body.dark-theme .top-bar {
  background: rgba(17, 24, 39, 0.7) !important;
  border-bottom-color: rgba(199, 241, 194, 0.14) !important;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28), inset 0 -1px 0 rgba(255, 255, 255, 0.08) !important;
}

.top-mode-tabs {
  gap: 5px !important;
  padding: 4px 6px !important;
  border: 1px solid rgba(47, 107, 47, 0.14) !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.58) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78), 0 8px 24px rgba(31, 54, 38, 0.08) !important;
  backdrop-filter: blur(16px) saturate(1.25) !important;
  -webkit-backdrop-filter: blur(16px) saturate(1.25) !important;
  height: 100% !important;
  min-height: 100% !important;
  max-height: 100% !important;
  align-self: stretch !important;
  box-sizing: border-box !important;
}

body.dark-theme .top-mode-tabs {
  border-color: rgba(199, 241, 194, 0.16) !important;
  background: rgba(15, 23, 42, 0.58) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 10px 26px rgba(0, 0, 0, 0.22) !important;
}

.top-mode-tab {
  height: 100% !important;
  min-height: 100% !important;
  padding: 0 14px !important;
  font-size: 0.92rem !important;
  font-weight: 750 !important;
  gap: 6px !important;
  border: 0 !important;
  border-radius: 999px !important;
  color: rgba(38, 56, 36, 0.72) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease !important;
}

.top-mode-tab svg,
.top-mode-tab i {
  width: 19px !important;
  height: 19px !important;
  stroke-width: 2.2px !important;
}

.top-mode-tab:hover,
.top-mode-tab:focus-visible {
  background: rgba(232, 245, 233, 0.72) !important;
  color: var(--primary-color, #2f6b2f) !important;
  transform: translateY(-1px);
}

.top-mode-tab.is-active {
  background: rgba(232, 245, 233, 0.9) !important;
  color: var(--primary-color, #2f6b2f) !important;
  box-shadow: inset 0 0 0 1px rgba(47, 107, 47, 0.16), 0 5px 14px rgba(47, 107, 47, 0.12) !important;
}

body.dark-theme .top-mode-tab {
  color: rgba(226, 232, 240, 0.72) !important;
}

body.dark-theme .top-mode-tab:hover,
body.dark-theme .top-mode-tab:focus-visible,
body.dark-theme .top-mode-tab.is-active {
  background: rgba(56, 74, 54, 0.72) !important;
  color: #c7f1c2 !important;
}

.toggle-btn {
  border: 1px solid rgba(47, 107, 47, 0.12) !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.58) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72), 0 8px 20px rgba(31, 54, 38, 0.08) !important;
  backdrop-filter: blur(14px) saturate(1.25) !important;
  -webkit-backdrop-filter: blur(14px) saturate(1.25) !important;
}

.toggle-btn:hover {
  background: rgba(232, 245, 233, 0.82) !important;
  color: var(--primary-color, #2f6b2f) !important;
}

body.dark-theme .toggle-btn {
  border-color: rgba(199, 241, 194, 0.14) !important;
  background: rgba(15, 23, 42, 0.58) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 10px 22px rgba(0, 0, 0, 0.24) !important;
}

.mindmap-actions,
.mindmap-handwriting-toolbar {
  border: 1px solid rgba(47, 107, 47, 0.14) !important;
  background: rgba(255, 255, 255, 0.62) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 12px 34px rgba(31, 54, 38, 0.14) !important;
  backdrop-filter: blur(18px) saturate(1.35) !important;
  -webkit-backdrop-filter: blur(18px) saturate(1.35) !important;
}

.mindmap-actions .btn,
.mindmap-handwriting-toolbar .hw-tool-btn {
  background: rgba(255, 255, 255, 0.18) !important;
  border-radius: 999px !important;
}

.mindmap-actions .btn:hover,
.mindmap-handwriting-toolbar .hw-tool-btn:hover {
  background: rgba(232, 245, 233, 0.84) !important;
}

.mindmap-handwriting-toolbar .hw-tool-btn.is-active {
  background: rgba(47, 107, 47, 0.26) !important;
  box-shadow: inset 0 0 0 1.5px rgba(47, 107, 47, 0.55), 0 2px 6px rgba(47, 107, 47, 0.22) !important;
  transform: translateY(-1px) scale(1.06) !important;
  color: var(--primary-color, #2f6b2f) !important;
}

.mindmap-handwriting-toolbar #hw-eraser-btn.is-active {
  background: rgba(239, 68, 68, 0.22) !important;
  box-shadow: inset 0 0 0 1.5px rgba(239, 68, 68, 0.65), 0 2px 6px rgba(239, 68, 68, 0.25) !important;
  color: #dc2626 !important;
  transform: translateY(-1px) scale(1.08) !important;
}

.mindmap-handwriting-toolbar #hw-move-btn.is-active {
  background: rgba(37, 99, 235, 0.22) !important;
  box-shadow: inset 0 0 0 1.5px rgba(37, 99, 235, 0.65), 0 2px 6px rgba(37, 99, 235, 0.25) !important;
  color: #2563eb !important;
  transform: translateY(-1px) scale(1.08) !important;
}

.mindmap-handwriting-toolbar #hw-finger-btn.is-active {
  background: rgba(16, 185, 129, 0.24) !important;
  box-shadow: inset 0 0 0 1.5px rgba(16, 185, 129, 0.65), 0 2px 6px rgba(16, 185, 129, 0.25) !important;
  color: #059669 !important;
}

.mindmap-handwriting-toolbar #hw-finger-btn.is-active .hw-chip-main,
.mindmap-handwriting-toolbar #hw-finger-btn.is-active .hw-chip-sub {
  color: #059669 !important;
}

body.dark-theme .mindmap-handwriting-toolbar .hw-tool-btn.is-active {
  background: rgba(199, 241, 194, 0.24) !important;
  box-shadow: inset 0 0 0 1.5px rgba(199, 241, 194, 0.55), 0 2px 6px rgba(0, 0, 0, 0.4) !important;
  color: #86efac !important;
}

body.dark-theme .mindmap-handwriting-toolbar #hw-eraser-btn.is-active {
  background: rgba(239, 68, 68, 0.3) !important;
  box-shadow: inset 0 0 0 1.5px rgba(248, 113, 113, 0.65), 0 2px 6px rgba(0, 0, 0, 0.4) !important;
  color: #fca5a5 !important;
}

body.dark-theme .mindmap-handwriting-toolbar #hw-move-btn.is-active {
  background: rgba(59, 130, 246, 0.3) !important;
  box-shadow: inset 0 0 0 1.5px rgba(96, 165, 250, 0.65), 0 2px 6px rgba(0, 0, 0, 0.4) !important;
  color: #93c5fd !important;
}

body.dark-theme .mindmap-handwriting-toolbar #hw-finger-btn.is-active {
  background: rgba(16, 185, 129, 0.28) !important;
  box-shadow: inset 0 0 0 1.5px rgba(52, 211, 153, 0.65), 0 2px 6px rgba(0, 0, 0, 0.4) !important;
  color: #6ee7b7 !important;
}

body.dark-theme .mindmap-handwriting-toolbar #hw-finger-btn.is-active .hw-chip-main,
body.dark-theme .mindmap-handwriting-toolbar #hw-finger-btn.is-active .hw-chip-sub {
  color: #6ee7b7 !important;
}

.mindmap-actions.actions-collapsed {
  border-radius: 999px !important;
  padding: 5px !important;
}

body.dark-theme .mindmap-actions,
body.dark-theme .mindmap-handwriting-toolbar {
  border-color: rgba(199, 241, 194, 0.16) !important;
  background: rgba(15, 23, 42, 0.66) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 16px 38px rgba(0, 0, 0, 0.3) !important;
}

.pwa-status {
  border: 1px solid rgba(47, 107, 47, 0.12) !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.72) !important;
  box-shadow: 0 10px 30px rgba(31, 54, 38, 0.12) !important;
  backdrop-filter: blur(16px) saturate(1.25) !important;
  -webkit-backdrop-filter: blur(16px) saturate(1.25) !important;
}

body.dark-theme .pwa-status {
  background: rgba(15, 23, 42, 0.78) !important;
  border-color: rgba(199, 241, 194, 0.16) !important;
}

.study-pull-square-indicator {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  z-index: 10000060;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(47, 107, 47, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--primary-color, #2f6b2f);
  box-shadow: 0 12px 28px rgba(31, 54, 38, 0.14);
  font-size: 0.82rem;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, calc(-110% + var(--study-pull-distance, 0px) * 0.5)) scale(0.96);
  transition: opacity 0.14s ease, transform 0.14s ease, background 0.14s ease;
  backdrop-filter: blur(16px) saturate(1.25);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
}

.study-pull-square-indicator svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.4;
}

body.study-pull-square-active .study-pull-square-indicator {
  opacity: 1;
  transform: translate(-50%, min(56px, var(--study-pull-distance, 0px) * 0.5)) scale(1);
}

body.study-pull-square-ready .study-pull-square-indicator {
  background: rgba(232, 245, 233, 0.94);
  box-shadow: 0 16px 34px rgba(47, 107, 47, 0.18);
}

body.dark-theme .study-pull-square-indicator {
  border-color: rgba(199, 241, 194, 0.18);
  background: rgba(15, 23, 42, 0.82);
  color: #c7f1c2;
}

@media (max-width: 768px) {
  html,
  body,
  .app-container,
  .main-content {
    max-width: 100%;
    overflow-x: hidden;
  }

  .mindmap-actions {
    left: auto !important;
    right: max(10px, env(safe-area-inset-right)) !important;
    max-width: calc(100vw - 20px) !important;
    padding: 5px !important;
    border-radius: 999px !important;
    justify-content: center !important;
  }

  .mindmap-actions:not(.actions-collapsed) {
    left: max(10px, env(safe-area-inset-left)) !important;
    justify-content: flex-start !important;
    padding: 6px 8px !important;
  }

  .mindmap-actions.actions-collapsed {
    min-width: 46px !important;
    width: auto !important;
    overflow: visible !important;
  }

  .mindmap-actions .btn,
  body.fullscreen-mode-active .mindmap-actions .btn {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
  }

  .pwa-status[data-state="info"]:not([data-actionable="true"]) {
    display: none !important;
  }
}

body.flashcard-page .card-answer-text-container {
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.card-answer-empty {
  margin: 0;
  padding: 18px 16px;
  border: 1px dashed color-mix(in srgb, var(--danger-color) 36%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--danger-light) 64%, transparent);
  color: var(--danger-color);
  font-weight: 700;
  line-height: 1.7;
  text-align: left;
}

.card-quick-controls .flashcard-delete-btn {
  color: var(--danger-color);
  background: color-mix(in srgb, var(--danger-light) 78%, #ffffff 22%);
}

.card-quick-controls .flashcard-delete-btn:hover,
.card-quick-controls .flashcard-delete-btn:focus-visible {
  border-color: color-mix(in srgb, var(--danger-color) 42%, transparent);
  transform: translateY(-1px);
}

@media (max-width: 430px) {
  body.flashcard-page .card-quick-controls {
    width: fit-content;
    max-width: 100%;
    justify-content: center;
  }

  body.flashcard-page .card-quick-controls .btn {
    width: 40px !important;
    min-width: 40px !important;
  }
}

@media (max-width: 768px) {
  body.flashcard-page .pwa-status {
    bottom: calc(128px + env(safe-area-inset-bottom)) !important;
    max-width: min(330px, calc(100vw - 40px));
    padding: 7px 12px;
  }

  body.flashcard-page .pwa-status[data-actionable="true"] {
    max-width: min(360px, calc(100vw - 28px));
  }
}

/* v212: Anki-like review home and three-grade flashcard controls. */
.flashcard-review-dashboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: min(820px, 100%);
  margin: 0 auto 8px;
}

.review-dashboard-card {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--primary-color) 14%, var(--border-color));
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(31, 54, 38, 0.07);
}

.review-dashboard-card span {
  font-size: 0.76rem;
  font-weight: 820;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.review-dashboard-card strong {
  font-size: 1.35rem;
  line-height: 1.05;
  color: var(--primary-color);
}

.review-dashboard-card small {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.review-dashboard-card.is-active {
  border-color: color-mix(in srgb, var(--primary-color) 42%, var(--border-color));
  background: color-mix(in srgb, var(--primary-light) 72%, #fff 28%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary-color) 18%, transparent), 0 10px 24px rgba(47, 107, 47, 0.12);
}

.review-dashboard-card.is-empty {
  opacity: 0.62;
}

.card-bottom-controls {
  flex-direction: column;
  gap: 8px;
}

.card-review-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  width: min(420px, 100%);
  padding: 4px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--primary-light) 46%, rgba(255,255,255,0.8) 54%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.62), 0 8px 18px rgba(31, 54, 38, 0.08);
}

.review-rating-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text-main);
  background: rgba(255,255,255,0.72);
  font-weight: 850;
  cursor: pointer;
}

.review-rating-btn svg,
.review-rating-btn i {
  width: 17px;
  height: 17px;
}

.review-rating-again {
  color: var(--danger-color);
  background: color-mix(in srgb, var(--danger-light) 72%, #fff 28%);
}

.review-rating-hard {
  color: #9a5b00;
  background: color-mix(in srgb, #fff3cd 78%, #fff 22%);
}

.review-rating-good {
  color: #fff;
  background: linear-gradient(135deg, var(--primary-color), color-mix(in srgb, var(--primary-color) 70%, #10b981 30%));
}

.card-recitation-controls {
  display: flex;
  justify-content: center;
  width: min(420px, 100%);
}

.flashcard-recitation-btn {
  min-height: 42px;
  padding-inline: 22px;
  border-radius: 14px;
  font-weight: 850;
  box-shadow: 0 10px 24px rgba(47, 107, 47, 0.16);
}

.card-quick-controls .flashcard-recitation-btn {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 14px;
  box-shadow: none;
}

.flashcard-recitation-btn.is-added {
  color: var(--primary-color);
  background: color-mix(in srgb, var(--primary-light) 84%, #fff 16%);
  border-color: color-mix(in srgb, var(--primary-color) 34%, var(--border-color));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary-color) 12%, transparent);
}

.inline-confirm-popover {
  position: fixed;
  z-index: 1200;
  width: min(240px, calc(100vw - 20px));
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--danger-color) 24%, var(--border-color));
  border-radius: 12px;
  background: var(--panel-bg);
  color: var(--text-main);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
}

.inline-confirm-text {
  font-size: 0.82rem;
  line-height: 1.45;
  font-weight: 760;
}

.inline-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 9px;
}

.inline-confirm-actions button {
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--panel-bg);
  color: var(--text-main);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.inline-confirm-actions .inline-confirm-ok {
  border-color: color-mix(in srgb, var(--danger-color) 36%, transparent);
  background: color-mix(in srgb, var(--danger-light) 78%, #fff 22%);
  color: var(--danger-color);
}

body.dark-theme .review-dashboard-card,
body.dark-theme .card-review-controls,
body.dark-theme .review-rating-btn {
  background: rgba(15, 23, 42, 0.68);
}

@media (max-width: 768px) {
  body.flashcard-page .flashcard-review-dashboard {
    gap: 6px;
    margin: 6px auto 6px;
  }

  body.flashcard-page .review-dashboard-card {
    min-height: 62px;
    padding: 8px 7px;
    border-radius: 12px;
  }

  body.flashcard-page .review-dashboard-card strong {
    font-size: 1.12rem;
  }

  body.flashcard-page .review-dashboard-card small {
    display: none;
  }

  body.flashcard-page .card-scene {
    min-height: clamp(390px, calc(100dvh - 250px), 720px) !important;
    height: clamp(390px, calc(100dvh - 250px), 720px) !important;
  }

  body.flashcard-page .card-bottom-controls {
    gap: 6px;
  }

  body.flashcard-page .card-quick-controls {
    width: fit-content;
    max-width: 100%;
    justify-content: center;
  }

  body.flashcard-page .card-review-controls {
    width: min(100%, 330px);
  }

  body.flashcard-page .card-recitation-controls {
    width: min(100%, 300px);
  }

  body.flashcard-page .card-recitation-controls .flashcard-recitation-btn {
    width: 100%;
  }

  body.flashcard-page .review-rating-btn {
    min-height: 42px;
    font-size: 0.86rem;
  }
}

/* v221: tablet sidebar handle, centered flashcards, and stable theme controls. */
@media (min-width: 769px) {
  .sidebar.collapsed .sidebar-toggle-trigger {
    right: -29px !important;
  }
}

@media (min-width: 901px) and (max-width: 1180px) {
  body.flashcard-page .sidebar.collapsed {
    margin-left: -240px !important;
  }

  body.flashcard-page .sidebar.collapsed .sidebar-toggle-trigger {
    right: -29px !important;
  }
}

/* v238: compact tablet/mobile shell, stable top actions, and page zoom controls. */
:root {
  --study-sidebar-width: 292px;
  --study-sidebar-tablet-width: 246px;
  --study-topbar-height: 58px;
  --study-page-zoom: 1;
}

@supports (zoom: 1) {
  body {
    zoom: var(--study-page-zoom, 1);
    width: calc(100% / var(--study-page-zoom, 1));
    min-height: calc(100dvh / var(--study-page-zoom, 1));
  }
}

.study-page-zoom-card {
  display: grid;
  gap: 10px;
}

.study-page-zoom-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.study-page-zoom-head h4 {
  margin: 0;
}

.study-page-zoom-value {
  flex: 0 0 auto;
  color: var(--primary-color);
  font-size: 0.84rem;
  font-weight: 800;
}

.study-page-zoom-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 8px;
}

.study-page-zoom-btn {
  min-height: 36px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--panel-bg);
  color: var(--text-main);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
}

.study-page-zoom-btn.is-active {
  border-color: rgba(47, 107, 47, 0.28);
  background: var(--primary-light);
  color: var(--primary-color);
  box-shadow: inset 0 0 0 1px rgba(47, 107, 47, 0.16);
}

body.flashcard-page .mastery-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  width: min(560px, calc(100vw - 28px));
  max-height: calc(100dvh - 36px);
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  background: var(--panel-bg);
  box-shadow: 0 24px 70px rgba(31, 54, 38, 0.22);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.96);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

body.flashcard-page .mastery-modal.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

body.flashcard-page .mastery-modal[aria-hidden="true"]:not(.active) {
  display: none !important;
}

body.flashcard-page .mastery-modal .modal-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar {
  width: var(--study-sidebar-width) !important;
  flex-basis: var(--study-sidebar-width) !important;
}

@media (min-width: 769px) {
  .sidebar.collapsed {
    margin-left: calc(-1 * var(--study-sidebar-width)) !important;
  }
}

.single-mode-container {
  padding-top: 10px !important;
}

.mindmap-container {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

body.flashcard-page .flashcards-container {
  padding-top: 8px !important;
}

body.flashcard-page .card-answer-text-container,
body.flashcard-page .card-question-text {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(95, 116, 94, 0.35) transparent;
}

body.flashcard-page .card-answer-text-container::-webkit-scrollbar,
body.flashcard-page .card-question-text::-webkit-scrollbar {
  width: 8px;
}

body.flashcard-page .card-answer-text-container::-webkit-scrollbar-thumb,
body.flashcard-page .card-question-text::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(95, 116, 94, 0.35);
}

@media (min-width: 769px) and (max-width: 1180px) {
  :root {
    --study-sidebar-width: var(--study-sidebar-tablet-width);
    --study-topbar-height: 54px;
  }

  .sidebar {
    width: var(--study-sidebar-width) !important;
    flex: 0 0 var(--study-sidebar-width) !important;
  }

  .sidebar-header {
    min-height: 56px !important;
    padding: 10px 12px !important;
  }

  .logo-area {
    gap: 8px !important;
  }

  .logo-img {
    width: 32px !important;
    height: 32px !important;
  }

  .logo-text .app-brand-title {
    display: flex !important;
    flex-direction: row !important;
    align-items: baseline !important;
    gap: 5px !important;
    max-width: none !important;
  }

  .logo-text .app-brand-title span:first-child {
    font-size: 0.95rem !important;
  }

  .logo-text .app-brand-title span:last-child {
    margin-top: 0 !important;
    font-size: 0.64rem !important;
  }

  .study-navigation {
    padding: 5px 10px !important;
  }

  .study-navigation:has(+ .study-navigation) {
    padding-top: 5px !important;
    padding-bottom: 2px !important;
    border-bottom: none !important;
  }

  .study-navigation + .study-navigation {
    padding-top: 2px !important;
    padding-bottom: 5px !important;
  }

  .study-navigation-label,
  .list-title {
    display: none !important;
  }

  .subject-toggle-group {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 3px !important;
    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 {
    display: flex !important;
    gap: 4px !important;
    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);
  }

  .subject-toggle-btn {
    flex: none !important;
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 28px !important;
    gap: 3px !important;
    padding: 2px 3px !important;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 650;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.18s ease;
    user-select: none;
    box-sizing: border-box !important;
  }

  .subbook-toggle-btn {
    flex: 1 1 0% !important;
    min-width: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 28px !important;
    gap: 3px !important;
    padding: 4px 4px !important;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 650;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.18s ease;
    user-select: none;
  }

  .chapter-list-container {
    padding: 6px 10px 18px !important;
  }

  .chapter-item {
    margin-bottom: 3px !important;
    padding: 9px 10px !important;
    font-size: 0.82rem !important;
  }



  .single-mode-container {
    padding: 6px 10px 10px !important;
  }

  body.flashcard-page .flashcards-container {
    padding: 8px 12px 14px !important;
  }

  body.flashcard-page .card-scene-wrapper {
    padding-inline: 26px !important;
  }

  body.flashcard-page .card-scene {
    min-height: clamp(500px, calc(100dvh - 126px), 650px) !important;
    height: clamp(500px, calc(100dvh - 126px), 650px) !important;
  }
}





@media (max-width: 768px) {
  :root {
    --study-topbar-height: 54px;
  }

  .sidebar {
    width: min(86vw, 320px) !important;
    flex-basis: auto !important;
  }

  .sidebar-header {
    min-height: 54px !important;
    padding: calc(8px + env(safe-area-inset-top)) 10px 8px !important;
  }

  .logo-img {
    width: 30px !important;
    height: 30px !important;
  }

  .logo-text .app-brand-title span:first-child {
    font-size: 0.86rem !important;
  }

  .logo-text .app-brand-title span:last-child {
    font-size: 0.6rem !important;
  }



  .single-mode-container {
    padding: 4px 6px calc(6px + env(safe-area-inset-bottom)) !important;
  }

  body.flashcard-page .flashcards-container {
    padding: 5px 4px calc(8px + env(safe-area-inset-bottom)) !important;
  }

  body.flashcard-page .card-scene-wrapper {
    padding-inline: 2px !important;
  }
}

body.flashcard-page .visual-editor-rich-input,
body.flashcard-page .visual-editor-rich-paragraph,
body.flashcard-page #visual-editor-question,
body.flashcard-page #visual-editor-page,
body.flashcard-page #visual-editor-answer-text,
body.flashcard-page #flashcard-textarea,
body.flashcard-page .card-question-text[contenteditable="true"],
body.flashcard-page .card-answer-text[contenteditable="true"] {
  -webkit-touch-callout: none !important;
}

/* v239: corrected scope - card scrolling + stable theme/account actions, without changing module-tab density. */
body.flashcard-page .flashcards-container,
body.flashcard-page .flashcards-active-area {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

body.flashcard-page .card-scene-wrapper,
body.flashcard-page .card-scene,
body.flashcard-page .flashcard,
body.flashcard-page .card-face {
  min-height: 0;
}

body.flashcard-page .card-question-text,
body.flashcard-page .card-answer-text-container {
  max-height: 100%;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.top-bar .theme-btn,
.top-bar .settings-btn,
.top-bar .account-sync-btn,
.top-bar .account-profile-trigger {
  flex-shrink: 0 !important;
}

/* v241: page zoom uses reverse layout compensation, so scaled pages still fill the viewport. */
@supports (zoom: 1) {
  body {
    width: calc(100vw / var(--study-page-zoom, 1)) !important;
    min-width: calc(100vw / var(--study-page-zoom, 1)) !important;
    max-width: calc(100vw / var(--study-page-zoom, 1)) !important;
    min-height: calc(100dvh / var(--study-page-zoom, 1)) !important;
    overflow-x: hidden !important;
  }

  body .app-container {
    width: calc(100vw / var(--study-page-zoom, 1)) !important;
    max-width: calc(100vw / var(--study-page-zoom, 1)) !important;
    height: calc(100dvh / var(--study-page-zoom, 1)) !important;
    min-height: calc(100dvh / var(--study-page-zoom, 1)) !important;
  }

  body .main-content {
    min-height: calc(100dvh / var(--study-page-zoom, 1)) !important;
    max-width: none !important;
  }

  body .top-bar {
    width: 100% !important;
    max-width: 100% !important;
  }

  body .modal-backdrop {
    width: calc(100vw / var(--study-page-zoom, 1)) !important;
    height: calc(100dvh / var(--study-page-zoom, 1)) !important;
  }
}

/* v242: iOS/iPadOS does not handle body zoom consistently in Safari/PWA.
   Keep Android on zoom, but use a transformed app stage for Apple devices. */
@supports (zoom: 1) {
  html.apple-study-device,
  html.apple-study-device body {
    width: 100vw !important;
    min-width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    overflow: hidden !important;
  }

  html.apple-study-device body {
    zoom: 1 !important;
  }

  html.apple-study-device body .app-container {
    width: calc(100vw / var(--study-page-zoom, 1)) !important;
    max-width: calc(100vw / var(--study-page-zoom, 1)) !important;
    height: calc(100dvh / var(--study-page-zoom, 1)) !important;
    min-height: calc(100dvh / var(--study-page-zoom, 1)) !important;
    transform: scale(var(--study-page-zoom, 1));
    transform-origin: top left;
    overflow: hidden !important;
  }

  html.apple-study-device body .main-content {
    min-height: calc(100dvh / var(--study-page-zoom, 1)) !important;
  }

  html.apple-study-device body .top-bar {
    width: 100% !important;
    max-width: 100% !important;
  }

  html.apple-study-device body .modal-backdrop,
  html.apple-study-device body .account-sync-backdrop {
    width: 100vw !important;
    height: 100dvh !important;
  }
}

html.apple-study-device .sidebar {
  min-height: 0 !important;
  overflow: visible !important;
}

html.apple-study-device .chapter-list-container {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* iPad/WebKit viewport guard: keep fixed edge tools inside the real visible viewport at 70-100% page zoom. */
html.ipad-study-device {
  --ipad-visible-width: 100vw;
  --ipad-visible-height: 100dvh;
  --ipad-stage-width: calc(100vw / var(--study-page-zoom, 1));
  --ipad-stage-height: calc(100dvh / var(--study-page-zoom, 1));
  --ipad-stage-right-pad: max(12px, env(safe-area-inset-right));
  --ipad-stage-bottom-pad: max(12px, env(safe-area-inset-bottom));
}

@supports (zoom: 1) {
  html.ipad-study-device body .app-container {
    width: var(--ipad-stage-width) !important;
    max-width: var(--ipad-stage-width) !important;
    height: var(--ipad-stage-height) !important;
    min-height: var(--ipad-stage-height) !important;
  }

  html.ipad-study-device body .main-content {
    min-height: var(--ipad-stage-height) !important;
  }

  html.ipad-study-device body .top-bar {
    width: 100% !important;
    max-width: 100% !important;
    padding-right: calc(var(--ipad-stage-right-pad) + 8px) !important;
    box-sizing: border-box !important;
  }

  html.ipad-study-device body .top-bar-right {
    justify-self: end !important;
    flex-shrink: 0 !important;
    max-width: max-content !important;
    position: relative !important;
    z-index: 40 !important;
  }

  html.ipad-study-device body .mindmap-actions,
  html.ipad-study-device body.fullscreen-mode-active .mindmap-actions {
    right: var(--ipad-stage-right-pad) !important;
    bottom: var(--ipad-stage-bottom-pad) !important;
    max-width: min(560px, calc(var(--ipad-stage-width) - 24px)) !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
  }

  html.ipad-study-device body.fullscreen-mode-active .mindmap-handwriting-toolbar {
    bottom: calc(var(--ipad-stage-bottom-pad) + 58px) !important;
    max-width: calc(var(--ipad-stage-width) - 20px) !important;
  }

  html.ipad-study-device body.fullscreen-mode-active .sidebar,
  html.ipad-study-device body.flashcard-immersive .sidebar {
    width: min(calc(var(--ipad-stage-width) * 0.86), 320px) !important;
    height: var(--ipad-stage-height) !important;
    display: flex !important;
  }

  html.ipad-study-device body.fullscreen-mode-active .sidebar-toggle-trigger,
  html.ipad-study-device body.flashcard-immersive .sidebar-toggle-trigger {
    display: flex !important;
    right: -22px !important;
    z-index: 1000004 !important;
  }
}

@media (min-width: 769px) and (max-width: 1180px) {
  body.flashcard-page .flashcards-active-area {
    gap: 12px !important;
  }

  body.flashcard-page .card-scene {
    min-height: clamp(500px, calc(100dvh - 154px), 620px) !important;
    height: clamp(500px, calc(100dvh - 154px), 620px) !important;
  }

  body.flashcard-page .card-bottom-controls {
    flex: 0 0 auto !important;
    margin-top: 12px !important;
  }
}

body.discussion-page .top-bar,
body.announcement-page .top-bar {
  width: calc(100vw / var(--study-page-zoom, 1)) !important;
  max-width: calc(100vw / var(--study-page-zoom, 1)) !important;
}

@media (max-width: 768px) {
  body.flashcard-page .flashcards-active-area,
  body.flashcard-page .card-scene-wrapper,
  body.flashcard-page .card-scene,
  body.flashcard-page .flashcard,
  body.flashcard-page .card-face,
  body.flashcard-page .card-bottom-controls {
    max-width: 100% !important;
  }
}

/* Mobile flashcard shell: page scroll outside, card text scroll inside, no 3D mirroring on phones. */
@supports (zoom: 1) {
  html {
    min-height: 100dvh;
    background: var(--bg-color);
  }

  body {
    height: auto;
    background: var(--bg-color);
  }

  body.flashcard-page,
  body.mastery-page {
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }

  body.flashcard-page .app-container,
  body.mastery-page .app-container,
  body.flashcard-page .main-content,
  body.mastery-page .main-content {
    height: auto;
    min-height: calc(100dvh / var(--study-page-zoom, 1));
    overflow-x: hidden;
  }
}

body.flashcard-page .single-mode-container {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

body.flashcard-page .flashcards-container {
  flex: 0 0 auto;
  max-height: none;
  align-items: stretch;
  overflow: visible;
}

body.flashcard-page .flashcards-active-area {
  flex: 0 0 auto;
  height: auto;
  overflow: visible;
  gap: 16px;
  padding-bottom: calc(22px + env(safe-area-inset-bottom));
}

body.flashcard-page .card-scene-wrapper {
  flex: 0 0 auto;
  align-items: flex-start;
  overflow: visible;
}

body.flashcard-page .card-scene {
  flex: 0 0 auto;
  max-height: none;
}

body.flashcard-page .flashcard,
body.flashcard-page .card-face {
  min-height: 0;
}

body.flashcard-page .card-question-text,
body.flashcard-page .card-answer-text-container {
  flex: 1 1 0%;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

body.flashcard-page .card-question-text {
  align-items: flex-start;
  justify-content: flex-start;
}

/* Importance labels stay inline with the question instead of becoming a second flex item. */
body.flashcard-page .card-question-text {
  display: block !important;
  white-space: normal;
  overflow-wrap: break-word;
}

body.flashcard-page .card-question-text .card-question-importance-label {
  display: inline;
  vertical-align: baseline;
}

body.flashcard-page .card-question-text .card-question-inline-flow {
  display: inline;
  white-space: normal;
  overflow-wrap: anywhere;
}

body.flashcard-page .card-bottom-controls {
  position: relative;
  z-index: 3;
  flex: 0 0 auto;
  margin-top: 14px;
  transform: none;
}

.mastery-top-card-tools .settings-btn,
.mastery-top-card-tools .account-profile-trigger,
.mastery-top-card-tools .account-sync-btn {
  width: 38px !important;
  min-width: 38px !important;
  max-width: 38px !important;
  height: 38px !important;
  min-height: 38px !important;
  padding: 0 !important;
  border-radius: 12px !important;
}

.mastery-top-card-tools .account-profile-trigger > span:not(.account-sync-avatar),
.mastery-top-card-tools .account-sync-btn > span:not(.account-sync-avatar) {
  display: none !important;
}

@media (max-width: 768px) {
  body.flashcard-page .single-mode-container {
    min-height: calc(100dvh - var(--study-topbar-height, 62px));
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
    overflow-y: auto;
  }

  body.flashcard-page .flashcards-container {
    width: 100%;
    min-height: calc(100dvh - var(--study-topbar-height, 62px) - 10px);
    max-height: none;
    padding: 4px 2px calc(18px + env(safe-area-inset-bottom));
    overflow: visible;
  }

  body.flashcard-page .flashcards-active-area {
    width: 100%;
    max-width: none;
    min-height: 0;
    gap: 12px;
    overflow: visible;
  }

  body.flashcard-page .card-scene-wrapper {
    padding-inline: 0;
    align-items: stretch;
  }

  body.flashcard-page .card-scene {
    width: 100%;
    height: var(--flashcard-card-height, clamp(430px, calc(100dvh - 184px), 680px));
    min-height: var(--flashcard-card-height, clamp(430px, calc(100dvh - 184px), 680px));
    max-height: none;
    perspective: none;
  }

  body.flashcard-page .flashcard {
    transform: none;
    transform-style: flat;
  }

  body.flashcard-page .card-face {
    inset: 0;
    padding: 22px 18px;
    transform: none;
    backface-visibility: visible;
    transition: opacity 0.16s ease, visibility 0.16s ease;
  }

  body.flashcard-page .card-back {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  body.flashcard-page .flashcard.is-flipped .card-front {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  body.flashcard-page .flashcard.is-flipped .card-back {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  body.flashcard-page .card-question-text,
  body.flashcard-page .card-answer-text-container {
    max-height: 100%;
  }

  body.flashcard-page .card-bottom-controls {
    margin-top: 12px;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
  }

  body.flashcard-page .floating-nav-prev { left: -2px; }
  body.flashcard-page .floating-nav-next { right: -2px; }

  body.flashcard-page .flashcards-active-area.is-inline-editing .card-scene {
    height: var(--flashcard-card-height, clamp(430px, calc(100dvh - 184px), 680px));
    min-height: var(--flashcard-card-height, clamp(430px, calc(100dvh - 184px), 680px));
  }
}

/* Flashcard stage layout: the card owns the study area and controls sit below it. */
html.flashcard-shell-page {
  --flashcard-stage-gap: 2px;
  --flashcard-stage-pad-x: clamp(12px, 3vw, 36px);
  height: calc(100dvh / var(--study-page-zoom, 1)) !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

body.flashcard-page {
  height: calc(100dvh / var(--study-page-zoom, 1)) !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

body.flashcard-page .app-container,
body.flashcard-page .main-content {
  height: calc(100dvh / var(--study-page-zoom, 1)) !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

body.flashcard-page .single-mode-container {
  flex: 1 1 auto !important;
  display: flex !important;
  min-height: 0 !important;
  height: auto !important;
  padding: 5px var(--flashcard-stage-pad-x) 6px !important;
  overflow: hidden !important;
}

body.flashcard-page .flashcards-container {
  flex: 1 1 auto !important;
  align-items: center !important;
  justify-content: flex-start !important;
  width: 100% !important;
  min-height: 0 !important;
  height: 100% !important;
  max-height: none !important;
  padding: 0 !important;
  overflow: hidden !important;
}

body.flashcard-page .flashcards-active-area {
  flex: 1 1 auto !important;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  grid-template-rows: minmax(0, 1fr) auto !important;
  justify-items: center !important;
  align-items: stretch !important;
  width: min(100%, 1100px) !important;
  max-width: 1100px !important;
  height: 100% !important;
  min-height: 0 !important;
  gap: var(--flashcard-stage-gap) !important;
  padding: 0 !important;
  overflow: hidden !important;
}

body.flashcard-page .card-scene-wrapper {
  justify-self: center !important;
  width: min(100%, 1000px) !important;
  min-width: 0 !important;
  min-height: 0 !important;
  height: auto !important;
  align-self: stretch !important;
  display: flex !important;
  align-items: stretch !important;
  justify-content: center !important;
  padding-inline: clamp(34px, 5vw, 64px) !important;
  overflow: visible !important;
}

body.flashcard-page .card-scene {
  flex: 0 1 860px !important;
  align-self: stretch !important;
  width: min(100%, 860px) !important;
  min-width: 0 !important;
  height: var(--flashcard-card-height, 100%) !important;
  min-height: 0 !important;
  max-height: var(--flashcard-card-height, 100%) !important;
}

body.flashcard-page .flashcard,
body.flashcard-page .card-face {
  min-width: 0 !important;
  min-height: 0 !important;
}

body.flashcard-page .card-question-text,
body.flashcard-page .card-answer-text-container {
  flex: 1 1 0 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-height: 100% !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

body.flashcard-page .card-bottom-controls {
  justify-self: center !important;
  flex: 0 0 auto !important;
  width: min(100%, 520px) !important;
  min-height: 52px !important;
  margin-top: 0 !important;
  padding-bottom: max(4px, env(safe-area-inset-bottom)) !important;
  overflow: visible !important;
}

body.flashcard-page .card-quick-controls {
  gap: 8px !important;
  min-height: 48px !important;
  padding: 5px !important;
}

body.flashcard-page .card-quick-controls .btn {
  width: 44px !important;
  min-width: 44px !important;
  min-height: 42px !important;
}

body.flashcard-immersive .main-content,
body.flashcard-immersive .single-mode-container,
body.flashcard-immersive .flashcards-container {
  height: calc(100dvh / var(--study-page-zoom, 1)) !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

body.flashcard-immersive .single-mode-container,
body.flashcard-immersive .flashcards-container {
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)) !important;
}

body.flashcard-immersive .flashcards-active-area {
  width: min(100%, 1120px) !important;
  max-width: 1120px !important;
}

body.flashcard-immersive .card-scene-wrapper {
  width: min(100%, 1040px) !important;
}

@media (min-width: 769px) and (max-width: 1180px), (hover: none) and (pointer: coarse) and (min-width: 769px) {
  body.flashcard-page .single-mode-container {
    padding: 5px 18px 6px !important;
  }

  body.flashcard-page .flashcards-active-area {
    width: min(100%, 980px) !important;
    max-width: 980px !important;
    gap: 2px !important;
  }

  body.flashcard-page .card-scene-wrapper {
    width: min(100%, 920px) !important;
    padding-inline: clamp(38px, 6vw, 72px) !important;
  }

  body.flashcard-page .card-scene {
    flex-basis: 780px !important;
    width: min(100%, 780px) !important;
  }

  body.flashcard-page .card-face {
    padding: 22px 28px !important;
  }

  body.flashcard-page .card-face.card-back {
    padding: 12px 24px calc(8px + env(safe-area-inset-bottom)) !important;
  }
}

@media (max-width: 768px) {
  html.flashcard-shell-page {
    --flashcard-stage-gap: 2px;
    --flashcard-stage-pad-x: 8px;
  }

  body.flashcard-page .single-mode-container {
    min-height: 0 !important;
    height: auto !important;
    padding: 4px var(--flashcard-stage-pad-x) calc(6px + env(safe-area-inset-bottom)) !important;
  }

  body.flashcard-page .flashcards-active-area {
    width: 100% !important;
    max-width: none !important;
    gap: 2px !important;
  }

  body.flashcard-page .card-scene-wrapper {
    width: 100% !important;
    padding-inline: 2px !important;
  }

  body.flashcard-page .card-scene {
    flex-basis: 100% !important;
    width: 100% !important;
  }

  body.flashcard-page .card-face {
    padding: clamp(14px, 3.6vw, 20px) clamp(12px, 3.2vw, 18px) !important;
  }

  body.flashcard-page .card-face.card-back {
    padding: 10px clamp(12px, 3.2vw, 18px) calc(6px + env(safe-area-inset-bottom)) !important;
  }

  body.flashcard-page .card-bottom-controls {
    width: 100% !important;
    min-height: 46px !important;
    padding-bottom: max(2px, env(safe-area-inset-bottom)) !important;
  }

  body.flashcard-page .card-quick-controls {
    width: fit-content !important;
    max-width: min(100%, 360px) !important;
    justify-content: center !important;
    gap: 5px !important;
    min-height: 42px !important;
    padding: 3px !important;
  }

  body.flashcard-page .card-quick-controls .btn {
    width: 40px !important;
    min-width: 40px !important;
    min-height: 38px !important;
  }
}

@media (hover: hover) and (pointer: fine) and (min-width: 769px) {
  html.flashcard-shell-page:not(.touch-study-device):not(:has(body.flashcard-immersive)) {
    height: calc(100dvh / var(--study-page-zoom, 1)) !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  html:not(.touch-study-device) body.flashcard-page:not(.flashcard-immersive) {
    height: calc(100dvh / var(--study-page-zoom, 1)) !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  html:not(.touch-study-device) body.flashcard-page:not(.flashcard-immersive) .app-container,
  html:not(.touch-study-device) body.flashcard-page:not(.flashcard-immersive) .main-content {
    height: calc(100dvh / var(--study-page-zoom, 1)) !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  html:not(.touch-study-device) body.flashcard-page:not(.flashcard-immersive) .sidebar {
    height: 100% !important;
    min-height: 0 !important;
  }

  html:not(.touch-study-device) body.flashcard-page:not(.flashcard-immersive) .chapter-list-container {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
  }

  html:not(.touch-study-device) body.flashcard-page:not(.flashcard-immersive) .single-mode-container {
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 0 !important;
    padding: clamp(8px, 1.6dvh, 16px) var(--flashcard-stage-pad-x) clamp(12px, 1.8dvh, 18px) !important;
    overflow: hidden !important;
  }

  html:not(.touch-study-device) body.flashcard-page:not(.flashcard-immersive) .flashcards-container {
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  html:not(.touch-study-device) body.flashcard-page:not(.flashcard-immersive) .flashcards-active-area {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr) auto !important;
    justify-items: center !important;
    align-items: stretch !important;
    height: 100% !important;
    min-height: 0 !important;
    width: min(100%, 1100px) !important;
    max-width: 1100px !important;
    gap: var(--flashcard-stage-gap) !important;
    overflow: hidden !important;
  }

  html:not(.touch-study-device) body.flashcard-page:not(.flashcard-immersive) .card-scene-wrapper {
    justify-self: center !important;
    flex: 1 1 auto !important;
    width: min(100%, 1000px) !important;
    height: auto !important;
    min-height: 0 !important;
    align-self: stretch !important;
    display: flex !important;
    align-items: stretch !important;
    justify-content: center !important;
    overflow: visible !important;
  }

  html:not(.touch-study-device) body.flashcard-page:not(.flashcard-immersive) .card-scene {
    flex: 0 1 860px !important;
    align-self: stretch !important;
    width: min(100%, 860px) !important;
    min-width: 0 !important;
    height: var(--flashcard-card-height, 100%) !important;
    min-height: 0 !important;
    max-height: var(--flashcard-card-height, 100%) !important;
  }

  html:not(.touch-study-device) body.flashcard-page:not(.flashcard-immersive) .card-bottom-controls {
    justify-self: center !important;
    margin-top: 0 !important;
    padding-bottom: max(4px, env(safe-area-inset-bottom)) !important;
  }
}

/* v243: mastery has a 3-column top bar; keep theme + login/settings as one right-side group. */
@media (min-width: 769px) and (max-width: 1180px) {
  body.mastery-page .mastery-top-bar .top-bar-right {
    display: flex !important;
    grid-column: 3 !important;
    grid-row: 1 !important;
    justify-self: end !important;
    align-self: center !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 8px !important;
    min-width: 0 !important;
    width: max-content !important;
    max-width: max-content !important;
    position: relative !important;
    z-index: 4 !important;
  }

  body.mastery-page .mastery-top-bar .top-bar-right .theme-btn,
  body.mastery-page .mastery-top-bar .top-bar-right .settings-btn,
  body.mastery-page .mastery-top-bar .top-bar-right .account-sync-btn,
  body.mastery-page .mastery-top-bar .top-bar-right .account-profile-trigger {
    grid-column: auto !important;
    grid-row: auto !important;
    justify-self: auto !important;
    flex: 0 0 auto !important;
  }
}

.study-pull-square-hit-zone {
  display: none;
}

@media (hover: none), (pointer: coarse) {
  body:not(.mobile-sidebar-open) .top-bar {
    z-index: 260;
  }

  body:not(.fullscreen-mode-active):not(.flashcard-immersive):not(.flashcard-page):not(.mastery-page):not(.discussion-page):not(.announcement-page) .study-pull-square-hit-zone {
    display: block;
    position: fixed;
    top: var(--study-topbar-height, 58px);
    left: var(--study-sidebar-tablet-width, 246px);
    right: 0;
    height: max(72px, calc(20dvh - var(--study-topbar-height, 58px)));
    z-index: 40;
    background: transparent;
    touch-action: pan-y;
  }
}

@media (max-width: 768px) {
  body:not(.fullscreen-mode-active):not(.flashcard-immersive):not(.flashcard-page):not(.mastery-page):not(.discussion-page):not(.announcement-page) .study-pull-square-hit-zone {
    left: 0;
  }
}

/* Flashcard editing layout: match flippable card with full-height editor. */
body.flashcard-page .flashcards-active-area.is-inline-editing {
  overflow: visible !important;
  padding-bottom: calc(76px + env(safe-area-inset-bottom)) !important;
}

body.flashcard-page .flashcards-active-area.is-inline-editing .card-scene-wrapper {
  height: auto !important;
}

body.flashcard-page .flashcards-active-area.is-inline-editing .card-scene {
  flex: 0 0 auto !important;
}

body.flashcard-page .flashcards-active-area.is-inline-editing .card-answer-text-container {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
}

body.flashcard-page .flashcards-active-area.is-inline-editing .card-question-text[contenteditable="true"],
body.flashcard-page .flashcards-active-area.is-inline-editing .card-answer-text[contenteditable="true"] {
  max-height: none !important;
  flex: 1 1 auto !important;
  min-height: calc(100% - 12px) !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

/* v0.33: mobile sidebar entry is a plain three-line icon, not a framed button. */
@media (max-width: 768px) {
  .top-bar #menu-btn,
  .top-bar #exam-menu-btn,
  .top-bar #open-prescription-sidebar,
  .top-bar #open-excipient-sidebar {
    width: 26px !important;
    min-width: 26px !important;
    height: 100% !important;
    flex-basis: 26px !important;
    border: 0 !important;
    border-color: transparent !important;
    border-radius: 999px !important;
    background: transparent !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    color: var(--primary-color, #2f6b2f) !important;
  }

  .top-bar #menu-btn:active,
  .top-bar #exam-menu-btn:active,
  .top-bar #open-prescription-sidebar:active,
  .top-bar #open-excipient-sidebar:active {
    background: rgba(47, 107, 47, 0.08) !important;
  }

  .top-bar #menu-btn::before,
  .top-bar #exam-menu-btn::before,
  .top-bar #open-prescription-sidebar::before,
  .top-bar #open-excipient-sidebar::before {
    width: 20px !important;
    height: 16px !important;
    border-radius: 1px !important;
    background:
      linear-gradient(currentColor, currentColor) 0 1px / 20px 2px no-repeat,
      linear-gradient(currentColor, currentColor) 0 7px / 14.5px 2px no-repeat,
      linear-gradient(currentColor, currentColor) 0 13px / 20px 2px no-repeat !important;
  }
}

/* v0.33: keep the mindmap action dock anchored on tablets when it expands. */
@media (min-width: 769px) and (max-width: 1180px),
       (hover: none) and (pointer: coarse) and (min-width: 769px) {
  .mindmap-actions,
  body.fullscreen-mode-active .mindmap-actions {
    left: auto !important;
    right: max(14px, env(safe-area-inset-right)) !important;
    bottom: calc(14px + env(safe-area-inset-bottom)) !important;
    width: auto !important;
    max-width: min(560px, calc(100vw - 28px)) !important;
    justify-content: flex-end !important;
    margin-left: 0 !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    transform: none !important;
    transform-origin: right center !important;
    scroll-snap-type: none !important;
  }

  .mindmap-actions:not(.actions-collapsed),
  body.fullscreen-mode-active .mindmap-actions:not(.actions-collapsed) {
    padding: 6px 8px !important;
  }

  .mindmap-actions.actions-collapsed,
  body.fullscreen-mode-active .mindmap-actions.actions-collapsed {
    left: auto !important;
    right: max(14px, env(safe-area-inset-right)) !important;
    width: auto !important;
    min-width: 48px !important;
    max-width: none !important;
    justify-content: center !important;
    overflow: visible !important;
  }
}

/* Chapter drawer handle in mindmap fullscreen and flashcard immersive modes */
body.fullscreen-mode-active .sidebar,
body.flashcard-immersive .sidebar {
  display: flex !important;
}

html.apple-study-device body.fullscreen-mode-active .sidebar,
html.ipad-study-device body.fullscreen-mode-active .sidebar,
html.apple-study-device body.flashcard-immersive .sidebar,
html.ipad-study-device body.flashcard-immersive .sidebar {
  display: flex !important;
}

body.fullscreen-mode-active .sidebar-overlay,
body.flashcard-immersive .sidebar-overlay {
  display: none !important;
}

body.fullscreen-mode-active .sidebar-overlay.open,
body.flashcard-immersive .sidebar-overlay.open {
  display: block !important;
}

body.fullscreen-mode-active .sidebar-toggle-trigger,
body.flashcard-immersive .sidebar-toggle-trigger {
  display: flex !important;
  right: -28px !important;
  width: 28px !important;
  height: 54px !important;
  pointer-events: auto !important;
  z-index: 1000003 !important;
}

html.apple-study-device body.fullscreen-mode-active .sidebar-toggle-trigger,
html.ipad-study-device body.fullscreen-mode-active .sidebar-toggle-trigger,
html.apple-study-device body.flashcard-immersive .sidebar-toggle-trigger,
html.ipad-study-device body.flashcard-immersive .sidebar-toggle-trigger {
  display: flex !important;
  right: -28px !important;
  width: 28px !important;
  height: 54px !important;
  pointer-events: auto !important;
  z-index: 1000004 !important;
}

/* v0.34: fixed mindmap fullscreen controls live outside the zoomed app stage. */
.mindmap-fullscreen-controls {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: calc(12px + env(safe-area-inset-left));
  right: auto;
  z-index: 10000080;
  display: none;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  pointer-events: none;
}

body.fullscreen-mode-active .mindmap-fullscreen-controls.is-visible {
  display: flex !important;
}

.mindmap-fullscreen-control {
  pointer-events: auto;
  min-width: 58px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 10px;
  border: 1px solid rgba(47, 107, 47, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--primary-color, #2f6b2f);
  box-shadow: 0 8px 22px rgba(31, 54, 38, 0.1);
  backdrop-filter: blur(12px) saturate(1.15);
  -webkit-backdrop-filter: blur(12px) saturate(1.15);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.mindmap-fullscreen-control svg,
.mindmap-fullscreen-control i {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}

.mindmap-fullscreen-control:active {
  transform: translateY(1px);
}

body.dark-theme .mindmap-fullscreen-control {
  border-color: rgba(199, 241, 194, 0.18);
  background: rgba(15, 23, 42, 0.72);
  color: #d8f5d2;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
}

@supports (zoom: 1) {
  html.apple-study-device body.fullscreen-mode-active .app-container,
  html.ipad-study-device body.fullscreen-mode-active .app-container {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    transform: none !important;
    overflow: visible !important;
  }

  html.apple-study-device body.fullscreen-mode-active .main-content,
  html.ipad-study-device body.fullscreen-mode-active .main-content {
    min-height: 100dvh !important;
  }
}

body.fullscreen-mode-active .mindmap-actions.actions-collapsed #fullscreen-mm-btn {
  display: inline-flex !important;
}

.top-bar,
.top-bar .top-mode-tabs,
.top-bar .top-mode-tab {
  touch-action: manipulation;
}

.top-bar .top-mode-tabs,
.top-bar .top-mode-tab {
  pointer-events: auto;
}

@media (max-width: 768px) {
  .top-bar {
    z-index: 10000010 !important;
  }

  .top-bar .top-mode-tabs {
    z-index: 10000011 !important;
  }

  .sidebar-overlay:not(.open),
  .exam-sidebar-overlay:not(.open) {
    display: none !important;
    pointer-events: none !important;
  }

  .mindmap-fullscreen-controls {
    top: calc(10px + env(safe-area-inset-top));
    left: calc(10px + env(safe-area-inset-left));
  }

  .mindmap-fullscreen-control {
    min-width: 54px;
    min-height: 34px;
    padding: 0 9px;
    font-size: 0.74rem;
  }
}

/* v0.17: on phones the flashcard answer back should scroll as one large surface. */
@media (max-width: 768px) {
  body.flashcard-page .flashcard.is-flipped .card-back {
    justify-content: flex-start !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-y !important;
    padding-bottom: calc(18px + env(safe-area-inset-bottom)) !important;
  }

  body.flashcard-page .flashcard.is-flipped .card-answer-text-container {
    flex: 0 0 auto !important;
    min-height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    -webkit-overflow-scrolling: auto !important;
  }

  body.flashcard-page .flashcard.is-flipped .card-answer-text {
    max-height: none !important;
    overflow: visible !important;
  }

  body.flashcard-page .flashcard.is-flipped .card-page-source,
  body.flashcard-page .flashcard.is-flipped .tap-hint,
  body.flashcard-page .flashcard.is-flipped .flashcard-annotation-toolbar {
    flex: 0 0 auto !important;
  }
}

/* v0.19: mobile flashcard and mindmap interaction cleanup. */
.card-back .tap-hint {
  display: none !important;
}

.flashcard-edit-stack {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  min-height: 42px;
  overflow: visible;
}

.flashcard-edit-stack #annotate-fc-btn {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  box-shadow: 0 10px 26px rgba(31, 54, 38, 0.16);
}

.flashcard-edit-stack #annotate-fc-btn.is-active {
  color: #fff;
  background: var(--primary-color);
}

.flashcard-annotation-canvas.touch-draw-disabled {
  touch-action: pan-y;
}

.flashcard-annotation-canvas.touch-draw-enabled {
  touch-action: none;
}

.flashcard-annotation-toolbar .anno-touch-btn.is-active {
  border-color: color-mix(in srgb, var(--primary-color) 42%, var(--border-color));
  background: var(--primary-color);
  color: #fff;
}

.homepage-announcement-banner,
.official-update-banner {
  position: relative;
  z-index: 560;
  pointer-events: auto;
}

.mindmap-version-toggle {
  z-index: 560 !important;
  pointer-events: auto;
}

.mindmap-version-btn,
.official-update-banner button,
.homepage-announcement-banner button {
  pointer-events: auto;
}

@media (hover: none), (pointer: coarse) {
  body:not(.flashcard-page):not(.mastery-page):not(.discussion-page):not(.announcement-page) .study-pull-square-hit-zone {
    top: var(--study-topbar-height, 58px) !important;
    height: max(72px, calc(20dvh - var(--study-topbar-height, 58px))) !important;
    z-index: 40 !important;
  }
}

@media (max-width: 768px) {
  body.mobile-sidebar-open .top-bar {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    z-index: 1 !important;
  }

  body.mobile-sidebar-open .sidebar.open {
    z-index: 10000030 !important;
  }

  body.mobile-sidebar-open .sidebar-overlay.open {
    z-index: 10000020 !important;
    display: block !important;
  }

  body.mobile-sidebar-open .sidebar-header {
    padding-top: max(12px, env(safe-area-inset-top)) !important;
  }
}

body.flashcard-immersive .single-mode-container,
body.flashcard-immersive .flashcards-container {
  padding-left: max(5px, env(safe-area-inset-left)) !important;
  padding-right: max(5px, env(safe-area-inset-right)) !important;
}

body.flashcard-immersive .flashcards-active-area {
  width: calc(100vw - 10px) !important;
  max-width: 1120px !important;
}

body.flashcard-immersive .card-scene-wrapper {
  width: min(100%, calc(100vw - 10px)) !important;
  padding-inline: 5px !important;
}

/* v0.21: iPad/iOS Safari PWA navigation hit-test stabilization. */
@supports (zoom: 1) {
  html.ios-safari-study-device,
  html.ios-safari-study-device body {
    width: 100vw !important;
    min-width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    overflow: hidden !important;
  }

  html.ios-safari-study-device body {
    zoom: 1 !important;
  }

  html.ios-safari-study-device body .app-container {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    transform: none !important;
    transform-origin: initial !important;
  }

  html.ios-safari-study-device body .main-content {
    min-height: 100dvh !important;
  }
}

html.ios-safari-study-device .top-bar {
  position: relative !important;
  z-index: 10000060 !important;
  isolation: isolate;
  transform: translateZ(0);
  touch-action: manipulation !important;
  -webkit-user-select: none;
  user-select: none;
}

html.ios-safari-study-device .top-bar::after {
  z-index: 0 !important;
  pointer-events: none !important;
}

html.ios-safari-study-device .top-mode-tabs {
  position: relative !important;
  z-index: 3 !important;
  pointer-events: auto !important;
  touch-action: manipulation !important;
  -webkit-overflow-scrolling: touch;
}

html.ios-safari-study-device .top-mode-tab {
  position: relative !important;
  z-index: 4 !important;
  min-height: 44px !important;
  pointer-events: auto !important;
  touch-action: manipulation !important;
  -webkit-tap-highlight-color: rgba(47, 107, 47, 0.16);
}

html.ios-safari-study-device .top-mode-tab svg,
html.ios-safari-study-device .top-mode-tab i,
html.ios-safari-study-device .top-mode-tab span {
  pointer-events: none !important;
}

html.ios-safari-study-device .study-pull-square-hit-zone,
html.ios-safari-study-device .sidebar-overlay:not(.open),
html.ios-safari-study-device .exam-sidebar-overlay:not(.open) {
  pointer-events: none !important;
}

/* v0.20: keep flashcard annotation controls aligned and floating. */
.flashcard-edit-stack {
  display: contents !important;
  width: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
}

.flashcard-edit-stack #annotate-fc-btn {
  position: relative !important;
  left: auto !important;
  bottom: auto !important;
  transform: none !important;
  box-shadow: none !important;
}

body.flashcard-page .flashcard-annotation-toolbar:not([hidden]),
body.mastery-page .flashcard-annotation-toolbar:not([hidden]),
body.mastery-page .mastery-annotation-toolbar:not([hidden]) {
  position: fixed !important;
  left: calc(50% + var(--flashcard-annotation-toolbar-x, 0px)) !important;
  right: auto !important;
  top: auto !important;
  bottom: calc(16px + env(safe-area-inset-bottom)) !important;
  z-index: 1000025 !important;
  display: flex !important;
  pointer-events: auto !important;
  align-items: center !important;
  justify-content: center !important;
  flex-wrap: nowrap !important;
  gap: 6px !important;
  width: max-content !important;
  max-width: calc(100vw - 18px) !important;
  margin: 0 !important;
  padding: 7px 8px !important;
  box-sizing: border-box !important;
  border-radius: 18px !important;
  background: color-mix(in srgb, var(--panel-bg, #ffffff) 92%, var(--primary-light, #e6f4ea) 8%) !important;
  border: 1px solid color-mix(in srgb, var(--primary-color, #1f6f43) 20%, var(--border-color, #d6e2d9)) !important;
  backdrop-filter: blur(14px) !important;
  -webkit-backdrop-filter: blur(14px) !important;
  box-shadow: 0 16px 36px rgba(31, 54, 38, 0.18) !important;
  transform: translate(-50%, var(--flashcard-annotation-toolbar-y, 0px)) !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  scrollbar-width: none !important;
  touch-action: none !important;
  -webkit-overflow-scrolling: touch !important;
}

body.mastery-page .flashcard-annotation-toolbar:not([hidden]),
body.mastery-page .mastery-annotation-toolbar:not([hidden]) {
  bottom: calc(90px + env(safe-area-inset-bottom)) !important;
}

body.mastery-page.mastery-immersive .flashcard-annotation-toolbar:not([hidden]),
body.mastery-page.mastery-immersive .mastery-annotation-toolbar:not([hidden]) {
  bottom: calc(18px + env(safe-area-inset-bottom)) !important;
}

body.flashcard-page .flashcard-annotation-toolbar:not([hidden])::-webkit-scrollbar,
body.mastery-page .flashcard-annotation-toolbar:not([hidden])::-webkit-scrollbar,
body.mastery-page .mastery-annotation-toolbar:not([hidden])::-webkit-scrollbar {
  display: none !important;
}

body.flashcard-page .flashcard-annotation-toolbar.is-positioned:not([hidden]),
body.mastery-page .flashcard-annotation-toolbar.is-positioned:not([hidden]),
body.mastery-page .mastery-annotation-toolbar.is-positioned:not([hidden]) {
  right: auto !important;
}

body.flashcard-page .flashcard-annotation-toolbar.is-dragging,
body.mastery-page .flashcard-annotation-toolbar.is-dragging,
body.mastery-page .mastery-annotation-toolbar.is-dragging {
  cursor: grabbing !important;
  user-select: none !important;
}

body.flashcard-page .flashcard-annotation-toolbar[hidden],
body.mastery-page .flashcard-annotation-toolbar[hidden],
body.mastery-page .mastery-annotation-toolbar[hidden] {
  display: none !important;
}

body.flashcard-page .flashcard-annotation-toolbar .anno-color,
body.mastery-page .flashcard-annotation-toolbar .anno-color,
body.mastery-page .mastery-annotation-toolbar .anno-color {
  flex: 0 0 30px !important;
  width: 30px !important;
  height: 30px !important;
}

body.flashcard-page .flashcard-annotation-toolbar .anno-width,
body.mastery-page .flashcard-annotation-toolbar .anno-width,
body.mastery-page .mastery-annotation-toolbar .anno-width {
  flex: 0 0 132px !important;
  max-width: 132px !important;
  min-width: 132px !important;
  justify-content: center !important;
  gap: 6px !important;
  white-space: nowrap !important;
}

body.flashcard-page .flashcard-annotation-toolbar .anno-width input,
body.mastery-page .flashcard-annotation-toolbar .anno-width input,
body.mastery-page .mastery-annotation-toolbar .anno-width input {
  width: 72px !important;
}

body.flashcard-page .flashcard-annotation-toolbar .btn,
body.mastery-page .flashcard-annotation-toolbar .btn,
body.mastery-page .mastery-annotation-toolbar .btn {
  flex: 0 0 auto !important;
  min-height: 34px !important;
  padding: 0 10px !important;
  border-radius: 11px !important;
  font-size: 0.82rem !important;
  line-height: 1 !important;
  white-space: nowrap !important;
}

body.flashcard-page .flashcard-annotation-toolbar .anno-touch-btn,
body.mastery-page .flashcard-annotation-toolbar .anno-touch-btn,
body.mastery-page .mastery-annotation-toolbar .anno-touch-btn {
  min-width: 82px !important;
}

body.flashcard-page .flashcard-annotation-toolbar [data-anno-action="undo"],
body.flashcard-page .flashcard-annotation-toolbar [data-anno-action="close"],
body.mastery-page .flashcard-annotation-toolbar [data-anno-action="undo"],
body.mastery-page .flashcard-annotation-toolbar [data-anno-action="close"],
body.mastery-page .mastery-annotation-toolbar [data-anno-action="undo"],
body.mastery-page .mastery-annotation-toolbar [data-anno-action="close"] {
  min-width: 58px !important;
}

body.flashcard-page .flashcard-annotation-toolbar .anno-eraser-btn,
body.mastery-page .flashcard-annotation-toolbar .anno-eraser-btn,
body.mastery-page .mastery-annotation-toolbar .anno-eraser-btn {
  min-width: 70px !important;
}

body.flashcard-page .flashcard-annotation-toolbar .anno-drag-handle,
body.mastery-page .flashcard-annotation-toolbar .anno-drag-handle,
body.mastery-page .mastery-annotation-toolbar .anno-drag-handle {
  flex: 0 0 26px !important;
  width: 26px !important;
  height: 34px !important;
  display: inline-grid !important;
  place-items: center !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 999px !important;
  background: color-mix(in srgb, var(--primary-light) 54%, transparent) !important;
  cursor: grab !important;
  touch-action: none !important;
  grid-template-rows: repeat(3, 4px) !important;
  row-gap: 3px !important;
}

body.flashcard-page .flashcard-annotation-toolbar.is-dragging .anno-drag-handle,
body.flashcard-page .flashcard-annotation-toolbar .anno-drag-handle:active,
body.mastery-page .flashcard-annotation-toolbar.is-dragging .anno-drag-handle,
body.mastery-page .flashcard-annotation-toolbar .anno-drag-handle:active,
body.mastery-page .mastery-annotation-toolbar.is-dragging .anno-drag-handle,
body.mastery-page .mastery-annotation-toolbar .anno-drag-handle:active {
  cursor: grabbing !important;
}

body.flashcard-page .flashcard-annotation-toolbar .anno-drag-handle span,
body.flashcard-page .flashcard-annotation-toolbar .anno-drag-handle::before,
body.flashcard-page .flashcard-annotation-toolbar .anno-drag-handle::after,
body.mastery-page .flashcard-annotation-toolbar .anno-drag-handle span,
body.mastery-page .flashcard-annotation-toolbar .anno-drag-handle::before,
body.mastery-page .flashcard-annotation-toolbar .anno-drag-handle::after,
body.mastery-page .mastery-annotation-toolbar .anno-drag-handle span,
body.mastery-page .mastery-annotation-toolbar .anno-drag-handle::before,
body.mastery-page .mastery-annotation-toolbar .anno-drag-handle::after {
  content: "";
  display: block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary-color) 62%, transparent);
}

body.flashcard-annotation-active .flashcard-icon-btn[data-tip]::after,
body.mastery-annotation-active .flashcard-icon-btn[data-tip]::after {
  display: none !important;
}

body.flashcard-page .flashcard-annotation-toolbar:not([hidden]) *,
body.mastery-page .flashcard-annotation-toolbar:not([hidden]) *,
body.mastery-page .mastery-annotation-toolbar:not([hidden]) * {
  pointer-events: auto !important;
}

body.flashcard-annotation-active .floating-nav-btn,
body.mastery-annotation-active .floating-nav-btn {
  pointer-events: none !important;
  opacity: 0.28 !important;
}

@media (max-width: 768px) {
  body.flashcard-page .flashcard-annotation-toolbar:not([hidden]),
  body.mastery-page .flashcard-annotation-toolbar:not([hidden]),
  body.mastery-page .mastery-annotation-toolbar:not([hidden]) {
    left: 50% !important;
    bottom: calc(10px + env(safe-area-inset-bottom)) !important;
    width: calc(100vw - 12px) !important;
    max-width: calc(100vw - 12px) !important;
    justify-content: center !important;
    align-content: center !important;
    flex-wrap: wrap !important;
    gap: 7px 6px !important;
    padding: 7px 6px !important;
    overflow: visible !important;
    transform: translate(-50%, var(--flashcard-annotation-toolbar-y, 0px)) !important;
  }

  body.mastery-page .flashcard-annotation-toolbar:not([hidden]),
  body.mastery-page .mastery-annotation-toolbar:not([hidden]) {
    bottom: calc(88px + env(safe-area-inset-bottom)) !important;
  }

  body.mastery-page.mastery-immersive .flashcard-annotation-toolbar:not([hidden]),
  body.mastery-page.mastery-immersive .mastery-annotation-toolbar:not([hidden]) {
    bottom: calc(12px + env(safe-area-inset-bottom)) !important;
  }

  body.flashcard-page .flashcard-annotation-toolbar .anno-color,
  body.mastery-page .flashcard-annotation-toolbar .anno-color,
  body.mastery-page .mastery-annotation-toolbar .anno-color {
    flex-basis: 28px !important;
    width: 28px !important;
    height: 28px !important;
  }

  body.flashcard-page .flashcard-annotation-toolbar .anno-width,
  body.mastery-page .flashcard-annotation-toolbar .anno-width,
  body.mastery-page .mastery-annotation-toolbar .anno-width {
    flex: 0 1 118px !important;
    min-width: 112px !important;
    max-width: 122px !important;
  }

  body.flashcard-page .flashcard-annotation-toolbar .anno-width input,
  body.mastery-page .flashcard-annotation-toolbar .anno-width input,
  body.mastery-page .mastery-annotation-toolbar .anno-width input {
    width: 58px !important;
  }

  body.flashcard-page .flashcard-annotation-toolbar .btn,
  body.mastery-page .flashcard-annotation-toolbar .btn,
  body.mastery-page .mastery-annotation-toolbar .btn {
    min-height: 44px !important;
    padding: 0 9px !important;
    font-size: 0.78rem !important;
    touch-action: manipulation !important;
  }

  body.flashcard-page .flashcard-annotation-toolbar [data-anno-action],
  body.mastery-page .flashcard-annotation-toolbar [data-anno-action],
  body.mastery-page .mastery-annotation-toolbar [data-anno-action] {
    min-height: 44px !important;
  }

  body.flashcard-page .flashcard-annotation-toolbar .anno-touch-btn,
  body.mastery-page .flashcard-annotation-toolbar .anno-touch-btn,
  body.mastery-page .mastery-annotation-toolbar .anno-touch-btn {
    min-width: 86px !important;
  }

  body.flashcard-page .flashcard-annotation-toolbar .anno-eraser-btn,
  body.mastery-page .flashcard-annotation-toolbar .anno-eraser-btn,
  body.mastery-page .mastery-annotation-toolbar .anno-eraser-btn {
    min-width: 72px !important;
  }
}

@media (max-width: 380px) {
  body.flashcard-page .flashcard-annotation-toolbar .btn,
  body.mastery-page .flashcard-annotation-toolbar .btn,
  body.mastery-page .mastery-annotation-toolbar .btn {
    padding: 0 7px !important;
    font-size: 0.74rem !important;
  }

  body.flashcard-page .flashcard-annotation-toolbar .anno-touch-btn,
  body.mastery-page .flashcard-annotation-toolbar .anno-touch-btn,
  body.mastery-page .mastery-annotation-toolbar .anno-touch-btn {
    min-width: 80px !important;
  }
}

@media (max-width: 768px) {
  body.flashcard-page .card-quick-controls {
    width: fit-content !important;
    max-width: min(100%, 360px) !important;
    justify-content: center !important;
  }

  body.flashcard-annotation-active .flashcard.is-flipped .card-back {
    padding-bottom: calc(150px + env(safe-area-inset-bottom)) !important;
  }
}

@media (max-width: 360px) {
  body.flashcard-page .card-quick-controls {
    gap: 4px !important;
    padding: 2px !important;
  }

  body.flashcard-page .card-quick-controls .btn {
    width: 36px !important;
    min-width: 36px !important;
  }
}

@media (hover: none), (pointer: coarse) {
  body:not(.flashcard-page):not(.mastery-page):not(.discussion-page):not(.announcement-page) .study-pull-square-hit-zone {
    top: var(--study-topbar-height, 58px) !important;
    height: max(72px, calc(20dvh - var(--study-topbar-height, 58px))) !important;
    z-index: 40 !important;
  }
}

/* ==========================================================================
   挖空填空自测 (Cloze Masking & Active Recall)
   ========================================================================== */

/* 允许卡片背面文本在触屏设备上正常选词，但全面禁止系统长按呼出框与放大镜 */
.card-answer-text,
.card-answer-text *,
.definition-answer-content,
.definition-answer-content * {
  -webkit-user-select: text;
  user-select: text;
}

.flashcard,
.card-scene,
.card-scene-wrapper,
.card-face,
.card-front,
.card-back,
.card-question-text,
.card-answer-text-container,
.card-answer-text,
.definition-answer-content,
.cloze-mask,
.cloze-content,
.mastery-review-card,
.mastery-review-stage,
.mastery-answer-text,
#mastery-card-answer,
#mastery-card-question {
  -webkit-touch-callout: none !important;
}

/* 挖空基础胶囊 */
.cloze-mask,
.cloze-mask * {
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
}

/* 挖空基础胶囊：高质感现代磨砂药丸设计 */
.cloze-mask {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  vertical-align: -0.02em;
  padding: 0 6px;
  margin: 0 2px;
  min-width: 2em;
  min-height: 1.32em;
  line-height: 1.32;
  border-radius: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-sizing: border-box;
}

/* 扩大移动端与平板触摸热区 */
.cloze-mask::before {
  content: "";
  position: absolute;
  top: -8px;
  bottom: -8px;
  left: -4px;
  right: -4px;
  pointer-events: auto;
}

/* 遮盖状态：高级质感紫水晶玻璃（Textured Amethyst Glassmorphism） */
.cloze-mask[data-revealed="false"] {
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.28) 0%, rgba(124, 58, 237, 0.18) 50%, rgba(192, 132, 252, 0.28) 100%);
  border: 1px solid rgba(168, 85, 247, 0.52);
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.12), inset 0 1px 1px rgba(255, 255, 255, 0.75), inset 0 -1px 2px rgba(139, 92, 246, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.cloze-mask[data-revealed="false"] .cloze-content {
  opacity: 0;
  visibility: hidden;
  user-select: none;
  pointer-events: none;
}

.cloze-mask[data-revealed="false"]:hover {
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.4) 0%, rgba(124, 58, 237, 0.28) 50%, rgba(192, 132, 252, 0.42) 100%);
  border-color: rgba(147, 51, 234, 0.78);
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.25), inset 0 1px 1.5px rgba(255, 255, 255, 0.9), inset 0 -1px 2px rgba(139, 92, 246, 0.2);
  transform: translateY(-1px);
}

.cloze-mask[data-revealed="false"]:active {
  transform: scale(0.97);
}

/* 揭晓状态：高雅温和的翡翠/主色微光强调，字迹清晰高亮 */
.cloze-mask[data-revealed="true"] {
  background: color-mix(in srgb, var(--success-color, #10b981) 12%, transparent);
  border: 1.5px solid color-mix(in srgb, var(--success-color, #10b981) 40%, transparent);
  box-shadow: 0 1px 4px rgba(16, 185, 129, 0.08);
  -webkit-user-select: text;
  user-select: text;
}

.cloze-mask[data-revealed="true"] .cloze-content {
  opacity: 1;
  visibility: visible;
  color: var(--primary-color);
  font-weight: 700;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 深色模式适配：沉醉紫曜晶透光玻璃质感 */
body.dark-theme .cloze-mask[data-revealed="false"] {
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.32) 0%, rgba(109, 40, 217, 0.2) 100%);
  border-color: rgba(168, 85, 247, 0.48);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35), inset 0 1px 1px rgba(255, 255, 255, 0.22);
}

body.dark-theme .cloze-mask[data-revealed="false"]:hover {
  background: linear-gradient(135deg, rgba(147, 51, 234, 0.45) 0%, rgba(109, 40, 217, 0.32) 100%);
  border-color: rgba(192, 132, 252, 0.72);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.32), inset 0 1px 1px rgba(255, 255, 255, 0.35);
}

body.dark-theme .cloze-mask[data-revealed="true"] {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(52, 211, 153, 0.45);
}

body.dark-theme .cloze-mask[data-revealed="true"] .cloze-content {
  color: #f1f5f9;
}

/* 虚拟划词高亮预览 (用于绕过 iOS / Android 原生工具栏) */
.cloze-selection-preview {
  display: inline;
  background: color-mix(in srgb, var(--primary-color, #2563eb) 22%, transparent);
  border-radius: 4px;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary-color, #2563eb) 35%, transparent);
  animation: cloze-preview-pulse 1.4s ease-in-out infinite alternate;
}

@keyframes cloze-preview-pulse {
  from {
    background: color-mix(in srgb, var(--primary-color, #2563eb) 18%, transparent);
  }
  to {
    background: color-mix(in srgb, var(--primary-color, #2563eb) 30%, transparent);
  }
}

/* 浮动微型挖空气泡 */
.floating-cloze-bubble {
  position: fixed;
  z-index: 2147483640;
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--panel-bg, #ffffff);
  border: 1px solid color-mix(in srgb, var(--primary-color) 32%, var(--border-color));
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transform: translate3d(0, 0, 0) scale(0.92);
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.floating-cloze-bubble.is-visible {
  display: inline-flex;
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

.floating-cloze-bubble .cloze-bubble-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border: none;
  background: transparent;
  color: var(--primary-color);
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.floating-cloze-bubble .cloze-bubble-btn svg,
.floating-cloze-bubble .cloze-bubble-btn i {
  width: 14px;
  height: 14px;
}

body.dark-theme .floating-cloze-bubble {
  background: rgba(26, 37, 25, 0.95);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
body.dark-theme .floating-cloze-bubble .cloze-bubble-btn {
  color: var(--accent-color);
}

/* ==========================================================================
   跨端触控体验与滚动回弹隔离优化 (Cross-platform Touch & Scroll Polish)
   ========================================================================== */
@media (hover: none), (pointer: coarse) {
  .btn:active,
  .top-mode-tab:active,
  .subject-toggle-btn:active,
  .subbook-toggle-btn:active,
  .theme-btn:active,
  .settings-btn:active,
  .account-sync-btn:active,
  .toggle-btn:active,
  .card-quick-controls .btn:active,
  .mindmap-fullscreen-control:active {
    transform: scale(0.96) !important;
    transition: transform 0.08s ease !important;
  }
}

.chapter-list-container,
.card-answer-text-container,
.card-question-text,
.discussion-container,
.discussion-messages,
.feedback-history-list {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* 触觉/物理微弹反馈动效降级 (iOS Safari & Android fallback) */
@keyframes haptic-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(0.96); }
  100% { transform: scale(1); }
}

.haptic-pulse {
  animation: haptic-pulse 0.18s cubic-bezier(0.25, 1, 0.5, 1) !important;
}

/* WebKit 3D 翻转复合层级与防 Z 轴重叠穿透 (仅针对非触控桌面端) */
html:not(.touch-study-device) .card-face {
  -webkit-backface-visibility: hidden !important;
  backface-visibility: hidden !important;
  transform: translate3d(0, 0, 1px);
}

html:not(.touch-study-device) .card-front {
  transform: rotateY(0deg) translate3d(0, 0, 1px);
}

html:not(.touch-study-device) .card-back {
  transform: rotateY(180deg) translate3d(0, 0, 1px);
}

/* ==========================================================================
   平板与触屏闪卡平铺交互 (Huawei MatePad / iPad / Android Tablet Touch Scroll)
   解决鸿蒙/安卓/iPad平板在宽屏(>768px)下因 3D preserve-3d/perspective 导致答案区无法上下滑动拖拽的内核 Bug
   ========================================================================== */
html.touch-study-device body.flashcard-page .card-scene,
body.flashcard-page .card-scene {
  perspective: none !important;
}

html.touch-study-device body.flashcard-page .flashcard,
body.flashcard-page .flashcard {
  transform: none !important;
  transform-style: flat !important;
  transition: none !important;
}

html.touch-study-device body.flashcard-page .card-face,
body.flashcard-page .card-face {
  inset: 0 !important;
  transform: none !important;
  backface-visibility: visible !important;
  -webkit-backface-visibility: visible !important;
  transition: opacity 0.18s ease, visibility 0.18s ease !important;
}

html.touch-study-device body.flashcard-page .card-front,
body.flashcard-page .card-front {
  transform: none !important;
}

html.touch-study-device body.flashcard-page .card-back,
body.flashcard-page .card-back {
  transform: none !important;
}

html.touch-study-device body.flashcard-page .card-face.card-back,
body.flashcard-page .card-face.card-back {
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
  padding-bottom: calc(24px + env(safe-area-inset-bottom)) !important;
}

html.touch-study-device body.flashcard-page .flashcard:not(.is-flipped) .card-front,
body.flashcard-page .flashcard:not(.is-flipped) .card-front {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

html.touch-study-device body.flashcard-page .flashcard:not(.is-flipped) .card-back,
body.flashcard-page .flashcard:not(.is-flipped) .card-back {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

html.touch-study-device body.flashcard-page .flashcard.is-flipped .card-front,
body.flashcard-page .flashcard.is-flipped .card-front {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

html.touch-study-device body.flashcard-page .flashcard.is-flipped .card-back,
body.flashcard-page .flashcard.is-flipped .card-back {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

html.touch-study-device body.flashcard-page .flashcard.is-flipped .card-answer-text-container,
body.flashcard-page .flashcard.is-flipped .card-answer-text-container {
  flex: 0 0 auto !important;
  min-height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  -webkit-overflow-scrolling: auto !important;
  touch-action: pan-y !important;
}

html.touch-study-device body.flashcard-page .flashcard.is-flipped .card-answer-text,
body.flashcard-page .flashcard.is-flipped .card-answer-text {
  max-height: none !important;
  overflow: visible !important;
  touch-action: pan-y !important;
}

/* 批注画布非激活状态下彻底穿透，杜绝拦截手指滑动手势 */
body.flashcard-page:not(.flashcard-annotation-active) .flashcard-annotation-canvas,
body.mastery-page:not(.mastery-annotation-active) .flashcard-annotation-canvas {
  pointer-events: none !important;
  touch-action: auto !important;
}

/* 移动触屏与平板设备性能加速：移除高开销 SVG 噪点滤镜，提升 GPU 复合层光栅化帧率 */
html.touch-study-device .sidebar::after,
html.touch-study-device .top-bar::after,
html.touch-study-device .settings-modal::after {
  filter: none !important;
  display: none !important;
}

/* 确保移动端侧边栏、关闭按钮及公告横幅拥有最高层级且点击必达 */
.sidebar {
  z-index: 10000030 !important;
}

#close-sidebar-btn,
.sidebar-header .toggle-btn {
  position: relative !important;
  z-index: 10000040 !important;
  cursor: pointer !important;
  pointer-events: auto !important;
  touch-action: manipulation !important;
}

/* ==========================================================================
   Homepage Announcement Ticker Bar (方案 A: 极简吸顶跑马灯条)
   ========================================================================== */
#homepage-announcement-banner.homepage-announcement-banner.is-ticker {
  position: relative !important;
  z-index: 560 !important;
  width: 100% !important;
  height: 30px !important;
  min-height: 30px !important;
  max-height: 30px !important;
  margin: 0 !important;
  padding: 0 8px 0 12px !important;
  display: flex;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 8px !important;
  background: color-mix(in srgb, var(--primary-color, #2b6cb0) 8%, var(--bg-color, #ffffff)) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border-radius: 0 !important;
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
  border-bottom: 1px solid color-mix(in srgb, var(--primary-color, #2b6cb0) 18%, transparent) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03) !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
  flex-shrink: 0 !important;
  pointer-events: auto !important;
  touch-action: manipulation !important;
  transition: max-height 0.22s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.18s ease, padding 0.22s ease !important;
}

#homepage-announcement-banner.is-hidden,
#homepage-announcement-banner[hidden],
#homepage-announcement-banner.is-ticker.is-hidden,
#homepage-announcement-banner.is-ticker[hidden] {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

#homepage-announcement-banner.is-ticker.is-closing {
  max-height: 0 !important;
  min-height: 0 !important;
  height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  opacity: 0 !important;
  border-bottom: none !important;
  pointer-events: none !important;
}

.ann-ticker-content {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  height: 100%;
  cursor: pointer;
  outline: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.ann-ticker-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.ann-ticker-icon {
  font-size: 0.85rem;
  line-height: 1;
  display: inline-block;
}

.ann-ticker-label {
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--primary-color, #2b6cb0);
  background: color-mix(in srgb, var(--primary-color, #2b6cb0) 15%, transparent);
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.ann-ticker-viewport {
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  mask-image: linear-gradient(to right, transparent 0, #000 6px, #000 calc(100% - 10px), transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 6px, #000 calc(100% - 10px), transparent 100%);
}

.ann-ticker-track {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  will-change: transform;
}

.ann-ticker-track.has-marquee {
  animation: ann-ticker-marquee var(--ticker-duration, 16s) linear infinite;
}

.ann-ticker-content:hover .ann-ticker-track.has-marquee,
.ann-ticker-content:focus-visible .ann-ticker-track.has-marquee,
.ann-ticker-content:active .ann-ticker-track.has-marquee {
  animation-play-state: paused;
}

.ann-ticker-text {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-main, #2d3748);
  line-height: 1;
  white-space: nowrap;
}

.ann-ticker-clone {
  padding-left: 48px;
}

.ann-ticker-tail {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  color: var(--primary-color, #2b6cb0);
  opacity: 0.85;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.ann-ticker-hint {
  font-size: 0.7rem;
  font-weight: 600;
}

.ann-ticker-arrow {
  width: 11px;
  height: 11px;
}

.ann-ticker-content:hover .ann-ticker-tail {
  opacity: 1;
  transform: translateX(1px);
}

.ann-ticker-close-btn {
  background: none !important;
  border: none !important;
  color: var(--text-muted, #a0aec0) !important;
  font-size: 1rem !important;
  cursor: pointer !important;
  padding: 4px 6px !important;
  line-height: 1 !important;
  border-radius: 4px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  opacity: 0.7 !important;
  pointer-events: auto !important;
  touch-action: manipulation !important;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease !important;
}

.ann-ticker-close-btn:hover {
  opacity: 1 !important;
  color: var(--text-main, #2d3748) !important;
  background: rgba(0, 0, 0, 0.05) !important;
}

@keyframes ann-ticker-marquee {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    transform: translate3d(-50%, 0, 0);
  }
}

/* 适配暗色模式 (Dark Theme) */
body.dark-theme #homepage-announcement-banner.is-ticker,
body[data-theme="dark"] #homepage-announcement-banner.is-ticker {
  background: color-mix(in srgb, var(--primary-color, #38bdf8) 12%, #18181b) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25) !important;
}

body.dark-theme .ann-ticker-close-btn:hover,
body[data-theme="dark"] .ann-ticker-close-btn:hover {
  background: rgba(255, 255, 255, 0.08) !important;
}

/* 移动端细致微调 (max-width: 640px) */
@media (max-width: 640px) {
  #homepage-announcement-banner.homepage-announcement-banner.is-ticker {
    height: 28px !important;
    min-height: 28px !important;
    max-height: 28px !important;
    padding: 0 6px 0 10px !important;
    gap: 6px !important;
  }
  .ann-ticker-label {
    font-size: 0.65rem;
    padding: 1px 4px;
  }
  .ann-ticker-text {
    font-size: 0.74rem;
  }
  .ann-ticker-hint {
    display: none;
  }
  .ann-ticker-arrow {
    width: 10px;
    height: 10px;
  }
}

/* ==========================================================================
   Mindmap In-App High-Res Print & Preview Viewer
   ========================================================================== */
.mindmap-print-viewer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 10000050;
  background: var(--bg-main, #f1f5f9);
  display: flex;
  flex-direction: column;
  color: var(--text-main, #1e293b);
  overflow: hidden;
}
.print-viewer-header {
  height: 56px;
  background: var(--card-bg, #ffffff);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
  gap: 12px;
}
.viewer-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.viewer-back-btn {
  padding: 6px 12px;
  font-size: 0.85rem;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.viewer-doc-title {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.viewer-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.viewer-action-btn {
  padding: 7px 14px;
  font-size: 0.84rem;
  font-weight: 600;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.viewer-print-btn {
  background: #059669 !important;
  border-color: #059669 !important;
  color: #fff !important;
}
.print-viewer-body {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 14px;
  display: flex;
  justify-content: center;
  background: color-mix(in srgb, var(--bg-main, #f1f5f9) 90%, #000 10%);
}
.print-paper-sheet {
  background: #ffffff;
  color: #111827;
  width: 100%;
  max-width: 1200px;
  min-height: calc(100vh - 120px);
  border-radius: 8px;
  padding: 24px 28px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(0,0,0,0.06);
}
.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 1.5px solid #e5e7eb;
  padding-bottom: 8px;
  margin-bottom: 14px;
  flex-shrink: 0;
}
.sheet-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sheet-book-tag {
  font-size: 8.5pt;
  font-weight: 700;
  color: #059669;
  letter-spacing: 0.5px;
}
.sheet-chapter-title {
  font-size: 14pt;
  font-weight: 800;
  color: #111827;
}
.sheet-meta-info {
  font-size: 8pt;
  color: #6b7280;
  text-align: right;
  line-height: 1.4;
}
.sheet-content-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.sheet-content-stage svg {
  width: 100%;
  height: auto;
  max-width: 100%;
  display: block;
}

@media (max-width: 768px) {
  .print-viewer-header {
    padding: 0 10px;
    height: 52px;
  }
  .viewer-doc-title {
    display: none;
  }
  .viewer-action-btn span {
    font-size: 0.8rem;
  }
  .print-paper-sheet {
    padding: 14px 12px;
    min-height: calc(100vh - 100px);
  }
}

@media print {
  body > *:not(#mindmap-print-viewer-modal) {
    display: none !important;
  }
  .mindmap-print-viewer {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    background: #ffffff !important;
    display: block !important;
  }
  .print-viewer-header {
    display: none !important;
  }
  .print-viewer-body {
    padding: 0 !important;
    background: #ffffff !important;
    overflow: visible !important;
  }
  .print-paper-sheet {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    max-width: none !important;
    width: 100% !important;
  }
  .sheet-content-stage svg {
    max-height: calc(100vh - 40px) !important;
  }
}





/* Mobile Official Update Banner Responsive Wrap */
@media (max-width: 768px) {
  .official-update-banner {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 10px 12px !important;
    margin: 8px 10px !important;
  }

  .official-update-banner > div:first-child {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  .official-update-banner > div:first-child span {
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.4 !important;
  }

  .official-update-banner > div:last-child {
    display: flex !important;
    width: 100% !important;
    justify-content: flex-end !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  .official-update-banner > div:last-child button {
    flex-shrink: 0 !important;
  }
}

/* Maintain 1.0 physical scale ONLY for popup modal dialogs, allowing top bar buttons to scale naturally */
.account-sync-panel,
.account-sync-backdrop,
.settings-modal,
.modal-backdrop,
.feedback-widget-modal {
  zoom: calc(1 / var(--study-page-zoom, 1));
}


/* Official Update Banner Refactored Responsive Styles */
.official-update-banner {
  position: relative;
  z-index: 560;
  pointer-events: auto;
  margin: 10px 16px;
  padding: 10px 14px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  backdrop-filter: blur(8px);
}

.official-update-content {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-main, #1e293b);
  min-width: 0;
}

.official-update-title {
  font-weight: 600;
  white-space: nowrap;
}

.official-update-desc {
  font-size: 0.8rem;
  opacity: 0.85;
}

.official-update-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.official-update-btn {
  padding: 4px 10px !important;
  font-size: 0.8rem !important;
}

.official-update-apply {
  background: #3b82f6 !important;
}

.official-update-close {
  background: none;
  border: none;
  color: var(--text-muted, #a0aec0);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .official-update-banner {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    margin: 8px 10px !important;
    padding: 8px 10px !important;
  }

  .official-update-content {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 2px !important;
    width: 100% !important;
  }

  .official-update-title,
  .official-update-desc {
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.35 !important;
  }

  .official-update-actions {
    display: flex !important;
    width: 100% !important;
    justify-content: flex-end !important;
    flex-wrap: nowrap !important;
    gap: 6px !important;
  }

  .official-update-btn {
    padding: 4px 8px !important;
    font-size: 0.76rem !important;
  }
}


/* ==========================================================================
   UI Harmonization & Immersive Refinements (v2.18)
   ========================================================================== */

/* 1. Unified circular transparent top-bar action buttons (Theme & User Avatar) */
.theme-btn,
.settings-btn,
.account-sync-btn,
.account-profile-trigger {
  width: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  height: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 50% !important;
  background: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  color: var(--text-main, #1e293b) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
  cursor: pointer !important;
  transition: transform 0.15s ease, background-color 0.15s ease, color 0.15s ease !important;
}

.theme-btn:hover,
.settings-btn:hover,
.account-sync-btn:hover,
.account-profile-trigger:hover {
  background: rgba(0, 0, 0, 0.06) !important;
  color: var(--primary-color, #2e7d32) !important;
  transform: scale(1.06);
}

.theme-btn:active,
.settings-btn:active,
.account-sync-btn:active,
.account-profile-trigger:active {
  background: rgba(0, 0, 0, 0.1) !important;
  transform: scale(0.94);
}

body.dark-theme .theme-btn,
body.dark-theme .settings-btn,
body.dark-theme .account-sync-btn,
body.dark-theme .account-profile-trigger {
  color: #e2e8f0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

body.dark-theme .theme-btn:hover,
body.dark-theme .settings-btn:hover,
body.dark-theme .account-sync-btn:hover,
body.dark-theme .account-profile-trigger:hover {
  background: rgba(255, 255, 255, 0.12) !important;
  color: #fff !important;
}

.theme-btn svg,
.theme-btn i {
  width: 22px !important;
  height: 22px !important;
  min-width: 22px !important;
  min-height: 22px !important;
  stroke-width: 2.1 !important;
}

.settings-btn svg,
.settings-btn i,
.account-sync-btn svg,
.account-sync-btn i {
  width: 25px !important;
  height: 25px !important;
  min-width: 25px !important;
  min-height: 25px !important;
  stroke-width: 2.2 !important;
}

/* /* 2. CPU-349 Modern Knowledge Workspace Sidebar (Scheme A Redesign) */
.sidebar {
  width: 288px !important;
  background: var(--glass-bg, rgba(247, 249, 246, 0.75)) !important;
  backdrop-filter: blur(24px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(24px) saturate(180%) !important;
  border-right: 1px solid var(--border-color, rgba(45, 90, 39, 0.09)) !important;
}

.sidebar-header {
  padding: 10px 14px 10px !important;
  min-height: 52px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  border-bottom: 1px solid var(--border-color, rgba(45, 90, 39, 0.08)) !important;
}

.logo-area {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  min-width: 0 !important;
  flex: 1 !important;
}

.brand-logo-img,
.logo-img,
.brand-logo-squircle {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  border-radius: 8px !important;
  object-fit: cover !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08) !important;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

.brand-logo-img:hover,
.logo-img:hover,
.brand-logo-squircle:hover {
  transform: scale(1.06) !important;
}

.brand-logo-squircle svg {
  width: 20px !important;
  height: 20px !important;
  stroke: #FFFFFF !important;
}

.logo-text {
  min-width: 0 !important;
  flex: 1 !important;
}

.logo-text .app-brand-title {
  display: flex !important;
  flex-direction: row !important;
  align-items: baseline !important;
  gap: 6px !important;
  max-width: none !important;
  margin: 0 !important;
  line-height: 1.2 !important;
}

.logo-text .app-brand-title span:first-child {
  font-size: 1.05rem !important;
  font-weight: 800 !important;
  letter-spacing: -0.2px !important;
  color: var(--text-main, #1e293b) !important;
  white-space: nowrap !important;
}

.logo-text .app-brand-title span:last-child,
.logo-text .app-brand-title .brand-version-pill {
  margin-top: 0 !important;
  font-size: 0.68rem !important;
  font-weight: 700 !important;
  color: var(--primary-color, #2D5A27) !important;
  background: var(--primary-light, rgba(45, 90, 39, 0.09)) !important;
  padding: 1.5px 6px !important;
  border-radius: 6px !important;
  letter-spacing: 0.2px !important;
  white-space: nowrap !important;
}

/* Header Close Button:
   Desktop & Tablet: Hidden completely; collapse/expand is handled exclusively by the left-middle floating trigger (.sidebar-toggle-trigger).
   Mobile (<= 768px): Displayed in the header of the sliding overlay drawer.
*/
.sidebar-collapse-btn,
#close-sidebar-btn,
#exam-sidebar-close,
#close-excipient-sidebar,
#close-prescription-sidebar,
.sidebar-header .toggle-btn {
  display: none !important;
}

@media (max-width: 768px) {
  .sidebar-collapse-btn,
  #close-sidebar-btn,
  #exam-sidebar-close,
  #close-excipient-sidebar,
  #close-prescription-sidebar,
  .sidebar-header .toggle-btn {
    width: 28px !important;
    min-width: 28px !important;
    height: 28px !important;
    min-height: 28px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    border-radius: 7px !important;
    background: rgba(0, 0, 0, 0.03) !important;
    color: var(--text-muted, #64748b) !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.15s ease !important;
    flex-shrink: 0 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03) !important;
  }

  .sidebar-collapse-btn:hover,
  #close-sidebar-btn:hover,
  #exam-sidebar-close:hover,
  #close-excipient-sidebar:hover,
  #close-prescription-sidebar:hover,
  .sidebar-header .toggle-btn:hover {
    background: var(--primary-light, rgba(45, 90, 39, 0.1)) !important;
    border-color: rgba(45, 90, 39, 0.2) !important;
    color: var(--primary-color, #2D5A27) !important;
    transform: none !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05) !important;
  }

  .sidebar-collapse-btn:active,
  #close-sidebar-btn:active,
  #exam-sidebar-close:active,
  #close-excipient-sidebar:active,
  #close-prescription-sidebar:active,
  .sidebar-header .toggle-btn:active {
    transform: scale(0.92) !important;
  }

  .sidebar-collapse-btn svg,
  #close-sidebar-btn svg,
  #exam-sidebar-close svg,
  #close-excipient-sidebar svg,
  #close-prescription-sidebar svg,
  .sidebar-header .toggle-btn svg {
    width: 16px !important;
    height: 16px !important;
    stroke-width: 2.2 !important;
  }

  body.dark-theme .sidebar-collapse-btn,
  body.dark-theme #close-sidebar-btn,
  body.dark-theme #exam-sidebar-close,
  body.dark-theme #close-excipient-sidebar,
  body.dark-theme #close-prescription-sidebar,
  body.dark-theme .sidebar-header .toggle-btn {
    border-color: rgba(255, 255, 255, 0.08) !important;
    background: rgba(255, 255, 255, 0.04) !important;
    color: #94a3b8 !important;
  }

  body.dark-theme .sidebar-collapse-btn:hover,
  body.dark-theme #close-sidebar-btn:hover,
  body.dark-theme #exam-sidebar-close:hover,
  body.dark-theme #close-excipient-sidebar:hover,
  body.dark-theme #close-prescription-sidebar:hover,
  body.dark-theme .sidebar-header .toggle-btn:hover {
    background: rgba(255, 255, 255, 0.12) !important;
    border-color: rgba(255, 255, 255, 0.16) !important;
    color: #fff !important;
  }
}

/* Apple / macOS Style Segmented Pill for Subject Navigation */
.subject-toggle-group {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 3px !important;
  background: rgba(0, 0, 0, 0.04) !important;
  padding: 3px !important;
  border-radius: 10px !important;
  border: 1px solid rgba(45, 90, 39, 0.06) !important;
}

body.dark-theme .subject-toggle-group {
  background: rgba(255, 255, 255, 0.06) !important;
  border-color: rgba(255, 255, 255, 0.06) !important;
}

.subject-toggle-btn {
  flex-direction: row !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 3.5px !important;
  min-height: 32px !important;
  height: 32px !important;
  padding: 0 3px !important;
  font-size: 0.73rem !important;
  font-weight: 600 !important;
  color: var(--text-muted, #64748b) !important;
  background: transparent !important;
  border: none !important;
  border-radius: 7px !important;
  cursor: pointer !important;
  transition: all 0.18s ease !important;
  white-space: nowrap !important;
  box-shadow: none !important;
  box-sizing: border-box !important;
  max-width: 100% !important;
  overflow: hidden !important;
}

.subject-toggle-btn span {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.subject-toggle-btn i,
.subject-toggle-btn svg {
  width: 13px !important;
  height: 13px !important;
  stroke-width: 2.2 !important;
  flex-shrink: 0 !important;
  transition: transform 0.16s ease !important;
}

.subject-toggle-btn:hover i,
.subject-toggle-btn:hover svg {
  transform: scale(1.1) !important;
}

/* Subject icon color differentiation */
.subject-toggle-btn[data-subject="pharmacology"] i,
.subject-toggle-btn[data-subject="pharmacology"] svg {
  color: #10b981 !important;
}
.subject-toggle-btn[data-subject="industrial_pharmacy"] i,
.subject-toggle-btn[data-subject="industrial_pharmacy"] svg {
  color: #3b82f6 !important;
}
.subject-toggle-btn[data-subject="pharmacy_administration"] i,
.subject-toggle-btn[data-subject="pharmacy_administration"] svg {
  color: #f59e0b !important;
}

.subject-toggle-btn.active[data-subject="pharmacology"],
.subject-toggle-btn[aria-selected="true"][data-subject="pharmacology"] {
  background: #ffffff !important;
  color: #065f46 !important;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.18) !important;
}
.subject-toggle-btn.active[data-subject="industrial_pharmacy"],
.subject-toggle-btn[aria-selected="true"][data-subject="industrial_pharmacy"] {
  background: #ffffff !important;
  color: #1e40af !important;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.18) !important;
}
.subject-toggle-btn.active[data-subject="pharmacy_administration"],
.subject-toggle-btn[aria-selected="true"][data-subject="pharmacy_administration"] {
  background: #ffffff !important;
  color: #92400e !important;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.18) !important;
}

body.dark-theme .subject-toggle-btn.active[data-subject="pharmacology"],
body.dark-theme .subject-toggle-btn[aria-selected="true"][data-subject="pharmacology"] {
  background: rgba(16, 185, 129, 0.18) !important;
  color: #6ee7b7 !important;
}
body.dark-theme .subject-toggle-btn.active[data-subject="industrial_pharmacy"],
body.dark-theme .subject-toggle-btn[aria-selected="true"][data-subject="industrial_pharmacy"] {
  background: rgba(59, 130, 246, 0.18) !important;
  color: #93c5fd !important;
}
body.dark-theme .subject-toggle-btn.active[data-subject="pharmacy_administration"],
body.dark-theme .subject-toggle-btn[aria-selected="true"][data-subject="pharmacy_administration"] {
  background: rgba(245, 158, 11, 0.18) !important;
  color: #fcd34d !important;
}

.subject-toggle-btn span {
  white-space: nowrap !important;
  overflow: visible !important;
}

/* Unify MCQ Bank Entry with Mastery Bank Button */
.mcq-bank-entry {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  width: 100% !important;
  min-height: 32px !important;
  gap: 6px !important;
  padding: 5px 10px !important;
  border: 1px solid color-mix(in srgb, var(--primary-color) 34%, var(--border-color)) !important;
  border-radius: 9px !important;
  background: color-mix(in srgb, var(--primary-light) 76%, #ffffff 24%) !important;
  color: var(--primary-color) !important;
  font-size: 0.81rem !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  text-decoration: none !important;
  box-shadow: 0 1px 3px rgba(31, 54, 38, 0.06) !important;
  transition: all 0.18s ease !important;
}

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

.mcq-bank-entry i,
.mcq-bank-entry svg {
  width: 16px !important;
  height: 16px !important;
  color: #ef4444 !important;
  flex-shrink: 0 !important;
}

.mcq-bank-entry strong {
  margin-left: auto !important;
  min-width: 22px !important;
  height: 19px !important;
  padding: 0 6px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 999px !important;
  background: rgba(239, 68, 68, 0.12) !important;
  color: #dc2626 !important;
  font-size: 0.74rem !important;
  font-weight: 750 !important;
}

body.dark-theme .mcq-bank-entry {
  background: rgba(30, 41, 59, 0.88) !important;
  border-color: rgba(148, 163, 184, 0.24) !important;
  color: #d9f99d !important;
}
body.dark-theme .mcq-bank-entry strong {
  background: rgba(239, 68, 68, 0.22) !important;
  color: #fca5a5 !important;
}

.subject-toggle-btn:hover {
  color: var(--text-main, #1e293b) !important;
  background: rgba(255, 255, 255, 0.5) !important;
}

body.dark-theme .subject-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.08) !important;
}

.subject-toggle-btn.active,
.subject-toggle-btn[aria-selected="true"] {
  color: var(--primary-color, #2D5A27) !important;
  background: var(--panel-bg, #FFFFFF) !important;
  font-weight: 700 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04) !important;
  border: none !important;
}

body.dark-theme .subject-toggle-btn.active,
body.dark-theme .subject-toggle-btn[aria-selected="true"] {
  background: var(--panel-bg, #1A2419) !important;
  color: var(--primary-color, #5BA852) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

/* ==========================================================================
   Chapter List: Modern 2-Column Layout, Tabular Monospace Index & Hanging Indent
   ========================================================================== */
.chapter-item {
  padding: 8px 10px 8px 14px !important;
  border-radius: 8px !important;
  cursor: pointer !important;
  font-size: 0.88rem !important;
  color: var(--text-main, #1e293b) !important;
  margin-bottom: 2px !important;
  transition: background-color 0.15s ease, color 0.15s ease !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  gap: 8px !important;
  position: relative !important;
  transform: none !important;
  user-select: none;
}

.chapter-item:hover {
  background-color: var(--primary-light, rgba(45, 90, 39, 0.06)) !important;
  transform: none !important;
}

.chapter-item.active {
  background-color: var(--primary-active, rgba(45, 90, 39, 0.12)) !important;
  color: var(--primary-color, #2D5A27) !important;
  font-weight: 600 !important;
}

body.dark-theme .chapter-item.active {
  background-color: var(--primary-active, rgba(91, 168, 82, 0.22)) !important;
  color: var(--primary-color, #5BA852) !important;
}

.chapter-item.active::before {
  content: "" !important;
  position: absolute !important;
  left: 3px !important;
  top: 18% !important;
  height: 64% !important;
  width: 3.5px !important;
  border-radius: 4px !important;
  background-color: var(--primary-color, #2D5A27) !important;
}

body.dark-theme .chapter-item.active::before {
  background-color: var(--primary-color, #5BA852) !important;
}

/* 章节主内容容器与等宽数字对齐 */
.chapter-item-main {
  display: flex !important;
  align-items: flex-start !important;
  gap: 8px !important;
  min-width: 0 !important;
  flex: 1 1 auto !important;
}

.chapter-index-num {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace) !important;
  font-size: 11.5px !important;
  font-weight: 600 !important;
  color: var(--text-subtle, #8A9E88) !important;
  min-width: 20px !important;
  line-height: 1.45 !important;
  letter-spacing: -0.2px !important;
  font-variant-numeric: tabular-nums !important;
  padding-top: 1px !important;
  flex-shrink: 0 !important;
}

.chapter-item.active .chapter-index-num {
  color: var(--primary-color, #2D5A27) !important;
}

body.dark-theme .chapter-item.active .chapter-index-num {
  color: var(--primary-color, #5BA852) !important;
}

/* 章节标题容器（双行悬挂缩进） */
.chapter-title-wrap {
  display: flex !important;
  flex-direction: column !important;
  min-width: 0 !important;
  flex: 1 1 auto !important;
  gap: 2px !important;
}

.chapter-title-text {
  font-size: 13px !important;
  line-height: 1.45 !important;
  color: inherit !important;
  word-break: break-word !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
}

.chapter-item.active .chapter-title-text {
  font-weight: 650 !important;
}

/* 兼容未重构子节点的直接 span 回退 */
.chapter-item > span:first-child:not(.chapter-item-main) {
  min-width: 0 !important;
  flex: 1 1 auto !important;
  line-height: 1.45 !important;
}

/* 统一各页面微徽章与目录计数 */
.sidebar-badges {
  display: flex !important;
  gap: 4px !important;
  align-items: center !important;
  flex-shrink: 0 !important;
}

.directory-index {
  font-family: var(--font-mono, ui-monospace, monospace) !important;
  font-variant-numeric: tabular-nums !important;
}

/* Sidebar Footer & Sleek License Card */
.sidebar-footer {
  margin-top: auto !important;
  padding: 6px 12px 8px !important;
  border-top: 1px solid var(--border-color, rgba(45, 90, 39, 0.08)) !important;
  background: var(--sidebar-bg, transparent) !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0 !important;
}

.sidebar-license-card {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 6px !important;
  padding: 4px 10px !important;
  min-height: 30px !important;
  border-radius: 999px !important;
  background: var(--panel-bg, #FFFFFF) !important;
  border: 1px solid var(--border-color, rgba(45, 90, 39, 0.08)) !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03) !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
  user-select: none !important;
}

body.dark-theme .sidebar-license-card {
  background: var(--panel-bg, #1A2419) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

.sidebar-license-card:hover {
  border-color: rgba(217, 119, 6, 0.35) !important;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(217, 119, 6, 0.04) 100%) !important;
  transform: translateY(-1px) !important;
}

.license-card-left {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  min-width: 0 !important;
  flex: 1 !important;
}

.license-avatar-badge {
  width: 20px !important;
  height: 20px !important;
  border-radius: 6px !important;
  background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%) !important;
  color: #B45309 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  box-shadow: 0 1px 2px rgba(217, 119, 6, 0.12) !important;
}

body.dark-theme .license-avatar-badge {
  background: linear-gradient(135deg, #78350F 0%, #92400E 100%) !important;
  color: #FCD34D !important;
}

.license-avatar-badge svg {
  width: 12px !important;
  height: 12px !important;
}

.license-vip-title {
  font-size: 11.5px !important;
  font-weight: 700 !important;
  color: var(--text-main, #1e293b) !important;
  white-space: nowrap !important;
}

.license-dot-sep {
  color: var(--text-muted, #94a3b8) !important;
  font-size: 10px !important;
  user-select: none !important;
}

.license-days-sub {
  font-size: 11px !important;
  color: var(--text-muted, #64748b) !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.sidebar-license-card.is-vip .license-vip-title {
  color: #b45309 !important;
}

body.dark-theme .sidebar-license-card.is-vip .license-vip-title {
  color: #fbbf24 !important;
}

.sidebar-license-card.is-expired .license-avatar-badge {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #ef4444 !important;
}

.license-card-arrow {
  color: var(--text-muted, #94a3b8) !important;
  width: 13px !important;
  height: 13px !important;
  flex-shrink: 0 !important;
  transition: transform 0.15s ease !important;
}

.sidebar-license-card:hover .license-card-arrow {
  color: #B45309 !important;
  transform: translateX(2px) !important;
}

.sidebar-toggle-trigger svg {
  width: 15px !important;
  height: 15px !important;
  stroke-width: 2.2 !important;
}

/* 3. Transparent Floating Sidebar Trigger in Fullscreen/Immersive Modes */
body.fullscreen-mode-active .sidebar-toggle-trigger,
body.flashcard-immersive .sidebar-toggle-trigger,
body.mastery-immersive .sidebar-toggle-trigger {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--text-muted, #64748b) !important;
  opacity: 0.65;
}

body.fullscreen-mode-active .sidebar-toggle-trigger:hover,
body.flashcard-immersive .sidebar-toggle-trigger:hover,
body.mastery-immersive .sidebar-toggle-trigger:hover {
  opacity: 1;
}

/* 4. Mobile Top Bar Menu Button width reduction & Flashcard Immersive Spacing */
@media (max-width: 768px) {
  .top-bar {
    grid-template-columns: 26px minmax(0, 1fr) auto !important;
    gap: 1.5px !important;
  }

  .top-bar .toggle-btn,
  .top-bar #menu-btn,
  .top-bar #exam-menu-btn,
  .top-bar #open-prescription-sidebar,
  .top-bar #open-excipient-sidebar {
    flex: 0 0 26px !important;
    width: 26px !important;
    min-width: 26px !important;
    height: 100% !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
  }

  .top-bar #menu-btn svg,
  .top-bar #menu-btn i {
    width: 20px !important;
    height: 16px !important;
  }

  /* Flashcard Immersive Fullscreen Tight Spacing */
  body.flashcard-page.flashcard-immersive .flashcards-container {
    padding: max(4px, env(safe-area-inset-top)) 4px max(4px, env(safe-area-inset-bottom)) !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
  }

  body.flashcard-page.flashcard-immersive .flashcards-active-area {
    width: 100% !important;
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    height: 100% !important;
    min-height: 0 !important;
  }

  body.flashcard-page.flashcard-immersive .card-scene-wrapper {
    width: 100% !important;
    flex: 1 1 auto !important;
    padding-inline: 2px !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
  }

  body.flashcard-page.flashcard-immersive .card-scene {
    width: 100% !important;
    flex: 1 1 auto !important;
    height: 100% !important;
    max-height: none !important;
    min-height: 0 !important;
  }

  body.flashcard-page.flashcard-immersive .flashcard {
    height: 100% !important;
    min-height: 0 !important;
  }

  body.flashcard-page.flashcard-immersive .card-face {
    height: 100% !important;
    padding: 14px 12px !important;
  }

  body.flashcard-page.flashcard-immersive .card-bottom-controls {
    margin-top: 2px !important;
    margin-bottom: max(2px, env(safe-area-inset-bottom)) !important;
    flex-shrink: 0 !important;
  }
}

@media (max-width: 768px) {
  html.touch-study-device body.flashcard-page .flashcard.is-definition-mode .card-face.card-front,
  body.flashcard-page .flashcard.is-definition-mode .card-face.card-front,
  body.flashcard-page .flashcard.is-definition-mode .card-front {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  html.touch-study-device body.flashcard-page .flashcard.is-definition-mode .definition-answer-content,
  body.flashcard-page .flashcard.is-definition-mode .definition-answer-content {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
}

/* 5. Clean Modal Header when account sync is embedded */
.settings-modal:has(.account-sync-card) .modal-header {
  border-bottom: none !important;
  padding-bottom: 0 !important;
}

.settings-modal:has(.account-sync-card) .modal-header h3 {
  font-size: 1.15rem !important;
  font-weight: 700 !important;
  color: var(--text-main, #1e293b) !important;
}


/* Mobile Navigation & Mindmap Toolbar Cleanups (v2.19) */

/* 1. Hide learning square in top tabs on mobile to keep top bar clean */
@media (max-width: 768px) {
  .learning-square-top-tab {
    display: none !important;
  }
}

/* 2. Unified circular transparent top-bar buttons (Theme & User Avatar) */
.top-bar-right .theme-btn,
.top-bar-right .settings-btn,
.top-bar-right .account-sync-btn,
.top-bar-right .account-profile-trigger {
  width: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  height: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 50% !important;
  background: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
}

.top-bar-right .theme-btn svg,
.top-bar-right .theme-btn i {
  width: 22px !important;
  height: 22px !important;
  min-width: 22px !important;
  min-height: 22px !important;
}

.top-bar-right .settings-btn svg,
.top-bar-right .settings-btn i,
.top-bar-right .account-sync-btn svg,
.top-bar-right .account-sync-btn i {
  width: 25px !important;
  height: 25px !important;
  min-width: 25px !important;
  min-height: 25px !important;
  stroke-width: 2.2 !important;
}

.top-bar-right .account-sync-avatar,
.top-bar .account-sync-avatar {
  width: 32px !important;
  min-width: 32px !important;
  max-width: 32px !important;
  height: 32px !important;
  min-height: 32px !important;
  max-height: 32px !important;
  border-radius: 50% !important;
  font-size: 1.05rem !important;
  font-weight: 850 !important;
  display: inline-grid !important;
  place-items: center !important;
  line-height: 1 !important;
}

/* 3. Mindmap Bottom Toolbar Collapse / Expand Button: Pure transparent icon, enlarged, textured subtle purple */
#toggle-actions-collapse-btn {
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  min-height: 44px !important;
  border-radius: 50% !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  color: #8b5cf6 !important;
  opacity: 0.88;
  cursor: pointer !important;
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), color 0.18s ease, opacity 0.18s ease !important;
}

#toggle-actions-collapse-btn svg {
  width: 24px !important;
  height: 24px !important;
  min-width: 24px !important;
  min-height: 24px !important;
  stroke-width: 2.3 !important;
  stroke: currentColor !important;
  transition: transform 0.25s ease !important;
}

#toggle-actions-collapse-btn:hover {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #7c3aed !important;
  opacity: 1;
  transform: scale(1.15) !important;
}

#toggle-actions-collapse-btn:active {
  transform: scale(0.92) !important;
  opacity: 0.75;
}

.mindmap-actions.actions-collapsed,
body.fullscreen-mode-active .mindmap-actions.actions-collapsed {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  padding: 0 !important;
  width: 44px !important;
  min-width: 44px !important;
  height: 44px !important;
  overflow: visible !important;
}

body.dark-theme #toggle-actions-collapse-btn {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #c4b5fd !important;
  opacity: 0.9;
}

body.dark-theme #toggle-actions-collapse-btn:hover {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #ddd6fe !important;
  opacity: 1;
}

body.dark-theme .mindmap-actions.actions-collapsed,
body.dark-theme.fullscreen-mode-active .mindmap-actions.actions-collapsed {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* 药事法规·时政新规名解排版优化：彻底去除背景色块、流式排版、杜绝横向溢出 */
body.flashcard-page .current-affairs-term-answer,
.current-affairs-term-answer {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
}

body.flashcard-page .current-affairs-term-answer p,
.current-affairs-term-answer p {
  text-indent: 0 !important;
  margin: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow-wrap: break-word !important;
  word-break: break-word !important;
  line-height: 1.85 !important;
}

body.flashcard-page .current-affairs-term-answer .term-full-name,
body.flashcard-page .current-affairs-term-answer .term-definition,
body.flashcard-page .current-affairs-term-answer .term-note,
.current-affairs-term-answer .term-full-name,
.current-affairs-term-answer .term-definition,
.current-affairs-term-answer .term-note {
  color: var(--text-main, #1e293b) !important;
  background: transparent !important;
  background-color: transparent !important;
  border: none !important;
  border-left: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
  max-width: 100% !important;
  line-height: 1.85 !important;
}

body.flashcard-page .current-affairs-term-answer .term-note,
.current-affairs-term-answer .term-note {
  color: var(--text-muted, #64748b) !important;
}

body.flashcard-page .current-affairs-term-answer .term-key-points,
.current-affairs-term-answer .term-key-points {
  display: flex !important;
  flex-direction: column !important;
  gap: 6px !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
}

body.flashcard-page .current-affairs-term-answer .term-key-points p,
.current-affairs-term-answer .term-key-points p {
  font-weight: 800 !important;
}

body.flashcard-page .current-affairs-term-answer .term-key-points ul,
.current-affairs-term-answer .term-key-points ul {
  margin: 0 !important;
  padding-left: 1.25em !important;
  list-style: disc !important;
  max-width: 100% !important;
}

body.flashcard-page .current-affairs-term-answer .term-key-points li,
.current-affairs-term-answer .term-key-points li {
  margin: 0 0 6px !important;
  max-width: 100% !important;
  overflow-wrap: break-word !important;
  word-break: break-word !important;
}

/* 时政新规名词解释：去除所有内联背景色块与多余边框，纯净自然文本排版 */
body.flashcard-page .current-affairs-term-answer span[style*="color"],
.current-affairs-term-answer span[style*="color"],
body.flashcard-page .current-affairs-term-answer strong,
.current-affairs-term-answer strong,
body.flashcard-page .current-affairs-term-answer b,
.current-affairs-term-answer b {
  background: transparent !important;
  background-color: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

body.dark-theme .current-affairs-term-answer .term-full-name,
body.dark-theme .current-affairs-term-answer .term-definition,
body.dark-theme .current-affairs-term-answer .term-note,
body.dark-theme .current-affairs-term-answer span[style*="color"] {
  background: transparent !important;
  background-color: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

body.flashcard-page .definition-page-source {
  max-width: min(100%, 760px) !important;
  white-space: normal !important;
  text-align: center !important;
  line-height: 1.45 !important;
}

body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .main-content,
body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .single-mode-container,
body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .flashcards-container {
  height: auto !important;
  min-height: 100dvh !important;
  max-height: none !important;
  overflow: visible !important;
}

body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .single-mode-container {
  padding-bottom: 42px !important;
}

body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .flashcards-active-area {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  align-self: flex-start !important;
  overflow: visible !important;
}

body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .card-scene-wrapper {
  width: min(100%, 1060px) !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  align-items: flex-start !important;
  padding-inline: clamp(8px, 2.2vw, 24px) !important;
  overflow: visible !important;
}

body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .card-scene,
body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .flashcard,
body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .flashcard .card-face.card-front {
  position: relative !important;
  inset: auto !important;
  width: min(100%, 1000px) !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  flex: 0 1 1000px !important;
  align-self: flex-start !important;
  overflow: visible !important;
}

body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .flashcard.is-current-affairs-guide-mode .definition-answer-box,
body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .flashcard.is-current-affairs-guide-mode .definition-answer-content {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
}

body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .floating-nav-btn {
  top: 220px !important;
}

.current-affairs-guide-source p {
  margin-bottom: 8px !important;
}


.current-affairs-source-link {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: fit-content !important;
  color: #ffffff !important;
  background: #166534 !important;
  border-radius: 999px !important;
  padding: 7px 14px !important;
  font-weight: 800 !important;
  text-decoration: none !important;
  box-shadow: 0 6px 18px rgba(22, 101, 52, 0.18) !important;
}

.current-affairs-source-link:hover {
  background: #14532d !important;
}

/* 2026-09-06 时政法规导读最终展开：外层页面也允许自然下拉 */
html:has(body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive)),
body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) {
  height: auto !important;
  min-height: 100dvh !important;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .app-container {
  height: auto !important;
  min-height: 100dvh !important;
  max-height: none !important;
  overflow: visible !important;
}

body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .card-scene {
  max-height: none !important;
}

/* 2026-09-06 修正：时政导读固定应用外壳，只让正文区滚动，避免侧边栏目录被压扁 */
html.current-affairs-guide-root,
html:has(body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive)),
body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) {
  height: calc(100dvh / var(--study-page-zoom, 1)) !important;
  min-height: 0 !important;
  max-height: calc(100dvh / var(--study-page-zoom, 1)) !important;
  overflow: hidden !important;
}

body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .app-container {
  height: calc(100dvh / var(--study-page-zoom, 1)) !important;
  min-height: 0 !important;
  max-height: calc(100dvh / var(--study-page-zoom, 1)) !important;
  overflow: hidden !important;
  align-items: stretch !important;
}

body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .sidebar {
  height: 100% !important;
  min-height: 0 !important;
  max-height: 100% !important;
  align-self: stretch !important;
  overflow: visible !important;
}

body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .chapter-list-container {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .main-content {
  height: 100% !important;
  min-height: 0 !important;
  max-height: 100% !important;
  overflow: hidden !important;
}

body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .single-mode-container {
  flex: 1 1 auto !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch !important;
}

body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .flashcards-container,
body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .flashcards-active-area {
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  overflow: visible !important;
}

body.flashcard-page.current-affairs-guide-view:not(.flashcard-immersive) .flashcards-active-area {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;
}

/* 2026-09-06 时政新规侧栏：短标题 + 日期标签，避免目录过长挤成正文 */
body.flashcard-page .chapter-item.chapter-item-compact {
  align-items: flex-start !important;
  padding: 10px 12px !important;
  margin-bottom: 8px !important;
  line-height: 1.35 !important;
  border: 1px solid transparent !important;
}

body.flashcard-page .chapter-item.chapter-item-compact:hover {
  transform: translateX(2px) !important;
  border-color: rgba(46, 125, 50, 0.16) !important;
}

body.flashcard-page .chapter-item.chapter-item-compact.active {
  background: linear-gradient(135deg, rgba(221, 238, 222, 0.96), rgba(232, 244, 233, 0.9)) !important;
  border-color: rgba(46, 125, 50, 0.18) !important;
  box-shadow: inset 3px 0 0 rgba(46, 125, 50, 0.45) !important;
}

body.flashcard-page .chapter-item-label {
  display: flex !important;
  min-width: 0 !important;
  flex: 1 1 auto !important;
  flex-direction: column !important;
  gap: 4px !important;
}

body.flashcard-page .chapter-item-title-line {
  display: block !important;
  min-width: 0 !important;
  color: var(--text-main) !important;
  font-size: 0.9rem !important;
  font-weight: 650 !important;
  letter-spacing: 0 !important;
  line-height: 1.35 !important;
}

body.flashcard-page .chapter-item-date-line {
  display: inline-flex !important;
  width: fit-content !important;
  max-width: 100% !important;
  align-items: center !important;
  border-radius: 999px !important;
  background: rgba(46, 125, 50, 0.08) !important;
  color: #2e7d32 !important;
  font-size: 0.72rem !important;
  font-weight: 750 !important;
  line-height: 1.2 !important;
  padding: 3px 8px !important;
  white-space: nowrap !important;
}

body.flashcard-page .chapter-item.chapter-item-compact.active .chapter-item-title-line {
  color: #1b5e20 !important;
  font-weight: 800 !important;
}

body.flashcard-page .chapter-item.chapter-item-compact.active .chapter-item-date-line {
  background: rgba(46, 125, 50, 0.14) !important;
  color: #1b5e20 !important;
}

body.dark-theme.flashcard-page .chapter-item-date-line {
  background: rgba(134, 239, 172, 0.12) !important;
  color: #86efac !important;
}

body.dark-theme.flashcard-page .chapter-item.chapter-item-compact.active .chapter-item-title-line,
body.dark-theme.flashcard-page .chapter-item.chapter-item-compact.active .chapter-item-date-line {
  color: #bbf7d0 !important;
}

/* 2026-09-12 闪卡背面排版优化：页码归入答案底部自然居中，释放卡片底部死白，让答案完整展示 */
html.touch-study-device body.flashcard-page .flashcard.is-flipped .card-face.card-back,
body.flashcard-page .flashcard.is-flipped .card-face.card-back {
  justify-content: flex-start !important;
  overflow: hidden !important;
  padding-top: 12px !important;
  padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important;
}

html.touch-study-device body.flashcard-page .flashcard.is-flipped .card-answer-text-container,
body.flashcard-page .flashcard.is-flipped .card-answer-text-container {
  display: flex !important;
  flex-direction: column !important;
  position: relative !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
  max-height: 100% !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding-bottom: 4px !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
}

html.touch-study-device body.flashcard-page .flashcard.is-flipped .card-answer-text,
body.flashcard-page .flashcard.is-flipped .card-answer-text {
  max-height: none !important;
  overflow: visible !important;
}

body.flashcard-page .card-page-source:not([hidden]) {
  position: static !important;
  display: inline-flex !important;
  align-self: center !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  transform: none !important;
  z-index: 1 !important;
  margin: 6px auto 2px !important;
  max-width: calc(100% - 24px) !important;
  pointer-events: auto !important;
}

.card-answer-text.textbook-answer {
  --textbook-level-top: #C71585;
  --textbook-level-mid: #7C3AED;
  --textbook-level-deep: #F59E0B;
}

.card-answer-text.textbook-answer .material-point-no-level-1,
.card-answer-text.textbook-answer .material-point-level-1 > .material-point-body > .material-point-title,
.card-answer-text.textbook-answer .answer-paragraph-level-1 > .answer-inline-marker,
.card-answer-text.textbook-answer .answer-paragraph-level-1 {
  color: var(--textbook-level-top) !important;
  font-weight: 820;
}

.card-answer-text.textbook-answer .material-point-no-level-2,
.card-answer-text.textbook-answer .material-point-level-2 > .material-point-body > .material-point-title,
.card-answer-text.textbook-answer .answer-paragraph-level-2 > .answer-inline-marker,
.card-answer-text.textbook-answer .answer-paragraph-level-2 {
  color: var(--textbook-level-mid) !important;
  font-weight: 800;
}

.card-answer-text.textbook-answer .material-point-no-level-3,
.card-answer-text.textbook-answer .material-point-level-3 > .material-point-body > .material-point-title,
.card-answer-text.textbook-answer .answer-paragraph-level-3 > .answer-inline-marker,
.card-answer-text.textbook-answer .answer-paragraph-level-3 {
  color: var(--textbook-level-deep) !important;
  font-weight: 780;
}

.card-answer-text.textbook-answer .textbook-point-list > li:not(:has(> .answer-structure-label)):not(:has(> strong)):not(:has(> b)) {
  color: var(--textbook-level-top) !important;
  font-weight: 820;
}

.card-answer-text.textbook-answer .textbook-point-list > li > strong:first-child,
.card-answer-text.textbook-answer .textbook-point-list > li > b:first-child {
  color: var(--textbook-level-top) !important;
  font-weight: 820;
}

.card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list > li:not(:has(> .answer-structure-label)):not(:has(> strong)):not(:has(> b)),
.card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li:not(:has(> .answer-structure-label)):not(:has(> strong)):not(:has(> b)) {
  color: var(--textbook-level-mid) !important;
  font-weight: 800;
}

.card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list > li > strong:first-child,
.card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list > li > b:first-child,
.card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li > strong:first-child,
.card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li > b:first-child {
  color: var(--textbook-level-mid) !important;
  font-weight: 800;
}

.card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list > li > .textbook-subpoint-list > li:not(:has(> .answer-structure-label)):not(:has(> strong)):not(:has(> b)),
.card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li > .textbook-subpoint-list > li:not(:has(> .answer-structure-label)):not(:has(> strong)):not(:has(> b)) {
  color: var(--textbook-level-deep) !important;
  font-weight: 780;
}

.card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list > li > .textbook-subpoint-list > li > strong:first-child,
.card-answer-text.textbook-answer .answer-section-block > .textbook-subpoint-list > li > .textbook-subpoint-list > li > b:first-child,
.card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li > .textbook-subpoint-list > li > strong:first-child,
.card-answer-text.textbook-answer .textbook-point-list > li > .textbook-subpoint-list > li > .textbook-subpoint-list > li > b:first-child {
  color: var(--textbook-level-deep) !important;
  font-weight: 780;
}

@media (max-width: 768px) {
  html.touch-study-device body.flashcard-page .flashcard.is-flipped .card-face.card-back,
  body.flashcard-page .flashcard.is-flipped .card-face.card-back {
    padding-top: 10px !important;
    padding-bottom: calc(6px + env(safe-area-inset-bottom)) !important;
  }

  body.flashcard-page .card-page-source:not([hidden]) {
    margin-top: 6px !important;
    max-width: calc(100% - 20px) !important;
  }
}
