/* ============ 作业留档助手 · 手机端样式 ============ */
:root {
  --primary: #4C6FFF;
  --primary-deep: #3A56EB;
  --bg: #F2F4F8;
  --card: #FFFFFF;
  --text: #1F2937;
  --muted: #8A94A6;
  --line: #E8ECF2;
  --danger: #F4436C;
  --green: #22C55E;
  --teal: #10B981;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(31, 41, 55, .06);
  --shadow-lg: 0 8px 28px rgba(58, 86, 235, .28);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161C;
    --card: #1E2129;
    --text: #E7EAF0;
    --muted: #7C8598;
    --line: #2A2E39;
    --shadow: 0 2px 12px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100dvh;
}

input, textarea, button, select { font-family: inherit; }
input, textarea { font-size: 16px; /* 防止 iOS 聚焦时自动放大 */ }

button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }

.page {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(110px + env(safe-area-inset-bottom));
}

/* ---------- 顶部导航 ---------- */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 16px 16px;
  border-radius: 0 0 22px 22px;
  box-shadow: 0 6px 18px rgba(58, 86, 235, .22);
}
.app-bar .row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-bar h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.app-bar .sub {
  font-size: 12px;
  opacity: .85;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.icon-btn:active { background: rgba(255, 255, 255, .3); }

/* ---------- 搜索框 ---------- */
.search-box {
  margin: 14px 16px 4px;
  background: var(--card);
  border-radius: 14px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow);
}

/* ---------- OSS 老文件同步提示条 ---------- */
.sync-banner {
  margin: 10px 16px 4px;
  background: #FFF7E8;
  border: 1px solid #F5D9A8;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sync-banner .sync-text { flex: 1; font-size: 12px; color: #8A6D3B; line-height: 1.5; }
.sync-banner .sync-btn {
  flex-shrink: 0;
  border: none;
  background: #F0A929;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  padding: 7px 10px;
}
.sync-banner .sync-btn:disabled { opacity: .6; }

.search-box input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
}

/* ---------- 学生列表 ---------- */
.list { padding: 12px 16px 8px; display: flex; flex-direction: column; gap: 10px; }

.student-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .12s ease;
}
.student-card:active { transform: scale(.985); }

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.student-info { flex: 1; min-width: 0; }
.student-name {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.student-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.badge-today {
  background: #FFF1E8;
  color: #FF7A45;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.chevron { color: var(--muted); font-size: 18px; flex-shrink: 0; }

/* ---------- 悬浮添加按钮 ---------- */
.fab {
  position: fixed;
  bottom: calc(26px + env(safe-area-inset-bottom));
  right: max(20px, calc(50vw - 300px));
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: #fff;
  font-size: 30px;
  font-weight: 300;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
}
.fab:active { transform: scale(.92); }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 70px 24px; color: var(--muted); }
.empty .e-icon { font-size: 46px; margin-bottom: 12px; }
.empty .e-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty .e-tip { font-size: 13px; }

/* ---------- 底部弹层（表单/菜单） ---------- */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .5);
  /* 必须高于全屏预览层(90)：否则从预览里删照片时确认框会被挡住看不见 */
  z-index: 110;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade .18s ease;
}
.mask.center { align-items: center; padding: 24px; }

.sheet {
  width: 100%;
  max-width: 640px;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
  animation: slide-up .22s ease;
}
.sheet-title { font-size: 17px; font-weight: 700; margin: 0 0 16px; text-align: center; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  background: transparent;
  color: var(--text);
}
.input:focus { border-color: var(--primary); }

