/* Saved & Calm · challenges: list, setup, grid, spin, printable sheet. */

.section-title--first { margin-top: 0; }

/* ── Library cards as links ────────────────────────── */
a.lib-card { color: inherit; text-decoration: none; transition: transform .2s var(--ease), box-shadow .2s, border-color .2s; }
a.lib-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
.lib-card h3 { font-size: 1.1rem; align-self: end; }
.lib-card__foot .pill { flex: none; }

/* ── Progress bars ─────────────────────────────────── */
.bar {
  display: block; height: 10px; border-radius: var(--r-pill);
  background: var(--surface-sunk); overflow: hidden;
}
.bar > span {
  display: block; height: 100%; min-width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--fill-1), var(--fill-2), var(--fill-3), var(--fill-4));
  transition: width .6s var(--ease);
}
.bar--big { height: 16px; }

/* ── Your challenges ───────────────────────────────── */
.ch-list { display: grid; gap: var(--s-3); margin: 0 0 var(--s-2); padding: 0; list-style: none; }
@media (min-width: 1280px) { .ch-list { grid-template-columns: 1fr 1fr; } }
.ch-card {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4); border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1);
  color: inherit; text-decoration: none;
  transition: transform .2s var(--ease), box-shadow .2s;
}
.ch-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.ch-card.is-quiet { opacity: .78; }
.ch-card__icon {
  display: grid; place-items: center; flex: none; width: 52px; height: 52px;
  border-radius: 16px; background: var(--fill-1); font-size: 1.6rem;
}
.ch-card__body { display: grid; gap: 4px; flex: 1; min-width: 0; }
.ch-card__name { font-weight: 550; }
.ch-card__body small { color: var(--ink-soft); }
.ch-card__pct {
  font-family: var(--font-display); font-variation-settings: var(--soft);
  font-size: 1.5rem; font-weight: 600; color: var(--accent-strong);
}

/* ── Setup ─────────────────────────────────────────── */
.setup-head { grid-template-columns: auto 1fr; align-items: center; column-gap: var(--s-4); }
.setup-head__icon {
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px;
  background: var(--fill-2); font-size: 2rem; transform: rotate(-4deg);
}
.setup { display: grid; gap: var(--s-4); }
.setup__main .card + .card { margin-top: var(--s-4); }
.setup__preview { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s-2)); z-index: 5; box-shadow: var(--shadow-2); }
@media (min-width: 1000px) {
  .setup { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
  .setup__preview { top: 80px; bottom: auto; }
}
.preview__total { margin-top: var(--s-2); font-size: var(--step-1); }
.preview__total b { font-family: var(--font-display); font-variation-settings: var(--soft); font-size: 1.8rem; color: var(--accent-strong); }
.mini-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; margin: var(--s-3) 0; }
.mini-grid span {
  display: grid; place-items: center; aspect-ratio: 1; border-radius: 6px;
  background: var(--cell); font-size: .55rem; color: #1D2B24; overflow: hidden; font-variant-numeric: tabular-nums;
}
.mini-grid__more { background: var(--surface-2) !important; color: var(--ink-soft) !important; font-size: .7rem !important; }
.mini-grid--blank span { background: transparent; border: 1.5px dashed var(--line-strong); color: var(--ink-soft); }
.shape-row { display: grid; grid-template-columns: 88px 1fr; align-items: center; gap: var(--s-2) var(--s-3); margin-top: var(--s-2); }
.shape-row__label { font-weight: 600; font-size: var(--step--1); color: var(--ink-soft); }
@media (max-width: 420px) { .shape-row { grid-template-columns: 1fr; gap: var(--s-1); } }
@media (max-width: 999px) { .setup__preview .mini-grid { display: none; } }
.btn--block { width: 100%; margin-top: var(--s-3); }
.rule-list { display: grid; gap: var(--s-2); }
.dot-row { display: inline-flex; gap: 2px; margin-right: 4px; }
.dot-row i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.input--area { min-height: 96px; padding: var(--s-3) var(--s-4); resize: vertical; line-height: 1.5; }

