:root {
  color-scheme: light dark;
  --bg-top: #e0e7ff;
  --bg-bottom: #fce7f3;
  --surface: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #cbd5e1;
  --accent: #6366f1;
  --accent-strong: #4f46e5;
  --on-accent: #ffffff;
  --danger: #dc2626;
  --shadow: 0 12px 32px rgb(49 46 129 / 0.14);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-top: #1e1b4b;
    --bg-bottom: #0f172a;
    --surface: #1e293b;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #475569;
    --accent: #818cf8;
    --accent-strong: #a5b4fc;
    --on-accent: #1e1b4b;
    --danger: #f87171;
    --shadow: 0 12px 32px rgb(0 0 0 / 0.45);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg-top), var(--bg-bottom)) fixed;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* wide screens: photo stands to the right of the card
   (34rem card centered => ~20rem free on each side from 75rem up) */
@media (min-width: 75rem) {
  body {
    background:
      url("IMG_3666.PNG") bottom right / auto min(88vh, 40rem) no-repeat fixed,
      linear-gradient(160deg, var(--bg-top), var(--bg-bottom)) fixed;
  }
}

/* narrow screens (mobile): no side space, so the photo stands at the bottom
   of the page, below the card; padding reserves the space it needs.
   scroll attachment (not fixed) — iOS Safari janks on fixed image layers */
@media (max-width: 74.99rem) {
  body {
    background:
      url("IMG_3666.PNG") bottom center / auto min(42vh, 24rem) no-repeat scroll,
      linear-gradient(160deg, var(--bg-top), var(--bg-bottom)) fixed;
    padding-bottom: min(42vh, 24rem);
  }
}

main {
  width: min(34rem, 92vw);
  margin: clamp(1.5rem, 6vh, 4rem) 0 4rem;
  padding: 1.75rem 2rem 2rem;
  background: var(--surface);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

h1 {
  margin: 0;
  font-size: 2.25rem;
  letter-spacing: -0.02em;
}

/* ---------- buttons ---------- */

button {
  font: inherit;
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

button:active {
  transform: translateY(1px);
}

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

/* primary actions */
#signin,
#add button {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

#signin:hover,
#add button:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--on-accent);
}

#logout {
  padding: 0.3rem 0.85rem;
  font-size: 0.9rem;
  color: var(--muted);
}

/* ---------- sign-in ---------- */

#login {
  text-align: center;
  padding: 2rem 0 1rem;
}

#login p {
  color: var(--muted);
  margin: 0 0 1.25rem;
}

/* ---------- list ---------- */

#list {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
}

#list li {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.5rem;
  margin: 0 -0.5rem;
  border-radius: 0.6rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  transition: background 0.15s;
}

#list li:hover {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

#list input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  flex: none;
  cursor: pointer;
  accent-color: var(--accent);
}

.item-text {
  flex: 1;
  font: inherit;
  border: none;
  background: transparent;
  color: inherit;
  padding: 0.3rem 0.15rem;
  border-radius: 0.25rem;
}

.item-text:focus {
  outline: none;
  box-shadow: inset 0 -2px var(--accent);
}

.item-text.done {
  text-decoration: line-through;
  opacity: 0.5;
}

.delete {
  border: none;
  padding: 0 0.45rem;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--muted);
  opacity: 0;
}

#list li:hover .delete,
.delete:focus-visible {
  opacity: 1;
}

.delete:hover {
  color: var(--danger);
  background: transparent;
  border: none;
}

/* touch devices have no hover — keep delete reachable */
@media (hover: none) {
  .delete {
    opacity: 0.55;
  }
}

/* ---------- add form ---------- */

#add {
  display: flex;
  gap: 0.6rem;
}

#add input {
  flex: 1;
  font: inherit;
  padding: 0.5rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: transparent;
  color: inherit;
}

#add input::placeholder {
  color: var(--muted);
}

#add input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
