:root {
  --bg: #eff3f8;
  --card: #ffffff;
  --ink: #16202c;
  --ink-2: #56657a;
  --ink-3: #8c9aab;
  --line: #e2e8f0;
  --primary: #1c74c4;
  --primary-dark: #155a99;
  --primary-soft: #e8f2fc;
  --green: #0f9c7e;
  --green-soft: #e4f7f2;
  --orange: #e8802a;
  --orange-soft: #fdf1e3;
  --red: #d9534f;
  --red-soft: #fdeceb;
  --shadow: 0 1px 2px rgba(22, 32, 44, .04), 0 8px 24px rgba(22, 32, 44, .06);
  --radius: 16px;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------- 顶部 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, #2a8ad6, #1c74c4);
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 15px; letter-spacing: .5px;
}
.brand-title { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.brand-sub { font-size: 12px; color: var(--ink-3); line-height: 1.3; }
.spacer { flex: 1; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 14px; border-radius: 10px; cursor: pointer;
  font-size: 14px; transition: .16s ease; white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: #f1f5f9; }
.btn-danger { color: var(--red); border-color: #f3d3d2; background: #fff; }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- 布局 ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 22px 20px 80px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }

/* ---------- 学生端 ---------- */
.hero { padding: 22px 20px 0; max-width: 1080px; margin: 0 auto; }
.hero h1 { margin: 6px 0 4px; font-size: 26px; letter-spacing: -.3px; }
.hero p { margin: 0; color: var(--ink-2); font-size: 14px; }

.stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0 4px; }
.stat {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 14px; font-size: 13px; color: var(--ink-2); cursor: pointer;
  transition: .16s ease;
}
.stat:hover { border-color: #c9d6e4; }
.stat.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.stat b { font-size: 17px; color: var(--ink); font-weight: 700; }
.stat.on b { color: var(--primary-dark); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 14px 0 16px; }
.field { display: flex; align-items: center; gap: 8px; }
select, input[type="text"], input[type="password"], input[type="datetime-local"], textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; outline: none; transition: .16s ease;
}
select:focus, input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(28, 116, 196, .12); }
.search { flex: 1; min-width: 180px; max-width: 320px; position: relative; }
.search input { padding-left: 32px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); opacity: .5; }

.group-title {
  display: flex; align-items: baseline; gap: 8px;
  margin: 26px 0 12px; font-size: 15px; font-weight: 700; color: var(--ink);
}
.group-title span { font-size: 12px; font-weight: 400; color: var(--ink-3); }
.count-pill {
  background: #fff; border: 1px solid var(--line); color: var(--ink-2);
  border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600;
}

.grid { display: grid; gap: 14px; }

.item {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 16px 18px; box-shadow: var(--shadow);
  position: relative; overflow: hidden; transition: .18s ease;
}
.item:hover { border-color: #cfdceb; transform: translateY(-1px); }
.item::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line); }
.item.urgent::before { background: var(--red); }
.item.important::before { background: var(--orange); }
.item.done { opacity: .62; }
.item.done .item-title { text-decoration: line-through; }

