/* ── Reset & tokens ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #f5f5f7;
  --surface:     #ffffff;
  --surface-2:   #f0f0f2;
  --border:      #e2e2e7;
  --accent:      #4f6ef7;
  --accent-dark: #3a57d4;
  --danger:      #f24e4e;
  --text-1:      #1a1a2e;
  --text-2:      #6b6b80;
  --text-3:      #a0a0b0;
  --done-color:  #a0a0b0;
  --radius-sm:   8px;
  --radius-md:   14px;
  --radius-lg:   20px;
  --shadow:      0 2px 16px rgba(0,0,0,.08);
  --shadow-lg:   0 8px 40px rgba(0,0,0,.18);
  --transition:  .18s ease;
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}

/* ── App shell ──────────────────────────────────────── */
.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 0 env(safe-area-inset-bottom, 16px);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────── */
.header {
  padding: 32px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header__title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header__icon { font-size: 1.4rem; }

.header__count {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 99px;
  white-space: nowrap;
}

/* ── Main ───────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 16px 24px;
}

/* ── Add form ───────────────────────────────────────── */
.form {
  display: flex;
  gap: 10px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px 6px 6px 16px;
  box-shadow: var(--shadow);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,110,247,.15);
}

.form__input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1rem;
  color: var(--text-1);
  min-width: 0;
}

.form__input::placeholder { color: var(--text-3); }

.form__btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
}

.form__btn svg { width: 20px; height: 20px; }

.form__btn:hover  { background: var(--accent-dark); }
.form__btn:active { transform: scale(.92); }

/* ── Filter tabs ────────────────────────────────────── */
.filters {
  display: flex;
  gap: 6px;
}

.filter {
  flex: 1;
  padding: 8px 4px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.filter:hover { border-color: var(--accent); color: var(--accent); }

.filter.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── List ───────────────────────────────────────────── */
.list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

/* Empty state */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 48px 20px;
  color: var(--text-3);
  font-size: .9rem;
  text-align: center;
}

.empty__icon { font-size: 2.5rem; margin-bottom: 4px; }

/* ── List item ──────────────────────────────────────── */
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  box-shadow: var(--shadow);
  animation: slide-in .2s ease;
  transition: opacity var(--transition), border-color var(--transition);
}

.item.hidden { display: none; }

@keyframes slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Checkbox */
.item__check {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  transition: all var(--transition);
  position: relative;
}

.item__check::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  opacity: 0;
  transition: opacity var(--transition);
}

.item__check:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.item__check:checked::after { opacity: 1; }

/* Label */
.item__label {
  flex: 1;
  font-size: .97rem;
  line-height: 1.4;
  word-break: break-word;
  cursor: pointer;
  transition: color var(--transition), text-decoration var(--transition);
  user-select: none;
}

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

.item.done {
  border-color: var(--surface-2);
  opacity: .75;
}

/* Action buttons */
.item__actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.item__btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--transition);
}

.item__btn svg { width: 16px; height: 16px; }

.item__btn:hover { background: var(--border); color: var(--text-1); }

.item__btn--delete:hover { background: #fde8e8; color: var(--danger); }

/* ── Footer ─────────────────────────────────────────── */
.footer {
  padding-top: 4px;
  display: flex;
  justify-content: center;
}

.footer__btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--transition);
}

.footer__btn:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: #fde8e8;
}

.footer__btn--reset {
  border-color: var(--danger);
  color: var(--danger);
}

.footer__btn--reset:hover {
  background: var(--danger);
  color: #fff;
}

#footer { display: none; }
#footer.visible { display: flex; }

/* ── Modal ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: grid;
  place-items: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  z-index: 100;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: translateY(12px);
  transition: transform var(--transition);
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal__title {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal__input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--text-1);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.modal__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,110,247,.15);
}

.modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal__btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.modal__btn--cancel {
  background: var(--surface-2);
  color: var(--text-2);
}

.modal__btn--cancel:hover { background: var(--border); }

.modal__btn--save {
  background: var(--accent);
  color: #fff;
}

.modal__btn--save:hover { background: var(--accent-dark); }

/* ── Install Banner ─────────────────────────────────── */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1.5px solid var(--border);
  box-shadow: 0 -4px 24px rgba(0,0,0,.10);
  padding: 14px 16px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 200;
  transform: translateY(100%);
  transition: transform .32s cubic-bezier(.22,.68,0,1.2);
}

.install-banner.visible { transform: translateY(0); }

.install-banner__icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}

.install-banner__icon svg { width: 24px; height: 24px; }

.install-banner__body {
  flex: 1;
  min-width: 0;
}

.install-banner__body > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.install-banner__body strong {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text-1);
}

.install-banner__body span {
  font-size: .76rem;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
}

.install-banner__share {
  width: 13px;
  height: 13px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.install-banner__add {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background var(--transition);
}

.install-banner__add:hover { background: var(--accent-dark); }

.install-banner__dismiss {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all var(--transition);
}

.install-banner__dismiss svg { width: 16px; height: 16px; }
.install-banner__dismiss:hover { background: var(--surface-2); color: var(--text-2); }

/* ── Responsive: wider screens get a card feel ──────── */
@media (min-width: 560px) {
  .app {
    padding-top: 24px;
    padding-bottom: 40px;
  }

  .header { padding: 24px 24px 16px; }
  .main   { padding: 0 24px 32px; }
}
