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

:root {
  --bg: #121212;
  --card: #1e1e1e;
  --accent: #00bcd4;
  --text: #ffffff;
  --text-dim: #888888;
  --danger: #ef5350;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ── PIN Screen ── */
.pin-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pin-container {
  width: 100%;
  max-width: 320px;
  text-align: center;
  padding: 0 24px;
}

.pin-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 36px;
  color: var(--accent);
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--text-dim);
  background: transparent;
  transition: background 0.15s, border-color 0.15s;
}

.dot.filled {
  background: var(--accent);
  border-color: var(--accent);
}

.pin-error {
  color: var(--danger);
  font-size: 14px;
  height: 20px;
  margin-bottom: 8px;
  transition: opacity 0.2s;
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 20px;
}

.key {
  aspect-ratio: 1.4;
  max-height: 64px;
  border: none;
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-size: 26px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
  user-select: none;
}

.key:active {
  background: #333;
}

.key-empty {
  background: transparent;
  cursor: default;
}

.key-del {
  font-size: 22px;
  color: var(--text-dim);
  background: transparent;
}

.key-del:active {
  background: rgba(255,255,255,0.05);
}

/* ── shake animation ── */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-6px); }
  80%      { transform: translateX(6px); }
}

.pin-dots.shake {
  animation: shake 0.4s ease;
}

/* ── Main App ── */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.header {
  flex-shrink: 0;
  padding: 16px 20px 8px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
}

.header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

/* ── Task List ── */
.task-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 8px;
  -webkit-overflow-scrolling: touch;
}

.task-item {
  background: var(--card);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.3s, transform 0.3s;
  user-select: none;
}

.task-item.completing {
  animation: fadeSlide 0.35s ease forwards;
}

@keyframes fadeSlide {
  to { opacity: 0.5; transform: translateX(0); }
}

.task-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--text-dim);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s;
}

.task-item.done .task-check {
  border-color: var(--accent);
  background: var(--accent);
}

.task-check-icon {
  display: none;
  width: 12px;
  height: 12px;
}

.task-item.done .task-check-icon {
  display: block;
}

.task-text {
  flex: 1;
  font-size: 16px;
  line-height: 1.4;
  transition: color 0.2s;
  word-break: break-word;
}

.task-item.done .task-text {
  text-decoration: line-through;
  color: var(--text-dim);
}

.task-delete {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.task-delete:hover {
  color: var(--danger);
  background: rgba(239, 83, 80, 0.12);
}

/* removing animation */
.task-item.removing {
  animation: removeSlide 0.3s ease forwards;
}

@keyframes removeSlide {
  to {
    opacity: 0;
    transform: translateX(60px);
    height: 0;
    padding: 0 16px;
    margin-bottom: 0;
  }
}

/* empty state */
.empty-state {
  text-align: center;
  color: var(--text-dim);
  margin-top: 40vh;
  font-size: 15px;
}

/* ── Add Bar ── */
.add-bar {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  background: var(--bg);
  border-top: 1px solid #2a2a2a;
}

.add-bar input {
  flex: 1;
  background: var(--card);
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  font-family: inherit;
}

.add-bar input::placeholder {
  color: var(--text-dim);
}

.add-bar input:focus {
  box-shadow: 0 0 0 1px var(--accent);
}

#add-btn {
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-size: 26px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}

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

/* scrollbar */
.task-list::-webkit-scrollbar { width: 4px; }
.task-list::-webkit-scrollbar-track { background: transparent; }
.task-list::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }
