/* ============================================================
 * 学生端（手机优先）
 * 设计前提：只用手机竖屏打开，单手可操作、字够大、不横向来回拖。
 * 因此与管理端 style.css 完全解耦：一套独立的设计变量 + 独立布局，
 * 只用 <link> 引本文件，不会把后台那套桌面表格样式带进来。
 * ============================================================ */

:root {
  --bg: #f2f5fb;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --border: #e4e9f2;
  --text: #1b2333;
  --text-2: #5a6580;
  --text-3: #94a0b4;
  --primary: #2f6bff;
  --primary-dark: #1f52d6;
  --primary-soft: #eaf0ff;
  --green: #10a05c;
  --green-soft: #e6f7ee;
  --amber: #cf7c05;
  --amber-soft: #fdf4e5;
  --red: #e0453c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 18px rgba(16, 24, 40, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  /* iPhone 刘海 / 底部小黑条 */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

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

/* .login 用了 display:flex，会压过 hidden 属性的浏览器默认样式——必须显式兜底 */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;   /* 横屏时不要自动放大字号 */
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

button { font-family: inherit; }

/* ---------------- 登录 ---------------- */
.login {
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(28px + var(--sat)) 20px calc(24px + var(--sab));
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background:
    radial-gradient(120% 60% at 50% 0%, #dfe8ff 0%, rgba(223, 232, 255, 0) 62%),
    var(--bg);
}

.login-brand { text-align: center; margin-bottom: 22px; }

.login-logo {
  width: 60px; height: 60px; margin: 0 auto 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(47, 107, 255, .18);
}

.login-brand h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: .5px; }
.login-sub { margin: 0; font-size: 13.5px; color: var(--text-2); }

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 20px 18px calc(18px + var(--sab));
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
}
.field input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  /* 16px 是 iOS 的硬门槛：小于 16px 聚焦时 Safari 会自动放大页面 */
  font-size: 16px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  appearance: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field input::placeholder { color: var(--text-3); font-size: 15px; }
.field input:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.btn-primary {
  width: 100%;
  height: 50px;
  margin-top: 4px;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: 2px;
  color: #fff;
  background: linear-gradient(180deg, #4d81ff, var(--primary));
  border: 0;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(47, 107, 255, .28);
  transition: transform .08s, box-shadow .15s, opacity .15s;
}
.btn-primary:active { transform: translateY(1px); box-shadow: 0 3px 10px rgba(47, 107, 255, .22); }
.btn-primary[disabled] { opacity: .6; box-shadow: none; }

.login-err {
  margin-top: 12px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--red);
  background: #fdeceb;
  border-radius: 10px;
}

.login-tip {
  max-width: 420px;
  margin: 18px 0 0;
  font-size: 12.5px;
  line-height: 1.7;
  text-align: center;
  color: var(--text-3);
}

/* ---------------- 顶栏 ---------------- */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + var(--sat)) 16px 10px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
}

.bar-who { display: flex; align-items: center; gap: 10px; min-width: 0; }

.bar-avatar {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #5b8bff, var(--primary));
  border-radius: 12px;
}

