:root {
  --bg: #f7f3ed;
  --panel: #fffaf3;
  --panel-strong: #ffffff;
  --ink: #1d1b18;
  --muted: #6b6258;
  --line: #e2d7c9;
  --brand: #7a4e2d;
  --brand-dark: #4b2f1e;
  --brand-soft: #f0dfcd;
  --accent: #1f6f62;
  --danger: #b02a37;
  --warning: #996515;
  --shadow: 0 18px 45px rgba(51, 35, 22, .10);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, var(--brand-soft) 0, transparent 30rem), var(--bg);
  color: var(--ink);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 22px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel), var(--brand-soft));
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 30px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--brand-dark);
  color: #fff;
  font-size: 28px;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 21px; line-height: 1; }
h2 { margin-bottom: 0; font-size: clamp(26px, 3vw, 38px); }
h3 { margin-bottom: 10px; font-size: 23px; }

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  padding: 13px 14px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 750;
}

.nav-item:hover, .nav-item.active {
  background: var(--brand-dark);
  color: #fff;
}

.sidebar-card {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 24px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.64);
  box-shadow: var(--shadow);
}
.sidebar-card p:last-child { margin-bottom: 0; color: var(--muted); font-size: 14px; }

.main-content {
  padding: 30px;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 25px;
}

.topbar-actions, .hero-actions, .form-actions, .filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button, .secondary-button, .ghost-button, .danger-button, .link-button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  font-weight: 800;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}

.primary-button {
  background: var(--brand-dark);
  color: #fff;
  box-shadow: 0 10px 22px rgba(75, 47, 30, .18);
}
.secondary-button {
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.ghost-button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.58);
  color: var(--brand-dark);
}
.danger-button {
  background: #fee8e9;
  color: var(--danger);
}
.link-button {
  padding: 8px 0;
  background: transparent;
  color: var(--brand);
}
.primary-button:hover, .secondary-button:hover, .ghost-button:hover, .danger-button:hover { transform: translateY(-1px); }

.view { display: none; }
.active-view { display: block; }

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, .7fr);
  gap: 24px;
  margin-bottom: 22px;
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--panel), var(--brand-soft));
  box-shadow: var(--shadow);
}

.hero-panel h3 {
  font-size: clamp(32px, 5vw, 54px);
  line-height: .96;
  margin-bottom: 16px;
}
.hero-copy { max-width: 760px; color: var(--muted); font-size: 18px; line-height: 1.55; }

.quality-card, .notice-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,.64);
}
.quality-card ul { margin: 12px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.8; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}
.stat-card strong { display: block; font-size: 31px; margin-bottom: 4px; }
.stat-card span { color: var(--muted); font-weight: 700; }

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
  gap: 22px;
}

.panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255,250,243,.88);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.panel-header h3 { margin-bottom: 0; }

.timeline {
  display: grid;
  gap: 15px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.timeline li { display: grid; grid-template-columns: 36px minmax(0,1fr); gap: 12px; }
.timeline span {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-dark);
  color: #fff;
  font-weight: 900;
}
.timeline p { margin-bottom: 0; color: var(--muted); }

.builder-layout { display: grid; gap: 18px; }
.form-panel { max-width: 1080px; }

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

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}
input, select, textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #dacdbb;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(122, 78, 45, .12); }

.notice-card { margin-bottom: 18px; color: var(--muted); line-height: 1.55; }
.notice-card strong { color: var(--ink); }
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 11px;
  margin-bottom: 18px;
}
.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
}
.checkbox-grid input { width: auto; }
.full-width { grid-column: 1 / -1; }

.course-grid, .learner-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.course-list.compact { display: grid; gap: 12px; }

.course-card, .learner-card, .mini-course-row {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 8px 20px rgba(51, 35, 22, .06);
}
.course-card h4, .learner-card h4, .mini-course-row h4 { margin: 0 0 8px; font-size: 18px; }
.course-card p, .learner-card p, .mini-course-row p { color: var(--muted); line-height: 1.48; }

