:root {
  --bg: #f3f7f5;
  --card: #ffffff;
  --text: #1a2e28;
  --muted: #5a7268;
  --accent: #1a5f4a;
  --accent-soft: #d8efe6;
  --danger: #2e8b57;
  --shadow: 0 8px 24px rgba(26, 95, 74, 0.12);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  padding-top: var(--safe-t);
}

.header {
  padding: 20px 20px 8px;
  text-align: center;
}
.header h1 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
}
.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.main {
  flex: 1;
  padding: 12px 16px 100px;
  overflow-y: auto;
}

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: 16px;
  padding: 14px 12px 14px 16px;
  box-shadow: var(--shadow);
}

.task-text {
  flex: 1;
  font-size: 1.05rem;
  line-height: 1.35;
  word-break: break-word;
}

.btn-done {
  flex-shrink: 0;
  border: none;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-done:active { transform: scale(0.97); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
  line-height: 1.5;
}
.empty[hidden], .task-list:empty + .empty { display: block; }
.task-list:not(:empty) + .empty { display: none; }
.empty[hidden] { display: none !important; }

.footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  max-width: 480px;
  margin: 0 auto;
}

.btn-add {
  width: 100%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 16px 18px;
  border-radius: 18px;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(26, 95, 74, 0.35);
}
.btn-add:active { transform: scale(0.98); }

.modal[hidden] { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 30, 24, 0.45);
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 20px 20px calc(20px + var(--safe-b));
  box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
}
.modal-card h2 {
  margin: 0 0 14px;
  font-size: 1.25rem;
}
.field-label {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.field-input {
  width: 100%;
  font-size: 1.1rem;
  padding: 14px 14px;
  border: 2px solid #cfe0d8;
  border-radius: 14px;
  outline: none;
  margin-bottom: 16px;
}
.field-input:focus { border-color: var(--accent); }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost { background: #eef3f0; color: var(--muted); }
.btn-primary { background: var(--accent); color: #fff; }

@media (min-width: 520px) {
  .modal { align-items: center; }
  .modal-card {
    border-radius: 24px;
    margin: 16px;
    padding-bottom: 20px;
  }
}
