:root {
  color-scheme: light;
  --bg: #f7f6f3;
  --card: #ffffff;
  --ink: #1d1d1f;
  --muted: #7a7873;
  --faint: #b9b6af;
  --line: #e9e6e0;
  --accent: #2f5bd3;
  --accent-soft: #e8eefc;
  --hot: #e0531f;
  --hot-soft: #fdece4;
  --wait: #8a6d1c;
  --wait-soft: #f8f0d8;
  --ok: #2f8f5b;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd {
  font: 11px/1 var(--font);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 3px 5px;
  color: var(--muted);
  background: var(--card);
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px calc(80px + env(safe-area-inset-bottom));
}

.top { display: flex; align-items: flex-end; justify-content: space-between; margin: 8px 2px 16px; }
.top h1 { font-size: 26px; letter-spacing: -0.02em; margin: 0; }
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
}

.add {
  display: flex; align-items: center; gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.03);
  transition: border-color .15s, box-shadow .15s;
}
.add:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.add .plus { color: var(--accent); font-size: 20px; font-weight: 500; }
.add input {
  flex: 1; border: 0; outline: 0; background: transparent;
  font: 16px var(--font); padding: 14px 0; color: var(--ink); min-width: 0;
}
.add input::placeholder { color: var(--faint); }
.add:focus-within .hint { display: none; }
@media (hover: none) { .hint { display: none; } }

.preview { display: flex; flex-wrap: wrap; gap: 6px; min-height: 8px; margin: 8px 2px 10px; }
.preview:empty { margin: 0; min-height: 14px; }

.section { margin-top: 18px; }
.section-head {
  display: flex; align-items: center; gap: 8px;
  width: 100%; border: 0; background: none; padding: 4px 2px 8px;
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  text-align: left;
}
.section-head .count { font-weight: 500; color: var(--faint); letter-spacing: 0; }
.section-head .caret { margin-left: auto; color: var(--faint); transition: transform .15s; font-size: 11px; }
.section.collapsed .caret { transform: rotate(-90deg); }
.section.collapsed .rows { display: none; }
.section-now .section-head { color: var(--ink); }

.rows {
  list-style: none; margin: 0; padding: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.empty { color: var(--muted); font-size: 14px; padding: 14px 16px; }

.task {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px 11px 14px;
  border-top: 1px solid var(--line);
  position: relative;
  cursor: default;
}
.task:first-child { border-top: 0; }
.task.sel { background: var(--accent-soft); }
.task.sel::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.task.urgent .title { font-weight: 600; }

.check {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--faint); background: none; padding: 0;
  display: grid; place-items: center; transition: all .15s;
}
.check:hover { border-color: var(--ok); background: #eaf5ee; }
.task.urgent .check { border-color: var(--hot); }
.task.done .check { background: var(--ok); border-color: var(--ok); }
.task.done .check::after { content: ""; width: 6px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.task.done .title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }

.body { flex: 1; min-width: 0; cursor: pointer; }
.title { overflow-wrap: anywhere; }
.title .at { color: var(--accent); font-weight: 500; }
.title .tag { color: var(--muted); }
.note-line { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }

.meta { display: flex; gap: 6px; align-items: center; flex: none; }
.pill {
  font-size: 12px; line-height: 1; padding: 5px 8px; border-radius: 999px;
  background: #f1efea; color: var(--muted); white-space: nowrap;
}
.pill.hot { background: var(--hot-soft); color: var(--hot); }
.pill.late { background: var(--hot-soft); color: var(--hot); font-weight: 600; }
.pill.today { background: var(--accent-soft); color: var(--accent); }
.pill.wait { background: var(--wait-soft); color: var(--wait); }
.pill.acc { background: var(--accent-soft); color: var(--accent); }

.quick { display: none; gap: 2px; }
@media (hover: hover) {
  .task:hover .quick { display: flex; }
  .task:hover .meta .pill.opt { display: none; }
}
.quick button {
  border: 0; background: none; color: var(--muted); font-size: 12px;
  padding: 5px 7px; border-radius: 7px;
}
.quick button:hover { background: #f1efea; color: var(--ink); }

.signin { min-height: 100vh; display: grid; place-content: center; justify-items: center; text-align: center; gap: 6px; padding: 24px; }
.signin h1 { margin: 10px 0 0; font-size: 30px; letter-spacing: -0.02em; }
.signin p { color: var(--muted); margin: 0 0 18px; }
.signin .err { color: var(--hot); margin-top: 12px; }

.btn {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 9px 16px; font-weight: 500; text-decoration: none; color: var(--ink); display: inline-block;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--hot); border-color: transparent; background: none; padding-left: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; color: var(--ink);
}
.chip.ghost { color: var(--muted); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip.toggle#e-urgent.on { background: var(--hot-soft); border-color: var(--hot); color: var(--hot); }
.chip.toggle#e-waiting.on { background: var(--wait-soft); border-color: var(--wait); color: var(--wait); }
.chip.date { font: 13px var(--font); padding: 5px 10px; }

.sheet {
  border: 0; padding: 20px; border-radius: 16px;
  width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 40px);
  background: var(--card); color: var(--ink);
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}
.sheet::backdrop { background: rgba(30, 28, 24, .28); }
@media (max-width: 560px) {
  .sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 18px 18px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}
.e-title {
  width: 100%; border: 0; outline: 0; font: 600 18px var(--font); padding: 2px 0 8px; color: var(--ink);
}
#e-note {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px; resize: vertical;
  font: 14px/1.45 var(--font); color: var(--ink); outline: 0;
}
#e-note:focus { border-color: var(--accent); }
.row-label { font-size: 12px; font-weight: 600; color: var(--muted); margin: 16px 0 8px; text-transform: uppercase; letter-spacing: .05em; }
.select { font: 14px var(--font); padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.sheet-actions { display: flex; gap: 8px; align-items: center; margin-top: 22px; }
.spacer { flex: 1; }

.help h2 { font-size: 15px; margin: 0 0 8px; }
.help h2 + p { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.help table { border-collapse: collapse; width: 100%; font-size: 14px; margin-bottom: 18px; }
.help td { padding: 5px 8px 5px 0; vertical-align: top; }
.help td:nth-child(even) { color: var(--muted); }
.help code { background: #f1efea; padding: 1px 5px; border-radius: 5px; font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; border-radius: 12px; padding: 10px 10px 10px 16px;
  display: flex; gap: 14px; align-items: center; font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.2);
  max-width: calc(100vw - 32px); z-index: 10;
}
.toast button { border: 0; background: rgba(255,255,255,.14); color: #fff; border-radius: 8px; padding: 6px 10px; font-weight: 600; }