.item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.subject {
  font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 6px;
  background: var(--primary-soft); color: var(--primary-dark);
}
.subject.s2 { background: var(--green-soft); color: #0b7d64; }
.subject.s3 { background: var(--orange-soft); color: #b96416; }
.subject.s4 { background: #f0edf9; color: #5b4b9c; }
.badge {
  font-size: 11px; padding: 2px 7px; border-radius: 5px;
  border: 1px solid var(--line); color: var(--ink-2);
}
.badge.homework { background: #f7f9fc; }
.badge.task { background: #fff8ec; border-color: #f5dcb7; color: #a8641a; }
.badge.urgent { background: var(--red-soft); border-color: #f7cfcd; color: #b8352f; font-weight: 600; }
.badge.new { background: var(--green-soft); border-color: #bfe9dd; color: #0b7d64; font-weight: 600; }

.item-title { font-size: 16px; font-weight: 700; margin: 0 0 4px; line-height: 1.45; }
.item-content { color: var(--ink-2); font-size: 14px; white-space: pre-wrap; margin: 0 0 12px; }
.item-foot {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border-top: 1px dashed var(--line); padding-top: 10px;
  font-size: 12.5px; color: var(--ink-3);
}
.deadline { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); }
.remain { font-weight: 700; }
.remain.ok { color: var(--green); }
.remain.warn { color: var(--orange); }
.remain.late { color: var(--red); }

.check {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; user-select: none; color: var(--ink-2); font-size: 13px;
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; background: #fff;
  transition: .16s ease;
}
.check:hover { border-color: #c9d6e4; }
.check.on { background: var(--green-soft); border-color: #bfe9dd; color: #0b7d64; font-weight: 600; }
.check .dot { width: 14px; height: 14px; border: 1.5px solid #c2ccd9; border-radius: 50%; display: grid; place-items: center; font-size: 10px; color: #fff; }
.check.on .dot { background: var(--green); border-color: var(--green); }

.empty {
  text-align: center; padding: 56px 20px; color: var(--ink-3);
  background: #fff; border: 1px dashed #d5dee8; border-radius: var(--radius);
}
.empty b { display: block; color: var(--ink-2); font-size: 15px; margin-bottom: 4px; }

/* ---------- 后台 ---------- */
.admin-grid { display: grid; grid-template-columns: 400px 1fr; gap: 20px; align-items: start; }
.sticky { position: sticky; top: 78px; }

.form-row { margin-bottom: 13px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.form-row .hint { font-size: 12px; color: var(--ink-3); font-weight: 400; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
textarea { resize: vertical; min-height: 96px; line-height: 1.6; }

.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; padding: 8px 10px; border: 1px solid var(--line); background: #fff;
  border-radius: 10px; cursor: pointer; font-size: 13.5px; transition: .16s ease;
}
.seg button.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); font-weight: 600; }
.seg button.on.warn { background: var(--orange-soft); border-color: var(--orange); color: #a8641a; }
.seg button.on.danger { background: var(--red-soft); border-color: var(--red); color: #b8352f; }

.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.form-actions .btn-primary { flex: 1; padding: 10px; }

.link-box {
  background: #f7fafc; border: 1px dashed #cfdceb; border-radius: 10px;
  padding: 10px 12px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 14px;
}
.link-box strong { display: block; color: var(--ink); font-size: 13px; margin-bottom: 3px; }
.link-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.link-row code { flex: 1; background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 4px 8px; font-size: 12.5px; color: var(--primary-dark); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.row:last-child { border-bottom: none; }
.row .t { flex: 1; min-width: 0; }
.row .t b { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t small { color: var(--ink-3); }
.row.off { opacity: .5; }
.row-check {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; user-select: none; font-size: 12.5px; color: var(--ink-2);
}
.row-check input {
  width: 15px; height: 15px; margin: 0; cursor: pointer;
  accent-color: var(--primary);
}
.row-actions { display: flex; gap: 4px; flex: none; }

.list-head {
  display: flex; align-items: center; gap: 10px;
  padding: 0 4px 10px; color: var(--ink-3); font-size: 12.5px;
}
.list-head b { color: var(--ink); font-size: 15px; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 30px 26px; }
.login-card h1 { font-size: 20px; margin: 14px 0 4px; }
.login-card p { color: var(--ink-3); font-size: 13px; margin: 0 0 20px; }
.login-card .btn-primary { width: 100%; padding: 10px; margin-top: 6px; }
.err { color: var(--red); font-size: 13px; min-height: 20px; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 16px);
  background: #16202c; color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13.5px; opacity: 0; pointer-events: none; transition: .25s ease; z-index: 100;
  box-shadow: 0 8px 24px rgba(22, 32, 44, .25); max-width: 86vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.offline {
  margin: 14px 0; padding: 12px 16px; border-radius: 10px;
  background: var(--orange-soft); border: 1px solid #f5dcb7; color: #8a5416; font-size: 13.5px;
}

@media (max-width: 560px) {
  .topbar-inner { padding: 10px 14px; }
  .brand .logo { width: 30px; height: 30px; font-size: 14px; }
  .brand-title { font-size: 15.5px; }
  .admin-link { display: none; }
}

@media (max-width: 860px) {
  .admin-grid { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .hero h1 { font-size: 22px; }
  .wrap { padding: 16px 14px 70px; }
  .hero { padding: 18px 14px 0; }
}
