:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.08);
  --fill: rgba(118, 118, 128, 0.12);
  --accent: #0071e3;
  --accent-press: #0062c4;
  --danger: #ff3b30;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --radius: 18px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #f5f5f7;
    --muted: #98989d;
    --line: rgba(255, 255, 255, 0.1);
    --fill: rgba(118, 118, 128, 0.24);
    --accent: #0a84ff;
    --accent-press: #409cff;
    --danger: #ff453a;
    --shadow: none;
  }
  :root .segmented button.on { background: #636366; }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.47;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---- top bar ---------------------------------------------------------- */
.bar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  height: 52px; padding: 0 max(20px, calc((100vw - 1080px) / 2));
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--text); font-weight: 600; font-size: 19px; letter-spacing: -0.02em; }
.bar nav { flex: 1; display: flex; gap: 20px; }
.bar nav a { color: var(--muted); font-size: 14px; }
.bar nav a.on { color: var(--text); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
}
.menu {
  position: absolute; right: max(20px, calc((100vw - 1080px) / 2)); top: 48px;
  min-width: 240px; padding: 6px; border-radius: 14px;
  background: var(--card); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  border: 1px solid var(--line);
}
.menu-head { display: flex; flex-direction: column; padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-head span { color: var(--muted); font-size: 13px; }
.menu button {
  display: block; width: 100%; text-align: left; padding: 9px 12px;
  border: 0; border-radius: 8px; background: none; cursor: pointer; font-size: 15px;
}
.menu button:hover { background: var(--fill); }
.danger { color: var(--danger); }

/* ---- layout ----------------------------------------------------------- */
main { max-width: 1080px; margin: 0 auto; padding: 32px 20px 80px; }
.large-title { font-size: 40px; line-height: 1.1; font-weight: 700; letter-spacing: -0.025em; margin: 8px 0 6px; }
.subtitle { color: var(--muted); font-size: 19px; margin: 0 0 28px; }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 15px; margin-bottom: 8px; }
.section-title { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; margin: 36px 0 12px; }
.muted { color: var(--muted); }
.center { text-align: center; padding: 60px 0; color: var(--muted); }

/* ---- controls --------------------------------------------------------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 24px; }
.segmented {
  display: inline-flex; padding: 2px; border-radius: 10px; background: var(--fill);
  overflow-x: auto; max-width: 100%; scrollbar-width: none;
}
.segmented button {
  border: 0; background: none; padding: 6px 14px; border-radius: 8px;
  font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; color: var(--text);
}
.segmented button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
.search {
  flex: 1; min-width: 200px; height: 36px; padding: 0 12px 0 34px; border-radius: 10px;
  border: 0; background: var(--fill) no-repeat 11px center / 15px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238e8e93' stroke-width='1.8'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 3.5 3.5' stroke-linecap='round'/%3E%3C/svg%3E");
  outline: none; font-size: 15px;
}
.search:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; padding: 0 22px; border-radius: 980px; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 17px; font-weight: 500;
}
.btn:hover { background: var(--accent-press); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.secondary { background: var(--fill); color: var(--text); }
.btn.small { height: 34px; padding: 0 16px; font-size: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 500; }
.input {
  height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); outline: none; font-size: 17px;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.error { color: var(--danger); font-size: 14px; min-height: 20px; }

/* ---- login ------------------------------------------------------------ */
.login { min-height: calc(100vh - 112px); display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 380px; padding: 40px 32px 32px; border-radius: 24px;
  background: var(--card); box-shadow: var(--shadow); text-align: center;
}
.login-card .logo {
  width: 64px; height: 64px; margin: 0 auto 18px; border-radius: 16px;
  display: grid; place-items: center; font-size: 30px;
  background: linear-gradient(135deg, #34c759, #0a84ff); color: #fff;
}
.login-card h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 6px; }
.login-card p { margin: 0 0 26px; color: var(--muted); }
.login-card form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.login-card .btn { margin-top: 8px; width: 100%; }

