:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --panel-2: #f0eee8;
  --line: #e3e0d8;
  --text: #1d1f22;
  --muted: #6b6f76;
  --accent: #2f5d50;
  --accent-soft: #dfeae5;
  --warn: #b5541c;
  --warn-soft: #f8e6da;
  --danger: #b3261e;
  --danger-soft: #f9dedc;
  --ok: #2e7d4f;
  --ok-soft: #dcefe3;
  --gold: #a87414;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a;
    --panel: #1f2125;
    --panel-2: #26292e;
    --line: #33363c;
    --text: #e8e6e1;
    --muted: #9a9ea6;
    --accent: #7fbfa8;
    --accent-soft: #23362f;
    --warn: #f0a46b;
    --warn-soft: #3a2a1f;
    --danger: #f2a49e;
    --danger-soft: #3b2222;
    --ok: #86d1a3;
    --ok-soft: #1f3327;
    --gold: #e8b04a;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel-2); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
button, select, input, textarea { font: inherit; color: inherit; }
button {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
button.small { padding: 2px 8px; font-size: 13px; }
input, select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.muted { color: var(--muted); }
.pad { padding: 16px; }
.small { font-size: 13px; }

/* 顶栏 */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 18px;
  padding: 10px 24px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); font-size: 17px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
#nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; }
#nav::-webkit-scrollbar { display: none; }
#nav a, #nav-courses a {
  padding: 5px 10px; border-radius: 8px; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
#nav-courses { display: contents; }
#nav a:hover { text-decoration: none; background: var(--panel-2); color: var(--text); }
#nav a.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--line); }
#search { width: 260px; }
#search input { padding: 6px 10px; }

main { max-width: 1240px; margin: 0 auto; padding: 20px 24px 60px; }

