/* ===================================================
   AI 学情诊断系统 — 全局样式 (main.css)
   Mobile-first · Education Tech Style
=================================================== */

/* ---------- CSS Variables ---------- */
:root {
  --primary: #4F8EF7;
  --primary-dark: #3A7AE4;
  --primary-light: #EEF4FF;
  --secondary: #06C4A0;
  --secondary-light: #E6FAF6;
  --error: #FF6B6B;
  --error-light: #FFF0F0;
  --warning: #FF9F43;
  --warning-light: #FFF4E6;
  --purple: #9B59B6;
  --purple-light: #F5EEF8;
  --text-1: #1A1A2E;
  --text-2: #4A5568;
  --text-3: #9CA3AF;
  --bg: #EFF3FE;
  --card: #FFFFFF;
  --border: #E8EDFD;
  --shadow-sm: 0 2px 10px rgba(79, 142, 247, 0.08);
  --shadow-md: 0 4px 20px rgba(79, 142, 247, 0.14);
  --shadow-lg: 0 8px 32px rgba(79, 142, 247, 0.18);
  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --header-h: 56px;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

img { max-width: 100%; display: block; }
a { text-decoration: none; color: inherit; }

/* ---------- Layout ---------- */
.page-wrapper {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: var(--bg);
}

/* ---------- App Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
}

.header-inner {
  max-width: 480px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 24px;
  line-height: 1;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.logo-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.2px;
}

.logo-tag {
  font-size: 11px;
  color: var(--primary);
  font-weight: 500;
}

/* ---------- Mode Banner & Key Config ---------- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-config-key {
  padding: 6px 12px;
  border-radius: 20px;
  background: white;
  color: var(--text-2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-config-key:active {
  background: var(--bg);
}

.mode-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: #FFF7E6;
  border: 1px solid #FFE7BA;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 12px;
}

.mode-banner.active-mode {
  background: #E6F7FF;
  border-color: #BAE7FF;
}

.mode-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #FA8C16;
  margin-right: 8px;
  flex-shrink: 0;
}

.mode-banner.active-mode .mode-status-dot {
  background: #1890FF;
}

.mode-text {
  color: #D46B08;
  font-weight: 500;
  flex: 1;
}

.mode-banner.active-mode .mode-text {
  color: #096DD9;
}

.btn-mode-set {
  padding: 3px 10px;
  background: #FA8C16;
  color: white;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 8px;
  white-space: nowrap;
}

.mode-banner.active-mode .btn-mode-set {
  background: #1890FF;
}

/* Key Modal */
.key-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.key-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 60, 0.6);
  backdrop-filter: blur(8px);
}

.key-modal-card {
  position: relative;
  z-index: 1;
  background: white;
  border-radius: var(--radius);
  padding: 24px 20px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

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

.key-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1);
}

.key-modal-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #F0F2F5;
  color: var(--text-3);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.key-modal-desc {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 16px;
}

.key-input-wrap {
  margin-bottom: 20px;
}

.key-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 6px;
}

.key-input {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-xs);
  border: 1.5px solid var(--border);
  font-size: 14px;
  outline: none;
  font-family: monospace;
  box-sizing: border-box;
}

.key-input:focus {
  border-color: var(--primary);
}

.key-hint {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 8px;
  line-height: 1.5;
}

.key-modal-btns {
  display: flex;
  gap: 10px;
}

.btn-key-cancel {
  flex: 1;
  padding: 11px;
  border-radius: var(--radius-xs);
  background: #F4F6FB;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
}

.btn-key-save {
  flex: 2;
  padding: 11px;
  border-radius: var(--radius-xs);
  background: var(--primary);
  color: white;
  font-size: 14px;
  font-weight: 700;
}

.btn-key-save:active {
  background: var(--primary-dark);
}

.btn-demo {
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(79, 142, 247, 0.25);
  font-size: 12.5px;
  font-weight: 700;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-demo:active { background: var(--primary); color: white; transform: scale(0.97); }

/* ---------- Main Content ---------- */
.main-content {
  padding: 0 16px 40px;
}

/* ---------- Hero Section ---------- */
.hero {
  padding: 28px 0 20px;
  text-align: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--secondary);
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.7; }
}

.hero-title {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.25;
  color: var(--text-1);
  letter-spacing: -0.5px;
  margin-bottom: 10px;
}

.hero-title .highlight {
  font-style: normal;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-desc {
  font-size: 14px;
  color: var(--text-3);
  line-height: 1.5;
}

/* ---------- Upload Section ---------- */
.upload-section {
  margin-bottom: 20px;
}

.upload-zone {
  background: var(--card);
  border-radius: var(--radius);
  border: 2px dashed #C5D6FC;
  padding: 32px 20px 24px;
  text-align: center;
  transition: all 0.25s;
  box-shadow: var(--shadow-sm);
}

.upload-zone:active { border-color: var(--primary); background: var(--primary-light); }

.upload-svg {
  width: 80px;
  height: 80px;
  margin: 0 auto 14px;
}

.upload-main-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 6px;
}

.upload-sub-text {
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 20px;
}

.upload-btn-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 22px;
  border-radius: 25px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}

.cam-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 14px rgba(79, 142, 247, 0.4);
}

.cam-btn:active { transform: scale(0.96); box-shadow: none; }

.gal-btn {
  background: white;
  color: var(--primary);
  border: 1.5px solid var(--border);
}

.gal-btn:active { background: var(--primary-light); transform: scale(0.96); }