.card-meta, .badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 900;
}
.badge.green { background: #dff3ed; color: #135c51; }
.badge.gold { background: #f7e7b7; color: #6e4e00; }
.badge.red { background: #fbe3e5; color: #8f1d2a; }
.badge.gray { background: #eeeeee; color: #4a4a4a; }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.card-actions button { padding: 9px 12px; font-size: 13px; }

.library-header { align-items: center; }
.filter-row input, .filter-row select { min-width: 190px; }

.progress-shell {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #efe5d8;
  margin: 14px 0 6px;
}
.progress-bar {
  height: 100%;
  width: 42%;
  border-radius: 999px;
  background: var(--accent);
}

.course-dialog {
  width: min(980px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  border: 0;
  border-radius: 26px;
  padding: 0;
  box-shadow: 0 35px 80px rgba(0,0,0,.28);
}
.course-dialog::backdrop { background: rgba(31, 24, 17, .48); backdrop-filter: blur(4px); }
.dialog-inner { padding: 28px; background: var(--panel); }
.dialog-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.close-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 900;
}
.module-list { display: grid; gap: 14px; margin: 18px 0; }
.module-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}
.module-card h4 { margin: 0 0 8px; }
.module-card ul { margin: 10px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.7; }
.quiz-list { display: grid; gap: 10px; padding-left: 20px; }
.quiz-list li { line-height: 1.55; }

.settings-panel { max-width: 900px; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--brand-dark);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: all .18s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

.empty-state {
  padding: 28px;
  border: 1px dashed #c9bbaa;
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
  background: rgba(255,255,255,.5);
}

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    display: grid;
    gap: 16px;
  }
  .nav-list { grid-template-columns: repeat(5, minmax(0,1fr)); }
  .sidebar-card { position: static; }
  .hero-panel, .two-column { grid-template-columns: 1fr; }
  .stat-grid, .course-grid, .learner-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 760px) {
  .main-content { padding: 18px; }
  .topbar, .panel-header, .library-header { display: grid; }
  .topbar-actions, .filter-row { align-items: stretch; }
  .topbar-actions button, .filter-row input, .filter-row select { width: 100%; }
  .nav-list { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .form-grid, .checkbox-grid, .stat-grid, .course-grid, .learner-grid { grid-template-columns: 1fr; }
  .hero-panel { padding: 24px; }
  .hero-panel h3 { font-size: 34px; }
}

.media-plan {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: #fffdf8;
  margin: 10px 0 20px;
}

.media-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.cue-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.cue-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  font-size: .9rem;
}

.cue-table th,
.cue-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.cue-table th {
  background: #f7efe2;
  color: var(--ink);
}

.small-muted {
  color: var(--muted);
  font-size: .9rem;
}

.hidden { display: none !important; }

.owner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 16px;
}

.quiet-list {
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.55;
}

.private-note {
  background: #fffaf4;
}

.edit-status {
  grid-column: 1 / -1;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand-dark);
  border-radius: 16px;
  background: #fffaf4;
  color: var(--brand-dark);
  box-shadow: 0 8px 20px rgba(51, 35, 22, .06);
}

.private-method-panel details {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 14px 16px;
}

.private-method-panel summary {
  cursor: pointer;
  font-weight: 900;
  color: var(--brand-dark);
}

.compact-timeline {
  margin-top: 16px;
}

.content-editor-shell {
  max-width: 1180px;
}

.editor-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.editor-toolbar select {
  min-width: 280px;
}

.content-editor-body {
  display: grid;
  gap: 18px;
}

.editor-header-card,
.editor-section,
.sticky-editor-actions {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  padding: 18px;
  box-shadow: 0 8px 20px rgba(51, 35, 22, .06);
}

.editor-header-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.editor-header-card p:last-child {
  color: var(--muted);
  margin-bottom: 0;
}

.compact-header {
  margin-bottom: 12px;
}

.compact-header h4 {
  margin: 0;
  font-size: 20px;
}

.editor-stack {
  display: grid;
  gap: 14px;
}

.compact-editor-stack {
  gap: 10px;
}

.editor-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffaf4;
  padding: 16px;
}

.editor-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.editor-card-top h5 {
  margin: 0;
  font-size: 16px;
}

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

.sticky-editor-actions {
  position: sticky;
  bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  z-index: 10;
}

