/* grace.css — the Grace planner's stylesheet, ported from planner/grace.html.
   Every rule is scoped under .grace (each block's mount + the runtime's portal) or under
   body.grace-host / body.grace-dark (classes grace.js puts on <body> only on a page that
   holds Grace blocks), so nothing here can restyle the rest of the site.
   Sizes that were rem are calc(n * var(--gfs)): --gfs is the member's text-size setting
   (14–24px, default 18px), set by grace.js on <html>. */
@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,500;0,600;1,400;1,500;1,600&family=Mulish:wght@400;500;600;700&display=swap');
/* ========================================
   CSS CUSTOM PROPERTIES — Follow Through ADHD palette
   ======================================== */
.grace,
body.grace-host {
  /* Follow Through ADHD — locked palette. Warm Oat ground, Walnut ink,
     Sage (completion), Clay/Terracotta (primary), Dusty Rose (accent). */
  --bg-primary: #EFE9DD;        /* Warm Oat — ground */
  --bg-secondary: #E5DECF;      /* deeper oat — nav + track troughs */
  --bg-card: #F5F0E8;           /* paper card surface */
  --bg-overlay: rgba(64,57,48,0.55);
  --text-primary: #403930;      /* Walnut ink — warm, not black */
  --text-secondary: #6E6456;    /* muted walnut */
  --text-muted: #9A8E7B;        /* quiet walnut */
  --accent: #C07A57;            /* Terracotta — primary action */
  --accent-light: #C07A5722;
  --accent-hover: #8C5638;      /* deep terracotta */
  --success: #98A684;           /* Sage — completion / done */
  --success-light: #98A68422;
  --warning: #B5654A;           /* muted terracotta — in-palette warning */
  --rose: #CFA295;              /* Dusty Rose — secondary accent */
  --lavender: #BBA89E;          /* rose-grey — kept in-palette */
  --gold: #C9A86A;              /* warm honey — kept in-palette */
  --border: #DBD2C3;            /* quiet divider line */
  --shadow: 0 2px 12px rgba(64,57,48,0.07);
  --shadow-lg: 0 10px 34px rgba(64,57,48,0.12);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-full: 999px;
  --font-body: 'Mulish', system-ui, sans-serif;
  --font-display: 'Lora', Georgia, serif;
  --font-size: 18px;
  --line-height: 1.6;
  --letter-spacing: 0.005em;
  --transition: cubic-bezier(.2,.7,.2,1);
}

/* ========================================
   DARK MODE — warm low-light layer.
   Overrides the neutral grounds with warm walnut tones for evening use.
   Sage and Clay accents are intentionally left untouched so the brand
   identity survives the flip. Accent-light tints are regenerated at
   slightly higher alpha so they stay visible on dark surfaces.
   ======================================== */
body.grace-dark,
body.grace-dark .grace {
  --bg-primary: #24201A;
  --bg-secondary: #2E2922;
  --bg-card: #322C25;
  --bg-overlay: rgba(0,0,0,0.66);
  --text-primary: #EFE9DD;
  --text-secondary: #C3B8A6;
  --text-muted: #8A8073;
  --border: #443D33;
  --shadow: 0 2px 12px rgba(0,0,0,0.35);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
}
/* Regenerate accent-light/success-light as slightly more opaque on dark
   so the tinted surfaces (capture banner, success pulses, selected
   unlock tiles) remain legible against the dark card background. */
body.grace-dark,
body.grace-dark .grace { --accent-light: color-mix(in srgb, var(--accent) 28%, transparent); }
body.grace-dark,
body.grace-dark .grace { --success-light: color-mix(in srgb, var(--success) 28%, transparent); }
/* Hairline separators read better as very-subtle light lines on dark. */
body.grace-dark .grace hr { border-color: var(--border); }
/* Images/illustrations that assume a light background get a subtle
   brightness knock-down so they don't glare. Applies only to emoji
   wrappers flagged with .dim-on-dark — we opt-in rather than blanket. */
body.grace-dark .grace .dim-on-dark { filter: brightness(0.9); }

