:root {
  color-scheme: dark;
  --bg: #0c0c0c;
  --panel: #1a1a1a;
  --panel-2: #262626;
  --panel-3: #303030;
  --border: #3a3a3a;
  --text: #f5f5f5;
  --muted: #a3a3a3;
  --muted-2: #737373;
  --cyan: #0fffff;
  --cyan-2: #11fdfe;
  --accent-rgb: 15, 255, 255;
  --amber: #f7d77a;
  --danger: #ef4444;
  --topbar-bg: #151515;
  --tabs-bg: #1b1b1b;
  --brand-bg: #101010;
  --field-bg: #111111;
  --search-bg: #383838;
  --prose-text: #dedede;
  --soft-text: #e5e5e5;
  --course-text: #dddddd;
  --progress-bg: #353535;
  --sidebar-bg: #171717;
  --hover-bg: #242424;
  --active-bg: #2d2d2d;
  --video-bg: #121212;
  --status-bg: #181818;
  --error-bg: #2b1010;
  --quill-bg: #101010;
  --quill-toolbar-bg: #202020;
  --quill-icon: #f5f5f5;
  --quill-picker-bg: #202020;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f8f8;
  --panel: #ffffff;
  --panel-2: #f1f5f5;
  --panel-3: #e7eeee;
  --border: #cbd5d6;
  --text: #111827;
  --muted: #4b5563;
  --muted-2: #6b7280;
  --cyan: #f59e0b;
  --cyan-2: #f59e0b;
  --accent-rgb: 245, 158, 11;
  --amber: #8a5b00;
  --danger: #b91c1c;
  --topbar-bg: #ffffff;
  --tabs-bg: #eef3f3;
  --brand-bg: #f7fbfb;
  --field-bg: #ffffff;
  --search-bg: #eef3f3;
  --prose-text: #1f2937;
  --soft-text: #1f2937;
  --course-text: #374151;
  --progress-bg: #d7e0e1;
  --sidebar-bg: #ffffff;
  --hover-bg: #fff7ed;
  --active-bg: #ffedd5;
  --video-bg: #f1f5f5;
  --status-bg: #f8fbfb;
  --error-bg: #fee2e2;
  --quill-bg: #ffffff;
  --quill-toolbar-bg: #f1f5f5;
  --quill-icon: #111827;
  --quill-picker-bg: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button,
input,
textarea,
select {
  max-width: 100%;
}

h1,
h2,
h3,
p,
li,
dt,
dd,
a,
span,
strong,
label,
summary,
figcaption,
button {
  overflow-wrap: anywhere;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 220px minmax(220px, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 64px;
  padding: 8px clamp(16px, 5vw, 80px);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  min-width: 0;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  background: var(--brand-bg);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 12px;
}

.brand-title {
  font-size: 20px;
}

.search input {
  width: 100%;
  height: 44px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--search-bg);
  color: var(--text);
}

.account {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--muted);
  min-width: 0;
  flex-wrap: wrap;
}

.ghost-link {
  color: var(--cyan);
}

.theme-toggle {
  min-width: 56px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: var(--cyan);
  color: var(--cyan);
}

.admin-edit-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 16px;
}

.admin-edit-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid rgba(var(--accent-rgb), .45);
  border-radius: 999px;
  background: color-mix(in srgb, var(--cyan) 10%, var(--panel));
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.1;
  text-transform: uppercase;
  vertical-align: middle;
}

.admin-edit-icon svg {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
}

.admin-edit-icon svg path {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.admin-edit-icon.is-compact {
  min-width: 28px;
  min-height: 28px;
  padding: 5px;
}

.admin-edit-icon.is-compact span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.admin-edit-icon:hover,
.admin-edit-icon:focus-visible {
  border-color: var(--cyan);
  background: var(--cyan);
  color: #001010;
}

.admin-section-edit {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 12px;
}

.admin-floating-edit {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 4;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 30px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  height: 52px;
  padding: 0 clamp(16px, 5vw, 80px);
  background: var(--tabs-bg);
  border-bottom: 1px solid var(--border);
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 52px;
  padding: 0;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.tab.is-active {
  color: var(--text);
}

.tab.is-active::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 4px;
  background: var(--text);
}

.page {
  width: min(1120px, calc(100vw - 32px));
  margin: 28px auto 72px;
}

.notice,
.form-error {
  width: min(720px, calc(100vw - 32px));
  margin: 18px auto;
  padding: 14px 16px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: var(--error-bg);
}

.about-layout,
.lesson-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 40px;
  align-items: start;
}

