:root {
  --bg: #0d0f14;
  --panel: #161a22;
  --panel-2: #1e222c;
  --line: #272d39;
  --text: #f2f4f8;
  --muted: #8b93a7;
  --accent: #4f7dff;
  --accent-soft: rgba(79, 125, 255, .14);
  --ok: #38d39f;
  --warn: #ffb020;
  --danger: #ff5c72;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
[hidden] { display: none !important; }

/* ---------- 登录 ---------- */
.auth {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 24px);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px 22px 24px;
}

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

.brand-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: linear-gradient(145deg, #6f95ff, #3b63e0);
  box-shadow: 0 10px 24px rgba(79, 125, 255, .38);
}

.brand h1 { font-size: 25px; letter-spacing: .02em; }
.brand p { margin-top: 6px; font-size: 13px; }

.seg {
  display: flex;
  padding: 4px;
  background: var(--panel-2);
  border-radius: 12px;
  margin-bottom: 18px;
}

.seg button {
  flex: 1;
  height: 36px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
}

.seg button.on { background: var(--panel); color: var(--text); font-weight: 600; }

.stack { display: flex; flex-direction: column; gap: 12px; }

.stack input, .field input, .field textarea, .field select {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  outline: none;
  font-family: inherit;
}

.stack input:focus, .field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent);
}

.stack button[type=submit] {
  height: 48px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  margin-top: 4px;
}

.stack button[type=submit]:disabled { opacity: .55; }

.tip { margin-top: 14px; font-size: 12.5px; color: var(--muted); text-align: center; min-height: 16px; }
.tip.err { color: var(--danger); }
.tip.ok { color: var(--ok); }

/* ---------- 应用框架 ---------- */
.app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 10px;
}

.topbar h1 { font-size: 24px; letter-spacing: -.01em; }
.topbar .muted { margin-top: 3px; }

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: #a9c0ff;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 600;
}

.main {
  flex: 1;
  padding: 8px 18px calc(96px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(12px + var(--safe-bottom));
  width: min(420px, calc(100% - 32px));
  display: flex;
  gap: 4px;
  padding: 6px;
  background: rgba(22, 26, 34, .92);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(14px);
  z-index: 20;
}

.tabbar button {
  flex: 1;
  height: 48px;
  border: none;
  border-radius: 13px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.tabbar button .g { font-size: 17px; line-height: 1; }
.tabbar button.on { background: var(--accent-soft); color: #b8caff; }

/* ---------- 通用卡片 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.card-head h3 { font-size: 15px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 13.5px;
}

.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.stat {
  background: var(--panel-2);
  border-radius: 14px;
  padding: 14px;
}

.stat .n { font-size: 26px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .l { margin-top: 5px; font-size: 12.5px; color: var(--muted); }
.stat.todo .n { color: #cfd6e6; }
.stat.pending .n { color: var(--warn); }
.stat.done .n { color: var(--ok); }
.stat.overdue .n { color: var(--danger); }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 96px; margin-top: 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar {
  width: 100%;
  max-width: 30px;
  min-height: 4px;
  border-radius: 7px 7px 4px 4px;
  background: linear-gradient(180deg, #6f95ff, #3b63e0);
  transition: height .3s ease;
}
.bar-col .lb { font-size: 10.5px; color: var(--muted); }

/* ---------- 作业列表 ---------- */
.a-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 15px 16px;
}

.a-top { display: flex; align-items: flex-start; gap: 10px; }

.a-title { flex: 1; font-size: 15.5px; font-weight: 600; line-height: 1.4; }

.badge {
  flex: 0 0 auto;
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge.todo { background: rgba(255, 255, 255, .09); color: #cfd6e6; }
.badge.submitted { background: rgba(255, 176, 32, .16); color: var(--warn); }
.badge.done { background: rgba(56, 211, 159, .15); color: var(--ok); }
.badge.overdue { background: rgba(255, 92, 114, .15); color: var(--danger); }

.a-meta { margin-top: 9px; font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.a-meta .dot { opacity: .5; }

.a-content {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.55;
  color: #c3cadb;
  white-space: pre-wrap;
  word-break: break-word;
}

.thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; }
.thumbs img {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}

.a-actions { display: flex; gap: 8px; margin-top: 13px; }

.btn {
  flex: 1;
  height: 40px;
  border-radius: 11px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  background: var(--panel-2);
  color: var(--text);
}

.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--muted); }
.btn.ok { background: rgba(56, 211, 159, .16); color: var(--ok); }
.btn:disabled { opacity: .5; }

.empty {
  padding: 46px 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 13px; }
.field label { font-size: 12.5px; color: var(--muted); }
.field textarea { min-height: 84px; resize: vertical; line-height: 1.5; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ---------- 弹层 ---------- */
.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-end;
  z-index: 50;
}

.sheet {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  max-height: 88vh;
  background: var(--panel);
  border-radius: 24px 24px 0 0;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  animation: up .22s ease-out;
}

@keyframes up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }

.sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.sheet-title { flex: 1; font-size: 16px; font-weight: 600; }

.icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.sheet-body { padding: 16px 18px calc(20px + var(--safe-bottom)); overflow-y: auto; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  background: rgba(30, 34, 44, .96);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  z-index: 100;
  max-width: 80vw;
  text-align: center;
}

.toast.err { border-color: rgba(255, 92, 114, .5); color: #ffb3be; }

.pick { display: flex; gap: 8px; flex-wrap: wrap; }
.pick label {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 14px;
  color: var(--muted);
}
.pick input { accent-color: var(--accent); }
.pick label.on { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }

.photo-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.photo-grid .ph {
  width: 74px;
  height: 74px;
  border-radius: 11px;
  border: 1px dashed var(--line);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 22px;
  position: relative;
  overflow: hidden;
}
.photo-grid .ph img { width: 100%; height: 100%; object-fit: cover; }
.photo-grid .ph .rm {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,.7); color: #fff; border: none;
  font-size: 12px; line-height: 1; display: grid; place-items: center;
}