/* ── Grid screen hero ──────────────────────────────── */
.ch-hero {
  padding: var(--s-5); border-radius: var(--r-lg);
  background:
    radial-gradient(90% 120% at 100% 0%, color-mix(in srgb, var(--fill-2) 45%, transparent), transparent 60%),
    radial-gradient(70% 100% at 0% 100%, color-mix(in srgb, var(--fill-1) 40%, transparent), transparent 60%),
    var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-2);
}
.ch-hero__top { display: flex; align-items: center; gap: var(--s-3); }
.ch-hero__icon {
  display: grid; place-items: center; flex: none; width: 56px; height: 56px; border-radius: 18px;
  background: var(--surface); box-shadow: var(--shadow-1); font-size: 1.8rem;
}
.ch-hero__title { flex: 1; min-width: 0; display: grid; gap: 2px; }
.ch-hero__title h1 { font-size: clamp(1.4rem, 5vw, 1.9rem); }
.ch-hero__top .icon-btn { font-size: 1.4rem; background: var(--surface); }
.ch-hero__nums { margin-top: var(--s-4); display: grid; gap: var(--s-3); }
.ch-big {
  font-family: var(--font-display); font-variation-settings: var(--soft);
  font-size: clamp(2.2rem, 9vw, 3.2rem); font-weight: 650; line-height: 1; letter-spacing: -.02em;
  color: var(--accent-strong); font-variant-numeric: tabular-nums;
}
.ch-big__of { font-size: .42em; font-weight: 450; color: var(--ink-soft); letter-spacing: 0; }
.ch-stats { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); color: var(--ink-soft); font-size: var(--step--1); }
.ch-stats b { color: var(--ink); font-weight: 600; }

.ch-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3);
  margin-top: var(--s-4); padding: var(--s-3) var(--s-4); border-radius: var(--r);
  background: var(--surface-2); color: var(--ink);
}
.ch-banner--gold { background: var(--gold-wash); color: var(--gold-ink); }
.ch-banner__actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

.ch-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); margin: var(--s-4) 0 0; }
.ch-actions .btn { flex: 1 1 160px; }

