/* 公共样式：CSS 变量、重置、通用组件 - 深邃星空蓝 + 流光金主题 */
:root {
  color-scheme: light;
  /* 清爽白底主题色（金色点缀保留） */
  --primary: #1e40af;
  --primary-dark: #1e3a8a;
  --primary-light: #3b82f6;
  --accent: #b45309;
  --accent-glow: rgba(180, 120, 20, 0.25);
  --accent-dark: #92400e;
  --accent-light: #f59e0b;

  --bg-gradient-start: #f8fafc;
  --bg-gradient-mid: #f1f5f9;
  --bg-gradient-end: #e2e8f0;

  --bg: #f5f7fa;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-body: #f8fafc;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --text: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.1);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --shadow-glow: 0 4px 20px rgba(180, 120, 20, 0.18);
  --shadow-glow-intense: 0 8px 30px rgba(180, 120, 20, 0.25);

  /* 圆角 */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  
  /* 间距 */
  --sidebar-width: 220px;
  --header-height: 56px;
  
  /* 动画 */
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  background: #f5f7fa;
  /* 滚动模型保持浏览器默认（视口滚动）。
     FIX: 之前的 scroll-behavior:smooth / overscroll-behavior:none / overflow-y:auto 组合
     在部分 Edge 版本上会导致鼠标滚轮完全失效（页面有内容但滚不动）。
     改用 overflow-x:clip 裁剪横向溢出——它不会把 html/body 变成滚动容器，兼容性最稳。 */
  overflow-x: clip;
  overscroll-behavior-y: none;
  /* 跨文档视图过渡（方案4）：MPA 页面切换时旧页淡入淡出新页，掩盖白屏。
     浏览器（Chrome/Edge 126+）不支持时自动忽略，零风险回退。
     需要跳转前后两个文档都加载了本规则（common.css 全站引入，天然满足）。 */
  view-transition-name: root;
}

/* 启用 MPA 跨文档视图过渡 */
@view-transition {
  navigation: auto;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Source Han Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-gradient-start);
  background: linear-gradient(180deg, var(--bg-gradient-start) 0%, var(--bg-gradient-mid) 50%, var(--bg-gradient-end) 100%);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: clip;
}

/* 动态星空背景 - 第一层：密集小星星（白底主题已隐藏） */
body::before {
  display: none;
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(2px 2px at 20px 30px, rgba(255,255,255,0.9), transparent),
    radial-gradient(1px 1px at 40px 70px, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 90px 40px, rgba(255,255,255,0.7), transparent),
    radial-gradient(1px 1px at 160px 120px, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 230px 80px, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 300px 150px, rgba(255,255,255,0.35), transparent),
    radial-gradient(2px 2px at 350px 50px, rgba(255,255,255,0.8), transparent),
    radial-gradient(1px 1px at 420px 200px, rgba(255,255,255,0.3), transparent),
    radial-gradient(1px 1px at 500px 100px, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 600px 180px, rgba(255,255,255,0.35), transparent),
    radial-gradient(2px 2px at 100px 200px, rgba(212, 175, 55, 0.7), transparent),
    radial-gradient(1px 1px at 450px 80px, rgba(212, 175, 55, 0.5), transparent),
    radial-gradient(1px 1px at 200px 180px, rgba(212, 175, 55, 0.6), transparent),
    radial-gradient(1px 1px at 550px 220px, rgba(212, 175, 55, 0.4), transparent),
    radial-gradient(1px 1px at 700px 60px, rgba(255,255,255,0.6), transparent),
    radial-gradient(1px 1px at 800px 140px, rgba(255,255,255,0.4), transparent),
    radial-gradient(2px 2px at 280px 250px, rgba(212, 175, 55, 0.5), transparent),
    radial-gradient(1px 1px at 650px 300px, rgba(255,255,255,0.5), transparent);
  background-repeat: repeat;
  background-size: 900px 350px;
  animation: none;
  will-change: auto;
  pointer-events: none;
  z-index: -3;
}

