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

svg { display: block; flex: 0 0 auto; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: "PolySans", "Inter", system-ui, sans-serif;
  font-size: var(--f12);
  -webkit-font-smoothing: antialiased;
}

.shell {
  width: var(--w-shell);
  max-width: var(--fill);
  margin: 0 auto;
  padding: var(--s100) 0 var(--s50);
  display: flex;
  flex-direction: column;
  gap: var(--s50);
}

.mark { align-self: center; height: var(--h-mark); }

:root[data-theme="dark"] .mark { content: url("contour-logo-cream.svg"); }

.intro { display: flex; flex-direction: column; gap: var(--s15); text-align: center; }

.intro h1 {
  margin: 0;
  font-size: var(--f36);
  line-height: var(--lh-hero);
  font-weight: var(--weight-bold);
  letter-spacing: var(--track-hero);
  color: var(--ink);
}

.intro p {
  margin: 0;
  font-size: var(--f16);
  line-height: var(--lh-lede);
  font-weight: var(--weight-regular);
  color: var(--ink-strong);
}

.subjects { display: flex; flex-direction: column; gap: var(--s20); }

.subject {
  background: var(--surface);
  border: var(--stroke) solid var(--line);
  border-radius: var(--r14);
  padding: var(--s16);
  display: flex;
  flex-direction: column;
  gap: var(--s16);
}

.body { display: flex; flex-direction: column; gap: var(--s16); }

.subject-top {
  display: flex;
  align-items: center;
  gap: var(--s16);
  padding-bottom: var(--s20);
  cursor: pointer;
  list-style: none;
}

.subject-top::-webkit-details-marker { display: none; }
.subject:not([open]) .subject-top { padding-bottom: 0; }

.tick {
  flex: 0 0 auto;
  width: var(--h-tick);
  height: var(--h-tick);
  border-radius: var(--r-pill);
  border: var(--stroke-2) solid var(--line);
  display: grid;
  place-items: center;
  color: var(--on-brand);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}

.tick svg {
  width: var(--i-check);
  height: var(--i-check);
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}

.subject[data-chosen] .tick { background: var(--brand); border-color: var(--brand); }
.subject[data-chosen] .tick svg { opacity: 1; }

.subject-head {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--s4);
}

.subject[open] .subject-head { height: var(--h-head); }

.subject-line { display: flex; align-items: center; gap: var(--s4); }

.subject-line h2 {
  margin: 0;
  font-size: var(--f16);
  line-height: var(--lh-name);
  font-weight: var(--weight-semibold);
  color: var(--ink);
}

.pill {
  border-radius: var(--r-pill);
  padding: var(--s2) var(--s8);
  font-size: var(--f9);
  line-height: var(--lh-xs);
  font-weight: var(--weight-semibold);
}

.subject-line .pill {
  padding: var(--s4) var(--s8);
  font-size: var(--f10);
  line-height: var(--lh-sm);
}

.pill-idle { background: var(--line-soft); color: var(--ink-strong); }
.pill-count { background: var(--brand-soft); color: var(--brand); }
.pill-homework { background: var(--homework-bg); color: var(--homework-fg); }
.pill-extension { background: var(--brand-soft); color: var(--brand); }
.pill-mastery { background: var(--mastery-bg); color: var(--mastery-fg); }

.held { font-size: var(--f10); line-height: var(--lh-sm); color: var(--muted); }
.held:empty { display: none; }

.chevron {
  flex: 0 0 auto;
  color: var(--ink);
  transition: transform var(--t-base) var(--ease);
}

.chevron svg { width: var(--i-chevron); height: var(--i-chevron); }
.subject[open] .chevron { transform: rotate(var(--turn-half)); }

.filters { display: flex; gap: var(--s15); width: var(--w-filters); max-width: var(--fill); }

.field {
  position: relative;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  gap: var(--s5);
}

.field span {
  padding-left: var(--s10);
  font-size: var(--f10);
  line-height: var(--lh-sm);
  font-weight: var(--weight-semibold);
  color: var(--ink-label);
}

.field select {
  appearance: none;
  width: var(--fill);
  height: var(--h-select);
  padding: 0 var(--s12) 0 var(--s16);
  background: var(--surface-raised);
  border: var(--stroke) solid var(--line);
  border-radius: var(--r10);
  font-family: inherit;
  font-size: var(--f12);
  color: var(--ink-strong);
  cursor: pointer;
}