/* 布局 */
.grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > h2, .card-h {
  margin: 0; padding: 14px 16px 10px; font-size: 15px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.card-b { padding: 0 16px 14px; }
h1.page { font-size: 22px; margin: 4px 0 16px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
h3.sec { font-size: 13px; color: var(--muted); font-weight: 600; margin: 12px 16px 6px; letter-spacing: .02em; }

/* 状态条 */
.banner { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.info { background: var(--accent-soft); color: var(--accent); }
.banner b { color: inherit; }
.statusline { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--muted); margin: -6px 0 16px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--danger); } .dot.mid { background: var(--gold); }

/* 课程标签 */
.tag {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 6px;
  background: var(--panel-2); color: var(--muted); white-space: nowrap; vertical-align: 1px;
}
.cdot { width: 8px; height: 8px; border-radius: 3px; display: inline-block; flex: none; }

/* 待办列表 */
.list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); align-items: flex-start; }
.item:first-child { border-top: 0; }
.item .when { width: 74px; flex: none; font-size: 13px; color: var(--muted); padding-top: 1px; font-variant-numeric: tabular-nums; }
.item .what { flex: 1; min-width: 0; }
.item .title { overflow-wrap: anywhere; }
.item .meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.item.done .title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
.item .side { flex: none; display: flex; gap: 6px; align-items: center; }
.pill { font-size: 12px; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.mid { background: var(--panel-2); color: var(--muted); }
.daygroup { font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 10px 16px 4px; border-top: 1px solid var(--line); background: var(--panel-2); }
.daygroup:first-child { border-top: 0; border-radius: var(--radius) var(--radius) 0 0; }
.daygroup.over { color: var(--danger); }
.check { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex: none; cursor: pointer; }

/* 考试倒计时 */
.exams { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 0 16px 14px; }
.exam { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--panel-2); }
.exam .n { font-size: 26px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.exam .n small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.exam .t { font-size: 13px; margin-top: 4px; overflow-wrap: anywhere; }

/* 课程卡 */
.courses { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; padding: 0 16px 14px; }
.ccard { display: block; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--text); position: relative; overflow: hidden; }
.ccard:hover { text-decoration: none; border-color: var(--accent); }
.ccard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--accent)); }
.ccard .s { font-weight: 700; }
.ccard .sc { float: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.ccard .nx { font-size: 12.5px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 公告 */
details.ann { border-top: 1px solid var(--line); }
details.ann:first-child { border-top: 0; }
details.ann summary { padding: 10px 16px; cursor: pointer; list-style: none; display: flex; gap: 8px; align-items: baseline; }
details.ann summary::-webkit-details-marker { display: none; }
details.ann summary .t { flex: 1; min-width: 0; overflow-wrap: anywhere; }
details.ann summary .d { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
details.ann .body { padding: 0 16px 12px; white-space: pre-wrap; font-size: 14px; color: var(--text); overflow-wrap: anywhere; }

/* 表格 */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .nowrap { white-space: nowrap; }
.scroll-x { overflow-x: auto; }

/* 文件 */
.folder { border-top: 1px solid var(--line); }
.folder:first-child { border-top: 0; }
.folder > summary { padding: 9px 16px; cursor: pointer; display: flex; gap: 8px; align-items: center; list-style: none; }
.folder > summary::-webkit-details-marker { display: none; }
.folder > summary::before { content: "▸"; color: var(--muted); font-size: 12px; width: 10px; }
.folder[open] > summary::before { content: "▾"; }
.folder > summary .n { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.files { list-style: none; margin: 0; padding: 0 16px 10px 34px; font-size: 14px; }
.files li { display: flex; gap: 8px; padding: 3px 0; align-items: baseline; }
.files li .fn { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.files li .fs { color: var(--muted); font-size: 12px; white-space: nowrap; }
.ext { font: 600 10.5px ui-monospace, Menlo, monospace; text-transform: uppercase; padding: 0 5px; border-radius: 4px; background: var(--panel-2); color: var(--muted); flex: none; min-width: 34px; text-align: center; }

/* 日历 */
.calbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.calbar h2 { margin: 0 8px 0 0; font-size: 20px; }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); gap: 1px; }
.month .wd { background: var(--panel-2); text-align: center; font-size: 12px; color: var(--muted); padding: 6px 0; }
.month .day { background: var(--panel); min-height: 96px; padding: 4px 5px; cursor: pointer; overflow: hidden; }
.month .day.other { background: var(--bg); }
.month .day.other .dn { opacity: .45; }
.month .day.today .dn { background: var(--accent); color: var(--bg); }
.month .day.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.month .dn { font-size: 12px; width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 50%; margin-bottom: 2px; font-variant-numeric: tabular-nums; }
.month .ev { font-size: 11.5px; line-height: 1.35; padding: 1px 4px; border-radius: 4px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: color-mix(in srgb, var(--c, var(--accent)) 16%, transparent); }
.month .ev.done { opacity: .5; text-decoration: line-through; }
.month .ev.exam { font-weight: 700; }
.month .more { font-size: 11px; color: var(--muted); }

/* 弹窗 */
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal[hidden] { display: none; }
.dialog { background: var(--panel); border-radius: 14px; padding: 18px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.dialog h3 { margin: 0 0 12px; }
.form { display: grid; gap: 10px; }
.form label { font-size: 13px; color: var(--muted); display: grid; gap: 4px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.form .actions .left { margin-right: auto; }
.inline-check { display: flex !important; align-items: center; gap: 8px; color: var(--text) !important; }
.inline-check input { width: auto; }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 999px; font-size: 14px; z-index: 60; }
#toast[hidden] { display: none; }

.steps { margin: 0; padding-left: 20px; }
.steps li { margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.empty { padding: 14px 16px; color: var(--muted); font-size: 14px; }
.toggle-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.toggle-row:first-child { border-top: 0; }
.toggle-row span { flex: 1; }

/* 登录页 */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; width: 100%; max-width: 340px; display: grid; gap: 12px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card .err { color: var(--danger); margin: 0; font-size: 14px; }
.login-card .hint { color: var(--muted); margin: 0; font-size: 14px; line-height: 1.7; }

@media (max-width: 900px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  #search { display: none; }
  .top { flex-wrap: wrap; gap: 8px 14px; padding: 10px 16px; }
  main { padding: 16px 16px 60px; }
}
@media (max-width: 600px) {
  .top .brand { display: none; }
  .month .day { min-height: 64px; padding: 3px; }
  .month .ev { font-size: 10px; padding: 0 2px; }
  .item .when { width: 58px; font-size: 12px; }
  .form .row { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
