/* ========================================
   全域樣式 — 高中數學刷題系統
   ======================================== */

/* CSS 自訂屬性 */
:root {
  /* 主色系 — 深藍紫漸層系統 */
  --primary-h: 230;
  --primary-s: 70%;
  --primary: hsl(var(--primary-h), var(--primary-s), 55%);
  --primary-light: hsl(var(--primary-h), var(--primary-s), 70%);
  --primary-dark: hsl(var(--primary-h), var(--primary-s), 40%);

  /* 強調色 */
  --accent-h: 160;
  --accent: hsl(var(--accent-h), 65%, 50%);
  --accent-light: hsl(var(--accent-h), 65%, 65%);

  /* 語義色 */
  --success: hsl(145, 65%, 45%);
  --success-bg: hsla(145, 65%, 45%, 0.12);
  --danger: hsl(0, 70%, 55%);
  --danger-bg: hsla(0, 70%, 55%, 0.12);
  --warning: hsl(40, 90%, 55%);
  --warning-bg: hsla(40, 90%, 55%, 0.12);
  --info: hsl(210, 70%, 55%);
  --info-bg: hsla(210, 70%, 55%, 0.12);

  /* 背景 */
  --bg-base: #0f1123;
  --bg-surface: #181b36;
  --bg-elevated: #1e2245;
  --bg-hover: #252a54;

  /* 文字 */
  --text-primary: #e8eaf6;
  --text-secondary: #9da5c7;
  --text-muted: #6b73a0;

  /* 邊框 */
  --border: hsla(230, 40%, 50%, 0.2);
  --border-active: hsla(230, 70%, 55%, 0.5);

  /* 陰影 */
  --shadow-sm: 0 2px 8px hsla(230, 50%, 10%, 0.3);
  --shadow-md: 0 4px 16px hsla(230, 50%, 10%, 0.4);
  --shadow-lg: 0 8px 32px hsla(230, 50%, 10%, 0.5);
  --shadow-glow: 0 0 20px hsla(230, 70%, 55%, 0.2);

  /* 圓角 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* 動畫 */
  --transition-fast: 0.15s ease;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);

  /* 間距 */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
}

/* 重設 */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* 基礎 */
html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse at 20% 20%, hsla(230, 60%, 30%, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, hsla(160, 60%, 30%, 0.1) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* ========================================
   導航列
   ======================================== */
.navbar {
  background: hsla(230, 40%, 15%, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: var(--space-md) var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}

.navbar-brand .icon {
  font-size: 1.5rem;
}

.navbar-nav {
  display: flex;
  gap: var(--space-xs);
  list-style: none;
}

.navbar-nav .nav-link {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: var(--transition);
  cursor: pointer;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link.active {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.navbar-nav .nav-link.active {
  background: hsla(230, 70%, 55%, 0.15);
  color: var(--primary-light);
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.navbar-user span {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ========================================
   按鈕
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 2px 12px hsla(var(--primary-h), 70%, 40%, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 4px 20px hsla(var(--primary-h), 70%, 40%, 0.5);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), hsl(145, 65%, 35%));
  color: white;
  box-shadow: 0 2px 12px hsla(145, 65%, 35%, 0.3);
}

.btn-success:hover {
  box-shadow: 0 4px 20px hsla(145, 65%, 35%, 0.5);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), hsl(0, 70%, 40%));
  color: white;
  box-shadow: 0 2px 12px hsla(0, 70%, 40%, 0.3);
}

.btn-danger:hover {
  box-shadow: 0 4px 20px hsla(0, 70%, 40%, 0.5);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary-light);
  background: hsla(230, 70%, 55%, 0.08);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: var(--space-sm) var(--space-md);
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.btn-sm {
  font-size: 0.8rem;
  padding: var(--space-xs) var(--space-md);
}

.btn-lg {
  font-size: 1rem;
  padding: var(--space-md) var(--space-xl);
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ========================================
   卡片
   ======================================== */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  transition: var(--transition);
}

.card:hover {
  border-color: var(--border-active);
  box-shadow: var(--shadow-md);
}

.card-glass {
  background: hsla(230, 30%, 20%, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid hsla(230, 40%, 50%, 0.15);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ========================================
   表單
   ======================================== */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.form-control {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px hsla(var(--primary-h), 70%, 55%, 0.15);
}

.form-control::placeholder {
  color: var(--text-muted);
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239da5c7' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ========================================
   登入頁面
   ======================================== */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-xl);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.5s ease;
}

.login-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.login-header .logo {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  display: block;
}

.login-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-light), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-header p {
  color: var(--text-muted);
  margin-top: var(--space-sm);
  font-size: 0.9rem;
}

.login-error {
  background: var(--danger-bg);
  border: 1px solid hsla(0, 70%, 55%, 0.3);
  color: var(--danger);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: var(--space-md);
  display: none;
}

/* ========================================
   儀表板
   ======================================== */
.dashboard {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-xl);
}

.dashboard-welcome {
  margin-bottom: var(--space-xl);
}

.dashboard-welcome h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: var(--space-sm);
}

