:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --ink: #1c2430;
  --muted: #5c6b7a;
  --brand: #0f4c81;
  --brand-ink: #fff;
  --card: #fff;
  --line: #d5dde6;
  --danger: #8d1d2c;
  --ok: #0f6b45;
}

body[data-theme="slate"] {
  color-scheme: dark;
  --bg: #0f1720;
  --ink: #e7eef6;
  --muted: #a9b8c7;
  --brand: #8eb8e5;
  --brand-ink: #102033;
  --card: #182430;
  --line: #2c3e50;
  --danger: #ffb4b4;
  --ok: #9ddeb8;
}

body[data-theme="forest"] {
  --bg: #f3f6f2;
  --ink: #1d2a22;
  --muted: #5d6f64;
  --brand: #1f6b45;
  --brand-ink: #fff;
  --card: #fff;
  --line: #d5e0d8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.5 "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

a { color: var(--brand); }
a:focus, button:focus, input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: inherit;
  font-weight: 650;
  text-decoration: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-user { font-size: 0.8rem; font-weight: 450; color: var(--muted); }

.brand img { height: 36px; width: auto; }
.logo-preview { max-height: 72px; width: auto; }
.profile-photo { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; }
.group-who { display: grid; grid-template-columns: 168px 1fr; gap: 1.5rem; align-items: end; margin: 0.5rem 0 1.5rem; }
.group-who img { width: 168px; height: 168px; object-fit: cover; border-radius: 8px; display: block; }
.group-who h1 { font-size: 2.6rem; font-weight: 500; line-height: 1; margin: 0; }
.group-facts dl { margin: 0; }
.group-facts dl div { display: grid; grid-template-columns: 7rem 1fr; gap: 1rem; padding: 0.7rem 0; border-top: 1px solid var(--line); }
.group-facts dt { color: var(--muted); font-size: 0.82rem; letter-spacing: 0.04em; text-transform: uppercase; }
.group-facts dd { margin: 0; }
.group-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.group-photos figure { margin: 0; width: auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0; overflow: hidden; }
.group-photos img { width: 100%; height: 220px; object-fit: cover; display: block; }
.group-photos figcaption, .group-docs li { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.55rem 0.7rem; }
.group-docs { list-style: none; padding: 0; margin: 0; }
.group-docs li { border-top: 1px solid var(--line); }
@media (max-width: 680px) {
  .group-who, .group-photos, .group-facts dl div { grid-template-columns: 1fr; }
  .group-who h1 { font-size: 2rem; }
}
.member-profile { display: grid; grid-template-columns: 240px 1fr; gap: 1.25rem; align-items: start; }
.member-profile .side img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 16px; display: block; }
.member-profile h1 { font-size: 1.8rem; margin: 0.8rem 0 0.2rem; }
.member-profile .card h2 { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.7rem; }
.member-profile dl { margin: 0; display: grid; gap: 0.75rem; }
.member-profile dt { font-size: 0.78rem; color: var(--muted); }
.member-profile dd { margin: 0; }
.member-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.member-photos figure { margin: 0; width: auto; background: transparent; border: 0; padding: 0; }
.member-photos img { width: 100%; height: 150px; object-fit: cover; border-radius: 12px; }
.member-photos figcaption, .member-docs li { display: flex; justify-content: space-between; gap: 0.5rem; font-size: 0.9rem; }
.member-photos figcaption { margin-top: 0.3rem; }
.member-docs { list-style: none; padding: 0; margin: 0; }
.member-docs li { padding: 0.7rem 0; border-top: 1px solid var(--line); }
@media (max-width: 760px) {
  .member-profile, .member-photos { grid-template-columns: 1fr; }
}
.gallery { display: flex; flex-wrap: wrap; gap: 1rem; }
.gallery figure { margin: 0; width: 180px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem; }
.gallery img { width: 160px; height: 120px; object-fit: cover; background: var(--line); display: block; }
.gallery figcaption { display: grid; gap: 0.2rem; margin-top: 0.4rem; }
.drop { border: 1px dashed var(--line); border-radius: 8px; padding: 0.75rem; max-width: 32rem; }
.drop.over { background: var(--card); }