.about-layout {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 320px);
  gap: 24px;
}

.lesson-layout {
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  gap: 28px;
}

.group-card,
.summary-card,
.course-card,
.lesson-panel,
.lesson-sidebar,
.auth-panel,
.admin-panel,
.empty-state {
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

.group-card,
.summary-card,
.lesson-panel {
  position: relative;
}

.group-card,
.lesson-panel,
.auth-panel,
.admin-panel,
.empty-state {
  padding: 32px;
}

.about-layout > .group-card {
  overflow: hidden;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(var(--accent-rgb), .05), rgba(26, 26, 26, 0) 260px),
    var(--panel);
}

.summary-card,
.lesson-sidebar {
  min-width: 0;
  padding: 18px;
}

.lesson-panel {
  min-width: 0;
}

.lesson-panel.has-admin-shortcut .lesson-actions {
  padding-right: 46px;
}

.group-card h1,
.lesson-panel h1,
.classroom h1,
.auth-panel h1,
.admin-panel h1 {
  margin: 0 0 24px;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
}

.about-layout .hero-art {
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 520;
  object-fit: cover;
  min-height: 286px;
  margin: 0 0 22px;
  display: block;
  border-radius: var(--radius);
  border: 1px solid var(--cyan);
}

.about-layout .about-thumb {
  width: 88px;
  height: 88px;
  margin: -58px 0 20px 24px;
  border-radius: var(--radius);
  border-width: 2px;
  border: 2px solid var(--cyan);
  background: var(--brand-bg);
  object-fit: cover;
  box-shadow: 0 0 0 6px var(--panel);
}

.about-layout .meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 28px;
  color: var(--text);
  font-weight: 700;
}

.about-layout .meta-row span,
.about-layout .meta-row a {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--soft-text);
  font-size: 14px;
}

.about-layout .meta-row span:first-child {
  border-color: rgba(var(--accent-rgb), .55);
  color: var(--cyan);
}

.about-layout .meta-row a:hover,
.about-layout .meta-row a:focus-visible {
  border-color: var(--cyan);
  color: var(--cyan);
}

.prose {
  color: var(--prose-text);
  line-height: 1.7;
}

.about-layout .prose {
  max-width: 72ch;
}

.prose h2,
.prose h3 {
  color: var(--text);
  line-height: 1.2;
}

.prose ul {
  padding-left: 24px;
}

.course-art {
  min-height: 140px;
  display: grid;
  place-items: center;
  border-radius: var(--radius) var(--radius) 0 0;
  background:
    linear-gradient(135deg, rgba(var(--accent-rgb), .22), rgba(34, 197, 94, .12)),
    repeating-linear-gradient(45deg, #0d777a 0 30px, #195f70 30px 60px);
  color: #f8fafc;
  font-weight: 900;
  text-align: center;
}

.summary-banner {
  width: 100%;
  min-height: 140px;
  display: block;
  object-fit: cover;
  border-radius: var(--radius) var(--radius) 0 0;
  background: #102728;
}

.about-layout .summary-card h2 {
  margin: 18px 0 8px;
}

.about-layout > .summary-card {
  position: sticky;
  top: 150px;
}

.about-layout .summary-card p {
  color: #d7d7d7;
  line-height: 1.5;
}

.about-layout .stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 18px 0;
}

.about-layout .stats a {
  display: block;
  padding: 12px 6px;
  text-align: center;
}

.about-layout .stats a:hover,
.about-layout .stats a:focus-visible {
  background: var(--hover-bg);
  color: var(--cyan);
}

.about-layout .stats dt {
  font-size: 18px;
  font-weight: 800;
}

.about-layout .stats dd {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.community-page,
.calendar-page,
.map-page,
.members-page,
.leaderboards-page {
  min-width: 0;
}

.filter-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 18px;
}

.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font-weight: 900;
}

.filter-tab b {
  color: var(--cyan);
}

.filter-tab.is-active,
.filter-tab:hover,
.filter-tab:focus-visible {
  border-color: var(--cyan);
  background: color-mix(in srgb, var(--cyan) 9%, var(--panel));
}

.activity-list,
.calendar-list,
.map-directory,
.member-list,
.leaderboard-list {
  display: grid;
  gap: 12px;
}

