/* ==========================================================================
   Bob 學習資訊中心 (Bob Learning Information Center - BIC)
   純原生 CSS 設計系統 - 現代科技風與極致閱讀體驗
   ========================================================================== */

:root {
  /* 品牌色系 */
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.12);
  --primary-glow: rgba(99, 102, 241, 0.35);
  
  --secondary: #06b6d4;
  --secondary-glow: rgba(6, 182, 212, 0.35);

  --accent: #ec4899;
  --accent-light: rgba(236, 72, 153, 0.12);

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  /* 深色主題（預設現代暗色系） */
  --bg-main: #0b0f19;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-hover: rgba(26, 34, 52, 0.9);
  --bg-surface: #131b2e;
  --bg-elevated: #1e293b;
  --bg-glass: rgba(15, 23, 42, 0.75);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-focus: rgba(99, 102, 241, 0.6);

  --text-main: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #0f172a;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 24px rgba(99, 102, 241, 0.25);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 淺色主題覆寫 */
[data-theme="light"] {
  --bg-main: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-hover: rgba(255, 255, 255, 0.98);
  --bg-surface: #ffffff;
  --bg-elevated: #f1f5f9;
  --bg-glass: rgba(255, 255, 255, 0.82);

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.15);
  --border-focus: rgba(99, 102, 241, 0.6);

  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #f8fafc;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 24px rgba(99, 102, 241, 0.15);
}

/* 全域重設與基礎樣式 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* 自訂捲軸 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.45);
}

/* 動態光暈背景裝飾 */
.ambient-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.ambient-blob-1 {
  position: absolute;
  top: -150px;
  left: 20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.16) 0%, rgba(99, 102, 241, 0) 70%);
  filter: blur(80px);
  animation: floatSlow 20s infinite alternate ease-in-out;
}

.ambient-blob-2 {
  position: absolute;
  top: 300px;
  right: -100px;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.14) 0%, rgba(6, 182, 212, 0) 70%);
  filter: blur(70px);
  animation: floatSlow 25s infinite alternate-reverse ease-in-out;
}

@keyframes floatSlow {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, 30px) scale(1.08); }
  100% { transform: translate(-30px, -20px) scale(0.95); }
}

/* 主容器 */
.app-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.content-wrapper {
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
}

/* 導覽列 (Navbar) */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 16px 0;
  transition: all var(--transition-normal);
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
  cursor: pointer;
}

.brand-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
  transition: transform var(--transition-fast);
}

.brand-link:hover .brand-icon-wrapper {
  transform: scale(1.06) rotate(-3deg);
}

.brand-text-group {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #f8fafc 30%, #94a3b8 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .brand-title {
  background: linear-gradient(135deg, #0f172a 30%, #475569 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 按鈕系統 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-glow);
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-ghost:hover {
  background: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-strong);
}

.btn-icon-only {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* 搜尋與篩選列 */
.search-filter-section {
  padding-top: 36px;
  margin-bottom: 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.search-bar-wrapper {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  height: 52px;
  padding: 0 48px 0 48px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

.search-input:focus {
  border-color: var(--primary);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--primary-light), var(--shadow-md);
}

.search-icon-left {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 1.1rem;
}

.search-clear-btn {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  font-size: 0.9rem;
  display: none;
}

.search-clear-btn:hover {
  color: var(--text-main);
}

/* 科目分類選項卡 (Category Tabs) */
.category-tabs {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
}

.category-tabs::-webkit-scrollbar {
  display: none;
}

.category-tab-btn {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.category-tab-btn:hover {
  background: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-strong);
}

.category-tab-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 10px var(--primary-glow);
}

/* 筆記卡片網格 */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 24px;
  margin-bottom: 64px;
}

.note-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: all var(--transition-normal);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.note-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.note-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.note-category-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.note-difficulty-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.badge-intro {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.badge-medium {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}

.badge-advanced {
  background: rgba(236, 72, 153, 0.15);
  color: #f472b6;
}

.note-title {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 10px;
  color: var(--text-main);
  transition: color var(--transition-fast);
}

.note-card:hover .note-title {
  color: #818cf8;
}

.note-description {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 18px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.note-tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.note-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.meta-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 空搜尋結果提示 */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px dashed var(--border-subtle);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

/* ==========================================================================
   筆記全螢幕沉浸式閱讀介面 (Reader View / Modal)
   ========================================================================== */
.reader-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  justify-content: center;
  align-items: flex-start;
  padding: 30px 20px;
  overflow-y: auto;
}

.reader-modal-overlay.active {
  display: flex;
}

.reader-container {
  width: 100%;
  max-width: 1080px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  position: relative;
  margin-bottom: 40px;
  animation: modalEnter 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalEnter {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 頂部閱讀進度條 */
.reading-progress-bar {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: transparent;
  z-index: 10;
}

.reading-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6366f1, #06b6d4, #ec4899);
  transition: width 0.1s ease;
}

.reader-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 30px;
  border-bottom: 1px solid var(--border-subtle);
}

.reader-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.reader-content-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 36px;
  padding: 36px 36px 56px 36px;
}

@media (max-width: 900px) {
  .reader-content-layout {
    grid-template-columns: 1fr;
  }
  .reader-toc-sidebar {
    display: none;
  }
}

/* 目錄邊欄 */
.reader-toc-sidebar {
  position: sticky;
  top: 80px;
  align-self: flex-start;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  padding-left: 20px;
  border-left: 1px solid var(--border-subtle);
}

.toc-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toc-link {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  line-height: 1.4;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.toc-link:hover {
  color: #818cf8;
}

/* Markdown 排版樣式 (Prose) */
.markdown-body {
  color: var(--text-main);
  line-height: 1.8;
  font-size: 1.05rem;
}

.markdown-body h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 24px;
  line-height: 1.3;
}

.markdown-body h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 36px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.markdown-body h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 24px;
  margin-bottom: 12px;
}