/* 第二层：稀疏大星星（白底主题已隐藏） */
body::after {
  display: none;
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(4px 4px at 150px 100px, rgba(255,255,255,0.4), transparent),
    radial-gradient(3px 3px at 320px 160px, rgba(255,255,255,0.3), transparent),
    radial-gradient(4px 4px at 480px 60px, rgba(255,255,255,0.35), transparent),
    radial-gradient(3px 3px at 120px 240px, rgba(255,255,255,0.2), transparent),
    radial-gradient(4px 4px at 580px 140px, rgba(255,255,255,0.25), transparent),
    radial-gradient(3px 3px at 280px 220px, rgba(255,255,255,0.22), transparent),
    radial-gradient(4px 4px at 380px 40px, rgba(212, 175, 55, 0.4), transparent),
    radial-gradient(3px 3px at 650px 180px, rgba(212, 175, 55, 0.3), transparent),
    radial-gradient(4px 4px at 80px 160px, rgba(212, 175, 55, 0.35), transparent),
    radial-gradient(5px 5px at 750px 200px, rgba(255,255,255,0.28), transparent),
    radial-gradient(3px 3px at 420px 280px, rgba(255,255,255,0.2), transparent),
    radial-gradient(4px 4px at 180px 300px, rgba(212, 175, 55, 0.3), transparent);
  background-repeat: repeat;
  background-size: 1000px 400px;
  animation: none;
  will-change: auto;
  pointer-events: none;
  z-index: -3;
}

/* 星星闪烁动画（已禁用，保持颜色不变但静态） */
@keyframes twinkle {
  0%, 100% { opacity: 1; }
  50% { opacity: 1; }
}

/* 星星漂浮动画（已禁用） */
@keyframes floatStars {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(0, 0); }
  50% { transform: translate(0, 0); }
  75% { transform: translate(0, 0); }
}

/* 流星动画层（已禁用） */
@keyframes shootingStar {
  0% {
    transform: translateX(-100%) translateY(0) rotate(-45deg);
    opacity: 0;
  }
  70% {
    opacity: 0;
  }
  100% {
    transform: translateX(-100%) translateY(0) rotate(-45deg);
    opacity: 0;
  }
}

/* 页面切换淡入动画 - 隐藏内容直到 CSS 加载完成，防止无样式闪烁 */
.page-fade {
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 页面切换退出动画 */
.page-fade-out {
  animation: fadeOut 0.3s ease;
}
@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* 衬线体标题 - 优雅字体对比 */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Noto Serif SC', 'STSong', 'SimSun', 'Source Han Serif SC', 'Georgia', serif;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text);
  text-shadow: 0 2px 20px rgba(0,0,0,0.4);
}

h1 { font-size: 40px; }
h2 { font-size: 32px; }
h3 { font-size: 24px; }
h4 { font-size: 20px; }
h5 { font-size: 18px; }
h6 { font-size: 16px; }

/* 无衬线体正文 - 清晰可读性 */
p, span, a, li, button, input, select, textarea {
  font-family: 'PingFang SC', 'Microsoft YaHei', 'Source Han Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #fff; text-shadow: 0 0 20px var(--accent-glow); }

/* 毛玻璃卡片效果 - 增强版 */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px) saturate(200%);
  -webkit-backdrop-filter: blur(20px) saturate(200%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.glass-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(212, 175, 55, 0.08),
    rgba(255, 255, 255, 0.03),
    transparent
  );
  transition: left 0.8s ease;
  pointer-events: none;
}

.glass-card:hover::before {
  left: 100%;
}

.glass-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* 通用按钮 - 悬浮发光效果 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 24px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition-normal);
  background: var(--bg-card);
  color: var(--text);
  position: relative;
  overflow: hidden;
  font-weight: 500;
}

/* 按钮流光效果 */
.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(212, 175, 55, 0.3),
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.6s ease;
  pointer-events: none;
}

.btn:hover::before {
  left: 100%;
}

/* 按钮悬浮光晕扩散 */
.btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(212, 175, 55, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.8s ease, height 0.8s ease;
  pointer-events: none;
}

.btn:hover::after {
  width: 500px;
  height: 500px;
}

.btn:hover {
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-glow);
  border-color: rgba(212, 175, 55, 0.4);
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: var(--bg-gradient-start);
  border-color: var(--accent);
  font-weight: 700;
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 100%);
  box-shadow: var(--shadow-glow-intense);
  border-color: var(--accent-light);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--danger);
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
}

.btn-success {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--success);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background: var(--bg-card);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-sm { padding: 6px 14px; font-size: 12px; }