.btn {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active { opacity: .85; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-deep)); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-danger-soft { background: #FFF0F3; color: var(--danger); }
.divider { height: 1px; background: var(--line); margin: 18px 0 14px; }

/* 确认对话框 */
.dialog {
  width: 100%;
  max-width: 330px;
  background: var(--card);
  border-radius: 20px;
  padding: 24px 20px 18px;
  text-align: center;
  animation: pop .18s ease;
}
.dialog .d-title { font-size: 17px; font-weight: 700; margin-bottom: 8px; }
.dialog .d-text { font-size: 13px; color: var(--muted); margin-bottom: 18px; white-space: pre-line; }
.dialog .d-btns { display: flex; gap: 10px; }
.dialog .d-btns .btn { padding: 11px; font-size: 15px; }

/* 动作面板 */
.sheet-actions { display: flex; flex-direction: column; gap: 10px; }
.sheet-actions .btn { padding: 14px; }

/* ---------- 学生详情页 ---------- */
.chips { display: flex; gap: 8px; padding: 14px 16px 0; flex-wrap: wrap; }
.chip {
  background: var(--card);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  box-shadow: var(--shadow);
}
.chip b { color: var(--primary); }

/* 底部操作栏：拍照 / 拍视频 / 相册 */
.action-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 640px;
  background: var(--card);
  display: flex;
  gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  z-index: 30;
  box-shadow: 0 -6px 24px rgba(31, 41, 55, .1);
  border-radius: 22px 22px 0 0;
}
.action-btn {
  flex: 1;
  border: none;
  border-radius: 16px;
  padding: 9px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 12.5px;
  font-weight: 700;
  background: #F3F5FA;
  color: var(--text);
}
.action-btn .a-icon { font-size: 22px; line-height: 1.2; }
.action-btn:active { transform: scale(.96); }
.action-btn.photo { background: linear-gradient(135deg, var(--primary), var(--primary-deep)); color: #fff; }
.action-btn.video { background: linear-gradient(135deg, #34D399, #0DA271); color: #fff; }

/* 上传进度 */
.progress-panel { padding: 12px 16px 0; display: flex; flex-direction: column; gap: 8px; }
.prog-row {
  background: var(--card);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
}
.prog-head { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 7px; }
.prog-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 75%; color: var(--text); }
.prog-pct { color: var(--muted); font-variant-numeric: tabular-nums; }
.prog-bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.prog-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #7C93FF);
  transition: width .2s ease;
}
.prog-fill.done { background: var(--green); }
.prog-fill.error { background: var(--danger); }

/* ---------- 相册 ---------- */
.gallery { padding: 6px 16px 0; }
.date-group { margin-top: 18px; }
.date-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.date-title .cnt { font-size: 12px; color: var(--muted); font-weight: 500; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

.thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--line);
  cursor: pointer;
  border: none;
  padding: 0;
}
.thumb img, .thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #9CA3AF;
  font-size: 12px;
  background: var(--line);
}
.thumb-fallback .f-icon { font-size: 26px; }
.play-ico {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: rgba(255, 255, 255, .95);
  text-shadow: 0 1px 8px rgba(0, 0, 0, .5);
  pointer-events: none;
}
.video-badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, .62);
  color: #fff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* ---------- 全屏预览 ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(9, 11, 16, .96);
  z-index: 90;
  display: flex;
  flex-direction: column;
  animation: fade .18s ease;
}
.lb-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  color: #fff;
}
.lb-date { font-size: 13px; opacity: .85; flex: 1; text-align: center; }
.lb-close {
  border: none;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 17px;
}
.lb-media {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  position: relative;
}
.lb-media img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-media video { width: 100%; max-height: 100%; border-radius: 4px; }
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 19px;
}
.lb-nav.prev { left: 8px; }
.lb-nav.next { right: 8px; }
.lb-bottom { display: flex; gap: 10px; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
.lb-btn {
  flex: 1;
  border: none;
  border-radius: 14px;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: rgba(255, 255, 255, .16);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.lb-btn.danger { background: var(--danger); }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(600px 320px at 85% -8%, rgba(124, 147, 255, .35), transparent 65%),
    radial-gradient(500px 300px at 0% 100%, rgba(52, 211, 153, .25), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border-radius: 26px;
  padding: 34px 26px 26px;
  box-shadow: 0 18px 50px rgba(31, 41, 55, .12);
}
.logo {
  width: 68px;
  height: 68px;
  margin: 0 auto 16px;
  border-radius: 22px;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  box-shadow: var(--shadow-lg);
}
.login-card h1 { font-size: 20px; text-align: center; margin: 0 0 4px; }
.login-sub { font-size: 13px; color: var(--muted); text-align: center; margin: 0 0 24px; }
.err-msg { color: var(--danger); font-size: 13px; text-align: center; min-height: 20px; margin: 10px 0 0; }
.hint {
  margin-top: 18px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  background: var(--bg);
  border-radius: 10px;
  padding: 9px 10px;
}
.shake { animation: shake .4s ease; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17, 24, 39, .92);
  color: #fff;
  font-size: 14px;
  padding: 11px 20px;
  border-radius: 999px;
  z-index: 120;
  max-width: 82vw;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, top .25s ease;
}
#toast.show { opacity: 1; top: calc(26px + env(safe-area-inset-top)); }
#toast.err { background: rgba(190, 18, 60, .95); }

/* ---------- 动画 ---------- */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { transform: translateY(48px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
@keyframes pop { from { transform: scale(.9); opacity: .5; } to { transform: scale(1); opacity: 1; } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

/* 桌面端微调 */
@media (min-width: 700px) {
  .page { padding-bottom: 130px; }
  .grid3 { grid-template-columns: repeat(4, 1fr); }
}

/* ============ 学生每日作业（v1.2：按学生×日期记录） ============ */

/* 学生页"今日作业"卡片 */
.hw-today {
  margin: 14px 16px 0;
  background: var(--card);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.hw-today:active { transform: scale(.985); }
.hw-today .t-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.hw-today .t { flex: 1; min-width: 0; }
.hw-today .t-title { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.hw-today .t-content {
  font-size: 14px; color: var(--text);
  white-space: pre-wrap; word-break: break-word; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.hw-today .t-empty { font-size: 13px; color: var(--primary); font-weight: 600; }

/* 学生相册日期组内的作业内容（带修改按钮） */
.hw-line {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 13px;
  color: var(--primary);
  background: rgba(76, 111, 255, .08);
  border-radius: 10px;
  padding: 8px 10px;
  margin: 8px 0 10px;
}
.hw-line .hw-text {
  flex: 1; min-width: 0;
  white-space: pre-wrap; word-break: break-word; line-height: 1.55;
}
.hw-line .hw-edit {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border: none;
  border-radius: 8px;
  background: rgba(76, 111, 255, .14);
  color: var(--primary);
  font-size: 14px;
  cursor: pointer;
}
.hw-line .hw-edit:active { transform: scale(.92); }

/* 还没记作业的日期：补记按钮 */
.hw-add {
  width: 100%;
  margin: 8px 0 10px;
  padding: 8px;
  border: 1.5px dashed rgba(76, 111, 255, .45);
  border-radius: 10px;
  background: none;
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
}
.hw-add:active { background: rgba(76, 111, 255, .08); }

/* 记了作业但还没有照片/视频 */
.hw-no-media { font-size: 13px; color: var(--muted); padding: 2px 4px 6px; }

/* 弹层里的多行输入框 */
textarea.input { resize: vertical; min-height: 120px; line-height: 1.6; }

/* ---------- 内置录像器（v1.5.3：720p 画质可控，清晰又省存储/流量） ---------- */
.rec-overlay {
  position: fixed; inset: 0; background: #000; z-index: 130;
  display: flex; flex-direction: column;
}
.rec-top {
  display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; color: #fff;
}
.rec-hint { font-size: 12px; opacity: .75; }
.rec-flip, .rec-close {
  background: rgba(255, 255, 255, .16); color: #fff; border: none;
  border-radius: 50%; width: 36px; height: 36px; font-size: 15px; cursor: pointer;
}
.rec-video { flex: 1; width: 100%; object-fit: contain; background: #000; }
.rec-timer {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  color: #FF4D4F; font-weight: 600; font-size: 15px;
  font-variant-numeric: tabular-nums; text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}
.rec-bottom {
  display: flex; justify-content: center;
  padding: 22px 0 calc(env(safe-area-inset-bottom) + 30px);
}
.rec-record {
  width: 74px; height: 74px; border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, .9); background: transparent;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.rec-record span {
  width: 58px; height: 58px; border-radius: 50%; background: #FF4D4F;
  transition: width .15s, height .15s, border-radius .15s;
}
.rec-record.recording span { width: 30px; height: 30px; border-radius: 7px; }