.markdown-body p {
  margin-bottom: 16px;
}

.markdown-body blockquote {
  border-left: 4px solid var(--primary);
  padding: 12px 18px;
  margin: 20px 0;
  background: var(--primary-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.markdown-body ul, .markdown-body ol {
  padding-left: 24px;
  margin-bottom: 18px;
}

.markdown-body li {
  margin-bottom: 8px;
}

.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: rgba(148, 163, 184, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  color: #38bdf8;
}

.markdown-body pre {
  margin: 20px 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: #111827 !important;
}

.markdown-body pre code {
  display: block;
  padding: 18px 20px;
  overflow-x: auto;
  font-size: 0.92rem;
  line-height: 1.6;
  background: transparent !important;
  color: #f1f5f9;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.95rem;
}

.markdown-body th, .markdown-body td {
  border: 1px solid var(--border-subtle);
  padding: 12px 16px;
  text-align: left;
}

.markdown-body th {
  background: var(--bg-elevated);
  font-weight: 700;
}

.markdown-body tr:nth-child(even) {
  background: rgba(148, 163, 184, 0.04);
}

/* 程式碼區塊標頭 (含複製按鈕) */
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1f2937;
  padding: 8px 16px;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.copy-code-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.copy-code-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

/* 筆記互動列 (讀畢打卡) */
.reader-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 40px;
  padding: 20px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

/* 頁尾 Footer (極簡) */
.footer {
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  padding: 24px 0;
  text-align: center;
}

.footer-content {
  display: flex;
  justify-content: center;
  align-items: center;
}

.footer-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ==========================================================================
   滿版筆記 SVG 檢視器專用樣式 (垂直覆蓋在整個 body 上方，實心深灰/黑底完全不透視)
   ========================================================================== */
.fullscreen-viewer-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background-color: #0b0f19; /* 實心深灰底，完全覆蓋不透視原本 UI */
  z-index: 9999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

.fullscreen-viewer-overlay.active {
  display: flex;
  opacity: 1;
}

/* 滿版頂部導航列 Header (實心不透明) */
.fullscreen-viewer-header {
  position: relative;
  z-index: 20;
  min-height: 64px;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background-color: #0f172a; /* 實心深色，避免任何透明度漏光 */
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* Header 左側資訊 */
.viewer-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.viewer-note-title {
  font-size: 1.12rem;
  font-weight: 700;
  color: #f8fafc;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.viewer-note-date {
  font-size: 0.8rem;
  color: #94a3b8;
  background: #1e293b;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Header 右側操作區 */
.viewer-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.viewer-download-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.download-btn {
  font-size: 0.82rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #1e293b;
  color: #cbd5e1;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.download-btn:hover {
  background: #334155;
  color: var(--primary-light);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.15);
}

.viewer-header-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 2px;
}

/* 右上角關閉按鈕：精密幾何居中、位置穩定不飄移 */
.viewer-close-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #1e293b;
  color: #94a3b8;
  cursor: pointer;
  box-sizing: border-box;
  flex-shrink: 0;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.viewer-close-icon {
  display: block;
  width: 16px;
  height: 16px;
  stroke: currentColor;
  pointer-events: none;
  transform-origin: center center;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.viewer-close-btn:hover {
  background: rgba(239, 68, 68, 0.18);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.45);
  transform: scale(1.06); /* 按鈕外框中心穩定不動，僅等比微放大 */
}

.viewer-close-btn:hover .viewer-close-icon {
  transform: rotate(90deg); /* 內部向量交叉圖示在自身幾何中心平滑旋轉 */
}

.viewer-close-btn:active {
  transform: scale(0.94);
}

/* 滿版底下 SVG 預覽畫布區 (實心深黑灰底，100% 不透視) */
.fullscreen-viewer-body {
  flex: 1;
  position: relative;
  width: 100%;
  height: calc(100vh - 64px);
  overflow: hidden;
  user-select: none;
  background-color: #0b0f19; /* 實心深灰底，徹底消除透視 */
  /* 科技感深邃微網格，提供平移與縮放參照座標感 */
  background-image:
    radial-gradient(circle at 50% 50%, rgba(56, 189, 248, 0.05) 0%, transparent 75%),
    linear-gradient(to right, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 100% 100%, 32px 32px, 32px 32px;
}

/* 舞台與拖曳平移區 */
.viewer-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  overflow: hidden;
  touch-action: none;
}

.viewer-stage.grabbing {
  cursor: grabbing !important;
}

/* 承載 SVG 內容的容器，透過 translate & scale 變形 */
.viewer-content {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.viewer-content.smooth-transition {
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* SVG 筆記本體樣式：立體陰影與高質感卡紙外框 */
.viewer-content svg,
.viewer-content img {
  display: block;
  max-width: none;
  max-height: none;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  filter: drop-shadow(0 15px 30px rgba(0, 0, 0, 0.35));
}

[data-theme="light"] .viewer-content svg,
[data-theme="light"] .viewer-content img {
  background: #ffffff;
  box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.08);
}

/* 載入狀態指示 */
.viewer-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 30px 40px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 10;
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 500;
  pointer-events: none;
}

.viewer-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* 懸浮控制工具列 (右下角) */
.viewer-float-controls {
  position: absolute;
  bottom: 24px;
  right: 24px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: 30px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .viewer-float-controls {
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

.viewer-ctrl-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.15rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
}

.viewer-ctrl-btn:hover {
  background: var(--bg-card-hover);
  color: var(--primary-light);
  transform: scale(1.1);
}

.viewer-ctrl-btn:active {
  transform: scale(0.95);
}

.viewer-zoom-val {
  width: auto;
  min-width: 60px;
  padding: 0 10px;
  border-radius: 18px;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--primary-light);
}

/* 左下角提示徽章 */
.viewer-hint-badge {
  position: absolute;
  bottom: 24px;
  left: 24px;
  z-index: 15;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
  animation: fadeIn 0.4s ease-out;
}

[data-theme="light"] .viewer-hint-badge {
  background: rgba(255, 255, 255, 0.8);
}

/* 響應式優化 */
@media (max-width: 768px) {
  .fullscreen-viewer-header {
    padding: 10px 14px;
    flex-wrap: wrap;
    min-height: auto;
  }

  .viewer-header-left {
    width: 100%;
    order: 1;
    margin-bottom: 6px;
  }

  .viewer-header-right {
    width: 100%;
    order: 2;
    justify-content: space-between;
  }

  .fullscreen-viewer-body {
    height: calc(100vh - 100px);
  }

  .viewer-hint-badge {
    display: none;
  }

  .download-btn {
    padding: 4px 8px;
    font-size: 0.76rem;
  }
}

/* 管理員視窗尺寸 */
.modal-dialog-sm {
  max-width: 440px;
  width: 90%;
}

.modal-dialog-md {
  max-width: 680px;
  width: 95%;
  max-height: 92vh;
  overflow-y: auto;
}

/* 上傳區塊與拖曳樣式 */
.form-select {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  outline: none;
}

.drop-zone-all {
  border: 2px dashed rgba(99, 102, 241, 0.4);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  background: rgba(99, 102, 241, 0.05);
  cursor: pointer;
  transition: all var(--transition-normal);
  margin-bottom: 20px;
}

.drop-zone-all.dragover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--primary);
  transform: scale(1.01);
}

.file-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.file-picker-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.file-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.badge-svg {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-png {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-json {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

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

.file-status.selected {
  color: #10b981;
  font-weight: 600;
}

.file-picker-label {
  display: block;
  text-align: center;
  padding: 8px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
}

.file-picker-label:hover {
  border-color: var(--primary);
  color: var(--text-main);
  background: var(--primary-light);
}


/* 響應式微調 */
@media (max-width: 768px) {
  .notes-grid {
    grid-template-columns: 1fr;
  }
  .reader-modal-overlay {
    padding: 10px 8px;
  }
  .reader-header {
    padding: 16px;
  }
  .reader-content-layout {
    padding: 20px 16px 40px 16px;
  }
  .hide-on-mobile {
    display: none !important;
  }
}