/* ---- book grid -------------------------------------------------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 22px; }
.book {
  display: flex; flex-direction: column; border-radius: var(--radius); overflow: hidden;
  background: var(--card); box-shadow: var(--shadow); color: var(--text);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.book:hover { transform: translateY(-3px) scale(1.01); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12); }
.cover {
  position: relative; aspect-ratio: 3 / 4; display: flex; flex-direction: column; justify-content: space-between;
  padding: 16px; color: #fff; overflow: hidden;
}
.cover img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  background: var(--card);
}
.cover .grade { font-size: 13px; font-weight: 600; opacity: 0.9; }
.cover .glyph { font-size: 44px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.book .meta { padding: 14px 16px 16px; }
.book .name { font-weight: 600; font-size: 16px; line-height: 1.3; }
.book .pages { color: var(--muted); font-size: 13px; margin-top: 4px; }
.book .pages.warn, .grade-table .warn { color: #ff9f0a; font-weight: 600; }

/* ---- book page -------------------------------------------------------- */
.hero { display: flex; gap: 28px; align-items: center; margin-bottom: 8px; }
.hero .cover { width: 140px; flex: none; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18); }
.hero .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px;
  border-bottom: 1px solid var(--line); cursor: pointer; color: var(--text);
}
.row:last-child { border-bottom: 0; }
.row:hover { background: color-mix(in srgb, var(--fill) 50%, transparent); }
.row .main { flex: 1; min-width: 0; }
.row .title { font-size: 16px; }
.row.unit .title { font-weight: 600; }
.row.child { padding-left: 38px; }
.row .detail { color: var(--muted); font-size: 13px; margin-top: 2px; }
.row .chev { color: var(--muted); font-size: 20px; }
.pill {
  flex: none; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 980px;
  background: var(--fill); color: var(--muted);
}