/* ── The grid ──────────────────────────────────────── */
.grid {
  display: grid; gap: 8px; margin-top: var(--s-5);
  grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
}
.grid--dense { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.grid--calendar { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.grid__weekday { text-align: center; font-size: var(--step--1); font-weight: 500; color: var(--ink-faint); }

.cell {
  position: relative; display: grid; place-content: center; justify-items: center; gap: 1px;
  aspect-ratio: 1; min-height: 44px; padding: 2px;
  border: 1.5px dashed var(--line-strong); border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  color: var(--ink); cursor: pointer; overflow: hidden;
  font-variant-numeric: tabular-nums;
  transition: transform .15s var(--ease), border-color .2s, background-color .2s;
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
.grid--dense .cell { border-radius: 10px; }
.cell:hover { border-color: var(--accent); transform: translateY(-1px); }
.cell:active { transform: scale(.94); }
.cell__n {
  font-family: var(--font-display); font-variation-settings: var(--soft);
  font-size: 1.15rem; font-weight: 600; line-height: 1;
}
.grid--dense .cell__n { font-size: .85rem; }
.cell__amt { font-size: .66rem; color: var(--ink-soft); line-height: 1.1; }
.cell__tick {
  position: absolute; top: 3px; right: 5px;
  font-size: .7rem; font-weight: 700; color: #1D2B24; opacity: 0; transform: scale(.4);
  transition: opacity .2s, transform .3s var(--ease);
}
.grid--dense .cell__tick { display: none; }

/* Filled: a soft splash of colour, like a coloured-in square on paper */
.cell.is-filled {
  border-style: solid; border-color: transparent;
  background:
    radial-gradient(120% 120% at 30% 25%, color-mix(in srgb, #fff 35%, var(--cell)) 0%, var(--cell) 60%);
  color: #1D2B24;
}
.cell.is-filled .cell__amt { color: rgba(29, 43, 36, .7); }
.cell.is-filled .cell__tick { opacity: 1; transform: none; }
:root[data-theme="dark"] .cell.is-filled, :root[data-theme="dark"] .cell.is-filled .cell__tick { color: #F6F3EB; }
:root[data-theme="dark"] .cell.is-filled .cell__amt { color: rgba(246, 243, 235, .78); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cell.is-filled, :root:not([data-theme="light"]) .cell.is-filled .cell__tick { color: #F6F3EB; }
  :root:not([data-theme="light"]) .cell.is-filled .cell__amt { color: rgba(246, 243, 235, .78); }
}

.cell.is-locked { opacity: .55; border-style: dotted; }
.cell.is-locked:hover { transform: none; border-color: var(--line-strong); }
.cell.is-next {
  opacity: 1; border: 2px solid var(--gold);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 28%, transparent);
  animation: glow 2.2s ease-in-out infinite;
}
@keyframes glow { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--gold) 12%, transparent); } }

.cell.just-filled { animation: splash .55s var(--ease); }
.cell.just-filled::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(circle, rgba(255, 255, 255, .7) 0%, transparent 60%);
  animation: shine .6s ease-out forwards;
}
@keyframes splash { 0% { transform: scale(.7); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes shine { from { opacity: 1; transform: scale(.3); } to { opacity: 0; transform: scale(1.6); } }

/* ── Fill Your Own (write-in) cells ─────────────────── */
.cell--writein .cell__n { font-size: .78rem; opacity: .75; }
.cell__line { display: block; width: 58%; margin: 6px auto 2px; border-bottom: 1.5px dotted var(--line-strong); }
.cell__write {
  font-family: var(--font-display); font-weight: 600; font-size: .98rem; line-height: 1.1;
  font-variation-settings: var(--soft); letter-spacing: -.01em;
}
.grid--dense .cell__write { display: none; }
.cell.is-filled .cell__write { color: #1D2B24; }
:root[data-theme="dark"] .cell.is-filled .cell__write { color: #F6F3EB; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .cell.is-filled .cell__write { color: #F6F3EB; } }
.cell.is-skipped { border-style: solid; border-color: var(--line); background: var(--surface-2); }
.cell--shaped.is-skipped { background: transparent; border-color: transparent; }
.cell--shaped .cell__write { font-size: .84rem; }
.wi-skip { display: block; margin-top: var(--s-3); }
.cell__skip { font-family: var(--font-display); font-size: 1.3rem; line-height: 1; color: var(--ink-soft); }
.ch-forecast { margin: var(--s-2) 0 0; color: var(--ink-soft); }
.ch-forecast b { color: var(--ink); }

/* ── Edit amounts mode ─────────────────────────────── */
.edit-head {
  margin-top: var(--s-4); padding: var(--s-3) var(--s-4); border-radius: var(--r);
  background: var(--gold-wash); color: var(--gold-ink);
}
.edit-head h2 { margin: 0 0 var(--s-1); font-size: var(--step-1); }
.edit-head p { margin: 0; }
.edit-head__key { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: var(--s-2) !important; color: inherit; opacity: .85; }
.edit-key { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: middle; }
.edit-head__key > span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; margin-right: var(--s-3); }
.edit-key--pinned { border: 2px solid var(--gold); background: var(--surface); }
.edit-key--changed { border: 2px dashed var(--ink-soft); background: var(--surface); }

[data-editing] .cell:not(.is-filled) { border-style: dashed; cursor: text; }
[data-editing] .cell.is-filled { opacity: .45; }
[data-editing] .cell.is-pinned, .cell.is-pinned { border: 2px solid var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 22%, transparent); }
.cell.is-pinned .cell__amt, .cell.is-changed .cell__amt { color: var(--ink); font-weight: 700; }
.cell.is-changed .cell__amt { text-decoration: underline dotted; text-underline-offset: 2px; }
.cell.is-changed { border-color: var(--ink-soft); }

.edit-bar {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s-2)); z-index: 5;
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--s-2) var(--s-4);
  margin-top: var(--s-4); padding: var(--s-3) var(--s-4); border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-2);
}
.edit-bar__total { margin: 0; font-size: var(--step-1); }
.edit-bar__total .money { font-family: var(--font-display, inherit); font-weight: 700; }
.edit-bar__keep { display: inline-flex; align-items: center; gap: var(--s-2); min-height: 44px; cursor: pointer; }
.edit-bar__keep input { width: 20px; height: 20px; accent-color: var(--gold); }
.edit-bar__warn { grid-column: 1 / -1; margin: 0; padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); background: var(--gold-wash); color: var(--gold-ink); font-size: var(--step--1); }
.edit-bar__btns { display: flex; gap: var(--s-2); justify-content: flex-end; }
.edit-bar__btns .btn { white-space: nowrap; }
@media (min-width: 521px) { .edit-bar { grid-template-columns: 1fr auto auto; } }
@media (max-width: 520px) {
  .edit-bar { grid-template-columns: 1fr; gap: var(--s-1); padding: var(--s-2) var(--s-3); }
  .edit-bar__total { font-size: var(--step-0); }
  .edit-bar__keep { min-height: 40px; }
  .edit-bar__btns .btn { flex: 1; min-height: 44px; padding-inline: var(--s-3); }
}

/* ── Menu dialog ───────────────────────────────────── */
.menu-list { display: grid; gap: 4px; margin-top: var(--s-2); }
.menu-item {
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 52px; padding: var(--s-2) var(--s-3);
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--ink);
  text-align: left; cursor: pointer; font-size: 1rem;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item__icon { width: 28px; text-align: center; font-size: 1.15rem; }
.menu-item__text { display: grid; }
.menu-item__text small { color: var(--ink-soft); font-size: var(--step--1); }
.menu-item--danger { color: var(--coral-ink); }

