:root {
  --ground: #F4F3EF;
  --card: #FFFFFF;
  --ink: #1F1E1B;
  --muted: #5C5A55;
  --line: #E3E1DA;
  --accent: #2450C7;
  --accent-dark: #1A3C99;
  --done: #6E6C66;
  --error: #B3261E;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: "Source Sans 3", system-ui, sans-serif;
}

main {
  max-width: 784px;
  margin: 0 auto;
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (max-width: 480px) {
  main { padding: 24px 16px; }
}

h1 { margin: 0; font-size: 32px; font-weight: 700; letter-spacing: -0.01em; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Add form */
.add-row { display: flex; gap: 8px; }
.add-row input {
  flex: 1; min-width: 0;
  font: inherit; font-size: 17px; color: var(--ink);
  padding: 12px 14px;
  border: 2px solid var(--line); border-radius: 8px;
  background: var(--card);
}
.add input:focus { outline: none; border-color: var(--accent); }
.add input[aria-invalid="true"] { border-color: var(--error); }
.add button[type="submit"] {
  font: inherit; font-size: 16px; font-weight: 600; color: #FFFFFF;
  background: var(--accent); border: none; border-radius: 8px;
  padding: 0 20px; min-height: 48px; cursor: pointer;
}
.add button[type="submit"]:hover { background: var(--accent-dark); }
.error { margin: 6px 0 0; font-size: 14px; color: var(--error); }
#error { margin: 0; }
#error:empty { display: none; }

/* Toolbar */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.counter { font-size: 14px; color: var(--muted); }
.filter {
  font: inherit; font-size: 14px; font-weight: 600; color: var(--accent);
  background: none; border: 1px solid var(--line); border-radius: 999px;
  padding: 0 14px; min-height: 36px; cursor: pointer;
}

/* Empty state */
#empty-state {
  background: var(--card); border: 1px dashed var(--line); border-radius: 10px;
  padding: 48px 24px; text-align: center;
}
#empty-state:empty { display: none; }
.empty-title { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
.empty-hint { margin: 0; font-size: 15px; color: var(--muted); }

/* List */
#items {
  list-style: none; margin: 0; padding: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden;
}
#items:not(:has(li)) { display: none; }
.item { display: flex; align-items: flex-start; gap: 4px; padding: 0 4px; }
/* The 44 px box centre meets the centre of the first text line (canvas page 15). */
.item .check { margin-top: -2px; }
.item + .item { border-top: 1px solid var(--line); }

.check, .delete {
  width: 44px; height: 44px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 0; cursor: pointer;
}
/* Drag order (spec 2026-10-12): only the grip starts a drag. touch-action
   lets a finger on the grip drag the row instead of scrolling the page. */
.grip, .grip-space { width: 24px; height: 44px; flex-shrink: 0; margin-top: -2px; }
.grip {
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 0;
  color: var(--muted); cursor: grab; touch-action: none;
}
.dragging, .dragging * { cursor: grabbing; }
.drag-ghost { opacity: 0.4; }
.drag-chosen { background: var(--card); }
.box {
  width: 20px; height: 20px; border-radius: 5px;
  border: 2px solid var(--muted); background: var(--card);
  display: flex; align-items: center; justify-content: center;
}
.done .box { background: var(--accent); border-color: var(--accent); }

.text-col {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 2px; padding: 8px 0;
}
.text {
  min-width: 0; text-align: left;
  font: inherit; font-size: 17px; line-height: 1.4; color: var(--ink);
  padding: 0; background: none; border: none; cursor: text;
  overflow-wrap: anywhere;
}
.meta { font-size: 13px; line-height: 1.3; color: var(--muted); }
.due.overdue { color: var(--error); font-weight: 600; }
.postpone { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.postpone-btn {
  font: inherit; font-size: 12px; font-weight: 600; color: var(--accent);
  background: #EEF2FC; border: 1px solid #C9D6F5; border-radius: 999px;
  padding: 0 10px; min-height: 28px; cursor: pointer;
}
.postpone-btn:hover { background: #DCE5FA; }
.done .text { color: var(--done); text-decoration: line-through; }

.delete { color: var(--muted); border-radius: 8px; }
.delete:hover { color: var(--error); }
.editing .check, .editing .delete { cursor: default; opacity: 0.5; }

/* Edit mode */
.edit { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding: 8px 0; }
.edit > input {
  font: inherit; font-size: 17px; color: var(--ink);
  padding: 8px 10px; border: 2px solid var(--accent); border-radius: 6px;
  background: var(--card); outline: none;
}
.edit input[aria-invalid="true"] { border-color: var(--error); }
.hint { margin: 0; font-size: 13px; color: var(--muted); }
.hint.error { color: var(--error); }

/* Due date inputs */
.due-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.add .due-line { margin-top: 8px; }
.due-line label { font-size: 14px; font-weight: 600; color: var(--muted); }
.due-line input {
  font: inherit; font-size: 15px; color: var(--ink);
  padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card);
}
.due-line input[aria-invalid="true"] { border-color: var(--error); }
.due-line input:user-invalid { border-color: var(--error); }
.due-line input.due-time { width: 7ch; }
.clear-due {
  font: inherit; font-size: 14px; color: var(--accent);
  background: none; border: none; padding: 6px 4px; cursor: pointer;
}

/* Notification permission bar */
.notify-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #EEF2FC; border: 1px solid #C9D6F5; border-radius: 10px;
  padding: 10px 14px; font-size: 14px;
}
.notify-bar:empty { display: none; }
.notify-bar button {
  font: inherit; font-size: 14px; font-weight: 600; color: #FFFFFF;
  background: var(--accent); border: none; border-radius: 8px;
  padding: 0 14px; min-height: 36px; cursor: pointer; white-space: nowrap;
}
.notify-bar.blocked { background: none; border: none; padding: 2px 4px; font-size: 13px; color: var(--muted); }

/* Header with the user */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.user-nav { font-size: 14px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.user-nav strong { color: var(--ink); }
.inline-form { display: inline; margin: 0; }
.link-button { font: inherit; color: var(--accent); background: none; border: none; padding: 0; cursor: pointer; text-decoration: underline; }

/* Log in, sign up, account */
.auth-wrap { max-width: 400px; margin: 0 auto; padding: 40px 16px; display: flex; flex-direction: column; gap: 20px; }
.auth-brand { margin: 0; text-align: center; font-size: 30px; font-weight: 700; }
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.auth-card h1 { margin: 0; font-size: 22px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 600; }
.field input {
  font: inherit; font-size: 16px; color: var(--ink); padding: 10px 12px;
  border: 2px solid var(--line); border-radius: 8px; background: var(--card); width: 100%;
}
.field input:focus { outline: none; border-color: var(--accent); }
.field input[aria-invalid="true"] { border-color: var(--error); }
.field .hint, .note { margin: 0; font-size: 13px; color: var(--muted); }
.note { background: var(--ground); border-radius: 8px; padding: 10px 12px; }
.field-error { font-size: 13px; color: var(--error); }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 72px; }
.show-password {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  font: inherit; font-size: 14px; font-weight: 600; color: var(--accent);
  background: none; border: none; padding: 8px; min-height: 36px; cursor: pointer;
}
.check-line { display: flex; align-items: center; gap: 10px; font-size: 15px; min-height: 32px; }
.check-line input { width: 20px; height: 20px; }
.btn-primary {
  font: inherit; font-size: 16px; font-weight: 600; color: #FFFFFF; background: var(--accent);
  border: none; border-radius: 8px; min-height: 48px; padding: 0 20px; cursor: pointer;
}
.btn-primary:hover { background: var(--accent-dark); }
.alert { background: #FCEDEC; color: var(--error); border: 1px solid #F2C4C0; border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.alert.ok { background: #EAF5EC; color: #1E6B32; border-color: #BFE0C7; }
.auth-foot { margin: 0; text-align: center; font-size: 15px; color: var(--muted); }

/* Account page */
.account-wrap { max-width: 560px; margin: 0 auto; padding: 24px 16px 40px; display: flex; flex-direction: column; gap: 20px; }
.account-wrap h1 { margin: 0; font-size: 28px; }
.account-wrap h2 { margin: 0; font-size: 20px; }
.account-top { display: flex; align-items: center; justify-content: space-between; font-size: 15px; }
.account-who { margin: 0; font-size: 15px; color: var(--muted); }
.account-who strong { color: var(--ink); }
.danger-zone { border: 2px solid #F2C4C0; }
.danger-zone h2 { color: var(--error); }
.danger-zone p { margin: 0; font-size: 15px; }
.btn-danger {
  font: inherit; font-size: 15px; font-weight: 600; color: #FFFFFF; background: var(--error);
  border: none; border-radius: 8px; min-height: 44px; padding: 0 16px; cursor: pointer;
}

/* Honeypot: hidden from people, visible to simple bots. */
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.btn-primary:disabled { opacity: 0.75; cursor: progress; }

#signup-check-error:empty { display: none; }
