:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1f2328;
  --muted: #6b7280;
  --accent: #2563eb;
  --danger: #dc2626;
  --border: #e5e7eb;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
}
header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
header h1 { margin: 0; font-size: 18px; }
#sync-btn { border: none; background: none; font-size: 18px; cursor: pointer; }
#sync-btn.spinning { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
main { max-width: 640px; margin: 0 auto; padding: 12px 12px 140px; }
.sub { font-size: 13px; color: var(--muted); margin: 18px 4px 6px; }
.empty { color: var(--muted); text-align: center; margin-top: 40px; }
.item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.item .check { width: 20px; height: 20px; flex-shrink: 0; }
.item .body { flex: 1; min-width: 0; }
.item .title { word-break: break-word; }
.item.done .title { text-decoration: line-through; color: var(--muted); }
.meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; font-size: 12px; }
.badge { background: var(--bg); border-radius: 6px; padding: 1px 6px; color: var(--muted); }
.badge.cw { background: #e8f1fd; color: var(--accent); }
.badge.gcal { background: #e9f5ee; color: #1c7c4a; }
.due-label { color: var(--muted); }
.due-label.overdue { color: var(--danger); font-weight: 600; }
.item button { border: none; background: none; cursor: pointer; font-size: 15px; color: var(--muted); padding: 4px; }
.item .promote { color: var(--accent); }
#add-btn {
  position: fixed; right: 20px; bottom: calc(76px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%;
  border: none; background: var(--accent); color: #fff;
  font-size: 28px; line-height: 1; cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs button {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0; font-size: 18px; color: var(--muted);
}
#tabs button span { font-size: 11px; }
#tabs button.active { color: var(--accent); font-weight: 600; }
dialog {
  border: none; border-radius: 12px; padding: 16px;
  width: min(92vw, 420px);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.3); }
#task-form { display: flex; flex-direction: column; gap: 10px; }
#task-form textarea, #task-form input:not([type="checkbox"]) {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; font-size: 15px; font-family: inherit; width: 100%;
}
.idea-check { font-size: 14px; color: var(--muted); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-actions button {
  border: none; border-radius: 8px; padding: 8px 16px;
  cursor: pointer; font-size: 14px;
}
#f-cancel { background: var(--bg); }
#f-save { background: var(--accent); color: #fff; }
