/* kPath: behavior charts
   Paper, pencil and rubber stamps: ruled writing paper for lists, the dash-dot border of the
   take-home sheet for the chart, school-bus yellow for the one action that matters on a screen,
   and stamp ink for marks. Dark mode is a chalkboard. */

:root {
  --desk: #f2f5fb;
  --paper: #ffffff;
  --ink: #1f2a44;
  --ink-soft: #56627f;
  --ink-faint: #8a94ad;
  --ink-muted: #6b7690; /* lightest text that still reads at 4.5:1 on paper */
  --rule: #c3d3f1;
  --rule-mid: #e9a3a3;
  --pen: #2448a8;
  --bus: #ffc21a;
  --bus-deep: #f0b000;
  --on-bus: #1f2a44;
  --danger: #b3261e;
  --on-danger: #ffffff;
  --focus: #1f6fd1;
  --banner: #fff4cc;

  --tone-violet: #6b3fc9;
  --tone-blue: #1f6fd1;
  --tone-green: #18865a;
  --tone-orange: #c95a0c;
  --tone-red: #c42f40;
  --tone-pink: #c8367c;
  --on-tone: #ffffff;
  --stamp-blend: multiply;

  /* Accents that themes recolour. */
  --highlight: var(--bus); /* highlighter swipe, "today" badges */
  --on-highlight: var(--on-bus);
  --goal-accent: var(--tone-orange); /* the pen loop around a chosen goal */

  --font-ui: 'Andika', ui-rounded, 'Trebuchet MS', system-ui, sans-serif;
  --font-hand: 'Schoolbell', 'Chalkboard SE', 'Comic Sans MS', cursive;

  --radius-m: 14px;
  --radius-l: 20px;
  --tabbar-h: 64px;
  --gutter: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --desk: #18221d;
    --paper: #1f2b25;
    --ink: #eaf0e8;
    --ink-soft: #b0beb4;
    --ink-faint: #7f8f85;
    --ink-muted: #8d9d93;
    --rule: #364a3f;
    --rule-mid: #7a5252;
    --pen: #a8c2ff;
    --bus: #ffcb45;
    --bus-deep: #ffd76e;
    --on-bus: #18221d;
    --danger: #ff8a80;
    --on-danger: #18221d;
    --focus: #8ab9ff;
    --banner: #3b3620;

    --tone-violet: #bba3ff;
    --tone-blue: #86b8ff;
    --tone-green: #76d6a6;
    --tone-orange: #ffab6b;
    --tone-red: #ff909b;
    --tone-pink: #ff93ca;
    --on-tone: #18221d;
    --stamp-blend: normal;
  }
}

/* Apricot: light-orange lines and edges instead of light blue, charcoal for the main buttons and
   chosen goals instead of yellow and orange. */
:root[data-theme='apricot'] {
  --desk: #fff4ea;
  --rule: #f5c8a0;
  --rule-mid: #e39e82;
  --bus: #2e3138;
  --bus-deep: #1d1f24;
  --on-bus: #ffffff;
  --highlight: #ffcf9e;
  --on-highlight: #1f2a44;
  --goal-accent: #2e3138;
  --banner: #fff0dd;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme='apricot'] {
    --desk: #1e1813;
    --paper: #28201a;
    --ink: #f3ece6;
    --ink-soft: #c9bbae;
    --ink-muted: #a8998c;
    --ink-faint: #8a7c70;
    --rule: #4d3b2e;
    --rule-mid: #8a5a45;
    --bus: #ece4dc;
    --bus-deep: #ffffff;
    --on-bus: #1e1813;
    --highlight: #b8622a;
    --on-highlight: #fff6ee;
    --goal-accent: #ece4dc;
    --banner: #3d2c1d;
  }
}

.tone-violet { --tone: var(--tone-violet); }
.tone-blue { --tone: var(--tone-blue); }
.tone-green { --tone: var(--tone-green); }
.tone-orange { --tone: var(--tone-orange); }
.tone-red { --tone: var(--tone-red); }
.tone-pink { --tone: var(--tone-pink); }