.bar-txt { min-width: 0; }
.bar-txt b { display: block; font-size: 16px; line-height: 1.25; }
.bar-txt span {
  display: block;
  font-size: 12px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.bar-exit {
  flex: 0 0 auto;
  height: 34px; padding: 0 14px;
  font-size: 13px; color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.bar-exit:active { background: #eef2f9; }

/* ---------------- 主体 ---------------- */
.main {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 14px calc(20px + var(--sab));
}

.block {
  margin-bottom: 16px;
  padding: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.block-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 12px;
}
.block-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .3px;
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.link-btn {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 4px 10px;
  font-size: 13px;
  color: var(--primary);
  background: none;
  border: 0;
  border-radius: 8px;
}
.link-btn:active { background: var(--primary-soft); }

/* 班级胶囊 */
.chips {
  display: flex; flex-wrap: wrap; gap: 8px;
}

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: all .15s;
}
.chip .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
}
.chip .dot.off { background: var(--text-3); }
.chip.is-active {
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-color: #c7d8ff;
}
.chip:active { transform: scale(.98); }

/* 视图切换 */
.seg {
  flex: 0 0 auto;
  display: flex;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.seg-btn {
  height: 34px; padding: 0 14px;
  font-size: 12.5px; color: var(--text-2);
  background: none; border: 0; border-radius: 999px;
}
.seg-btn.is-active {
  color: var(--text);
  font-weight: 600;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(16, 24, 40, .12);
}

/* 顶部小结 + 按日期分组 */
.tt-summary { margin: 0 0 12px; font-size: 13px; color: var(--text-2); }
.tt-summary b { color: var(--text); font-weight: 700; }

/* ---------------- 我的试卷 ----------------
 * 一张卡 = 一份卷子：科目/日期在上，分数在中间（学生最关心），
 * 备注折行显示、附件做成可点的 chip。整卡不做跳转，避免手机上多一层页面。
 * ---------------------------------------- */
.head-hint { flex: none; font-size: 12.5px; color: var(--text-3); }
.block-head h2 { flex: 1; }

.paper-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface);
}
.paper-card + .paper-card { margin-top: 10px; }

