/* Teach — a paper planner by day, a chalkboard by night. */

@font-face { font-family: 'Atkinson'; src: url(/fonts/atkinson-hyperlegible-latin-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson'; src: url(/fonts/atkinson-hyperlegible-latin-700-normal.woff2) format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Zilla'; src: url(/fonts/zilla-slab-latin-600-normal.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Zilla'; src: url(/fonts/zilla-slab-latin-700-normal.woff2) format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --paper: #f6f1e4;
  --paper-2: #fffdf6;        /* index-card white */
  --rule: #c9d8e6;           /* notebook line blue */
  --margin: #e0a39b;         /* notebook margin red */
  --ink: #1e2a45;            /* navy pen */
  --ink-soft: #55607a;
  --pencil: #8a8676;
  --red: #b3352b;            /* red pen / NO PLAN stamp */
  --green: #2e6b3c;          /* READY stamp */
  --highlight: #ffe27a;      /* highlighter */
  --star: #e8b023;
  --edge: #d8cfb9;
  --shadow: rgba(60, 45, 20, .14);
  /* Planner divider tabs, one per class (cycled). */
  --tab-1: #d6a128; --tab-2: #2b7c77; --tab-3: #b45a33; --tab-4: #4b6ea6; --tab-5: #7c5a9c; --tab-6: #5f7f2f;
  --link: #3d5f99;          /* links and small labels, readable on paper */
  --display: 'Zilla', 'Rockwell', 'Georgia', serif;
  --body: 'Atkinson', system-ui, sans-serif;
  color-scheme: light;
}

/* Chalkboard. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1f2a24; --paper-2: #26332c; --rule: rgba(233, 230, 216, .07); --margin: rgba(224, 120, 110, .35);
    --ink: #ecebe2; --ink-soft: #b9bdb1; --pencil: #8f978b; --red: #f08a7c; --green: #93d19c;
    --highlight: rgba(255, 226, 122, .28); --star: #f4c54a; --edge: #3a4a40; --shadow: rgba(0, 0, 0, .35); --link: #9db8e8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1f2a24; --paper-2: #26332c; --rule: rgba(233, 230, 216, .07); --margin: rgba(224, 120, 110, .35);
  --ink: #ecebe2; --ink-soft: #b9bdb1; --pencil: #8f978b; --red: #f08a7c; --green: #93d19c;
  --highlight: rgba(255, 226, 122, .28); --star: #f4c54a; --edge: #3a4a40; --shadow: rgba(0, 0, 0, .35); --link: #9db8e8;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  background: var(--paper); color: var(--ink);
  font: 400 17px/1.5 var(--body);
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.15; margin: 0; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px 96px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--tab-4); outline-offset: 2px; }

/* ---- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 8px; cursor: pointer;
  border: 2px solid var(--ink); background: var(--ink); color: var(--paper);
  font-weight: 700; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn.small { min-height: 44px; padding: 0 14px; font-size: 15px; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%;
  border: 0; background: transparent; cursor: pointer; color: var(--ink);
}
.icon-btn:hover { background: var(--shadow); }
.icon-btn svg { width: 24px; height: 24px; }

/* ---- Top: the date written at the top of the planner page */
.top {
  display: flex; align-items: center; gap: 4px;
  padding: 18px 0 10px; border-bottom: 2px solid var(--ink);
}
.top .when { flex: 1; min-width: 0; text-align: center; }
.top .weekday { font-family: var(--display); font-size: 30px; font-weight: 700; }
.top .weekday .hl { background: linear-gradient(transparent 55%, var(--highlight) 55%, var(--highlight) 92%, transparent 92%); padding: 0 4px; }
.top .date { color: var(--ink-soft); font-size: 15px; }
.back-today {
  display: block; margin: 8px auto 0; border: 0; background: none; cursor: pointer;
  color: var(--link); font-weight: 700; text-decoration: underline; text-underline-offset: 3px;
}

/* ---- Quick add: a sticky note */
.quick {
  margin: 18px 0 6px; padding: 12px; border-radius: 4px;
  background: #fff3a8; color: #2b2a1f;
  box-shadow: 0 1px 0 rgba(0,0,0,.06), 3px 4px 0 var(--shadow);
  transform: rotate(-.4deg);
}
:root[data-theme="dark"] .quick { background: #4b4a2c; color: #f5f0cf; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .quick { background: #4b4a2c; color: #f5f0cf; } }
.quick form { display: flex; gap: 8px; }
.quick input {
  flex: 1; min-width: 0; min-height: 46px; padding: 0 12px;
  border: 0; border-bottom: 2px dashed currentColor; background: transparent; outline: none; font-size: 18px;
}
.quick input::placeholder { color: currentColor; opacity: .55; }
.quick .btn { background: #2b2a1f; border-color: #2b2a1f; color: #fff3a8; }
.quick .hint { margin: 6px 2px 0; font-size: 14px; opacity: .75; min-height: 21px; }

/* ---- Section headings: underlined in pen */
.section-head { display: flex; align-items: baseline; gap: 10px; margin: 28px 0 10px; }
.section-head h2 { font-size: 22px; }
.section-head .count { color: var(--ink-soft); font-size: 15px; }
.section-head .count b { color: var(--ink); }

/* ---- Classes: index cards with a colored divider tab */
.classes { display: grid; gap: 12px; }
.card {
  position: relative; display: block; width: 100%; text-align: left; cursor: pointer;
  padding: 14px 16px 14px 22px; border: 1px solid var(--edge); border-radius: 6px;
  background: var(--paper-2); box-shadow: 2px 3px 0 var(--shadow);
}
.card::before { /* the divider tab */
  content: ''; position: absolute; left: -1px; top: -1px; bottom: -1px; width: 8px;
  border-radius: 6px 0 0 6px; background: var(--tab, var(--tab-1));
}
.card .meta { font-size: 14px; color: var(--ink-soft); padding-right: 104px; }
.card .meta b { color: color-mix(in srgb, var(--tab, var(--ink)) 48%, var(--ink)); }
.card h3 { font-size: 20px; margin: 2px 0 4px; padding-right: 104px; }
.card .lesson { font-size: 16px; color: var(--ink-soft); }
.card .lesson.none { color: var(--red); font-weight: 700; }
.card .go { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.stamp {
  position: absolute; right: 12px; top: 14px;
  font-family: var(--display); font-weight: 700; font-size: 14px; letter-spacing: .12em;
  padding: 3px 8px; border: 2.5px solid currentColor; border-radius: 4px;
  transform: rotate(-6deg); opacity: .85;
}
.stamp.no { color: var(--red); }
.stamp.ok { color: var(--green); transform: rotate(4deg); }
.weekend {
  padding: 22px; text-align: center; border: 2px dashed var(--edge); border-radius: 8px; color: var(--ink-soft);
}
.weekend p { margin: 0 0 12px; }

/* ---- To-do: ruled notebook paper with a red margin */
.notebook {
  list-style: none; margin: 0; padding: 0;
  background: var(--paper-2); border: 1px solid var(--edge); border-radius: 6px;
  box-shadow: 2px 3px 0 var(--shadow); overflow: hidden;
  background-image: linear-gradient(90deg, transparent 47px, var(--margin) 47px, var(--margin) 49px, transparent 49px);
}
.notebook li {
  display: flex; align-items: center; gap: 8px; min-height: 54px;
  padding: 4px 6px 4px 4px; border-bottom: 1px solid var(--rule);
}
.notebook li:last-child { border-bottom: 0; }
.check {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; background: none; cursor: pointer; padding: 0;
}
.check .box {
  width: 24px; height: 24px; border: 2px solid var(--ink); border-radius: 4px; display: grid; place-items: center;
  background: var(--paper-2);
}
.check svg { width: 22px; height: 22px; color: var(--green); opacity: 0; transform: scale(.4); transition: transform .18s ease, opacity .18s; }
li.done .check svg { opacity: 1; transform: scale(1.15); }
.task-text {
  flex: 1; min-width: 0; padding: 8px 6px 8px 12px; border: 0; background: none; text-align: left; cursor: pointer;
  overflow-wrap: anywhere;
}
li.done .task-text { color: var(--pencil); text-decoration: line-through; text-decoration-thickness: 2px; }
.tag {
  display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 10px; font-size: 13px; font-weight: 700;
  vertical-align: 2px; background: var(--shadow); color: var(--ink-soft);
}
.tag.late { background: transparent; color: var(--red); border: 1.5px solid var(--red); }
.empty { padding: 18px 16px 18px 62px; color: var(--ink-soft); }
.stars { color: var(--ink-soft); font-size: 15px; }
.stars .star { color: var(--star); }

/* Coming up */
details.upcoming { margin-top: 14px; }
details.upcoming summary { cursor: pointer; color: var(--ink-soft); font-weight: 700; padding: 8px 2px; min-height: 44px; }
details.upcoming .notebook li { min-height: 46px; }

/* Gold star sticker when something gets done */
.sticker {
  position: fixed; z-index: 50; width: 64px; height: 64px; pointer-events: none;
  color: var(--star); filter: drop-shadow(1px 2px 0 rgba(0,0,0,.25));
  animation: stick .9s cubic-bezier(.2, 1.4, .4, 1) forwards;
}
@keyframes stick {
  0% { transform: translate(-50%, -50%) scale(.2) rotate(-40deg); opacity: 0; }
  35% { transform: translate(-50%, -50%) scale(1.15) rotate(8deg); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1) rotate(-4deg); opacity: 1; }
  100% { transform: translate(-50%, -90%) scale(.9) rotate(-4deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sticker { animation-duration: .01s; }
  .check svg { transition: none; }
}

/* ---- Sheets (lesson editor, task menu) */
dialog {
  width: min(680px, 100vw); max-width: 100vw; max-height: 100dvh; margin: auto auto 0; padding: 0;
  border: 0; border-radius: 14px 14px 0 0; background: var(--paper); color: var(--ink);
  box-shadow: 0 -6px 30px rgba(0,0,0,.25);
}
@media (min-width: 720px) { dialog { margin: auto; border-radius: 12px; } }
dialog::backdrop { background: rgba(20, 22, 30, .45); }
.sheet { padding: 18px 16px 20px; }
.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.sheet-head h2 { flex: 1; font-size: 22px; }
.sheet-head .sub { display: block; font-family: var(--body); font-weight: 400; font-size: 14px; color: var(--ink-soft); }
label.field { display: block; margin: 0 0 14px; font-weight: 700; }
label.field span { display: block; margin-bottom: 4px; }
label.field small { font-weight: 400; color: var(--ink-soft); }
.input, textarea.input {
  display: block; width: 100%; min-height: 46px; padding: 10px 12px; font-weight: 400;
  border: 2px solid var(--edge); border-radius: 8px; background: var(--paper-2);
}
.input:focus { border-color: var(--ink); outline: none; }
.input, textarea.input { font-weight: 400; font-size: 17px; color: var(--ink); }
textarea.input {
  min-height: 42dvh; resize: vertical; line-height: 28px; padding-top: 6px;
  background-image: repeating-linear-gradient(transparent 0 27px, var(--rule) 27px 28px);
  background-attachment: local;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row .spacer { flex: 1; }
.menu { display: grid; gap: 8px; }
.menu .btn { justify-content: flex-start; }

/* Lesson view */
.lesson-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 16px; padding: 12px 14px; background: var(--paper-2); border: 1px solid var(--edge); border-radius: 8px; line-height: 1.6; max-height: 55dvh; overflow: auto; }

/* ---- Settings */
.settings h2 { font-size: 22px; margin: 26px 0 8px; }
.settings p.help { color: var(--ink-soft); margin: 0 0 12px; }
.class-row {
  position: relative; display: grid; gap: 8px; margin-bottom: 12px; padding: 12px 12px 12px 20px;
  background: var(--paper-2); border: 1px solid var(--edge); border-radius: 6px;
}
.class-row::before { content: ''; position: absolute; left: -1px; top: -1px; bottom: -1px; width: 8px; border-radius: 6px 0 0 6px; background: var(--tab); }
.class-row .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 480px) { .class-row .grid { grid-template-columns: 1fr; } }
.class-row label { font-size: 14px; font-weight: 700; color: var(--ink-soft); }

/* ---- Toast: a note slipped under the door */
.toast {
  position: fixed; left: 50%; bottom: 22px; z-index: 60; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 8px;
  background: var(--ink); color: var(--paper); font-weight: 700; box-shadow: 0 6px 18px rgba(0,0,0,.25);
  display: flex; gap: 14px; align-items: center;
}
.toast button { border: 0; background: none; color: var(--highlight); font-weight: 700; cursor: pointer; text-decoration: underline; min-height: 32px; }

/* ---- Login */
.login { max-width: 380px; margin: 0 auto; padding: 14dvh 16px 40px; }
.login h1 { font-size: 46px; }
.login h1 .hl { background: linear-gradient(transparent 55%, var(--highlight) 55%, var(--highlight) 92%, transparent 92%); padding: 0 4px; }
.login p { color: var(--ink-soft); margin: 4px 0 26px; }
.login .btn { width: 100%; margin-top: 4px; }
.login .error { color: var(--red); font-weight: 700; min-height: 26px; margin: 10px 0 0; }

/* ---- Day | Week: index tabs sticking up from the top of the page */
.tabs { display: flex; gap: 6px; padding-top: 12px; }
.tab {
  min-height: 44px; padding: 10px 22px 8px; border: 1px solid var(--edge); border-bottom: 0; border-radius: 10px 10px 0 0;
  background: var(--shadow); color: var(--ink-soft); font-family: var(--display); font-weight: 700; font-size: 17px; text-decoration: none;
}
.tab.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.tabs + .top { padding-top: 8px; border-top: 0; }
.help { color: var(--ink-soft); margin: 8px 0 0; }
.icon-btn.small { width: 44px; height: 44px; }
.icon-btn.small svg { width: 20px; height: 20px; }

/* ---- Week */
#view.wide { max-width: 1240px; }
.progress { margin: 16px 0 6px; }
.progress-text { font-size: 16px; color: var(--ink-soft); margin-bottom: 6px; }
.progress-text b { color: var(--ink); }
.progress .left { color: var(--red); font-weight: 700; }
.bar { height: 10px; border-radius: 6px; background: var(--shadow); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--green); border-radius: 6px; transition: width .3s; }

.week { display: grid; gap: 14px; margin-top: 16px; }
@media (min-width: 960px) { .week { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; } }
.day-col {
  background: var(--paper-2); border: 1px solid var(--edge); border-radius: 6px; box-shadow: 2px 3px 0 var(--shadow);
  padding: 6px 8px 10px;
}
.day-col.today { border: 2px solid var(--ink); }
.day-head { display: flex; align-items: center; gap: 6px; border-bottom: 2px solid var(--ink); padding-bottom: 4px; margin-bottom: 8px; }
.day-name {
  flex: 1; min-width: 0; text-align: left; border: 0; background: none; cursor: pointer; padding: 6px 4px; min-height: 44px;
  font-family: var(--display); font-weight: 700; font-size: 19px;
}
.day-name .hl { background: linear-gradient(transparent 55%, var(--highlight) 55%, var(--highlight) 92%, transparent 92%); padding: 0 3px; }
.day-name small { display: block; font-family: var(--body); font-weight: 400; font-size: 14px; color: var(--ink-soft); }
.slots { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.slots li { min-width: 0; }
.slot {
  position: relative; display: block; width: 100%; min-height: 54px; text-align: left; cursor: pointer;
  padding: 7px 8px 7px 16px; border: 1px solid var(--edge); border-radius: 5px; background: var(--paper);
  overflow-wrap: anywhere;
}
.slot::before { content: ''; position: absolute; left: -1px; top: -1px; bottom: -1px; width: 6px; border-radius: 5px 0 0 5px; background: var(--tab); }
.slot small { display: block; font-size: 13px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot span { font-weight: 700; font-size: 15px; line-height: 1.3; }
.slot.empty { border-style: dashed; border-color: var(--red); background: transparent; }
.slot .none { color: var(--red); }
.day-col.off { background: transparent; box-shadow: none; border-style: dashed; }
.off-box { padding: 14px 6px; text-align: center; color: var(--ink-soft); display: grid; gap: 2px; }
.off-box b { font-family: var(--display); font-size: 18px; color: var(--ink); letter-spacing: .04em; }

/* ---- No plan yet: three big choices */
.choices { display: grid; gap: 10px; }
.choice {
  display: grid; gap: 2px; text-align: left; cursor: pointer; min-height: 72px; padding: 14px 16px;
  border: 2px solid var(--ink); border-radius: 10px; background: var(--paper-2); box-shadow: 3px 3px 0 var(--ink);
}
.choice:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.choice b { font-family: var(--display); font-size: 21px; }
.choice span { color: var(--ink-soft); }
.choice.primary { background: var(--highlight); }
.choice.primary span { color: var(--ink); }

/* ---- Rescue: backup lessons */
.bank { display: grid; gap: 8px; margin-bottom: 12px; }
.bank-item { border: 1px solid var(--edge); border-radius: 8px; background: var(--paper-2); }
.bank-item summary { cursor: pointer; padding: 12px 14px; min-height: 48px; list-style: none; display: grid; grid-template-columns: 16px 1fr; gap: 4px 6px; align-items: start; }
.bank-item summary > * { grid-column: 2; justify-self: start; }
.bank-item summary::-webkit-details-marker { display: none; }
.bank-item summary::before { content: '▸'; color: var(--ink-soft); }
.bank-item[open] summary::before { content: '▾'; }
.bank-item .tag { margin-left: 0; }
.bank-item .lesson-body { margin: 0 12px 12px; max-height: 40dvh; background: var(--paper); }
.bank-item .btn { margin: 0 12px 14px; }
details.more > summary { cursor: pointer; font-weight: 700; color: var(--ink-soft); padding: 10px 2px; min-height: 44px; }

/* ---- AI: numbered steps */
.step { display: grid; grid-template-columns: 36px 1fr; gap: 10px; margin-bottom: 18px; }
.step .num {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: var(--paper); font-family: var(--display); font-weight: 700;
}
.step > div > b { display: block; font-family: var(--display); font-size: 19px; margin: 3px 0 8px; }
.step .help { margin: 0 0 10px; }
textarea.input.paste { min-height: 140px; background-image: none; line-height: 1.5; margin-bottom: 10px; }
.week-actions { margin: 12px 0 0; }
.settings .notebook li { padding-right: 10px; }

/* ---- Grades */
.grade-tag {
  display: inline-block; margin-left: 8px; padding: 0 6px; border: 1.5px solid var(--tab-4); border-radius: 4px;
  color: var(--tab-4); font-family: var(--display); font-weight: 700; font-size: 12px; letter-spacing: .08em; vertical-align: 2px;
}
:root[data-theme="dark"] .grade-tag { color: #9db8e8; border-color: #9db8e8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .grade-tag { color: #9db8e8; border-color: #9db8e8; } }
.grade-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 10px; }
.grade-chips .label { font-weight: 700; color: var(--ink-soft); font-size: 15px; }
.chip {
  padding: 2px 10px; border-radius: 14px; font-size: 14px; font-weight: 700;
  border: 1.5px dashed var(--red); color: var(--red);
}
.chip.ok { border: 1.5px solid var(--green); color: var(--green); }
.chip.ok::before { content: '✓ '; }
.grade-warn { margin: 0 0 10px; padding: 10px 12px; border-left: 4px solid var(--red); background: var(--paper-2); color: var(--ink); border-radius: 0 6px 6px 0; }
.grade-sub { display: block; font-size: 14px; color: var(--ink-soft); margin-top: 2px; }
.grade-sub b { color: var(--ink); }
.check .box.half { border-style: dashed; }
li.half .check svg { opacity: .5; transform: scale(1); }
.grade-check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: -4px 0 12px; font-weight: 700; cursor: pointer; }
.grade-check input { width: 22px; height: 22px; accent-color: var(--ink); }
.grade-line { margin: 0 0 14px; }
.grade-box { padding: 10px 12px; border: 1.5px solid var(--tab-4); border-radius: 8px; background: var(--paper-2); }
.linkish { border: 0; background: none; color: var(--link); text-decoration: underline; cursor: pointer; font-weight: 700; padding: 6px 4px; min-height: 36px; }
.num-input { max-width: 120px; }
.week .grade-tag { margin-left: 6px; font-size: 11px; }
.week-actions + .week, .grade-chips + .week { margin-top: 12px; }
.time-row { display: grid; grid-template-columns: auto 170px; gap: 4px 12px; align-items: center; margin: 14px 0 0; }
.time-row .grade-check { margin: 0; }
.time-row small { grid-column: 1 / -1; margin: 0; }

/* ---- Bell ringers */
.card-wrap { display: grid; grid-template-columns: minmax(0, 1fr); }
.card-wrap .card { position: relative; z-index: 1; }
.bell-strip {
  display: flex; gap: 10px; align-items: baseline; text-align: left; cursor: pointer; min-height: 44px; min-width: 0;
  margin: -4px 10px 0 18px; padding: 10px 12px 8px; border: 1px solid var(--edge); border-top: 0; border-radius: 0 0 6px 6px;
  background: var(--paper); box-shadow: 2px 3px 0 var(--shadow);
}
.bell-label {
  flex: none; font-family: var(--display); font-weight: 700; font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  color: color-mix(in srgb, var(--tab, var(--ink)) 48%, var(--ink));
}
.bell-q { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); font-size: 15px; }
.bell-card {
  white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 12px; padding: 16px 18px; border-radius: 4px;
  background: var(--paper-2); border: 1px solid var(--edge); box-shadow: 2px 3px 0 var(--shadow);
  font-size: 20px; line-height: 1.45;
  border-top: 6px solid var(--tab-4);
}
.bell-answer { margin: 0 0 12px; padding: 8px 12px; background: var(--paper-2); border-left: 4px solid var(--green); white-space: pre-wrap; }
.steps-mini { margin: 0 0 14px; padding-left: 22px; color: var(--ink-soft); }
.steps-mini li { margin: 2px 0; }
.course-pick { margin-bottom: 12px; }
.sheet-preview { margin-top: 14px; padding: 14px; background: #fff; color: #111; border: 1px solid var(--edge); border-radius: 6px; font-family: Arial, sans-serif; font-size: 14px; max-height: 50dvh; overflow: auto; }
.sheet-preview h2 { font-family: Arial, sans-serif; font-size: 18px; margin: 0 0 4px; }
.sheet-preview table { border-collapse: collapse; width: 100%; }
.sheet-preview td { border: 1px solid #444; padding: 8px; vertical-align: top; }

/* Projector view */
body.proj-on #view { max-width: none; padding: 0; }
.projector { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; background: var(--paper); transition: background .4s; }
.projector.times-up { background: var(--highlight); }
.proj-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 24px; border-bottom: 2px solid var(--ink); font-size: 20px; }
.proj-top b { font-family: var(--display); font-size: 24px; }
.proj-top .row { flex-wrap: nowrap; }
.proj-main { padding: 4vh 6vw; display: grid; align-content: center; gap: 2vh; }
.proj-label { font-family: var(--display); font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--link); font-size: clamp(16px, 2vw, 26px); }
.proj-q { font-family: var(--display); font-weight: 600; font-size: clamp(28px, 4.6vw, 72px); line-height: 1.2; white-space: pre-wrap; overflow-wrap: anywhere; }
.proj-answer summary { cursor: pointer; font-weight: 700; color: var(--ink-soft); font-size: clamp(16px, 1.6vw, 22px); min-height: 44px; }
.proj-answer p { font-size: clamp(22px, 3vw, 44px); margin: 6px 0 0; color: var(--green); font-weight: 700; }
.proj-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 28px; padding: 14px 24px 22px; border-top: 2px dashed var(--edge); }
.clock { font-family: var(--display); font-weight: 700; font-size: clamp(44px, 6vw, 96px); font-variant-numeric: tabular-nums; min-width: 4ch; text-align: center; }
.times-up-msg { display: none; font-family: var(--display); font-weight: 700; font-size: clamp(24px, 3vw, 44px); }
.times-up .times-up-msg { display: block; }
:root[data-theme="dark"] .projector.times-up, :root[data-theme="dark"] .projector.times-up * { color: #1f2a24; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .projector.times-up { background: #ffe27a; } :root:not([data-theme="light"]) .projector.times-up * { color: #1f2a24; } }

/* ---- Units (TEKS) */
.unit-summary { position: relative; margin: 14px 0 6px; padding: 14px 14px 10px 22px; background: var(--paper-2); border: 1px solid var(--edge); border-radius: 6px; box-shadow: 2px 3px 0 var(--shadow); }
.unit-summary::before { content: ''; position: absolute; left: -1px; top: -1px; bottom: -1px; width: 8px; border-radius: 6px 0 0 6px; background: var(--tab); }
.unit-summary .meta { color: var(--ink-soft); font-size: 14px; }
.unit-summary p { margin: 10px 0 0; }
.unit-summary .help { margin-top: 4px; }
.units { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.unit { background: var(--paper-2); border: 1px solid var(--edge); border-radius: 6px; }
.unit.current { border: 2px solid var(--ink); }
.unit summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 40px 1fr; gap: 2px 10px; padding: 12px 14px; min-height: 56px; }
.unit summary::-webkit-details-marker { display: none; }
.unit-no { grid-row: span 2; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--ink); font-family: var(--display); font-weight: 700; }
.unit.done .unit-no { background: var(--green); border-color: var(--green); color: var(--paper); }
.unit-title { font-family: var(--display); font-weight: 700; font-size: 18px; }
.unit-meta { color: var(--ink-soft); font-size: 14px; }
.tag.now { background: var(--highlight); color: var(--ink); }
.teks-list { list-style: none; margin: 0; padding: 0 10px; border-top: 1px solid var(--rule); }
.teks-list li { display: flex; gap: 6px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--rule); font-size: 15px; }
.teks-list li > div { padding-top: 10px; overflow-wrap: anywhere; }
.teks-list li.done > div { color: var(--ink-soft); }
.teks-list .cite { font-family: var(--display); }
.teks-list .covered { color: var(--green); font-weight: 700; }
.unit-actions { padding: 10px 14px 14px; }
textarea.input.teks-box { min-height: 90px; font-size: 15px; }
.wide-date { max-width: 200px; }

/* ---- Coach */
@media (max-width: 420px) { .tab { padding: 10px 14px 8px; font-size: 16px; } .tabs { gap: 4px; } }
.ramp { margin-top: 6px; }
.ramp .task-text a { color: var(--link); font-weight: 700; }
.ioi-card { margin: 18px 0 0; padding: 14px 16px; border-radius: 4px; background: #fff3a8; color: #2b2a1f; box-shadow: 3px 4px 0 var(--shadow); transform: rotate(.3deg); }
:root[data-theme="dark"] .ioi-card { background: #4b4a2c; color: #f5f0cf; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ioi-card { background: #4b4a2c; color: #f5f0cf; } }
.ioi-card ol { margin: 6px 0 0; padding-left: 22px; }
.routines { display: grid; gap: 10px; }
.routine { background: var(--paper-2); border: 1px solid var(--edge); border-radius: 6px; box-shadow: 2px 3px 0 var(--shadow); }
.routine summary { list-style: none; cursor: pointer; padding: 12px 14px; min-height: 56px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.routine summary::-webkit-details-marker { display: none; }
.routine-name { font-family: var(--display); font-weight: 700; font-size: 19px; }
.routine-line { flex-basis: 100%; color: var(--ink-soft); font-size: 15px; }
.routine-body { padding: 0 16px 16px; border-top: 1px solid var(--rule); }
.routine-body h3 { font-size: 17px; margin: 14px 0 4px; }
.routine-body ol, .routine-body ul { margin: 0; padding-left: 22px; }
.routine-body li { margin: 3px 0; }
.starters li { font-style: italic; }
.sideways { margin: 14px 0; padding: 8px 12px; border-left: 4px solid var(--red); background: var(--paper); }
.proj-steps { margin: 0; padding-left: 1.2em; font-family: var(--display); font-weight: 600; font-size: clamp(22px, 3.2vw, 48px); line-height: 1.3; }
.proj-steps li { margin: .2em 0; }
.proj-starters { display: flex; flex-wrap: wrap; gap: 6px 22px; color: var(--ink-soft); font-size: clamp(16px, 1.8vw, 26px); font-style: italic; }
.proj-starters b { font-style: normal; color: var(--ink); }
.leader-sheet { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .leader-sheet { grid-template-columns: 1fr; } }
.leader-card { border: 3px dashed var(--ink); border-radius: 10px; padding: 14px 16px; background: var(--paper-2); break-inside: avoid; }
.leader-card h2 { font-size: 26px; letter-spacing: .1em; margin: 0 0 8px; }
.leader-card p { margin: 4px 0; font-size: 15px; }
.starters-mini { color: var(--ink-soft); font-size: 13px !important; }
.grade-check.light { font-weight: 400; margin: 0; min-height: 40px; }
.fresh .btn.small { margin: 4px 0 10px; }
@media print {
  .no-print, .tabs, .toast { display: none !important; }
  body { background: #fff; }
  .leader-sheet { grid-template-columns: 1fr 1fr; }
  .leader-card { background: #fff; color: #000; }
}
.grade-check input { flex: none; }
.time-row .input { max-width: none; }
.proj-steps { font-size: clamp(20px, 2.5vw, 40px); }
.projector:has(.proj-steps) .proj-main { padding: 3vh 6vw; }
.week-course { margin: 0 0 12px; }
.week-course.off textarea { opacity: .45; }
.week-course .sections { font-weight: 400; color: var(--ink-soft); }
.count-line { font-weight: 700; color: var(--ink); }
.slides-strip {
  display: flex; gap: 10px; align-items: baseline; min-height: 44px; min-width: 0; text-decoration: none;
  margin: -4px 10px 0 18px; padding: 10px 12px 8px; border: 1px solid var(--edge); border-top: 0; border-radius: 0 0 6px 6px;
  background: var(--paper-2); box-shadow: 2px 3px 0 var(--shadow);
}
.slides-strip .bell-q { color: var(--link); font-weight: 700; }
.slides-strip + .bell-strip { margin-top: 0; }

/* ---- Games */
html { background: var(--paper); }
body { padding-bottom: env(safe-area-inset-bottom); }
.games { margin-top: 8px; }
.games .notebook li { gap: 8px; padding-right: 10px; }
.games > .btn { margin-top: 10px; }
.jeopardy .jboard { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 8px; padding: 14px 18px; align-content: start; }
.jcat { font-family: var(--display); font-weight: 700; text-align: center; padding: 10px 6px; font-size: clamp(14px, 1.6vw, 24px); background: var(--ink); color: var(--paper); border-radius: 6px; display: grid; place-items: center; overflow-wrap: anywhere; }
.jtile { min-height: clamp(54px, 11vh, 110px); border-radius: 6px; border: 2px solid var(--ink); background: var(--paper-2); color: var(--ink);
  font-family: var(--display); font-weight: 700; font-size: clamp(20px, 3vw, 44px); cursor: pointer; box-shadow: 2px 3px 0 var(--shadow); }
.jtile:hover:not(:disabled) { background: var(--highlight); }
.jtile.used { background: transparent; border-style: dashed; box-shadow: none; cursor: default; }
.jtile.empty { visibility: hidden; }
.scores { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; justify-content: center; }
.score { display: grid; justify-items: center; }
.score b { font-family: var(--display); font-size: clamp(22px, 2.6vw, 38px); }
.score b.neg { color: var(--red); }
.team-name { width: 9em; text-align: center; border: 0; border-bottom: 2px dashed var(--edge); background: transparent; font-weight: 700; }
.team-count { display: flex; gap: 6px; }
.jclue .janswer { font-size: clamp(22px, 3vw, 44px); color: var(--green); font-weight: 700; margin: 0; }
.award { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.award-team { display: flex; gap: 6px; align-items: center; }
.award-team span { font-weight: 700; min-width: 7em; }
.charades .proj-main { justify-items: center; text-align: center; }
.charade-word { font-family: var(--display); font-weight: 700; font-size: clamp(40px, 9vw, 110px); line-height: 1.1; padding: 3vh 0; overflow-wrap: anywhere; }
.charade-mode { color: var(--ink-soft); margin: 0; }
.quiz-list { margin: 10px 0 14px; padding-left: 26px; }
.quiz-list > li { margin: 0 0 12px; padding: 10px 12px; background: var(--paper-2); border: 1px solid var(--edge); border-radius: 8px; }
.quiz-list > li.warn { border-color: var(--red); }
.quiz-q { font-weight: 700; margin-bottom: 4px; overflow-wrap: anywhere; }
.quiz-list ul { margin: 0; padding-left: 18px; color: var(--ink-soft); }
.quiz-list ul li.right { color: var(--green); font-weight: 700; list-style: none; margin-left: -18px; }
.quiz-warn { color: var(--red); margin: 6px 0 0; font-size: 14px; }
.import-steps { margin-top: 16px; padding: 12px 14px; border-left: 4px solid var(--green); background: var(--paper-2); }
.import-steps ol { margin: 6px 0 0; padding-left: 22px; }


/* ---- v1.4 polish (from the UI audit) */
.back-today { min-height: 44px; padding: 8px 10px; }
.task-text { min-height: 44px; }
.team-name { min-height: 44px; }
.toast button { min-height: 44px; padding: 0 6px; }
/* Toasts float above sheets and never cover projector controls. */
.toast { bottom: calc(22px + env(safe-area-inset-bottom)); }
body.proj-on .toast, dialog .toast { bottom: auto; top: calc(16px + env(safe-area-inset-top)); }
/* Sheets: no focus ring on the title we focus for screen readers. */
.sheet-head h2:focus { outline: none; }
.sheet-head h2 { overflow-wrap: anywhere; }
/* Week on tablets: two columns instead of one long list. */
@media (min-width: 640px) and (max-width: 959px) { .week { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* "More" list on the plan sheet. */
.more-list { display: grid; gap: 6px; margin: 4px 0 0; }
.more-item { display: grid; grid-template-columns: 1fr; text-align: left; gap: 0; min-height: 52px; padding: 8px 14px; border: 1px solid var(--edge); border-radius: 8px; background: var(--paper-2); color: var(--ink); cursor: pointer; text-decoration: none; }
.more-item b { font-weight: 700; }
.more-item span { color: var(--ink-soft); font-size: 14px; }
.more-item.danger b { color: var(--red); }
details.more-wrap > summary { list-style: none; }
details.more-wrap > summary::-webkit-details-marker { display: none; }
/* Jump links at the top of long pages. */
.jump { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; }
.jump a { min-height: 44px; display: inline-flex; align-items: center; padding: 0 12px; border: 1.5px solid var(--edge); border-radius: 22px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 15px; background: var(--paper-2); }
/* Page states. */
.state-box { margin: 28px 0; padding: 22px; text-align: center; border: 2px dashed var(--edge); border-radius: 10px; color: var(--ink-soft); }
.state-box b { display: block; color: var(--ink); font-family: var(--display); font-size: 20px; margin-bottom: 6px; }
.state-box .btn { margin-top: 12px; }
/* First-day setup card. */
.setup { margin: 18px 0 0; padding: 14px 16px; border: 2px solid var(--ink); border-radius: 10px; background: var(--paper-2); }
.setup h2 { font-size: 20px; }
.setup ol { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.setup li a, .setup li .done-step { display: flex; align-items: center; gap: 10px; min-height: 44px; color: var(--ink); text-decoration: none; font-weight: 700; }
.setup li .done-step { color: var(--ink-soft); text-decoration: line-through; font-weight: 400; }
.setup .dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ink); display: grid; place-items: center; flex: none; font-size: 14px; }
.setup .done-step .dot { background: var(--green); border-color: var(--green); color: var(--paper); }
/* Collapsed class rows in Settings. */
details.class-row { padding: 0; }
details.class-row > summary { list-style: none; cursor: pointer; display: flex; gap: 8px; align-items: center; min-height: 52px; padding: 8px 12px 8px 20px; }
details.class-row > summary::-webkit-details-marker { display: none; }
details.class-row > summary b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.class-row > summary small { color: var(--ink-soft); }
details.class-row[open] > summary { border-bottom: 1px solid var(--rule); }
details.class-row > .class-edit { display: grid; gap: 8px; padding: 12px 12px 12px 20px; }
.fold > summary { cursor: pointer; list-style: none; min-height: 48px; display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 700; font-size: 22px; margin: 18px 0 4px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: '▸'; font-size: 16px; color: var(--ink-soft); }
.fold[open] > summary::after { content: '▾'; }
.grades-ok { margin: 0; color: var(--ink-soft); }
.grades-ok b { color: var(--green); }
.linkish { min-height: 44px; }
.team-count .btn { min-width: 44px; }
details.class-row > summary { display: grid; grid-template-columns: 1fr auto; column-gap: 8px; }
details.class-row > summary b { white-space: normal; overflow: visible; grid-column: 1; }
details.class-row > summary small { grid-column: 1; grid-row: 2; }
details.class-row > summary .tag { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.teks-list .planned { color: var(--link); font-weight: 700; }

/* ---- View plan (screen + print/PDF) */
.pv-bar { margin: 16px 0 6px; }
.pv { margin: 10px 0 30px; padding: 22px 22px 18px; background: var(--paper-2); border: 1px solid var(--edge); border-radius: 8px; box-shadow: 2px 3px 0 var(--shadow); }
.pv-meta { color: var(--ink-soft); font-size: 14px; }
.pv-head h1 { font-size: 28px; margin: 4px 0 14px; padding-bottom: 10px; border-bottom: 2px solid var(--ink); }
.pv-head .grade-tag { font-size: 13px; vertical-align: 6px; }
.pv-block { margin: 0 0 12px; padding: 10px 14px; border-radius: 6px; border-left: 5px solid var(--edge); background: var(--paper); break-inside: avoid; }
.pv-block h3 { font-size: 17px; margin: 0 0 4px; display: flex; gap: 8px; align-items: baseline; letter-spacing: .02em; }
.pv-time { font-family: var(--body); font-weight: 700; font-size: 13px; padding: 1px 8px; border-radius: 10px; background: var(--shadow); color: var(--ink-soft); }
.pv-block p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.pv-block ol { margin: 4px 0 0; padding-left: 22px; }
.pv-block li { margin: 2px 0; }
.pv-intro { font-weight: 700; }
.pv-goal { border-left-color: var(--green); font-size: 18px; }
.pv-bell { border-left-color: var(--tab-1); }
.pv-q { font-size: 18px; }
.pv-answer { margin-top: 6px !important; color: var(--ink-soft); }
.pv-input { border-left-color: var(--tab-4); }
.pv-output { border-left-color: var(--tab-2); }
.pv-exit { border-left-color: var(--red); }
.pv-coach, .pv-challenge { border-left-color: var(--tab-5); }
.pv-materials { border-left-color: var(--pencil); }
.pv-teks { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--edge); font-size: 13px; color: var(--ink-soft); }
.pv-slides { margin: 12px 0 0; }
.pv-slides a { color: var(--link); font-weight: 700; }
@media print {
  @page { margin: 14mm; }
  html, body { background: #fff !important; }
  :root, :root:not([data-theme="light"]), :root[data-theme="dark"] { --paper: #fff !important; --paper-2: #fff !important; --ink: #111 !important; --ink-soft: #444 !important; --edge: #bbb !important; --shadow: #eee !important; --red: #a32d24 !important; --green: #2e6b3c !important; --link: #2b4a80 !important; --pencil: #777 !important; color-scheme: light; }
  .pv-time { background: #eee; color: #333; }
  body { font-size: 12pt; }
  #view { max-width: none; padding: 0; }
  .pv { border: 0; box-shadow: none; padding: 0; margin: 0; }
  .pv-block { background: #fff; border-top: 1px solid #ddd; border-right: 1px solid #ddd; border-bottom: 1px solid #ddd; }
  .tabs, .pv-bar, dialog, .toast { display: none !important; }
}
