[hidden] { display: none !important; }
:root {
  --bg: #f6f5f2; --card: #ffffff; --text: #1d1d1f; --muted: #6e6e73; --line: #e4e2dd;
  --accent: #d9532b; --accent-soft: #fbe6de; --overdue: #c62828; --high: #d9532b; --low: #8e8e93;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151515; --card: #1f1f1f; --text: #f2f2f2; --muted: #9a9a9f; --line: #2e2e2e;
    --accent: #ff7a50; --accent-soft: #3a2219; --overdue: #ff6b6b; --high: #ff7a50; --low: #7c7c80;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 96px); }
h1 { font-size: 32px; margin: 8px 0 16px; letter-spacing: -0.02em; }
header { display: flex; align-items: center; justify-content: space-between; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: 10px 14px; background: var(--line); color: var(--text); }
button.primary, #add-form button, #login-form button { background: var(--accent); color: #fff; }
button.danger { background: transparent; color: var(--overdue); padding-left: 0; }
button.icon { background: transparent; font-size: 22px; color: var(--muted); padding: 8px; }
button.icon svg, #tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }
.header-actions { display: flex; gap: 2px; }
#search-bar { margin-bottom: 12px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--card); width: 100%;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
}
textarea { resize: vertical; }
#add-form, #login-form { display: flex; gap: 8px; margin-bottom: 12px; }
#add-form { margin-bottom: 6px; }
#add-form button { width: 46px; font-size: 22px; padding: 0; }
#add-preview { display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; margin: 0 2px 6px; }
#add-preview span { font-size: 13px; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
#add-preview .high { background: var(--accent); color: #fff; }
#add-preview .low { background: var(--line); color: var(--muted); }
/* Floats over the list so showing/hiding it never shifts what you're about to tap. */
#add-form { position: relative; }
#add-hint { position: absolute; z-index: 5; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 8px 10px; font-size: 12px; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 16px rgb(0 0 0 / 0.08); }
#add-hint b { font-weight: 500; color: var(--text); }
.error { color: var(--overdue); }

#filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
#filters button { white-space: nowrap; padding: 6px 12px; border-radius: 999px; font-size: 14px; background: var(--card); border: 1px solid var(--line); }
#filters button.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.group h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 20px 4px 6px; font-weight: 600; }
.group.overdue h2 { color: var(--overdue); }
.group ul { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: 14px; border: 1px solid var(--line); overflow: hidden; }
.task { position: relative; border-top: 1px solid var(--line); touch-action: pan-y; overflow: hidden; }
.task:first-child { border-top: 0; }
.task > .row { position: relative; z-index: 1; display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; background: var(--card); transition: transform 0.15s ease; }
.task.swiping > .row { transition: none; }
.swipe-hint { position: absolute; inset: 0; display: flex; align-items: center; padding: 0 18px; font-size: 14px; font-weight: 600; color: #fff; }
.swipe-hint.left { background: #3a9d5d; justify-content: flex-start; opacity: 0.55; }
.swipe-hint.right { background: #e0a100; justify-content: flex-end; opacity: 0.55; }
.task.arm-left .swipe-hint.left, .task.arm-right .swipe-hint.right { opacity: 1; }
.task:not(.swiping) .swipe-hint { visibility: hidden; }
.check {
  flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%; padding: 0;
  border: 2px solid var(--muted); background: transparent;
}
.task.high .check { border-color: var(--high); }
.task.done .check { background: var(--accent); border-color: var(--accent); }
.task.done .check::after { content: "✓"; color: #fff; font-size: 13px; line-height: 18px; display: block; text-align: center; }
.body { flex: 1; min-width: 0; cursor: pointer; }
.title { overflow-wrap: anywhere; }
.task.done .title { color: var(--muted); text-decoration: line-through; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 2px; }
.meta .project { color: var(--accent); }
.meta .late { color: var(--overdue); }
.meta .repeat, .meta .steps { white-space: nowrap; }
.meta .notes { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.empty { color: var(--muted); text-align: center; padding: 48px 0; }
.show-done { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; margin: 20px 4px; }
.show-done input { width: auto; }
.kbd-hint { display: none; font-size: 12px; color: var(--muted); text-align: center; margin-top: 24px; }
kbd { font: inherit; font-size: 11px; padding: 1px 5px; border: 1px solid var(--line); border-radius: 4px; background: var(--card); }
@media (hover: hover) and (pointer: fine) { .kbd-hint { display: block; } }

/* Tab bar at the bottom on iPhone, sidebar on a wide Mac window. */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around;
  padding: 6px 4px calc(env(safe-area-inset-bottom) + 6px);
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
#tabs button { position: relative; flex: 1; max-width: 110px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px; background: transparent; color: var(--muted); font-size: 11px; border-radius: 10px; }
#tabs button.active { color: var(--accent); }
#tabs .badge { position: absolute; top: 0; left: calc(50% + 6px); font-style: normal; font-size: 10px; font-weight: 600; min-width: 16px; height: 16px; line-height: 16px; padding: 0 4px; border-radius: 8px; background: var(--muted); color: var(--bg); }
#tabs .badge.late { background: var(--overdue); color: #fff; }
#tabs .badge:empty { display: none; }
@media (min-width: 900px) {
  #tabs { top: 0; right: auto; width: 200px; flex-direction: column; justify-content: flex-start; gap: 2px; padding: 72px 10px 16px; border-top: 0; border-right: 1px solid var(--line); }
  #tabs button { max-width: none; flex: none; flex-direction: row; gap: 10px; font-size: 15px; padding: 9px 12px; }
  #tabs button.active { background: var(--accent-soft); }
  #tabs .badge { position: static; margin-left: auto; }
  main { padding-left: calc(200px + 32px); max-width: calc(640px + 232px); padding-bottom: 48px; }
}

#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 76px); z-index: 20;
  display: flex; align-items: center; gap: 14px; padding: 10px 10px 10px 16px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: 14px; box-shadow: 0 6px 24px rgb(0 0 0 / 0.2); max-width: calc(100vw - 32px);
}
#toast span { white-space: nowrap; }
#toast button { background: transparent; color: var(--accent); font-weight: 600; padding: 4px 8px; }
@media (min-width: 900px) { #toast { bottom: 24px; left: calc(50% + 100px); } }

dialog { border: 0; border-radius: 16px; padding: 20px; width: min(520px, calc(100vw - 32px)); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / 0.4); }
#edit-form { display: grid; gap: 12px; }
#edit-form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
#edit-form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#edit-form .actions { display: flex; gap: 8px; align-items: center; }
#edit-form .actions span { flex: 1; }
#edit-form label.inline { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--text); padding-top: 18px; }
#edit-form label.inline input { width: auto; }
.subtasks { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.subtasks legend { font-size: 13px; color: var(--muted); padding: 0; margin-bottom: 4px; }
#subtask-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
#subtask-list li { display: flex; align-items: center; gap: 8px; }
#subtask-list input[type="checkbox"] { width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
#subtask-list input:not([type]) { padding: 6px 10px; }
#subtask-list li:has(input:checked) input:not([type]) { text-decoration: line-through; color: var(--muted); }
#subtask-list .remove { font-size: 20px; padding: 0 6px; }
#subtask-new { padding: 6px 10px; }
