:root {
  --navy: #8a4a2a;
  --navy-dark: #653619;
  --accent: #b3541e;
  --bg: #f6f4f1;
  --card: #ffffff;
  --text: #241d18;
  --muted: #7a6e64;
  --border: #e2dad2;
  --urgent: #a3181f;
  --high: #d9541e;
  --medium: #c9820b;
  --low: #4a7c59;
  --done: #4a7c59;
  --radius: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
}

input, textarea {
  -webkit-user-select: text;
  user-select: text;
}

#app {
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--navy);
  color: white;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar h1 {
  font-size: 19px;
  margin: 0;
  flex: 1;
  font-weight: 600;
}

.topbar .sub {
  font-size: 13px;
  color: #e8d9cd;
  font-weight: 400;
}

.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: white;
  touch-action: manipulation;
}
.btn:active { opacity: 0.75; }
.btn.secondary { background: #ece4dc; color: var(--text); }
.btn.ghost { background: transparent; color: white; padding: 8px 10px; }
.btn.danger { background: var(--urgent); }
.btn.done { background: var(--done); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: default; }

.content {
  padding: 16px;
  max-width: 780px;
  margin: 0 auto;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  border: 1px solid var(--border);
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.tab-btn {
  flex: 1;
  padding: 10px 8px;
  text-align: center;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  background: white;
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}
.tab-btn.active {
  background: var(--navy);
  border-color: var(--navy);
  color: white;
}

.sort-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.sort-btn {
  flex: 1;
  padding: 8px;
  text-align: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.sort-btn.active {
  background: #f1e6dc;
  border-color: var(--accent);
  color: var(--accent);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-state .icon { font-size: 42px; margin-bottom: 12px; }

.task-card {
  display: flex;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
}
.task-thumb {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: #eee;
}
.task-thumb-placeholder {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  flex-shrink: 0;
  background: #f1e6dc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.task-info { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 15px; }
.task-desc { font-size: 13px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-badges { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  color: white;
  white-space: nowrap;
}
.badge.urgent { background: var(--urgent); }
.badge.high { background: var(--high); }
.badge.medium { background: var(--medium); }
.badge.low { background: var(--low); }
.badge.timeframe { background: #ece4dc; color: var(--text); }
.badge.doneBadge { background: var(--done); }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.field input[type=text], .field textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  font-family: inherit;
  color: var(--text);
}
.field textarea { min-height: 80px; resize: vertical; }

.picker-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.picker-option {
  flex: 1;
  min-width: 30%;
  padding: 12px 8px;
  text-align: center;
  border-radius: 10px;
  border: 2px solid var(--border);
  font-weight: 600;
  font-size: 13.5px;
  background: white;
  color: var(--text);
  cursor: pointer;
}
.picker-option.selected.urgent { border-color: var(--urgent); background: #fbe9ea; color: var(--urgent); }
.picker-option.selected.high { border-color: var(--high); background: #fdece3; color: var(--high); }
.picker-option.selected.medium { border-color: var(--medium); background: #fdf1e0; color: var(--medium); }
.picker-option.selected.low { border-color: var(--low); background: #e9f3ec; color: var(--low); }
.picker-option.selected.timeframe { border-color: var(--accent); background: #f1e6dc; color: var(--accent); }

.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.photo-thumb {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .remove {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.add-photo-btn {
  width: 84px;
  height: 84px;
  border-radius: 8px;
  border: 1.5px dashed var(--border);
  background: transparent;
  color: var(--accent);
  font-size: 26px;
  cursor: pointer;
}

.action-row {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.action-row .btn { flex: 1; min-width: 45%; }

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

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy-dark);
  color: white;
  padding: 10px 18px;
  border-radius: 100px;
  font-size: 14px;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; }

.count-badge {
  background: rgba(255,255,255,0.18);
  color: white;
  border-radius: 100px;
  padding: 2px 10px;
  font-size: 13px;
  font-weight: 600;
}