.field svg {
  position: absolute;
  right: var(--s12);
  bottom: var(--caret-inset);
  width: var(--i-caret);
  height: var(--i-caret);
  color: var(--ink-strong);
  pointer-events: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols-week), minmax(0, 1fr));
  gap: var(--s5);
  background: var(--surface-raised);
  border: var(--stroke) solid var(--line);
  border-radius: var(--r10);
  padding: var(--s5);
}

.day {
  background: var(--surface);
  border-radius: var(--r8);
  padding: var(--s12) var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s8);
}

.day-head {
  display: flex;
  justify-content: space-between;
  padding: 0 var(--s5);
  font-size: var(--f12);
  line-height: var(--lh-day);
  font-weight: var(--weight-regular);
  color: var(--muted);
}

.slot[hidden] { display: none; }

.slot {
  display: block;
  width: var(--fill);
  padding: 0;
  background: none;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.slot-body {
  min-height: var(--h-card);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--s10);
  background: var(--surface-raised);
  border: var(--stroke) solid var(--line);
  border-radius: var(--r8) var(--r8) 0 0;
  padding: var(--s7);
  transition: border-color var(--t-fast) var(--ease);
}

.slot-body b {
  font-size: var(--f10);
  line-height: var(--lh-sm);
  font-weight: var(--weight-semibold);
  color: var(--ink-time);
}

.where {
  margin-top: calc(var(--s3) - var(--s10));
  display: flex;
  align-items: center;
  gap: var(--s4);
  font-size: var(--f9);
  line-height: var(--lh-xs);
  font-weight: var(--weight-regular);
  color: var(--ink);
}

.where svg { width: var(--i-pin); height: var(--i-pin); color: var(--muted); }

.slot-bar {
  height: var(--h-bar);
  display: grid;
  place-items: center;
  border: var(--stroke) solid var(--line);
  border-top: 0;
  border-radius: 0 0 var(--r8) var(--r8);
  background: var(--brand-wash);
  color: var(--brand);
  font-size: var(--f9);
  line-height: var(--lh-xs);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  transition: border-color var(--t-fast) var(--ease);
}

.slot[data-scarce] .slot-bar { background: var(--danger-wash); color: var(--danger); }
.slot[data-held] .slot-body, .slot[data-held] .slot-bar { border-color: var(--brand); }

.slot[data-full] { cursor: not-allowed; }
.slot[data-full] .slot-bar { background: var(--danger-wash); color: var(--danger); }
.slot[data-full] .slot-body b, .slot[data-full] .where { opacity: var(--dim-spent); }

.slot[data-full] .pill {
  opacity: var(--dim-spent);
  background: var(--line-soft);
  color: var(--spent-fg);
}

.foot { display: flex; justify-content: flex-end; }

.send {
  width: var(--w-send);
  height: var(--h-send);
  padding: 0 var(--s16);
  border: 0;
  border-radius: var(--r-pill);
  background: var(--send-off-bg);
  color: var(--send-off-fg);
  font-family: inherit;
  font-size: var(--f12);
  line-height: var(--lh-send);
  font-weight: var(--weight-bold);
  cursor: not-allowed;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.send:enabled { background: var(--accent); color: var(--on-accent); cursor: pointer; }

.toast {
  position: fixed;
  right: var(--s20);
  bottom: var(--s20);
  width: var(--w-toast);
  max-width: var(--fill);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  padding: var(--s16);
  border-radius: var(--r12);
  background: var(--brand);
  opacity: 0;
  transform: translateY(var(--s8));
  pointer-events: none;
  transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease);
}

.toast[data-open] { opacity: 1; transform: none; }

.toast b {
  display: flex;
  align-items: center;
  gap: var(--s8);
  color: var(--on-brand);
  font-size: var(--f14);
  line-height: var(--lh-title);
  font-weight: var(--weight-semibold);
}

.toast svg, .theme svg { width: var(--i-info); height: var(--i-info); }

.toast p {
  margin: 0;
  color: var(--on-brand-soft);
  font-size: var(--f12);
  line-height: var(--lh-body);
  font-weight: var(--weight-regular);
}

.theme {
  position: fixed;
  top: var(--s20);
  right: var(--s20);
  width: var(--h-tick);
  height: var(--h-tick);
  display: grid;
  place-items: center;
  border: var(--stroke) solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface-raised);
  color: var(--ink);
  cursor: pointer;
}

@media (max-width: 1200px) {
  .shell { padding: var(--s50) var(--s16); }
  .grid { grid-template-columns: repeat(var(--cols-narrow), minmax(0, 1fr)); }
  .filters { flex-wrap: wrap; width: var(--fill); }
  .toast { left: var(--s20); width: auto; }
}
