:root {
  --bg: #f3f0ea;
  --panel: #fffcf7;
  --line: #d9d1c4;
  --text: #1f1b16;
  --muted: #6f675c;
  --accent: #215e52;
  --accent-fill: #2a7a69;
  --ok: #2d6a4f;
  --bad: #9b2c2c;
  --warn: #b45309;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Noto Sans CJK SC", "WenQuanYi Micro Hei", "Noto Sans", sans-serif;
}

.top {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand { font-weight: 700; letter-spacing: 0.04em; }
.tabs { display: flex; gap: 6px; }

.tab, .ghost, .primary, .file-btn {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}

.tab.active, .primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.ghost:hover, .file-btn:hover, .tab:hover { border-color: var(--accent); }
.tiny { padding: 4px 10px; font-size: 13px; }
.file-btn { display: inline-flex; align-items: center; }
.file-btn input { display: none; }

.status-row { margin-left: auto; display: flex; gap: 10px; align-items: center; font-size: 13px; }
.status { color: var(--muted); }
.status.ok { color: var(--ok); }

.page { min-height: calc(100vh - 54px); }
.hidden { display: none !important; }

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 54px);
  min-height: 0;
}

.side {
  border-right: 1px solid var(--line);
  background: #f7f3ec;
  padding: 14px 12px;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.side-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.side h2 {
  font-size: 13px;
  color: var(--muted);
  margin: 0 8px;
}

.group-toggle { display: flex; gap: 4px; }
.editor-actions { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }

.history { flex: 1; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 4px; }

.hist, .mode {
  text-align: left;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  width: 100%;
}

.hist.active { background: #e7efe9; }
.hist:hover { background: #eee8dc; }
.hist .sub, .muted, .hint, .caption { color: var(--muted); }
.hist .sub {
  display: block;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.content {
  padding: 20px 28px 48px;
  min-height: 0;
  overflow-y: auto;
}

.work-content { max-width: none; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0;
}

input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}

textarea { width: 100%; min-height: 220px; resize: vertical; }

.md-body {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 28px 40px;
  line-height: 1.7;
  overflow-x: auto;
}

.md-body h1 { font-size: 1.7em; margin: 0 0 0.6em; }
.md-body h2 { font-size: 1.35em; margin: 1.2em 0 0.4em; }
.md-body h3 { font-size: 1.15em; margin: 1em 0 0.4em; }
.md-body [id] { scroll-margin-top: 12px; }
.md-body a[id]:empty {
  display: block;
  height: 0;
  overflow: hidden;
  visibility: hidden;
}
.md-body a[href^="#"] { text-underline-offset: 2px; }
.md-body img { max-width: 100%; height: auto; }
.md-body blockquote {
  margin: 0.8em 0;
  padding: 0.2em 0 0.2em 14px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}
.md-body pre {
  padding: 12px;
  overflow: auto;
  background: #f6f3ee;
  border-radius: 10px;
}
.md-body code { font-family: "JetBrains Mono", "Fira Code", ui-monospace, monospace; font-size: 0.92em; }
.md-body .sourceCode .kw, .md-body .op { color: #215e52; }
.md-body .sourceCode .st { color: #9b2c2c; }
.md-body .sourceCode .bu, .md-body .sourceCode .dt { color: #2a7a69; }
.md-body .sourceCode .co { color: var(--muted); }
.md-body table { border-collapse: collapse; }
.md-body th, .md-body td { border: 1px solid var(--line); padding: 6px 10px; }

.item-row {
  display: grid;
  grid-template-columns: 1fr 110px 120px auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.week-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: var(--panel);
}
.week-table th, .week-table td {
  border: 1px solid var(--line);
  vertical-align: top;
  padding: 6px;
  font-size: 13px;
}
.week-table th { background: #f7f3ec; font-weight: 650; }
.week-table .item-name { width: 140px; font-weight: 650; }
.week-table textarea {
  min-height: 84px;
  padding: 6px;
  border-radius: 8px;
}

.pill {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: #e4efe9;
  font-size: 12px;
}
.pill.done { background: #e8f0e4; }
.pill.paused { background: #f5ead8; }
.pill.todo { background: #eee8dc; }

.mask {
  position: fixed;
  inset: 0;
  background: rgba(31, 27, 22, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.login-card { width: min(420px, calc(100% - 32px)); }
.bad { color: var(--bad); }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #1f1b16;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
}

.doc-list { display: flex; flex-direction: column; gap: 8px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .side { min-height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .history { max-height: 240px; }
  .item-row { grid-template-columns: 1fr; }
}