/* ------------------------------------------------------------------ base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1.0625rem;
  line-height: 1.45;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--pen);
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.muted {
  color: var(--ink-soft);
}

.icon {
  width: 22px;
  height: 22px;
  flex: none;
}

/* Primary-ruled handwriting lines: solid top and base, dashed middle. */
.ruled {
  background:
    linear-gradient(var(--rule), var(--rule)) left top / 100% 2px no-repeat,
    repeating-linear-gradient(90deg, var(--rule-mid) 0 7px, transparent 7px 13px) left 54% / 100% 2px no-repeat,
    linear-gradient(var(--rule), var(--rule)) left bottom / 100% 2px no-repeat;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* ------------------------------------------------------------------ top bar and tabs */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: calc(env(safe-area-inset-top) + 8px) var(--gutter) 8px;
  background: var(--desk);
  border-bottom: 2px solid var(--rule);
}

.brand {
  min-width: 0;
}

.class-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  min-height: 48px;
  padding: 0 4px 0 0;
  border: 0;
  background: none;
  color: var(--ink);
}

.wordmark {
  display: block;
  min-width: 0;
  padding: 7px 6px 2px;
  overflow: hidden;
  font-family: var(--font-hand);
  font-size: 1.75rem;
  line-height: 1.05;
  white-space: nowrap;
  text-overflow: ellipsis;
  background:
    linear-gradient(var(--rule), var(--rule)) left top / 100% 2px no-repeat,
    repeating-linear-gradient(90deg, var(--rule-mid) 0 7px, transparent 7px 13px) left 56% / 100% 2px no-repeat,
    linear-gradient(var(--rule), var(--rule)) left bottom / 100% 2px no-repeat;
}

.tabs {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--paper);
  border-top: 2px solid var(--rule);
}

.tabs[hidden] {
  display: none;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: var(--tabbar-h);
  color: var(--ink-soft);
  font-size: 0.8125rem;
  font-weight: 700;
  text-decoration: none;
}

.tab .icon {
  width: 26px;
  height: 26px;
}

.tab[aria-current='page'] {
  color: var(--ink);
}

/* A highlighter swipe under the current section. */
.tab[aria-current='page'] span {
  padding: 0 4px;
  background: linear-gradient(transparent 52%, var(--highlight) 52% 92%, transparent 92%);
}

/* ------------------------------------------------------------------ layout */

.view {
  display: block;
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px var(--gutter) 24px;
}

.view:focus {
  outline: none;
}

.view-title {
  margin: 10px 0 6px;
  font-family: var(--font-hand);
  font-size: 2rem;
  font-weight: 400;
  line-height: 1.1;
}

.banner {
  margin: 8px 0 12px;
  padding: 10px 14px;
  border: 2px solid var(--bus-deep);
  border-radius: 12px;
  background: var(--banner);
}

.hint {
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

/* ------------------------------------------------------------------ buttons and fields */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px 18px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
}

.btn:hover {
  background: color-mix(in srgb, var(--ink) 6%, var(--paper));
}

.btn-primary {
  background: var(--bus);
  color: var(--on-bus);
  box-shadow: 0 3px 0 var(--ink);
}

.btn-primary:hover {
  background: var(--bus-deep);
}

.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.btn-danger {
  border-color: var(--danger);
  color: var(--danger);
}

.sheet .btn-danger {
  background: var(--danger);
  color: var(--on-danger);
}

.btn-small {
  min-height: 40px;
  padding: 6px 12px;
  font-size: 0.9375rem;
}

.btn-large {
  min-height: 54px;
  padding: 10px 28px;
  font-size: 1.125rem;
}

.btn-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--pen);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-quiet:hover {
  background: color-mix(in srgb, var(--pen) 8%, transparent);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.icon-btn {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
}

.icon-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

.icon-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 40px;
  padding: 4px 6px;
  border: 0;
  background: none;
  color: var(--pen);
  font-size: 0.875rem;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

.count {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--pen);
  color: var(--paper);
  font-size: 0.75rem;
  line-height: 20px;
  text-align: center;
}

input:not([type='checkbox']):not([type='radio']):not([type='file']),
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 9px 12px;
  border: 2px solid var(--rule);
  border-radius: 10px;
  background: var(--paper);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--ink-soft);
}

textarea {
  resize: vertical;
  color: var(--pen);
  font-family: var(--font-hand);
  font-size: 1.25rem;
  line-height: 1.3;
}

::placeholder {
  color: var(--ink-faint);
  opacity: 1;
}

[aria-invalid='true'] {
  border-color: var(--danger) !important;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
  font-size: 0.9375rem;
  font-weight: 700;
}

.field input,
.field textarea,
.field select {
  font-weight: 400;
}

fieldset.field {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 8px;
  padding: 0;
  font-weight: 700;
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.875rem;
  font-weight: 700;
}

