:root {
  --teal: #1D9E75;
  --teal-d: #0F6E56;
  --teal-l: #E1F5EE;
  --blue: #185FA5;
  --blue-l: #E6F1FB;
  --amber: #BA7517;
  --amber-l: #FAEEDA;
  --red: #C0392B;
  --red-l: #FCEBEB;
  --purple: #534AB7;
  --purple-l: #EEEDFE;
  --ink: #1f2328;
  --ink2: #57606a;
  --ink3: #8b949e;
  --line: #e6e8eb;
  --bg: #f5f7f8;
  --card: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal-d); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
button, input, select, textarea { font-family: inherit; font-size: 15px; }

/* ---------- 布局 ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }

.topbar {
  background: linear-gradient(135deg, var(--teal-d), var(--teal));
  color: #fff;
  padding: 18px 0 14px;
}
.topbar .wrap { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.brand h1 { font-size: 19px; letter-spacing: .5px; line-height: 1.2; }
.brand p { margin: 2px 0 0; font-size: 12.5px; opacity: .88; line-height: 1.4; }
.topbar .spacer { flex: 1; }
.admin-btn {
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .38);
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
}
.admin-btn.on { background: #fff; color: var(--teal-d); border-color: #fff; }

.nav {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 30;
}
.nav .wrap { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav .wrap::-webkit-scrollbar { display: none; }
.nav a {
  flex: 0 0 auto;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--ink2);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.nav a.active { color: var(--teal-d); border-bottom-color: var(--teal); font-weight: 600; }
.nav a.admin-only { color: var(--amber); }

/* ---------- 学期选择器（顶部标题右侧） ---------- */
.term-picker { display: flex; align-items: center; gap: 8px; }
.term-picker select {
  width: auto; min-width: 208px; padding: 6px 12px;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .42);
  color: #fff; border-radius: 20px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.term-picker select:focus { outline: none; border-color: #fff; background: rgba(255, 255, 255, .26); }