/* ========================================
   BASE STYLES
   ======================================== */
.grace,
.grace *,
.grace *::before,
.grace *::after { box-sizing: border-box; margin: 0; padding: 0; }

.grace { font-size: var(--gfs, 18px); }

body.grace-host { background: var(--bg-primary); min-height: 100vh; transition: background 0.5s var(--transition), color 0.5s var(--transition); }
.grace { font-family: var(--font-body); color: var(--text-primary); line-height: var(--line-height); letter-spacing: var(--letter-spacing); text-align: left; -webkit-font-smoothing: antialiased; }


/* ========================================
   LAYOUT
   ======================================== */
.grace .app { max-width: 680px; margin: 0 auto; padding: 16px 16px 100px; }

.grace .nav {
  display: flex; gap: 4px; padding: 4px;
  background: var(--bg-secondary); border-radius: var(--radius);
  margin-bottom: 24px; overflow-x: auto;
}
.grace .nav-btn {
  flex: 1; padding: 10px 12px; border: none; background: transparent;
  color: var(--text-secondary); font-family: var(--font-body);
  font-size: calc(0.85 * var(--gfs, 18px)); font-weight: 500; border-radius: 10px;
  cursor: pointer; transition: all 0.3s var(--transition); white-space: nowrap;
}
.grace .nav-btn.active { background: var(--bg-card); color: var(--accent); box-shadow: var(--shadow); }
.grace .nav-btn:hover:not(.active) { color: var(--text-primary); }

.grace .view { display: none; }
.grace .view.active { display: block; animation: fadeIn 0.3s var(--transition); }

/* ========================================
   STATS BAR
   ======================================== */
.grace .stats-bar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 16px; background: var(--bg-card);
  border-radius: var(--radius); margin-bottom: 20px;
  box-shadow: var(--shadow); font-size: calc(0.8 * var(--gfs, 18px));
}
.grace .stat { display: flex; flex-direction: column; align-items: center; }
.grace .stat-value { font-weight: 600; color: var(--accent); font-size: calc(1.1 * var(--gfs, 18px)); }
.grace .stat-label { color: var(--text-muted); font-size: calc(0.7 * var(--gfs, 18px)); }
.grace .xp-bar-wrap {
  flex: 1; height: 8px; background: var(--bg-secondary);
  border-radius: var(--radius-full); overflow: hidden;
}
.grace .xp-bar-fill {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: var(--radius-full); transition: width 0.6s var(--transition);
}
.grace .unlock-badge {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
  padding: 6px 12px; background: var(--accent-light);
  border-radius: var(--radius); font-weight: 500; color: var(--accent);
  line-height: 1.2; max-width: 170px; text-align: right;
}
.grace .unlock-badge .unlock-badge-label {
  font-size: calc(0.72 * var(--gfs, 18px)); font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.grace .unlock-badge .unlock-badge-value {
  font-size: calc(0.6 * var(--gfs, 18px)); font-weight: 500; opacity: 0.8;
  text-transform: uppercase; letter-spacing: 0.4px;
}

.grace .backup-nudge {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; margin: 0 0 14px 0;
  background: var(--accent-light); border-left: 3px solid var(--accent);
  border-radius: var(--radius); font-size: calc(0.85 * var(--gfs, 18px)); color: var(--text-primary);
}
.grace .backup-nudge-text { flex: 1; line-height: 1.4; }
.grace .backup-nudge-text strong { color: var(--accent); }
.grace .backup-nudge-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

/* ========================================
   TASK CARDS
   ======================================== */
.grace .section-label {
  font-size: calc(0.75 * var(--gfs, 18px)); font-weight: 500; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px;
  padding-left: 4px;
}

.grace .task-card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 10px; box-shadow: var(--shadow);
  border-left: 4px solid transparent; cursor: pointer;
  transition: transform 0.3s var(--transition), box-shadow 0.3s var(--transition);
  position: relative;
}
.grace .task-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.grace .task-card.active-focus {
  border-left-color: var(--accent);
  transform: scale(1.02); box-shadow: var(--shadow-lg);
}
.grace .task-card.completed {
  opacity: 0.6; border-left-color: var(--success);
}
.grace .task-card.completed .task-name { text-decoration: line-through; color: var(--text-muted); }

.grace .task-header { display: flex; align-items: center; gap: 12px; }
.grace .task-check {
  width: 26px; height: 26px; border-radius: 50%; border: 2.5px solid var(--border);
  background: transparent; cursor: pointer; transition: all 0.3s var(--transition);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.grace .task-check:hover { border-color: var(--accent); background: var(--accent-light); }
.grace .task-check.checked {
  border-color: var(--success); background: var(--success);
  animation: checkBounce 0.4s var(--transition);
}
.grace .task-check.checked::after {
  content: ''; width: 8px; height: 14px;
  border: solid white; border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) translateY(-1px);
  animation: checkDraw 0.3s ease-out;
}
.grace .task-name { font-weight: 500; font-size: calc(1 * var(--gfs, 18px)); flex: 1; }

.grace .recurring-badge {
  display: inline-block;
  font-size: calc(0.75 * var(--gfs, 18px));
  margin-left: 4px;
  padding: 1px 4px;
  border-radius: var(--radius-full);
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s var(--transition), background 0.2s var(--transition);
  vertical-align: baseline;
}
.grace .recurring-badge:hover {
  opacity: 1;
  background: var(--bg-secondary);
}
.grace .task-time {
  font-size: calc(0.75 * var(--gfs, 18px)); color: var(--text-muted);
  padding: 3px 8px; background: var(--bg-secondary);
  border-radius: var(--radius-full); white-space: nowrap;
}
.grace .task-goal-link {
  font-size: calc(0.7 * var(--gfs, 18px)); color: var(--accent); margin-top: 6px;
  padding-left: 38px; font-style: italic;
}

/* Micro-steps accordion */
.grace .micro-steps { padding-left: 38px; margin-top: 10px; }
.grace .micro-step {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; font-size: calc(0.88 * var(--gfs, 18px));
  border-bottom: 1px solid var(--border);
  transition: all 0.3s var(--transition);
}
.grace .micro-step:last-child { border-bottom: none; }
.grace .micro-step.completed .step-text { color: var(--text-muted); text-decoration: line-through; }
.grace .step-check {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border); background: transparent;
  cursor: pointer; transition: all 0.2s var(--transition);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.grace .step-check:hover { border-color: var(--accent); }
.grace .step-check.checked { border-color: var(--success); background: var(--success); }
.grace .step-check.checked::after {
  content: ''; width: 6px; height: 10px;
  border: solid white; border-width: 0 2px 2px 0;
  transform: rotate(45deg) translateY(-1px);
}
.grace .step-text { flex: 1; color: var(--text-secondary); }
.grace .step-progress {
  display: flex; gap: 4px; margin-bottom: 8px;
}
.grace .step-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border); transition: background 0.3s var(--transition);
}
.grace .step-dot.filled { background: var(--success); }
.grace .add-step-btn {
  border: none; background: transparent; color: var(--text-muted);
  font-size: calc(0.8 * var(--gfs, 18px)); cursor: pointer; padding: 6px 0;
  font-family: var(--font-body);
}
.grace .add-step-btn:hover { color: var(--accent); }


/* ========================================
   TIME LANDSCAPE
   ======================================== */
.grace .time-landscape {
  padding: 14px 18px; background: var(--bg-card);
  border-radius: var(--radius); margin-top: 16px;
  box-shadow: var(--shadow);
}
.grace .time-landscape-label { font-size: calc(0.7 * var(--gfs, 18px)); color: var(--text-muted); margin-bottom: 8px; }
.grace .time-track {
  height: 32px; background: var(--bg-secondary);
  border-radius: var(--radius-sm); position: relative; overflow: hidden;
}
.grace .time-elapsed {
  position: absolute; right: 0; top: 0; height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: var(--radius-sm);
  opacity: 0.35;
}
.grace .time-block {
  position: absolute; top: 2px; bottom: 2px;
  background: var(--accent); border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(0.6 * var(--gfs, 18px)); color: white; font-weight: 500;
  padding: 0 4px; overflow: hidden; white-space: nowrap;
}
.grace .time-now {
  position: absolute; top: 0; bottom: 0; width: 3px;
  background: var(--accent); border-radius: 2px; z-index: 2;
  box-shadow: 0 0 6px var(--accent);
}
.grace .time-remaining { font-size: calc(0.75 * var(--gfs, 18px)); color: var(--text-secondary); margin-top: 6px; text-align: right; }

/* ========================================
   BUTTONS
   ======================================== */
.grace .btn {
  padding: 10px 20px; border: none; border-radius: var(--radius-full);
  font-family: var(--font-body); font-size: calc(0.88 * var(--gfs, 18px)); font-weight: 500;
  cursor: pointer; transition: all 0.3s var(--transition);
  display: inline-flex; align-items: center; gap: 6px;
}
.grace .btn-primary { background: var(--accent); color: white; }
.grace .btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.grace .btn-secondary { background: var(--bg-secondary); color: var(--text-secondary); }
.grace .btn-secondary:hover { background: var(--border); }
.grace .btn-ghost { background: transparent; color: var(--text-secondary); }
.grace .btn-ghost:hover { color: var(--accent); }
.grace .btn-sm { padding: 6px 14px; font-size: calc(0.8 * var(--gfs, 18px)); }

/* ========================================
   FAB (Brain Dump Button)
   ======================================== */
.grace .fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 100;
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--accent); color: white; border: none;
  font-size: 28px; cursor: pointer; box-shadow: var(--shadow-lg);
  transition: all 0.3s var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.grace .fab:hover { transform: scale(1.08) translateY(-2px); background: var(--accent-hover); }
.grace .fab:active { transform: scale(0.96); }

/* ========================================
   OVERLAYS
   ======================================== */
.grace .overlay {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg-overlay); display: none;
  align-items: flex-end; justify-content: center;
  animation: fadeIn 0.2s ease-out;
}
.grace .overlay.show { display: flex; }
.grace .overlay-panel {
  background: var(--bg-primary); width: 100%; max-width: 680px;
  max-height: 90vh; border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px; overflow-y: auto;
  animation: slideUp 0.3s var(--transition);
}
.grace .overlay-full {
  align-items: stretch; justify-content: center;
}
.grace .overlay-full .overlay-panel {
  max-height: 100vh; border-radius: 0; height: 100%;
  display: flex; flex-direction: column;
}

.grace .capture-input {
  width: 100%; padding: 16px; border: 2px solid var(--border);
  border-radius: var(--radius); font-family: var(--font-body);
  font-size: calc(1.1 * var(--gfs, 18px)); background: var(--bg-card); color: var(--text-primary);
  outline: none; transition: border-color 0.3s var(--transition);
  resize: none; min-height: 100px;
}
.grace .capture-input:focus { border-color: var(--accent); }
.grace .capture-input::placeholder { color: var(--text-muted); }


/* ========================================
   GOALS VIEW
   ======================================== */
.grace .goal-card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 18px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.grace .goal-name { font-weight: 600; font-size: calc(1.05 * var(--gfs, 18px)); margin-bottom: 8px; }
.grace .goal-progress-bar {
  height: 8px; background: var(--bg-secondary);
  border-radius: var(--radius-full); overflow: hidden; margin-bottom: 10px;
}
.grace .goal-progress-fill {
  height: 100%; border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: width 0.6s var(--transition);
}
.grace .milestone {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; font-size: calc(0.88 * var(--gfs, 18px));
}
.grace .milestone-marker {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border); flex-shrink: 0;
  transition: all 0.3s var(--transition);
}
.grace .milestone.done .milestone-marker { background: var(--success); border-color: var(--success); }
.grace .milestone.done .milestone-text { color: var(--text-muted); text-decoration: line-through; }

.grace .goal-card.goal-complete {
  border: 2px solid var(--success);
  background: linear-gradient(135deg, var(--bg-card), var(--success-light));
  position: relative; overflow: hidden;
}
.grace .goal-card.goal-complete::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 40%, var(--success-light) 100%);
  pointer-events: none;
}
.grace .goal-card.goal-complete .goal-name {
  color: var(--success);
}
.grace .goal-complete-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; background: var(--success);
  color: white; border-radius: var(--radius-full);
  font-size: calc(0.8 * var(--gfs, 18px)); font-weight: 600; margin-top: 10px;
  animation: goalBadgeIn 0.6s var(--transition);
}
@keyframes goalBadgeIn {
  0% { transform: scale(0) rotate(-10deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(2deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes goalGlow {
  0%, 100% { box-shadow: var(--shadow), 0 0 0 0 var(--success); }
  50% { box-shadow: var(--shadow), 0 0 20px 4px var(--success-light); }
}
.grace .goal-card.goal-celebrating {
  animation: goalGlow 1.5s ease-in-out 3;
}

/* ========================================
   SETTINGS
   ======================================== */
.grace .setting-group {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 18px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.grace .setting-group-title {
  font-weight: 600; font-size: calc(0.9 * var(--gfs, 18px)); margin-bottom: 12px;
  color: var(--accent);
}
.grace .setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.grace .setting-row:last-child { border-bottom: none; }
.grace .setting-label { font-size: calc(0.88 * var(--gfs, 18px)); }
.grace .setting-hint { font-size: calc(0.72 * var(--gfs, 18px)); color: var(--text-muted); }

.grace select,
.grace input[type="range"] {
  font-family: var(--font-body); font-size: calc(0.85 * var(--gfs, 18px));
  padding: 6px 10px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg-secondary);
  color: var(--text-primary); outline: none;
}
.grace input[type="range"] {
  accent-color: var(--accent);
  -webkit-appearance: none; appearance: none;
  height: 6px; padding: 0; border: none;
  border-radius: var(--radius-full);
  background: var(--border);
}
.grace input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: var(--radius-full);
  background: var(--border);
}
.grace input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  margin-top: -6px; cursor: pointer;
}
.grace input[type="range"]::-moz-range-track {
  height: 6px; border-radius: var(--radius-full);
  background: var(--border); border: none;
}
.grace input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
}
.grace input[type="range"]::-moz-range-progress {
  height: 6px; border-radius: var(--radius-full);
  background: var(--accent);
}
.grace select:focus,
.grace input:focus { border-color: var(--accent); }

.grace .toggle {
  width: 48px; height: 26px; border-radius: var(--radius-full);
  background: var(--border); border: none; cursor: pointer;
  position: relative; transition: background 0.3s var(--transition);
}
.grace .toggle.on { background: var(--accent); }
.grace .toggle::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 20px; height: 20px; border-radius: 50%;
  background: white; transition: transform 0.3s var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.grace .toggle.on::after { transform: translateX(22px); }

/* ========================================
   EMPTY STATES
   ======================================== */
.grace .empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-muted); font-size: calc(0.9 * var(--gfs, 18px));
}
.grace .empty-state-icon { font-size: calc(2.5 * var(--gfs, 18px)); margin-bottom: 12px; }

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes checkBounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
@keyframes checkDraw {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}
@keyframes cardComplete {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 0.6; }
}
@keyframes xpPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
@keyframes gentlePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
@keyframes welcomeSlide {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.grace .anim-card-complete { animation: cardComplete 0.5s var(--transition) forwards; }
.grace .anim-xp-pulse { animation: xpPulse 0.4s var(--transition); }
.grace .anim-welcome { animation: welcomeSlide 0.5s var(--transition); }

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}
@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ========================================
   COMPLETION ANIMATION STYLES (16 total)
   ======================================== */
/* 1. checkDraw — already defined above */
/* 2. colorWash */
@keyframes colorWash {
  0% { background-position: -100% 0; }
  100% { background-position: 100% 0; }
}
/* 3. glowPulse */
@keyframes glowPulse {
  0% { box-shadow: 0 0 0 0 var(--success); }
  50% { box-shadow: 0 0 16px 6px var(--success-light); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
/* 4. scalePop */
@keyframes scalePop {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  70% { transform: scale(0.98); }
  100% { transform: scale(1); }
}
/* 5. confettiBurst — CSS dots */
@keyframes dotScatter1 { 0%{transform:translate(0) scale(1);opacity:1}100%{transform:translate(20px,-30px) scale(0);opacity:0} }
@keyframes dotScatter2 { 0%{transform:translate(0) scale(1);opacity:1}100%{transform:translate(-15px,-25px) scale(0);opacity:0} }
@keyframes dotScatter3 { 0%{transform:translate(0) scale(1);opacity:1}100%{transform:translate(25px,10px) scale(0);opacity:0} }
@keyframes dotScatter4 { 0%{transform:translate(0) scale(1);opacity:1}100%{transform:translate(-20px,15px) scale(0);opacity:0} }
/* 6. stamp */
@keyframes stampIn {
  0% { transform: scale(3) rotate(-15deg); opacity: 0; }
  60% { transform: scale(0.9) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
/* 7. ripple */
@keyframes rippleOut {
  0% { transform: scale(0.5); opacity: 0.6; border-width: 3px; }
  100% { transform: scale(2.5); opacity: 0; border-width: 1px; }
}
/* 8. slideAway → REPLACED with glow wave (non-removal) */
@keyframes glowWave {
  0%   { box-shadow: inset 0 0 0 0 var(--success-light); }
  40%  { box-shadow: inset 200px 0 60px -20px var(--success-light); }
  100% { box-shadow: inset 0 0 0 0 var(--success-light); }
}
/* 9. dissolve → REPLACED with sparkle pulse (non-removal) */
@keyframes sparklePulse {
  0%   { box-shadow: 0 0 0 0 var(--success); }
  50%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
/* 10. shimmer (kept, slightly enhanced) */
@keyframes shimmerSweep {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
/* 11. fold → REPLACED with lift & settle (non-removal) */
@keyframes liftSettle {
  0%   { transform: translateY(0) scale(1); }
  35%  { transform: translateY(-4px) scale(1.015); }
  100% { transform: translateY(0) scale(1); }
}
/* 12. inkSpread → REPLACED with color bloom (non-removal, working gradient) */
@keyframes colorBloom {
  0%   { background-size: 0% 100%; }
  100% { background-size: 100% 100%; }
}
/* 13. bounceChain — applied per step with delay */
@keyframes bounceStep {
  0% { transform: translateY(0); }
  30% { transform: translateY(-8px); }
  50% { transform: translateY(0); }
  70% { transform: translateY(-3px); }
  100% { transform: translateY(0); }
}
/* 14. sparkleTrail */
@keyframes sparkleMove {
  0% { offset-distance: 0%; opacity: 1; }
  80% { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}
/* 15. aurora */
@keyframes auroraShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
/* 16. gravityDrop → REPLACED with weighted bounce (non-removal) */
@keyframes weightedBounce {
  0%   { transform: translateY(0); }
  30%  { transform: translateY(6px); }
  60%  { transform: translateY(-2px); }
  100% { transform: translateY(0); }
}

/* Unlock gallery */
.grace .unlock-tabs { display:flex;gap:2px;margin-bottom:12px;overflow-x:auto; }
.grace .unlock-tab {
  padding:6px 12px;border:none;background:var(--bg-secondary);color:var(--text-secondary);
  font-family:var(--font-body);font-size:calc(0.75 * var(--gfs, 18px));border-radius:var(--radius-sm);cursor:pointer;white-space:nowrap;
}
.grace .unlock-tab.active { background:var(--accent);color:white; }
.grace .unlock-grid { display:grid;grid-template-columns:repeat(3,1fr);gap:8px; }
.grace .unlock-item {
  padding:10px 8px;border-radius:var(--radius-sm);border:2px solid var(--border);
  text-align:center;font-size:calc(0.72 * var(--gfs, 18px));cursor:pointer;transition:all 0.3s var(--transition);
  position:relative;min-height:54px;display:flex;flex-direction:column;align-items:center;justify-content:center;
}
.grace .unlock-item.active { border-color:var(--accent);background:var(--accent-light); }
.grace .unlock-item.locked { opacity:0.35;cursor:default; }
.grace .unlock-item .unlock-name { font-weight:500;margin-top:2px; }
.grace .unlock-item .unlock-day { font-size:calc(0.6 * var(--gfs, 18px));color:var(--text-muted); }

@media (prefers-reduced-motion: reduce) {
  .grace,
.grace *,
.grace *::before,
.grace *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Manual reduced-motion toggle — independent of OS preference.
   Research: ADHD users often want situational control (migraine days,
   meltdown days) without changing their whole OS setting. */
body.grace-reduced-motion .grace *,
body.grace-reduced-motion .grace *::before,
body.grace-reduced-motion .grace *::after {
  animation-duration: 0.01ms !important;
  transition-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
}

/* ========================================
   HELP TAB
   ======================================== */
.grace .help-intro {
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: calc(0.88 * var(--gfs, 18px));
  line-height: 1.55;
}
.grace .help-intro strong { color: var(--accent); }

.grace .help-section-title {
  font-size: calc(0.72 * var(--gfs, 18px));
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin: 22px 0 10px 4px;
}

.grace .help-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow 0.3s var(--transition);
}
.grace .help-card.open { box-shadow: var(--shadow-lg); }

.grace .help-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s var(--transition);
}
.grace .help-card-header:hover { background: var(--bg-secondary); }

.grace .help-card-icon {
  font-size: calc(1.25 * var(--gfs, 18px));
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}
.grace .help-card-title {
  flex: 1;
  font-weight: 500;
  font-size: calc(0.96 * var(--gfs, 18px));
  color: var(--text-primary);
}
.grace .help-card-chevron {
  font-size: calc(0.7 * var(--gfs, 18px));
  color: var(--text-muted);
  transition: transform 0.3s var(--transition);
}
.grace .help-card.open .help-card-chevron { transform: rotate(180deg); }

.grace .help-card-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s var(--transition);
}
.grace .help-card.open .help-card-body { max-height: 1200px; }

.grace .help-card-body-inner {
  padding: 0 16px 16px 56px;
  font-size: calc(0.88 * var(--gfs, 18px));
  line-height: 1.6;
}

.grace .help-block {
  margin-top: 14px;
}
.grace .help-block:first-child { margin-top: 6px; }

.grace .help-block-label {
  display: inline-block;
  font-size: calc(0.65 * var(--gfs, 18px));
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-bottom: 6px;
}
.grace .help-block-what .help-block-label {
  background: var(--accent-light);
  color: var(--accent);
}
.grace .help-block-why .help-block-label {
  background: var(--success-light);
  color: var(--success);
}
.grace .help-block-how .help-block-label {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.grace .help-block-text {
  color: var(--text-primary);
}
.grace .help-block-how .help-block-text ul {
  margin: 4px 0 0 0;
  padding-left: 18px;
}
.grace .help-block-how .help-block-text li {
  margin-bottom: 3px;
}

.grace .help-jump-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 6px 12px;
  background: var(--accent-light);
  color: var(--accent);
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-body);
  font-size: calc(0.75 * var(--gfs, 18px));
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--transition);
}
.grace .help-jump-btn:hover {
  background: var(--accent);
  color: white;
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
  @page { margin: 12mm; }
  body.grace-host { background: white; color: black; }
  body.grace-host::before { display: none !important; }
  body.grace-host > *:not(.grace-portal), body.grace-host main, .grace-portal > *:not(.print-sheet) { display: none !important; }
  body.grace-host .grace-portal { display: block !important; }
  .grace .print-sheet { display: block !important; }
}
.grace .print-sheet {
  display: none;
  font-family: var(--font-body);
  color: black;
  background: white;
  /* Base font-size is overridden inline by JS to fit one page */
  font-size: 11pt;
  line-height: 1.4;
}
.grace .print-sheet .print-header {
  border-bottom: 0.5pt solid #999;
  padding-bottom: 0.4em;
  margin-bottom: 0.8em;
}
.grace .print-sheet .print-title {
  font-size: 1.5em; font-weight: 600;
}
.grace .print-sheet .print-zone {
  margin-bottom: 1em;
  page-break-inside: avoid;
}
.grace .print-sheet .print-zone:last-child { margin-bottom: 0; }
.grace .print-sheet .print-zone-title {
  font-weight: 600;
  font-size: 1.1em;
  margin-bottom: 0.4em;
  padding-bottom: 0.15em;
  border-bottom: 0.25pt solid #ccc;
}
.grace .print-sheet .print-task {
  display: flex; align-items: flex-start; gap: 0.6em;
  margin-bottom: 0.35em;
  font-size: 1em;
  line-height: 1.35;
}
.grace .print-sheet .print-checkbox {
  width: 1.4em; height: 1.4em;
  border: 1.25pt solid #555;
  border-radius: 0.2em;
  flex-shrink: 0;
  margin-top: 0.05em;
}
.grace .print-sheet .print-substep {
  padding-left: 0.5em;
  font-size: 0.9em;
  color: #555;
  margin-bottom: 0.2em;
}
.grace .print-sheet .print-substep .print-checkbox {
  width: 1em; height: 1em;
}
.grace .print-sheet .print-goal-name {
  font-weight: 500;
}
.grace .print-sheet .print-goal-progress {
  font-size: 0.85em;
  color: #666;
  margin-left: 0.4em;
}
.grace .print-sheet .print-empty {
  color: #999;
  font-size: 0.9em;
  font-style: italic;
}
.grace .print-sheet .print-overflow {
  font-size: 0.78em;
  color: #888;
  font-style: italic;
  padding-left: 2em;
  margin-top: 0.15em;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 480px) {
  .grace .app { padding: 12px 12px 90px; }
  .grace .stats-bar { flex-wrap: wrap; gap: 10px; }
  .grace .fab { bottom: 16px; right: 16px; width: 54px; height: 54px; font-size: 24px; }
}

/* ========================================
   FOLLOW THROUGH ADHD — brand layer
   ======================================== */
/* faint paper grain, fixed behind all content */
body.grace-host::before {
  content:"";position:fixed;inset:0;pointer-events:none;z-index:0;opacity:.5;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
}
.grace .app {position:relative;z-index:1;}
/* Lora carries the editorial moments */
.grace .stat-value {font-family:var(--font-display);}
/* brand masthead */
.grace .brand-head {
  display:flex;align-items:center;justify-content:center;gap:9px;
  padding:14px 0 6px;color:var(--sage);
}
.grace .brand-head .brand-sprig {display:block;color:var(--sage);flex:none;}
.grace .brand-head .brand-word {
  font-family:var(--font-display);font-weight:500;font-size:calc(1.16 * var(--gfs, 18px));
  letter-spacing:.01em;color:var(--text-primary);
}
@media (prefers-reduced-motion:reduce) {.grace .brand-head {}}

/* ========================================
   BLOCK ADDITIONS — pieces the builder blocks add (not in the old single-page app)
   ======================================== */
.grace.grace-mount { display: block; }
.grace .grace-limit {
  font-size: calc(0.7 * var(--gfs, 18px)); font-weight: 500; background: var(--bg-secondary);
  padding: 2px 8px; border-radius: var(--radius-full); margin-left: 8px; color: var(--text-secondary);
}
.grace .grace-limit-note {
  font-size: calc(0.78 * var(--gfs, 18px)); color: var(--text-secondary); background: var(--bg-secondary);
  border-radius: var(--radius-sm); padding: 8px 12px; margin-top: 6px; line-height: 1.5;
}
.grace .grace-sync { margin-left: 6px; line-height: 1; }
/* editor canvas only: a label for blocks that draw nothing in place (the + button lives bottom-right) */
.grace .grace-editor-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-family: system-ui, sans-serif;
  color: var(--text-secondary); border: 1px dashed var(--border); border-radius: 999px; padding: 4px 10px;
}
