/* ============================================
   莱芜学情诊断 · 全局样式
   护眼配色：莫兰迪色系（低饱和度）
   ============================================ */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; }
body {
  background: #f5f1ea;
  color: #2d3a35;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ====== 颜色变量（莫兰迪） ====== */
:root {
  --c-bg: #f5f1ea;
  --c-card: #ffffff;
  --c-primary: #7c9885;
  --c-primary-dark: #4d6b5c;
  --c-accent: #d4a373;
  --c-warn: #c5645a;
  --c-purple: #8b6f9c;
  --c-text: #2d3a35;
  --c-text-2: #4d6b5c;
  --c-text-3: #6b7872;
  --c-text-4: #9aa39d;
  --c-border: #e0d8cc;
  --c-shadow: 0 2px 12px rgba(77, 107, 92, 0.08);
}

/* ====== 通用 ====== */
.container { max-width: 720px; margin: 0 auto; padding: 16px 16px 100px; }
.hidden { display: none !important; }
[aria-busy="true"] { opacity: 0.7; }

/* ====== 顶部条 ====== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(180deg, #ffffff 0%, #f5f1ea 100%);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--c-primary-dark); font-size: 16px; }
.logo {
  display: inline-block; width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-accent) 100%);
  color: #fff; border-radius: 8px;
  text-align: center; line-height: 28px; font-weight: 700;
  font-size: 16px; box-shadow: var(--c-shadow);
}
.user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--c-text-3); }
.user button {
  background: transparent; border: 1px solid var(--c-border);
  color: var(--c-text-3); padding: 6px 12px; border-radius: 14px;
  font-size: 13px; cursor: pointer; min-height: 32px;
}
.user button:hover { background: var(--c-bg); }

/* ====== 底部导航（触控友好） ====== */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: #ffffff;
  border-top: 1px solid var(--c-border);
  display: flex; align-items: stretch; justify-content: space-around;
  padding: 6px 4px calc(env(safe-area-inset-bottom, 0) + 6px);
  box-shadow: 0 -2px 10px rgba(77, 107, 92, 0.05);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; color: var(--c-text-3);
  padding: 6px 0;
  min-height: 48px;   /* 触控区 ≥ 48px */
  font-size: 12px;    /* P1：放大到 12px（之前 11px 过小） */
  transition: color .15s;
}
.nav-item .icon { font-size: 22px; line-height: 1; margin-bottom: 2px; }
.nav-item.active { color: var(--c-primary-dark); font-weight: 600; }
.nav-item:active { background: var(--c-bg); }

/* ====== 卡片 ====== */
.card {
  background: var(--c-card);
  border-radius: 16px;
  padding: 18px 18px 16px;
  margin-bottom: 14px;
  box-shadow: var(--c-shadow);
  border: 1px solid var(--c-border);
}
.card-title {
  font-size: 18px; font-weight: 600; color: var(--c-primary-dark);
  margin-bottom: 4px; display: flex; align-items: center; gap: 8px;
}
.card-subtitle { font-size: 13px; color: var(--c-text-3); margin-bottom: 12px; }