/* 表单元素 */
input, select, textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: #ffffff;
  color: var(--text);
  transition: all var(--transition-fast);
}

/* 下拉框样式修复 - 深色主题适配 */
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  color-scheme: light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 44px;
}

select option {
  background: #ffffff;
  color: #1e293b;
  padding: 12px 16px;
  font-size: 14px;
}

select option:hover {
  background: #eff6ff;
  color: #1e40af;
}

select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), 0 0 30px rgba(212, 175, 55, 0.25);
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), 0 0 30px rgba(212, 175, 55, 0.25);
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text);
  font-size: 13px;
}

/* Toast 提示 */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 16px 28px;
  border-radius: var(--radius);
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text);
  z-index: 9999;
  opacity: 0;
  transform: translateY(-30px);
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-color: rgba(16, 185, 129, 0.3); background: rgba(16, 185, 129, 0.08); }
.toast-error { border-color: rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.08); }
.toast-info { border-color: rgba(59, 130, 246, 0.3); background: rgba(59, 130, 246, 0.08); }

/* 模态框 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  visibility: visible;
  transition: all var(--transition-normal);
}

.modal-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal {
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  transform: scale(1);
  transition: transform var(--transition-normal);
}

.modal-overlay.hidden .modal {
  transform: scale(0.9);
}

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

.modal-header h3 { 
  font-size: 20px; 
  color: var(--accent);
  font-family: 'Noto Serif SC', 'STSong', serif;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent-glow);
}

.modal-body { padding: 28px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 28px;
  border-top: 1px solid var(--border);
}

.form-group { margin-bottom: 20px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* 流光动画 */
@keyframes flowLight {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.flow-light {
  background: linear-gradient(90deg, var(--accent), #fff, var(--accent));
  background-size: 200% 100%;
  animation: flowLight 3s linear infinite;
}

/* 悬浮发光效果 */
.glow-hover {
  transition: box-shadow var(--transition-normal);
}

.glow-hover:hover {
  box-shadow: 0 0 40px var(--accent-glow);
}

/* 进度条 */
.progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-light) 100%);
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px var(--accent-glow);
}

/* 分隔线 */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 20px 0;
}

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.03);
}

::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(212, 175, 55, 0.5);
}

/* ============ 全局增强：按钮/表单/布局统一 ============ */

/* 按钮尺寸补充 */
.btn-xs { padding: 4px 10px; font-size: 11px; border-radius: 6px; }
.btn-lg { padding: 14px 32px; font-size: 16px; }

/* 按钮变体补充 */
.btn-warning {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.25);
}
.btn-warning:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--warning);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
}

.btn-info {
  background: rgba(59, 130, 246, 0.12);
  color: var(--info);
  border-color: rgba(59, 130, 246, 0.25);
}
.btn-info:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--info);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

/* 按钮组 */
.btn-group {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* 表单网格 */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* 表单内联组 */
.form-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.3;
}
.empty-state .empty-text {
  font-size: 15px;
}

