:root {
  --accent:  #4F46E5;
  --text:    #111827;
  --muted:   #9CA3AF;
  --border:  #E5E7EB;
  --bg:      #F3F4F6;
  --card:    #FFFFFF;
}

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

html, body {
  height: 100%;
  overscroll-behavior: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { background: var(--bg); color: var(--text); }

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  /* safe-area padding applied per-zone below */
}

/* ── Header ── */

header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.6px;
  color: var(--text);
}

#add-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#add-btn:active { opacity: 0.8; }

/* ── Add form ── */

#add-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

#new-task-input {
  flex: 1;
  height: 44px;
  border: 2px solid var(--accent);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 16px;
  color: var(--text);
  outline: none;
  background: #fff;
}

#add-confirm,
#add-cancel {
  height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

#add-confirm { background: var(--accent); color: #fff; }
#add-cancel  { background: var(--border);  color: var(--text); }

#add-confirm:active { opacity: 0.85; }
#add-cancel:active  { opacity: 0.75; }

/* ── Task list ── */

main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#task-list { list-style: none; }

#task-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 8px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  min-height: 56px;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}

#task-list li.dragging { opacity: 0; }

body.dragging-active { user-select: none; -webkit-user-select: none; cursor: grabbing; }

/* ghost clone appended to body while dragging */
#drag-ghost {
  background: var(--card);
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
}

.check-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

.check-btn:active { transform: scale(0.9); }

.task-title {
  flex: 1;
  font-size: 17px;
  line-height: 1.4;
  cursor: text;
  word-break: break-word;
  padding: 6px 0;
  user-select: none;
  -webkit-user-select: none;
}

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

.edit-input {
  flex: 1;
  height: 40px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 17px;
  color: var(--text);
  outline: none;
  background: #fff;
  font-family: inherit;
}

.drag-handle {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: var(--muted);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
}

/* ── Footer ── */

footer {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px);
  background: var(--card);
  border-top: 1px solid var(--border);
}

footer button {
  flex: 1;
  height: 44px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}

footer button:active { background: var(--bg); }

/* ── All-done overlay ── */

#all-done-overlay {
  position: fixed;
  inset: 0;
  background: rgba(79, 70, 229, 0.12);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

#all-done-overlay.visible { opacity: 1; }

#all-done-message {
  background: #fff;
  border-radius: 22px;
  padding: 30px 44px;
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.5px;
  box-shadow: 0 24px 64px rgba(79, 70, 229, 0.22);
}
