*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --orange:  #c84b1e;
  --blue:    #3a72c4;
  --yellow:  #f4c235;
  --teal:    #48b8a0;
  --purple:  #7b6db8;
  --coral:   #e8623a;
  --cream:   #ffffff;
  --card:    whitesmoke;
  --card-done: whitesmoke;
  --ink:     #1c1410;
  --muted:   #a09080;
}

body {
  font-family: 'Mulish', sans-serif;
  background: var(--cream);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 60px 20px;
  scrollbar-gutter: stable both-edges;
  touch-action: manipulation;
}

.container {
  width: 100%;
  max-width: 520px;
}

h1 {
  font-family: 'Syne', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: #000;
  margin-bottom: 28px;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.add-btn {
  margin-left: auto;
  padding: 5px 14px;
  border-radius: 999px;
  border: none;
  background: var(--teal);
  color: #fff;
  font-family: 'Syne', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.add-btn:hover { background: #37a08a; }

.status {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e0e0e0;
  color: #aaa;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Material Symbols Rounded';
  font-size: 16px;
  line-height: 1;
  transition: background 0.2s, color 0.2s;
  cursor: default;
  flex-shrink: 0;
  user-select: none;
}

.status.loading { background: #e0e0e0; color: #aaa; animation: spin 1s linear infinite; }
.status.saving  { background: #fdefc3; color: #8a6200; }
.status.saved   { background: #c4ede5; color: #1e6e5a; }
.status.error   { background: #f5cfc4; color: #8a2010; }

@keyframes spin { to { transform: rotate(360deg); } }

form#todo-form {
  display: none;
  gap: 0;
  margin-bottom: 16px;
  background: whitesmoke;
  border-radius: 999px;
  padding: 4px 4px 4px 20px;
  align-items: center;
}

form#todo-form.visible { display: flex; }

input[type="text"] {
  flex: 1;
  padding: 8px 0;
  border: none;
  border-radius: 0;
  font-size: 0.95rem;
  font-family: 'Mulish', sans-serif;
  font-weight: 600;
  background: transparent;
  outline: none;
  color: var(--ink);
  min-width: 0;
}

input[type="text"]::placeholder { color: var(--muted); font-weight: 400; }

button[type="submit"] {
  padding: 8px 18px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 0.82rem;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

button[type="submit"]:hover { background: #2e5fa8; }

ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }

li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  background: var(--card);
  border-radius: 999px;
}

li.done { background: var(--card-done); }

li.done .todo-text {
  text-decoration: line-through;
  color: var(--muted);
}

.check {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 1.5px solid lightgray;
  border-radius: 4px;
  cursor: pointer;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}

li.done .check {
  background: var(--teal);
  border-color: var(--teal);
}

li.done .check::after {
  content: '';
  display: block;
  width: 4px;
  height: 8px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

.todo-body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.todo-text {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.due-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}

.due-label {
  font-size: 0.8rem;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.due-label:hover { color: var(--muted); }
.due-label.overdue { color: var(--coral); }
.due-label.today   { color: var(--ink); }

.add-due {
  font-size: 0.8rem;
  color: #c0b0a0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
}

.add-due:hover { color: var(--muted); }

.delete-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.delete {
  background: none;
  border: none;
  color: #c0b0a0;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}

.delete:hover { color: var(--muted); }

.delete-confirm {
  display: flex;
  align-items: center;
  gap: 4px;
}

.delete-yes {
  font-size: 0.75rem;
  background: var(--coral);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 2px 7px;
  cursor: pointer;
}

.delete-yes:hover { background: var(--orange); }

.delete-cancel {
  font-size: 0.75rem;
  background: none;
  color: var(--muted);
  border: none;
  cursor: pointer;
  padding: 2px 4px;
}

.delete-cancel:hover { color: var(--ink); }

.empty {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 16px 0;
}

/* auth screen */
#auth-screen {
  width: 100%;
  max-width: 520px;
}

#auth-screen h1 {
  margin-bottom: 32px;
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-field {
  background: whitesmoke;
  border-radius: 999px;
  padding: 4px 4px 4px 20px;
  display: flex;
  align-items: center;
}

.auth-field input {
  flex: 1;
  padding: 8px 0;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.95rem;
  font-family: 'Mulish', sans-serif;
  font-weight: 600;
  color: var(--ink);
  min-width: 0;
}

.auth-field input::placeholder { color: var(--muted); font-weight: 400; }

#auth-form button {
  padding: 12px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 0.82rem;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s;
}

#auth-form button:hover { background: #2e5fa8; }

#auth-error {
  font-size: 0.82rem;
  color: var(--coral);
  padding: 4px 20px;
  min-height: 1.2em;
}

.signout-btn {
  background: none;
  border: none;
  font-family: 'Material Symbols Rounded';
  font-size: 16px;
  color: #c0b0a0;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  display: flex;
  align-items: center;
}

.signout-btn:hover { color: var(--muted); }

@media (max-width: 480px) {
  body { padding: 40px 24px; }
  li { padding: 10px 14px; gap: 8px; }
  .todo-text { font-size: 0.9rem; }
  .due-label, .add-due { font-size: 0.72rem; }
  .delete-yes, .delete-cancel { font-size: 0.72rem; }
  #due-picker { max-width: calc(100vw - 28px); }
  button[type="submit"] { padding: 8px 14px; font-size: 0.78rem; }
}

#due-picker {
  position: fixed;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  display: none;
  flex-direction: column;
  gap: 6px;
  z-index: 999;
  min-width: 160px;
}

#due-picker.open { display: flex; }

#due-picker input[type="date"] {
  font-family: 'Mulish', sans-serif;
  font-size: 0.9rem;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 5px 8px;
  outline: none;
  color: var(--ink);
  width: 100%;
}

#due-picker input[type="date"]:focus { border-color: var(--blue); }

#due-picker .no-due {
  font-family: 'Mulish', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  padding: 2px 0;
}

#due-picker .no-due:hover { color: var(--coral); }

.color-btn {
  flex-shrink: 0;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: #ddd;
  padding: 0;
}

#color-picker {
  position: fixed;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
  display: none;
  flex-direction: row;
  gap: 6px;
  align-items: center;
  z-index: 999;
}

#color-picker.open { display: flex; }

.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,0.12);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.color-swatch.clear {
  background: whitesmoke;
  font-size: 0.7rem;
  color: #aaa;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