@media (max-width: 1080px) {
  .nav-list { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .editor-header-card { display: grid; }
  .cue-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .editor-toolbar,
  .editor-toolbar select,
  .editor-toolbar button,
  .sticky-editor-actions button { width: 100%; }
  .cue-grid { grid-template-columns: 1fr; }
}

/* v6 Script, Voiceover & Audio Cleanup Studio */
.wide-filter-row {
  grid-template-columns: minmax(240px, 1fr) auto;
  width: min(720px, 100%);
}

.content-editor-body {
  margin-top: 1rem;
}

.voiceover-header-card {
  align-items: stretch;
}

.voiceover-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: .75rem;
  min-width: 280px;
}

.voiceover-status-grid span {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: .85rem;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .86rem;
}

.voiceover-status-grid strong {
  display: block;
  color: var(--ink);
  font-size: 1.25rem;
}

.voiceover-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin: 1rem 0;
}

.voiceover-stack .editor-card {
  border-left: 5px solid rgba(32, 82, 75, .35);
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-weight: 700;
  color: var(--ink);
}

.inline-check input {
  width: auto;
}

.small-muted {
  color: var(--muted);
  font-size: .85rem;
  margin: .2rem 0 0;
}

@media (max-width: 760px) {
  .wide-filter-row {
    grid-template-columns: 1fr;
  }

  .voiceover-status-grid {
    grid-template-columns: 1fr;
    min-width: 0;
  }
}

.voice-checkbox {
  align-self: end;
  min-height: 48px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.65);
}

.voice-checkbox input {
  margin-right: 8px;
}


/* v8 Learner Player & Categorized Library */
.library-filter-grid,
.learner-filter-grid {
  grid-template-columns: minmax(220px, 1.3fr) repeat(3, minmax(150px, .7fr));
  width: min(980px, 100%);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: .75rem 0;
}

.tag-row span,
.lesson-row em {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.7);
  color: var(--muted);
  border-radius: 999px;
  padding: .22rem .55rem;
  font-size: .78rem;
  font-style: normal;
}

.learner-player-panel {
  margin-top: 1rem;
}

.learner-player-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  margin-bottom: 1rem;
}

.learner-progress-card {
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  background: var(--surface-soft);
  text-align: right;
}

.learner-progress-card strong {
  display: block;
  font-size: 2rem;
  color: var(--ink);
}

.large-progress {
  height: 12px;
  margin: .75rem 0 1.25rem;
}

.learner-player-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 1.2rem;
}

.module-playlist {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1rem;
  background: rgba(255,255,255,.65);
}

.module-playlist h4 {
  margin-top: 0;
}

.playlist-item {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: .75rem;
  margin-bottom: .6rem;
  display: flex;
  gap: .75rem;
  align-items: start;
  text-align: left;
  cursor: pointer;
}

.playlist-item span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-soft);
  font-weight: 800;
}

.playlist-item.active {
  border-color: rgba(32, 82, 75, .65);
  box-shadow: 0 8px 18px rgba(32, 82, 75, .12);
}

.playlist-item.done span {
  background: rgba(32, 128, 91, .13);
  color: #16724e;
}

.playlist-item small {
  display: block;
  color: var(--muted);
  margin-top: .25rem;
}

.lesson-stage {
  display: grid;
  gap: 1rem;
}

.media-placeholder {
  min-height: 210px;
  border: 1px dashed rgba(32, 82, 75, .45);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(32,82,75,.08), rgba(201,164,92,.08));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
}

.play-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.lesson-content-block {
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 1.25rem;
  background: #fff;
}

.lesson-content-block h4,
.lesson-content-block h5 {
  margin-bottom: .4rem;
}

.certificate-ready {
  margin-top: 1rem;
}

.lesson-directory {
  display: grid;
  gap: .85rem;
}

.lesson-group {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: .8rem 1rem;
  background: rgba(255,255,255,.7);
}

.lesson-group summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--ink);
}

.lesson-group summary span {
  color: var(--muted);
  font-weight: 600;
  margin-left: .5rem;
}

.lesson-table {
  display: grid;
  gap: .5rem;
  margin-top: .8rem;
}

.lesson-row {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: .8rem;
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(140px, .7fr) minmax(160px, .8fr) minmax(180px, 1fr);
  gap: .75rem;
  align-items: center;
  text-align: left;
  cursor: pointer;
}