.term-picker select option { color: var(--ink); background: #fff; }

/* ---------- 非当前学期提示条 ---------- */
.term-notice:empty { display: none; }
.term-notice { padding: 12px 0 0; }
.viewing-other {
  padding: 10px 14px;
  background: var(--amber-l); border: 1px solid #f0d9b5; border-radius: 10px;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 13.5px;
}
.viewing-other b { color: var(--amber); }

main { padding: 20px 0 60px; min-height: 60vh; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card > h2 { font-size: 15px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card > h2 .sub { font-size: 12px; font-weight: 400; color: var(--ink3); }

.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.stat .label { font-size: 12.5px; color: var(--ink2); }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: -.3px; }
.stat .unit { font-size: 12px; font-weight: 400; color: var(--ink3); }
.stat.in .value { color: var(--teal-d); }
.stat.out .value { color: var(--red); }
.stat.warn { border-color: var(--amber); background: var(--amber-l); }
.stat.warn .value { color: var(--amber); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { background: #f6f8f9; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-d); }
.btn.danger { color: var(--red); border-color: #f3c9c5; background: var(--red-l); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  background: var(--teal-l);
  color: var(--teal-d);
}
.tag.gray { background: #f0f2f4; color: var(--ink2); }
.tag.amber { background: var(--amber-l); color: var(--amber); }
.tag.red { background: var(--red-l); color: var(--red); }
.tag.blue { background: var(--blue-l); color: var(--blue); }
.tag.purple { background: var(--purple-l); color: var(--purple); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink2); font-weight: 600; font-size: 12.5px; background: #fafbfc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.voided td { color: var(--ink3); text-decoration: line-through; }
tr.dim td { color: var(--ink3); background: #fafbfc; }
tr.dim td.motto { font-style: italic; }

/* 座右铭列：与其他文本区分，用细斜体 + 引号 */
td.motto { color: var(--ink2); font-style: italic; font-size: 13px; min-width: 180px; }
table.members td.motto { color: var(--teal-d); }

.form-row { display: grid; gap: 10px; margin-bottom: 12px; }
.form-row label { font-size: 13px; color: var(--ink2); display: block; margin-bottom: 4px; }
input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal-l); border-color: var(--teal); }
textarea { resize: vertical; min-height: 72px; }

.empty { text-align: center; color: var(--ink3); padding: 34px 0; font-size: 14px; }
.muted { color: var(--ink2); font-size: 13px; }
.small { font-size: 12.5px; color: var(--ink3); }

/* ---------- 首页 ---------- */
.hero-card {
  background: linear-gradient(135deg, #0F6E56, #1D9E75);
  color: #fff;
  border: none;
}
.hero-card h2 { color: #fff; font-size: 16px; }
.hero-motto { font-size: 13px; opacity: .92; margin-top: 6px; }
.hero-meta { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 14px; font-size: 13px; opacity: .95; }

/* 每日一句 */
.hero-quote { padding: 22px 22px 16px; }
.quote-label { font-size: 12px; opacity: .85; letter-spacing: 4px; }
.quote-text { font-size: 19px; line-height: 1.55; margin-top: 10px; font-weight: 500; letter-spacing: .5px; }
.quote-from { font-size: 13px; opacity: .92; margin-top: 8px; text-align: right; }

.feed-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.feed-item:last-child { border-bottom: none; }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); margin-top: 8px; flex: 0 0 8px; }
.feed-dot.out { background: var(--red); }
.feed-body { flex: 1; min-width: 0; }
.feed-title { font-size: 14px; }
.feed-meta { font-size: 12px; color: var(--ink3); margin-top: 2px; }
.feed-amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.feed-amt.in { color: var(--teal-d); }
.feed-amt.out { color: var(--red); }

.birthday {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--amber-l);
  border: 1px solid #f0d9b5;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.birthday .cake { font-size: 22px; }
.birthday b { color: var(--amber); }

/* ---------- 课表 ---------- */
.tt-wrap { overflow-x: auto; }
table.timetable { min-width: 620px; font-size: 13px; }
table.timetable th, table.timetable td { text-align: center; padding: 8px 4px; }
table.timetable td.period { background: #fafbfc; color: var(--ink2); width: 92px; }
table.timetable td.now { background: var(--teal-l); font-weight: 700; color: var(--teal-d); }
table.timetable td.today-col { background: #fcfdfe; }
.tt-time { display: block; font-size: 11px; color: var(--ink3); }

/* ---------- 作息表 ---------- */
table.daily-schedule {
  border: 1.5px solid #9aa1a8;
  border-radius: 6px;
  overflow: hidden;
}
table.daily-schedule th,
table.daily-schedule td {
  border-right: 1px solid #c8ccd1;
  border-bottom: 1px solid #c8ccd1;
}
table.daily-schedule th:last-child,
table.daily-schedule td:last-child { border-right: none; }
table.daily-schedule tbody tr:last-child td { border-bottom: none; }
table.daily-schedule th { background: #eef1f4; color: var(--ink); font-weight: 600; font-size: 13px; }
.daily-schedule td.ds-content { text-align: left; padding-left: 12px; font-weight: 500; }
.daily-schedule td.ds-time  { text-align: center; min-width: 110px; }
.daily-schedule tr.ds-tag-red    td.ds-time { color: var(--red); font-weight: 700; background: var(--red-l); }
.daily-schedule tr.ds-tag-purple td.ds-content { background: var(--purple-l); }
.daily-schedule tr.ds-tag-purple td.ds-time    { background: var(--purple-l); }
.daily-schedule tr.ds-tag-orange td.ds-content { background: var(--amber-l); }
.daily-schedule tr.ds-tag-orange td.ds-time    { background: var(--amber-l); }

/* 合并后的空白单元格：保持中性（不继承行 tag 底色，不被 current 行高亮） */
.daily-schedule td.ds-empty {
  background: var(--card) !important;
  color: var(--ink3);
  text-align: center;
}
.daily-schedule tr.ds-current td.ds-empty {
  background: var(--card) !important;
}

/* 当前正在进行的活动 —— 行描边 + 加粗 */
.daily-schedule tr.ds-current td {
  outline: 2px solid var(--teal);
  outline-offset: -2px;
  position: relative;
}
.daily-schedule tr.ds-current td.ds-content {
  color: var(--teal-d);
  font-weight: 700;
  background: var(--teal-l) !important;
}
.daily-schedule tr.ds-current td.ds-time {
  font-weight: 700;
  background: var(--teal-l) !important;
}

/* 顶部「现在进行」提示条 */
.routine-now {
  background: var(--teal-l);
  border: 1px solid #b3dac6;
  border-left: 4px solid var(--teal);
  color: var(--teal-d);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.routine-now b { color: var(--teal-d); font-weight: 700; }
.routine-now .ds-now-time {
  display: inline-block;
  background: rgba(255,255,255,.75);
  padding: 2px 9px;
  border-radius: 5px;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.routine-now.ds-now-rest {
  background: #f6f8f9;
  border-color: var(--line);
  border-left-color: var(--ink3);
  color: var(--ink2);
}

/* 管理员编辑作息表 */
.routine-edit table { width: 100%; font-size: 13px; border-collapse: collapse; }
.routine-edit th, .routine-edit td { padding: 6px 4px; text-align: left; border-bottom: 1px solid var(--line); }
.routine-edit input, .routine-edit select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }
.routine-edit input:focus, .routine-edit select:focus { outline: none; border-color: var(--teal); }

/* ---------- 影像资料馆 ---------- */
.album {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s;
}
.album:hover { border-color: var(--teal); }
.album-cover { position: relative; height: 130px; overflow: hidden; }
.album-img { position: absolute; inset: 0; }
.album-img.blur { filter: blur(9px); opacity: .72; }
.album-count, .album-lock {
  position: absolute; z-index: 2; font-size: 11.5px; padding: 2px 8px; border-radius: 20px;
  background: rgba(0, 0, 0, .5); color: #fff;
}
.album-count { right: 8px; bottom: 8px; }
.album-lock { left: 8px; top: 8px; background: rgba(163, 45, 45, .88); }
.album-body { padding: 10px 12px 12px; }
.album-title { font-size: 14px; font-weight: 600; line-height: 1.4; }
.album-meta { font-size: 12px; color: var(--ink3); margin-top: 3px; }
.album-desc { font-size: 12.5px; color: var(--ink2); margin-top: 6px; }

.ph-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ph-img {
  height: 74px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px;
}
.ph-img.blur { filter: blur(7px); opacity: .8; }
.ph-cap { font-size: 12px; color: var(--ink2); margin-top: 4px; text-align: center; }

/* ---------- 树洞 ---------- */
.hole {
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-left: 3px solid var(--purple);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.hole .hole-body { font-size: 14.5px; }
.hole .hole-meta { font-size: 12px; color: var(--ink3); margin-top: 8px; display: flex; gap: 12px; flex-wrap: wrap; }
.hole.pending { border-left-color: var(--amber); background: var(--amber-l); }
.hole.hidden { border-left-color: var(--ink3); opacity: .6; }

/* ---------- 资源 ---------- */
.res {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.res:last-child { border-bottom: none; }
.res-ico {
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--blue-l); color: var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; flex: 0 0 38px;
}
.res-title { font-weight: 600; font-size: 14.5px; }
.res-desc { font-size: 13px; color: var(--ink2); margin-top: 2px; }

/* ---------- 凭证 ---------- */
.proof {
  width: 46px; height: 46px;
  border-radius: 8px;
  background: repeating-linear-gradient(45deg, #eef1f3, #eef1f3 6px, #e6eaee 6px, #e6eaee 12px);
  border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--ink2); cursor: pointer;
}
/* 记一笔的凭证上传控件：label 作为点击区 */
.proof-up {
  width: 56px; height: 56px; cursor: pointer; color: var(--teal-d);
  border: 1px dashed var(--teal); background: var(--teal-l); font-size: 12px;
}
.proof-up:hover { background: #d3efe6; }
.proof-up input { display: none; }
.proof-preview {
  width: 56px; height: 56px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line);
}

/* ---------- 弹层 ---------- */
.mask {
  position: absolute; inset: 0;
  background: rgba(15, 23, 32, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 100;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 420px;
  padding: 20px; max-height: 86vh; overflow-y: auto;
}
.modal h3 { font-size: 16px; margin-bottom: 14px; }

.toast {
  position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: rgba(24, 32, 40, .92); color: #fff;
  padding: 10px 18px; border-radius: 22px; font-size: 14px; z-index: 200;
}

.lock-note {
  background: var(--amber-l); border: 1px solid #f0d9b5; color: #7a4d0a;
  border-radius: var(--radius); padding: 14px; font-size: 13.5px; margin-bottom: 14px;
}

.pill-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.pill {
  padding: 5px 12px; border-radius: 18px; border: 1px solid var(--line);
  background: #fff; font-size: 13px; cursor: pointer; color: var(--ink2);
}
.pill.on { background: var(--teal); border-color: var(--teal); color: #fff; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink2); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

.footer { text-align: center; color: var(--ink3); font-size: 12.5px; padding: 24px 0 10px; }

/* ===== 移动端优化（手机优先体验） ===== */
@media (max-width: 720px) {
  .wrap { padding: 0 12px; }
  main { padding: 16px 0 56px; }
  .topbar { padding: 14px 0 12px; }
  .topbar .wrap { gap: 8px; }
  .spacer { display: none; }
  .brand h1 { font-size: 17px; }
  .brand p { font-size: 12px; }
  /* 学期选择器在窄屏独占一行，避免与标题/按钮挤在一起 */
  .term-picker { order: 3; flex: 1 1 100%; }
  .term-picker select { min-width: 0; width: 100%; }
  .admin-btn { order: 2; }
  .nav a { padding: 11px 11px; font-size: 13.5px; }
  .card { padding: 13px; }
  .card > h2 { font-size: 14.5px; flex-wrap: wrap; }
  .g4 { grid-template-columns: 1fr; }
  .g3 { grid-template-columns: repeat(2, 1fr); }
  .form-row.g3 { grid-template-columns: 1fr; }
  .stat .value { font-size: 19px; }
  th, td { padding: 9px 6px; }
  /* 课程表：保持横向滑动，但收紧尺寸，减少压迫感 */
  table.timetable { min-width: 520px; font-size: 12px; }
  table.timetable th, table.timetable td { padding: 7px 3px; }
  .tt-wrap { -webkit-overflow-scrolling: touch; }
  /* 作息表：三列本就能容纳，仅收紧内边距 */
  table.daily-schedule { font-size: 12.5px; }
  table.daily-schedule td.ds-content { padding-left: 8px; }
  table.daily-schedule td.ds-time { min-width: 86px; padding: 8px 4px; }
}

/* 班级成员：窄屏下表格转为卡片（依赖各 td 上的 data-label 显示字段名） */
@media (max-width: 600px) {
  table.members, table.members tbody { display: block; width: 100%; }
  table.members thead { display: none; }
  table.members tr {
    display: block;
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 8px 12px;
    background: var(--card);
    box-shadow: var(--shadow);
  }
  table.members tr.dim { background: #fafbfc; }
  table.members td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--line);
    text-align: right;
  }
  table.members td:last-child { border-bottom: none; }
  table.members td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    text-align: left;
    color: var(--ink3);
    font-size: 12px;
    font-weight: 600;
  }
  table.members td.motto { font-style: italic; }
  table.members td.motto::before { font-style: normal; }
  /* 操作列：按钮横排，不显示字段标签 */
  table.members td:has(button) { justify-content: flex-start; flex-wrap: wrap; gap: 8px; }
  table.members td:has(button)::before { display: none; }

  /* 作息表：窄屏变活动卡片列表（内容 + 周一 + 周二至周五），不再横滑 */
  table.daily-schedule { border: none; }
  table.daily-schedule thead { display: none; }
  table.daily-schedule, table.daily-schedule tbody, table.daily-schedule tr, table.daily-schedule td { display: block; width: 100%; }
  table.daily-schedule tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 10px 12px;
    background: var(--card);
    box-shadow: var(--shadow);
  }
  table.daily-schedule tr.ds-tag-red    { background: var(--red-l); }
  table.daily-schedule tr.ds-tag-purple { background: var(--purple-l); }
  table.daily-schedule tr.ds-tag-orange { background: var(--amber-l); }
  table.daily-schedule tr.ds-current td { outline: none; }
  table.daily-schedule tr.ds-current { outline: 2px solid var(--teal); outline-offset: -2px; }
  table.daily-schedule td {
    border: none !important;
    padding: 3px 0;
    text-align: left;
    background: transparent !important;
  }
  table.daily-schedule td.ds-content { font-weight: 600; color: var(--ink); }
  table.daily-schedule td.col-mon::before    { content: "周一 "; color: var(--ink3); font-size: 11.5px; margin-right: 4px; }
  table.daily-schedule td.col-tuefri::before { content: "周二~五 "; color: var(--ink3); font-size: 11.5px; margin-right: 4px; }
  table.daily-schedule td.col-merged::before { content: "时间 "; color: var(--ink3); font-size: 11.5px; margin-right: 4px; }
  table.daily-schedule td.ds-empty { display: none; }
}

@media (max-width: 480px) {
  .g4, .g3 { grid-template-columns: 1fr; }
  .stat .value { font-size: 18px; }
  .btn-row { flex-direction: column; align-items: stretch; }
  .btn-row .btn { width: 100%; }
  .modal { padding: 18px 16px; }
  .hole .hole-meta { font-size: 11.5px; }
  .feed-item { gap: 8px; }
  .card > h2 .sub { display: block; width: 100%; margin-top: 4px; }
}
@media print {
  .nav, .topbar .admin-btn, .btn, .footer { display: none !important; }
  body { background: #fff; }
}