.field-grid {
  display: grid;
  gap: 14px;
}

/* ------------------------------------------------------------------ stamps */

.stamp {
  color: var(--tone);
}

.stamp-slot {
  --size: 58px;
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: var(--size);
  height: var(--size);
  padding: 0;
  border: 2px solid var(--ink-soft);
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
}

button.stamp-slot:hover:not(:disabled) {
  border-color: var(--ink);
}

.stamp-slot:disabled {
  border-style: dashed;
  cursor: default;
}

.stamp-slot .stamp,
.mini-slot .stamp {
  position: absolute;
  inset: -9%;
  width: 118%;
  height: 118%;
  opacity: 0.95;
  mix-blend-mode: var(--stamp-blend);
  transform: rotate(var(--rot, 0deg));
}

.stamp-slot.is-big {
  --size: 96px;
}

.stamp-slot.is-small {
  --size: 40px;
}

.absent-word {
  color: var(--pen);
  font-family: var(--font-hand);
  font-size: 0.95rem;
  transform: rotate(-10deg);
}

.is-big .absent-word {
  font-size: 1.45rem;
}

/* The one bit of theatre: a stamp pressed onto the page. */
.stamp-in {
  animation: slot-thud 300ms ease-out;
}

.stamp-in .stamp {
  animation: stamp-press 300ms cubic-bezier(0.2, 0.9, 0.25, 1.15) both;
}

@keyframes stamp-press {
  0% {
    opacity: 0;
    transform: rotate(var(--rot, 0deg)) scale(1.7);
  }
  55% {
    opacity: 1;
  }
  100% {
    opacity: 0.95;
    transform: rotate(var(--rot, 0deg)) scale(1);
  }
}

@keyframes slot-thud {
  0%,
  50% {
    transform: scale(1);
  }
  72% {
    transform: scale(0.93);
  }
  100% {
    transform: scale(1);
  }
}

/* ------------------------------------------------------------------ week and day navigation */

.week-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  margin: 4px 0 10px -10px;
}

.week-label {
  margin: 0 4px;
}

.week-label strong {
  color: var(--pen);
  font-family: var(--font-hand);
  font-size: 1.55rem;
  font-weight: 400;
}

.day-chips {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 0 0 14px;
}

.day-chip {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 58px;
  padding: 7px 2px 6px;
  border: 2px solid var(--rule);
  border-radius: var(--radius-m);
  background: var(--paper);
  color: var(--ink-soft);
}

.day-chip-name {
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.1;
}

.day-chip-date {
  color: var(--ink);
  font-family: var(--font-hand);
  font-size: 1.5rem;
  line-height: 1;
}

.day-chip-today {
  position: absolute;
  top: -10px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--highlight);
  color: var(--on-highlight);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 18px;
}

.day-chip.is-done::after {
  content: '';
  position: absolute;
  top: 7px;
  right: 7px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--tone-green);
}

.day-chip.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.day-chip.is-active .day-chip-date {
  color: var(--paper);
}

.day-chip.is-active.is-done::after {
  background: var(--highlight);
}

.today-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

.progress {
  flex: 1;
  min-width: 0;
}

.progress p {
  margin: 0 0 5px;
}

.progress-rule {
  max-width: 320px;
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: var(--rule);
}

.progress-rule span {
  display: block;
  height: 100%;
  background: var(--tone-green);
  transition: width 0.3s ease;
}

.all-done {
  margin: 0;
  color: var(--tone-green);
  font-family: var(--font-hand);
  font-size: 1.35rem;
  line-height: 1.1;
}

/* ------------------------------------------------------------------ Today: the class on ruled paper */

.roster,
.send-list {
  margin: 0 calc(var(--gutter) * -1);
  padding: 0;
  list-style: none;
  background: var(--paper);
  border-top: 2px solid var(--rule);
}

.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  padding: 12px var(--gutter) 14px;
  border-bottom: 2px solid var(--rule);
}

.row-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
}

.name-link {
  flex: 1;
  min-width: 0;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: var(--font-hand);
  font-size: 1.45rem;
  line-height: 1.1;
  text-align: left;
  overflow-wrap: anywhere;
}

.name-link:hover {
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 2px;
}

.row-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.absent-btn {
  min-height: 38px;
  padding: 4px 12px;
  border: 1.5px dashed var(--ink-faint);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.8125rem;
  font-weight: 700;
}

