:root {
  --brand: #1f4e79;
  --brand-2: #2f6db0;
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #1c2430;
  --muted: #6b7684;
  --line: #e5e9f0;
  --ok: #1a7f4b;
  --ok-bg: #e5f5ec;
  --pend: #b26b00;
  --pend-bg: #fff3d9;
  --danger: #c0392b;
  --shadow: 0 2px 10px rgba(31, 78, 121, .07), 0 8px 28px rgba(31, 78, 121, .06);
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 15px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.err-msg { color: var(--danger); min-height: 20px; font-size: 13px; margin: 6px 0 0; }

/* ---------- 按钮 ---------- */
.btn {
  border: none; border-radius: 10px; cursor: pointer; font-size: 15px;
  padding: 11px 18px; font-weight: 600; transition: .15s; font-family: inherit;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 9px; }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-ghost:hover { background: rgba(31,78,121,.07); }
.btn-outline { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn-outline:hover { background: rgba(31,78,121,.06); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: rgba(192,57,43,.06); }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, #1f4e79 0%, #2f6db0 55%, #4a8fd0 100%);
}
.login-card {
  background: var(--card); border-radius: 20px; padding: 34px 26px 28px;
  width: 100%; max-width: 380px; box-shadow: 0 18px 50px rgba(0,0,0,.22);
}
.brand { text-align: center; margin-bottom: 22px; }
.brand-logo {
  width: 60px; height: 60px; border-radius: 16px; margin: 0 auto 12px;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: #fff; font-size: 30px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.brand h1 { font-size: 21px; margin: 0; color: var(--brand); }
.brand-sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 7px; }
.field input {
  width: 100%; padding: 13px 14px; border: 1.5px solid var(--line); border-radius: 11px;
  font-size: 17px; letter-spacing: 1px; font-family: inherit; transition: .15s;
}
.field input:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(47,109,176,.14); }
.login-tip { text-align: center; color: var(--muted); font-size: 12px; margin: 16px 0 0; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
}
.topbar-left { display: flex; align-items: center; gap: 11px; }
.avatar {
  width: 42px; height: 42px; border-radius: 12px; flex: 0 0 42px;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: #fff; font-weight: 700; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
.hello { font-weight: 700; font-size: 15px; }
.sid-line { font-size: 12px; color: var(--muted); }
.day-title-wrap { display: flex; align-items: center; gap: 9px; }
.day-date { font-weight: 700; font-size: 16px; }

/* ---------- 容器 ---------- */
.container { max-width: 860px; margin: 0 auto; padding: 18px 16px 60px; }
.section-title { display: flex; align-items: baseline; gap: 10px; margin: 6px 2px 16px; }
.section-title h2 { font-size: 18px; margin: 0; }

/* ---------- 日期卡片 ---------- */
.days-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 13px; }
.day-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; cursor: pointer; box-shadow: var(--shadow); transition: .16s;
  display: flex; flex-direction: column; gap: 11px;
}
.day-card:hover { transform: translateY(-2px); border-color: var(--brand-2); }
.day-card .dc-top { display: flex; align-items: center; justify-content: space-between; }
.day-card .dc-date { font-size: 17px; font-weight: 700; }
.day-card .dc-week { font-size: 12px; color: var(--muted); }
.day-card .dc-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12px; padding: 3px 9px; border-radius: 20px;
  background: #eef2f8; color: var(--muted);
}
.chip.up { background: #e8f0fe; color: var(--brand); }

/* ---------- 徽章 ---------- */
.badge { font-size: 12px; padding: 3px 10px; border-radius: 20px; font-weight: 600; }
.badge.completed { background: var(--ok-bg); color: var(--ok); }
.badge.pending { background: var(--pend-bg); color: var(--pend); }

/* ---------- 选项卡 ---------- */
.tabs {
  display: flex; gap: 6px; background: #eef1f6; padding: 5px; border-radius: 12px;
  margin-bottom: 18px;
}
.tab {
  flex: 1; border: none; background: transparent; padding: 9px 6px; border-radius: 9px;
  font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; font-family: inherit;
}
.tab.active { background: #fff; color: var(--brand); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

.doc-actions { margin-bottom: 14px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- 文档渲染 ---------- */
.doc {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 20px; box-shadow: var(--shadow);
}
.doc .doc-h1 { text-align: center; color: var(--brand); font-size: 22px; font-weight: 800; margin: 0 0 4px; }
.doc .doc-date { text-align: center; color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.doc .info-table { width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: 14px; }
.doc .info-table td { border: 1px solid var(--line); padding: 8px 11px; vertical-align: top; }
.doc .info-table td.k { background: #eef4fb; font-weight: 700; width: 92px; white-space: nowrap; color: var(--brand); }
.doc .callout {
  border-radius: 11px; padding: 13px 15px; margin: 14px 0; font-size: 14px;
  border: 1px solid transparent;
}
.doc .callout .co-title { font-weight: 700; margin-bottom: 5px; }
.callout.goal { background: #e8f5e9; border-color: #cbe8cf; }
.callout.script { background: #fff8e6; border-color: #f2e2b0; }
.callout.req { background: #fdeaea; border-color: #f6cdcd; }
.callout.parent { background: #eaf1fd; border-color: #cddef6; }
.callout.next { background: #eef4fb; border-color: #cfe0f2; }
.doc .sec { margin-top: 22px; }
.doc .sec-h { color: var(--brand); font-size: 17px; font-weight: 700; margin: 0 0 4px;
  padding-bottom: 6px; border-bottom: 2px solid #eef1f6; }
.doc .sec-src { color: var(--muted); font-size: 12px; margin: 0 0 10px; }
.doc .item { margin: 14px 0; }
.doc .item-title { font-weight: 700; font-size: 15px; margin: 0 0 3px; }
.doc .item-tags { color: var(--danger); font-size: 12px; margin: 0 0 5px; }
.doc .item-content { white-space: pre-wrap; font-size: 14px; margin: 0 0 6px; }
.doc .draft {
  background: #f6f7f9; border: 1px solid var(--line); border-radius: 9px;
  padding: 12px 13px; font-family: "SF Mono", "Courier New", monospace; font-size: 13px;
  white-space: pre-wrap; color: #33404f; margin: 6px 0;
}
.doc .doc-sub { color: var(--brand); font-size: 15px; font-weight: 700; margin: 20px 0 8px; }
.doc ul.doc-list { margin: 0; padding-left: 20px; }
.doc ul.doc-list li { margin: 4px 0; font-size: 14px; }

/* ---------- 上传 ---------- */
.upload-switch { display: flex; gap: 8px; margin-bottom: 14px; }
.pill {
  border: 1.5px solid var(--line); background: #fff; border-radius: 22px;
  padding: 7px 18px; font-size: 14px; font-weight: 600; color: var(--muted);
  cursor: pointer; font-family: inherit;
}
.pill.active { border-color: var(--brand); color: var(--brand); background: #eef4fb; }
.dropzone {
  border: 2px dashed #c3cede; border-radius: var(--radius); background: var(--card);
  padding: 34px 20px; text-align: center; cursor: pointer; transition: .15s;
}
.dropzone.drag { border-color: var(--brand-2); background: #eef4fb; }
.dz-icon { font-size: 38px; }
.dz-main { font-weight: 700; margin: 8px 0 3px; }
.dz-sub { color: var(--muted); font-size: 12px; margin: 0; }
.upload-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0 6px; flex-wrap: wrap; }
.upload-status { font-size: 13px; color: var(--brand); min-height: 18px; margin-bottom: 6px; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.photo-thumb {
  position: relative; aspect-ratio: 1; border-radius: 11px; overflow: hidden;
  border: 1px solid var(--line); background: #eee; cursor: zoom-in;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

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

/* ---------- 灯箱 ---------- */
.lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.86); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: rgba(28,36,48,.94); color: #fff; padding: 11px 20px; border-radius: 24px;
  font-size: 14px; z-index: 200; box-shadow: 0 6px 20px rgba(0,0,0,.3);
  animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; } }

@media (max-width: 500px) {
  .days-grid { grid-template-columns: 1fr 1fr; }
  .doc { padding: 18px 15px; }
}