/* ---- plan ------------------------------------------------------------- */
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.check { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-size: 15px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.holidays { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.holiday { display: grid; grid-template-columns: 1fr 140px 140px 120px 36px; gap: 8px; align-items: center; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--fill); cursor: pointer; font-size: 18px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 24px 0; }
.stat { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 16px; }
.stat b { display: block; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: 13px; }
.banner { padding: 14px 18px; border-radius: 14px; margin: 16px 0; font-size: 15px; }
.banner.warn { background: color-mix(in srgb, #ff9f0a 16%, var(--card)); }
.banner.ok { background: color-mix(in srgb, #34c759 14%, var(--card)); }
.month { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 26px 0 8px 4px; }
.plan-row { display: grid; grid-template-columns: 130px 1fr auto; gap: 16px; align-items: center; cursor: default; }
.plan-row .dates { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); }

/* ---- sheet (reader, dialogs) ------------------------------------------ */
dialog {
  border: 0; padding: 0; border-radius: 22px; background: var(--card); color: var(--text);
  width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 64px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.35); backdrop-filter: blur(4px); }
.sheet { padding: 28px; overflow: auto; max-height: calc(100vh - 64px); }
.sheet-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 24px; letter-spacing: -0.02em; }
.page-text { white-space: pre-wrap; font-size: 16px; line-height: 1.65; }
.page-text h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 28px 0 8px; border-top: 1px solid var(--line); padding-top: 18px; }
.page-text h3:first-child { margin-top: 0; border: 0; padding-top: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.spinner {
  width: 28px; height: 28px; margin: 60px auto; border-radius: 50%;
  border: 3px solid var(--fill); border-top-color: var(--accent); animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .large-title { font-size: 32px; }
  .hero { flex-direction: column; align-items: flex-start; }
  .holiday { grid-template-columns: 1fr 1fr; }
  .holiday input:first-child { grid-column: 1 / -1; }
  .plan-row { grid-template-columns: 1fr auto; }
  .plan-row .dates { grid-column: 1 / -1; }
}

@media print {
  .bar, .no-print, .toolbar, .back { display: none !important; }
  body { background: #fff; color: #000; font-size: 12px; }
  main { padding: 0; max-width: none; }
  .list, .panel, .stat { box-shadow: none; border: 1px solid #ddd; }
  .row { break-inside: avoid; }
}

/* ---- teaching material ------------------------------------------------ */
.makers { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.maker {
  display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow); color: var(--text);
  transition: transform 0.2s ease;
}
.maker:hover { transform: translateY(-2px); }
.maker b { display: block; font-size: 15px; font-weight: 600; }
.maker small { color: var(--muted); font-size: 13px; }
.maker-icon { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; }
.topic-picks {
  max-height: 320px; overflow: auto; margin-top: 8px; border: 1px solid var(--line); border-radius: 12px;
}
.pick { display: flex; gap: 12px; align-items: flex-start; padding: 11px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.pick:last-child { border-bottom: 0; }
.pick.child { padding-left: 38px; }
.pick input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.pick small { display: block; color: var(--muted); font-size: 12px; }
.textarea { height: auto; padding: 10px 14px; resize: vertical; font-size: 15px; }
.generating { text-align: center; color: var(--muted); padding: 48px 0; }
.doc-actions { display: flex; align-items: center; gap: 12px; margin: 28px 0 12px; }

.paper {
  background: #fff; color: #1d1d1f; border-radius: 6px; padding: 56px 64px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06), 0 18px 48px rgba(0, 0, 0, 0.12);
  font-size: 15px; line-height: 1.6; max-width: 820px; margin: 0 auto;
}
.paper-head { text-align: center; margin-bottom: 26px; }
.paper-head h2 { font-size: 24px; letter-spacing: -0.01em; margin: 6px 0; }
.paper-meta { color: #6e6e73; font-size: 13px; }
.paper h3 { font-size: 15px; margin: 22px 0 6px; }
.paper p, .paper ul { margin: 4px 0; }
.paper ul { padding-left: 22px; }
.paper table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 6px; }
.paper th, .paper td { border: 1px solid #d2d2d7; padding: 8px 10px; vertical-align: top; text-align: left; }
.paper th { background: #f5f5f7; font-weight: 600; }
/* A stage's numbered steps come one per line. */
.paper table.stages td { white-space: pre-line; }
.paper .board { border: 1px solid #d2d2d7; background: #fbfbfd; padding: 10px 14px; border-radius: 8px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; white-space: pre-line; }
.paper small { color: #6e6e73; }
.student-line { display: flex; flex-wrap: wrap; gap: 8px 24px; font-size: 14px; margin: 0 0 18px; }
.instructions { background: #f5f5f7; border-radius: 8px; padding: 10px 14px; }
.questions { padding-left: 24px; }
.questions li { margin: 12px 0; break-inside: avoid; }
.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 20px; margin-top: 4px; }
.write-line { border-bottom: 1px solid #c7c7cc; height: 28px; }
.write-space { border: 1px solid #d2d2d7; border-radius: 6px; height: 110px; margin-top: 6px; }
.pts, .pg, .lvl { color: #6e6e73; font-size: 12px; }
.lvl { border: 1px solid #d2d2d7; border-radius: 980px; padding: 0 7px; }
.answer { color: #0a7d32; font-size: 14px; margin-top: 4px; }
.key { border-top: 2px dashed #d2d2d7; margin-top: 28px; padding-top: 6px; }
.keytable td:first-child { width: 48px; text-align: center; }
.hide-answers .answer { display: none; }
.source { color: #8e8e93; font-size: 12px; margin-top: 28px !important; border-top: 1px solid #e5e5ea; padding-top: 10px; }

@media (max-width: 640px) {
  .paper { padding: 28px 20px; }
  .options { grid-template-columns: 1fr; }
}
@media print {
  @page { size: A4; margin: 16mm; }
  .no-print, .doc-actions, #make-form, .large-title, .subtitle { display: none !important; }
  .paper { box-shadow: none; padding: 0; max-width: none; border-radius: 0; font-size: 12pt; }
  .paper .key { break-before: page; }
}

/* ---- school: assignments, people, materials ---------------------------- */
.title-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.title-row .btn { margin-bottom: 28px; }
.empty { padding: 36px 24px; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); color: var(--muted); text-align: center; }
.empty.small { padding: 22px; }
.kind-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; }
.danger-text { color: var(--danger) !important; }
.small-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 16px; }
.small-grid .book .name { font-size: 14px; }
.avatar.small { flex: none; width: 36px; height: 36px; font-size: 15px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; }
.pill-blue { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.credential { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--fill); margin: 12px 0; }
.credential code { flex: 1; font-size: 18px; letter-spacing: 0.04em; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; word-break: break-all; }
.small-text { font-size: 13px; }
button.row.action { width: 100%; border: 0; background: none; text-align: left; font-size: 16px; justify-content: space-between; }
button.row.action.danger { color: var(--danger); }
.plan-doc { max-width: 900px; }
.paper.editing { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 4px; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238e8e93' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; background-size: 12px; padding-right: 36px; }
@media print {
  .title-row, .doc-actions { display: none !important; }
  .plan-doc .stat { border: 1px solid #ddd; }
}

/* ---- curriculum --------------------------------------------------------- */
.programme { display: flex; flex-direction: column; gap: 10px; }
.unit { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.unit summary { display: flex; align-items: center; gap: 10px; padding: 14px 18px; cursor: pointer; list-style: none; }
.unit summary::-webkit-details-marker { display: none; }
.unit summary::before { content: "›"; color: var(--muted); transition: transform 0.2s ease; font-size: 18px; }
.unit[open] summary::before { transform: rotate(90deg); }
.unit-title { flex: 1; font-weight: 600; font-size: 15px; }
.lessons { margin: 0; padding: 4px 22px 16px 46px; }
.lessons li { margin: 10px 0; }
.lessons b { font-size: 14px; font-weight: 600; }
.lessons p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.pick-unit { padding: 10px 14px 6px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; background: var(--fill); }
.objective { color: var(--muted); font-size: 12.5px; margin-top: 4px; line-height: 1.45; }
.page-link { border: 0; background: var(--fill); color: var(--accent); border-radius: 980px; font-size: 12px; padding: 2px 9px; margin-left: 6px; cursor: pointer; }
.pg-tag { font-style: normal; color: var(--accent); font-size: 12px; }

/* ---- plan rows: book and lesson plan ---------------------------------------- */
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 0; border-radius: 980px; padding: 5px 12px; font-size: 13px; cursor: pointer; background: var(--fill); color: var(--text); }
.chip.primary { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.chip.done { background: color-mix(in srgb, #34c759 16%, transparent); color: #248a3d; }
.chip:disabled { opacity: 0.6; cursor: default; }
.plan-row { align-items: flex-start; }
.page-figure { margin: 14px 0; }
.page-figure img { max-width: 100%; border-radius: 10px; background: #fff; }
.page-figure figcaption { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ---- simpler assignment page -------------------------------------------- */
.hero.compact { gap: 20px; }
.hero.compact .cover { width: 84px; border-radius: 10px; padding: 8px; }
.hero.compact .cover .glyph { font-size: 26px; }
.hero.compact .large-title { font-size: 32px; }
.steps { list-style: none; padding: 0; margin: 22px 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.steps li { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); }
.steps li > span { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 700; background: var(--fill); color: var(--muted); }
.steps li.done > span { background: #34c759; color: #fff; font-size: 0; }
.steps li.done > span::after { content: "✓"; font-size: 15px; }
.steps li.current { outline: 2px solid var(--accent); }
.steps li.current > span { background: var(--accent); color: #fff; }
.steps li div { flex: 1; min-width: 0; }
.steps li b { display: block; font-size: 15px; }
.steps li small { color: var(--muted); font-size: 13px; }
.link { border: 0; background: none; color: var(--accent); font-size: 15px; cursor: pointer; padding: 0; white-space: nowrap; }
.tabs { margin-bottom: 18px; }
.danger-zone { margin-top: 48px; text-align: center; }
.plan-row.now { background: color-mix(in srgb, var(--accent) 7%, var(--card)); }
.now-tag { display: block; font-style: normal; font-size: 11px; font-weight: 600; color: var(--accent); margin-top: 2px; }
/* ---- year plan as a month calendar ---------------------------------------- */
.cal-head { display: flex; align-items: center; gap: 10px; margin: 18px 0 10px; }
.cal-head b { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; min-width: 170px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(5, 1fr) repeat(2, 0.55fr); gap: 1px; background: var(--line);
  border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.cal-wd { background: var(--card); padding: 8px 0; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); }
.cal-day { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 3px; min-height: 92px; min-width: 0;
  padding: 6px; border: 0; background: var(--card); color: var(--text); text-align: left; cursor: pointer; font: inherit; }
.cal-day:hover { background: color-mix(in srgb, var(--accent) 5%, var(--card)); }
.cal-day.other { color: var(--muted); background: color-mix(in srgb, var(--fill) 50%, var(--card)); }
.cal-day.other .cal-ev { opacity: 0.55; }
.cal-day.weekend, .cal-day.off { background: color-mix(in srgb, var(--fill) 70%, var(--card)); }
.cal-day.on { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-num { align-self: flex-start; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-size: 13px; font-weight: 600; }
.cal-day.today .cal-num { background: var(--accent); color: #fff; }
.cal-ev { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 11.5px; line-height: 1.35;
  padding: 1px 6px; border-radius: 5px; background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--accent); }
.cal-ev.review { background: color-mix(in srgb, #5e5ce6 14%, transparent); color: #5e5ce6; }
.cal-off { font-size: 11px; color: var(--muted); line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cal-more { font-size: 11px; color: var(--muted); padding-left: 6px; }
.cal-dot { display: none; }
@media (max-width: 700px) {
  .cal-grid { grid-template-columns: repeat(7, 1fr); }
  .cal-day { min-height: 54px; align-items: center; padding: 4px 2px; }
  .cal-num { align-self: center; }
  .cal-ev, .cal-more, .cal-off { display: none; }
  .cal-dot { display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
    font-size: 11px; font-weight: 600; background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); }
  .cal-head b { min-width: 0; font-size: 17px; }
}
details.fold { margin-top: 14px; }
details.fold > summary { cursor: pointer; color: var(--accent); font-size: 15px; padding: 6px 0; }
.pick-group > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 14px; cursor: pointer; background: var(--fill); border-bottom: 1px solid var(--line); list-style: none; }
.pick-group > summary::-webkit-details-marker { display: none; }
.pick-unit-check { display: flex; gap: 10px; align-items: center; font-weight: 600; font-size: 14px; }
.pick-unit-check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---- print: always light paper ------------------------------------------ */
.print-only { display: none; }
@media print {
  /* A dark-mode device would otherwise print its dark palette: near-white
     text that, with background graphics off, lands on white paper unseen. */
  :root {
    --bg: #fff; --card: #fff; --text: #1d1d1f; --muted: #555; --line: #ccc;
    --fill: #eee; --accent: #0060c0; --shadow: none; color-scheme: light;
  }
  html, body { background: #fff !important; color: #000 !important; }
  .hero, .steps, .tabs, .danger-zone, .row-actions, .now-tag, .doc-actions { display: none !important; }
  .print-only { display: block; }
  .list, .stat, .banner, .plan-row.now, .unit { background: #fff !important; }
  .row, .plan-row { break-inside: avoid; }
}

/* ---- slide deck preview ------------------------------------------------- */
.deck { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.slide { aspect-ratio: 16 / 9; overflow: auto; background: #fff; color: #1d1d1f; border-radius: 10px; padding: 16px 18px 16px 22px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12); border-left: 6px solid #0071e3; font-size: 13px; }
.slide.first { background: #0071e3; color: #fff; border-left-color: #0071e3; display: flex; flex-direction: column; justify-content: center; text-align: center; }
.slide h3 { margin: 0 0 8px; font-size: 16px; }
.slide ul { margin: 0; padding-left: 18px; }
.slide .notes { color: #6e6e73; font-size: 11.5px; border-top: 1px dashed #d2d2d7; margin-top: 8px; padding-top: 6px; }

/* Moodle */
.pupil-form { display: grid; grid-template-columns: 2fr 1fr 1.5fr auto; gap: 8px; margin: 8px 0; }
@media (max-width: 640px) { .pupil-form { grid-template-columns: 1fr; } }
.table-wrap { overflow-x: auto; }
.grade-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.grade-table th, .grade-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: center; }
.grade-table th:first-child, .grade-table td:first-child { text-align: left; }

/* hours a week, and the days, as cards */
.pick-cards { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.pick-card { min-width: 64px; padding: 10px 12px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--card);
  color: var(--text); display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; font: inherit; }
.pick-card b { font-size: 20px; font-weight: 600; }
.pick-card.day { min-width: 86px; }
.pick-card.day b { font-size: 15px; }
.pick-card small { color: var(--muted); font-size: 12px; min-height: 1em; }
.pick-card.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
.pick-card.on small { color: var(--accent); font-weight: 600; }
.pick-other { width: 84px; }

/* ---- phones ---------------------------------------------------------------
   Nothing may widen the page: rows of controls wrap or scroll inside
   themselves, and the page never scrolls sideways. */
.toolbar > * { max-width: 100%; min-width: 0; }
#grade-box:not([hidden]) { display: flex; }
.doc-actions { flex-wrap: wrap; }
.btn { white-space: nowrap; }
@media screen and (max-width: 640px) {
  main { padding: 20px 16px 64px; }
  .paper { overflow-x: auto; }
  .large-title { font-size: 28px; }
  .bar { gap: 14px; padding: 0 16px; }
  .brand { flex: none; max-width: 32vw; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .bar nav { min-width: 0; gap: 14px; overflow-x: auto; scrollbar-width: none; }
  .bar nav a { white-space: nowrap; }
  .avatar { flex: none; }
  .title-row .btn { margin-bottom: 16px; }
  .doc-actions { gap: 8px; margin: 20px 0 12px; }
  .doc-actions > span[style*="flex:1"] { display: none; }
  .doc-actions > .muted { flex-basis: 100%; }
  .paper { padding: 24px 16px; }
  #source { flex-direction: column; width: 100%; }
  #source button { white-space: normal; text-align: left; }
  .holiday { grid-template-columns: 1fr 1fr 36px; }
  .holiday input { min-width: 0; width: 100%; }
  #per-week { display: grid; grid-template-columns: repeat(6, 1fr); }
  #per-week .pick-other { grid-column: 1 / -1; width: 100%; }
  #days { display: grid; grid-template-columns: repeat(5, 1fr); }
  .pick-card, .pick-card.day { min-width: 0; padding: 10px 2px; }
  .pick-card.day b { font-size: 14px; }
  .makers { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
  dialog { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 22px 22px 0 0; max-height: 92vh; }
  .sheet { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; }
}

.year-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px; margin-bottom: 16px; border-radius: 12px; background: var(--fill); font-size: 15px; }
.late-tag { display: block; font-style: normal; font-size: 11px; font-weight: 600; color: #ff9f0a; }
.chip.unit, .unit-actions .chip.done { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.unit { background: color-mix(in srgb, #5e5ce6 16%, var(--card)); color: #5e5ce6; font-weight: 600; }
.unit-actions { margin: 2px 0 6px; }

/* AI use */
.meter { height: 6px; border-radius: 3px; background: var(--fill); margin-top: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 3px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding: 12px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); overflow-x: auto; }
.bars .bar { flex: 1 0 14px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.bars .bar i { display: block; width: 100%; border-radius: 4px 4px 0 0; background: var(--accent); }
.bars .bar small { font-size: 10px; color: var(--muted); }
.ai-left { margin: 8px 0 0; }
.objective.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
@media print { .objective.clamp { display: block; -webkit-line-clamp: unset; } }

/* The manager's overview: a hundred teachers in one table. */
.title-row .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.dash-table td, .dash-table th { white-space: nowrap; }
.dash-table tr.clickable { cursor: pointer; }
.dash-table tr.clickable:hover td { background: var(--fill); }
.dash-table .warn { color: #ff9f0a; font-weight: 600; }
.dash-table .ok { color: #34c759; font-weight: 600; }
#bulk-text { width: 100%; font-family: ui-monospace, monospace; font-size: 13px; resize: vertical; }

/* A teacher's week: one row per lesson, under its day. */
.week-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.week-head .section-title .muted { font-weight: 400; font-size: 15px; }
.month.today { color: var(--accent); }
.class-tag { display: inline-block; color: #fff; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 6px; margin-right: 6px; vertical-align: 1px; white-space: nowrap; }
.week-lesson { cursor: default; }

/* ---- dashboard shell: a sidebar on wide screens ------------------------- */
#nav a { display: inline-flex; align-items: center; gap: 8px; }
#nav svg { width: 18px; height: 18px; flex: none; }
#avatar .me-name { display: none; }
.stat { position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--stat, var(--accent)); }
.stat:nth-child(6n + 2) { --stat: #34c759; }
.stat:nth-child(6n + 3) { --stat: #ff9f0a; }
.stat:nth-child(6n + 4) { --stat: #af52de; }
.stat:nth-child(6n + 5) { --stat: #ff375f; }
.stat:nth-child(6n + 6) { --stat: #64d2ff; }
@media screen and (min-width: 960px) {
  body:has(#bar:not([hidden])) { padding-left: 240px; }
  body:has(#bar:not([hidden])) main { max-width: 1240px; padding: 36px 40px 80px; }
  #bar {
    position: fixed; inset: 0 auto 0 0; width: 240px; height: auto;
    flex-direction: column; align-items: stretch; gap: 0; padding: 22px 12px 14px;
    background: var(--card); border-bottom: 0; border-right: 1px solid var(--line);
    backdrop-filter: none; -webkit-backdrop-filter: none;
  }
  #bar .brand { padding: 0 12px 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #bar nav { flex-direction: column; gap: 2px; }
  #bar nav a { display: flex; padding: 9px 12px; border-radius: 10px; font-size: 15px; color: var(--text); }
  #bar nav a svg { color: var(--muted); }
  #bar nav a:hover { background: var(--fill); }
  #bar nav a.on { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 600; }
  #bar nav a.on svg { color: var(--accent); }
  #avatar {
    display: flex; align-items: center; gap: 10px; width: 100%; height: auto; padding: 8px;
    border-radius: 12px; background: none; color: var(--text); text-align: left; font-weight: 500;
  }
  #avatar:hover { background: var(--fill); }
  #avatar .initial {
    flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
    background: var(--accent); color: #fff; font-weight: 600;
  }
  #avatar .me-name { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
  #menu { position: fixed; top: auto; right: auto; left: 12px; bottom: 66px; }
}
@media screen and (max-width: 640px) {
  #nav a span { display: none; }
  #nav a.on svg { color: var(--accent); }
}
.price-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.price { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); }
.price span { font-size: 13px; color: var(--muted); }
.price b { font-size: 18px; }
.lesson-note { color: var(--text); background: var(--fill); border-radius: 8px; padding: 6px 10px; margin-top: 6px; }
.week-head .btn { margin-left: auto; }
.cover-lesson { margin-bottom: 24px; }
@media print { .cover-lesson { break-after: page; margin: 0; } }
.class-list { display: flex; flex-direction: column; gap: 8px; }
.class-row { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; padding: 10px 14px; border-radius: 12px; background: var(--fill); }
.class-row .check { min-width: 110px; }
.pick-cards.compact { flex-basis: 100%; gap: 6px; align-items: center; }
.pick-cards.compact .pick-card { min-width: 72px; padding: 6px 10px; }
.class-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 10px; }
.course-card .meta { display: flex; flex-direction: column; }
.results { margin: 8px 0 28px; display: flex; flex-direction: column; gap: 12px; }
.results-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.results .stats { margin: 0; }
.sub-title { font-size: 17px; font-weight: 600; margin: 12px 0 0; }
.level-bars { display: flex; align-items: flex-end; gap: 4px; height: 54px; margin-top: 6px; }
.level-bars > div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; gap: 2px; }
.level-bars i { display: block; width: 100%; min-height: 2px; border-radius: 3px 3px 0 0; background: var(--accent); }
.level-bars small { font-size: 10px; color: var(--muted); }
.remedial-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.remedial { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.remedial-top { display: flex; gap: 8px; align-items: center; justify-content: space-between; width: 100%; }
.remedial .names { color: var(--text); }
tr.behind td:first-child { color: var(--danger); font-weight: 600; }
.results .grade-table td:last-child, .results .grade-table th:last-child { text-align: left; }
