@import url("https://fonts.googleapis.com/css2?family=Figtree:wght@300;400;500;600&family=Newsreader:opsz,wght@6..72,400;6..72,500&display=swap");
/* PATA-LIKE: the Patagonia-based theme before the Italian refinement. Default. */
/* Light theme only. Type and component styles follow patagonia.com:
   body 300 weight, headings 500 with tight tracking, 1px pill buttons, light-gray pill search,
   black utility bar, thin underlined text links, serif article titles.
   Patagonia's own faces (Ridgeway Sans, Copernicus) are proprietary; Figtree and Newsreader
   are the closest open equivalents and load from Google Fonts. */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f5f5;
  --surface-3: #ebebeb;
  --text: #000000;
  --muted: #4a4a4a;
  --muted-2: #707070;
  --line: #e5e5e5;
  --line-strong: #000000;
  --danger: #b00020;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  --pill: 30px;
  --card-radius: 8px;
  --utility-h: 32px;
  --nav-h: 64px;
  --topbar-h: calc(var(--utility-h) + var(--nav-h));
  --toc-w: 300px;
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-weight: 300;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
a { color: var(--text); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
b, strong { font-weight: 500; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
body:not(.is-admin) .admin-only { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--pill);
  padding: 9px 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.btn:hover { background: var(--text); color: var(--bg); }
.btn.primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn.primary:hover { background: #333; border-color: #333; }
.btn.ghost {
  background: transparent; border-color: transparent; padding-left: 0; padding-right: 0; border-radius: 0;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px;
}
.btn.ghost:hover { background: transparent; color: var(--muted-2); }
.btn.danger { color: var(--danger); }
.btn.small { font-size: 13px; padding: 6px 14px; }
.btn.wide { width: 100%; padding: 13px 20px; font-size: 16px; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn {
  font: inherit; border: 0; background: transparent; color: var(--text);
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 300;
}
.icon-btn:hover { background: var(--surface-2); }

/* ---------- top bar: black utility strip + white nav row ---------- */
.topbar {
  height: var(--topbar-h);
  display: grid;
  grid-template-rows: var(--utility-h) var(--nav-h);
  position: relative; z-index: 20;
  background: var(--surface);
}
.utility {
  background: #000; color: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 24px; font-size: 13px; font-weight: 300;
}
.utility .brand { color: #fff; text-decoration: none; font-weight: 500; letter-spacing: .01em; }
.utility .right { display: flex; align-items: center; gap: 18px; }
.utility .btn.ghost { color: #fff; font-size: 13px; font-weight: 300; padding: 0; }
.utility .btn.ghost:hover { color: #ccc; }
.nav {
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
}
.search {
  flex: 1; max-width: 520px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border-radius: 40px; padding: 0 8px 0 16px;
  color: var(--muted);
}
.search input {
  flex: 1; min-width: 0; font: inherit; font-weight: 300; border: 0; background: transparent; color: var(--text);
  height: 40px; outline: none;
}
.search input::placeholder { color: var(--muted-2); }
.search input::-webkit-search-cancel-button { display: none; }
.search .clear { border: 0; background: transparent; color: var(--muted); font-size: 20px; cursor: pointer; padding: 0 8px; }
.counter { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.badge {
  font-size: 12px; font-weight: 500; background: var(--text); color: var(--bg);
  padding: 3px 10px; border-radius: var(--pill);
}
.whoami { font-size: 13px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#menu-btn { display: none; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--toc-w) 1fr;
  height: calc(100dvh - var(--topbar-h));
}
.toc {
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.toc-head {
  padding: 20px 24px 8px; display: flex; justify-content: space-between; align-items: baseline;
  font-size: 20px; font-weight: 500; letter-spacing: -.02em;
}
.toc-head .muted { font-size: 13px; font-weight: 300; }
.toc-list { overflow-y: auto; flex: 1; padding: 0 12px 20px; }
.toc-section { margin-top: 14px; }
.toc-section-title { display: flex; align-items: center; gap: 8px; font-family: var(--serif); font-size: 21px; font-weight: 500; line-height: 1.2; color: var(--text); padding: 10px 12px 6px; }
.toc-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left; font: inherit; font-size: 14px; font-weight: 300; line-height: 1.4;
  border: 0; background: transparent; color: var(--text);
  padding: 8px 12px; border-radius: var(--pill); cursor: pointer;
}
.toc-item:hover { background: var(--surface-2); }
.toc-item.active { background: var(--text); color: var(--bg); font-weight: 500; }
.toc-item.active .num, .toc-item.active .vid { color: rgba(255,255,255,.7); }
.toc-item .num { color: var(--muted-2); font-size: 12px; min-width: 18px; font-variant-numeric: tabular-nums; }
.toc-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-item .vid { color: var(--muted-2); display: inline-flex; }
.toc-item mark { background: #fff2a8; color: inherit; padding: 0 1px; }
.toc-item.active mark { background: transparent; color: #fff2a8; }
.toc-item .move, .toc-section-title .move { display: none; gap: 2px; }
.is-admin .toc-item:hover .move, .is-admin .toc-section-title:hover .move { display: inline-flex; }
.toc-section-title .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-section-title .move button { border: 0; background: transparent; color: var(--muted-2); cursor: pointer; padding: 0 3px; font-size: 11px; line-height: 1; font-family: var(--font); }
.toc-section-title .move button:hover { color: var(--text); }
.toc-item .move button { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0 3px; font-size: 11px; line-height: 1; opacity: .7; }
.toc-item .move button:hover { opacity: 1; }
.toc-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 8px 18px; }
.toc-foot:empty { display: none; }
.toc-foot .btn.ghost { font-size: 13px; }
.mobile-only { display: none; }
.theme-pick { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
.theme-pick select { font: inherit; font-size: 13px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); padding: 3px 6px; border-radius: 0; }
.toc-empty { padding: 20px 12px; color: var(--muted); font-size: 14px; }
.toc-backdrop { display: none; }

/* ---------- feed ---------- */
.feed {
  position: relative;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  outline: none;
  overscroll-behavior: contain;
  background: var(--surface);
}
.lesson {
  height: calc(100dvh - var(--topbar-h));
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  border-bottom: 1px solid var(--line);
}
.media {
  position: relative;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
}
.media-inner { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.media video, .media iframe { width: 100%; height: 100%; max-height: 100%; display: block; background: #000; border: 0; }
.media video { object-fit: contain; }
.media img { width: 100%; height: 100%; object-fit: contain; display: block; }
.lesson.has-image .media { background: var(--surface-3); }
.media .placeholder {
  width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #ededed, #e4e4e4); color: var(--muted-2); font-size: 14px;
}
.media .placeholder svg { display: block; margin: 0 auto 8px; opacity: .5; }
.media .placeholder small { display: block; margin-top: 6px; font-size: 12px; opacity: .8; max-width: 260px; text-align: center; }
.spinner { display: inline-block; width: 22px; height: 22px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .9s linear infinite; margin-bottom: 10px; opacity: .7; }
@keyframes spin { to { transform: rotate(360deg); } }
#u-created { user-select: all; word-break: break-all; }
.media .placeholder a { color: var(--text); }
.pos-badge {
  display: none; position: absolute; left: 12px; top: 12px; z-index: 2;
  padding: 3px 9px; border-radius: var(--pill); background: rgba(0,0,0,.55); color: #fff;
  font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; backdrop-filter: blur(4px);
}
.unmute {
  position: absolute; left: 20px; bottom: 20px;
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-weight: 500; font-size: 13px;
  background: #fff; color: #000; border: 0; border-radius: var(--pill);
  padding: 8px 16px; cursor: pointer; box-shadow: var(--shadow);
}
.add-video {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: linear-gradient(135deg, #ededed, #e4e4e4);
}
.add-video .note { color: var(--muted-2); font-size: 14px; }
.add-video .btn { font-size: 15px; padding: 12px 26px; }
.add-video .progress { width: min(320px, 80%); }
.add-video-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.hint-text { margin: 4px 0 0; font-size: 12.5px; line-height: 1.5; text-transform: none; letter-spacing: 0; }
/* in-page recorder */
.modal.rec { width: min(760px, calc(100vw - 32px)); }
.rec-stage { position: relative; background: #000; border-radius: var(--card-radius); overflow: hidden; aspect-ratio: 16 / 9; }
.rec-stage video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.rec-overlay { position: absolute; left: 12px; top: 10px; display: flex; align-items: center; gap: 10px; color: #fff; font-size: 13px; font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.rec-overlay .muted { color: rgba(255,255,255,.75); }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #e0312b; animation: blink 1s steps(2) infinite; }
@keyframes blink { to { opacity: .2; } }
.rec-foot { flex-wrap: wrap; }
@media (max-width: 860px) { .rec-stage { aspect-ratio: auto; height: min(52dvh, 420px); } }
.text {
  padding: 48px 56px 72px;
  overflow-y: auto;
  min-height: 0;
  background: var(--surface);
}
.text-head { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.text-head .section { font-family: var(--serif); font-size: 34px; font-weight: 500; line-height: 1.1; color: var(--text); letter-spacing: -.01em; width: 100%; }
.text-head .meta { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 300; color: var(--muted); }
.text-head .aud { padding: 1px 8px; border: 1px solid currentColor; border-radius: var(--pill); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.card-actions { margin-top: 2px; }
.card-actions .btn.ghost { padding-left: 0; padding-right: 0; }
.title {
  font-family: var(--font); font-weight: 500; font-size: 20px; line-height: 1.3; letter-spacing: -.01em;
  margin: 8px 0 16px; color: var(--text);
}
.body { font-size: 16px; font-weight: 300; line-height: 1.7; max-width: 62ch; }
.body :is(h1,h2,h3,h4) { font-weight: 500; letter-spacing: -.02em; margin: 1.4em 0 .5em; line-height: 1.2; }
.body h1 { font-size: 1.5em; } .body h2 { font-size: 1.3em; } .body h3 { font-size: 1.12em; } .body h4 { font-size: 1em; }
.body p { margin: 0 0 1em; }
.body ul, .body ol { padding-left: 1.3em; margin: 0 0 1em; }
.body li { margin: .3em 0; }
.body blockquote { margin: 0 0 1em; padding: .8em 1.1em; border-left: 2px solid var(--text); background: var(--surface-2); }
.body code { background: var(--surface-2); padding: .1em .35em; font-size: .92em; }
.body pre { background: var(--surface-2); padding: 14px 16px; overflow: auto; border-radius: var(--card-radius); }
.body table { border-collapse: collapse; margin: 0 0 1em; }
.body th, .body td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.body th { font-weight: 500; }
.body img { max-width: 100%; border-radius: var(--card-radius); }
.body mark.red { background: transparent; color: #c1121f; font-weight: 500; }
.body hr { border: 0; border-top: 1px solid var(--line); margin: 1.5em 0; }
.empty { height: calc(100dvh - var(--topbar-h)); display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; }
.empty h2 { margin: 0 0 8px; font-weight: 500; letter-spacing: -.02em; font-size: 28px; }

/* ---------- floating add button ---------- */
.fab {
  position: fixed; right: 32px; bottom: 32px; z-index: 30;
  width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: var(--text); color: var(--bg);
  font-size: 32px; line-height: 1; font-weight: 300;
  box-shadow: var(--shadow); cursor: pointer;
}
.fab:hover { background: #333; }

/* ---------- modals / forms ---------- */
.modal {
  border: 0; border-radius: var(--card-radius); padding: 0; width: min(640px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(0,0,0,.5); }
.modal form { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 26px 8px; }
.modal-head h2 { margin: 0; font-size: 24px; font-weight: 500; letter-spacing: -.02em; }
.modal-body { padding: 8px 26px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { display: flex; align-items: center; gap: 14px; padding: 16px 26px 22px; border-top: 1px solid var(--line); }
.spacer { flex: 1; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
.field small { font-weight: 300; }
.field input:not([type=file]):not([type=checkbox]), .field textarea, .field select {
  font: inherit; font-weight: 300; font-size: 15px;
  border: 1px solid var(--muted-2); border-radius: 4px; padding: 11px 14px;
  background: var(--surface); color: var(--text); width: 100%;
}
.field input::placeholder, .field textarea::placeholder { color: var(--muted-2); }
.field textarea { resize: vertical; min-height: 130px; line-height: 1.6; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--text); outline-offset: -1px; }
.video-picker { display: flex; flex-direction: column; gap: 8px; }
.video-picker .or { text-align: center; color: var(--muted-2); font-size: 12px; font-weight: 300; }
.drop {
  display: block; border: 1px dashed var(--muted-2); border-radius: 4px; padding: 20px; text-align: center;
  font-weight: 300; color: var(--muted); cursor: pointer; background: var(--surface-2);
}
.drop:hover, .drop.over { border-color: var(--text); color: var(--text); border-style: solid; }
.drop input { display: none; }
/* remove-video button on the card */
.remove-video {
  position: absolute; right: 14px; top: 14px; z-index: 2;
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; min-width: 34px; padding: 0 10px; border-radius: var(--pill);
  border: 1px solid rgba(255,255,255,.7); background: rgba(0,0,0,.55); color: #fff;
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; backdrop-filter: blur(4px);
}
.remove-video .minus { font-size: 20px; line-height: 1; font-weight: 300; }
.remove-video .ask { display: none; }
.remove-video.armed { background: var(--danger); border-color: var(--danger); }
.remove-video.armed .ask { display: inline; }
.remove-video:disabled { opacity: .5; cursor: default; }
/* checkbox row in the lesson form */
.check {
  display: flex; align-items: center; gap: 10px; margin-top: 4px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); color: var(--text); cursor: pointer;
}
.check input[type=checkbox] { width: 16px; height: 16px; margin: 0; accent-color: var(--text); flex: none; }
.check:has(input:checked) { border-color: var(--danger); color: var(--danger); }

.check { font-weight: 300; font-size: 14px; display: flex; gap: 8px; align-items: center; color: var(--muted); }
.progress { position: relative; height: 6px; background: var(--surface-3); border-radius: var(--pill); overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--text); transition: width .15s; }
.progress .pct { position: absolute; right: 0; top: 10px; font-size: 12px; color: var(--muted); }
.error { color: var(--danger); font-size: 14px; margin: 0; }
.hint { background: var(--surface-2); padding: 12px 14px; border-radius: 4px; font-size: 12.5px; margin: 0; white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* users */
.user-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--card-radius); overflow: auto; max-height: 42vh; }
.user-row {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name role" "meta actions";
  column-gap: 12px; row-gap: 2px; align-items: center;
  padding: 9px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.user-row:last-child { border-bottom: 0; }
.user-row.pending { background: var(--surface-2); }
.u-name { grid-area: name; display: flex; align-items: center; gap: 8px; min-width: 0; }
.u-name b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-name .you { color: var(--muted-2); font-size: 12px; }
.u-role { grid-area: role; justify-self: end; }
.u-meta { grid-area: meta; color: var(--muted); font-size: 12.5px; min-width: 0; overflow-wrap: anywhere; }
.u-meta .sep { margin: 0 6px; color: var(--muted-2); }
.u-actions { grid-area: actions; justify-self: end; display: flex; gap: 12px; white-space: nowrap; }
.u-actions button {
  font: inherit; font-size: 12.5px; font-weight: 500; border: 0; background: transparent; padding: 0; cursor: pointer; color: var(--text);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
}
.u-actions button:hover { color: var(--muted-2); }
.u-actions button.danger { color: var(--danger); }
.u-actions button.primary { background: var(--danger); color: #fff; text-decoration: none; padding: 2px 10px; border-radius: var(--pill); }
.tag { font-size: 10px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; padding: 2px 8px; border-radius: var(--pill); border: 1px solid var(--text); color: var(--text); white-space: nowrap; }
.tag.admin { background: var(--text); color: var(--bg); }
.tag.manager { background: var(--surface-2); }
.tag.pending { border-style: dashed; color: var(--muted); border-color: var(--muted-2); }
.role-select { font: inherit; font-size: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); padding: 2px 6px; border-radius: var(--pill); }
.user-form { display: flex; flex-direction: column; gap: 14px; padding-top: 6px; border-top: 1px solid var(--line); }
.user-form h3 { margin: 10px 0 0; font-size: 16px; font-weight: 500; letter-spacing: -.01em; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }
.with-btn { display: flex; gap: 8px; }
.with-btn input { flex: 1; min-width: 0; }
.row-end { display: flex; justify-content: flex-end; }
.share-row { display: flex; flex-wrap: wrap; gap: 8px; }
.share-row .btn { text-decoration: none; }
.small { font-size: 13px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: #000; color: #fff; padding: 10px 20px; border-radius: var(--pill);
  font-size: 14px; font-weight: 500; z-index: 50; box-shadow: var(--shadow);
  opacity: 0; transition: opacity .2s; pointer-events: none; white-space: nowrap; max-width: calc(100vw - 32px);
  overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; }

/* ---------- login ---------- */
.login-page { display: flex; align-items: center; justify-content: center; padding: 20px; overflow: auto; background: var(--surface-2); }
.login-card {
  width: min(420px, 100%); background: var(--surface); border-radius: var(--card-radius); padding: 36px 32px 32px;
  box-shadow: var(--shadow);
}
.login-mark { color: var(--text); margin-bottom: 10px; }
.login-card h1 { margin: 0 0 4px; font-family: var(--serif); font-weight: 400; font-size: 34px; line-height: 1.1; letter-spacing: -.01em; }
.login-card p { margin: 0 0 22px; }
.login-card .brand-line { display: block; margin: 10px 0 14px; font-family: var(--font); font-size: 13px; font-weight: 500; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }
.login-card form { display: flex; flex-direction: column; gap: 14px; }

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  :root { --utility-h: 30px; --nav-h: 56px; }
  #menu-btn { display: inline-flex; }
  .utility { padding: 0 16px; font-size: 12px; }
  .utility .right .btn { display: none; }
  .nav { padding: 0 12px; gap: 8px; }
  .search { max-width: none; }
  .counter { display: none; }
  .whoami { display: none; }
  .layout { grid-template-columns: 1fr; }
  .toc {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: min(320px, 86vw);
    transform: translateX(-100%); transition: transform .2s ease; z-index: 25;
    box-shadow: var(--shadow);
  }
  .toc.open { transform: none; }
  .toc-backdrop { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(0,0,0,.4); z-index: 24; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .toc-backdrop.show { opacity: 1; pointer-events: auto; }
  .toc-foot { flex-wrap: wrap; justify-content: flex-start; gap: 6px 18px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .mobile-only { display: inline-flex; }
  .is-admin .toc-item .move, .is-admin .toc-section-title .move { display: inline-flex; }
  .lesson { grid-template-columns: 1fr; grid-template-rows: minmax(200px, 42%) 1fr; }
  .text { padding: 20px 20px calc(88px + env(safe-area-inset-bottom)); }
  /* Inputs below 16px make iOS Safari zoom the page when they get focus. */
  .field input:not([type=file]):not([type=checkbox]), .field textarea, .field select, .search input { font-size: 16px; }
  .title { font-size: 18px; }
  .text-head .section { font-size: 20px; }
  .pos-badge { display: inline-block; }
  .text-head .meta .pos { display: none; }
  .text-head .meta:not(:has(.aud:not([hidden]))) { display: none; }
  .body { font-size: 16px; }
  .fab { right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); width: 54px; height: 54px; font-size: 28px; }
  .toast { bottom: calc(88px + env(safe-area-inset-bottom)); }

  /* Compact admin dialogs and user entry on phones */
  .modal { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .modal form { max-height: calc(100dvh - 16px); }
  .modal-head { padding: 14px 16px 4px; }
  .modal-head h2 { font-size: 20px; }
  .modal-body { padding: 4px 16px; gap: 10px; }
  .modal-foot { padding: 10px 16px 14px; gap: 10px; }
  .modal-foot .btn { padding: 8px 14px; font-size: 14px; }
  .field { gap: 4px; font-size: 13px; }
  .field input:not([type=file]), .field textarea, .field select { padding: 8px 10px; }
  .field textarea { min-height: 96px; }
  .drop { padding: 12px; font-size: 14px; }
  .video-picker { gap: 6px; }
  .hint { font-size: 12px; padding: 8px 10px; }
  .user-list { max-height: 36vh; }
  .user-row { padding: 8px 10px; font-size: 13px; grid-template-columns: 1fr auto; }
  .u-meta { white-space: normal; }
  .u-actions { gap: 10px; }
  .user-form { gap: 10px; }
  .user-form h3 { margin-top: 4px; font-size: 15px; }
  .grid-2 { gap: 10px; }
  .with-btn .btn { padding: 6px 10px; font-size: 13px; }
  .row-end .btn { padding: 9px 16px; }
}