.dashboard-welcome p {
  color: var(--text-secondary);
}

/* 統計卡片 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  text-align: center;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-active);
  box-shadow: var(--shadow-glow);
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-card .stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* 單元網格 */
.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-lg);
}

.unit-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.unit-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0;
  transition: var(--transition);
}

.unit-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-active);
  box-shadow: var(--shadow-md);
}

.unit-card:hover::before {
  opacity: 1;
}

.unit-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.unit-card .unit-meta {
  display: flex;
  gap: var(--space-md);
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: var(--space-md);
}

/* 進度條 */
.progress-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
  margin-top: var(--space-sm);
}

.progress-bar .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 3px;
  transition: width 0.5s ease;
}

.progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* ========================================
   答題介面
   ======================================== */
.quiz-container {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--space-xl);
}

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
}

.quiz-progress {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.quiz-progress .current {
  color: var(--primary-light);
  font-weight: 700;
  font-size: 1.2rem;
}

.question-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
  animation: fadeInUp 0.3s ease;
}

.question-meta {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-type {
  background: var(--info-bg);
  color: var(--info);
}

.badge-easy {
  background: var(--success-bg);
  color: var(--success);
}

.badge-medium {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-hard {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge-concept {
  background: hsla(280, 60%, 55%, 0.12);
  color: hsl(280, 60%, 65%);
}

.question-content {
  font-size: 1.05rem;
  line-height: 1.8;
  margin-bottom: var(--space-lg);
  white-space: pre-wrap;
}

.question-content img {
  max-width: 100%;
  max-height: 400px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  margin: var(--space-md) 0;
  display: block;
}

/* 選項 */
.options-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.option-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-elevated);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.95rem;
}

.option-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-active);
}

.option-item.selected {
  border-color: var(--primary);
  background: hsla(var(--primary-h), 70%, 55%, 0.1);
}

.option-item.correct {
  border-color: var(--success);
  background: var(--success-bg);
}

.option-item.wrong {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.option-item input[type="radio"],
.option-item input[type="checkbox"] {
  display: none;
}

.option-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
  transition: var(--transition);
}

.option-item.selected .option-label {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.option-item.correct .option-label {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.option-item.wrong .option-label {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

/* 填空題 */
.fill-input {
  width: 100%;
  margin-bottom: var(--space-md);
}

.fill-input .form-control {
  font-size: 1.1rem;
  padding: var(--space-md);
}

/* 結果顯示 */
.result-banner {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-weight: 600;
  animation: slideIn 0.3s ease;
}

.result-banner.correct {
  background: var(--success-bg);
  border: 1px solid hsla(145, 65%, 45%, 0.3);
  color: var(--success);
}

.result-banner.wrong {
  background: var(--danger-bg);
  border: 1px solid hsla(0, 70%, 55%, 0.3);
  color: var(--danger);
}

.result-banner .icon {
  font-size: 1.3rem;
}

/* 詳解區 */
.solution-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: var(--space-lg);
  margin-top: var(--space-md);
}

.solution-box h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-light);
  margin-bottom: var(--space-sm);
}

.solution-box .solution-content {
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.solution-box .solution-content img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  margin: var(--space-md) 0;
}

/* 答題按鈕區 */
.quiz-actions {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-lg);
  flex-wrap: wrap;
}

/* ========================================
   錯題本 / 複習
   ======================================== */
.review-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: var(--space-xl);
}

.review-header {
  margin-bottom: var(--space-xl);
}

.review-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: var(--space-sm);
}

.review-tabs {
  display: flex;
  gap: var(--space-xs);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  padding: var(--space-xs);
  border: 1px solid var(--border);
  margin-bottom: var(--space-lg);
}

.review-tab {
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: none;
  font-family: inherit;
}

.review-tab.active {
  background: var(--primary);
  color: white;
}

.review-tab:hover:not(.active) {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.review-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.review-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  transition: var(--transition);
}

.review-item:hover {
  border-color: var(--border-active);
}

.review-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
}

.review-item-content {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* ========================================
   管理者介面
   ======================================== */
.admin-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-xl);
}

.admin-header {
  margin-bottom: var(--space-xl);
}

.admin-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: var(--space-sm);
}

.admin-tabs {
  display: flex;
  gap: var(--space-xs);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  padding: var(--space-xs);
  border: 1px solid var(--border);
  margin-bottom: var(--space-xl);
}

.admin-tab {
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: none;
  font-family: inherit;
}

.admin-tab.active {
  background: var(--primary);
  color: white;
}