/* ====== 看板卡片 ====== */
.dash-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.dash-card {
  background: #fff; border-radius: 14px; padding: 16px;
  border: 1px solid var(--c-border);
  text-align: center; min-height: 92px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.dash-card .num { font-size: 32px; font-weight: 700; color: var(--c-primary-dark); line-height: 1.2; }
.dash-card .lbl { font-size: 13px; color: var(--c-text-3); margin-top: 4px; }
.dash-card.warn { background: #c5645a14; }
.dash-card.warn .num { color: var(--c-warn); }
.dash-card.accent { background: #d4a37314; }
.dash-card.accent .num { color: #b87e4b; }

/* ====== 表单 ====== */
.form-group { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-label { display: block; font-size: 14px; color: var(--c-text-2); margin-bottom: 6px; font-weight: 500; }
.form-label .req { color: var(--c-warn); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 12px; min-height: 44px;   /* 触控区 ≥ 44px */
  border: 1px solid var(--c-border); border-radius: 10px;
  background: #fff; color: var(--c-text); font-size: 15px;
  transition: border-color .15s;
}
.form-textarea { min-height: 80px; resize: vertical; line-height: 1.5; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(124, 152, 133, 0.15);
}

/* ====== 按钮 ====== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 16px; min-height: 44px; min-width: 44px;    /* 触控区 ≥ 44px */
  border: none; border-radius: 10px;
  background: var(--c-primary); color: #fff; font-size: 15px; font-weight: 500;
  cursor: pointer; text-decoration: none;
  transition: filter .15s, transform .05s;
  user-select: none;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-ghost { background: #fff; color: var(--c-primary-dark); border: 1px solid var(--c-border); }
.btn-ghost:hover { background: var(--c-bg); }
.btn-accent { background: var(--c-accent); color: #fff; }
.btn-danger { background: var(--c-warn); }
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 12px 18px; min-height: 48px; font-size: 16px; }
.btn-sm { padding: 6px 12px; min-height: 36px; min-width: 36px; font-size: 14px; }   /* P1：32px → 36px，44px 在 hover/active 状态 */

.btn-link { background: none; color: var(--c-primary-dark); border: none; padding: 0; min-height: auto; min-width: auto; text-decoration: underline; }

/* ====== 列表项 ====== */
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--c-border);
}
.list-item:last-child { border-bottom: none; }
.list-item .info { flex: 1; min-width: 0; }
.list-item .title { font-weight: 500; color: var(--c-text); }
.list-item .meta { font-size: 13px; color: var(--c-text-3); margin-top: 2px; }

/* ====== 错题项 ====== */
.q-item { padding: 12px 0; border-bottom: 1px solid var(--c-border); }
.q-item:last-child { border-bottom: none; }
.q-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; flex-wrap: wrap; gap: 6px; }
.q-body { font-size: 14px; color: var(--c-text); margin-top: 6px; }

/* ====== Tag ====== */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; line-height: 1.5;
  background: var(--c-border); color: var(--c-text-2);
  margin-right: 4px;
}
.tag-severe { background: #c5645a22; color: var(--c-warn); }
.tag-moderate { background: #d4a37322; color: #b87e4b; }
.tag-mild { background: #b8cdc122; color: var(--c-primary-dark); }
.tag-legacy { background: #8b6f9c22; color: var(--c-purple); }
.tag-new { background: #b8cdc122; color: var(--c-primary-dark); }

/* ====== 弱项排名 ====== */
.weak-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--c-border); }
.weak-item:last-child { border-bottom: none; }
.weak-item .rank {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--c-border); color: var(--c-text-3);
  display: flex; align-items: center; justify-content: center; font-weight: 600;
  flex-shrink: 0;
}
.weak-item .rank.top3 { background: var(--c-warn); color: #fff; }
.weak-item .name { flex: 1; min-width: 0; }

/* ====== 关联项 ====== */
.corr-item { padding: 10px 0; border-bottom: 1px solid var(--c-border); }
.corr-item:last-child { border-bottom: none; }

/* ====== 中考倒计时 ====== */
.countdown {
  background: linear-gradient(135deg, #8b6f9c22 0%, #d4a37322 100%);
  border-radius: 16px; padding: 16px; text-align: center;
  margin-bottom: 14px; border: 1px solid var(--c-border);
}
.countdown .days { font-size: 40px; font-weight: 700; color: var(--c-purple); line-height: 1.1; }
.countdown .lbl { font-size: 14px; color: var(--c-text-3); margin-top: 4px; }

/* ====== 图表容器 ====== */
.chart-wrap { position: relative; height: 240px; }

/* ====== 空状态 ====== */
.empty {
  text-align: center; padding: 32px 20px;
  color: var(--c-text-3);
}
.empty .icon { font-size: 56px; opacity: 0.5; line-height: 1; }
.empty .tip { font-size: 14px; line-height: 1.7; margin-top: 14px; color: var(--c-text-2); }
.empty .btn { margin-top: 16px; }

/* ====== 加载态 ====== */
.loading { text-align: center; padding: 30px 0; }
.spinner {
  width: 32px; height: 32px; margin: 0 auto;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ====== Toast ====== */
.toast {
  position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%) translateY(20px);
  background: rgba(45, 58, 53, 0.92); color: #fff;
  padding: 10px 18px; border-radius: 24px;
  font-size: 14px; z-index: 1000;
  opacity: 0; transition: opacity .2s, transform .2s;
  pointer-events: none;
  max-width: 80%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ====== 登录页 ====== */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #7c9885 0%, #d4a373 100%);
}
.login-box {
  background: #fff; border-radius: 20px; padding: 32px 24px;
  width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(77, 107, 92, 0.2);
}
.login-title {
  text-align: center; color: var(--c-primary-dark); margin: 0 0 6px;
  font-size: 24px; font-weight: 700;
}
.login-sub { text-align: center; color: var(--c-text-3); margin: 0 0 24px; font-size: 13px; }
.login-tabs { display: flex; background: var(--c-bg); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.login-tab {
  flex: 1; text-align: center; padding: 10px 0; cursor: pointer; font-size: 14px;
  border-radius: 8px; transition: all .2s; color: var(--c-text-3);
  min-height: 40px;  /* 触控区 */
}
.login-tab.active { background: #fff; color: var(--c-primary-dark); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }

/* ====== 扫描页 ====== */
.scan-stage {
  position: relative; width: 100%; aspect-ratio: 4/3;
  background: #2d3a35; border-radius: 14px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.scan-stage video, .scan-stage img.preview-img { width: 100%; height: 100%; object-fit: cover; }
.scan-stage .scan-frame {
  position: absolute; left: 12%; right: 12%; top: 18%; bottom: 18%;
  border: 2px dashed rgba(255,255,255,0.5); border-radius: 12px;
  pointer-events: none;
}

/* ====== 导出页 ====== */
.export-card {
  display: flex; gap: 16px; align-items: flex-start;
  padding: 16px; margin-bottom: 14px;
  border: 1px solid var(--c-border); border-radius: 12px;
  background: #fafaf6;
}
.export-card .ic { font-size: 36px; line-height: 1; }
.export-card .info { flex: 1; }
.export-card h3 { margin: 0 0 4px; color: var(--c-text); font-size: 16px; }
.export-card p { margin: 0; font-size: 13px; color: var(--c-text-3); }

/* ====== 响应式 ====== */
@media (max-width: 480px) {
  .container { padding: 12px 12px 100px; }
  .dash-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .card { padding: 14px; }
  .form-row { grid-template-columns: 1fr; }
}

/* ====== 无障碍 - 减少动画 ====== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ====== 链接 ====== */
a { color: var(--c-primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, .form-input:focus-visible, .form-select:focus-visible, .form-textarea:focus-visible {
  outline: 2px solid var(--c-primary); outline-offset: 2px;
}

/* ====== SR-only ====== */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
