@layer views {
  /* ── levels: the goal ring, the streak, the level bar, "+xp", celebrations, recaps ── */
  .goal-ring { position: relative; display: inline-grid; place-items: center; flex: none; }
  .goal-ring svg { display: block; rotate: -90deg; }
  .ring-track { fill: none; stroke: var(--track); stroke-width: 3.5; }
  .ring-arc { fill: none; stroke: var(--reward-fill); stroke-width: 3.5; stroke-linecap: round; transition: stroke-dashoffset 900ms var(--ease-liquid), stroke var(--t); }
  .goal-ring[data-done="true"] .ring-arc { stroke: var(--success); }
  .goal-ring b { position: absolute; font-size: var(--fs-label); font-weight: 800; color: var(--fg); font-variant-numeric: tabular-nums; }

  .streak { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: var(--fs-sm); }
  .streak svg { width: 17px; height: 17px; }
  .streak b { font-variant-numeric: tabular-nums; }
  .streak[data-on="true"] { color: var(--reward); }
  .streak[data-on="true"] svg { fill: color-mix(in oklch, var(--reward) 30%, transparent); }
  .streak[data-on="true"][data-today="false"] { opacity: .7; }

  .celebrate { position: fixed; inset: 0 0 auto; z-index: 70; display: grid; justify-items: center; padding-top: calc(76px + env(safe-area-inset-top, 0px)); pointer-events: none; }
  .celebrate-card {
    position: relative; pointer-events: auto; cursor: pointer; display: grid; justify-items: center; gap: 2px; padding: 16px 30px 17px;
    border-radius: var(--r-card); border: 1.5px solid transparent; box-shadow: var(--shadow-float);
    background: linear-gradient(var(--bg-raise), var(--bg-raise)) padding-box, var(--grad) border-box;
    animation: cele-in 520ms var(--ease-liquid);
  }
  .celebrate-card b { font-size: 26px; font-weight: 800; letter-spacing: -0.04em; color: var(--fg); }
  .celebrate-card > span:not(.burst) { font-size: var(--fs-meta); color: var(--fg-2); }
  /* the daily goal met: done, so the colour of done (7, 30 and 100 days in a row keep the gradient) */
  .celebrate[data-tone="goal"] .celebrate-card { background: var(--bg-raise); border-color: var(--success); }
  .celebrate.out .celebrate-card { animation: cele-out 300ms ease-in forwards; }
  @keyframes cele-in { from { opacity: 0; translate: 0 -14px; scale: .94; } }
  @keyframes cele-out { to { opacity: 0; translate: 0 -10px; } }
  .burst { position: absolute; inset: 50% auto auto 50%; width: 0; height: 0; }
  .burst i {
    position: absolute; width: 6px; height: 6px; margin: -3px; border-radius: 2px; background: var(--grad-a, var(--learning));
    rotate: calc(var(--k) * 25.7deg); animation: burst 900ms var(--ease-liquid) forwards;
  }
  .burst i:nth-child(3n) { background: var(--reward-fill); } .burst i:nth-child(3n + 1) { background: var(--known); }
  @keyframes burst { 0% { transform: translateY(0) scale(1); opacity: 1; } 100% { transform: translateY(-86px) scale(.4); opacity: 0; } }

  .recap { display: grid; gap: 14px; padding: var(--pad-card); border-radius: var(--r-card); border: 1px solid var(--line); background: var(--surface); }
  .recap-stats { display: flex; flex-wrap: wrap; gap: 10px 22px; }
  .recap-stat { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-meta); color: var(--fg-2); }

  .prog-card { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 28px; padding: var(--pad-card); border-radius: var(--r-card); border: 1px solid var(--line); background: var(--surface); }
  .prog-side { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 24px; }
  .prog-stat { display: flex; align-items: center; gap: 10px; }
  .prog-stat > div, .prog-stat-text { display: grid; line-height: 1.25; }
  /* The streak and the week open the last twelve weeks: plain until pointed at. */
  :is(.prog-open, button.prog-week) {
    border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
    padding: 6px 8px; margin: -6px -8px; border-radius: var(--r-item); transition: background var(--t-fast);
    &:hover { background: var(--surface-2); }
  }
  button.prog-week { height: auto; min-height: 62px; }
  .prog-stat b { font-size: var(--fs-body-sm); color: var(--fg); font-variant-numeric: tabular-nums; }
  /* the ring and the flame sit in the same 40px column, so their words line up */
  .prog-stat .streak { width: 40px; height: 40px; justify-content: center; }
  .prog-stat .streak svg { width: 26px; height: 26px; }
  .prog-stat .streak b { display: none; }
  .prog-week { display: flex; align-items: flex-end; gap: 5px; height: 50px; }
  .prog-day { display: grid; justify-items: center; gap: 3px; font-family: var(--mono); font-size: var(--fs-label); color: var(--muted); }
  .prog-day i { display: block; width: 10px; border-radius: 3px; background: var(--track); }
  .prog-day[data-met="true"] i { background: var(--success); }

  /* The last twelve weeks: a week a row, a square a day, green where the goal was met. */
  dialog.prog-cal { width: min(400px, calc(100vw - 32px)); }
  .prog-cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .prog-cal-head .icon-btn { margin: -6px -8px -6px 0; }
  .prog-cal-body { display: grid; gap: 18px; min-height: 120px; }
  .prog-cal-body > .spin { place-self: center; }
  .prog-cal-grid { display: grid; grid-template-columns: 2.6em repeat(7, minmax(0, 26px)); gap: 5px; justify-content: center; align-items: center; }
  .prog-cal-wd { text-align: center; }
  .prog-cal-month { white-space: nowrap; }
  .prog-cal-day { aspect-ratio: 1; border-radius: 5px; background: var(--track); }
  .prog-cal-day[data-some="true"] { background: color-mix(in oklch, var(--success) 28%, var(--track)); }
  .prog-cal-day[data-met="true"] { background: var(--success); }
  .prog-cal-day[data-today="true"] { outline: 2px solid var(--fg-2); outline-offset: 1px; }
  .prog-cal-day[data-future="true"] { background: none; }
  .prog-cal-stats { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 20px; padding-top: 14px; border-top: 1px solid var(--line); }
  .prog-cal-stat { display: grid; gap: 2px; }
  .prog-cal-stat b { font-size: var(--fs-row); color: var(--fg); font-variant-numeric: tabular-nums; }

  /* The session's heads-up: today's goal. */
  .ss-hud { display: flex; align-items: center; gap: 12px; }
  .ss-icon { border: 0; background: none; color: var(--muted); display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; }
  .ss-icon:hover { color: var(--fg); background: var(--surface-2); }
  .ss-icon svg { width: 16px; height: 16px; }

  /* A skill turning solid: "now solid", said quietly as the bar fills. */
  .skill[data-up="true"] .skill-tier { color: var(--fg-2); font-weight: 600; animation: cele-in 520ms var(--ease-liquid) 650ms both; }

  @media (max-width: 640px) {
    .prog-week { display: none; }
  }
  @media (prefers-reduced-motion: reduce) {
    .celebrate-card, .celebrate.out .celebrate-card, .skill[data-up="true"] .skill-tier { animation: none; }
    .ring-arc { transition: none; }
  }
}
