/* ==========================================================================
   試卷寶 AI (Exam Paper Cleaner) - iOS Apple HIG Design System
   ========================================================================== */

:root {
  /* iOS 經典深色調與玻璃質感色彩 */
  --bg-primary: #000000;
  --bg-secondary: #121214;
  --bg-card: rgba(28, 28, 30, 0.75);
  --bg-card-solid: #1c1c1e;
  --bg-elevated: rgba(44, 44, 46, 0.85);
  --bg-blur: rgba(18, 18, 20, 0.72);
  
  /* Apple 系統標誌色 */
  --accent-blue: #0a84ff;
  --accent-blue-hover: #0071e3;
  --accent-green: #30d158;
  --accent-orange: #ff9f0a;
  --accent-red: #ff453a;
  --accent-purple: #bf5af2;
  --accent-cyan: #64d2ff;
  --gdrive-color: #34a853;
  
  /* 文字階層 */
  --text-primary: #ffffff;
  --text-secondary: rgba(235, 235, 245, 0.65);
  --text-tertiary: rgba(235, 235, 245, 0.35);
  
  /* 邊框與陰影 */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.16);
  --border-accent: rgba(10, 132, 255, 0.35);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
  
  /* 圓角與間距 */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;
  
  /* 安全區域 */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

/* 基本重設 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Noto Sans TC", sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: calc(75px + var(--sab));
  min-height: 100vh;
}

/* ==========================================================================
   Header 導航列
   ========================================================================== */
.ios-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(12px + var(--sat)) 16px 12px 16px;
  background: var(--bg-blur);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
  transition: all 0.3s ease;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0a84ff, #5e5ce6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(10, 132, 255, 0.35);
}

.app-logo svg {
  width: 22px;
  height: 22px;
}

.app-title-group {
  display: flex;
  flex-direction: column;
}

.app-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-ai {
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  background: linear-gradient(135deg, #ff375f, #ff9f0a);
  color: #fff;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.app-subtitle {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

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

.ios-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}

.ios-pill-btn:active {
  transform: scale(0.96);
  background: var(--bg-elevated);
}

.ios-pill-btn.accent {
  background: var(--accent-blue);
  color: #ffffff;
  border: none;
}

.ios-pill-btn.gdrive-pill.connected {
  border-color: rgba(52, 168, 83, 0.4);
  background: rgba(52, 168, 83, 0.15);
  color: #5bb974;
}

.ios-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ios-icon-btn:active {
  transform: scale(0.92);
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.ios-icon-btn svg, .ios-pill-btn svg {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   主容器與 Section 切換
   ========================================================================== */
.app-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

.app-section {
  display: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.app-section.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   多頁面批次管理標籤列 (Multi-Page Bar)
   ========================================================================== */
.multi-page-bar {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 12px;
}

.multi-page-bar.hidden {
  display: none;
}

.multi-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.page-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.page-count-badge svg {
  width: 14px;
  height: 14px;
}

.add-page-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(10, 132, 255, 0.15);
  border: 1px solid var(--border-accent);
  color: var(--accent-cyan);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.add-page-btn:active {
  transform: scale(0.95);
  background: var(--accent-blue);
  color: #fff;
}

.add-page-btn svg {
  width: 13px;
  height: 13px;
}

.page-chips-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.page-chips-scroll::-webkit-scrollbar {
  display: none;
}

.page-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.page-chip.active {
  background: var(--accent-blue);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(10, 132, 255, 0.4);
}

.page-chip .btn-del-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  border: none;
  font-size: 10px;
  cursor: pointer;
  margin-left: 2px;
}

/* ==========================================================================
   Hero 橫幅與卡片
   ========================================================================== */
.hero-banner {
  padding: 20px 16px;
  background: radial-gradient(circle at top right, rgba(10, 132, 255, 0.15), transparent 70%),
              var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-cyan);
  margin-bottom: 8px;
}

.hero-tag svg {
  width: 14px;
  height: 14px;
}

.hero-title {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.4px;
  margin-bottom: 8px;
}

.hero-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ==========================================================================
   操作卡片網格 (Action Grid)
   ========================================================================== */
.action-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.file-input-hidden {
  display: none;
}

.action-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.25, 1, 0.5, 1);
  text-decoration: none;
  color: inherit;
  width: 100%;
  text-align: left;
}

