:root {
  --ink: #00214e;
  --canvas: #f8fafc;
  --char: #00214e;
  --char-2: #24548a;
  --bar: 80px;
  --sidebar: #edf4fc;
  --blue: #0052cc;
  --line: #d8dde6;
  --muted: #4b5563;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  writing-mode: horizontal-tb;
}

body { min-height: 100vh; }

a { color: var(--blue); }

img { max-width: 100%; height: auto; object-fit: contain; }

button, input, textarea { font: inherit; color: var(--ink); }

.top {
  position: fixed;
  z-index: 30;
  top: 0;
  left: 0;
  right: 0;
  height: var(--bar);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0 0.9rem;
  background: var(--char);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  flex-shrink: 0;
  min-width: 64px;
}

.brand span { white-space: nowrap; }

.logo { height: 64px; width: auto; max-width: none; flex: 0 0 auto; display: block; }

.search { display: flex; gap: 0.35rem; margin-left: auto; }

.search input {
  width: min(280px, 28vw);
  border: 0;
  border-radius: 6px;
  padding: 0.4rem 0.65rem;
  background: #fff;
}

.search button, .primary, .toolbar button, .clip, .ghost {
  border: 0;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
}

.ghost { background: transparent; color: #fff; border: 1px solid #8ea0bd; }
.sheet .ghost, .sheet .linkish { color: var(--char); border-color: #94a3b8; }

.top-links { display: flex; gap: 0.65rem; align-items: center; }
.top-links a { color: #fff; font-size: 0.82rem; font-weight: 700; text-decoration: none; }
.top-links a:hover { color: #d6e6ff; }
.who { color: #fff; font-size: 0.82rem; font-weight: 700; white-space: nowrap; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; }
.signout { margin: 0; }
.signout .ghost { padding: 0.35rem 0.6rem; }

.meter { width: 132px; flex: 0 0 auto; }

.meter-bar {
  height: 6px;
  background: var(--char-2);
  border-radius: 99px;
  overflow: hidden;
}

.meter-bar span { display: block; height: 100%; width: 0; background: var(--blue); }

.meter p { margin: 0.15rem 0 0; font-size: 0.75rem; color: #fff; }

#menu-btn {
  display: none;
  background: transparent;
  color: #fff;
  border: 1px solid #8ea0bd;
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
}

.side {
  position: fixed;
  z-index: 25;
  top: var(--bar);
  left: 0;
  bottom: 0;
  width: 300px;
  background: var(--sidebar);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  border-right: 1px solid #d3e3f5;
}

.tabs { display: flex; border-bottom: 1px solid #d3e3f5; }

.tabs button {
  flex: 1;
  background: transparent;
  color: #334155;
  border: 0;
  border-bottom: 3px solid transparent;
  padding: 0.75rem 0.4rem;
  cursor: pointer;
  font-weight: 700;
}

.tabs button.on { color: var(--blue); border-bottom-color: var(--blue); }

.side-admin {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  padding: 0.55rem 0.85rem 0.45rem;
  background: #edf4fc;
  border-bottom: 1px solid #d3e3f5;
}
.side-admin a { color: #00214e; font-size: 0.82rem; font-weight: 700; text-decoration: none; }
.side-admin a:hover { color: #0052cc; }
.side-scroll { overflow: auto; padding-bottom: 2rem; }

.course-toggle {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  margin: 0;
  padding: 0.85rem 0.9rem;
  background: #d7e7f8;
  color: #00214e;
  border: 0;
  border-bottom: 1px solid #c5d9ef;
  cursor: pointer;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.3;
  text-align: left;
}

.folder-head { display: flex; align-items: stretch; }
.folder-head > .course-toggle,
.folder-head > .mod-toggle { flex: 1; width: auto; min-width: 0; }
.rename-pencil {
  flex: 0 0 auto;
  width: 2rem;
  border: 0;
  background: transparent;
  color: #0052cc;
  cursor: pointer;
  padding: 0;
}
.course-head .rename-pencil { background: #d7e7f8; border-bottom: 1px solid #c5d9ef; }
.nav-rename {
  flex: 1;
  min-width: 0;
  margin: 0.35rem 0.2rem;
  padding: 0.25rem 0.4rem;
  border: 1px solid #0052cc;
  border-radius: 4px;
  background: #fff;
  color: #00214e;
  font: inherit;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
}
.course-nav.open > .folder-head > .course-toggle { color: var(--blue); }
.course-nav.open > .folder-head > .course-toggle .chev { transform: rotate(-135deg); margin-top: 0.2rem; }

.course-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.22s ease;
}

.course-nav.open > .course-panel { grid-template-rows: 1fr; }
.course-panel-inner { overflow: hidden; }

.course-block { margin: 1.8rem 0 0.2rem; }
.course-block > h2 { margin: 0 0 0.35rem; color: #00214e; font-size: 1.35rem; }
.mod-block h3 { margin: 0 0 0.4rem; color: var(--blue); font-size: 1.05rem; }

.mod-link {
  display: block;
  margin: 0;
  padding: 0.75rem 1rem;
  color: #00214e;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
}

.mod-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin: 0;
  padding: 0.75rem 1rem;
  background: transparent;
  color: #00214e;
  border: 0;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
}

.mod-nav.open > .folder-head > .mod-toggle,
.mod-nav.open > .mod-head .mod-link {
  color: var(--blue);
  box-shadow: inset 3px 0 0 var(--blue);
}

.mod-head { display: flex; align-items: stretch; }
.mod-head .mod-link { flex: 1; }
.mod-head .mod-toggle { width: 2.5rem; justify-content: center; padding: 0; }

.chev {
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  margin-top: -0.2rem;
  flex: 0 0 auto;
}

.mod-nav.open .chev { transform: rotate(-135deg); margin-top: 0.15rem; }

.mod-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.22s ease;
}

.mod-nav.open .mod-panel { grid-template-rows: 1fr; }

.mod-panel-inner { overflow: hidden; }

.mod-link.active, .side a.unit.active {
  background: var(--blue);
  color: #fff;
}

.unit-line { display: flex; align-items: flex-start; }
.unit-line > .unit { flex: 1; min-width: 0; }
.unit-trash {
  display: none;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  margin: 0.28rem 0.35rem 0 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #00214e;
  cursor: pointer;
}
body.is-editing .unit-trash { display: flex; }
.unit-trash:hover { color: #0052cc; }
.card-trash {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 3;
  width: 2rem;
  height: 2rem;
  margin: 0;
  border: 1px solid #c5d9ef;
  background: #f8fafc;
}
body.is-editing .card-trash { top: 4.6rem; }

.side a.unit {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
  padding: 0.32rem 1rem 0.32rem 1.15rem;
  color: #00214e;
  text-decoration: none;
  line-height: 1.35;
  font-size: 0.92rem;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
}

.side a.unit.sub { padding-left: 1.6rem; color: #1e293b; }

.side a.unit:hover { color: var(--blue); }

.tick {
  flex: 0 0 0.95rem;
  width: 0.95rem;
  height: 0.95rem;
  margin-top: 0.18rem;
  border: 1.5px solid #94a3b8;
  border-radius: 3px;
  background: #fff;
}

.side a.unit.done .tick,
.unit-row.done .tick {
  background: var(--blue);
  border-color: var(--blue);
  position: relative;
}

.side a.unit.done .tick::after,
.unit-row.done .tick::after {
  content: "";
  position: absolute;
  left: 0.28rem;
  top: 0.08rem;
  width: 0.22rem;
  height: 0.45rem;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.side a.unit.active .tick { border-color: #fff; background: transparent; }
.side a.unit.active.done .tick { background: #fff; }
.side a.unit.active.done .tick::after { border-color: var(--blue); }

.unit-row { display: flex; gap: 0.45rem; align-items: flex-start; }

.empty-mod { color: #475569; padding: 0 1rem; font-size: 0.85rem; }

.main { margin: var(--bar) 0 0 300px; background: var(--canvas); min-height: calc(100vh - var(--bar)); }

.sheet { padding: 1.6rem 2rem 3rem; }

.sheet h1, .stage-read h1, .book-body h1 {
  margin: 0 0 0.6rem;
  font-size: 2rem;
  line-height: 1.2;
  color: var(--ink);
}

.lede, .prose p, .book-body .noindent, .book-body p {
  max-width: 72ch;
  margin: 0 0 1rem;
  color: var(--ink);
  line-height: 1.7;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  letter-spacing: normal;
  word-spacing: normal;
}

li {
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 2px;
  padding-bottom: 2px;
}

.prose li,
.editor li,
.book-body li {
  max-width: 72ch;
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 2px;
  padding-bottom: 2px;
  color: var(--ink);
  line-height: 1.7;
}

.prose li p,
.editor li p,
.book-body li p {
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.prose { overflow: auto; }
.prose strong, .prose b { font-weight: 700; }
.prose::after { content: ""; display: block; clear: both; }

.prose figure.frame {
  margin: 0.35rem 0 1rem;
  max-width: 100%;
}

.prose figure.align-left { float: left; margin: 0.2rem 1rem 0.8rem 0; }
.prose figure.align-right { float: right; margin: 0.2rem 0 0.8rem 1rem; }
.prose figure.align-center { float: none; display: block; clear: both; margin: 0.8rem auto 1rem; text-align: center; }
.prose figure.frame figcaption,
.prose figure.frame figcaption.text-xs {
  display: block;
  margin: 0.25rem 0 0;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 400;
  font-style: italic;
  text-align: center;
  line-height: 1.4;
}
.prose figure.width-25 { width: 25%; }
.prose figure.width-30 { width: 30%; }
.prose figure.width-35 { width: 35%; }
.prose figure.width-40 { width: 40%; }
.prose figure.width-45 { width: 45%; }
.prose figure.width-50 { width: 50%; }
.prose figure.width-55 { width: 55%; }
.prose figure.width-60 { width: 60%; }
.prose figure.width-65 { width: 65%; }
.prose figure.width-70 { width: 70%; }
.prose figure.width-75 { width: 75%; }
.prose figure.width-80 { width: 80%; }
.prose figure.width-85 { width: 85%; }
.prose figure.width-90 { width: 90%; }
.prose figure.width-95 { width: 95%; }
.prose figure.width-100 { width: 100%; float: none; clear: both; }

.prose img.inline-diagram {
  display: block;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  margin: 0.8rem auto;
  border: 1px solid var(--line);
  background: #fff;
  cursor: zoom-in;
}
.prose img.inline-diagram.width-25 { width: 25%; }
.prose img.inline-diagram.width-30 { width: 30%; }
.prose img.inline-diagram.width-35 { width: 35%; }
.prose img.inline-diagram.width-40 { width: 40%; }
.prose img.inline-diagram.width-45 { width: 45%; }
.prose img.inline-diagram.width-50 { width: 50%; }
.prose img.inline-diagram.width-55 { width: 55%; }
.prose img.inline-diagram.width-60 { width: 60%; }
.prose img.inline-diagram.width-65 { width: 65%; }
.prose img.inline-diagram.width-70 { width: 70%; }
.prose img.inline-diagram.width-75 { width: 75%; }
.prose img.inline-diagram.width-80 { width: 80%; }
.prose img.inline-diagram.width-85 { width: 85%; }
.prose img.inline-diagram.width-90 { width: 90%; }
.prose img.inline-diagram.width-95 { width: 95%; }
.prose img.inline-diagram.width-100 { width: 100%; }
.inline-shot { display: block; margin: 0.8rem auto; }
.inline-shot img.inline-diagram { margin: 0 auto; }

.inline-video { margin: 1rem 0; clear: both; }
.inline-video video { display: block; width: 100%; max-height: 70vh; background: #00214e; border-radius: 8px; }

.book-pages {
  margin: 0.35rem 0 1rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--blue);
  border-radius: 8px;
  background: #fff;
  padding: 0.35rem 0.8rem 0.6rem;
}
.book-pages summary { cursor: pointer; color: var(--blue); font-weight: 700; }
.book-pages-body { color: var(--ink); }
.book-pages-body h3 { margin: 0.8rem 0 0.3rem; font-size: 0.95rem; color: var(--char); }
.book-pages-body p { white-space: pre-wrap; }

.prose img,
.prose figure img,
.figures img,
.shot img {
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

.prose figure img {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  cursor: zoom-in;
}

.frame-tools { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.35rem; }
.inline-shot .frame-tools { display: inline-flex; margin: 0 0 0 0.35rem; vertical-align: middle; }
.frame-tools button {
  background: var(--char);
  color: #fff;
  border: 0;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  cursor: pointer;
}
.frame-tools button.on { background: var(--blue); }
.frame-tools button[data-trash] { background: #9f1239; }
.width-field {
  flex: 1 0 100%;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.2rem;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 700;
}
.width-slider { flex: 1; accent-color: var(--blue); }
.width-readout { flex: 0 0 2.4rem; color: #00214e; font-weight: 700; }
.edit-note { flex: 1 0 100%; margin: 0; color: #e8eef8; font-size: 0.75rem; }
.main-gate { margin-left: 0; }
.gate-card { margin: 2rem auto; }
.metrics { width: 100%; border-collapse: collapse; background: #fff; }
.metrics th, .metrics td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); color: #00214e; vertical-align: top; }
.metrics th { background: #00214e; color: #fff; font-size: 0.85rem; }
.activity-block { margin-top: 2.2rem; }
.activity-block h2 { margin: 0 0 0.35rem; color: #00214e; font-size: 1.35rem; }
.activity-filters { display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; align-items: flex-end; margin: 0.6rem 0 1rem; }
.activity-filters label { display: block; flex: 1 1 12rem; font-weight: 700; color: #00214e; }
.activity-filters select, .activity-filters input[type="date"] {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #00214e;
  font: inherit;
}
.activity-filters .primary { margin-bottom: 0.05rem; }
.user-table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.user-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.user-actions .primary, .user-actions .ghost, .user-actions .text-action { padding: 0.35rem 0.55rem; font-size: 0.82rem; }
.sheet .user-actions .ghost { background: #fff; }
.text-action {
  border: 0;
  background: transparent;
  color: #0052cc;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}
.issued-key { font-family: Consolas, ui-monospace, monospace; letter-spacing: 0.03em; user-select: all; }
.reset-hint { color: var(--muted); font-size: 0.9rem; font-weight: 400; }
.check-line { display: flex; gap: 0.45rem; align-items: flex-start; font-weight: 650; }
.check-line input { width: auto; margin-top: 0.35rem; }
.student-deck { margin-bottom: 1.4rem; }

.caption-field {
  flex: 1 0 100%;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 0.2rem;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 700;
}
.caption-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.3rem 0.45rem;
  font-weight: 400;
  color: #00214e;
  background: #fff;
}
.is-editing figure.frame { cursor: grab; }
.is-editing figure.frame.dragging { opacity: 0.45; }
.drop-mark { height: 4px; margin: 0.3rem 0; border-radius: 99px; background: var(--blue); }

.prose h2, .book-body .heading2 {
  font-size: 1.35rem;
  line-height: 1.3;
  margin: 1.5rem 0 0.55rem;
  color: var(--ink);
}

.prose h3 { font-size: 1.12rem; margin: 1.2rem 0 0.4rem; }

.prose ul, .prose ol, .editor ul, .editor ol { margin: 0 0 1rem; padding-left: 1.25rem; }
.prose ul, .editor ul { list-style: disc; }
.prose ol, .editor ol { list-style: decimal; }

.mod-block { margin: 1.4rem 0 1.8rem; }

.mod-block h2 { margin: 0 0 0.4rem; color: var(--blue); font-size: 1.2rem; }

.mod-block ol { margin: 0; padding-left: 1.3rem; }

.mod-block li { margin-top: 0; margin-bottom: 0; padding-top: 2px; padding-bottom: 2px; }

.mod-block a { color: var(--ink); font-weight: 650; text-decoration: none; }

.mod-block a:hover { color: var(--blue); }

.pill {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.05rem 0.4rem;
  border-radius: 99px;
  background: #e8f0ff;
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 700;
}

.stage.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: calc(100vh - var(--bar));
}

.stage-video {
  background: var(--char);
  color: #fff;
  padding: 1rem 1rem 2rem;
  overflow: auto;
  height: calc(100vh - var(--bar));
}

.stage-read {
  position: relative;
  overflow: auto;
  height: calc(100vh - var(--bar));
  padding: 1.4rem 1.6rem 3rem;
  background: var(--canvas);
}

.stage.single .stage-read {
  height: auto;
  overflow: visible;
  width: 100%;
  max-width: 64rem;
  margin-left: auto;
  margin-right: auto;
}

.kicker {
  margin: 0 0 0.6rem;
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

video { width: 100%; background: #00214e; border-radius: 6px; }

.clip { display: block; width: 100%; margin-top: 0.45rem; text-align: left; background: var(--char-2); }

.crumb { margin: 0 0 0.4rem; color: var(--muted); font-size: 0.92rem; }

.figures { display: grid; gap: 1rem; margin: 1rem 0 1.4rem; }

.figures figure { margin: 0; max-width: 720px; }

.shot {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  cursor: zoom-in;
}

.shot img { display: block; width: 100%; }

figcaption, .cite { color: var(--blue); font-size: 0.92rem; font-weight: 700; }

.text-ref, .hosted, .quiz {
  margin: 1.4rem 0;
  padding: 1rem 1rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  max-width: 760px;
}

.text-ref h2, .hosted h2, .quiz h2 { margin: 0 0 0.5rem; font-size: 1.2rem; }

.hosted a, .hosted-links a { overflow-wrap: anywhere; }
.video-stack { display: flex; flex-direction: column; gap: 0.4rem; margin: 1.6rem 0 2rem; }
.video-wrapper {
  margin: 1.5rem auto;
  max-width: 48rem;
}
.video-wrapper h4 {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #64748b;
}
.video-wrapper video {
  display: block;
  width: 100%;
  border-radius: 0.5rem;
  box-shadow: 0 4px 8px rgba(15, 23, 42, 0.16);
  background: #00214e;
}
.video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #00214e;
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 4px 8px rgba(15, 23, 42, 0.16);
}
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.hosted-links { margin: 0.4rem auto 1rem; max-width: 48rem; padding-left: 1.2rem; }

.vimeo-set { margin: 0 0 1.2rem; max-width: 760px; }
.vimeo-set h2 { margin: 0 0 0.55rem; font-size: 1.2rem; }
.vimeo-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 0 0 0.8rem;
  background: #00214e;
  border-radius: 8px;
  overflow: hidden;
}
.vimeo-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.quiz-head { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }

.quiz-score { margin: 0; color: var(--blue); font-weight: 700; }

.qcard { margin: 0 0 1.1rem; }

.quiz-edit {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.45rem;
  background: #fff;
  color: var(--blue);
  border: 1px solid var(--blue);
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem;
  cursor: pointer;
}
.quiz-edit:hover { background: #e8f0ff; }

.quiz-modal[hidden] { display: none; }
.quiz-modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4.5rem 1rem 2rem;
  overflow: auto;
}
.quiz-modal form {
  width: min(40rem, 100%);
  background: #fff;
  color: #00214e;
  border-radius: 12px;
  padding: 1rem 1.1rem 1.2rem;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.25);
}
.quiz-modal h2 {
  margin: -1rem -1.1rem 1rem;
  padding: 0.85rem 1.1rem;
  border-radius: 12px 12px 0 0;
  background: #00214e;
  color: #fff;
  font-size: 1.05rem;
}
.quiz-modal label { display: block; margin: 0.7rem 0; font-weight: 700; }
.quiz-modal textarea,
.quiz-modal input,
.quiz-modal select {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
  background: #fff;
  color: #00214e;
  font: inherit;
  font-weight: 400;
}
.quiz-modal textarea { min-height: 6rem; }
.quiz-modal-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.4rem; }
#quiz-edit-status { min-height: 1.2rem; color: #9f1239; }

.qcard h3 { margin: 0 0 0.45rem; font-size: 1.05rem; line-height: 1.45; }

.opt {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  margin: 0.45rem 0;
  cursor: pointer;
  line-height: 1.45;
  white-space: normal;
  word-break: normal;
}

.opt .lab { flex: 0 0 1.4rem; color: var(--blue); font-weight: 800; }

.opt:hover { border-color: var(--blue); }

.opt.is-correct, .opt.is-correct .lab { background: var(--blue); color: #fff; border-color: var(--blue); }

.opt.is-wrong { border-color: #9f1239; background: #fff5f7; }

.explain { color: var(--ink); }

.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; max-width: 760px; }

.pager a { font-weight: 700; }

#mark-done, .primary { background: var(--blue); color: #fff; }

#lightbox {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

#lightbox[hidden] { display: none; }

#lightbox img { max-width: 94vw; max-height: 90vh; background: #fff; }

#lightbox-close {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  background: var(--blue);
  color: #fff;
  border: 0;
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
}

.results { list-style: none; padding: 0; }

.results li { margin-top: 0; margin-bottom: 0; padding-top: 2px; padding-bottom: 2px; }

.results p { margin: 0.2rem 0 0; max-width: 70ch; }

mark { background: transparent; color: var(--blue); font-weight: 800; }

.book-body { max-width: 64rem; width: 100%; margin-left: auto; margin-right: auto; }

.book-body .chapnum { color: var(--blue); font-weight: 800; }

.book-body .chaptitle { font-size: 2rem; line-height: 1.2; margin: 0.2rem 0 1rem; }

.book-body .dropcap::first-letter {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--blue);
  float: left;
  line-height: 0.85;
  padding-right: 0.35rem;
}

.book-body img { display: block; margin: 0.6rem 0 1rem; }

.stack label { display: block; font-weight: 700; margin: 0.8rem 0; }

.stack input[type="text"], .stack input[type="password"], .stack input[type="number"], .stack select {
  display: block;
  width: min(640px, 100%);
  margin-top: 0.3rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.admin-list { list-style: none; padding: 0; }

.admin-list li { display: flex; gap: 0.6rem; align-items: center; margin-top: 0; margin-bottom: 0; padding-top: 2px; padding-bottom: 2px; }

.admin-list input { width: 4.5rem; padding: 0.3rem; border: 1px solid var(--line); border-radius: 6px; }

.admin-head { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }

.toolbar { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.5rem; }

.toolbar button { background: var(--char); }

.editor {
  min-height: 50vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  background: #fff;
}

.editor:focus { outline: 2px solid var(--blue); }

.alert { padding: 0.6rem 0.75rem; border-radius: 8px; background: #fff5f7; color: #9f1239; }

.alert.good { background: #e8f0ff; color: var(--blue); }

.source { color: var(--muted); font-size: 0.9rem; }

.deck-list { list-style: none; margin: 0 0 1.2rem; padding: 0; min-height: 2.6rem; }
.deck-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 9.5rem 6.2rem;
  gap: 0.55rem;
  align-items: center;
  margin: 0.35rem 0;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.deck-row.dragging { opacity: 0.45; }
.deck-row a { color: var(--ink); font-weight: 650; text-decoration: none; }
.deck-row a:hover { color: var(--blue); }
.deck-row label { display: grid; gap: 0.15rem; font-size: 0.75rem; font-weight: 700; color: var(--muted); }
.deck-row select, .deck-row input { width: 100%; padding: 0.3rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); }
.grip { cursor: grab; color: var(--muted); font-size: 0.75rem; font-weight: 800; user-select: none; }
.deck-mod h2, .deck-mod h3 { margin: 1rem 0 0.35rem; color: var(--blue); font-size: 1.15rem; }
.course-admin { margin-top: 1.5rem; padding-top: 0.4rem; border-top: 1px solid var(--line); }
.course-admin-head { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: center; justify-content: space-between; }
.course-admin-head h2 { margin: 0.4rem 0; color: #00214e; font-size: 1.35rem; }
.create-course { margin: 0 0 1.2rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.create-course form { margin-top: 0.8rem; }
#course-delete-dialog,
.security-dialog {
  border: 0;
  border-radius: 10px;
  padding: 1.2rem 1.3rem;
  width: min(34rem, calc(100vw - 2rem));
  max-width: 34rem;
  background: #f8fafc;
  color: #00214e;
}
#course-delete-dialog::backdrop,
.security-dialog::backdrop { background: rgba(0, 33, 78, 0.45); }
#course-delete-dialog h2,
.security-dialog h2 { margin: 0 0 0.4rem; color: #00214e; }
.security-dialog input[readonly] { background: #eef2f7; }
.course-delete-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

.edit-dock { position: fixed; z-index: 45; top: 12px; right: 12px; }
.edit-dock button {
  background: var(--blue);
  color: #fff;
  border: 0;
  border-radius: 6px;
  font-weight: 700;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.28);
}
.edit-dock button[aria-pressed="true"] { background: #fff; color: var(--char); }
body[data-admin="1"][data-section="lesson"] .top { padding-right: 12.5rem; }

.edit-bar {
  position: fixed;
  z-index: 44;
  top: var(--bar);
  left: 300px;
  right: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  padding: 0.45rem 0.8rem;
  background: var(--char);
  color: #fff;
}
.edit-bar[hidden] { display: none; }
.edit-bar .toolbar { margin: 0; }
.upload-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: var(--char-2);
  color: #fff;
  border: 1px solid #8ea0bd;
  border-radius: 6px;
  font-weight: 700;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
}
.upload-btn input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.admin-links { margin: 0; }
.admin-links a { color: var(--blue); font-weight: 700; }
.mod-admin-head { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: center; }
.mod-admin-head h2 { margin: 1rem 0 0.2rem; }
.mod-admin-head p { margin: 1rem 0 0; color: var(--muted); }
.unit-pick { display: flex; gap: 0.65rem; align-items: flex-start; margin: 0.35rem 0; }
.unit-pick a { color: var(--ink); font-weight: 650; text-decoration: none; }
.pick-all { display: flex; gap: 0.45rem; align-items: center; font-weight: 700; color: var(--blue); }
.create-mod { margin-bottom: 1.4rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line); }
.move-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: center;
  margin-top: 1rem;
  padding: 0.8rem;
  border-radius: 8px;
  background: var(--char);
  color: #fff;
}
.move-bar select { margin-left: 0.4rem; padding: 0.35rem; border-radius: 6px; color: var(--ink); }
.edit-bar .toolbar button { background: var(--char-2); border: 1px solid #8ea0bd; }
#edit-save, #edit-cancel {
  border-radius: 6px;
  font-weight: 700;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
}
#edit-save { background: var(--blue); color: #fff; border: 0; }
#edit-cancel { background: transparent; color: #fff; border: 1px solid #8ea0bd; }
#edit-status { margin: 0; font-size: 0.85rem; }
.is-editing .stage-read { padding-top: 4.4rem; }
.is-editing .prose, .is-editing .stage-read h1 { outline: 2px solid var(--blue); border-radius: 8px; }
.is-editing .stage-read h1 { padding: 0.2rem 0.4rem; }

.foot-note { margin-top: 2rem; }

.linkish { text-decoration: none; padding: 0.4rem 0.7rem; }

.narrow { max-width: 640px; }

@media (max-width: 900px) {
  #menu-btn { display: inline-flex; }
  .top-links { display: none; }
  .brand span { display: none; }
  .logo { height: 56px; }
  .search { flex: 1 1 auto; min-width: 0; margin-left: 0.45rem; }
  .search input { width: auto; flex: 1 1 5rem; min-width: 0; }
  .side { transform: translateX(-105%); transition: transform 0.18s ease; width: min(320px, 88vw); }
  .side.open { transform: none; }
  .main { margin-left: 0; }
  .sheet { padding: 1.1rem 1rem 2.5rem; }
  .stage.split {
    display: block;
    height: auto;
  }
  .stage-video, .stage-read {
    height: auto;
    position: static;
  }
  .stage-video { min-height: 50vh; }
  .stage.single .stage-read, .stage-read { height: auto; }
  body[data-admin="1"][data-section="lesson"] .top { padding-right: 0.9rem; }
  .edit-dock { top: 88px; right: 8px; }
  .edit-bar { left: 0; top: 134px; }
  body.is-editing .card-trash { top: 7.2rem; }
  .deck-row { grid-template-columns: auto minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .who, .meter { display: none; }
}

body[data-section="gate"] {
  background: #e8f1f8;
  color: #00214e;
}

body[data-section="gate"] .main-gate {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e8f1f8;
  padding: 1.5rem 1rem;
}

body[data-section="gate"] .gate-card {
  width: min(440px, 100%);
  max-width: 440px;
  min-width: 0;
  margin: 0;
  padding: 1.75rem 1.5rem 1.15rem;
  background: #ffffff;
  color: #00214e;
  border: 1px solid #d3e2ee;
  border-radius: 12px;
  text-align: center;
}

body[data-section="gate"] .gate-logo {
  display: block;
  width: 260px;
  max-width: 100%;
  height: auto;
  margin: 0 auto 0.85rem;
}

body[data-section="gate"] .gate-card h1 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.25;
  color: #00214e;
}

body[data-section="gate"] .gate-sub,
body[data-section="gate"] .gate-tag,
body[data-section="gate"] .gate-note,
body[data-section="gate"] .gate-phone {
  margin: 0.35rem 0 0;
  color: #4d6278;
  line-height: 1.45;
}

body[data-section="gate"] .gate-sub {
  font-size: 1.05rem;
  font-weight: 700;
}

body[data-section="gate"] .gate-tag {
  margin-bottom: 0.85rem;
  font-size: 0.92rem;
}

body[data-section="gate"] .gate-card .alert {
  margin: 0 0 0.85rem;
  text-align: left;
}

body[data-section="gate"] .gate-card form,
body[data-section="gate"] .gate-card .stack label {
  text-align: left;
  color: #00214e;
}

body[data-section="gate"] .stack input[type="text"],
body[data-section="gate"] .stack input[type="password"] {
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid #d3e2ee;
  border-radius: 6px;
  background: #ffffff;
  color: #00214e;
}

body[data-section="gate"] .gate-card .primary {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.7rem 1rem;
  border: 0;
  border-radius: 6px;
  background: #0b3a63;
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

body[data-section="gate"] .gate-note {
  margin-top: 1rem;
  font-size: 0.92rem;
}

body[data-section="gate"] .gate-phone {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid #d3e2ee;
  color: #00214e;
  font-weight: 700;
}

@media (max-width: 480px) {
  body[data-section="gate"] .main-gate { padding: 1rem 0.75rem; }
  body[data-section="gate"] .gate-card { padding: 1.35rem 1rem 1rem; }
  body[data-section="gate"] .gate-card h1 { font-size: 1.28rem; }
}
