:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #1d1c1a;
  --muted: #6b6862;
  --line: #e4e1db;
  --accent: #2f5d8a;
  --accent-text: #ffffff;
  --high: #b5452f;
  --tag: #eef2f7;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --card: #1f1f1d;
    --text: #ecebe8;
    --muted: #9b9890;
    --line: #33322f;
    --accent: #6d9fd0;
    --accent-text: #0e1620;
    --high: #e07a62;
    --tag: #26303b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
header, main { max-width: 760px; margin: 0 auto; padding: 0 16px; }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 20px; flex-wrap: wrap; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 8px; }
h3 { font-size: 0.95rem; margin: 12px 0 6px; }
.muted { color: var(--muted); font-size: 0.9rem; }
.count { font-weight: normal; font-size: 0.85rem; }

nav { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 3px; }
nav button { background: transparent; color: var(--text); border: 0; }
nav button.active { background: var(--accent); color: var(--accent-text); }

button {
  font: inherit; font-size: 0.9rem; cursor: pointer;
  background: var(--accent); color: var(--accent-text);
  border: 1px solid transparent; border-radius: 7px; padding: 6px 12px;
}
button.secondary, .actions button { background: transparent; color: var(--text); border-color: var(--line); }
button.danger { color: var(--high); border-color: var(--high); }
button:disabled { opacity: 0.5; cursor: default; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; min-width: 0;
}
textarea { width: 100%; resize: vertical; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 14px 0; }
#add { margin: 16px 0; display: grid; gap: 8px; }
#add-title { width: 100%; font-size: 1.05rem; padding: 10px 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > select, .row > input { flex: 1 1 120px; }

ul { list-style: none; margin: 0; padding: 0; }
.todo, .suggestion { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--line); }
.todo:first-child, .suggestion:first-child { border-top: 0; }
.todo .done { margin-top: 4px; width: 18px; height: 18px; flex: none; }
.body { flex: 1; min-width: 0; }
.title { overflow-wrap: anywhere; }
.notes { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.9rem; color: var(--muted); }
.notes:empty, .meta:empty { display: none; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.actions button { padding: 4px 9px; font-size: 0.82rem; }
.todo.high .title { font-weight: 600; }
.todo.overdue .meta { color: var(--high); }
.edit-form { display: grid; gap: 8px; width: 100%; }

.ai-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.ai-head h2 { margin: 0; }
#digest-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 4px; }
.tag { display: inline-block; font-size: 0.75rem; background: var(--tag); border-radius: 5px; padding: 1px 7px; margin-bottom: 3px; }
.suggestion.archive .tag { color: var(--muted); }
.suggestion.do_next .tag { color: var(--high); }

#projects-box summary { cursor: pointer; font-weight: 600; }
#add-project-form { display: flex; gap: 8px; margin: 10px 0; }
#add-project-form input { flex: 1; }
#project-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
#project-list li span:first-child { flex: 1; }
.empty { text-align: center; padding: 24px 0; }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: 8px;
  max-width: calc(100% - 32px); font-size: 0.9rem;
}

@media (max-width: 520px) {
  .todo { flex-wrap: wrap; }
  .todo .actions { width: 100%; justify-content: flex-start; padding-left: 28px; }
}

/* sign-in, account, link buttons */
a { color: var(--accent); }
a.button {
  display: inline-block; text-decoration: none; font-size: 0.9rem;
  background: var(--accent); color: var(--accent-text);
  border: 1px solid transparent; border-radius: 7px; padding: 6px 12px;
}
a.button.secondary { background: transparent; color: var(--text); border-color: var(--line); }
.small { font-size: 0.82rem; }
#signin { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
#signin[hidden], #app[hidden] { display: none; }
.signin-card { max-width: 420px; text-align: center; padding: 28px 24px; }
.signin-card .button { font-size: 1rem; padding: 10px 18px; margin: 8px 0 14px; }
#account-box summary { cursor: pointer; font-weight: 600; }
#account-box .row { margin-top: 8px; }
.prose { max-width: 680px; margin: 0 auto; padding: 24px 16px 48px; }
.prose h1 { margin-bottom: 4px; }
.prose li { margin: 6px 0; }