/* ── Spin, low money, celebrate ────────────────────── */
.spin {
  display: grid; place-items: center; margin: var(--s-3) 0;
  padding: var(--s-5); border-radius: var(--r);
  background: repeating-linear-gradient(-45deg, var(--surface-2) 0 12px, var(--surface) 12px 24px);
  border: 1px solid var(--line);
}
.spin__slot {
  display: grid; justify-items: center; gap: 4px; min-width: 200px; padding: var(--s-4) var(--s-5);
  border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow-1);
}
.spin__label { color: var(--ink-soft); font-size: var(--step--1); letter-spacing: .04em; }
.spin__amount {
  font-family: var(--font-display); font-variation-settings: var(--soft);
  font-size: 2.6rem; font-weight: 650; color: var(--accent-strong); line-height: 1.05;
}
.spin__slot.is-landed { animation: land .45s var(--ease); background: var(--gold-wash); }
.spin__slot.is-landed .spin__label { color: var(--gold-ink); font-weight: 600; }
@keyframes land { 0% { transform: scale(.9); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }
.spin__note { text-align: center; }

.low-money, .celebrate {
  display: grid; justify-items: center; gap: 2px; margin: var(--s-2) 0 var(--s-3);
  padding: var(--s-4); border-radius: var(--r); background: var(--accent-wash); text-align: center;
}
.low-money span { color: var(--ink-soft); font-size: var(--step--1); }
.low-money b, .celebrate {
  font-family: var(--font-display); font-variation-settings: var(--soft);
  font-size: 2rem; font-weight: 650; color: var(--accent-strong);
}
.celebrate { font-size: 1.5rem; background: var(--gold-wash); color: var(--gold-ink); }

/* ── Printable sheet ───────────────────────────────── */
.print-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.tick-toggle { display: inline-flex; align-items: center; gap: var(--s-2); min-height: 44px; font-size: var(--step--1); color: var(--ink-soft); cursor: pointer; }
.tick-toggle input { width: 20px; height: 20px; accent-color: var(--accent); }

/* Small calendar cells: the fill colour carries the tick; the 🌿 would cover the date. */
@media (max-width: 520px) {
  .grid--calendar .cell__tick { display: none; }
  .grid--calendar { gap: 6px; }
}

/* ── Goal size picker ──────────────────────────────── */
.goal-chips { display: grid; gap: var(--s-2); grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.goal-chip { position: relative; cursor: pointer; }
.goal-chip input { position: absolute; opacity: 0; pointer-events: none; }
.goal-chip__body {
  display: grid; gap: 2px; height: 100%; padding: var(--s-3);
  border: 1.5px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface);
  transition: border-color .2s, background-color .2s;
}
.goal-chip__body b { font-family: var(--font-display); font-variation-settings: var(--soft); font-size: 1.25rem; font-weight: 650; }
.goal-chip__body small { color: var(--ink-soft); font-size: .74rem; line-height: 1.35; }
.goal-chip__tag { color: var(--gold-ink) !important; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; font-size: .66rem !important; }
.goal-chip:hover .goal-chip__body { border-color: var(--accent); }
.goal-chip input:checked + .goal-chip__body { border-color: var(--accent); background: var(--accent-wash); }
.goal-chip input:checked + .goal-chip__body b { color: var(--accent-strong); }
.goal-chip input:focus-visible + .goal-chip__body { box-shadow: var(--ring); }
.goal-scale { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-top: var(--s-3); }
.chip--small span { min-height: 44px; padding: 0 var(--s-3); font-size: var(--step--1); }
.ob-options #ob-goals .goal-chips { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

/* ── 12-Month Saver ────────────────────────────────── */
.months { display: grid; gap: var(--s-3); margin-top: var(--s-5); grid-template-columns: 1fr; }
@media (min-width: 620px) { .months { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1280px) { .months { grid-template-columns: repeat(3, 1fr); } }
.month { padding: var(--s-3) var(--s-4) var(--s-4); border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); }
.month.is-now { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.month.is-done { background: color-mix(in srgb, var(--accent-wash) 55%, var(--surface)); }
.month__head { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2); }
.month__head h2 { flex: 1; font-size: 1.05rem; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.month__emoji { font-size: 1.3rem; }
.month__sum { font-size: var(--step--1); font-weight: 600; color: var(--accent-strong); white-space: nowrap; }
.month__sum small { color: var(--ink-faint); font-weight: 400; }
.grid--month { margin-top: 0; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }

/* ── Cash stuffing ─────────────────────────────────── */
.ch-methods { font-size: var(--step--1); color: var(--ink-soft); }
.ch-methods b { color: var(--ink); font-weight: 600; }
.save-as { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin-top: var(--s-3); }
.cell.is-filled .cell__tick { font-size: .7rem; }
.celebrate { display: block; text-align: center; }