.activity-row,
.calendar-row,
.map-member,
.member-row,
.leaderboard-row {
  min-width: 0;
  display: grid;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

.activity-row {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
}

.activity-body,
.calendar-body {
  min-width: 0;
}

.activity-body header,
.comment-body header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.activity-body header b,
.comment-body header b {
  color: var(--text);
}

.activity-body p {
  margin: 8px 0 10px;
  color: var(--soft-text);
  line-height: 1.55;
}

.activity-context {
  color: var(--cyan);
  font-size: 14px;
  font-weight: 800;
}

.calendar-row {
  grid-template-columns: minmax(110px, 150px) minmax(0, 1fr);
  align-items: start;
}

.calendar-date {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid rgba(var(--accent-rgb), .42);
  border-radius: var(--radius);
  background: rgba(var(--accent-rgb), .07);
  color: var(--cyan);
}

.calendar-date b {
  font-size: 16px;
  line-height: 1.2;
}

.calendar-date span,
.calendar-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.calendar-body h2 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.25;
}

.calendar-body p {
  margin: 0 0 12px;
  color: var(--course-text);
  line-height: 1.5;
}

.calendar-outline {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.calendar-outline li {
  min-width: 0;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--soft-text);
}

.calendar-outline b {
  color: var(--cyan);
}

.map-directory {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.map-member {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
}

.member-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.member-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--cyan);
  border-radius: 50%;
  background: var(--brand-bg);
  color: var(--cyan);
  font-size: 13px;
  font-weight: 900;
}

.member-info {
  min-width: 0;
}

.member-info h2,
.leaderboard-body h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.member-info p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.member-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.member-badges span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.member-badges .is-online {
  border-color: var(--cyan);
  color: var(--cyan);
}

.leaderboard-row {
  grid-template-columns: auto auto minmax(0, 1fr) auto;
}

.leaderboard-rank {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 900;
}

.leaderboard-body {
  min-width: 0;
}

.leaderboard-body .progress {
  margin-top: 20px;
}

.leaderboard-row strong {
  color: var(--cyan);
  white-space: nowrap;
}

.empty-copy {
  margin: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--muted);
}

.about-layout .owner-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  color: var(--soft-text);
  font-weight: 700;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--cyan);
  background: var(--brand-bg);
  object-fit: cover;
}

.primary-button,
.secondary-button,
.complete-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  background: var(--cyan);
  color: #001010;
}

.secondary-button {
  width: 100%;
  border-color: var(--border);
  background: var(--panel-2);
  color: var(--text);
  text-transform: uppercase;
}

.about-layout .secondary-button {
  border-color: rgba(var(--accent-rgb), .55);
  background: #102728;
  color: var(--cyan);
}

.complete-button {
  gap: 10px;
  background: var(--panel-3);
  color: var(--text);
  border-color: var(--border);
}

.complete-button::before {
  content: "";
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.complete-button:hover,
.complete-button:focus-visible {
  border-color: var(--cyan);
}

.complete-button.is-complete {
  background: var(--amber);
  color: #191919;
}

.complete-button.is-complete::before {
  background: currentColor;
  box-shadow: inset 0 0 0 3px var(--amber);
}

.complete-button.is-saving,
.complete-button:disabled {
  cursor: default;
  opacity: .78;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.section-head span {
  color: var(--muted);
}

.classroom {
  max-width: 760px;
  margin: 0 auto;
}

.course-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.classroom-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.pagination-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.pagination-button,
.page-number {
  min-width: 38px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
}

.pagination-button {
  min-width: 92px;
}

.pagination-button:hover,
.pagination-button:focus-visible,
.page-number:hover,
.page-number:focus-visible,
.page-number.is-active {
  border-color: var(--cyan);
  background: color-mix(in srgb, var(--cyan) 9%, var(--panel));
  color: var(--cyan);
}

.pagination-button.is-disabled {
  color: var(--muted-2);
  cursor: default;
  opacity: .7;
}

.course-card {
  position: relative;
  overflow: hidden;
  min-height: 355px;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .035), transparent 42%),
    var(--panel);
  box-shadow: 0 18px 40px rgba(0, 0, 0, .24);
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}

.course-card:hover,
.course-card:focus-within {
  border-color: rgba(var(--accent-rgb), .58);
  box-shadow: 0 22px 50px rgba(0, 0, 0, .34), 0 0 0 1px rgba(var(--accent-rgb), .12);
  transform: translateY(-2px);
}

