/* ——— The Learning Loop (js/screens/loop.js) ———
   The parent's home, in the open look both worlds share (css/open.css): calm
   white cards on the sunny sky, Fredoka, big tap targets, phone first. Charts
   use one hue each and text tokens for every word (the dataviz rules): bars in
   lilac, days practised and the meter in mint on a lighter mint track, the
   limit as a dashed orange line. Empty days are plain outlines, never red. */

.view-loop {
  --ll-surface: #fff;
  --ll-line: #ece4f3;      /* hairlines, empty dots, the grid */
  --ll-empty: #cdbfdc;     /* an empty day's outline */
  --ll-track: #d3f2e6;     /* the meter's track: a lighter step of the mint */
  --ll-fill: var(--mint-deep, #22a37f);
  --ll-bar: var(--lilac-deep, #7d58d6);
  --ll-bar-on: #5f3fb8;
  --ll-limit: var(--pink-deep, #e86a1a);
  --ll-link: #6a46c4;
  --ll-card-shadow: 0 6px 20px rgba(110, 90, 150, 0.12);
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.4;
}
.view-loop.ll-is-plan { max-width: 1040px; }
.view-loop button:not(.back-pill) { font: inherit; }

/* ——— Headings and links ——— */
.ll-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 16px;
}
.ll-top-plan { justify-content: flex-start; align-items: center; gap: 12px; }
.ll-title {
  font-size: clamp(28px, 6vw, 38px);
  font-weight: 600;
  line-height: 1.15;
  text-wrap: balance;
}
.ll-h2 { font-size: 20px; font-weight: 600; margin: 0 0 10px; }
.ll-soft { color: var(--ink-soft); }
.ll-small { font-size: 15px; }
.ll-link {
  min-height: 44px;
  padding: 8px 4px;
  border: 0;
  background: none;
  color: var(--ll-link);
  font-size: 17px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.ll-quiet { color: var(--ink-soft); font-weight: 500; font-size: 16px; align-self: flex-start; }
.ll-back {
  align-self: flex-start;
  min-height: 44px;
  padding: 8px 2px;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}
.ll-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  padding-top: 4px;
}

/* ——— Cards ——— */
.ll-card {
  background: var(--ll-surface);
  border-radius: 22px;
  padding: 16px 18px;
  box-shadow: var(--ll-card-shadow);
}
.ll-empty { margin: 0; }

/* The 10-second card per child. */
.ll-heroes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 16px;
  align-items: start;
}
.ll-hero {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  border: 0;
  padding: 18px 18px 14px;
  text-align: left;
  color: inherit;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.15s;
}
div.ll-hero { cursor: default; }
button.ll-hero:hover { box-shadow: 0 10px 26px rgba(110, 90, 150, 0.18); }
button.ll-hero:active { transform: translateY(2px); }
/* Parent first: time left, and "Hand to <name> ▶" with the plan link beside it. */
.ll-left { font-size: 16px; font-weight: 600; color: var(--ll-fill); }
.ll-left-up { color: var(--ink-soft); }
.ll-planday { font-size: 16px; }
.ll-planday b { font-weight: 600; }
.ll-planday-done { color: var(--ll-fill); font-weight: 600; }
.ll-acts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  margin-top: 4px;
}
.ll-hand, .ll-more { font-size: 19px; padding: 12px 22px; white-space: normal; line-height: 1.2; }
.ll-acts .ll-go { align-self: center; }
/* The walk-through: plans (or the PIN) to set up, at the top of the hub. */
.ll-walk {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  border: 2px solid #c9b6ef;
  background: #fbf8ff;
}
.ll-walk-icon { flex: none; font-size: 34px; line-height: 1; }
.ll-walk-text { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ll-walk-text .ll-h2, .ll-walk-text p { margin: 0; }
.ll-walk-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin-top: 6px; }
.ll-walk-go { font-size: 18px; padding: 10px 26px; }
.ll-hero-empty { cursor: default; display: flex; flex-direction: column; gap: 12px; }
.ll-hero-wrap { display: flex; flex-direction: column; gap: 8px; }
.ll-nudge {
  display: block;
  width: 100%;
  border: 2px dashed #c9b6ef;
  border-radius: 18px;
  background: #f6f0ff;
  color: #4b2c86;
  font-weight: 700;
  padding: 12px 16px;
  text-align: left;
  cursor: pointer;
}
.ll-nudge:hover { background: #efe5ff; }
.ll-hero-empty p { margin: 0; }
.ll-who { display: flex; align-items: center; gap: 12px; }
.ll-avatar {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 26px;
  line-height: 1;
  background: var(--lilac-soft);
  overflow: hidden;
}
.ll-avatar.has-look { display: block; background: radial-gradient(circle at 50% 60%, #fff 0 45%, var(--lilac-soft) 100%); }
.ll-name { font-size: 23px; font-weight: 600; }
.ll-today { font-size: 17px; }
.ll-today b { font-weight: 600; }
.ll-meter {
  display: block;
  height: 10px;
  border-radius: 999px;
  background: var(--ll-track);
  overflow: hidden;
}
.ll-meter span { display: block; height: 100%; border-radius: 999px; background: var(--ll-fill); }
.ll-moment {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.35;
}
.ll-emoji { flex: none; font-size: 22px; line-height: 1.15; }
.ll-moment-text { min-width: 0; overflow-wrap: anywhere; }
.ll-next { font-size: 16px; color: var(--ink-soft); }
.ll-next b { color: var(--ink); font-weight: 600; }
.ll-headstart {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 15px;
  font-weight: 600;
}
.ll-pips { display: flex; flex-wrap: wrap; gap: 4px; }
.ll-pips i { width: 10px; height: 10px; border-radius: 50%; background: var(--ll-line); }
.ll-pips i.on { background: var(--ll-fill); }
.ll-go { align-self: flex-end; font-size: 16px; font-weight: 600; color: var(--ll-link); }
.ll-setup { --b: #d9590c; --d: #a9440a; font-size: 18px; padding: 12px 20px; white-space: normal; text-align: center; line-height: 1.25; }

/* ——— A child's plan ——— */
.ll-top-plan .ll-avatar { width: 52px; height: 52px; font-size: 30px; }
.ll-plan { display: flex; flex-direction: column; gap: 22px; }
.ll-col { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.ll-sect { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ll-sect > .ll-h2 { margin: 0; }
.ll-sect > .ll-link { align-self: flex-start; }
@media (min-width: 880px) {
  .ll-plan { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr); gap: 28px; align-items: start; }
}

/* Moments, grouped under quiet day labels. */
.ll-feed, .ll-feed ul { list-style: none; margin: 0; padding: 0; }
.ll-feed { display: flex; flex-direction: column; gap: 12px; }
.ll-feed ul { display: flex; flex-direction: column; gap: 8px; }
.ll-feed-day { display: flex; flex-direction: column; gap: 6px; }
.ll-when { font-size: 14px; font-weight: 600; color: var(--ink-soft); letter-spacing: 0.02em; }
.ll-feed-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 16px;
  font-size: 16px;
  line-height: 1.4;
}
.ll-feed-item .ll-emoji { font-size: 20px; }
.ll-k-mastered, .ll-k-solid { box-shadow: var(--ll-card-shadow), inset 4px 0 0 var(--ll-fill); }

/* Goals: a status chip, the strand as dots, the countdown, and "What's next?". */
.ll-goal { display: flex; flex-direction: column; gap: 8px; }
.ll-goal p { margin: 0; }
.ll-goal-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }
.ll-goal-head h3 { font-size: 19px; font-weight: 600; line-height: 1.25; }
.ll-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  background: #f1ecf6;
  color: #5d4672;
}
.ll-st-practicing { background: var(--lilac-soft); color: #5a3db0; }
.ll-st-solid, .ll-st-known { background: #daf5ea; color: #17694f; }
.ll-st-mastered { background: #fff0c2; color: #7a4e00; }
.ll-st-review { background: #ffe8d4; color: #9a4208; }
.ll-help { align-self: flex-start; background: #e3f1ff; color: #1f5f99; }
.ll-ladder { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0; }
.ll-ladder i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ll-empty); background: transparent; }
.ll-ladder i.done { background: var(--ll-fill); border-color: var(--ll-fill); }
.ll-ladder i.now { border: 3px solid var(--pink); background: var(--ll-surface); box-shadow: 0 0 0 2px var(--ll-surface), 0 0 0 4px rgba(255, 138, 61, 0.25); }
.ll-ladder i.now.done { background: var(--ll-fill); }
.ll-next-btn {
  align-self: stretch;
  min-height: 48px;
  margin-top: 2px;
  padding: 10px 16px;
  border: 2px solid var(--lilac-soft);
  border-radius: 16px;
  background: #faf7ff;
  color: var(--ink);
  font-size: 16px;
  text-align: left;
  cursor: pointer;
}
.ll-next-btn b { font-weight: 600; color: #5a3db0; }
.ll-next-btn:active { transform: translateY(1px); }

/* Keep climbing / Untimed practice. */
.ll-toggles { display: flex; flex-direction: column; gap: 14px; }
.ll-toggle { display: flex; align-items: flex-start; gap: 14px; }
.ll-toggle > span { display: flex; flex-direction: column; gap: 2px; }
.ll-toggle b { font-weight: 600; }
.ll-switch {
  flex: none;
  position: relative;
  width: 56px;
  height: 34px;
  margin-top: 2px;
  border: 0;
  border-radius: 999px;
  background: #ddd3e7;
  cursor: pointer;
  transition: background 0.15s;
}
.ll-switch::after {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s;
}
.ll-switch[aria-checked='true'] { background: var(--ll-fill); }
.ll-switch[aria-checked='true']::after { transform: translateX(22px); }
/* An email change on its way: both switches wait for the server. */
.ll-switch[aria-disabled='true'] { opacity: 0.55; cursor: progress; }

/* 📬 Email updates, at the bottom of the hub: the same switches, and where
   the emails go (a long address wraps instead of widening the card). */
.ll-email { display: flex; flex-direction: column; gap: 12px; }
.ll-email > .ll-h2 { margin: 0; }
.ll-email > p { margin: 0; }
.ll-email-to { overflow-wrap: anywhere; }
.ll-email-to b { font-weight: 600; color: var(--ink); }

/* Each day: 10 / 15 / 20 / 30 minutes, then "No limit" across the bottom. */
.ll-chips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.ll-choice {
  min-height: 48px;
  border: 2px solid var(--ll-line);
  border-radius: 16px;
  background: var(--ll-surface);
  color: var(--ink);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}
.ll-choice[data-min='0'] { grid-column: 1 / -1; order: 1; }
.ll-choice[aria-pressed='true'] { border-color: var(--lilac); background: var(--lilac-soft); color: #4b2f9e; }
.ll-card > p { margin: 0; }
/* Reading aloud: Automatic / Always / Don't, side by side (js/read-aloud.js). */
.ll-chips.ll-read { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ll-read .ll-choice { padding: 6px 8px; line-height: 1.2; }

/* Minutes, last 7 days. */
.ll-chart-card { display: flex; flex-direction: column; gap: 4px; }
.ll-readout { margin: 0; font-size: 15px; font-weight: 600; min-height: 1.4em; }
.ll-chart { display: block; width: 100%; height: auto; overflow: visible; }
.ll-chart text { font-family: var(--font); fill: var(--ink-soft); font-size: 11px; font-weight: 500; }
.ll-chart .ll-tick { font-variant-numeric: tabular-nums; }
.ll-chart .ll-day.today { fill: var(--ink); font-weight: 600; }
.ll-chart .ll-grid { stroke: var(--ll-line); stroke-width: 1; }
.ll-chart .ll-base { stroke: #d9cfe3; stroke-width: 1; }
.ll-chart .ll-bar { fill: var(--ll-bar); transition: fill 0.12s; }
.ll-chart .ll-bar.on { fill: var(--ll-bar-on); }
.ll-chart .ll-hit { fill: transparent; pointer-events: all; cursor: pointer; }
.ll-chart .ll-limit { stroke: var(--ll-limit); stroke-width: 2; stroke-dasharray: 5 4; }
.ll-chart .ll-limit-label { font-weight: 600; fill: var(--ink-soft); paint-order: stroke; stroke: var(--ll-surface); stroke-width: 3px; }

/* Days practised: filled where practised, plain outlines otherwise. */
.ll-dots { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 8px; }
.ll-dots i {
  aspect-ratio: 1;
  max-width: 26px;
  width: 100%;
  justify-self: center;
  border-radius: 50%;
  border: 2px solid var(--ll-empty);
  background: transparent;
}
.ll-dots i.on { background: var(--ll-fill); border-color: var(--ll-fill); }
.ll-dots i.today { box-shadow: 0 0 0 2px var(--ll-surface), 0 0 0 4px var(--ll-line); }
.ll-dots-ends { display: flex; justify-content: space-between; margin-top: 6px; font-size: 13px; }
.ll-count { margin: 8px 0 0; font-size: 16px; }
.ll-count b { font-weight: 600; }

/* Solid and mastered, newest first. */
.ll-timeline { list-style: none; margin: 0; padding: 14px 18px; display: flex; flex-direction: column; gap: 12px; }
.ll-timeline li {
  display: grid;
  grid-template-columns: 22px 54px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  font-size: 16px;
}
.ll-timeline b { font-weight: 600; }
.ll-tl-dot { display: grid; place-items: center; align-self: center; width: 22px; height: 22px; font-size: 16px; line-height: 1; }
.ll-tl-solid .ll-tl-dot::before { content: ''; width: 12px; height: 12px; border-radius: 50%; background: var(--ll-fill); }
.ll-tl-when { font-size: 14px; font-weight: 600; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

@media (max-width: 420px) {
  .view-loop { font-size: 16px; gap: 16px; }
  .ll-card { padding: 14px 16px; }
  .ll-hero { padding: 16px 16px 12px; }
  .ll-chips { gap: 6px; }
  .ll-read .ll-choice { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  .ll-hero, .ll-switch, .ll-switch::after, .ll-chart .ll-bar { transition: none; }
}

/* "Since <name> started" (growth cards, js/growth.js) and strengths. */
.ll-growth { margin-bottom: 10px; }
.ll-growth-head { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ll-growth-lines { margin: 8px 0 0; padding-left: 20px; }
.ll-growth-lines li { margin: 4px 0; line-height: 1.45; overflow-wrap: anywhere; }
.ll-strength { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; padding: 6px 0; }
.ll-strength + .ll-strength { border-top: 1px solid rgba(0, 0, 0, 0.06); }
.ll-strength p { margin: 0; overflow-wrap: anywhere; }
