.wrap { max-width: 960px; margin: 0 auto; padding: var(--space-16) var(--space-16) 96px; }
.titlebar { position: sticky; top: calc(var(--appbar-h, 57px) - 1px); z-index: 9; background: var(--bg-app); margin: calc(-1 * var(--space-16)) calc(-1 * var(--space-16)) var(--space-16); padding: var(--space-16) var(--space-16) var(--space-16); display: flex; flex-direction: column; align-items: stretch; gap: var(--space-12); margin-bottom: var(--space-16); padding-bottom: var(--space-16); border-bottom: 1px solid var(--color-border); }
.titlebar h1 { font-weight: 700; font-size: 24px; line-height: 1.25; margin: 0; text-wrap: balance; }
.add-btn { white-space: nowrap; }
/* Mobile only: the title and the add button share one row (title at the start, compact button at the end). */
@media (max-width: 639px) {
  /* 1px under the bar (which is above it) so a fractional bar height never leaves a gap */
  .titlebar { flex-direction: row; align-items: center; justify-content: space-between; gap: var(--space-8); }
  .titlebar h1 { min-width: 0; }
  .titlebar .add-btn { display: none; }
}
@media (min-width: 640px) { .titlebar { flex-direction: row; align-items: center; justify-content: space-between; } .titlebar h1 { font-size: 32px; } }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--space-24); }
.card {
  position: relative; display: flex; flex-direction: column; gap: var(--space-8);
  background: var(--color-surface); border-radius: var(--radius-card);
  --card-pad: var(--space-16); padding: var(--card-pad); box-shadow: var(--shadow-card); cursor: pointer;
  transition: transform .15s ease;
  /* photo-print frame: thin cream border with a wider strip at the bottom, each card tilted a little */
  --tilt: -1.2deg; transform: rotate(var(--tilt));
  border: 9px solid var(--polaroid, #f4efe6); border-bottom-width: 30px; border-radius: 4px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.45);
}
.grid > .card:nth-child(even) { --tilt: 1deg; }
@media (min-width: 640px) { .card { --card-pad: var(--space-24); } }
.card:hover { transform: rotate(var(--tilt)) translateY(-2px); }
.card.achieved { border-color: var(--polaroid, #f4efe6); }
/* Success header: spans the card's full width at the very top, clipped to its rounded top corners */
.success-head { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; margin: calc(-1 * var(--space-16)) calc(-1 * var(--space-16)) var(--space-4); padding: 10px 14px; border-radius: calc(var(--radius-card) - 1px) calc(var(--radius-card) - 1px) 0 0; background: linear-gradient(90deg, #163F43 0%, #21524F 50%, #163F43 100%); border-bottom: 1px solid rgba(121, 227, 200, 0.25); box-shadow: 0 0 16px rgba(121, 227, 200, 0.10); color: #B9F4E3; font-size: 14px; font-weight: 700; }
.success-head .icon { flex: none; width: 18px; height: 18px; color: #79E3C8; }
@media (min-width: 640px) { .success-head { margin: calc(-1 * var(--space-24)) calc(-1 * var(--space-24)) var(--space-4); } }
.card-top { display: flex; align-items: flex-start; gap: var(--space-12); }
.icon-box { flex: none; width: 54px; height: 54px; display: grid; place-items: center; font-size: 28px; border-radius: 14px; background: var(--color-lavender); overflow: hidden; }
.icon-box img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card-title { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-4); }
.card h2 { margin: 0; font-size: 16px; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tag { display: inline-block; background: var(--color-mint); color: var(--accent-mint); font-size: 11px; font-weight: 500; line-height: 1.5; padding: 2px var(--space-8); border-radius: var(--radius-pill); white-space: nowrap; }
.badge { flex: none; align-self: flex-start; background: var(--color-success-bg); color: var(--color-success); font-weight: 500; font-size: 14px; line-height: 1.5; padding: var(--space-4) var(--space-12); border-radius: var(--radius-pill); white-space: nowrap; }
.gauge { width: 100%; max-width: 260px; margin: 0 auto; }
.gauge svg { display: block; width: 100%; height: auto; overflow: visible; }
.g-track { fill: var(--gauge-track); stroke: none; }
.g-fill { stroke: none; }
.g-glow { filter: drop-shadow(0 0 4px var(--aurora-glow)); }
.g-done .g-glow { filter: brightness(1.1) saturate(1.1) drop-shadow(0 0 5px rgba(93, 211, 232, 0.28)); }
.g-int { fill: var(--aurora-4); stroke: none; }
.g-int-t { font-size: 8.5px; font-weight: 600; fill: var(--aurora-4); }
.g-sep { stroke: var(--color-surface); stroke-width: 1.5; }
.g-pct { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; } /* 22px at the card's rendered gauge width */
.g-amount { font-size: 23px; font-weight: 700; fill: var(--gauge-amount); font-variant-numeric: tabular-nums; } /* 30px rendered */
.g-sub { font-size: 10px; font-weight: 500; fill: var(--gauge-sub); } /* 13px rendered */
.chips { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-8); }
.chip { display: flex; flex-direction: column; gap: 2px; border-radius: 8px; padding: var(--space-8) var(--space-12); color: var(--color-text); }
.chip-lavender { background: var(--date-bg); border: 1px solid var(--date-border); --chip-label: var(--date-label); --chip-value: var(--date-value); }
.chip-sky { background: var(--days-bg); border: 1px solid var(--days-border); --chip-label: var(--days-label); --chip-value: var(--days-value); }
.chip-head { display: flex; align-items: center; gap: 6px; color: var(--chip-label); }
.chip-head .icon { flex: none; width: 14px; height: 14px; }
.chip-label { font-size: 12px; font-weight: 500; line-height: 1.4; color: var(--chip-label); }
.chip-value { font-size: 14px; font-weight: 600; line-height: 1.4; color: var(--chip-value); }
.milestone { display: flex; align-items: center; gap: var(--space-8); border-radius: 8px; padding: var(--space-8) var(--space-12); background: var(--color-butter); color: var(--color-text); font-size: 12px; line-height: 1.5; }
.milestone > span { flex: 1; }
.milestone b { font-weight: 500; }
.milestone .icon { flex: none; width: 16px; height: 16px; }
.milestone:not(.milestone-done) { background: var(--deposit-bg); border: 1px solid var(--deposit-border); color: var(--deposit-label); font-weight: 500; }
.milestone:not(.milestone-done) b { font-size: 15px; font-weight: 700; color: var(--deposit-value); }
.milestone-done { background: var(--color-success-bg); color: var(--color-success); font-weight: 500; justify-content: center; }
.empty { text-align: center; padding: var(--space-32) var(--space-16) var(--space-24); max-width: 420px; margin: 0 auto; }
.empty .gauge { max-width: 200px; margin-bottom: var(--space-16); opacity: .9; }
.empty h2 { font-weight: 700; font-size: 24px; line-height: 1.3; margin: 0 0 var(--space-8); }
.empty p { margin: 0 0 var(--space-24); color: var(--color-text-muted); }
.foot { position: fixed; inset-inline: 0; bottom: 0; z-index: 5; background: var(--color-canvas); border-top: 1px solid var(--color-border); padding: 10px var(--space-16) calc(10px + env(safe-area-inset-bottom)); text-align: center; font-size: 14px; font-weight: 500; color: var(--color-text-muted); }
/* goal form pieces */
.emoji-row { display: flex; flex-wrap: wrap; gap: var(--space-8); }
.emoji-opt { position: relative; width: 46px; height: 46px; border-radius: var(--radius-control); border: 1px solid var(--color-input-border); background: var(--color-input-bg); font-size: 24px; display: grid; place-items: center; }
.emoji-opt[aria-pressed="true"] { border: 2px solid var(--color-primary); background: var(--color-lavender); }
.pic-opt { width: 56px; height: 56px; padding: 0; overflow: visible; border: 0; background: none; border-radius: 16px; }
.pic-opt img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; display: block; }
.pic-opt[aria-pressed="true"] { border: 0; background: none; outline: none; box-shadow: 0 0 0 2px var(--color-focus), 0 0 10px 1px var(--aurora-glow), 0 0 18px 2px rgba(120, 206, 178, 0.28); }
.emoji-opt[aria-pressed="true"]::after { content: "✓"; position: absolute; top: -6px; inset-inline-end: -6px; width: 18px; height: 18px; border-radius: 50%; background: var(--color-primary); color: var(--color-on-primary); font-size: 12px; line-height: 18px; text-align: center; }
.summary { border-radius: var(--radius-control); padding: var(--space-12) var(--space-16); margin: var(--space-4) 0 var(--space-16); background: var(--color-lavender); min-height: 20px; color: var(--color-text); }
.summary.bad { background: var(--color-error-bg); color: var(--color-error); }
.summary h3 { margin: 0 0 var(--space-4); font-size: 14px; color: var(--color-text); font-weight: 500; }
.summary p { margin: 0; font-weight: 700; }
.summary .sub { font-weight: 500; color: var(--color-text); margin-top: 2px; }
.summary.bad h3, .summary.bad .sub { color: var(--color-error); }
.summary.plan { padding: 16px 18px; border-radius: 16px; background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)), var(--surface-2); border: 1px solid rgba(121, 227, 200, 0.18); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05); text-align: center; }
.summary.plan h3 { text-align: start; font-size: 14px; font-weight: 600; color: #DDE8F2; margin-bottom: 8px; }
.plan-head { display: flex; align-items: center; gap: 12px; text-align: start; margin-bottom: 12px; }
.plan-pic { flex: none; width: 56px; height: 56px; display: grid; place-items: center; border-radius: 12px; overflow: hidden; font-size: 28px; background: var(--color-lavender); }
.plan-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.plan-title { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.plan-name { font-size: 18px; font-weight: 700; line-height: 1.3; color: #F6F8FC; overflow-wrap: anywhere; }
.plan-title .tag { background: rgba(121, 227, 200, 0.12); color: #A6E7D6; font-size: 12px; padding: 5px 10px; border-radius: 999px; }
.plan-deposit { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: linear-gradient(90deg, rgba(93, 211, 232, 0.12), rgba(121, 227, 200, 0.20)); border: 1px solid rgba(121, 227, 200, 0.55); box-shadow: 0 0 14px rgba(93, 211, 232, 0.22), inset 0 0 12px rgba(121, 227, 200, 0.08); color: #B9F4E3; font-size: 14px; font-weight: 500; }
.plan-deposit .icon { flex: none; width: 18px; height: 18px; color: #79E3C8; }
.plan-deposit span { flex: 1; text-align: start; }
.plan-deposit b { font-size: 17px; font-weight: 700; color: #F6F8FC; text-shadow: 0 0 10px rgba(121, 227, 200, 0.35); }
.plan-main { font-size: 22px; font-weight: 700; line-height: 1.3; color: #F6F8FC; }
.plan-date { margin-top: 6px; font-size: 16px; font-weight: 600; color: var(--color-text-muted); }
.plan-date-val { background: linear-gradient(to left, #79E3C8, #5DD3E8, #7F9CFF); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; }
.plan-pill { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 5px 12px; border-radius: 999px; background: rgba(7, 17, 29, 0.45); border: 1px solid var(--color-border); color: #D9F6FB; font-size: 13px; font-weight: 500; }
.plan-pill .icon { flex: none; width: 15px; height: 15px; color: #79E3C8; }
.tl { display: flex; align-items: center; gap: 0; margin-top: 18px; }
.tl-end { flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--color-bg-bar, #0C1722); border: 1.5px solid #5DD3E8; color: #79E3C8; box-shadow: 0 0 10px rgba(93, 211, 232, 0.18); }
.tl-end .icon { width: 15px; height: 15px; }
.tl-start { border-color: #79E3C8; }
.tl-line { position: relative; flex: 1; height: 3px; border-radius: 2px; background: linear-gradient(to left, #B9F4E3, #79E3C8, #5DD3E8, #7F9CFF); box-shadow: 0 0 8px rgba(93, 211, 232, 0.18); }
.tl-line i { position: absolute; top: 50%; width: 8px; height: 8px; margin: -4px -4px 0 0; border-radius: 50%; background: #0C1722; border: 1.5px solid #5DD3E8; }
[dir="rtl"] .tl-line i { margin: -4px 0 0 -4px; }
.tl-labels { display: flex; justify-content: space-between; margin-top: 8px; }
.tl-labels div { display: flex; flex-direction: column; gap: 1px; align-items: center; }
.tl-labels b { font-size: 13px; font-weight: 600; color: var(--color-text); }
.tl-labels span { font-size: 11px; color: var(--color-text-muted); }

.track-tag-row { margin: calc(-1 * var(--space-8)) 0 var(--space-16); }

/* Private / shared marker, at the end of the card header */
.share { position: absolute; top: calc(var(--radius-card) - 15px); left: calc(var(--radius-card) - 15px); z-index: 2; display: inline-flex; align-items: center; margin: 0; }
.card-top { padding-left: 34px; } /* keeps the title clear of the corner icon */
.share-private { width: 30px; height: 30px; justify-content: center; border-radius: 50%; background: var(--color-canvas); border: 1px solid var(--color-border); color: var(--color-text-muted); }
.share-private .icon { width: 16px; height: 16px; }
/* Brief highlight when a card is opened from a notification */
@keyframes card-flash { 0%, 100% { box-shadow: var(--shadow-card); } 30%, 70% { box-shadow: 0 0 0 3px var(--color-primary), var(--shadow-card); } }
.card.flash { animation: card-flash 1.5s ease; }

/* Sharing section in the goal dialog */
.sharing { margin: 16px 0; padding: 16px; background: #243B4C; border: 1px solid rgba(121, 227, 200, 0.25); border-radius: 14px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05); }
.sh-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; color: var(--accent-mint); }
.sh-head .icon { flex: none; width: 18px; height: 18px; }
.sh-head h3 { margin: 0; font-size: 15px; font-weight: 500; color: var(--color-text); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: #162C3D; border-radius: 12px; }
.seg-opt { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 4px; border: 0; border-radius: 10px; background: transparent; color: #D6E2EA; font-size: 14px; font-weight: 500; transition: background-color .18s ease, color .18s ease; }
.seg-opt .icon { flex: none; width: 18px; height: 18px; color: #A9B7C8; transition: color .18s ease; }
.seg-opt[aria-pressed="true"] { background: #79E3C8; color: #102A32; font-weight: 600; }
.seg-opt[aria-pressed="true"] .icon { color: #102A32; }
.seg-opt:disabled { cursor: default; }
.sh-explain { display: flex; align-items: flex-start; gap: 10px; margin: 10px 0 0; padding: 12px; border-radius: 10px; background: #1B3948; }
.sh-explain[hidden] { display: none; }
.sh-explain-ico .icon { width: 18px; height: 18px; color: #B9F4E3; margin-top: 1px; }
.sh-explain-title { font-size: 13px; font-weight: 600; color: #B9F4E3; }
.sh-explain-text { margin-top: 2px; font-size: 12.5px; line-height: 1.5; color: #BDD1DC; }
#sh-body { margin-top: 12px; }
.sh-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.sh-row { display: flex; align-items: center; gap: 8px; border: 0.5px solid var(--color-border); border-radius: 10px; padding: 6px 8px; }
.avatar.sh-avatar { width: 28px; height: 28px; flex: none; font-size: 12px; }
.sh-who { flex: 1; min-width: 0; }
.sh-email-txt { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: end; }
.sh-status { font-size: 11px; color: var(--color-text-muted); }
.sh-role { width: auto; min-height: 36px; font-size: 12px; padding: 4px 8px; }
.sh-rolelabel { font-size: 12px; color: var(--color-text-muted); }
.sh-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; min-height: 44px; }
.sh-link svg { width: 16px; height: 16px; }
.sh-addrow { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.sh-email { flex: 1; min-width: 0; direction: ltr; }
.sh-addbtn { min-height: 44px; }
.sh-help { font-size: 12px; color: var(--color-text-muted); line-height: 1.5; margin: 8px 0 0; }
.sh-help b { font-weight: 500; color: var(--color-text); }
.sharing .err { min-height: 0; }

/* Filter row above the goal list: slim pills like the track tag. The tap area is larger than the pill (see ::after). */
.filter-row { display: flex; gap: var(--space-8); margin-bottom: var(--space-16); flex-wrap: wrap; }
.filter-chip { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; position: relative; padding: 2px var(--space-12); border-radius: var(--radius-pill); border: 1px solid var(--color-primary); background: transparent; color: var(--color-text); font-size: 12px; font-weight: 500; line-height: 1.5; }
.filter-chip::after { content: ""; position: absolute; inset: -9px -4px; }
.filter-ico { display: inline-flex; } .filter-ico svg { width: 13px; height: 13px; }
.filter-chip:hover { background: var(--color-surface-2); }
.filter-chip.on { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); }
.filter-empty { text-align: center; color: var(--color-text-muted); margin: var(--space-32) 0; }

/* Phones: the four filters stay on one line (tighter chips on very narrow screens). */
@media (max-width: 639px) { .filter-row { flex-wrap: nowrap; } .filter-chip { flex: 0 1 auto; } }
@media (max-width: 380px) { .filter-row { gap: 4px; } .filter-chip { padding-inline: 6px; gap: 3px; } .filter-ico svg { width: 12px; height: 12px; } }
.owner-line { font-size: 12px; color: var(--color-text-muted); margin: 2px 0 4px; }

/* Avatars on the goal picture (bottom-left corner): one full circle, up to two crescents behind it peeking inward, and a "+N" tag under the stack. */
.pic { position: relative; flex: none; display: block; width: 54px; height: 54px; }
/* The main circle's center sits exactly on the picture's bottom-left corner (22px circle: 11px out on each side). "+N" sits at the top-right of the outermost circle. */
.pa-stack { position: absolute; left: -11px; bottom: -11px; z-index: 1; direction: ltr; display: block; width: 22px; height: 22px; pointer-events: none; }
.pa-row { position: relative; display: block; width: 22px; height: 22px; }
.pa { position: absolute; top: 0; left: 0; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--color-surface); overflow: hidden; font-size: 11px; font-weight: 600; line-height: 1; color: var(--color-text); background: var(--color-canvas); }
.pa img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pa.tone-0 { background: var(--color-pink); }
.pa.tone-1 { background: var(--color-mint); }
.pa-main { z-index: 3; }
.pa-layer { z-index: 2; }
.pa-l1 { transform: translateX(5px); }
.pa-l2 { z-index: 1; transform: translateX(10px); }
.pa-count { position: absolute; left: calc(22px + 5px * var(--n, 0) - 13px); top: -9px; z-index: 4; box-sizing: border-box; min-width: 22px; height: 17px; padding: 0 5px; display: inline-flex; align-items: center; justify-content: center; border-radius: 9px; border: 2px solid var(--color-surface); background: var(--color-canvas); color: var(--color-text); font-size: 11px; font-weight: 600; line-height: 1; }

/* Picture banner: the goal picture across the top of the card (bleeding to the frame), name bottom-end, track tag top-end, owner circle straddling the bottom-end edge, private/shared marker in the start corner. */
.card-banner { --banner-h: calc(var(--card-pad) + 54px + 126px); position: relative; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-start; gap: 4px; min-height: var(--banner-h); margin: 0 calc(-1 * var(--card-pad)) 0; padding: 8px 12px 52px; color: #fff; }
.card:not(.achieved) > .card-banner { margin-top: calc(-1 * var(--card-pad)); }
.banner-pic { position: absolute; inset: 0; overflow: hidden; background: transparent; display: grid; place-items: center; }
.banner-pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 40%; display: block; -webkit-mask-image: linear-gradient(to bottom, #000 52%, transparent 100%); mask-image: linear-gradient(to bottom, #000 52%, transparent 100%); }
.banner-emoji { font-size: 40px; line-height: 1; justify-self: end; margin-inline-end: 18%; margin-top: -4px; }
.banner-pic::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(8, 13, 20, 0.45) 0%, rgba(8, 13, 20, 0) 45%); }
.banner-tag, .banner-name { position: relative; z-index: 1; }
.banner-tag { max-width: calc(100% - 46px); display: flex; } .banner-tag .tag { overflow: hidden; text-overflow: ellipsis; }
.banner-name { align-self: stretch; padding-inline-start: 0; padding-inline-end: 46px; text-align: start; min-width: 0; }
.banner-name h2 { color: #fff; font-size: 17px; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); }
.banner-name .owner-line { color: rgba(255, 255, 255, 0.82); margin: 0 0 1px; font-size: 11px; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6); }
.banner-tag .tag { background: rgba(16, 26, 38, 0.72); color: #d3f1e4; border: 1px solid rgba(255, 255, 255, 0.16); }
.card-banner .share { top: 8px; left: 8px; background: rgba(16, 26, 38, 0.78); border-color: rgba(255, 255, 255, 0.18); color: #dfe7f1; }
/* owner circle: right side (start in RTL), half outside the banner; crescents peek inward (to the left), "+N" at the outer crescent */
.card-banner .pa-stack { left: auto; right: 12px; top: 8px; bottom: auto; width: 30px; height: 30px; z-index: 3; }
.card-banner .pa-row { width: 30px; height: 30px; }
.card-banner .pa { width: 30px; height: 30px; font-size: 12px; border-color: var(--color-surface); }
.card-banner .pa-l1 { transform: translateX(-9px); }
.card-banner .pa-l2 { transform: translateX(-18px); }
.card-banner .pa-count { left: calc(-9px * var(--n, 0) - 7px); top: auto; bottom: -6px; }
.card-banner .banner-tag { margin-top: 4px; margin-inline-start: calc(30px + 9px * var(--n, 0) + 10px); max-width: calc(100% - 30px - 9px * var(--n, 0) - 10px - 46px); }
.card-banner .banner-name { padding-inline-end: 0; }

/* Tighter body under the banner: the gauge sits right under the picture, the date / days-left chips are one line each, the deposit row is slimmer. */
.card-banner + .gauge { margin-top: -52px; position: relative; z-index: 2; }
.card .chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card .chip { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 6px; min-width: 0; padding: 6px 10px; }
.card .chip-head { white-space: nowrap; }
.card .chip-value { white-space: nowrap; }
.card .chip-value { font-size: 13px; }
.card .chip-label { font-size: 11.5px; }
.card .milestone { padding: 6px var(--space-12); }
.card .milestone:not(.milestone-done) b { font-size: 14px; }

/* Goals loader: three polaroids that develop, text, three blinking dots - equal 16px steps */
.goals-loader { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; min-height: 50vh; padding: var(--space-32) var(--space-16); text-align: center; }
.gl-stack { position: relative; width: 200px; height: 98px; }
.gl-pol { position: absolute; width: 64px; padding: 4px 4px 14px; background: var(--polaroid, #f4efe6); border-radius: 3px; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5); animation: gl-dev 2.4s ease-in-out infinite; }
.gl-pol i { display: block; aspect-ratio: 1; border-radius: 2px; background: #3A4F63; animation: gl-img 2.4s ease-in-out infinite; }
.gl-p1 { right: 0; top: 10px; transform: rotate(7deg); }
.gl-p2 { right: 62px; top: 0; transform: rotate(-4deg); animation-delay: 0.35s; } .gl-p2 i { animation-delay: 0.35s; }
.gl-p3 { right: 124px; top: 12px; transform: rotate(-9deg); animation-delay: 0.7s; } .gl-p3 i { animation-delay: 0.7s; }
.gl-text { margin: 0; font-size: 15px; line-height: 20px; color: #DDE8F2; }
.gl-dots { display: flex; justify-content: center; gap: 5px; height: 6px; }
.gl-dots span { width: 6px; height: 6px; border-radius: 50%; background: #79E3C8; animation: gl-dot 1.2s infinite; }
.gl-dots span:nth-child(2) { animation-delay: 0.2s; } .gl-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes gl-dev { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
@keyframes gl-img { 0% { background: #3A4F63; } 60%, 100% { background: #5DD3E8; } }
@keyframes gl-dot { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .gl-pol, .gl-pol i, .gl-dots span { animation: none; } .gl-pol i { background: #5DD3E8; } }

/* Wide screens: three goals per row (the page and the app bar get wider to fit them) */
@media (min-width: 1024px) { .wrap { max-width: 1160px; } .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Picture picker: every picture is a small polaroid; the selected one straightens and lifts */
.pol-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px 8px; padding: 8px 4px 4px; } /* five per row: ten pictures and the upload tile fit in three short rows */
.pol-cell { position: relative; min-width: 0; }
.pol-grid .pic-opt { display: block; width: 100%; height: auto; padding: 3px 3px 10px; overflow: visible; border: 0; border-radius: 2px; background: var(--polaroid, #f4efe6); box-shadow: 0 3px 7px rgba(0, 0, 0, 0.45); transform: rotate(-3deg); transition: transform 0.15s ease, box-shadow 0.15s ease; }
.pol-grid .pol-cell:nth-child(4n+2) .pic-opt { transform: rotate(2.5deg); }
.pol-grid .pol-cell:nth-child(4n+3) .pic-opt { transform: rotate(-1.5deg); }
.pol-grid .pol-cell:nth-child(4n+4) .pic-opt { transform: rotate(3deg); }
.pol-grid .pic-opt img { display: block; width: 100%; aspect-ratio: 1; height: auto; border-radius: 1px; object-fit: cover; }
.pol-grid .pic-opt:hover { transform: rotate(0) translateY(-2px); }
.pol-grid .pic-opt[aria-pressed="true"] { transform: rotate(0) scale(1.06); background: var(--polaroid, #f4efe6); box-shadow: 0 0 0 2px var(--color-focus), 0 6px 12px rgba(0, 0, 0, 0.5), 0 0 14px 1px var(--aurora-glow); }
.pol-grid .pic-opt[aria-pressed="true"]::after { top: -7px; inset-inline-end: -7px; width: 16px; height: 16px; line-height: 16px; font-size: 10px; font-weight: 700; z-index: 1; }
.pol-emoji span { display: grid; place-items: center; aspect-ratio: 1; font-size: 26px; background: #E8E1D2; border-radius: 1px; }
.pol-upload { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 100%; height: auto; aspect-ratio: 1 / 1.16; padding: 2px; border: 1.5px dashed #6C8497; border-radius: 2px; background: transparent; color: #A9BDCB; font-family: inherit; font-size: 10px; line-height: 1.15; text-align: center; box-shadow: none; }
.pol-upload:hover { border-color: var(--color-focus); color: #DDE8F2; }
.pol-plus { font-size: 17px; line-height: 1; }
.pol-remove { position: absolute; top: -7px; inset-inline-start: -7px; z-index: 2; width: 18px; height: 18px; padding: 0; border: 0; border-radius: 50%; background: #F2A08F; color: #10202C; font-size: 10px; font-weight: 700; line-height: 18px; text-align: center; }
.pol-grid button:disabled { opacity: 0.55; }

/* Mobile only: the add button (two polaroids and a small plus badge) sits at the end of the sticky title row, its top level with the title and its bottom just spilling over the row's line (the desktop keeps a normal button in the title row). */
.fab { display: none; }
@media (max-width: 639px) {
  .fab { display: block; position: absolute; z-index: 2; inset-inline-end: 8px; top: 14px; width: 86px; height: 86px; padding: 0; border: 0; background: none; cursor: pointer; transform: scale(0.64); transform-origin: top left; }
  .fab-pol { position: absolute; display: block; padding: 3px 3px 9px; background: var(--polaroid, #f4efe6); border-radius: 3px; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5); box-sizing: border-box; }
  .fab-pol img { display: block; width: 100%; height: 100%; object-fit: cover; }
  .fab-pol-back { width: 50px; height: 57px; right: 4px; top: 4px; transform: rotate(-12deg); }
  .fab-pol-front { width: 62px; height: 69px; right: 18px; top: 14px; transform: rotate(7deg); }
  .fab-plus { position: absolute; right: 0; bottom: 0; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-gold); color: var(--bg-app); border: 3px solid var(--bg-app); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5); box-sizing: border-box; }
  .fab-plus svg { width: 14px; height: 14px; stroke-width: 3.2; }
  .fab:active { transform: scale(0.6); }
}

/* Cream strip under the picture: start date and the delete button */
.card-foot { position: absolute; inset-inline: -9px; bottom: -30px; height: 30px; display: flex; align-items: center; justify-content: space-between; padding-inline: 8px 6px; color: color-mix(in srgb, var(--bg-app) 62%, var(--polaroid, #f4efe6)); font-size: 11px; cursor: default; }
.card-start { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-del { display: grid; place-items: center; width: 30px; height: 30px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; flex: none; }
.card-del:hover { color: color-mix(in srgb, var(--danger) 65%, var(--bg-app)); background: color-mix(in srgb, var(--danger) 18%, transparent); }
.card-del:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 0; }
/* Pause sits next to the trash; on a paused goal it becomes a filled "continue" button */
.card-btns { display: flex; flex: none; gap: 2px; }
.card-pause:hover { color: var(--bg-app); background: rgba(23, 34, 46, 0.12); }
.card .card-play { display: flex; align-items: center; justify-content: center; gap: 5px; width: auto; height: 22px; align-self: center; padding: 0 9px; border: 1px solid rgba(23, 34, 46, 0.45); border-radius: 999px; color: #17222e; font: inherit; font-size: 11.5px; font-weight: 600; line-height: 1; }
.card .card-play:hover { background: rgba(23, 34, 46, 0.12); }
.card .card-play .icon, .card .card-play svg { width: 9px; height: 9px; }
/* A paused goal fades; the continue button stays clear */
.card.paused .card-banner img, .card.paused .vb-pic img { filter: grayscale(1) brightness(0.8); }
.card.paused > .gauge, .card.paused > .chips, .card.paused .vb-bar, .card.paused .vb-top { filter: grayscale(1); }
.card.paused > .gauge, .card.paused > .chips, .card.paused .vb-cap > :not(.vb-last) { opacity: 0.55; }
.milestone-paused .icon { width: 18px; height: 18px; }

/* Wide cards end right after their last row. The "achieved" strip lies on the picture, so an achieved goal does not make its whole row of cards taller. */
@media (min-width: 640px) {
  .card { padding-bottom: var(--space-16); }
  .card > .success-head { position: absolute; top: 0; left: 0; right: 0; margin: 0; z-index: 4; }
  .card.achieved > .card-banner { margin-top: calc(-1 * var(--card-pad)); padding-top: 50px; }
  .card.achieved .card-banner .share, .card.achieved .card-banner .pa-stack { top: 50px; }
}

/* "Discover other people's goals": the search card under the filter row (public filter only) */
.disc { margin-bottom: var(--space-16); padding: var(--space-16); border: 1px solid var(--color-border); border-radius: var(--radius-card); background: linear-gradient(135deg, color-mix(in srgb, var(--aurora-4) 14%, var(--color-surface)), var(--color-surface) 70%); }
.disc-title { margin: 0; font-size: 16px; font-weight: 700; color: var(--color-text); }
.disc-sub { margin: 2px 0 var(--space-12); font-size: 13px; color: var(--color-text-muted); }
.disc-field { position: relative; display: flex; align-items: center; height: 40px; }
.disc-ico { position: absolute; inset-inline-start: 14px; display: grid; place-items: center; color: var(--color-text-muted); pointer-events: none; }
.disc-ico svg { width: 18px; height: 18px; }
.disc-input { width: 100%; height: 40px; box-sizing: border-box; padding-block: 0; padding-inline: 40px; border: 1px solid var(--color-border); border-radius: var(--radius-pill); background: var(--color-surface-2); color: var(--color-text); font: inherit; font-size: 14px; -webkit-appearance: none; appearance: none; }
.disc-input::placeholder { color: var(--color-text-muted); }
.disc-input::-webkit-search-cancel-button { display: none; }
.disc-input:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.disc-x { position: absolute; inset-inline-end: 6px; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--color-text-muted); }
.disc-x svg { width: 16px; height: 16px; }
.disc-x:hover { background: var(--color-surface); color: var(--color-text); }
.disc-x:focus-visible { outline: 2px solid var(--color-focus); }
.disc-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.disc-live { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.disc-cats { display: flex; gap: var(--space-12); margin: var(--space-12) 0 0; padding: 8px 4px 4px; list-style: none; overflow-x: auto; scrollbar-width: none; }
.disc-cats::-webkit-scrollbar { display: none; }
.disc-cat { flex: none; }
.disc-pol { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0; border: 0; background: none; color: var(--color-text); font: inherit; font-size: 11px; cursor: pointer; }
.disc-pol img { display: block; width: 56px; height: 56px; box-sizing: content-box; padding: 3px 3px 10px; background: var(--polaroid, #f4efe6); border-radius: 2px; object-fit: cover; box-shadow: 0 3px 7px rgba(0, 0, 0, 0.45); transform: rotate(var(--tilt, 0deg)); transition: transform 0.15s ease, box-shadow 0.15s ease; background-clip: padding-box; }
.disc-pol:hover img { transform: rotate(0) translateY(-2px); }
.disc-pol[aria-pressed="true"] img { transform: rotate(0) scale(1.05); box-shadow: 0 0 0 2px var(--accent-mint-strong), 0 6px 12px rgba(0, 0, 0, 0.5); }
.disc-pol[aria-pressed="true"] .disc-cap { color: var(--accent-mint-strong); font-weight: 600; }
.disc-pol:focus-visible { outline: none; }
.disc-pol:focus-visible img { box-shadow: 0 0 0 2px var(--color-focus), 0 3px 7px rgba(0, 0, 0, 0.45); }
.disc-empty { margin: var(--space-24) 0; }
.disc-empty p { margin: 0 0 var(--space-8); }
.disc-link { padding: 4px 8px; border: 0; background: none; color: var(--color-link); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; }

/* Phones: the goal list is a vision board (taped polaroids over the cork photo). Wider screens never show .vb and keep the card above. */
.vb { display: none; }
@media (max-width: 639px) {
  .grid { gap: 26px; padding-top: 10px; }
  .grid::before { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: linear-gradient(rgba(7, 17, 29, 0.62), rgba(7, 17, 29, 0.82)), url("../pics/budget-bg.jpg") center / cover; }
  .card { gap: 0; margin: 0 6px; padding: 9px 9px 6px; border: 0; border-radius: 5px; background: var(--polaroid, #f4efe6); color: #17222e; box-shadow: 0 12px 24px rgba(0, 0, 0, 0.6); }
  .card > :not(.vb) { display: none; }
  .vb { display: block; min-width: 0; }
  .vb-tape { position: absolute; top: -11px; left: 50%; width: 84px; height: 22px; margin-left: -42px; background: rgba(235, 203, 136, 0.82); transform: rotate(-3deg); z-index: 4; }
  .vb-pic { position: relative; height: 150px; border-radius: 2px; overflow: hidden; background: var(--surface-1); }
  .vb-pic .banner-pic img { -webkit-mask-image: none; mask-image: none; }
  .vb-pic .banner-pic::after { content: none; }
  .vb-pic .banner-emoji { font-size: 64px; margin: 24px 0 0; justify-self: center; }
  .vb-top { position: relative; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 9px; }
  .vb-who, .vb-top .tag { display: inline-flex; align-items: center; min-height: 28px; box-sizing: border-box; border: 1px solid rgba(255, 255, 255, 0.16); border-radius: var(--radius-pill); background: rgba(7, 17, 29, 0.76); color: #fff; font-size: 12px; font-weight: 500; }
  .vb-who { flex: none; gap: 5px; padding: 1px 3px; padding-inline-start: 8px; }
  .vb-top .tag { display: block; flex: none; max-width: 100%; line-height: 26px; padding: 0 10px; color: #d3f1e4; overflow: hidden; text-overflow: ellipsis; }
  .vb-who .share { position: static; width: auto; height: auto; border: 0; background: none; color: inherit; }
  .vb-who .share .icon { width: 14px; height: 14px; }
  .vb-who .pa-stack { position: static; display: inline-flex; align-items: center; gap: 3px; width: auto; height: 22px; }
  .vb-who .pa-row { width: calc(22px + 9px * var(--n, 0)); }
  .vb-who .pa { border-width: 1px; border-color: rgba(255, 255, 255, 0.7); color: var(--color-text); }
  .vb-who .pa { left: auto; right: 0; }
  .vb-who .pa-l1 { transform: translateX(-9px); }
  .vb-who .pa-l2 { transform: translateX(-18px); }
  .vb-who .pa-count { position: static; border: 0; background: none; color: #fff; padding: 0 4px 0 2px; min-width: 0; font-size: 12px; }
  /* Days left: a tear-off calendar leaf */
  .vb-stamp { position: absolute; bottom: 8px; left: 10px; min-width: 58px; display: flex; flex-direction: column; align-items: center; border-radius: 7px; overflow: hidden; background: #fbf8f1; color: #17222e; line-height: 1.2; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45); }
  .vb-stamp span { font-size: 11px; color: #52606c; padding: 0 6px 4px; }
  .vb-stamp span:first-child { align-self: stretch; text-align: center; padding: 2px 6px; background: var(--accent-gold); color: #17222e; font-weight: 600; }
  .vb-stamp b { font-size: 21px; font-weight: 600; padding: 0 6px; }
  .vb-stamp-done .icon { width: 24px; height: 24px; margin: 7px 0 3px; color: #17604b; }
  .vb-stamp-done span:first-of-type { align-self: center; background: none; color: #17604b; font-size: 12px; font-weight: 600; padding: 0 8px 5px; }
  .vb-stamp-done { border-top: 14px solid #9AD8BD; }
  .vb-cap { padding: 7px 4px 0; font-size: 13.5px; line-height: 1.45; }
  .vb-owner { font-size: 12px; color: #52606c; }
  .vb-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0 10px; }
  .vb-row:first-of-type { flex-wrap: nowrap; }
  .card .vb h2 { min-width: 0; font-size: 19px; font-weight: 600; color: #17222e; }
  .vb-pct { flex: none; font-size: 22px; font-weight: 700; color: var(--surface-1); }
  .vb-bar { height: 10px; margin: 4px 0 6px; border-radius: 9px; background: #ded7ca; overflow: hidden; }
  /* The fill uses the same colours as the wide card's gauge, spread over the filled part; the tip marks the interest. */
  .vb-bar i { position: relative; display: block; height: 100%; border-radius: 9px; overflow: hidden; background: linear-gradient(to left, var(--aurora-1), var(--aurora-2) 35%, var(--aurora-3) 70%, var(--aurora-4)); }
  .vb-bar i b { position: absolute; top: 0; bottom: 0; left: 0; background: var(--aurora-4); }
  .vb-money b { font-size: 17px; font-weight: 600; }
  .vb-int { color: var(--aurora-4); font-weight: 600; } /* the gauge interest colour */
  .vb-done { margin-top: 4px; padding: 3px 10px; border-radius: 8px; background: #d5ecdf; color: #17604b; font-weight: 600; text-align: center; }
  .vb-dim { margin-top: 3px; color: #52606c; font-size: 12.5px; }
  .vb-last { flex-wrap: nowrap; margin-top: 0; min-height: 32px; }
  .vb .card-del { width: 32px; height: 32px; color: #52606c; }
  .vb .card-play { width: auto; height: 24px; color: #17222e; }
  .card.paused { background: #cfccc6; }
  .card.paused .vb-tape { width: 130px; margin-left: -65px; display: flex; align-items: center; justify-content: center; background: #8f99a3; color: #fff; font-size: 13px; font-weight: 600; }
  .card.paused .vb-stamp span:first-child { background: #8f99a3; color: #fff; }
  .vb-stamp-paused .icon { width: 22px; height: 22px; margin: 3px 0; }
}