.lesson-row small {
  display: block;
  color: var(--muted);
  margin-top: .2rem;
}

@media (max-width: 980px) {
  .library-filter-grid,
  .learner-filter-grid,
  .learner-player-grid,
  .lesson-row {
    grid-template-columns: 1fr;
  }

  .learner-player-header {
    display: grid;
  }

  .learner-progress-card {
    text-align: left;
  }
}

/* v9 Theme presets and visual media additions */
:root[data-theme="plum"] {
  --bg: #f7f4fb;
  --panel: #fffaff;
  --panel-strong: #ffffff;
  --ink: #201a27;
  --muted: #675e72;
  --line: #e4d8ee;
  --brand: #7c3f8c;
  --brand-dark: #46225a;
  --brand-soft: #eeddf6;
  --accent: #b7791f;
  --shadow: 0 18px 45px rgba(70, 34, 90, .12);
}

:root[data-theme="teal"] {
  --bg: #eff8f7;
  --panel: #faffff;
  --panel-strong: #ffffff;
  --ink: #142525;
  --muted: #526767;
  --line: #cfe5e2;
  --brand: #148276;
  --brand-dark: #0f3f4b;
  --brand-soft: #d9f0ed;
  --accent: #274690;
  --shadow: 0 18px 45px rgba(15, 63, 75, .12);
}

:root[data-theme="rose"] {
  --bg: #fff4f7;
  --panel: #fffafb;
  --panel-strong: #ffffff;
  --ink: #241c20;
  --muted: #6b5f65;
  --line: #ead3dc;
  --brand: #b03a63;
  --brand-dark: #4a2734;
  --brand-soft: #f6dce6;
  --accent: #3f6f68;
  --shadow: 0 18px 45px rgba(74, 39, 52, .12);
}

:root[data-theme="emerald"] {
  --bg: #f1f8f3;
  --panel: #fbfffc;
  --panel-strong: #ffffff;
  --ink: #17231c;
  --muted: #59695f;
  --line: #d3e6d8;
  --brand: #2d8a57;
  --brand-dark: #1d3f30;
  --brand-soft: #ddf0e4;
  --accent: #8a5d2d;
  --shadow: 0 18px 45px rgba(29, 63, 48, .12);
}

:root[data-theme="indigo"] {
  --bg: #f4f6fc;
  --panel: #fbfcff;
  --panel-strong: #ffffff;
  --ink: #171b28;
  --muted: #5d6375;
  --line: #d8deef;
  --brand: #4c5fd7;
  --brand-dark: #26315e;
  --brand-soft: #e1e6fb;
  --accent: #7b5e1d;
  --shadow: 0 18px 45px rgba(38, 49, 94, .12);
}

:root[data-theme="brown"] {
  --bg: #f7f3ed;
  --panel: #fffaf3;
  --panel-strong: #ffffff;
  --ink: #1d1b18;
  --muted: #6b6258;
  --line: #e2d7c9;
  --brand: #7a4e2d;
  --brand-dark: #4b2f1e;
  --brand-soft: #f0dfcd;
  --accent: #1f6f62;
  --shadow: 0 18px 45px rgba(51, 35, 22, .10);
}

.visual-stage {
  background-size: cover;
  background-position: center;
  color: #fff;
  min-height: 230px;
  text-shadow: 0 1px 2px rgba(0,0,0,.45);
}
.visual-stage small { display: block; opacity: .92; margin-top: 6px; }

.quiz-panel {
  margin: 18px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-strong);
}
.compact-header { align-items: flex-start; }
.quiz-form { display: grid; gap: 14px; margin: 12px 0; }
.quiz-question {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: rgba(255,255,255,.7);
}
.quiz-question legend { font-weight: 800; padding: 0 6px; }
.quiz-question label { display: block; margin-top: 10px; color: var(--muted); }

.visual-cover-preview {
  min-height: 180px;
  margin-top: 16px;
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--brand-soft), rgba(255,255,255,.75));
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-end;
  color: var(--ink);
}
.visual-cover-preview.has-cover { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.45); }
.visual-cover-preview p { margin-bottom: 0; }

