/* ---------- Goals ---------- */

.topbar.goals { background: none; }

.view-goals {
  overflow-y: auto;
  overflow-x: hidden;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(var(--tabbar-h) + var(--tabbar-gap) + 40px + env(safe-area-inset-bottom));
  scrollbar-width: none;
}
.view-goals::-webkit-scrollbar { display: none; }
.view-goals > * { max-width: var(--col); margin-left: auto; margin-right: auto; }

/* The big title sits on the top bar's row, level with the round "…" button. */
.goals-title {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0 60px 0 2px;
  margin-bottom: 6px;
  font-family: "Inter", -apple-system, sans-serif;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.5px;
}

/* Sections: a colored dot + label, rows, "Show N more", then a thin rule. */
.goal-sec { padding: 8px 0 10px; border-bottom: 1px solid var(--border); }
.goal-sec-head { display: flex; align-items: center; gap: 10px; height: 36px; font-size: 0.9375rem; font-weight: 600; letter-spacing: 0; }
.goal-sec.tracking .goal-sec-head { color: #1f9d4f; }
.goal-sec.goal .goal-sec-head { color: var(--imessage-blue); }
.goal-sec.done .goal-sec-head { color: var(--text-3); }
.goal-lead { flex: none; width: 36px; display: grid; place-items: center; } /* lines up with the checkboxes */
.goal-dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
/* A soft halo that breathes out from the dot, so live sections feel alive. Completed stays still. */
.goal-sec:not(.done) .goal-dot::before,
.goal-sec:not(.done) .goal-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: currentColor;
  opacity: 0;
  animation: goal-halo 2.4s cubic-bezier(0.25, 0.6, 0.35, 1) infinite;
}
.goal-sec:not(.done) .goal-dot::after { animation-delay: 1.2s; }
.goal-sec.goal .goal-dot::before { animation-delay: 0.6s; }
.goal-sec.goal .goal-dot::after { animation-delay: 1.8s; }
@keyframes goal-halo {
  0% { transform: scale(1); opacity: 0.45; }
  100% { transform: scale(3.2); opacity: 0; }
}
.goal-empty { padding: 2px 0 10px 46px; font-size: 0.9375rem; line-height: 1.5; color: var(--text-2); }

.goal-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
  transition: height 0.28s ease, opacity 0.2s ease, padding 0.28s ease;
}
.goal-row.leaving { overflow: hidden; opacity: 0; padding-top: 0; padding-bottom: 0; }
.goal-check {
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: none;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.goal-box {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  border: 1.8px solid #c7c7cc;
  display: grid;
  place-items: center;
  transition: background 0.15s, border-color 0.15s;
}
.goal-box svg { width: 16px; height: 16px; stroke: #fff; stroke-width: 2.6; opacity: 0; transform: scale(0.5); transition: opacity 0.15s, transform 0.22s cubic-bezier(0.3, 1.4, 0.5, 1); }
@media (hover: hover) { .goal-check:hover .goal-box { border-color: var(--text-2); } }
.goal-row.done .goal-box, .goal-row.checking .goal-box { background: var(--accent); border-color: var(--accent); }
.goal-row.done .goal-box svg, .goal-row.checking .goal-box svg { opacity: 1; transform: none; }
.goal-row.unchecking .goal-box { background: none; border-color: #c7c7cc; }
.goal-row.unchecking .goal-box svg { opacity: 0; transform: scale(0.5); }
.goal-text { flex: 1; min-width: 0; padding-top: 7px; } /* first line centered on the checkbox */
.goal-title { display: block; font-size: 1.0625rem; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.goal-note {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 2px;
  font-size: 0.9375rem;
  line-height: 1.4;
  color: var(--text-2);
  overflow-wrap: anywhere;
}
.goal-row.done .goal-title, .goal-row.checking .goal-title { color: var(--text-3); text-decoration: line-through; }
.goal-row.unchecking .goal-title { color: var(--text); text-decoration: none; }
.goal-row .kebab { height: 36px; margin-right: -8px; }
.goal-row .kebab svg { width: 18px; height: 18px; }

.goal-more {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 40px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-2);
  text-align: left;
  cursor: pointer;
}
.goal-more svg { width: 20px; height: 20px; }
.goal-more:hover { color: var(--text); }

/* "Create a goal", then one quick-add row per category. */
.goal-add {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 1.0625rem;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.goal-add .goal-lead svg { width: 22px; height: 22px; }
.goal-clay { display: block; width: 30px; height: 30px; object-fit: contain; -webkit-user-drag: none; }
.goal-create { margin-top: 8px; font-weight: 500; }
.goal-create .goal-lead svg { stroke-width: 2; }
.goal-add-name { flex: 1; min-width: 0; }
.goal-add-plus { flex: none; width: 36px; height: 36px; margin-right: -8px; display: grid; place-items: center; color: var(--text-2); transition: color 0.15s; }
.goal-add-plus svg { width: 20px; height: 20px; }
.goal-add:hover .goal-add-plus { color: var(--text); }
.goal-add:active, .goal-more:active { opacity: 0.6; }

/* Create / edit sheet: an iOS-style bottom sheet that rises from the bottom edge. */
.goal-backdrop { background: rgba(16, 17, 19, 0.18); padding: 0; align-items: flex-end; }
.goal-panel {
  position: relative;
  width: min(520px, 100%);
  max-height: calc(100% - 16px - env(safe-area-inset-top));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 16px calc(18px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.97);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--border);
  border-radius: 32px 32px 0 0;
  border-bottom: 0;
  box-shadow: 0 -8px 40px rgba(16, 17, 19, 0.12);
  scrollbar-width: none;
  animation: sheet-up 0.3s cubic-bezier(0.3, 0.8, 0.25, 1);
  will-change: transform;
}
.goal-panel::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  width: 38px;
  height: 5px;
  margin-left: -19px;
  border-radius: 999px;
  background: #d1d1d6;
}
.goal-panel::-webkit-scrollbar { display: none; }
.goal-backdrop.closing .goal-panel { animation: sheet-down 0.24s ease forwards; }
.goal-panel-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.goal-panel-head .round-btn { width: 40px; height: 40px; justify-self: start; }
.goal-panel-head .round-btn svg { width: 20px; height: 20px; }
.goal-panel-head .btn { justify-self: end; }
.goal-panel-title { font-size: 1.0625rem; font-weight: 600; white-space: nowrap; }
.goal-input {
  width: 100%;
  height: 52px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 18px;
  background: var(--pill);
  font: inherit;
  font-size: 1.0625rem;
  color: var(--text);
  outline: 0;
  transition: border-color 0.15s, background 0.15s;
}
.goal-input::placeholder { color: var(--text-3); }
.goal-input:focus { background: #fff; border-color: var(--border); }
.goal-textarea { height: auto; min-height: 92px; padding: 14px 18px; line-height: 1.45; resize: none; }
.goal-cats { display: flex; flex-wrap: wrap; gap: 8px; }
.goal-cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.goal-cat svg { width: 18px; height: 18px; flex: none; }
.goal-cat .goal-clay { width: 22px; height: 22px; flex: none; margin: -2px 0; }
.goal-cat[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

@media (max-width: 600px) {
  .goals-title { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .goal-row, .goal-box, .goal-box svg { transition: none; }
  .goal-dot::before, .goal-dot::after { animation: none !important; }
}

/* "Hide subtitles" in the Goals menu: titles only. */
.no-subs .goal-note { display: none; }