.course-card:focus-within {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.course-main-link {
  display: block;
  min-width: 0;
  height: 187px;
  flex: 0 0 187px;
}

.course-art {
  position: relative;
  min-height: 0;
  height: 100%;
  aspect-ratio: auto;
  align-content: end;
  justify-items: start;
  padding: 18px;
  border-radius: 0;
  background:
    radial-gradient(circle at 78% 18%, rgba(247, 215, 122, .18), transparent 24%),
    linear-gradient(135deg, rgba(var(--accent-rgb), .25), rgba(34, 197, 94, .10)),
    repeating-linear-gradient(45deg, #0a6f72 0 24px, #164e63 24px 48px);
  font-size: 14px;
}

.course-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent 34%, rgba(0, 0, 0, .46)),
    linear-gradient(90deg, rgba(0, 0, 0, .18), transparent 58%);
}

.course-art::after {
  content: "";
  position: absolute;
  top: 16px;
  right: 16px;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, .38);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(var(--accent-rgb), .28), transparent 64%),
    rgba(0, 0, 0, .36);
  clip-path: circle(50%);
}

.course-art span {
  position: relative;
  width: clamp(58px, 30%, 86px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px solid rgba(var(--accent-rgb), .9);
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, .16), transparent 32%),
    rgba(8, 21, 24, .86);
  color: #f8fafc;
  font-size: clamp(20px, 3vw, 30px);
  line-height: 1;
  letter-spacing: 0;
  box-shadow: 0 18px 38px rgba(0, 0, 0, .3);
}

.course-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  padding: 20px 18px 18px;
}

.field-help {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.course-admin-actions {
  position: absolute;
  top: 14px;
  right: 54px;
  z-index: 5;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0;
}

.course-state {
  width: max-content;
  max-width: 100%;
  margin-bottom: 12px;
  padding: 6px 9px;
  border: 1px solid rgba(var(--accent-rgb), .45);
  border-radius: 6px;
  background: rgba(var(--accent-rgb), .08);
  color: var(--cyan);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.course-body h2 {
  margin: 0 0 10px;
  font-size: 20px;
  line-height: 1.25;
}

.course-body p {
  margin: 0 0 22px;
  color: var(--course-text);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.progress {
  position: relative;
  height: 10px;
  margin-top: auto;
  overflow: visible;
  border-radius: 999px;
  background: var(--progress-bg);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 10%, transparent);
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--cyan-2));
}

.progress b {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.lesson-sidebar {
  position: sticky;
  top: 142px;
  max-height: calc(100vh - 168px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--sidebar-bg);
}

.lesson-course-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  margin: 14px 0 12px;
}

.lesson-course-head h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.lesson-course-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: var(--cyan);
  font-size: 14px;
  font-weight: 800;
}

.module-group {
  padding: 14px 0 0;
  border-top: 1px solid var(--border);
}

.module-group + .module-group {
  margin-top: 18px;
}

.module-group h2 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-progress {
  margin: 0 0 18px;
  padding: 0;
  border: 0;
  background: transparent;
}

.lesson-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--soft-text);
  font-size: 14px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.lesson-link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.lesson-link::before {
  content: "";
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border: 1px solid var(--muted-2);
  border-radius: 50%;
}

.lesson-link:hover,
.lesson-link:focus-visible {
  background: var(--hover-bg);
  color: var(--text);
}

.lesson-link.is-active {
  background: var(--active-bg);
  color: var(--text);
  box-shadow: inset 3px 0 0 var(--cyan);
  font-weight: 800;
}

.lesson-link.is-active::before {
  border-color: var(--cyan);
  background: var(--cyan);
}

.lesson-link.is-complete:not(.is-active)::before {
  border-color: var(--cyan);
  background: var(--cyan);
}

.lesson-actions {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  padding-bottom: 22px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--border);
}

.lesson-actions h1 {
  flex: 1 1 320px;
  margin: 0;
}

.lesson-actions form {
  flex: 0 0 auto;
}