.visual-module-list { display: grid; gap: 16px; }
.visual-module-card {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-strong);
}
.visual-thumb {
  min-height: 140px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--brand-soft), rgba(255,255,255,.85));
  border: 1px dashed var(--line);
  background-size: cover;
  background-position: center;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}
.visual-fields { min-width: 0; }
.certificate-ready .secondary-button { margin-left: 10px; }

@media (max-width: 760px) {
  .visual-module-card { grid-template-columns: 1fr; }
}

/* v10 additions: charts, creator plans, and help center */
.plan-editor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.plan-card,
.check-card,
.help-card,
.chart-editor-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  padding: 1rem;
  box-shadow: var(--shadow-soft);
}

.plan-card label,
.chart-editor-card label {
  display: grid;
  gap: .4rem;
  font-size: .86rem;
  color: var(--muted);
}

.plan-card input,
.plan-card textarea,
.chart-editor-card input,
.chart-editor-card textarea,
.chart-editor-card select {
  width: 100%;
}

.featured-plan {
  outline: 2px solid var(--accent);
}

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

.check-card p {
  color: var(--muted);
  margin-bottom: 0;
}

.chart-card-list {
  display: grid;
  gap: 1rem;
}

.chart-preview-box {
  display: grid;
  grid-template-columns: minmax(180px, .75fr) minmax(240px, 1fr);
  gap: 1rem;
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 16px;
  background: var(--soft-surface);
}

.mini-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
}