nav, .subnav { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.menu-pop { position: relative; }
.menu-pop > .panel { display: none; position: absolute; z-index: 2; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0.5rem; min-width: 10rem; }
.menu-pop:hover > .panel, .menu-pop:focus-within > .panel { display: grid; gap: 0.35rem; }
.menu-pop > .panel .menu-pop > .panel { left: 100%; top: 0; }
.actions button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }
.cal-move { display: flex; gap: 1rem; }
.cal-scroll { overflow-x: auto; }
.cal-grid { display: grid; gap: 2px; min-width: 36rem; }
.cal-head, .cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.cal-head div { font-size: 0.8rem; color: var(--muted); padding: 0.2rem; }
.cal-day { min-height: 4.5rem; border: 1px solid var(--line); border-radius: 6px; padding: 0.2rem; background: var(--card); }
.cal-day.outside { opacity: 0.55; }
.cal-day.today { outline: 2px solid var(--brand); }
.cal-num { display: block; font-size: 0.8rem; }
.cal-event { display: block; width: 100%; margin-top: 0.15rem; text-align: left; font-size: 0.75rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-dialog { border: 1px solid var(--line); border-radius: 8px; padding: 1rem; max-width: 32rem; }
.cal-dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.menu-toggle { display: none; }
.group-switch { display: flex; align-items: center; gap: 0.4rem; }
.group-switch label { margin: 0; font-size: 0.85rem; color: var(--muted); }
.group-switch select { width: auto; min-width: 10rem; margin: 0; }
body.menu-side nav.primary { flex-direction: column; align-items: flex-start; }
body.menu-side .group-switch { flex-direction: column; align-items: stretch; width: 100%; }
body.menu-side .group-switch select { width: 100%; }
@media (min-width: 768px) {
  /* Left menu: the top bar keeps the logo, site name and user name; the menu sits below it on the left with the page beside it. */
  body.menu-side .page-body { display: grid; grid-template-columns: 14rem 1fr; align-items: start; }
  body.menu-side .page-body > nav.primary { position: sticky; top: 0; padding: 1rem 1.25rem; gap: 0.55rem; }
  body.menu-side .page-main { min-width: 0; }
  body.menu-side .menu-pop > .panel { left: 100%; top: 0; }
}
@media (max-width: 767px) {
  .menu-pop > .panel, .menu-pop > .panel .menu-pop > .panel { position: static; }
  .menu-toggle { display: inline-block; }
  nav.primary { display: none; width: 100%; }
  nav.primary.open { display: flex; flex-direction: column; align-items: flex-start; }
  body.menu-side .page-body > nav.primary { padding: 0.75rem 1.25rem; }
}
nav form { margin: 0; }

main { max-width: 960px; margin: 0 auto; padding: 1.25rem; }

.landing-links { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 0 0 0.5rem; }
.site-footer { max-width: 960px; margin: 0 auto; padding: 0 1.25rem 2rem; color: var(--muted); }
.check { display: flex; gap: 0.4rem; align-items: flex-start; margin-top: 0.8rem; }
.landing-links .button { margin-top: 0; }

h1 { font-size: 1.6rem; margin: 0 0 0.75rem; }

.card, form.card, .stack > * {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
}

.stack { display: grid; gap: 1rem; }

label { display: block; font-weight: 600; margin-top: 0.75rem; }
input, select, textarea {
  width: 100%;
  max-width: 32rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card);
  color: inherit;
  font: inherit;
}
textarea { min-height: 6rem; }
input[type="checkbox"], input[type="radio"] { width: auto; max-width: none; margin: 0; }

label.check {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 0.45rem;
  font-weight: 400;
  text-align: left;
}

