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

:root {
  --bg: #f5f5f7;
  --card-bg: rgba(255, 255, 255, 0.72);
  --card-border: rgba(0, 0, 0, 0.06);
  --card-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #aeaeb2;
  --accent: #007aff;
  --accent-hover: #0063d1;
  --green: #34c759;
  --yellow: #ff9f0a;
  --red: #ff3b30;
  --orange: #ff6723;
  --divider: rgba(0, 0, 0, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
          "Helvetica Neue", Helvetica, Arial, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.47;
  -webkit-font-smoothing: antialiased;
  padding: 0 0 100px;
}

/* ── Header ────────────────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: rgba(245, 245, 247, 0.72);
  border-bottom: 0.5px solid var(--divider);
  padding: 16px 20px 12px;
}
.header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.header-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.header-actions {
  position: absolute;
  top: 18px;
  right: 20px;
  display: flex;
  gap: 8px;
}
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.04);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.icon-btn:hover { background: rgba(0,0,0,0.08); }
.icon-btn.active { background: var(--accent); color: white; }

/* ── Container ─────────────────────────────────────────────────────────── */
.container {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 16px 0;
}

/* ── Cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  backdrop-filter: saturate(120%) blur(12px);
  -webkit-backdrop-filter: saturate(120%) blur(12px);
  border: 0.5px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  margin-bottom: 12px;
  overflow: hidden;
}
.card-header {
  padding: 14px 16px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.card-header .count {
  float: right;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: none;
  letter-spacing: 0;
}

/* ── Task Items ────────────────────────────────────────────────────────── */
.task-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-top: 0.5px solid var(--divider);
  gap: 12px;
  transition: background 0.12s;
}
.task-item:first-child { border-top: none; }
.task-item:active { background: rgba(0,0,0,0.02); }

.task-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--text-tertiary);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  padding: 0;
}
.task-check:hover { border-color: var(--accent); }
.task-check.done {
  border-color: var(--green);
  background: var(--green);
  animation: checkPop 0.3s ease;
}
.task-check.done::after {
  content: "✓";
  color: white;
  font-size: 13px;
  font-weight: 700;
}

@keyframes checkPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.task-info { flex: 1; min-width: 0; }
.task-name {
  font-size: 15px;
  font-weight: 400;
  color: var(--text-primary);
}
.task-name.completed {
  color: var(--text-tertiary);
  text-decoration: line-through;
}
.task-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
  display: flex;
  gap: 8px;
  align-items: center;
}

.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-room { background: #e8f0fe; color: #1967d2; }
.badge-kitchen { background: #fef3e0; color: #e37400; }
.badge-bathroom { background: #e8f5e9; color: #1b873f; }
.badge-hallway { background: #f3e8fd; color: #8b5cf6; }
.badge-daily { background: #fff3e0; color: #f57c00; }
.badge-consumables { background: #fce4ec; color: #c62828; }
.badge-maintenance { background: #eceff1; color: #546e7a; }

.streak { color: var(--orange); font-weight: 600; }
.overdue-tag {
  color: var(--red);
  font-weight: 600;
  font-size: 11px;
}

.task-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.task-btn {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  font-family: var(--font);
  transition: all 0.12s;
}
.btn-skip {
  background: rgba(0,0,0,0.04);
  color: var(--text-secondary);
}
.btn-skip:hover { background: rgba(0,0,0,0.08); }
.btn-later {
  background: rgba(0,0,0,0.04);
  color: var(--text-secondary);
}
.btn-later:hover { background: rgba(0,0,0,0.08); }

/* ── Consumable Progress ───────────────────────────────────────────────── */
.progress-bar {
  height: 4px;
  background: rgba(0,0,0,0.06);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ── Weekly Calendar ───────────────────────────────────────────────────── */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 0 16px 14px;
}
.week-day {
  text-align: center;
  padding: 8px 0 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
}
.week-day.today { color: var(--accent); }
.week-count {
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  padding: 4px 0 8px;
}
.week-count.zero { color: var(--text-tertiary); }
.week-count.today-count { color: var(--accent); }
.week-tasks {
  text-align: center;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-tertiary);
  padding: 0 0 8px;
}
.week-tasks.today-count { color: var(--accent); }

/* ── Stats ─────────────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 0 16px 14px;
}
.stat-box {
  text-align: center;
  padding: 12px 0;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
}
.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  font-weight: 500;
}

/* ── Panels (Add Task / Settings) ────────────────────────────────────── */
.panel {
  display: none;
  padding: 16px;
  border-top: 0.5px solid var(--divider);
}
.panel.open { display: block; }

.form-group {
  margin-bottom: 12px;
}
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
  display: block;
}
.form-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 0.5px solid rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.8);
  font-size: 15px;
  font-family: var(--font);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}
.form-input:focus { border-color: var(--accent); }
.form-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 0.5px solid rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.8);
  font-size: 15px;
  font-family: var(--font);
  color: var(--text-primary);
  outline: none;
  -webkit-appearance: none;
}

.form-btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: white;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
}
.form-btn:hover { background: var(--accent-hover); }
.form-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Settings ────────────────────────────────────────────────────────── */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 0.5px solid var(--divider);
}
.settings-row:first-child { border-top: none; }
.settings-label {
  font-size: 15px;
  color: var(--text-primary);
}
.settings-input {
  width: 80px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 0.5px solid rgba(0,0,0,0.12);
  background: rgba(255,255,255,0.8);
  font-size: 15px;
  font-family: var(--font);
  text-align: center;
  outline: none;
}

