/* CurricuManager styles. Plain CSS, no build step. Sections: tokens, base, layout,
   components, forms, plan pages, library pages, lesson board, plan timeline
   (holidays, lost and cancelled lessons), responsive. */

/* ---------- Tokens ---------- */
:root {
  --bg: #f4f6f3;
  --surface: #fff;
  --surface-muted: #f7f9f7;
  --ink: #1f2e29;
  --ink-soft: #3d4f47;
  --muted: #5f6f66;
  --line: #dde5df;
  --line-strong: #c3d1c7;
  --brand: #206c4d;
  --brand-dark: #165138;
  --brand-soft: #e7f4eb;
  --danger: #a12626;
  --danger-soft: #fff0ef;
  --warning-soft: #fff6dc;
  --buffer-soft: #fffbe3;
  --focus: #d28c24;
  /* One colour per reusable item kind, used for badges, dots and card accents. */
  --topic: #2f5f9e;
  --topic-soft: #e8eff9;
  --exercise: #23764b;
  --exercise-soft: #e3f3e8;
  --exam: #74449c;
  --exam-soft: #f1eaf8;
  /* Repeated topics (revisions): orange, distinct from all kind and status colours. */
  --revision: #b45309;
  --revision-soft: #fff3e3;
  /* Lost lessons (public holidays, cancelled lessons): pink. */
  --lost: #9d174d;
  --lost-soft: #fdf2f7;
  --lost-line: #d98fb0;
  --lost-ink: #831843;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgb(20 40 30 / 5%), 0 2px 8px rgb(20 40 30 / 4%);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-size: 16px;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: #176749; text-underline-offset: 3px; }
a:hover { color: var(--brand-dark); }
h1 { font-size: clamp(1.6rem, 2.6vw, 2.2rem); line-height: 1.2; margin: 6px 0 8px; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; line-height: 1.3; }
small { display: block; margin-top: 4px; color: var(--muted); }
summary { cursor: pointer; font-weight: 600; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip, .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.skip:focus { position: static; width: auto; height: auto; clip: auto; padding: 12px; display: block; }
.muted, .helptext { color: var(--muted); font-size: .9rem; }
.lead { color: var(--ink-soft); margin: 0; }
.eyebrow { font-size: .74rem; letter-spacing: .08em; font-weight: 700; color: #557063; margin: 0; display: flex; align-items: center; gap: 6px; }

/* ---------- Layout ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-nav { max-width: 1500px; margin: auto; display: flex; align-items: center; gap: 28px; padding: 12px 32px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; font-weight: 750; text-decoration: none; color: #183f30; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: #fff; font-size: 1rem; }
.nav-links { display: flex; gap: 4px; flex: 1; min-width: 0; }
.nav-links a { padding: 8px 12px; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink-soft); font-weight: 550; white-space: nowrap; }
.nav-links a:hover { background: var(--surface-muted); color: var(--brand-dark); }
.nav-links a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-dark); box-shadow: inset 0 -2px 0 var(--brand); }
.nav-user { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.nav-user form { margin: 0; }
.account { color: var(--muted); font-size: .9rem; }
main { max-width: 1500px; margin: auto; padding: 28px 32px 40px; min-height: 78vh; }
footer { padding: 22px; text-align: center; font-size: .8rem; color: var(--muted); }
.heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin: 4px 0 24px; }
.heading > div:first-child { min-width: 0; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 8px; font-size: .88rem; color: var(--muted); margin-bottom: 14px; }
.breadcrumb [aria-current] { color: var(--ink-soft); font-weight: 600; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }

/* ---------- Components ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.panel > h2:first-child { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.empty { text-align: center; padding: 56px 24px; }
.empty p { max-width: 650px; margin: 16px auto 24px; }
.button, button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--brand); color: #fff; border: 1px solid var(--brand); padding: 9px 16px; border-radius: 7px; text-decoration: none; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.button:hover, button:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.secondary { background: var(--surface); color: var(--brand); border-color: var(--line-strong); }
.secondary:hover { background: var(--brand-soft); color: var(--brand-dark); border-color: #9fbcab; }
.small { padding: 6px 12px; font-size: .88rem; }
button.block { width: 100%; }
button.danger { background: var(--danger); border-color: var(--danger); }
button.danger:hover { background: #801b1b; border-color: #801b1b; }
.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 20px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; background: #edf1ee; color: var(--ink-soft); font-size: .78rem; font-weight: 500; white-space: nowrap; line-height: 1.6; }
.badge-outline { background: transparent; border: 1px solid var(--line-strong); }
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0; }
.status-planned { background: #eef1ef; color: #4b5b53; }
.status-completed { background: #dff1e4; color: #235735; }
.status-review { background: #fff0ca; color: #735315; }
.status-skipped { background: #f3e5e3; color: #824236; }
.status-cancelled { background: #f7deda; color: #812b24; }
.kind-badge.kind-topic { background: var(--topic-soft); color: var(--topic); }
.kind-badge.kind-exercise { background: var(--exercise-soft); color: var(--exercise); }
.kind-badge.kind-exam { background: var(--exam-soft); color: var(--exam); }
.kind-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; flex-shrink: 0; }
.kind-dot.kind-topic { background: var(--topic); }
.kind-dot.kind-exercise { background: var(--exercise); }
.kind-dot.kind-exam { background: var(--exam); }
.notice { padding: 11px 16px; border: 1px solid #a6cbb4; background: var(--brand-soft); border-radius: 8px; margin-bottom: 20px; }
.notice-error { border-color: #e2b4b0; background: var(--danger-soft); color: #7a1f1f; }
.notice-warning { border-color: #ecd49a; background: var(--warning-soft); }
.errorlist { color: var(--danger); background: var(--danger-soft); padding: 8px 12px 8px 28px; border-radius: var(--radius-sm); margin: 8px 0 0; font-size: .9rem; }
.delete-link { color: var(--danger); }
.usage-list { max-height: 260px; overflow: auto; margin: 0 0 12px; padding: 8px 12px 8px 30px; background: var(--surface-muted); border: 1px solid var(--line); border-radius: 8px; font-size: .92rem; }
.danger-zone { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ---------- Forms ---------- */
.form-panel { max-width: 780px; margin: auto; }
.form-panel > h1 { margin-top: 10px; }
.back-link { font-size: .9rem; }
.back-link + .eyebrow { margin-top: 16px; }
.form-intro { background: var(--surface-muted); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; font-size: .92rem; }
.narrow { max-width: 440px; margin: 40px auto; }
.field { margin-bottom: 18px; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: block; font-weight: 600; margin-bottom: 6px; }
.required { color: var(--danger); }
input, select, textarea { font: inherit; padding: 9px 12px; border: 1px solid #a8b9ad; border-radius: var(--radius-sm); width: 100%; background: #fff; color: var(--ink); }
input:hover, select:hover, textarea:hover { border-color: #7f9788; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
textarea { resize: vertical; }
input[type=checkbox] { width: auto; margin: 0 8px 0 0; accent-color: var(--brand); }
.helptext { margin-top: 5px; font-size: .85rem; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.field-check label { display: flex; align-items: center; font-weight: 600; cursor: pointer; }
.form-actions { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.weekday-grid { border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px 6px; margin: 0 0 18px; }
.weekday-grid legend { font-weight: 700; padding: 0 6px; }
.weekday-grid .helptext { margin: 0 0 10px; }
.weekday-options { display: flex; flex-wrap: wrap; gap: 8px 18px; padding-bottom: 10px; }
.weekday-options label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 600; }
.weekday-options input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
.tag-dropdown { position: relative; }
.tag-dropdown > summary { border: 1px solid #a8b9ad; border-radius: var(--radius-sm); padding: 9px 12px; background: #fff; font-weight: 400; overflow-wrap: anywhere; }
.tag-options { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 10; background: #fff; border: 1px solid #a8b9ad; border-radius: var(--radius-sm); padding: 8px; box-shadow: 0 8px 20px rgb(0 0 0 / 14%); max-height: 260px; overflow: auto; }
.tag-options label { display: flex; align-items: center; padding: 5px 6px; margin: 0; font-weight: 400; border-radius: 4px; }
.tag-options label:hover { background: var(--surface-muted); }
.tag-options #id_tags { max-height: 240px; }
#id_tags label { font-weight: 400; }
.form-layout { display: grid; grid-template-columns: minmax(0, 780px) minmax(260px, 380px); gap: 20px; justify-content: center; align-items: start; }
.form-layout .form-panel { margin: 0; width: 100%; }
.info-panel { font-size: .92rem; color: var(--ink-soft); position: sticky; top: 16px; }
.holiday-list h3 { font-size: 1rem; margin: 14px 0 4px; }
.holiday-list ul { margin: 4px 0; padding-left: 20px; }

/* ---------- Plan list and plan detail ---------- */
.plan-card { display: flex; flex-direction: column; padding: 20px 22px; transition: border-color .15s, box-shadow .15s; }
.plan-card:hover { border-color: var(--line-strong); box-shadow: 0 4px 16px rgb(20 40 30 / 8%); }
.plan-card h2 { margin: 6px 0 2px; font-size: 1.35rem; }
.plan-card h2 a { text-decoration: none; }
.plan-card h2 a:hover { text-decoration: underline; }
.plan-card .muted { margin: 6px 0 12px; }
.card-actions { display: flex; gap: 18px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); font-size: .92rem; }
.plan-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 22px; margin: 4px 0 0; color: var(--ink-soft); font-size: .92rem; }
.plan-meta .badge { margin-left: 2px; }
.units { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 18px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.table-wrap table { border-collapse: collapse; width: 100%; min-width: 1150px; text-align: left; }
.table-wrap th, .table-wrap td { padding: 12px 14px; border-bottom: 1px solid #e6ece8; vertical-align: top; }
.table-wrap thead th { position: sticky; top: 0; z-index: 1; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; background: #edf2ee; color: #506257; white-space: nowrap; }
.table-wrap td { font-size: .9rem; }
.table-wrap tbody tr:last-child td { border-bottom: 0; }
.table-wrap tbody tr:hover { background: #f8faf7; }
.lesson-table .seq { color: var(--muted); font-variant-numeric: tabular-nums; }
.prose { white-space: pre-wrap; min-width: 160px; max-width: 340px; overflow-wrap: anywhere; }
.date { white-space: nowrap; }
.title-cell { min-width: 150px; }
.lesson-title { font-weight: 650; overflow-wrap: anywhere; }
.title-cell .badge { margin-left: 6px; vertical-align: 1px; }  /* lesson_row is spaceless */
.table-item { white-space: normal; border-left: 3px solid var(--line-strong); background: var(--surface-muted); border-radius: 4px; padding: 3px 8px; margin: 5px 0; font-size: .85rem; }
.table-item.kind-topic { border-left-color: var(--topic); }
.table-item.kind-exercise { border-left-color: var(--exercise); }
.table-item.kind-exam { border-left-color: var(--exam); }
.table-item.is-revision { border-left: 3px dashed var(--revision); background: var(--revision-soft); }
.revision-badge { background: var(--revision); color: #fff; font-weight: 600; }
.item-details .revision-badge, .table-item .revision-badge { padding: 0 7px; font-size: .7rem; margin-right: 4px; }
.revision-note { margin: 4px 0; font-size: .82rem; color: var(--revision); font-weight: 600; }
.table-item summary { font-weight: 500; }
.table-item[open] summary { font-weight: 650; }
.lesson-status { margin-top: 6px; }

/* ---------- Library pages and tags ---------- */
.filter-panel { padding: 16px 18px; margin-bottom: 18px; }
.library-filter { max-width: 820px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; }
.library-filter .search-filter-row { flex: 1 1 100%; }
.library-filter small { margin: 0; }
.library-filter .tag-dropdown { margin: 0; max-width: none; }
.search-filter-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(180px, 1fr) minmax(160px, 1fr); gap: 16px; align-items: start; }
.search-text-field, .search-tag-field { min-width: 0; }
.filter-label { display: block; font-weight: 600; margin-bottom: 6px; }
.library-list { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; box-shadow: var(--shadow); }
.library-row { display: grid; grid-template-columns: 18px 85px minmax(160px, 1fr) minmax(100px, 1fr) 40px; gap: 12px; align-items: start; padding: 9px 14px; border-bottom: 1px solid #e6ece8; border-left: 3px solid transparent; font-size: .9rem; }
.library-row.kind-topic { border-left-color: var(--topic); }
.library-row.kind-exercise { border-left-color: var(--exercise); }
.library-row.kind-exam { border-left-color: var(--exam); }
.single-kind .library-row { grid-template-columns: 18px minmax(160px, 1fr) minmax(100px, 1fr) 40px; }
.bulk-select { width: 16px; height: 16px; margin: 5px 0 0; accent-color: var(--brand); }
/* Bulk tag editing above the library list (bulk-tags.js). */
.bulk-tags { padding: 12px 18px; margin-bottom: 14px; }
.bulk-tags-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.bulk-tags-row > .bulk-count { flex: 1 0 auto; }
.bulk-tags-row > .tag-dropdown, .bulk-tags-row > .bulk-new-tag { flex: 0 1 190px; min-width: 150px; }
.bulk-count { margin: 0; font-size: .9rem; }
.bulk-tags .tag-dropdown > summary, .bulk-new-tag input { padding: 6px 10px; font-size: .9rem; }
.bulk-new-tag { margin: 0; }
.bulk-new-tag input { width: 100%; }
.results-line .select-all { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; color: var(--ink-soft); }
.results-line .select-all input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand); }
.library-row:last-child { border-bottom: 0; }
.library-row:hover { background: #f8faf7; }
.library-row > .badge { justify-self: start; }
.library-details { min-width: 0; }
.library-details summary { font-weight: 550; overflow-wrap: anywhere; }
.library-details .item-description { font-size: .85rem; }
.library-tags { min-width: 0; }
.library-tags .badge { padding: 1px 8px; font-size: .74rem; white-space: normal; overflow-wrap: anywhere; }
.library-edit { justify-self: end; font-size: .88rem; }
.empty-row { margin: 0; padding: 18px; color: var(--muted); }
.tag-rows { list-style: none; margin: 0; padding: 0; }
.tag-rows li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 4px; border-bottom: 1px solid #edf1ee; }
.tag-rows li:last-child { border-bottom: 0; }
.tag-rows a { font-size: .88rem; }
.item-tags .badge, .item-classes .badge { margin: 1px 0; }
.class-badge { background: #fef3c7; color: #78350f; border: 1px solid #fcd34d; }

/* ---------- Lesson board ---------- */
.board-help { max-width: 900px; margin-top: -8px; }
.teaching-card { border: 1px solid var(--line); border-left: 3px solid var(--line-strong); border-radius: var(--radius-sm); padding: 6px 10px; margin: 5px 0; background: #fff; overflow-wrap: anywhere; font-size: .88rem; }
.teaching-card.kind-topic { border-left-color: var(--topic); }
.teaching-card.kind-exercise { border-left-color: var(--exercise); }
.teaching-card.kind-exam { border-left-color: var(--exam); }
/* Library items already used (in this plan on the board, anywhere on library pages). */
.use-badge { background: #334155; color: #fff; font-weight: 600; }
.item-details .use-badge, .library-details .use-badge { padding: 0 7px; font-size: .7rem; margin-left: 4px; }
.library-box .teaching-card.in-use { background: #f5f7fa; }
.library-row.in-use { background: #fafbfc; }
.teaching-card.is-revision { border-color: #f1c89a; border-left: 3px dashed var(--revision); background: var(--revision-soft); }
.teaching-card[draggable="true"] { cursor: grab; }
.teaching-card[draggable="true"]:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.teaching-card button { margin-top: 10px; }
.item-description { white-space: pre-wrap; overflow-wrap: anywhere; margin: 10px 0; }
.item-details summary { line-height: 1.5; font-weight: 550; }
.item-details .badge { padding: 0 7px; font-size: .7rem; margin-right: 4px; }
.item-details[open] > summary { margin-bottom: 10px; }
.item-details form { padding-top: 6px; }
.drop-active { outline: 3px dashed var(--brand); background: #dceee1; }
/* Where a dragged item will land inside a lesson. */
.teaching-card.insert-before { box-shadow: 0 -3px 0 var(--brand); }
.teaching-card.insert-after { box-shadow: 0 3px 0 var(--brand); }
/* Shown while an assigned item is dragged: drop outside the lessons to remove it. */
.remove-hint { position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); z-index: 50;
  padding: 8px 16px; border-radius: 999px; background: var(--ink); color: #fff; font-size: .88rem; font-weight: 600; box-shadow: 0 6px 18px rgb(0 0 0 / 20%); pointer-events: none; }
.remove-hint .hint-armed, .remove-hint.armed .hint-idle { display: none; }
.remove-hint.armed { background: var(--danger); }
.remove-hint.armed .hint-armed { display: inline; }
.undo-toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); z-index: 50;
  display: flex; align-items: center; gap: 12px; max-width: calc(100% - 32px); padding: 10px 12px 10px 18px; border-radius: 10px;
  background: var(--ink); color: #fff; box-shadow: 0 8px 24px rgb(0 0 0 / 25%); font-size: .9rem; }
.undo-toast .undo-button { background: #fff; color: var(--ink); border-color: #fff; }
.undo-toast .undo-close { background: transparent; border: 0; color: #fff; font-size: 1.2rem; padding: 0 4px; line-height: 1; }
.order-controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.order-controls form { margin: 0; }
.teaching-card .order-controls button { margin-top: 0; }
button:disabled, button:disabled:hover { opacity: .45; cursor: not-allowed; background: var(--surface); color: var(--brand); border-color: var(--line-strong); }

/* Workspace: lesson LIST on the left, sticky library boxes on the right. */
.planning-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.lesson-list { display: flex; flex-direction: column; align-items: stretch; min-width: 0; width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.lesson-list > .lesson-drop { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 16px; width: 100%; min-width: 0; min-height: 0; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none; background: #fff; }
.lesson-list > .lesson-drop:last-child { border-bottom: 0; }
.lesson-list > .lesson-drop.drop-active { outline-offset: -3px; background: #dceee1; }
.lesson-summary { margin: 0; padding: 0; border: 0; }
.lesson-summary h2 { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; font-size: 1rem; margin: 0 0 2px; }
.lesson-summary h2 .badge { flex-shrink: 0; font-size: .72rem; }
.lesson-summary .muted { font-size: .8rem; }
/* Title, tags and a cancellation note flow as one line of text across the whole lesson; the
   summary and the item zones sit side by side below it. */
.lesson-list > .lesson-drop { row-gap: 2px; }
.lesson-drop > .lesson-heading { grid-column: 1 / -1; grid-row: 1; }
.lesson-drop > .lesson-summary { grid-column: 1; grid-row: 2; }
.lesson-drop > .lesson-items { grid-column: 2; grid-row: 2; }
.lesson-heading { display: flex; align-items: baseline; gap: 12px; }
.lesson-heading-main { flex: 1 1 auto; min-width: 0; }
.lesson-heading .lesson-date { flex: 0 0 auto; color: var(--muted); font-size: .85rem; font-weight: 600; white-space: nowrap; }
.lesson-heading h2 { display: inline; margin: 0 8px 0 0; font-size: 1rem; }
.lesson-heading h2 .badge { font-size: .72rem; vertical-align: 2px; }
.lesson-heading .cancelled-note { display: inline; margin: 0; }
.lesson-heading .cancelled-note .badge { vertical-align: 1px; }
.lesson-items { min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.item-zone { min-width: 0; display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.item-zone > .teaching-card { width: 100%; max-width: 100%; margin: 0; flex: 0 0 auto; }
.lesson-items .item-details { width: 100%; min-width: 0; }
.item-zone > .zone-hint { margin: 0; width: 100%; text-align: right; font-size: .85rem; color: #8a988f; font-style: italic; }
/* Homework: exercises to do after the lesson. Empty zones appear only while an exercise is dragged. */
.homework-zone { padding: 6px 8px 8px; border: 1px dashed #b7c7bd; border-radius: 8px; background: #f7faf8; }
.homework-zone.is-empty { display: none; }
.dragging-exercise .homework-zone.is-empty { display: flex; }
.dragging-exercise .lesson-drop.is-lost .homework-zone.is-empty { display: none; }  /* cancelled: accepts nothing */
.homework-zone .zone-label { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--exercise); }
.homework-zone > .zone-hint { text-align: left; }
.item-zone.zone-active { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.homework-item { border-left-style: dotted; }

/* Sidebar: vertically centered as space permits (library-position.js sets --library-height). */
.library-sidebar { position: sticky; top: max(16px, calc((100dvh - var(--library-height, 0px)) / 2)); min-width: 0; max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
.compact-library { padding: 12px 14px; }
.library-box + .library-box { margin-top: 10px; }
.library-box > summary { display: flex; align-items: center; gap: 4px; }
.library-box > summary .box-count { margin-left: auto; }
.library-box[open] > summary { margin-bottom: 8px; }
.library-box[data-kind="topic"] { border-top: 3px solid var(--topic); }
.library-box[data-kind="exercise"] { border-top: 3px solid var(--exercise); }
.library-box[data-kind="exam"] { border-top: 3px solid var(--exam); }
.library-box .box-create { margin: 0 0 8px; font-size: .88rem; }
.library-box .search-filter-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.library-box label, .library-box .filter-label { font-size: .8rem; }
.library-box input[type=search], .library-box .tag-dropdown > summary { padding: 6px 9px; font-size: .9rem; }
.library-box .tag-options { position: static; box-shadow: none; max-height: 180px; margin-top: 4px; }
.library-box .hide-used { display: flex; align-items: center; margin: 8px 0 0; font-size: .82rem; font-weight: 500; cursor: pointer; }
.library-box .box-clear { padding: 3px 8px; margin-top: 8px; font-size: .8rem; }
.library-box .box-items { max-height: 220px; overflow-y: auto; margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.library-box .teaching-card { width: 100%; margin: 0; }
.library-box .box-empty { margin: 4px 0; font-size: .85rem; color: var(--muted); }
.library-box [hidden] { display: none !important; }  /* looks redundant with [hidden] above, but removing it shifts the sidebar layout slightly */

/* ---------- Plan timeline: holidays, lost and cancelled lessons ---------- */
/* Holidays and closures between lessons: striped "no teaching" rows, with the lessons they cost. */
.break-row { --break: #0f766e; --break-soft: #e6f6f3;
  background: repeating-linear-gradient(135deg, var(--break-soft) 0 10px, #fff 10px 20px); color: var(--ink-soft); font-size: .88rem; }
.break-row.break-public { --break: var(--lost); --break-soft: #fcebf2; }
.break-row.break-closure { --break: #57534e; --break-soft: #f0efed; }
.table-wrap tr.break-row td { padding: 7px 14px; border-left: 4px solid var(--break); }
.table-wrap tbody tr.break-row:hover { background: repeating-linear-gradient(135deg, var(--break-soft) 0 10px, #fff 10px 20px); }
.lesson-list > .break-row { padding: 6px 16px; border-bottom: 1px solid var(--line); border-left: 4px solid var(--break); }
.break-badge { background: var(--break); color: #fff; font-weight: 600; font-size: .7rem; padding: 0 7px; margin-right: 4px; }
.break-dates { color: var(--muted); margin-left: 4px; }
.break-cost { color: var(--muted); }
.break-cost.costs { color: var(--ink); font-weight: 600; }
/* Lessons lost to a public holiday (shown on their date) and cancelled lessons: pink, struck through. */
.lost-badge { background: var(--lost); color: #fff; font-weight: 600; font-size: .7rem; padding: 0 7px; }
.lost-title { color: var(--lost); font-weight: 650; text-decoration: line-through; text-decoration-color: var(--lost-line); }
.lost-reason { color: var(--lost-ink); font-size: .85rem; }
.table-wrap tr.lost-lesson-row td { background: var(--lost-soft); color: var(--muted); }
.table-wrap tr.lost-lesson-row td:first-child { box-shadow: inset 4px 0 0 var(--lost); }
.lesson-list > .lost-lesson { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 16px; padding: 12px 16px;
  border-bottom: 1px solid var(--line); background: var(--lost-soft); box-shadow: inset 4px 0 0 var(--lost); }
.lesson-list > .lost-lesson .lost-reason { align-self: center; text-align: right; }
/* Buffer lessons: light yellow (the drop highlight and a cancelled lesson's pink win). */
.table-wrap tr.is-buffer td, .lesson-drop.is-buffer { background: var(--buffer-soft); }
/* Lessons with an exam (lesson table): purple, above buffer yellow; a cancelled lesson's pink wins. */
.table-wrap tr.has-exam td { background: var(--exam-soft); }
.table-wrap tr.has-exam td:first-child { box-shadow: inset 4px 0 0 var(--exam); }
.exam-note { margin-top: 6px; color: var(--exam); font-size: .85rem; overflow-wrap: anywhere; }
.exam-note a { margin-left: 4px; }
.table-wrap tr.status-row-cancelled td { background: var(--lost-soft); }
.table-wrap tr.status-row-cancelled td:first-child { box-shadow: inset 4px 0 0 var(--lost); }
.status-row-cancelled .lesson-title, .lesson-drop.is-lost .lesson-heading h2 a { text-decoration: line-through; text-decoration-color: var(--lost-line); color: var(--lost); }
.lesson-list > .lesson-drop.is-lost { background: var(--lost-soft); box-shadow: inset 4px 0 0 var(--lost); }
.cancelled-note { color: var(--lost-ink); font-size: .82rem; margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .planning-workspace { grid-template-columns: minmax(0, 1fr) 300px; gap: 12px; }
  .lesson-list > .lesson-drop, .lesson-list > .lost-lesson { grid-template-columns: 1fr; gap: 8px; }
  .lesson-list > .lesson-drop > * { grid-column: 1; grid-row: auto; }
  .lesson-list > .lost-lesson .lost-reason { text-align: left; }
  .form-layout { grid-template-columns: minmax(0, 1fr); }
  .info-panel { position: static; }
}
@media (max-width: 760px) {
  main { padding: 20px 16px 32px; }
  .site-nav { flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px 0; }
  .nav-links { order: 3; flex: 1 1 100%; overflow-x: auto; padding-bottom: 6px; margin: 0 -4px; scrollbar-width: none; }
  .nav-links a { padding: 7px 10px; }
  .heading { align-items: flex-start; flex-direction: column; gap: 14px; }
  .panel { padding: 18px; }
  .cards, .split { grid-template-columns: 1fr; }
  .field-pair { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 700px) {
  .planning-workspace { display: flex; flex-direction: column; }
  .library-sidebar { position: static; order: -1; width: 100%; max-height: 45dvh; }
}
@media (max-width: 600px) {
  .search-filter-row { grid-template-columns: 1fr; gap: 10px; }
  .library-row { grid-template-columns: 18px 70px minmax(0, 1fr) 35px; gap: 8px; }
  .library-tags { grid-column: 3; grid-row: 2; }
  .library-edit { grid-column: 4; grid-row: 1; }
  .single-kind .library-row { grid-template-columns: 18px minmax(0, 1fr) 35px; }
  .single-kind .library-tags { grid-column: 2; grid-row: 2; }
  .single-kind .library-edit { grid-column: 3; grid-row: 1; }
  .bulk-tags-row > .tag-dropdown, .bulk-tags-row > .bulk-new-tag { flex: 1 1 100%; }
}

/* Cancel / reinstate a lesson in place (lesson table and board). */
/* Icon-only lesson status buttons (lesson_status_form.html); the label is in aria-label/title. */
.icon-button { width: 32px; height: 32px; padding: 0; }
.icon-button .icon { display: block; }
.cancel-open { color: var(--lost-ink); }
.cancel-open:hover { color: #fff; background: var(--lost); border-color: var(--lost); }
.buffer-toggle[aria-pressed=true] { background: #fef3c7; color: #92400e; border-color: #f59e0b; }
.buffer-toggle[aria-pressed=true]:hover { background: #fde68a; color: #78350f; border-color: #d97706; }
.cancel-dialog { width: min(440px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 40px rgb(20 40 30 / 25%); color: var(--ink); }
.cancel-dialog::backdrop { background: rgb(20 40 30 / 35%); }
.cancel-dialog > form { margin: 0; padding: 20px; gap: 10px; }
.cancel-dialog h2 { flex-basis: 100%; margin: 0 0 4px; font-size: 1.1rem; }
.cancel-dialog label[for] { flex-basis: 100%; }
.cancel-dialog .actions { flex-basis: 100%; justify-content: flex-end; margin-top: 6px; }
.lesson-status-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.lesson-status-form label { font-size: .8rem; font-weight: 600; }
.lesson-status-form input[type=text] { flex: 1 1 10rem; min-width: 0; padding: 5px 8px; font-size: .85rem; }
.lesson-status-actions { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.lesson-status-actions > .lesson-status-form { margin-top: 0; }
.shift-option { display: flex; align-items: center; gap: 6px; font-weight: 500 !important; }
.shift-preview { flex-basis: 100%; margin: 0; color: var(--ink-soft); font-size: .8rem; }
.buffer-badge { background: #e0f2fe; color: #075985; border: 1px solid #7dd3fc; font-size: .7rem; padding: 0 7px; }