.prose {
  min-width: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

.prose h2,
.prose h3,
.prose h4 {
  margin: 26px 0 14px;
  line-height: 1.2;
  letter-spacing: 0;
}

.prose h2:first-child,
.prose h3:first-child,
.prose h4:first-child {
  margin-top: 0;
}

.prose h2 {
  font-size: clamp(24px, 2.4vw, 32px);
}

.prose h3 {
  font-size: 22px;
}

.prose h4 {
  font-size: 18px;
}

.prose p,
.prose li {
  color: var(--soft-text);
  font-size: 16px;
  line-height: 1.7;
}

.prose p {
  margin: 0 0 18px;
}

.prose ol,
.prose ul {
  display: grid;
  gap: 12px;
  margin: 0 0 24px;
  padding-left: 24px;
}

.prose hr {
  height: 1px;
  margin: 30px 0;
  border: 0;
  background: var(--border);
}

.lesson-discussion {
  margin-top: 34px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}

.lesson-discussion h2 {
  margin: 0 0 16px;
  font-size: 22px;
  line-height: 1.2;
}

.comment-list {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

.comment-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-2);
}

.comment-body {
  min-width: 0;
}

.comment-body header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
}

.comment-body time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.comment-body p {
  margin: 0;
  color: var(--soft-text);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.lesson-comment-form {
  display: grid;
  gap: 12px;
}

.lesson-comment-form label {
  color: var(--text);
  font-weight: 900;
}

.student-editor {
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.student-editor .ql-editor {
  min-height: 120px;
}

.video-box {
  margin: 28px 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--video-bg);
}

.video-box.is-hls-ready {
  border-color: #285f5f;
}

.video-box.is-hls-waiting,
.video-box.is-hls-error {
  border-color: #745d2d;
}

.video-box figcaption {
  margin-bottom: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.video-box video {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  background: #000;
  border-radius: var(--radius);
}

.video-box iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  border: 0;
  border-radius: var(--radius);
  background: #000;
}

.video-box p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.video-status {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--status-bg);
}

.video-status.is-error {
  border-color: var(--danger);
  background: var(--error-bg);
  color: var(--text);
}

.auth-panel {
  max-width: 520px;
  margin: 80px auto;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.auth-form input {
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--field-bg);
  color: var(--text);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.admin-grid article {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel-2);
}

.admin-list {
  display: grid;
  gap: 18px;
  margin-top: 28px;
}

.admin-course {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

.admin-course h2 {
  margin: 0 0 12px;
}

.admin-course-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  flex-wrap: wrap;
}

.admin-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 14px;
  font-weight: 800;
}

.admin-row {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.admin-row span {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.admin-row small {
  color: var(--muted);
  font-size: 13px;
}

.admin-row b,
.edit-link,
.inline-admin-link {
  color: var(--cyan);
}

.editor-admin {
  max-width: 960px;
  margin: 0 auto;
}

.lesson-editor-form,
.about-editor-form,
.course-creator-form,
.course-editor-form,
.lesson-creator-form,
.module-editor-form {
  display: grid;
  gap: 18px;
}

.lesson-editor-form label,
.about-editor-form label,
.course-creator-form label,
.course-editor-form label,
.lesson-creator-form label,
.module-editor-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.lesson-editor-form input,
.lesson-editor-form textarea,
.about-editor-form input,
.about-editor-form textarea,
.course-creator-form input,
.course-creator-form textarea,
.course-editor-form input,
.course-editor-form textarea,
.course-editor-form select,
.lesson-creator-form input,
.lesson-creator-form textarea,
.lesson-creator-form select,
.module-editor-form input {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--field-bg);
  color: var(--text);
}

.rich-editor-source {
  display: none;
}

.course-creator-form textarea,
.course-editor-form textarea,
.lesson-creator-form textarea {
  resize: vertical;
}

.course-creator-form .checkbox-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.course-creator-form .checkbox-row input {
  min-height: 0;
  width: 18px;
  height: 18px;
  padding: 0;
  accent-color: var(--cyan);
}

.rich-editor-label {
  color: var(--muted);
  font-weight: 800;
}

.form-grid-2,
.form-grid-3 {
  display: grid;
  gap: 14px;
}

.form-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.small-button {
  width: auto;
  min-width: 150px;
}

.form-context {
  margin: -12px 0 4px;
  color: var(--muted);
  font-weight: 800;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.notice-inline {
  display: inline-block;
  padding: 10px 12px;
  border: 1px solid var(--cyan);
  border-radius: var(--radius);
  background: rgba(var(--accent-rgb), .08);
  color: var(--cyan);
}

.notice-inline a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.quill-editor {
  max-width: 100%;
  min-height: 360px;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--quill-bg);
}

.ql-toolbar,
.ql-container,
.ql-editor {
  max-width: 100%;
}

.ql-toolbar.ql-snow,
.ql-container.ql-snow {
  border-color: var(--border);
}

.ql-toolbar.ql-snow {
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--quill-toolbar-bg);
}

