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

:root {
  --bg: #f4f4f6;
  --card: #ffffff;
  --text: #1c1c1e;
  --muted: #6e6e73;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --border: #e3e3e8;
  --radius: 14px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  padding-top: max(14px, env(safe-area-inset-top));
}

.topbar h1 {
  font-size: 18px;
  font-weight: 700;
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.back-btn, .review-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--accent);
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
}
.back-btn:active, .review-btn:active { background: var(--bg); }
.hidden { visibility: hidden; }

/* Thin progress line pinned to the bottom of the top bar, always in view */
.topbar-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  opacity: 0;
  transition: opacity 0.25s;
}
.topbar-progress.on { opacity: 1; }
.topbar-progress i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.3s;
}
.topbar-progress.full i { background: var(--green); }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

/* ---------- Home ---------- */
.home-grid { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }

.home-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 18px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.home-btn:active { transform: scale(0.98); background: #fafafa; }
.home-btn .icon { font-size: 28px; }
.home-btn .sub { display: block; font-size: 13px; font-weight: 400; color: var(--muted); margin-top: 3px; }
.home-btn.issue { border-left: 4px solid var(--amber); }

/* ---------- Forms ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.purpose { font-size: 14px; color: var(--muted); margin-bottom: 14px; }

label.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="text"], input[type="date"], textarea, select {
  width: 100%;
  font-size: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 14px;
  appearance: none;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }
textarea { min-height: 90px; resize: vertical; }

/* ---------- Task list ---------- */
.task {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
.task:last-child { border-bottom: none; }

.task input[type="checkbox"] {
  appearance: none;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border: 2px solid #c7c7cc;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  margin-top: -1px;
}
.task input[type="checkbox"]:checked {
  background: var(--green);
  border-color: var(--green);
}
.task input[type="checkbox"]:checked::after {
  content: "\2713";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}
.task span { font-size: 16px; line-height: 1.4; }
.task input:checked + span { color: var(--muted); }

.progress {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  margin-bottom: 10px;
}
.progress .done { color: var(--green); }

/* ---------- Photos ---------- */
.photo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: 2px dashed #c7c7cc;
  border-radius: 10px;
  background: none;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}
.photo-previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.photo-previews .thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.photo-previews img { width: 100%; height: 100%; object-fit: cover; }
/* Who took it, on photos that came from the other phone */
.thumb-by {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 3px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Still on its way up — it will ride along with the submission either way */
.thumb.pending img { opacity: 0.55; }
.thumb.pending::after {
  content: "sending";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 3px 6px;
  background: rgba(217, 119, 6, 0.9);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.04em;
}

.thumb .remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
}

/* ---------- Signature ---------- */
.sig-canvas {
  width: 100%;
  height: 150px;
  border: 2px dashed #c7c7cc;
  border-radius: 10px;
  background: #fff;
  touch-action: none;
  display: block;
}
.sig-clear {
  margin-top: 8px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.sig-img {
  max-width: 280px;
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* ---------- Complete toggle + submit ---------- */
.complete-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 16px;
  font-weight: 600;
}
.switch { position: relative; width: 52px; height: 31px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  background: #d1d1d6;
  border-radius: 31px;
  cursor: pointer;
  transition: background 0.2s;
}
.slider::before {
  content: "";
  position: absolute;
  width: 27px;
  height: 27px;
  left: 2px;
  top: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(21px); }

.submit-btn {
  width: 100%;
  padding: 16px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  margin-top: 4px;
}
.submit-btn:active { background: var(--accent-dark); }
.submit-btn:disabled { background: #a5b4fc; cursor: not-allowed; }

.error-msg { color: var(--red); font-size: 14px; font-weight: 600; text-align: center; margin-top: 10px; }

/* ---------- Urgency pills ---------- */
.pill-row { display: flex; gap: 8px; margin-bottom: 14px; }
.pill {
  flex: 1;
  padding: 11px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
}
.pill.active-Low { background: var(--green); border-color: var(--green); color: #fff; }
.pill.active-Medium { background: var(--amber); border-color: var(--amber); color: #fff; }
.pill.active-High { background: var(--red); border-color: var(--red); color: #fff; }

/* ---------- Success ---------- */
.success-screen { text-align: center; padding: 60px 20px; }
.success-screen .big { font-size: 64px; }
.success-screen h2 { margin: 16px 0 8px; }
.success-screen p { color: var(--muted); margin-bottom: 28px; }

/* ---------- Review / submissions ---------- */
.sub-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  cursor: pointer;
}
.sub-card .row1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sub-card .kind { font-weight: 700; font-size: 15px; }
.sub-card .meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.complete { background: #dcfce7; color: var(--green); }
.badge.incomplete { background: #fee2e2; color: var(--red); }
.badge.urgency-Low { background: #dcfce7; color: var(--green); }
.badge.urgency-Medium { background: #fef3c7; color: var(--amber); }
.badge.urgency-High { background: #fee2e2; color: var(--red); }
.badge.resolved { background: #dcfce7; color: var(--green); }
.badge.open { background: #fee2e2; color: var(--red); }

.sub-detail { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.sub-detail h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 12px 0 6px; }
.sub-detail h4:first-child { margin-top: 0; }
.detail-task { display: flex; gap: 8px; font-size: 15px; padding: 4px 0; align-items: baseline; }
.detail-task .mark { font-weight: 700; }
.detail-task.done .mark { color: var(--green); }
.detail-task.missed .mark { color: var(--red); }
.detail-task.missed span { color: var(--red); font-weight: 600; }
.detail-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.detail-photos a { display: block; aspect-ratio: 1; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); }
.detail-photos img { width: 100%; height: 100%; object-fit: cover; }
.notes-text { font-size: 15px; white-space: pre-wrap; }

.resolve-btn {
  margin-top: 12px;
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.filter-row { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 4px; }
.filter-row .pill { flex: 0 0 auto; padding: 8px 14px; font-size: 14px; }
.filter-row .pill.on { background: var(--text); border-color: var(--text); color: #fff; }

.empty { text-align: center; color: var(--muted); padding: 50px 20px; font-size: 15px; }

/* ---------- Home greeting + editor entry ---------- */
.hello {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 14px;
}
.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 0 0 8px;
  font-family: inherit;
}
.edit-lists-btn {
  display: block;
  margin: 26px auto 0;
  padding: 10px 18px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
.edit-lists-btn:active { background: var(--card); }

/* ---------- Name / PIN gate ---------- */
.name-gate h2 { font-size: 20px; margin-bottom: 8px; }
.name-gate p { font-size: 14px; color: var(--muted); margin-bottom: 16px; line-height: 1.45; }

/* ---------- Who else is on the list ---------- */
.presence-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
}
.presence {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}
.presence .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.55);
  animation: pulse-dot 2.4s infinite;
}
.presence .dot.off { background: var(--amber); animation: none; }
@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(22, 163, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}
.presence-card .link-btn { flex-shrink: 0; white-space: nowrap; }

/* ---------- Progress ring ---------- */
.progress-card { display: flex; align-items: center; gap: 18px; }
.ring-wrap { position: relative; width: 80px; height: 80px; flex-shrink: 0; }
.ring { width: 80px; height: 80px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; stroke-linecap: round; }
.ring-bg { stroke: #e8e8ee; }
.ring-fg {
  stroke: var(--accent);
  transition: stroke-dashoffset 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), stroke 0.4s;
}
.ring-fg.full { stroke: var(--green); }
.ring-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
}
.ring-copy { display: flex; flex-direction: column; gap: 3px; }
.ring-copy strong { font-size: 17px; }
.ring-copy span { font-size: 14px; color: var(--muted); }
.ring-copy span.all-done { color: var(--green); font-weight: 600; }

/* ---------- Sections inside a checklist ---------- */
.section-head {
  padding: 16px 4px 8px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.task-card .section-head:first-child { border-top: none; margin-top: 0; padding-top: 4px; }
.sec-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.sec-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.sec-count { font-size: 12px; font-weight: 700; color: var(--muted); }
.section-head.complete .sec-title,
.section-head.complete .sec-count { color: var(--green); }
.sec-bar {
  height: 4px;
  background: #e8e8ee;
  border-radius: 999px;
  margin-top: 7px;
  overflow: hidden;
}
.sec-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.section-head.complete .sec-bar i { background: var(--green); }
.section-head.flash { animation: sec-flash 0.7s ease-out; }
@keyframes sec-flash {
  0% { background: rgba(22, 163, 74, 0.18); }
  100% { background: transparent; }
}

/* ---------- Task rows ---------- */
.task { position: relative; overflow: hidden; }
.task .task-text { flex: 1; }
.task .by {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--bg);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
  align-self: center;
}
.task .by:empty { display: none; }
.task.just-checked { animation: task-pop 0.4s ease-out; }
@keyframes task-pop {
  0% { background: rgba(22, 163, 74, 0.22); }
  100% { background: transparent; }
}
.task.remote-checked { animation: task-remote 1.1s ease-out; }
@keyframes task-remote {
  0% { background: rgba(37, 99, 235, 0.22); }
  100% { background: transparent; }
}
.task input[type="checkbox"]:checked { animation: box-pop 0.28s ease-out; }
@keyframes box-pop {
  0% { transform: scale(0.7); }
  55% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.shared-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e0e9ff;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* ---------- Submit readiness ---------- */
.ready-line {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  margin-top: 10px;
  min-height: 20px;
}
.ready-line.need { color: var(--muted); }
.ready-line.warn { color: var(--amber); }
.ready-line.good { color: var(--green); }
.submit-btn.not-ready { background: #9db4f0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  max-width: min(440px, calc(100vw - 32px));
  background: rgba(28, 28, 30, 0.94);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 999px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.good { background: rgba(22, 163, 74, 0.96); }

.confetti {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
}

/* ---------- Submission detail additions ---------- */
.detail-section {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 12px 0 4px;
}
.detail-by {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
  padding-left: 8px;
  white-space: nowrap;
}
.detail-task { justify-content: flex-start; }

/* ---------- Checklist editor ---------- */
.edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.edit-row:last-child { border-bottom: none; }
.edit-move { display: flex; flex-direction: column; gap: 2px; }
.edit-move button {
  width: 30px;
  height: 22px;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.edit-row .edit-text {
  flex: 1;
  margin-bottom: 0;
  padding: 10px;
  font-size: 15px;
}
.edit-row.section .edit-text {
  font-weight: 700;
  text-transform: uppercase;
  font-size: 13px;
  letter-spacing: 0.04em;
  background: #eef1f8;
  color: var(--accent);
}
.edit-del {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border: none;
  background: var(--bg);
  border-radius: 8px;
  color: var(--red);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.edit-add { display: flex; gap: 8px; margin-top: 14px; }
.edit-add button {
  flex: 1;
  padding: 12px;
  border: 2px dashed #c7c7cc;
  border-radius: 10px;
  background: none;
  color: var(--accent);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}
.icon-input { width: 80px; text-align: center; font-size: 22px; }
.reset-btn {
  width: 100%;
  margin-top: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .presence .dot { animation: none; }
  .task.just-checked, .task.remote-checked, .section-head.flash,
  .task input[type="checkbox"]:checked { animation: none; }
  .ring-fg, .sec-bar i, .topbar-progress i { transition: none; }
}