.action-card:hover {
  background: var(--bg-elevated);
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.action-card:active {
  transform: scale(0.98);
}

.card-icon-bubble {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.camera-bubble {
  background: linear-gradient(135deg, #0a84ff, #0056b3);
  color: #fff;
  box-shadow: 0 4px 14px rgba(10, 132, 255, 0.35);
}

.album-bubble {
  background: linear-gradient(135deg, #30d158, #1f8b3a);
  color: #fff;
  box-shadow: 0 4px 14px rgba(48, 209, 88, 0.3);
}

.drive-bubble {
  background: linear-gradient(135deg, #ff9f0a, #d97706);
  color: #fff;
  box-shadow: 0 4px 14px rgba(255, 159, 10, 0.3);
}

.sample-bubble {
  background: linear-gradient(135deg, #bf5af2, #8e24aa);
  color: #fff;
  box-shadow: 0 4px 14px rgba(191, 90, 242, 0.3);
}

.card-icon-bubble svg {
  width: 24px;
  height: 24px;
}

.card-content {
  flex: 1;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.2px;
  margin-bottom: 2px;
}

.card-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.card-arrow {
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
}

.card-arrow svg {
  width: 20px;
  height: 20px;
}

.card-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: rgba(191, 90, 242, 0.2);
  color: #d896ff;
  border: 1px solid rgba(191, 90, 242, 0.3);
}

/* 特色藥丸列 */
.feature-pills-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.feat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.feat-pill svg {
  width: 14px;
  height: 14px;
  color: var(--accent-blue);
}

/* ==========================================================================
   切邊與梯形透視校正 (Crop & Perspective)
   ========================================================================== */
.section-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.toolbar-title {
  font-size: 1rem;
  font-weight: 600;
}

.ios-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: var(--accent-blue);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 8px;
}

.ios-nav-btn.primary {
  color: #fff;
  background: var(--accent-blue);
  padding: 6px 14px;
  border-radius: var(--radius-full);
}

.ios-nav-btn svg {
  width: 16px;
  height: 16px;
}

.crop-editor-wrapper {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
  margin-bottom: 14px;
  touch-action: none;
}

.crop-canvas-container {
  position: relative;
  width: 100%;
  min-height: 380px;
  max-height: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#cropCanvas {
  max-width: 100%;
  max-height: 520px;
  display: block;
  cursor: crosshair;
}

/* 放大鏡 */
.crop-loupe {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  pointer-events: none;
  z-index: 50;
  background: #000;
}

.crop-loupe.hidden {
  display: none;
}

.crop-controls-bar {
  display: flex;
  justify-content: space-around;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 4px;
}

.ios-tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.72rem;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.ios-tool-btn:active, .ios-tool-btn.active {
  color: var(--accent-blue);
  background: rgba(10, 132, 255, 0.12);
}

.ios-tool-btn svg {
  width: 18px;
  height: 18px;
}

/* ==========================================================================
   iOS Segmented Control (分頁切換)
   ========================================================================== */
.ios-segmented-control {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 3px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  gap: 3px;
}

.segment-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 6px;
  border-radius: 11px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.25, 1, 0.5, 1);
  white-space: nowrap;
}

.segment-tab svg {
  width: 14px;
  height: 14px;
}

.segment-tab.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

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

/* ==========================================================================
   Studio 還原工作台
   ========================================================================== */
.studio-preview-box {
  position: relative;
  background: #000;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 14px;
  min-height: 380px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.canvas-viewport {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#mainCanvas {
  max-width: 100%;
  max-height: 480px;
  display: block;
}

#brushCanvas {
  position: absolute;
  top: 0;
  left: 0;
  max-width: 100%;
  max-height: 480px;
  cursor: crosshair;
  touch-action: none;
}

.brush-layer.hidden {
  display: none;
}

.compare-fab {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.compare-fab svg {
  width: 14px;
  height: 14px;
}

/* 濾鏡切換輪播 */
.filter-carousel {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 14px;
  scrollbar-width: none;
}

.filter-carousel::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-chip .chip-icon svg {
  width: 14px;
  height: 14px;
}

.filter-chip.active {
  background: rgba(10, 132, 255, 0.18);
  border-color: var(--accent-blue);
  color: #ffffff;
}

/* 細節調整卡片 */
.tuning-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.slider-group {
  margin-bottom: 12px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.slider-header span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.slider-header svg {
  width: 13px;
  height: 13px;
}

.slider-val {
  color: var(--accent-blue);
  font-weight: 600;
}

.ios-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-elevated);
  outline: none;
}

.ios-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

.manual-eraser-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.ios-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 500;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  cursor: pointer;
}

.ios-chip-btn.active {
  background: var(--accent-red);
  color: #fff;
  border-color: transparent;
}

.ios-chip-btn svg {
  width: 14px;
  height: 14px;
}

.brush-size-box {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.brush-size-box input {
  width: 70px;
}

.ios-big-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}

.ios-big-btn.primary {
  background: var(--accent-blue);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(10, 132, 255, 0.4);
}

.ios-big-btn:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.ios-big-btn svg {
  width: 18px;
  height: 18px;
}

/* ==========================================================================
   AI 題目文字解析視圖
   ========================================================================== */
.ai-header-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 14px;
}

.ai-status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent-green);
}

.pulse-ring {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 0 0 rgba(48, 209, 88, 0.7);
  animation: pulseGreen 2s infinite;
}

@keyframes pulseGreen {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(48, 209, 88, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(48, 209, 88, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(48, 209, 88, 0); }
}

.ai-loading-box {
  text-align: center;
  padding: 40px 20px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

.spinner-ios {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px auto;
}

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

.loading-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.loading-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.ai-results-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: all 0.2s ease;
}

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

.q-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(10, 132, 255, 0.15);
  color: var(--accent-cyan);
}

