:root {
  --bg: #f6f4f1;
  --card: #ffffff;
  --text: #2b2622;
  --muted: #8a8079;
  --line: #ebe6e1;
  --danger: #d6453d;
  --danger-soft: #fde6e4;
  --warn: #b7791f;
  --warn-soft: #fbf0d9;
  --ok-soft: #eef0ee;
  --accent: #e8773a;
  --accent-soft: #fdeadd;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1917;
    --card: #282522;
    --text: #f1ece7;
    --muted: #9c928a;
    --line: #39342f;
    --danger: #f0736b;
    --danger-soft: #472624;
    --warn: #e5b45a;
    --warn-soft: #403419;
    --ok-soft: #33302c;
  }
}

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

html, body { margin: 0; background: var(--bg); color: var(--text); }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 96px);
}

.topbar { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.topbar h1 { font-size: 26px; margin: 0; }
.muted { color: var(--muted); font-size: 13px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  flex: none; padding: 7px 14px; border-radius: 999px; background: var(--card);
  border: 1px solid var(--line); font-size: 14px; white-space: nowrap;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; }
.card.tap { display: block; width: 100%; text-align: left; }
.section-title { font-size: 13px; color: var(--muted); margin: 18px 4px 8px; }

.row { display: flex; align-items: center; gap: 12px; }
.row .grow { flex: 1; min-width: 0; }
.icon { font-size: 26px; width: 34px; text-align: center; flex: none; }
.title { font-weight: 600; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { flex: none; font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--ok-soft); color: var(--muted); }
.badge.overdue { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.badge.soon { background: var(--warn-soft); color: var(--warn); font-weight: 600; }

.actions { display: flex; gap: 8px; margin-top: 12px; }
.btn {
  flex: 1; padding: 10px 12px; border-radius: 10px; background: var(--ok-soft);
  font-size: 15px; text-align: center;
}
.btn.primary { background: var(--accent); color: #fff; font-weight: 600; }
.btn.soft { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn:disabled { opacity: 0.45; }

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

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button { flex: 1; max-width: 186px; padding: 9px 0 7px; font-size: 12px; color: var(--muted); }
.tabbar button span { display: block; font-size: 22px; line-height: 1.2; }
.tabbar button.on { color: var(--accent); font-weight: 600; }

.fab {
  position: fixed; right: max(16px, calc(50vw - 264px)); bottom: calc(env(safe-area-inset-bottom) + 76px); z-index: 6;
  width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff;
  font-size: 30px; line-height: 1; box-shadow: 0 6px 18px rgb(0 0 0 / 0.22);
}

.mask { position: fixed; inset: 0; z-index: 20; background: rgb(0 0 0 / 0.42); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto;
  background: var(--bg); border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px);
}
.sheet h2 { font-size: 18px; margin: 0 0 14px; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin: 0 4px 5px; }
.field input, .field textarea, .field select {
  display: block; width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); -webkit-appearance: none; appearance: none;
}
.field textarea { min-height: 76px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.two { display: flex; gap: 10px; }
.two > * { flex: 1; min-width: 0; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 30;
  max-width: 528px; margin: 0 auto; display: flex; align-items: center; gap: 12px;
  background: #2b2622; color: #fff; border-radius: 12px; padding: 12px 14px; font-size: 15px;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.25);
}
.toast .grow { flex: 1; }
.toast button { color: #ffc49c; font-weight: 600; flex: none; }

[hidden] { display: none !important; }
