:root {
  --bg: #f4f5f2; --card: #ffffff; --ink: #1d2320; --muted: #6b726e; --line: #dfe3df;
  --brand: #1f5f4a; --brand-soft: #e3efe9; --red: #c0392b; --red-soft: #fbe9e7;
  --amber: #a85d00; --amber-soft: #fff1db; --blue: #2457a6; --blue-soft: #e6eefb;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816; --card: #1d2320; --ink: #e7ece9; --muted: #9aa39e; --line: #2e3632;
    --brand: #4fb28c; --brand-soft: #1f3a30; --red: #ff7b6b; --red-soft: #3a1f1b;
    --amber: #f0b45a; --amber-soft: #3a2c16; --blue: #8fb4ff; --blue-soft: #1c2a44;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif; font-size: 16px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.pad { padding: 16px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; background: var(--brand); color: #fff; }
.brand { font-weight: 700; letter-spacing: .02em; }
.who { font-size: 14px; opacity: .95; display: flex; gap: 10px; align-items: center; }
.who a { color: #fff; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 10px 16px 0; background: var(--card); border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex: none; padding: 8px 14px 10px; border-radius: 10px 10px 0 0; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .badge { display: inline-block; min-width: 20px; margin-left: 4px; padding: 0 6px; border-radius: 10px; background: var(--red); color: #fff; font-size: 12px; text-align: center; }

.sub { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px; scrollbar-width: none; }
.sub::-webkit-scrollbar { display: none; }
.sub a { flex: none; padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 14px; }
.sub a.on { background: var(--brand); border-color: var(--brand); color: #fff; }

main { max-width: 760px; margin: 0 auto; padding: 0 16px 120px; }
h2 { font-size: 15px; margin: 18px 0 8px; color: var(--muted); font-weight: 700; }
h2.red { color: var(--red); }

.add { display: block; width: 100%; margin: 4px 0 6px; padding: 12px 14px; border: 1.5px dashed var(--brand); border-radius: 12px; background: var(--brand-soft); color: var(--brand); font-weight: 700; text-align: left; cursor: pointer; }

.card { display: flex; gap: 10px; align-items: flex-start; padding: 12px; margin-bottom: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.card.over { border-left: 4px solid var(--red); }
.check { flex: none; width: 30px; height: 30px; margin-top: 1px; border-radius: 50%; border: 2px solid var(--brand); background: transparent; cursor: pointer; display: grid; place-items: center; }
.check.done { background: var(--brand); color: #fff; }
.card .body { flex: 1; min-width: 0; }
.card .title { font-weight: 600; word-break: break-word; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; font-size: 13px; }
.chip { padding: 1px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chip.red { background: var(--red-soft); border-color: transparent; color: var(--red); font-weight: 700; }
.chip.amber { background: var(--amber-soft); border-color: transparent; color: var(--amber); font-weight: 700; }
.chip.blue { background: var(--blue-soft); border-color: transparent; color: var(--blue); font-weight: 700; }
.chip.green { background: var(--brand-soft); border-color: transparent; color: var(--brand); }
.empty { padding: 28px 8px; text-align: center; color: var(--muted); }

.search { width: 100%; padding: 10px 12px; margin: 4px 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }

.sum { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.sum a { display: block; padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; color: var(--ink); text-decoration: none; }
.sum .n { font-size: 26px; font-weight: 700; }
.sum .s { font-size: 13px; color: var(--muted); }

/* 下から出るシート */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.panel { width: 100%; max-width: 760px; max-height: 92vh; overflow-y: auto; background: var(--card); border-radius: 16px 16px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); }
.panel h3 { margin: 0 0 12px; font-size: 18px; }
label.f { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.panel input[type=text], .panel input[type=date], .panel textarea, .panel select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.panel textarea { min-height: 80px; resize: vertical; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.btn { padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { color: var(--red); }
.btn.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); }
.seg { display: flex; gap: 6px; }
.seg .btn { flex: 1; }
.detail { white-space: pre-wrap; word-break: break-word; margin: 4px 0 8px; }
.log { list-style: none; padding: 0; margin: 6px 0; font-size: 14px; }
.log li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.log .when { color: var(--muted); font-size: 12px; }
.err { color: var(--red); margin-top: 8px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; display: flex; gap: 14px; align-items: center; padding: 10px 16px; border-radius: 12px; background: #222; color: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.25); max-width: calc(100% - 32px); }
.toast[hidden] { display: none; }
.toast button { background: none; border: 0; color: #7fe0b8; font-weight: 700; cursor: pointer; }

.login { max-width: 420px; margin: 60px auto; text-align: center; padding: 0 16px; }
.login a { display: inline-block; margin-top: 16px; padding: 14px 24px; border-radius: 12px; background: var(--brand); color: #fff; text-decoration: none; font-weight: 700; }