.admin-tab:hover:not(.active) {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* 表格 */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

th {
  background: var(--bg-elevated);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

tr:hover td {
  background: var(--bg-hover);
}

td .actions {
  display: flex;
  gap: var(--space-xs);
}

/* 對話框 / Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: hsla(0, 0%, 0%, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  animation: fadeInUp 0.3s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-md);
  margin-top: var(--space-xl);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

/* ========================================
   圖片上傳
   ======================================== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-muted);
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: hsla(var(--primary-h), 70%, 55%, 0.05);
  color: var(--primary-light);
}

.upload-zone .icon {
  font-size: 2rem;
  margin-bottom: var(--space-sm);
}

.uploaded-images {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.uploaded-images img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
}

/* ========================================
   Toast 通知
   ======================================== */
.toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: 0.9rem;
  animation: slideInRight 0.3s ease;
  min-width: 300px;
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.error {
  border-left: 4px solid var(--danger);
}

.toast.info {
  border-left: 4px solid var(--info);
}

/* ========================================
   空狀態
   ======================================== */
.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.empty-state p {
  font-size: 1rem;
  margin-bottom: var(--space-lg);
}

/* ========================================
   載入動畫
   ======================================== */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  flex-direction: column;
  gap: var(--space-md);
  color: var(--text-muted);
}

/* ========================================
   動畫
   ======================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(40px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  75% {
    transform: translateX(5px);
  }
}

/* ========================================
   響應式設計
   ======================================== */
@media (max-width: 768px) {
  .navbar {
    padding: var(--space-sm) var(--space-md);
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  .navbar-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    padding-bottom: var(--space-xs);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .unit-grid {
    grid-template-columns: 1fr;
  }

  .quiz-container,
  .review-container,
  .admin-container {
    padding: var(--space-md);
  }

  .question-card {
    padding: var(--space-md);
  }

  .modal {
    width: 95%;
    padding: var(--space-lg);
  }

  .review-tabs,
  .admin-tabs {
    overflow-x: auto;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .quiz-actions {
    flex-direction: column;
  }

  .quiz-actions .btn {
    width: 100%;
  }
}

/* ========================================
   密碼變更對話框
   ======================================== */
.change-password-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: hsla(0, 0%, 0%, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.change-password-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  max-width: 400px;
  width: 90%;
  animation: fadeInUp 0.3s ease;
}

.change-password-card h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: var(--space-sm);
}

.change-password-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: var(--space-lg);
}

/* ========================================
   填充題：拖放數字卡片互動系統
   ======================================== */

/* 答案結構預覽區 */
.fill-interactive { text-align: center; }

.fill-structure {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  padding: var(--space-lg);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  line-height: 1;
  min-height: 60px;
}

.fill-structure .math-char {
  display: inline-flex;
  align-items: center;
  font-family: 'Noto Sans TC', sans-serif;
}

/* CSS 分數排版 */
.fill-structure .math-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 4px;
}
.fill-structure .math-frac .math-num {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-bottom: 3px;
  border-bottom: 2px solid var(--text-primary);
}
.fill-structure .math-frac .math-den {
  display: flex;
  align-items: center;
  gap: 2px;
  padding-top: 3px;
}

/* CSS 根號排版 */
.fill-structure .math-sqrt {
  display: inline-flex;
  align-items: stretch;
  vertical-align: middle;
  margin: 0 2px;
}
.fill-structure .math-sqrt::before {
  content: '√';
  font-size: 1.3em;
  line-height: 1;
}
.fill-structure .math-sqrt-body {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border-top: 2px solid var(--text-primary);
  padding: 2px 4px 0;
}

/* 可拖放空格 */
.drop-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 2px dashed var(--primary);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--primary);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  position: relative;
}
.drop-slot:hover, .drop-slot.drag-over {
  border-color: var(--accent);
  background: hsla(var(--accent-h), 65%, 50%, 0.15);
  transform: scale(1.1);
}
.drop-slot.filled {
  border-style: solid;
  border-color: var(--success);
  background: var(--success-bg);
  color: var(--text-primary);
}
.drop-slot.filled:hover {
  border-color: var(--danger);
  background: var(--danger-bg);
}

/* 數字卡片區 */
.number-cards {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  justify-content: center;
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
}
.number-card {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: 2px solid var(--border-primary);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: grab;
  transition: all 0.2s ease;
  user-select: none;
  -webkit-user-select: none;
}
.number-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.number-card:active, .number-card.selected {
  border-color: var(--accent);
  background: hsla(var(--accent-h), 65%, 50%, 0.2);
  transform: scale(1.05);
  box-shadow: 0 0 12px hsla(var(--accent-h), 65%, 50%, 0.4);
}

.fill-hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  margin-top: var(--space-sm);
}

kbd {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.85em;
  font-family: monospace;
}