.q-badge.choice { background: rgba(10, 132, 255, 0.15); color: var(--accent-cyan); }
.q-badge.blank { background: rgba(255, 159, 10, 0.15); color: var(--accent-orange); }
.q-badge.calc { background: rgba(191, 90, 242, 0.15); color: #d896ff; }

.q-body {
  font-size: 0.92rem;
  line-height: 1.6;
  margin-bottom: 12px;
}

.q-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  padding-left: 8px;
}

.q-opt-item {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.q-solution-box {
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid var(--accent-green);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 12px;
}

.sol-answer {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-green);
  margin-bottom: 4px;
}

.sol-detail {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ==========================================================================
   錯題本 (Mistake Notebook)
   ========================================================================== */
.mistake-header-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.box-title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.box-title svg {
  width: 16px;
  height: 16px;
  color: var(--accent-orange);
}

.box-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.mistakes-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mistake-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 69, 58, 0.25);
  border-radius: var(--radius-md);
  padding: 16px;
  position: relative;
}

.mistake-tag {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255, 69, 58, 0.15);
  color: var(--accent-red);
}

/* ==========================================================================
   輸出中心與 Google Drive
   ========================================================================== */
.export-banner {
  text-align: center;
  padding: 20px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.export-icon-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(10, 132, 255, 0.15);
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px auto;
}

.export-icon-circle svg {
  width: 24px;
  height: 24px;
}

.export-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.export-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.export-options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.export-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.gdrive-export-card {
  border-color: rgba(52, 168, 83, 0.35);
  background: linear-gradient(135deg, rgba(52, 168, 83, 0.1), var(--bg-card));
}

.item-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.gdrive-bg {
  background: #34a853;
  color: #fff;
}

.pdf-bg {
  background: #ff453a;
  color: #fff;
}

.item-icon-box svg {
  width: 20px;
  height: 20px;
}

.item-info {
  flex: 1;
}

.item-title {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.item-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.export-status-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(52, 168, 83, 0.15);
  border: 1px solid rgba(52, 168, 83, 0.4);
  border-radius: var(--radius-md);
  color: #5bb974;
}

.export-status-box.hidden {
  display: none;
}

.export-status-box .status-icon svg {
  width: 24px;
  height: 24px;
}

.export-status-box h5 {
  font-size: 0.9rem;
  font-weight: 700;
}

.export-status-box p {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   底部 iOS Tab Bar
   ========================================================================== */
.ios-tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(56px + var(--sab));
  padding-bottom: var(--sab);
  background: var(--bg-blur);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 90;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 0.68rem;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 0;
  transition: all 0.2s ease;
}

.tab-item svg {
  width: 22px;
  height: 22px;
}

.tab-item.active {
  color: var(--accent-blue);
}

.tab-item:active {
  transform: scale(0.92);
}

/* ==========================================================================
   iOS Modal Sheet (設定與授權彈窗)
   ========================================================================== */
.ios-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: opacity 0.3s ease;
}

.ios-modal-backdrop.hidden {
  display: none;
}

.ios-modal-sheet {
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  background: var(--bg-card-solid);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  border-top: 1px solid var(--border-light);
  padding: 12px 20px calc(20px + var(--sab)) 20px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 36px;
  height: 5px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-full);
  margin: 0 auto 12px auto;
}

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

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-title svg {
  width: 20px;
  height: 20px;
  color: var(--accent-blue);
}

.modal-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: none;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.modal-close-btn svg {
  width: 16px;
  height: 16px;
}

.setting-group {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 14px;
}

.group-title {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.group-title svg {
  width: 16px;
  height: 16px;
  color: var(--accent-cyan);
}

.group-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.4;
}

.input-field-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.input-field-box label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.ios-text-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.ios-text-input:focus {
  border-color: var(--accent-blue);
}

.auth-buttons-row {
  display: flex;
  gap: 8px;
}

.ios-btn-fill {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  background: var(--gdrive-color);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.ios-btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--accent-red);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
}

.ios-btn-fill svg, .ios-btn-outline svg {
  width: 16px;
  height: 16px;
}

.info-box .info-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border-subtle);
}

.info-box .info-row:last-child {
  border-bottom: none;
}

.info-lbl {
  color: var(--text-secondary);
}

.badge-zeabur {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(100, 210, 255, 0.2);
  color: var(--accent-cyan);
}

/* ==========================================================================
   Toast 浮動通知
   ========================================================================== */
.ios-toast {
  position: fixed;
  top: calc(70px + var(--sat));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: rgba(30, 30, 32, 0.92);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  z-index: 300;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.ios-toast.hidden {
  opacity: 0;
  transform: translate(-50%, -15px);
  pointer-events: none;
}

.ios-toast svg {
  width: 18px;
  height: 18px;
  color: var(--accent-blue);
}

/* ==========================================================================
   響應式排版 (桌面/平板體驗增強)
   ========================================================================== */
@media (min-width: 768px) {
  body {
    padding-bottom: 20px;
  }
  
  .ios-tab-bar {
    display: none;
  }
  
  .action-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }
  
  .crop-canvas-container {
    min-height: 480px;
  }
}
