:root {
  --bg: #fbfaf7;
  --panel: #ffffff;
  --line: #e6e2d9;
  --line-strong: #d4cec0;
  --ink: #2b2a26;
  --muted: #8a857a;
  --accent: #4a6b52;
  --accent-soft: #eef3ee;
  --danger: #9a4a3c;
  --shadow: 0 1px 2px rgba(40, 35, 25, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font: 14px/1.6 "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button { font: inherit; cursor: pointer; border-radius: 6px; border: 1px solid var(--line-strong); background: #fff; padding: 4px 12px; color: var(--ink); }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.06); }
button.ghost { background: #fff; }
button.danger { border-color: #d8b8b0; color: var(--danger); }
button.link { border: none; background: none; color: var(--muted); padding: 2px 6px; text-decoration: underline; }
button:disabled { opacity: .45; cursor: default; }

input, textarea {
  font: inherit; color: inherit; background: #fff;
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* 登录 */
.login { display: flex; align-items: center; justify-content: center; height: 100%; }
.login .card { width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px 26px; box-shadow: var(--shadow); }
.login h1 { margin: 0 0 6px; font-size: 22px; font-weight: 600; letter-spacing: 2px; }
.login .sub { font-size: 12px; color: var(--muted); margin-left: 8px; letter-spacing: 0; }
.login label { display: block; margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.login input { display: block; width: 100%; margin-top: 4px; }
.login .primary { width: 100%; margin-top: 20px; padding: 8px; }
.login .hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.login .adv { margin-top: 16px; font-size: 12px; color: var(--muted); }

/* 顶栏 */
.app { display: flex; flex-direction: column; height: 100%; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; letter-spacing: 2px; }
.brand .sub { font-size: 11px; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.status { flex: 1; color: var(--muted); font-size: 13px; }
.status.dirty { color: var(--danger); }
.actions { display: flex; align-items: center; gap: 8px; }
.who { color: var(--muted); font-size: 12px; margin-left: 6px; }

/* 标签 */
.tabs { display: flex; gap: 2px; padding: 0 18px; background: var(--panel); border-bottom: 1px solid var(--line); }
.tab { border: none; border-bottom: 2px solid transparent; background: none; border-radius: 0; padding: 8px 14px; color: var(--muted); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab b { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.tab.active b { color: var(--accent); }

/* 工具条 */
.toolbar { display: flex; align-items: center; gap: 8px; padding: 8px 18px; background: #fff; border-bottom: 1px solid var(--line); }
.toolbar input[type=search] { width: 180px; }
.sep { width: 1px; height: 18px; background: var(--line); }
.dirty { margin-left: auto; color: var(--muted); font-size: 13px; }

.batchbar { display: flex; align-items: center; gap: 10px; padding: 8px 18px; background: var(--accent-soft); border-bottom: 1px solid var(--line); font-size: 13px; }
.batchbar .inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.batchbar input[type=number] { width: 68px; }

main { flex: 1; overflow: auto; padding: 0 18px 60px; }

/* 表格 */
.grid { width: 100%; border-collapse: collapse; margin-top: 8px; background: var(--panel); }
.grid th, .grid td { border-bottom: 1px solid var(--line); padding: 6px 8px; vertical-align: top; text-align: left; }
.grid th { position: sticky; top: 0; background: var(--panel); font-weight: 500; color: var(--muted); font-size: 12px; z-index: 1; }
.grid tr:hover td { background: #fdfcf9; }
.grid tr.row-sel td { background: var(--accent-soft); }
.c-chk { width: 30px; }
.c-text { min-width: 320px; }
.c-time { width: 180px; }
.c-dur { width: 90px; color: var(--muted); font-variant-numeric: tabular-nums; }
.c-dream { width: 160px; color: var(--muted); font-size: 12px; }
.c-state { width: 160px; white-space: nowrap; }
.c-drag { width: 28px; color: var(--line-strong); cursor: grab; text-align: center; }

.grid textarea { width: 100%; resize: none; overflow: hidden; border-color: transparent; background: transparent; padding: 2px 4px; min-height: 26px; line-height: 1.5; }
.grid textarea:hover { border-color: var(--line); background: #fff; }
.grid textarea:focus { border-color: var(--accent); background: #fff; }

.grid input[type=datetime-local] { width: 100%; border-color: transparent; background: transparent; padding: 2px 4px; }
.grid input[type=datetime-local]:hover { border-color: var(--line); background: #fff; }

.done-tag { color: var(--accent); font-size: 12px; }
.unknown-tag { display: inline-block; margin-left: 4px; padding: 0 4px; border-radius: 3px; background: #f1ede4; color: var(--muted); font-size: 11px; }
.state-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.time-cell { position: relative; }
.time-cell.time-empty input[type=datetime-local] { color: transparent; }
.time-cell.time-empty::after {
  content: "未结束"; position: absolute; left: 6px; top: 3px;
  color: #b9b3a6; font-size: 12px; pointer-events: none;
}
.time-cell.time-empty:hover::after { content: "点一下填结束时间"; }
.row-actions { white-space: nowrap; }
.row-actions button { padding: 0 6px; font-size: 12px; border: none; background: none; color: var(--muted); }
.row-actions button:hover { color: var(--danger); }
.row-actions button.ok:hover { color: var(--accent); }

.addline { display: flex; gap: 8px; padding-top: 10px; }
.addline input { flex: 1; }

.empty { color: var(--muted); padding: 28px 4px; text-align: center; }

/* 设置 */
.settings { max-width: 520px; padding-top: 16px; }
.settings h3 { margin: 26px 0 8px; font-size: 13px; color: var(--muted); font-weight: 500; }
.settings label { display: block; margin: 8px 0; font-size: 13px; color: var(--muted); }
.settings label input { display: block; width: 100%; margin-top: 4px; }
.settings button { margin-top: 6px; }
.settings .hint { color: var(--muted); font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #33312b; color: #fff; padding: 8px 16px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 4px 14px rgba(0,0,0,.18); z-index: 20; max-width: 70vw;
}
.toast.err { background: #6d3327; }

.drag-over td { background: var(--accent-soft) !important; }