/* ── Loading / Error ───────────────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  font-size: 15px;
}
.loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--divider);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-msg {
  background: #fff2f0;
  border: 0.5px solid rgba(255,59,48,0.2);
  color: var(--red);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 12px;
}

.setup-card {
  padding: 20px;
  text-align: center;
}
.setup-card p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ── Toast ─────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text-primary);
  color: white;
  padding: 10px 20px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 200;
  pointer-events: none;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ── Empty State ───────────────────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-tertiary);
  font-size: 14px;
}

/* ── Bottom Navigation ────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  justify-content: space-around;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: rgba(245, 245, 247, 0.88);
  border-top: 0.5px solid var(--divider);
  padding: 6px 0 env(safe-area-inset-bottom, 8px);
}
.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 16px;
  text-decoration: none;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 500;
  transition: color 0.15s;
}
.nav-tab .nav-icon { font-size: 20px; }
.nav-tab .nav-label { font-size: 10px; }
.nav-tab.active { color: var(--accent); }
.nav-tab:hover { color: var(--text-secondary); }

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-content {
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px 16px env(safe-area-inset-bottom, 16px);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
}
.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.06);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Manage View ──────────────────────────────────────────────────────── */
.paused-task { opacity: 0.5; }
.paused-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--text-tertiary);
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  vertical-align: middle;
  margin-left: 4px;
}
.header-action-btn {
  float: right;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}
.duration-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  background: rgba(0,0,0,0.04);
  padding: 1px 4px;
  border-radius: 3px;
}
.effort-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  text-transform: capitalize;
}
.effort-low { background: #e8f5e9; color: #1b873f; }
.effort-medium { background: #fff3e0; color: #f57c00; }
.effort-high { background: #fce4ec; color: #c62828; }

.btn-resume {
  background: rgba(52, 199, 89, 0.12);
  color: var(--green);
}
.btn-accept {
  background: rgba(0, 122, 255, 0.12);
  color: var(--accent);
}

/* ── Toggle Switch ────────────────────────────────────────────────────── */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(0,0,0,0.12);
  border-radius: 26px;
  transition: 0.2s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  height: 22px;
  width: 22px;
  left: 2px;
  bottom: 2px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Suggestion Cards ─────────────────────────────────────────────────── */
.suggestion-card {
  border-left: 3px solid var(--accent);
}

/* ── Notification Test Indicator ──────────────────────────────────────── */
.test-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.06);
}
.test-dot-gray   { background: #9ca3af; }
.test-dot-yellow { background: #fbbf24; }
.test-dot-green  { background: #22c55e; }
.test-dot-red    { background: #ef4444; }