.ql-snow .ql-stroke {
  stroke: var(--quill-icon);
}

.ql-snow .ql-fill {
  fill: var(--quill-icon);
}

.ql-snow .ql-picker,
.ql-snow .ql-picker-options {
  color: var(--quill-icon);
}

.ql-editor {
  color: var(--text);
}

.ql-snow .ql-picker-options {
  background: var(--quill-picker-bg);
  border-color: var(--border);
}

.ql-snow .ql-picker-label,
.ql-snow .ql-picker-item {
  color: var(--quill-icon);
}

.ql-snow .ql-picker-label:hover,
.ql-snow .ql-picker-item:hover,
.ql-snow .ql-picker-item.ql-selected,
.ql-snow .ql-picker-label.ql-active {
  color: var(--cyan);
}

.ql-snow button:hover .ql-stroke,
.ql-snow button:focus .ql-stroke,
.ql-snow button.ql-active .ql-stroke,
.ql-snow .ql-picker-label:hover .ql-stroke {
  stroke: var(--cyan);
}

.ql-snow button:hover .ql-fill,
.ql-snow button:focus .ql-fill,
.ql-snow button.ql-active .ql-fill,
.ql-snow .ql-picker-label:hover .ql-fill {
  fill: var(--cyan);
}

.ql-editor {
  min-height: 360px;
  font-size: 16px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.ql-editor.ql-blank::before {
  color: var(--muted);
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 170px minmax(160px, 1fr) auto;
    gap: 10px;
    padding-inline: 24px;
  }

  .brand-title {
    font-size: 18px;
  }

  .account {
    justify-content: flex-end;
    gap: 10px;
  }

  .account-name {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .about-layout {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 250px);
    gap: 16px;
  }

  .lesson-layout {
    grid-template-columns: minmax(210px, 230px) minmax(0, 1fr);
    gap: 16px;
  }

  .about-layout > .summary-card {
    position: static;
  }

  .lesson-sidebar {
    position: sticky;
    top: 132px;
    order: 0;
    max-height: calc(100vh - 152px);
  }

  .lesson-panel {
    order: 0;
  }

  .lesson-actions {
    display: grid;
    padding-right: 0;
  }

  .lesson-panel.has-admin-shortcut .lesson-actions {
    padding-right: 0;
  }

  .lesson-actions form,
  .complete-button {
    width: 100%;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .classroom-pagination {
    display: grid;
    justify-items: start;
  }

  .editor-actions {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 640px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding-inline: 16px;
  }

  .search {
    grid-column: 1 / -1;
  }

  .account {
    justify-content: flex-start;
    grid-column: 1 / -1;
  }

  .page {
    width: min(100% - 24px, 1120px);
    margin-top: 20px;
  }

  .about-layout,
  .lesson-layout {
    grid-template-columns: 1fr;
  }

  .lesson-sidebar {
    position: static;
    order: 1;
    max-height: none;
  }

  .lesson-panel {
    order: 2;
  }

  .course-list {
    grid-template-columns: 1fr;
  }

  .course-card {
    min-height: 0;
  }

  .course-main-link {
    height: auto;
    min-height: 180px;
    flex-basis: auto;
  }

  .course-art {
    aspect-ratio: 1.9 / 1;
  }

  .about-layout > .group-card,
  .about-layout > .summary-card {
    padding: 18px;
  }

  .about-layout .hero-art {
    min-height: 0;
  }

  .about-layout .about-thumb {
    margin-left: 12px;
  }

  .about-layout .stats {
    grid-template-columns: 1fr;
  }

  .member-row,
  .activity-row,
  .calendar-row,
  .map-member,
  .leaderboard-row {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .map-directory {
    grid-template-columns: 1fr;
  }

  .member-badges {
    justify-content: flex-start;
  }

  .leaderboard-row strong {
    white-space: normal;
  }

  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .admin-row {
    display: grid;
  }

  .admin-edit-bar,
  .admin-section-edit,
  .course-admin-actions {
    justify-content: stretch;
  }

  .admin-edit-icon:not(.is-compact) {
    width: 100%;
  }

  .primary-button,
  .secondary-button,
  .complete-button,
  .small-button {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    white-space: normal;
    text-align: center;
  }
}