.absent-btn[aria-pressed='true'] {
  border-style: solid;
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.row.is-absent .name-link {
  color: var(--ink-soft);
}

.ratings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 6px;
}

.rate {
  min-height: 46px;
  padding: 6px 10px;
  border: 2px solid color-mix(in srgb, var(--tone) 50%, var(--paper));
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.15;
  hyphens: auto;
}

/* On phones, an odd last choice takes the whole row instead of sitting alone in half of it. */
.rate:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.rate:hover {
  background: color-mix(in srgb, var(--tone) 9%, var(--paper));
}

.rate[aria-pressed='true'] {
  border-color: var(--tone);
  background: var(--tone);
  color: var(--on-tone);
}

.row-extra {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.goal-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.goal-chip {
  min-height: 38px;
  padding: 5px 12px;
  border: 1.5px solid var(--rule);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-muted);
  font-size: 0.9375rem;
}

.goal-chip:hover {
  color: var(--ink);
}

/* Same look as a chosen goal on the chart: dark bold text inside an orange pen loop. */
.goal-chip[aria-pressed='true'] {
  border-color: var(--goal-accent);
  box-shadow: inset 0 0 0 1.5px var(--goal-accent);
  background: color-mix(in srgb, var(--goal-accent) 12%, var(--paper));
  color: var(--ink);
  font-weight: 700;
}

.note-field textarea {
  min-height: 52px;
}

/* ------------------------------------------------------------------ Charts: the take-home sheet */

.student-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 12px -10px;
}

.student-pick {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.student-pick select {
  padding-right: 40px;
  font-family: var(--font-hand);
  font-size: 1.5rem;
  appearance: none;
}

.student-pick .icon {
  position: absolute;
  top: 50%;
  right: 12px;
  translate: 0 -50%;
  pointer-events: none;
}

.paper-chart {
  --frame: var(--ink);
  --dash-h: repeating-linear-gradient(90deg, var(--frame) 0 22px, transparent 22px 30px, var(--frame) 30px 35px, transparent 35px 43px);
  --dash-v: repeating-linear-gradient(180deg, var(--frame) 0 22px, transparent 22px 30px, var(--frame) 30px 35px, transparent 35px 43px);
  position: relative;
  margin: 0 calc(var(--gutter) * -1);
  padding: 26px 22px 22px;
  background:
    var(--dash-h) left 9px top 9px / calc(100% - 18px) 4px no-repeat,
    var(--dash-h) left 9px bottom 9px / calc(100% - 18px) 4px no-repeat,
    var(--dash-v) left 9px top 9px / 4px calc(100% - 18px) no-repeat,
    var(--dash-v) right 9px top 9px / 4px calc(100% - 18px) no-repeat,
    var(--paper);
}

.paper-head {
  margin-bottom: 16px;
  text-align: center;
}

.paper-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 400;
  line-height: 1.6;
}

.fill-in {
  padding: 0 8px;
  border-bottom: 2px solid var(--ink);
  color: var(--pen);
  font-family: var(--font-hand);
  font-size: 1.15em;
  white-space: nowrap;
}

.paper-name {
  margin: 6px 0 0;
  font-size: 1.125rem;
}

.paper-name .fill-in {
  font-size: 1.5rem;
}

.paper-days {
  display: grid;
  border: 2.5px solid var(--ink);
}

.paper-day {
  display: grid;
  grid-template-areas:
    'name name'
    'stamp body';
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0 14px;
  padding: 0 12px 14px;
  border-top: 2.5px solid var(--ink);
}

.paper-day:first-child {
  border-top: 0;
}

.paper-day-name {
  display: flex;
  grid-area: name;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 -12px 12px;
  padding: 8px 12px;
  border-bottom: 2px solid var(--rule);
  font-size: 1.125rem;
}

.paper-day-name span {
  color: var(--ink-soft);
  font-size: 0.875rem;
  font-weight: 400;
}

.paper-day.is-today .paper-day-name {
  background: color-mix(in srgb, var(--highlight) 30%, var(--paper));
}

.paper-day-stamp {
  grid-area: stamp;
}

.paper-day-body {
  display: grid;
  grid-area: body;
  align-content: start;
  gap: 8px;
  min-width: 0;
}

.check-list {
  display: grid;
  gap: 2px;
}

.check-opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 40px;
  padding: 7px 6px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--ink);
  line-height: 1.2;
  text-align: left;
}

.check-opt .box {
  position: relative;
  flex: none;
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--ink);
  border-radius: 2px;
}