.mini-data-table th,
.mini-data-table td {
  border: 1px solid var(--border);
  padding: .45rem .55rem;
  text-align: left;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.help-card {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 1rem;
}

.video-placeholder {
  min-height: 120px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: var(--accent-contrast);
  display: grid;
  place-items: center;
  align-content: center;
  gap: .35rem;
  text-align: center;
  padding: 1rem;
}

.video-placeholder span {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .72rem;
  opacity: .85;
}

.compact-steps {
  margin-top: .75rem;
  color: var(--muted);
}

.danger-link {
  color: #9f1239;
}

@media (max-width: 1100px) {
  .plan-editor-grid,
  .checklist-grid,
  .help-grid {
    grid-template-columns: 1fr 1fr;
  }
  .chart-preview-box,
  .help-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .plan-editor-grid,
  .checklist-grid,
  .help-grid {
    grid-template-columns: 1fr;
  }
}

/* v11 additions: admin dashboard, roles, review queue, and reports */
.admin-two-column {
  align-items: start;
}

.role-matrix-wrap {
  overflow-x: auto;
}

.role-matrix-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: var(--panel-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.role-matrix-table th,
.role-matrix-table td {
  border: 1px solid var(--line);
  padding: .75rem;
  text-align: left;
  vertical-align: top;
}

.role-matrix-table th {
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.role-matrix-table td span,
.small-muted {
  color: var(--muted);
  font-size: .88rem;
}

.role-preview-note {
  margin-top: 1rem;
}

.admin-checklist-stack,
.review-queue {
  display: grid;
  gap: 1rem;
}

.admin-course-readiness,
.review-card,
.report-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-strong);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.readiness-top,
.review-card {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.readiness-list {
  display: grid;
  gap: .45rem;
  margin: .9rem 0 0;
  padding: 0;
  list-style: none;
}

.readiness-list li {
  display: flex;
  gap: .45rem;
  align-items: center;
  color: var(--muted);
}

.readiness-list li.pass span {
  color: var(--accent);
  font-weight: 900;
}

.readiness-list li.fail span {
  color: var(--danger);
  font-weight: 900;
}

.review-card h4,
.report-card h4 {
  margin: 0 0 .5rem;
}

.review-card p {
  color: var(--muted);
}

.review-actions {
  min-width: 220px;
  display: grid;
  gap: .55rem;
}

.review-actions select {
  width: 100%;
  padding: .7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
}

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

.report-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: .55rem;
}

.report-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: .45rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.report-list li:last-child {
  border-bottom: 0;
}

.small-empty {
  padding: .75rem;
}

@media (max-width: 1180px) {
  .report-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .review-card {
    display: grid;
  }

  .review-actions {
    min-width: 0;
  }
}

@media (max-width: 720px) {
  .report-grid {
    grid-template-columns: 1fr;
  }
}

/* v12 Workspaces, users, invitations, and assignments */
.workspace-two-column {
  align-items: start;
}

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

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

.workspace-directory,
.assignment-grid {
  display: grid;
  gap: 1rem;
}

.user-card,
.assignment-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-strong);
  padding: 1rem;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.user-card h4,
.assignment-card h4 {
  margin: 0 0 .4rem;
}

.user-card p,
.assignment-card p {
  color: var(--muted);
  margin: .25rem 0;
}

.user-card-actions {
  min-width: 160px;
  display: grid;
  gap: .55rem;
}

@media (max-width: 980px) {
  .compact-form-grid,
  .assignment-form-grid {
    grid-template-columns: 1fr;
  }

  .user-card,
  .assignment-card {
    display: grid;
  }

  .user-card-actions {
    min-width: 0;
  }
}

/* v13 architecture planning */
.architecture-cards {
  margin-top: 1rem;
}

.three-column {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.mini-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel-strong);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.mini-card h4 {
  margin: 0 0 .45rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: .4rem .75rem;
  font-size: .78rem;
  font-weight: 800;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
}

.status-pill.approved {
  background: rgba(31, 111, 98, .12);
  color: var(--accent);
  border-color: rgba(31, 111, 98, .25);
}

.status-pill.review {
  background: var(--brand-soft);
  color: var(--brand-dark);
  border-color: var(--line);
}

.responsive-table {
  overflow-x: auto;
}

.responsive-table table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.responsive-table th,
.responsive-table td {
  border-bottom: 1px solid var(--line);
  padding: .85rem;
  text-align: left;
  vertical-align: top;
}

.responsive-table th {
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-size: .86rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

@media (max-width: 980px) {
  .three-column {
    grid-template-columns: 1fr;
  }
}


/* v15 production starter helpers */
.roadmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.roadmap-card {
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 1rem;
  background: var(--panel-soft);
}
.roadmap-card h4 { margin: 0 0 .5rem; }
.roadmap-card p { margin: 0; color: var(--muted-text); }
.numbered-list { list-style: decimal; padding-left: 1.25rem; }
.production-stats .stat-card p { margin: .45rem 0 0; color: var(--muted-text); font-size: .9rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }

/* v16.1 sidebar and Help Center visibility fix */
.sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand-block {
  flex: 0 0 auto;
}

.nav-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  padding-bottom: 8px;
}

.nav-list::-webkit-scrollbar {
  width: 7px;
}

.nav-list::-webkit-scrollbar-thumb {
  background: rgba(75, 47, 30, .28);
  border-radius: 999px;
}

.sidebar-card {
  position: static;
  flex: 0 0 auto;
  margin-top: 16px;
  padding: 14px;
  max-height: 150px;
  overflow-y: auto;
}

.sidebar-card p:last-child {
  font-size: 12px;
  line-height: 1.35;
}

.quick-help-panel {
  margin-bottom: 22px;
}

.muted-text {
  color: var(--muted);
}

@media (max-width: 1080px) {
  .sidebar {
    overflow: visible;
  }
  .nav-list {
    overflow: visible;
    padding-right: 0;
  }
}


/* v19 Source & Media Library */
.source-media-layout {
  align-items: start;
}

.media-filter-row input[type="search"] {
  min-width: 260px;
}

.media-asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.media-asset-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1rem;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.media-asset-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  margin-bottom: .75rem;
}

.media-file-name {
  margin: 0;
  color: var(--muted);
  font-size: .9rem;
  word-break: break-word;
}

.media-badges {
  margin-bottom: .8rem;
}

.media-meta-list {
  display: grid;
  gap: .45rem;
  margin: .75rem 0;
}

.media-meta-list div {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: .75rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: .4rem;
}

.media-meta-list dt {
  font-weight: 800;
  color: var(--brand-dark);
}

.media-meta-list dd {
  margin: 0;
  color: var(--muted);
}

.media-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin-top: .8rem;
}

.danger-button {
  border: 1px solid rgba(176, 42, 55, .2);
  color: var(--danger);
  background: rgba(176, 42, 55, .08);
  border-radius: 999px;
  padding: .7rem .95rem;
  font-weight: 800;
}

@media (max-width: 760px) {
  .media-meta-list div {
    grid-template-columns: 1fr;
    gap: .15rem;
  }
}