table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
th, td { text-align: left; padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
td form { margin: 0; }
details.add-row { margin-top: 0.75rem; }
details.add-row > summary { cursor: pointer; width: fit-content; color: var(--brand); }
.bot-picker { max-height: 24rem; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 0.5rem 0.75rem; }
.bot-output { white-space: pre-wrap; margin: 0.25rem 0; }

button, .button {
  display: inline-block;
  margin-top: 0.8rem;
  padding: 0.4rem 0.8rem;
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: var(--brand-ink);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

button.quiet, .button.quiet { background: transparent; color: var(--brand); border: 1px solid var(--line); }

.password-line {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  max-width: 32rem;
}
.password-line input { flex: 1 1 auto; width: 1%; max-width: none; }
.password-line button { margin-top: 0; white-space: nowrap; }

table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.errors, .flash { padding: 0.6rem 0.8rem; border-radius: 6px; }
.errors { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, var(--card)); }
.validation-summary-valid, .field-validation-valid { display: none; }
.field-error { display: block; margin-top: 0.25rem; color: var(--danger); font-size: 0.92rem; }
.flash, .tenant { color: var(--ok); }
.tenant { margin: 0; padding: 0.4rem 1.25rem; background: var(--card); border-bottom: 1px solid var(--line); }
.muted { color: var(--muted); }
.row-actions form { display: inline; }
code { font-family: ui-monospace, monospace; }
.lesson-body { white-space: pre-wrap; }
.player { display: grid; grid-template-columns: 16rem 1fr; gap: 1rem; align-items: start; }
.lesson-nav { list-style: none; padding: 0; margin: 0; }
.lesson-nav li { margin: 0.35rem 0; }
@media (max-width: 768px) {
  .player { grid-template-columns: 1fr; }
}

.message-list li.message-item { cursor: pointer; }
.message-list li.message-item:hover, .message-list li.message-item:focus { background: rgba(0, 0, 0, 0.04); outline: none; }
.message-preview { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60ch; }
dialog.message-dialog { max-width: min(42rem, 92vw); border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.2rem; }
dialog.message-dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
dialog.message-dialog .message-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.message-list li.message-item.unread { font-weight: 600; border-left: 3px solid var(--brand); padding-left: 0.5rem; }
.message-list li.message-item.unread .message-preview { font-weight: normal; }

/* Rich editor (Quill): its own light, high-contrast chrome so every theme (default, slate, forest, custom CSS) shows the controls.
   The site's global button/select rules would otherwise paint Quill's tiny toolbar buttons with the theme colours. */
body .ql-toolbar.ql-snow { background: #f7f9fb; border: 1px solid #b8c4d0; border-radius: 6px 6px 0 0; color: #1c2430; max-width: none; }
body .ql-container.ql-snow { border: 1px solid #b8c4d0; border-top: 0; border-radius: 0 0 6px 6px; }
body .ql-snow.ql-toolbar button, body .ql-snow .ql-toolbar button {
  margin: 0; padding: 3px 5px; width: 28px; height: 24px; border: 0; border-radius: 4px;
  background: transparent; color: #1c2430; display: inline-block; float: left; line-height: 1;
}
body .ql-snow.ql-toolbar button:hover, body .ql-snow.ql-toolbar button:focus, body .ql-snow.ql-toolbar button.ql-active { background: #dde6ef; }
body .ql-snow .ql-stroke, body .ql-snow .ql-stroke-miter { stroke: #1c2430; }
body .ql-snow .ql-fill, body .ql-snow .ql-stroke.ql-fill { fill: #1c2430; }
body .ql-snow.ql-toolbar button:hover .ql-stroke, body .ql-snow.ql-toolbar button.ql-active .ql-stroke,
body .ql-snow .ql-picker-label:hover .ql-stroke, body .ql-snow .ql-picker-label.ql-active .ql-stroke { stroke: #0f4c81; }
body .ql-snow.ql-toolbar button:hover .ql-fill, body .ql-snow.ql-toolbar button.ql-active .ql-fill,
body .ql-snow .ql-picker-label:hover .ql-fill, body .ql-snow .ql-picker-label.ql-active .ql-fill { fill: #0f4c81; }
body .ql-snow .ql-picker { color: #1c2430; }
body .ql-snow .ql-picker-label { color: #1c2430; background: transparent; border-color: transparent; }
body .ql-snow .ql-picker-label:hover, body .ql-snow .ql-picker-label.ql-active, body .ql-snow .ql-picker-item:hover, body .ql-snow .ql-picker-item.ql-selected { color: #0f4c81; }
body .ql-snow .ql-picker-options { background: #fff; color: #1c2430; border: 1px solid #b8c4d0; box-shadow: 0 4px 12px rgba(0,0,0,.25); }
body .ql-snow .ql-picker.ql-expanded .ql-picker-label { border-color: #b8c4d0; color: #1c2430; }
body .ql-snow .ql-picker.ql-expanded .ql-picker-label .ql-stroke { stroke: #1c2430; }
body .ql-snow .ql-tooltip { background: #fff; color: #1c2430; border-color: #b8c4d0; }
body .ql-snow .ql-tooltip input[type="text"] { width: 170px; max-width: none; padding: 3px 5px; background: #fff; color: #1c2430; border: 1px solid #b8c4d0; }
body .ql-snow .ql-tooltip a { color: #0f4c81; }
body .rich-editor, body .rich-editor .ql-editor { background: #fff; color: #111; }
body .rich-editor .ql-editor.ql-blank::before { color: #6b7785; }
body .rich-source { background: #fff !important; color: #111 !important; border: 1px solid #b8c4d0; max-width: none; }
body .rich-tabs button { margin-top: 0.25rem; }
body .rich-tabs button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }

/* Vimeo lesson video */
.vimeo-field { border: 1px dashed currentColor; border-radius: 6px; padding: .6rem; margin: .5rem 0; }
.vimeo-chosen { display: flex; gap: .6rem; align-items: center; min-height: 2rem; }
.vimeo-chosen img { width: 120px; border-radius: 4px; }
.vimeo-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .4rem; }
.vimeo-upload-btn { cursor: pointer; padding: .35rem .8rem; border: 1px solid currentColor; border-radius: 4px; }
.vimeo-field progress { width: 100%; }
.vimeo-picker { width: min(900px, 95vw); max-height: 85vh; }
.vimeo-picker-head { display: flex; gap: .5rem; align-items: center; margin-bottom: .6rem; }
.vimeo-picker-head input[type=search] { flex: 1; }
.vimeo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .6rem; overflow: auto; }
.vimeo-card { display: flex; flex-direction: column; gap: .25rem; text-align: left; padding: .4rem; }
.vimeo-card img, .vimeo-noimg { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 4px; background: #0002; display: flex; align-items: center; justify-content: center; }
.vimeo-player { position: relative; padding-top: 56.25%; margin: 1rem 0; }
.vimeo-player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.vimeo-drop { border: 2px dashed currentColor; opacity: .7; border-radius: 6px; padding: .8rem; text-align: center; margin-bottom: .5rem; }
.vimeo-field.dragging { outline: 3px solid #4da3ff; background: #4da3ff22; }
.vimeo-field.dragging .vimeo-drop { opacity: 1; border-color: #4da3ff; }
button.danger { color: #e66; }
.member-classes .chip { display: inline-flex; align-items: center; gap: .2rem; border: 1px solid currentColor; border-radius: 999px; padding: 0 .5rem; margin: 0 .2rem .2rem 0; font-size: .9em; }
form.inline { display: inline; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .2rem .8rem; }
.facts dt { font-weight: 600; }
.new-lesson { outline: 2px solid #4da3ff; }

.hp-field { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