.paper-top { display: flex; align-items: center; justify-content: flex-start; gap: 8px; }
.paper-subj {
  font-size: 11.5px; font-weight: 600; padding: 1px 8px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary);
}
.paper-date { font-size: 12px; color: var(--text-3); }
/* 试卷折叠：最新一份默认展开，其余收成两行摘要 */
.paper-card { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.paper-right { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: none; }
.paper-files-n { font-size: 11.5px; color: var(--text-3); }
.paper-fold-arrow { font-size: 11px; color: var(--text-3); }
.paper-fold-arrow::after { content: '▾'; }
.paper-card.is-folded .paper-fold-arrow::after { content: '▸'; }
.paper-card:not(.is-folded) .paper-files-n { display: none; }
.paper-card.is-folded {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 10px; align-items: center; padding: 10px 12px;
}
.paper-card.is-folded .paper-top { grid-column: 1 / -1; }
.paper-card.is-folded .paper-name { margin-top: 3px; font-size: 13.5px; }
.paper-card.is-folded .paper-score { margin-top: 3px; justify-content: flex-end; flex-wrap: nowrap; }
.paper-card.is-folded .paper-score b { font-size: 17px; }
.paper-card.is-folded .paper-rate,
.paper-card.is-folded .paper-rank { display: none; }
.paper-card.is-folded .paper-remark,
.paper-card.is-folded .paper-files { display: none; }

.paper-name { margin-top: 6px; font-size: 14.5px; font-weight: 600; line-height: 1.4; word-break: break-word; }

.paper-score { display: flex; align-items: baseline; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.paper-score b { font-size: 21px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.paper-total { font-size: 12.5px; color: var(--text-3); margin-right: 6px; }
.paper-rate {
  font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.paper-rate.r-good { background: var(--green-soft); color: var(--green); }
.paper-rate.r-mid { background: var(--amber-soft); color: var(--amber); }
.paper-rate.r-low { background: #fdeceb; color: var(--red); }
.paper-rank { font-size: 12px; color: var(--text-3); }

.paper-remark {
  margin-top: 7px; padding: 7px 9px;
  font-size: 12.5px; line-height: 1.55; color: var(--text-2);
  background: var(--surface-2); border-radius: 8px; word-break: break-word;
}

.paper-files { display: flex; flex-direction: column; gap: 6px; margin-top: 9px; }
.file-row { display: flex; align-items: stretch; gap: 6px; }
.file-chip {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;
  padding: 9px 10px; min-height: 40px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2);
  font-family: inherit; font-size: 13px; color: var(--text); text-align: left;
  cursor: pointer;
}
.file-chip:active { background: var(--primary-soft); border-color: var(--primary); }
.file-chip.is-busy { opacity: .55; pointer-events: none; }
.file-chip-ico { flex: none; font-size: 15px; }
.file-chip-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip-size { flex: none; font-size: 11.5px; color: var(--text-3); }
/* 右侧「下载」是明确的动作提示，避免学生以为这一行只是文字 */
.file-chip-act {
  flex: none; font-size: 11.5px; font-weight: 600; color: var(--primary);
  border-left: 1px solid var(--border); padding-left: 8px;
}
.file-view {
  flex: none; min-width: 50px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); font-family: inherit; font-size: 12.5px;
  color: var(--primary); cursor: pointer;
}
.file-view:active { background: var(--primary-soft); border-color: var(--primary); }

/* 附件查看层：占满屏幕，不新开窗口 */
.fv {
  position: fixed; inset: 0; z-index: 90;
  display: flex; flex-direction: column;
  background: rgba(17, 24, 39, .92);
}
.fv-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-top)) 12px;
  padding-top: calc(10px + env(safe-area-inset-top));
  color: #fff;
}
.fv-name {
  flex: 1; min-width: 0; font-size: 13.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.fv-btn {
  flex: none; min-height: 34px; padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, .35); border-radius: 8px;
  background: rgba(255, 255, 255, .12); color: #fff;
  font-family: inherit; font-size: 13px; cursor: pointer;
}
.fv-btn-main { background: #2563eb; border-color: #2563eb; font-weight: 600; }
.fv-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0 8px; }
.fv-img { max-width: 100%; max-height: 100%; object-fit: contain; }
/* PDF：pdf.js 逐页画在 canvas 上，容器纵向滚动 */
.fv-body.is-doc { display: block; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 8px 14px; }
.fv-page {
  display: block; width: 100%; max-width: 900px; height: auto;
  margin: 0 auto 10px; background: #fff; border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}
.fv-pdf { width: 100%; height: 100%; border: 0; background: #fff; border-radius: 8px; }
.fv-loading { color: #e5e7eb; font-size: 13.5px; padding: 24px; text-align: center; }
.fv-tip { padding: 8px 12px calc(10px + env(safe-area-inset-bottom)) 12px; text-align: center; font-size: 12px; color: rgba(255, 255, 255, .7); }
body.is-fv-open { overflow: hidden; }

.more-btn {
  display: block; width: 100%; margin-top: 10px; min-height: 40px;
  border: 1px dashed var(--border); border-radius: 10px;
  background: transparent; color: var(--text-2);
  font-family: inherit; font-size: 13px; cursor: pointer;
}
.more-btn:active { background: var(--surface-2); }
.day-group { margin-bottom: 14px; }
.day-group:last-child { margin-bottom: 0; }
.day-head { display: flex; align-items: center; gap: 7px; margin: 0 0 8px; padding-left: 2px; font-size: 13px; color: var(--text-2); }
.day-head b { font-size: 13.5px; color: var(--text); }
.day-head.is-today b { color: var(--primary); }
.today-tag { padding: 1px 7px; font-size: 10.5px; font-weight: 600; color: #fff; background: var(--primary); border-radius: 999px; }
.day-cnt { margin-left: auto; font-size: 11.5px; color: var(--text-3); }
/* 已上「0.5 天 / 1 天」用主色强调，学生一眼看到上了多少 */
.day-cnt.is-done { color: var(--primary); font-weight: 600; }
/* 上课记录折叠：日期头可点（展开/收起该天），折叠组只留头部一行 */
.day-head.is-foldable { cursor: pointer; -webkit-tap-highlight-color: transparent; padding-right: 2px; }
.day-head.is-foldable:active b { color: var(--primary); }
.day-head .fold-arrow { font-size: 11px; color: var(--text-3); }
.day-head .fold-arrow::after { content: '▾'; }
.day-group.is-folded .day-head { margin-bottom: 0; }
.day-group.is-folded .day-head .fold-arrow::after { content: '▸'; }
.day-group.is-folded .lesson { display: none; }
.more-btn.fold-all { margin-top: 0; margin-bottom: 14px; }
/* 单日课程列表 */
.day-list { display: flex; flex-direction: column; gap: 8px; }

.lesson {
  display: flex; align-items: stretch; gap: 12px;
  padding: 11px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.lesson.is-empty {
  background: transparent;
  border-style: dashed;
  opacity: .62;
}
.lesson.is-now {
  background: #fff;
  border-color: #c7d8ff;
  box-shadow: 0 3px 12px rgba(47, 107, 255, .12);
}

.lesson-time {
  flex: 0 0 62px;
  display: flex; flex-direction: column; justify-content: center;
  text-align: center;
  border-right: 1px solid var(--border);
  padding-right: 8px;
}
.lesson-no { font-size: 12px; font-weight: 700; color: var(--primary); }
.lesson-hm {
  font-size: 11px; color: var(--text-3);
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.lesson-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.lesson-subject {
  font-size: 16px; font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
}
.lesson-teacher { font-size: 12.5px; color: var(--text-2); }
.lesson-empty-txt { font-size: 14px; color: var(--text-3); }

.tag-now {
  align-self: center;
  margin-left: 4px;
  padding: 2px 7px;
  font-size: 10.5px;
  font-weight: 600;
  color: #fff;
  background: var(--green);
  border-radius: 999px;
}

/* 上课记录：内容 / 作业 / 我的出勤 */
.lesson-note { margin-top: 5px; font-size: 12.5px; line-height: 1.5; color: var(--text-2); word-break: break-word; }
.lesson-note .n-k { margin-right: 5px; padding: 0 5px; font-size: 10.5px; color: var(--text-3); background: var(--surface); border: 1px solid var(--border); border-radius: 4px; }
.lesson.is-off { opacity: .7; background: transparent; border-style: dashed; }
.lesson.is-off .lesson-subject { text-decoration: line-through; color: var(--text-3); }
.tag-off { align-self: center; padding: 1px 7px; font-size: 10.5px; color: var(--text-3); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
/* 英语课词汇任务：老师勾选后这里只读展示（完成=绿色，未完成=灰色） */
.vocab-badge { align-self: center; padding: 1px 7px; font-size: 10.5px; border-radius: 999px; white-space: nowrap; color: var(--text-3); background: var(--surface); border: 1px solid var(--border); }
.vocab-badge.is-done { color: #0a7f63; background: rgba(16, 163, 127, .13); border-color: transparent; font-weight: 600; }
.att-badge { align-self: center; margin-left: auto; padding: 2px 8px; font-size: 11px; font-weight: 600; border-radius: 999px; }
.att-badge.a-present { color: #0a7f63; background: rgba(16, 163, 127, .13); }
.att-badge.a-absent { color: #c23b3b; background: rgba(220, 70, 70, .12); }
.att-badge.a-late { color: #a86b00; background: rgba(240, 170, 30, .16); }
.att-badge.a-leave { color: var(--text-2); background: var(--surface); }
/* 空态 / 加载 */
.empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--text-3);
}
.empty-ico { display: block; font-size: 30px; margin-bottom: 8px; }
.empty-txt { font-size: 13.5px; }

.loading {
  padding: 26px 0;
  text-align: center;
  font-size: 13px;
  color: var(--text-3);
}

.foot {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 20px calc(22px + var(--sab));
  font-size: 11.5px;
  line-height: 1.7;
  text-align: center;
  color: var(--text-3);
}

/* ---------------- Toast ---------------- */
.toast-root {
  position: fixed; left: 0; right: 0; bottom: calc(24px + var(--sab));
  z-index: 100;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
  padding: 0 20px;
}
.toast {
  max-width: 92vw;
  padding: 10px 16px;
  font-size: 13.5px;
  color: #fff;
  background: rgba(27, 35, 51, .92);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .2);
  animation: toast-in .18s ease-out;
}
.toast.err { background: rgba(224, 69, 60, .95); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------------- 大屏兜底 ----------------
 * 手机上竖屏是主场景；平板/电脑打开时就是一条居中的「手机宽度」卡片，
 * 不会把课表拉成难看的超宽表格。
 * ---------------------------------------- */
@media (min-width: 640px) {
  body { background: #e9eefb; }
  .bar { border-radius: 0; }
  .main { padding-top: 18px; }
  .login { padding-top: 40px; }
}

/* 横屏矮屏：把课表区域留足高度 */
@media (max-height: 460px) and (orientation: landscape) {
  .login { justify-content: flex-start; }
  .login-brand { margin-bottom: 12px; }
  .login-logo { display: none; }
}

/* 尊重系统「减少动效」 */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