.check-opt[aria-pressed='true'] {
  font-weight: 700;
}

/* A pen check that overshoots the box, as it would on paper. */
.check-opt[aria-pressed='true'] .box::after {
  content: '';
  position: absolute;
  top: -12px;
  left: -2px;
  width: 30px;
  height: 30px;
  background: var(--tone);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath d='M3 18 Q8 21 10 28 Q16 12 28 3' fill='none' stroke='black' stroke-width='4.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath d='M3 18 Q8 21 10 28 Q16 12 28 3' fill='none' stroke='black' stroke-width='4.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

.check-opt:hover:not(:disabled) {
  background: color-mix(in srgb, var(--tone) 9%, transparent);
}

.check-opt:disabled,
.goal-opt:disabled {
  opacity: 0.4;
  cursor: default;
}

.goal-list {
  display: grid;
  justify-items: start;
  gap: 2px;
}

.goal-opt {
  min-height: 36px;
  padding: 4px 10px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: none;
  color: var(--ink-muted);
  font-size: 0.9375rem;
  line-height: 1.2;
  text-align: left;
}

.goal-opt::before {
  content: '-';
}

.goal-opt:hover:not(:disabled) {
  color: var(--ink);
}

.goal-opt[aria-pressed='true'] {
  border-color: var(--goal-accent);
  background: color-mix(in srgb, var(--goal-accent) 12%, var(--paper));
  color: var(--ink);
  font-weight: 700;
}

.comments-label {
  margin: 4px 0 0;
}

.paper-note {
  min-height: 56px;
}

.paper-day .absent-btn {
  justify-self: start;
}

.family-note {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  font-weight: 700;
}

.chart-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

/* ------------------------------------------------------------------ Send home */

.send-intro p {
  max-width: 64ch;
  margin: 0 0 14px;
  color: var(--ink-soft);
}

.send-list {
  margin-top: 16px;
}

.send-row {
  display: grid;
  gap: 8px;
  padding: 12px var(--gutter);
  border-bottom: 2px solid var(--rule);
}

.send-who {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.send-emails {
  color: var(--ink-soft);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.mini-week {
  display: flex;
  gap: 6px;
}

.mini-slot {
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1.5px solid var(--ink-faint);
  border-radius: 50%;
}

.mini-absent {
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 700;
}

.send-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.sent-badge {
  margin-right: auto;
  color: var(--tone-green);
  font-family: var(--font-hand);
  font-size: 1.2rem;
  line-height: 1;
}

.send-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.send-footer p {
  margin: 0;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------------ Class */

.panel {
  margin: 0 0 16px;
  padding: 18px 16px;
  border: 2px solid var(--rule);
  border-radius: var(--radius-l);
  background: var(--paper);
}

.panel h3 {
  margin: 0 0 10px;
  font-family: var(--font-hand);
  font-size: 1.65rem;
  font-weight: 400;
  line-height: 1.1;
}

.panel h3 .muted {
  font-family: var(--font-ui);
  font-size: 1rem;
}

.panel h4 {
  margin: 20px 0 4px;
  font-size: 1rem;
}

.panel p {
  max-width: 65ch;
  margin: 0 0 12px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.student-list {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.student-item {
  display: grid;
  grid-template-areas:
    'name remove'
    'email email'
    'error error';
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 6px;
  padding: 10px 0;
  border-bottom: 2px solid var(--rule);
}

.student-item > :nth-child(1) {
  grid-area: name;
}

.student-item > :nth-child(1) input {
  font-family: var(--font-hand);
  font-size: 1.3rem;
}

.student-item > :nth-child(2) {
  grid-area: email;
}

.student-item > :nth-child(3) {
  grid-area: remove;
}

.student-item > .field-error {
  grid-area: error;
}

.add-students summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--pen);
  font-weight: 700;
  cursor: pointer;
}

.add-students[open] {
  display: grid;
  gap: 10px;
}

.add-students[open] > .btn {
  justify-self: start;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.template-item {
  position: relative;
  display: grid;
}

.template-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 36px;
  height: 36px;
  color: var(--ink-soft);
}

.template-delete .icon {
  width: 18px;
  height: 18px;
}

.template-item:has(.template-delete) .template-card {
  padding-right: 42px;
}

.template-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 2px solid var(--rule);
  border-radius: var(--radius-m);
  background: var(--paper);
  font-weight: 400;
  cursor: pointer;
}

.template-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.template-card:has(input:checked) {
  border-color: var(--ink);
  box-shadow: 0 3px 0 var(--ink);
}

.template-card:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.template-mini {
  display: grid;
  flex: none;
  justify-items: start;
  gap: 4px;
  width: 54px;
  padding: 6px;
  border: 1.5px solid var(--ink-soft);
  border-radius: 3px;
  background: var(--paper);
}

.template-new {
  width: 100%;
  border-style: dashed;
  color: var(--ink);
  text-align: left;
}

.template-new:hover {
  border-color: var(--ink-soft);
}

.template-mini-new {
  align-content: center;
  justify-items: center;
  min-height: 74px;
  border-style: dashed;
  color: var(--ink-soft);
  font-size: 1.6rem;
  line-height: 1;
}

.template-mini i {
  display: block;
}

.mini-circle {
  justify-self: center;
  width: 22px;
  height: 22px;
  margin-bottom: 2px;
  border: 1.5px solid var(--ink-soft);
  border-radius: 50%;
}

.mini-box {
  width: 100%;
  height: 6px;
  background: linear-gradient(90deg, var(--ink-soft) 0 6px, transparent 6px 9px, var(--rule) 9px);
}

.mini-dash {
  width: 78%;
  height: 3px;
  background: var(--rule);
}

.mini-line {
  width: 100%;
  height: 2px;
  background: var(--rule);
}

.template-text {
  display: grid;
  gap: 2px;
}

.template-name {
  font-weight: 700;
}

.template-desc {
  color: var(--ink-soft);
  font-size: 0.875rem;
  line-height: 1.3;
}

.style-name {
  max-width: 420px;
  margin: 18px 0 0;
}

.theme-field {
  margin-top: 16px;
}

.theme-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.theme-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 16px 6px 10px;
  border: 2px solid var(--rule);
  border-radius: 999px;
  background: var(--paper);
  font-weight: 700;
  cursor: pointer;
}

.theme-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-option:has(input:checked) {
  border-color: var(--ink);
  box-shadow: 0 3px 0 var(--ink);
}

.theme-option:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.theme-dots {
  display: flex;
}

.theme-dots i {
  width: 18px;
  height: 18px;
  margin-left: -6px;
  border: 2px solid var(--paper);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.12);
}

.theme-dots i:first-child {
  margin-left: 0;
}

.choice-list,
.goal-edit-list {
  display: grid;
  gap: 8px;
  margin: 8px 0 10px;
  padding: 0;
  list-style: none;
}

.choice-row,
.goal-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.choice-row .field,
.goal-row .field {
  flex: 1;
}

.toggles {
  display: grid;
  gap: 6px;
  margin: 18px 0;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  font-weight: 700;
  cursor: pointer;
}

.toggle input {
  flex: none;
  width: 22px;
  height: 22px;
  accent-color: var(--ink);
}

/* ------------------------------------------------------------------ Welcome and empty states */

.welcome {
  max-width: 780px;
  margin: 0 auto;
}

.welcome-title {
  margin: 18px 0 14px;
  font-family: var(--font-hand);
  font-size: clamp(2.3rem, 8vw, 3.6rem);
  font-weight: 400;
  line-height: 1.5;
}

.welcome-title span {
  padding: 6px 4px 0;
}

.hero-stamps {
  display: flex;
  gap: 4px;
  margin: 0 0 6px;
}

.hero-stamps .stamp {
  width: 46px;
  height: 46px;
  mix-blend-mode: var(--stamp-blend);
  transform: rotate(var(--rot));
}

.lede {
  max-width: 52ch;
  margin: 0 0 20px;
  color: var(--ink-soft);
  font-size: 1.15rem;
}

.welcome-form {
  display: grid;
  gap: 18px;
}

.welcome-form > .btn {
  justify-self: start;
}

.or {
  color: var(--ink-soft);
  text-align: center;
}

.empty {
  padding: 40px 0;
  text-align: center;
}

.empty p {
  margin: 0 auto 20px;
  max-width: 42ch;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------------ sheets and toasts */

.sheet {
  width: min(520px, calc(100vw - 32px));
  max-height: 86dvh;
  padding: 0;
  border: 0;
  border-radius: var(--radius-l);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 0 0 2px var(--ink), 0 6px 0 2px var(--ink);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.sheet.is-wide {
  width: min(860px, calc(100vw - 32px));
}

.sheet::backdrop {
  background: rgb(15 20 35 / 0.45);
}

.sheet-body {
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
}

.sheet-title {
  margin: 0;
  font-family: var(--font-hand);
  font-size: 1.85rem;
  font-weight: 400;
  line-height: 1.15;
}

.sheet-sub {
  margin: 2px 0 14px;
  color: var(--ink-soft);
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* "New chart style": settings and editor on the left, a preview of one day on the right. */
.style-builder {
  display: grid;
  gap: 16px;
  margin-top: 8px;
}

.style-builder .sheet-actions {
  position: sticky;
  bottom: 0;
  margin: 0;
  padding: 12px 0;
  border-top: 2px solid var(--rule);
  background: var(--paper);
}

.preview-label {
  margin: 0 0 6px;
  color: var(--ink-soft);
  font-size: 0.8125rem;
  font-weight: 700;
}

.preview-day {
  border: 2.5px solid var(--ink);
  background: var(--paper);
  font-size: 0.8125rem;
  line-height: 1.25;
}

.preview-day-name {
  padding: 5px;
  border-bottom: 2px solid var(--ink);
  font-weight: 700;
  text-align: center;
}

.preview-stamp {
  display: grid;
  place-items: center;
  padding: 10px 0;
  border-bottom: 2px solid var(--ink);
}

.preview-circle {
  width: 46px;
  height: 46px;
  border: 2px solid var(--ink-soft);
  border-radius: 50%;
}

.preview-body {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 70px;
  padding: 10px;
}

.preview-body ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.preview-check {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.preview-check .box {
  flex: none;
  width: 12px;
  height: 12px;
  margin-top: 2px;
  border: 2px solid var(--ink);
}

.preview-goal,
.preview-empty {
  color: var(--ink-soft);
}

.preview-comments,
.preview-empty {
  margin: 0;
}

.preview-line {
  display: block;
  height: 2px;
  margin-top: 12px;
  background: var(--rule);
}

.style-editor h5 {
  margin: 16px 0 4px;
  font-size: 1rem;
}

.style-editor .toggle {
  margin-top: 12px;
}

.style-editing {
  margin-top: 8px;
}

.inline-link {
  display: inline;
  min-height: 0;
  padding: 0;
  font-size: inherit;
}

.stamp-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stamp-choice {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 12px 6px 10px;
  border: 2px solid var(--rule);
  border-radius: var(--radius-m);
  background: var(--paper);
  font-size: 0.9375rem;
  font-weight: 700;
}

.stamp-choice .stamp-slot {
  --size: 62px;
  pointer-events: none;
}

.stamp-choice:hover {
  border-color: var(--ink-soft);
}

.stamp-choice.is-current {
  border-color: var(--ink);
  box-shadow: 0 3px 0 var(--ink);
}

.fill-options {
  display: grid;
  gap: 8px;
}

.fill-choice {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 62px;
  padding: 10px 14px;
  border: 2px solid color-mix(in srgb, var(--tone) 50%, var(--paper));
  border-radius: var(--radius-m);
  background: var(--paper);
  font-size: 1.05rem;
  font-weight: 700;
  text-align: left;
}

.fill-choice:hover {
  background: color-mix(in srgb, var(--tone) 9%, var(--paper));
}

.class-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.class-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 10px 14px;
  border: 2px solid var(--rule);
  border-radius: var(--radius-m);
  background: var(--paper);
  text-align: left;
}

.class-choice.is-current {
  border-color: var(--ink);
  box-shadow: 0 3px 0 var(--ink);
}

.class-choice-name {
  font-family: var(--font-hand);
  font-size: 1.4rem;
}

.toast {
  position: fixed;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px);
  left: 50%;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  width: max-content;
  max-width: calc(100vw - 32px);
  padding: 10px 10px 10px 18px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  opacity: 0;
  transform: translate(-50%, 16px);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-btn {
  flex: none;
  min-height: 40px;
  padding: 6px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--highlight);
  color: var(--on-highlight);
  font-weight: 700;
}

.print-area {
  display: none;
}

/* ------------------------------------------------------------------ larger screens */

@media (min-width: 640px) {
  :root {
    --gutter: 24px;
  }

  .roster,
  .send-list,
  .paper-chart {
    margin-right: 0;
    margin-left: 0;
    border: 2px solid var(--rule);
    border-radius: var(--radius-l);
    box-shadow: 4px 4px 0 var(--rule);
  }

  .roster,
  .send-list {
    overflow: hidden;
  }

  .paper-chart {
    border: 0;
    border-radius: 4px;
    padding: 34px 32px 28px;
  }

  .field-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* All of a style's choices on one row (--choices is set on the element). */
  .ratings {
    grid-template-columns: repeat(var(--choices, 4), minmax(0, 1fr));
  }

  .rate:last-child:nth-child(odd) {
    grid-column: auto;
  }

  .student-item {
    grid-template-areas:
      'name email remove'
      'error error error';
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) auto;
  }

  .send-row {
    grid-template-columns: minmax(180px, 1.3fr) auto auto;
    align-items: center;
    gap: 16px;
  }

  .panel {
    padding: 22px 24px;
  }

  .sheet-body {
    padding: 24px;
  }

  .style-builder {
    grid-template-areas:
      'start preview'
      'editor preview'
      'actions actions';
    grid-template-columns: minmax(0, 1fr) 220px;
    align-items: start;
    column-gap: 24px;
  }

  .style-builder-start {
    grid-area: start;
  }

  .style-builder .style-preview {
    position: sticky;
    top: 0;
    grid-area: preview;
  }

  .style-builder .style-editor {
    grid-area: editor;
  }

  .style-builder .sheet-actions {
    grid-area: actions;
  }
}

@media (max-width: 639px) {
  .sheet,
  .sheet.is-wide {
    width: 100vw;
    max-width: 100vw;
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -2px 0 var(--ink);
  }
}

@media (min-width: 900px) {
  body {
    padding-bottom: 48px;
  }

  .topbar {
    padding: 12px max(24px, calc((100vw - 1180px) / 2 + 24px)) 10px;
  }

  .wordmark {
    font-size: 2rem;
  }

  .tabs {
    position: static;
    display: flex;
    gap: 4px;
    margin-left: auto;
    padding: 0;
    border: 0;
    background: none;
  }

  .tab {
    flex-direction: row;
    gap: 8px;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 999px;
    font-size: 1rem;
  }

  .tab .icon {
    width: 21px;
    height: 21px;
  }

  .tab:hover {
    color: var(--ink);
  }

  .view {
    padding-top: 16px;
  }

  .toast {
    bottom: 28px;
  }

  .day-chips,
  .today-bar {
    max-width: 720px;
  }

  /* Charts: five columns, like the paper sheet. */
  .paper-days {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: auto auto 1fr;
  }

  /* Subgrid keeps the header and stamp rows lined up across all five days. */
  .paper-day {
    grid-row: span 3;
    grid-template-rows: subgrid;
    grid-template-areas:
      'name'
      'stamp'
      'body';
    grid-template-columns: minmax(0, 1fr);
    border-top: 0;
    border-left: 2.5px solid var(--ink);
  }

  .paper-day:first-child {
    border-left: 0;
  }

  .paper-day-name {
    flex-direction: column;
    align-items: center;
    margin-bottom: 0;
    border-bottom: 2.5px solid var(--ink);
  }

  .paper-day-stamp {
    display: grid;
    place-items: center;
    margin: 0 -12px 12px;
    padding: 14px 0;
    border-bottom: 2.5px solid var(--ink);
  }

  .paper-title {
    font-size: 1.6rem;
  }
}

@media (min-width: 1100px) {
  /* Today: one line per child. */
  .row {
    align-items: start;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .row-main {
    display: grid;
    grid-template-columns: minmax(150px, 220px) minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px 16px;
  }

  .row-head {
    display: contents;
  }

  .name-link {
    grid-row: 1;
    grid-column: 1;
  }

  .ratings {
    grid-row: 1;
    grid-column: 2;
    margin: 0;
  }

  .row-tools {
    grid-row: 1;
    grid-column: 3;
    justify-content: flex-end;
  }

  .row-extra {
    grid-column: 1 / -1;
    margin-top: 4px;
  }
}

/* ------------------------------------------------------------------ motion and print */

@media (prefers-reduced-motion: reduce) {
  .stamp-in,
  .stamp-in .stamp {
    animation: none;
  }

  .progress-rule span,
  .toast {
    transition: none;
  }
}

@media print {
  @page {
    size: landscape;
    margin: 0.25in;
  }

  body {
    padding: 0;
    background: #fff;
  }

  .topbar,
  .view,
  .toast,
  .sheet {
    display: none !important;
  }

  .print-area {
    display: block;
  }

  .print-area img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 7.9in;
    margin: 0 auto;
    break-after: page;
  }

  .print-area img:last-child {
    break-after: auto;
  }
}
