body {
  --bg: #f4f6f8;
  --card: #ffffff;
  --border: #d5dbe3;
  --text: #1c2430;
  --muted: #5c6b7a;
  --accent: #1d6fbf;
  --done: #1b7f4e;
  --doing: #b86e00;
  --planned: #1d6fbf;
  --line: #b7c6d9;
  background: var(--bg);
  color: var(--text);
}

main.page { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1.5rem 3rem; }
main.page.full { max-width: none; }

.topbar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.switcher { display: flex; gap: 0.5rem; }
.switcher a {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
}
.switcher a:hover { text-decoration: none; border-color: var(--accent); }
.switcher a.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 650; }
#save-msg { font-size: 0.85rem; color: var(--done); }
#save-msg.err { color: #b42318; }

.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
}
.panel + .panel { margin-top: 1rem; }
.panel h3 { margin: 0; font-size: 1rem; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.75rem; }

label { display: block; font-size: 0.8rem; color: var(--muted); margin: 0.55rem 0 0.2rem; }
input, select, textarea {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #a9cdf0; border-color: var(--accent); }
textarea { min-height: 3.6rem; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }

button {
  padding: 0.38rem 0.75rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}
button.ghost { background: #fff; color: var(--text); border-color: var(--border); font-weight: 500; }
button.ghost:hover { border-color: var(--accent); color: var(--accent); }
button.warn { background: #fff; color: #b42318; border-color: #e6b8b3; font-weight: 500; }
button.warn:hover { background: #fdecea; }
button.small { padding: 0.15rem 0.45rem; font-size: 0.76rem; }
button.link {
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font-weight: 500;
  font-size: inherit;
}
button.link:hover { text-decoration: underline; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; }
.muted { color: var(--muted); font-size: 0.85rem; }
.form-err { color: #b42318; font-size: 0.82rem; margin-top: 0.4rem; }
[hidden] { display: none !important; }

/* ---------- 日程 ---------- */
.sched-top {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(290px, 1fr);
  gap: 1rem;
  align-items: start;
  margin-bottom: 1rem;
}
.sched-top .panel + .panel { margin-top: 0; }
@media (max-width: 860px) { .sched-top { grid-template-columns: 1fr; } }

.cal-head { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.6rem; }
.cal-head h3 { margin: 0 0.4rem; min-width: 7.5rem; text-align: center; font-size: 1.05rem; }
.cal-head .spacer { flex: 1; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { text-align: center; font-size: 0.75rem; color: var(--muted); padding: 0.2rem 0; }
.cal-cell {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  min-width: 0;
  min-height: 82px;
  margin: 0;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.25rem 0.3rem;
  text-align: left;
  vertical-align: top;
  font-weight: 400;
  overflow: hidden;
}
button.cal-cell:hover { border-color: var(--accent); }
.cal-cell.out { background: transparent; border-color: transparent; cursor: default; }
.cal-cell.weekend .num { color: #9a3b3b; }
.cal-cell.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: #f1f7fd; }
.cal-cell .num {
  align-self: flex-start;
  min-width: 1.5rem;
  height: 1.5rem;
  line-height: 1.5rem;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 650;
  color: var(--text);
  border-radius: 999px;
}
.cal-cell.today .num { background: var(--accent); color: #fff; }
.cal-cell .chip {
  display: block;
  margin-top: 2px;
  padding: 0 0.25rem;
  border-radius: 4px;
  font-size: 0.7rem;
  line-height: 1.35;
  color: #24415f;
  background: #e8f0f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-cell .chip.wake, .cal-cell .chip.sleep { background: #f0edf7; color: #4c3f77; }
.cal-cell .chip.other { background: #eef1f4; color: #44505c; }
.cal-cell .chip.due { background: #fdecea; color: #a12a1f; }
.cal-cell .chip.begin { background: #e7f5ed; color: #1b6b43; }
.cal-cell .chip.more { background: none; color: var(--muted); }

.day-plans { margin: 0.2rem 0 0.6rem; font-size: 0.85rem; }
.day-plans .tag {
  display: inline-block;
  margin: 0 0.3rem 0.3rem 0;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #e8f0f9;
  color: #24415f;
}
.day-plans .tag.due { background: #fdecea; color: #a12a1f; }
.item { border-top: 1px solid var(--border); padding: 0.55rem 0; font-size: 0.9rem; }
.item:first-child { border-top: none; }
.item .when { color: var(--accent); font-weight: 650; margin-right: 0.45rem; }
.item .kind { color: var(--muted); font-size: 0.78rem; margin-right: 0.35rem; }
.item .sub { margin-top: 0.2rem; white-space: pre-wrap; }
.item .sub .k { color: var(--muted); font-size: 0.78rem; margin-right: 0.3rem; }
.item .btn-row { margin-top: 0.35rem; }
.quick { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin-top: 0.7rem; padding-top: 0.7rem; border-top: 1px solid var(--border); }
.quick .muted { margin-right: 0.2rem; }
.inline-form { margin-top: 0.7rem; padding: 0.3rem 0.8rem 0.8rem; border: 1px solid var(--border); border-radius: 10px; background: #fafbfc; }
.inline-form h4 { margin: 0.6rem 0 0; font-size: 0.92rem; }
.radio-row { display: flex; gap: 1rem; }
.radio-row label { display: flex; align-items: center; gap: 0.3rem; margin: 0.2rem 0 0; color: var(--text); font-size: 0.88rem; }
.radio-row input { width: auto; }

.plan-line { position: relative; margin-left: 8px; padding-left: 20px; }
.plan-line.empty { margin-left: 0; padding-left: 0; }
.plan-line.empty::before { display: none; }
.plan-line::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: #c5d4e8;
}
.plan-item { position: relative; padding: 0.35rem 0 0.9rem; }
.plan-item::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 0.65rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
  box-sizing: border-box;
}
.plan-item .dates { font-size: 0.85rem; color: var(--muted); }
.plan-item .title { font-weight: 650; }
.plan-item .note { white-space: pre-wrap; font-size: 0.9rem; }
.plan-item .linked { margin-top: 0.25rem; font-size: 0.84rem; color: var(--muted); }
.plan-item .linked div { margin-top: 0.1rem; }
.plan-today { position: relative; padding: 0.2rem 0 0.7rem; color: #a12a1f; font-size: 0.85rem; font-weight: 650; }
.plan-today::before {
  content: "";
  position: absolute;
  left: -21px;
  top: 0.45rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #c0392b;
}

/* ---------- 工作记录 ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 0.9rem; font-size: 0.82rem; color: var(--muted); }
.legend i { display: inline-block; width: 0.7rem; height: 0.7rem; border-radius: 3px; margin-right: 0.3rem; vertical-align: -1px; }
.legend .done i { background: var(--done); }
.legend .planned i { background: var(--planned); }
.legend .idea i { background: var(--doing); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; margin-bottom: 0.75rem; }
.toolbar .spacer { flex: 1; }

.tree-wrap {
  --w: 256px;
  --half: 127px;
  --gap: 20px;
  overflow: auto;
  padding: 1rem 1.1rem 1.5rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.roots { display: flex; align-items: flex-start; gap: 48px; width: max-content; }
.trow { display: flex; align-items: stretch; }
.tmain { width: var(--w); flex: none; display: flex; flex-direction: column; }
.down-line { flex: 1; min-height: var(--gap); width: 2px; margin-left: var(--half); background: var(--line); }

/* 旁边的分支 */
.side { position: relative; margin-left: 30px; padding-bottom: 12px; display: flex; flex-direction: column; gap: 10px; }
.side::before { content: ""; position: absolute; left: -30px; top: 20px; width: 15px; height: 2px; background: var(--line); }
.side-item { position: relative; }
.side-item::before { content: ""; position: absolute; left: -15px; top: -10px; bottom: 0; width: 2px; background: var(--line); }
.side-item:first-child::before { top: 20px; }
.side-item:last-child::before { bottom: auto; height: 32px; }
.side-item:first-child:last-child::before { display: none; }
.side-item::after { content: ""; position: absolute; left: -15px; top: 20px; width: 15px; height: 2px; background: var(--line); }

/* 下面分成几路 */
.fork { display: flex; align-items: flex-start; }
.fork-col { position: relative; padding: var(--gap) 28px 0 0; }
.fork-col:last-child { padding-right: 0; }
.fork-col::before { content: ""; position: absolute; top: 0; left: var(--half); width: 2px; height: var(--gap); background: var(--line); }
.fork-col::after { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--line); }
.fork-col:first-child::after { left: var(--half); }
.fork-col:last-child::after { right: auto; width: calc(var(--half) + 2px); }

.node {
  position: relative;
  width: var(--w, 256px);
  background: #fff;
  border: 1px solid var(--border);
  border-left: 5px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.6rem 0.5rem;
  font-size: 0.86rem;
}
.node.done { border-left-color: var(--done); }
.node.planned { border-left-color: var(--planned); }
.node.idea { border-left-color: var(--doing); }
.node .node-top { display: flex; align-items: center; justify-content: space-between; gap: 0.3rem; min-height: 1.5rem; }
.node .st { font-size: 0.7rem; font-weight: 650; white-space: nowrap; }
.node.done .st { color: var(--done); }
.node.planned .st { color: var(--planned); }
.node.idea .st { color: var(--doing); }
.node .node-title { font-weight: 650; line-height: 1.35; margin-top: 0.1rem; }
.node .node-note { margin-top: 0.25rem; color: #44505c; font-size: 0.8rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.node .ops { display: flex; flex-wrap: nowrap; gap: 3px; opacity: 0.6; }
.node .ops button { padding: 0.05rem 0.32rem; font-size: 0.72rem; white-space: nowrap; }
.node:hover .ops, .node:focus-within .ops { opacity: 1; }
.node.editing {
  z-index: 5;
  width: 320px;
  box-shadow: 0 6px 24px rgba(28, 36, 48, 0.22);
  border-color: var(--accent);
  border-left-color: var(--accent);
}
.node.editing label { margin-top: 0.4rem; }
.node.editing textarea { min-height: 6rem; }
.loose-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.7rem; }

body.guest .owner-only { display: none !important; }
#page-notes { margin-bottom: 1rem; }
.guest-hint { margin: 0 0 0.35rem; color: var(--muted); font-size: 0.85rem; }
.anno-item { color: #c0392b; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.9rem; line-height: 1.45; margin-top: 0.2rem; }
.anno-item .who { font-weight: 700; margin-right: 0.4rem; }
.anno-item .link { margin-left: 0.45rem; color: var(--muted); font-weight: 400; }
.anno-open { color: #c0392b; }
.anno-form { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.35rem; }
.anno-form textarea { min-height: 4.5rem; }
.node:has(.anno-form) { width: 320px; z-index: 4; }