/* ---------- Multi-Image Upload & Grid ---------- */
.upload-multi-wrap {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.multi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.multi-title-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.multi-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
}

.multi-count-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

.btn-clear-all {
  font-size: 13px;
  color: var(--text-3);
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-clear-all:active {
  color: var(--error);
  background: var(--error-light);
}

/* Image Grid */
.image-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 360px) {
  .image-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.grid-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #F4F7FC;
  border: 1.5px solid var(--border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
}

.grid-item-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: pointer;
}

/* Page order tag */
.grid-page-tag {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(26, 26, 46, 0.8);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  backdrop-filter: blur(4px);
  pointer-events: none;
  z-index: 2;
}

/* Remove button */
.grid-remove-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #FF4D4F;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 2px 6px rgba(255, 77, 79, 0.4);
  border: 1.5px solid white;
  transition: transform 0.15s, background 0.15s;
  z-index: 3;
}

.grid-remove-btn:active {
  transform: scale(0.88);
  background: #E03134;
}

/* Page order sort bar (bottom of thumbnail) */
.grid-sort-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.4) 70%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 6px 4px;
  z-index: 2;
}

.btn-move {
  background: rgba(255, 255, 255, 0.25);
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  backdrop-filter: blur(2px);
  transition: all 0.15s;
}

.btn-move:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.btn-move:not(:disabled):active {
  background: var(--primary);
  transform: scale(0.9);
}

.grid-item-order {
  color: white;
  font-size: 10px;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

/* Add Card in Grid */
.grid-add-card {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  border: 2px dashed #C5D6FC;
  background: #F8FAFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  color: var(--primary);
  transition: all 0.2s;
}

.grid-add-card:active {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: scale(0.97);
}

.grid-add-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
}

.grid-add-text {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
}

/* Append action buttons */
.append-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.btn-append {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
}

.append-cam {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(79, 142, 247, 0.2);
}

.append-cam:active {
  background: #DDE8FF;
}

.append-gal {
  background: #F3F5FA;
  color: var(--text-2);
  border: 1px solid var(--border);
}

.append-gal:active {
  background: #E5E9F2;
}

.multi-tip {
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
  line-height: 1.5;
}

/* Lightbox Modal */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
}

.lightbox-content {
  position: relative;
  z-index: 1;
  max-width: 92vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

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

.lightbox-tag {
  color: white;
  font-size: 14px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.2);
  padding: 3px 12px;
  border-radius: 12px;
}

.lightbox-close {
  color: white;
  font-size: 20px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-img-wrap {
  overflow: auto;
  border-radius: var(--radius-sm);
  max-height: 75vh;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.lightbox-img-wrap img {
  width: 100%;
  height: auto;
  display: block;
}

/* Legacy single-upload preview (kept for fallback) */
.upload-preview {
  display: none;
}

/* ---------- Feature Pills ---------- */
.features-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 20px;
  scrollbar-width: none;
}

.features-row::-webkit-scrollbar { display: none; }

.feature-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  background: white;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.feature-pill span:first-child { font-size: 14px; }

/* ---------- CTA Area ---------- */
.cta-area {
  margin-bottom: 20px;
}

.btn-cta {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 17px 24px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary) 0%, #7B61FF 100%);
  color: white;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.3px;
  transition: all 0.25s;
  box-shadow: 0 6px 24px rgba(79, 142, 247, 0.5);
  position: relative;
  overflow: hidden;
}

.btn-cta::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transition: left 0.5s;
}

.btn-cta:not(:disabled):hover::before { left: 100%; }

.btn-cta:disabled {
  background: #D1D9EF;
  box-shadow: none;
  cursor: not-allowed;
  color: #9CA3AF;
}

.btn-cta:not(:disabled):active { transform: scale(0.98); }

.cta-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 10px;
}

/* ---------- Trust Row ---------- */
.trust-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.trust-item {
  font-size: 11.5px;
  color: var(--text-3);
}

.trust-sep {
  color: var(--border);
  font-size: 12px;
}

/* ---------- Loading Overlay ---------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.loading-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 60, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.loading-card {
  position: relative;
  z-index: 1;
  background: white;
  border-radius: var(--radius);
  padding: 36px 28px 28px;
  width: 100%;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 20, 0.3);
}

.spinner-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
}

.spinner-ring {
  position: absolute;
  inset: 0;
  border: 4px solid #EEF4FF;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.spinner-emoji {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 26px;
  animation: brainPulse 2s ease-in-out infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes brainPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.12); }
}

.loading-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 20px;
}

.loading-steps {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.l-step {
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0.3;
  transition: opacity 0.4s, transform 0.4s;
}

.l-step.active { opacity: 1; transform: translateX(2px); }
.l-step.done { opacity: 0.6; }

.l-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.3s;
}

.l-step.active .l-dot { background: var(--primary); animation: dotPulse 1s ease-in-out infinite; }
.l-step.done .l-dot { background: var(--secondary); animation: none; }

@keyframes dotPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.4); }
}

.l-text {
  font-size: 13.5px;
  color: var(--text-2);
  font-weight: 500;
}

.loading-tip {
  font-size: 12px;
  color: var(--text-3);
}

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  pointer-events: none;
}

.toast {
  padding: 12px 22px;
  background: rgba(26, 26, 46, 0.9);
  color: white;
  border-radius: 25px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: rgba(255, 107, 107, 0.95); }
.toast.success { background: rgba(6, 196, 160, 0.95); }

/* ---------- Utilities ---------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