/* 加载状态 */
.loading-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(212, 175, 55, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 章节标题 */
.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  padding-left: 12px;
  border-left: 3px solid var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 工具栏 */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ============ 全局手机端防溢出 ============ */
html {
  overflow-x: hidden;
  max-width: 100vw;
}

body {
  max-width: 100vw;
  overflow-x: hidden;
}

/* 所有元素不允许超出视口宽度 */
*, *::before, *::after {
  max-width: 100%;
}

/* 表格容器允许横向滚动 */
.table-wrapper, .table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* flex/grid 容器允许子元素收缩 */
.flex-container, .stats-grid, .form-grid, .form-grid-2, .form-grid-3,
.btn-group, .toolbar, .page-actions, .search-box, .table-toolbar {
  min-width: 0;
}

/* 图片和媒体自适应 */
img, video, canvas, svg {
  max-width: 100%;
  height: auto;
}

/* pre/code 不溢出 */
pre {
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* ============ 手机端响应式增强 ============ */
@media (max-width: 768px) {
  /* 按钮在手机端稍小 */
  .btn { padding: 9px 16px; font-size: 13px; }
  .btn-sm { padding: 7px 12px; font-size: 12px; }
  .btn-lg { padding: 12px 24px; font-size: 15px; }

  /* 页面标题缩小 */
  .page-header { 
    flex-direction: column; 
    align-items: stretch; 
    gap: 12px; 
    margin-bottom: 20px;
  }
  .page-header h2 { font-size: 20px; letter-spacing: 1px; }
  .page-actions { 
    justify-content: stretch; 
    width: 100%;
  }
  .page-actions .btn { flex: 1; }

  /* 内容区 padding 收缩 */
  .content { padding: 14px; }
  .card-body { padding: 16px; }

  /* 表单网格变单列 */
  .form-grid, .form-grid-2, .form-grid-3 {
    grid-template-columns: 1fr;
  }
  .form-row { grid-template-columns: 1fr; }

  /* 工具栏垂直排列 */
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-left, .toolbar-right { width: 100%; }

  /* 搜索框全宽 */
  .search-box { width: 100%; }
  .search-box input { width: 100%; }

  /* 表格最小宽度，允许滚动 */
  table { min-width: 500px; }
  table th, table td { padding: 10px 12px; font-size: 12px; }

  /* 弹窗全宽 */
  .modal { width: 94%; max-height: 88vh; }
  .modal-body { padding: 16px; }
  .modal-header { padding: 16px; }
  .modal-header h3 { font-size: 17px; }
  .modal-footer { padding: 14px 16px; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; min-width: 100px; }

  /* 章节标题缩小 */
  .section-title { font-size: 14px; margin-bottom: 12px; }

  /* 统计卡片两列 */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .stat-card { padding: 16px; gap: 12px; }
  .stat-icon { width: 48px; height: 48px; font-size: 22px; border-radius: 12px; }
  .stat-info h3 { font-size: 22px; }
  .stat-info p { font-size: 11px; }

  /* 标签缩小 */
  .tag { padding: 3px 8px; font-size: 11px; }

  /* 上传区缩小 */
  .upload-area { padding: 24px 16px; }
  .upload-area .upload-icon { font-size: 36px; }

  /* 表单输入框在手机端更大（防止 iOS 缩放） */
  input, select, textarea {
    font-size: 16px;
    padding: 10px 14px;
  }

  /* select 在手机端允许原生选择器 */
  select {
    -webkit-appearance: auto;
    appearance: auto;
    background-image: none;
    padding-right: 14px;
  }
}

@media (max-width: 480px) {
  /* 超小屏幕：统计卡片单列 */
  .stats-grid { grid-template-columns: 1fr; }

  /* 按钮组全宽 */
  .btn-group { width: 100%; }
  .btn-group .btn { flex: 1; }

  /* D1：表格工具栏所有按钮/输入全宽堆叠，48px点击高度 */
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .table-toolbar > * {
    width: 100% !important;
  }
  .table-toolbar .btn {
    min-height: 48px;
    font-size: 15px;
  }
  .table-toolbar .search-box input {
    min-height: 48px;
    font-size: 16px;
  }
  .search-box {
    width: 100% !important;
    gap: 8px;
  }
  .search-box > * {
    width: 100%;
  }

  /* 弹窗按钮组：垂直堆叠，每个按钮全宽+48px高 */
  .modal-footer {
    flex-direction: column-reverse;
    gap: 10px;
    padding: 14px 16px;
  }
  .modal-footer .btn {
    width: 100%;
    min-height: 48px;
    font-size: 15px;
  }

  /* 顶部栏进一步缩小 */
  .topbar-title { font-size: 14px; letter-spacing: 0; }

  /* 分页按钮缩小 */
  .pagination button { padding: 8px 12px; font-size: 12px; }
  .pagination .page-info { font-size: 12px; }
}

/* ============ B1：触屏设备去掉 300ms 延迟 ============ */
@media (hover: none) and (pointer: coarse) {
  .btn,
  .sidebar-nav a,
  .pagination button,
  .tab-item,
  .course-module,
  .album-item,
  .countdown-item,
  .notice-item,
  .mobile-menu-toggle,
  .sidebar-close,
  .sidebar-overlay,
  .modal .close,
  .modal-footer .btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
}

/* ============ B2：按钮/导航按压反馈 ============ */
@media (hover: none) and (pointer: coarse) {
  .btn:active {
    transform: scale(0.96) !important;
    filter: brightness(0.9) !important;
    transition: transform 0.06s ease-out !important;
  }
  .sidebar-nav a:active {
    background: rgba(212, 175, 55, 0.15) !important;
  }
  .album-item:active,
  .notice-item:active,
  .course-module:active,
  .countdown-item:active {
    transform: scale(0.98);
    filter: brightness(0.92);
  }
  .pagination button:active {
    transform: scale(0.93);
  }
  .mobile-menu-toggle:active span {
    background: var(--accent) !important;
  }
}

/* ============ A4：弹窗按钮扩大分离（手机端 768px 以下） ============ */
@media (max-width: 768px) {
  .sidebar-close {
    display: block !important;
  }
}

/* ============ B3 + B4：仅针对 OPPO/vivo 等自带浏览器降级 ============
   html.bad-webview 这个类由 common.js 按 UA 注入
   - 关闭 backdrop-filter（性能杀手）
   - 关闭所有伪元素流光动画
   - 关闭星空 twinkle/floatStars/shootingStar 动画
   - 简化 box-shadow / transition 速度
==================================================================== */
html.bad-webview .sidebar,
html.bad-webview .topbar,
html.bad-webview .card,
html.bad-webview .stat-card,
html.bad-webview .table-wrapper,
html.bad-webview .modal,
html.bad-webview .album-item,
html.bad-webview .notice-item,
html.bad-webview .course-modules,
html.bad-webview .countdown-item,
html.bad-webview .upload-area,
html.bad-webview .mobile-menu-toggle,
html.bad-webview .sidebar-overlay,
html.bad-webview .balance-card,
html.bad-webview .modal-backdrop {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

html.bad-webview .sidebar {
  background: rgba(248, 250, 252, 0.98) !important;
}
html.bad-webview .topbar {
  background: rgba(255, 255, 255, 0.97) !important;
}
html.bad-webview .card,
html.bad-webview .stat-card,
html.bad-webview .table-wrapper,
html.bad-webview .album-item,
html.bad-webview .notice-item,
html.bad-webview .course-modules,
html.bad-webview .countdown-item,
html.bad-webview .upload-area {
  background: #ffffff !important;
}
html.bad-webview .modal {
  background: rgba(248, 250, 252, 0.99) !important;
}

/* B4：禁用伪元素流光（这些动画在坏WebView持续消耗GPU） */
html.bad-webview .card::before,
html.bad-webview .stat-card::before,
html.bad-webview .stat-card::after,
html.bad-webview .album-item::before,
html.bad-webview .sidebar-nav a::before,
html.bad-webview .sidebar-nav a::after,
html.bad-webview .btn::before,
html.bad-webview .btn::after,
html.bad-webview .course-module::before {
  display: none !important;
}

/* 简化星空动画 */
html.bad-webview body::before,
html.bad-webview body::after {
  animation: none !important;
}

/* 过渡速度统一加快 */
html.bad-webview * {
  transition-duration: 0.12s !important;
  animation-duration: 0.2s !important;
}

/* 去掉 hover 上浮（坏WebView会在触摸时触发） */
html.bad-webview .stat-card:hover,
html.bad-webview .card:hover,
html.bad-webview .album-item:hover,
html.bad-webview .course-module:hover,
html.bad-webview .notice-item:hover,
html.bad-webview .countdown-item:hover,
html.bad-webview .btn:hover {
  transform: none !important;
}

/* 简化阴影，减少重绘 */
html.bad-webview .card,
html.bad-webview .stat-card,
html.bad-webview .table-wrapper,
html.bad-webview .modal {
  box-shadow: 0 2px 6px rgba(0,0,0,0.4) !important;
}
html.bad-webview .sidebar {
  box-shadow: 4px 0 20px rgba(0,0,0,0.5) !important;
}

/* ============ 平板端布局（html.tablet 由 common.js 注入） ============ */
/* 触摸设备 769-1024px：增大触摸目标，避免误触 */
html.tablet body { font-size: 15px; }
html.tablet .btn { min-height: 44px; padding: 10px 18px; }
html.tablet .sidebar-nav a { min-height: 44px; padding: 14px 20px; font-size: 15px; }
html.tablet .stat-card { cursor: default; }
html.tablet .card { cursor: default; }

/* OPPO 平板横屏（宽度 >1024px 触摸设备）：触摸目标稍大 */
@media (min-width: 1025px) and (pointer: coarse) {
  .btn { min-height: 40px; }
  .sidebar-nav a { min-height: 42px; }
}
