html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

:root {
  --admin-bg: #f5f7fb;
  --admin-surface: #ffffff;
  --admin-border: #dfe5ef;
  --admin-muted: #667085;
  --admin-text: #1f2937;
  --admin-primary: #0d6efd;
  --admin-primary-soft: #e8f1ff;
  --admin-sidebar: #111827;
  --admin-sidebar-muted: #aeb8c8;
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.18);
}

html {
  position: relative;
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--admin-text);
  background: var(--admin-bg);
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.5rem;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--admin-border);
  backdrop-filter: blur(10px);
}

.admin-topbar-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  line-height: 1.2;
  min-width: 0;
}

.admin-topbar-logo {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 8px;
  color: #ffffff;
  background: var(--admin-primary);
  font-weight: 800;
}

.admin-topbar-logo img,
.admin-brand-mark img,
.app-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-topbar-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-shell {
  display: flex;
  min-height: calc(100vh - 64px);
}

.admin-sidebar {
  position: sticky;
  top: 64px;
  width: 264px;
  height: calc(100vh - 64px);
  flex-direction: column;
  padding: 1rem;
  background: var(--admin-sidebar);
  transition: width 0.18s ease;
}

.admin-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.75rem;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 44px;
  padding: 0.25rem 0.5rem;
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
  min-width: 0;
}

.admin-brand:hover {
  color: #ffffff;
}

.admin-brand-mark,
.admin-avatar,
.admin-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.admin-brand-mark {
  width: 36px;
  height: 36px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--admin-primary);
  color: #ffffff;
}

.admin-brand-text,
.admin-nav-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-logo-preview {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem;
  border: 1px solid #d7e0ed;
  border-radius: 8px;
  background: #f8fafc;
}

.app-logo-preview img {
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border: 1px solid #d7e0ed;
  border-radius: 8px;
  background: #ffffff;
}

.teacher-guide-preview,
.teacher-guide-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 420px);
  align-items: center;
  gap: 1rem;
}

.teacher-guide-preview {
  padding: 0.85rem;
  border: 1px solid #d7e0ed;
  border-radius: 8px;
  background: #f8fafc;
}

.teacher-guide-preview video,
.teacher-guide-layout video {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid #d7e0ed;
  border-radius: 8px;
  background: #111827;
}

.admin-collapse-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  color: var(--admin-sidebar-muted);
  background: rgba(255, 255, 255, 0.08);
}

.admin-collapse-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
}

.admin-avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--admin-primary-soft);
  color: var(--admin-primary);
  font-weight: 700;
}

.admin-nav {
  display: grid;
  gap: 0.35rem;
}

.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 42px;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  color: var(--admin-sidebar-muted);
  text-decoration: none;
  transition: background 0.16s ease, color 0.16s ease, justify-content 0.16s ease;
}

.admin-nav-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.admin-nav-link.active {
  color: #ffffff;
  background: var(--admin-primary);
}

.admin-nav-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.75rem;
  font-weight: 700;
}

.admin-nav-link.active .admin-nav-icon {
  background: rgba(255, 255, 255, 0.2);
}

.admin-content {
  width: 100%;
  padding: 1.5rem;
}

.admin-menu-minimized .admin-sidebar {
  width: 84px;
}

.admin-menu-minimized .admin-brand {
  justify-content: center;
}

.admin-menu-minimized .admin-brand-text,
.admin-menu-minimized .admin-nav-text {
  display: none;
}

.admin-menu-minimized .admin-sidebar-head {
  flex-direction: column;
}

.admin-menu-minimized .admin-collapse-btn i {
  transform: rotate(180deg);
}

.admin-menu-minimized .admin-nav-link {
  justify-content: center;
  padding-inline: 0.5rem;
}

.auth-content {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

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

.page-kicker {
  color: var(--admin-primary);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.app-card {
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  background: var(--admin-surface);
  box-shadow: 0 8px 24px rgba(31, 41, 55, 0.04);
}

.filter-panel {
  border: 1px solid #d9e2ef;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
  box-shadow: 0 8px 24px rgba(31, 41, 55, 0.04);
}

.filter-panel-header {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid #e7edf6;
}

.filter-panel-body {
  padding: 1rem;
}

.data-grid {
  border: 1px solid #d8e1ee;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(31, 41, 55, 0.05);
  overflow: hidden;
}

.data-grid-toolbar {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid #d8e1ee;
  background: #ffffff;
}

.app-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--admin-border);
}

.app-card-body {
  padding: 1.25rem;
}

.app-table {
  margin-bottom: 0;
}

.app-table thead th {
  color: #475467;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  background: #eef3f9;
  border-bottom: 1px solid var(--admin-border);
}

.app-table tbody td {
  border-color: #eef2f7;
  padding: 0.9rem 1rem;
  vertical-align: middle;
}

.app-table tbody tr:hover {
  background: #f9fbff;
}

.badge-soft-success {
  color: #067647;
  background: #dcfae6;
}

.badge-soft-danger {
  color: #b42318;
  background: #fee4e2;
}

.badge-soft-secondary {
  color: #475467;
  background: #eef2f7;
}

.badge-soft-primary {
  color: #084298;
  background: #e8f1ff;
}

.summary-tile {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid #d8e1ee;
  border-radius: 8px;
  background: #f8fbff;
}

.summary-icon {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 8px;
  color: var(--admin-primary);
  background: var(--admin-primary-soft);
}

.form-label {
  font-weight: 600;
}

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

.empty-state {
  max-width: 420px;
  margin: 0 auto;
}

.empty-icon {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.75rem;
  border-radius: 8px;
  color: var(--admin-primary);
  background: var(--admin-primary-soft);
}

.label-with-hint {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.hint-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #b9c6d8;
  border-radius: 50%;
  color: var(--admin-muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  background: #ffffff;
}

.hint-icon:hover {
  color: var(--admin-primary);
  border-color: var(--admin-primary);
  background: var(--admin-primary-soft);
}

.record-title {
  font-weight: 700;
  color: var(--admin-text);
}

.record-subtitle {
  max-width: 460px;
  margin-top: 0.2rem;
  color: var(--admin-muted);
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.country-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid #e4eaf3;
  border-radius: 8px;
  color: #344054;
  background: #ffffff;
  font-size: 0.88rem;
}

.table-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 8px;
}

.form-grid {
  display: grid;
  gap: 1rem;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1rem;
  align-items: start;
}

.editor-main {
  border: 1px solid #d7e0ed;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(31, 41, 55, 0.05);
}

.editor-main form {
  padding: 1.25rem;
}

.editor-section {
  padding: 1rem;
  border: 1px solid #e3e9f2;
  border-radius: 8px;
  background: #ffffff;
}

.editor-section + .editor-section {
  margin-top: 1rem;
}

.editor-section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.editor-section-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--admin-primary);
  background: var(--admin-primary-soft);
}

.editor-side {
  display: grid;
  gap: 1rem;
}

.side-panel {
  padding: 1rem;
  border: 1px solid #dfe5ef;
  border-radius: 8px;
  background: #f8fbff;
}

.guidance-list {
  display: grid;
  gap: 0.55rem;
  color: #475467;
  font-size: 0.9rem;
}

.guidance-list div {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
}

.guidance-list i {
  color: #067647;
  margin-top: 0.1rem;
}

.form-panel {
  padding: 1rem;
  border: 1px solid #e4eaf3;
  border-radius: 8px;
  background: #fbfcff;
}

.form-panel-title {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  color: #344054;
  font-weight: 700;
}

.status-switch {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid #dfe5ef;
  border-radius: 8px;
  background: #ffffff;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 1px solid var(--admin-border);
}

.validation-summary-valid {
  display: none;
}

.subject-workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.subject-rail {
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 96px);
  padding: 1rem;
  border: 1px solid #d8e1ee;
  border-radius: 8px;
  background: #ffffff;
  overflow: auto;
  box-shadow: 0 10px 28px rgba(31, 41, 55, 0.05);
}

.subject-search {
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid #e4eaf3;
}

.subject-list {
  display: grid;
  gap: 0.5rem;
}

.subject-list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  padding: 0.75rem;
  border: 1px solid #e4eaf3;
  border-radius: 8px;
  color: var(--admin-text);
  text-decoration: none;
  background: #ffffff;
}

.subject-list-item:hover {
  border-color: #b7c7dd;
  background: #f8fbff;
}

.subject-list-item.active {
  border-color: var(--admin-primary);
  background: var(--admin-primary-soft);
}

.subject-list-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 8px;
  color: var(--admin-primary);
  background: #eef4ff;
}

.subject-list-title,
.subject-list-subtitle {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subject-list-title {
  font-weight: 700;
}

.subject-list-subtitle {
  color: var(--admin-muted);
  font-size: 0.82rem;
}

.subject-main {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.subject-hero,
.workspace-panel {
  border: 1px solid #d8e1ee;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(31, 41, 55, 0.05);
}

.subject-hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem;
}

.subject-hero-info {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.subject-cover-link {
  flex: 0 0 auto;
  border-radius: 8px;
  line-height: 0;
}

.subject-cover-image {
  width: 74px;
  height: 74px;
  border: 1px solid #d7e0ed;
  border-radius: 8px;
  object-fit: cover;
  background: #f8fafc;
  box-shadow: 0 8px 18px rgba(31, 41, 55, 0.08);
}

.index-cover-link .subject-cover-image {
  width: 58px;
  height: 58px;
}

.subject-hero-actions {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.metric-tile {
  padding: 0.9rem 1rem;
  border: 1px solid #dfe7f2;
  border-radius: 8px;
  background: #ffffff;
}

.metric-tile span {
  display: block;
  color: var(--admin-muted);
  font-size: 0.82rem;
}

.metric-tile strong {
  display: block;
  margin-top: 0.1rem;
  font-size: 1.45rem;
}

.workspace-panel {
  overflow: hidden;
}

.workspace-panel.is-collapsible .workspace-panel-head {
  cursor: pointer;
}

.workspace-panel.is-collapsed > :not(.workspace-panel-head) {
  display: none !important;
}

.collapse-panel-toggle {
  flex: 0 0 auto;
}

.collapse-panel-toggle i {
  transition: transform 0.16s ease;
}

.workspace-panel.is-collapsed .collapse-panel-toggle i {
  transform: rotate(180deg);
}

.workspace-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid #e4eaf3;
}

.workspace-panel > .row,
.workspace-panel > .stack-list {
  padding: 1rem;
}

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

.workspace-grid .workspace-panel:first-child {
  grid-row: span 2;
}

.content-card {
  min-height: 92px;
  padding: 1rem;
  border: 1px solid #e4eaf3;
  border-radius: 8px;
  background: #fbfcff;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-top: 1px solid #e4eaf3;
  background: #fbfcff;
}

.stack-list {
  display: grid;
  gap: 0.65rem;
}

.stack-item,
.definition-item {
  padding: 0.75rem;
  border: 1px solid #e4eaf3;
  border-radius: 8px;
  background: #ffffff;
}

.stack-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.stack-item small {
  display: block;
  color: var(--admin-muted);
  margin-top: 0.15rem;
}

.definition-item summary {
  cursor: pointer;
  font-weight: 700;
}

.definition-item summary span {
  display: block;
  margin-top: 0.15rem;
  color: var(--admin-muted);
  font-size: 0.82rem;
  font-weight: 400;
}

.definition-item p {
  margin: 0.75rem 0 0;
  color: #344054;
}

.subject-flow {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1rem;
}

.flow-column-terms {
  padding-bottom: 1rem;
  border-bottom: 1px solid #dbeafe;
}

.flow-column-terms .stack-list {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.flow-column {
  display: grid;
  align-content: start;
  gap: 0.65rem;
}

.flow-column-title {
  color: #475467;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.flow-chip,
.flow-empty,
.flow-warning,
.index-card {
  border: 1px solid #e4eaf3;
  border-radius: 8px;
  background: #ffffff;
}

.flow-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.7rem 0.8rem;
  font-weight: 600;
}

.flow-chip i,
.flow-warning i {
  color: var(--admin-primary);
}

.flow-chip span {
  color: var(--admin-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.flow-empty,
.flow-warning {
  padding: 0.8rem;
  color: var(--admin-muted);
  font-size: 0.9rem;
}

.flow-warning {
  display: flex;
  gap: 0.5rem;
  color: #b54708;
  background: #fffaeb;
  border-color: #fedf89;
}

.index-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem;
  color: var(--admin-text);
  text-decoration: none;
}

.index-card-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem;
  align-items: stretch;
}

.index-card-row.is-sortable {
  grid-template-columns: auto minmax(0, 1fr) auto auto;
}

.index-card:hover {
  border-color: #b7c7dd;
  background: #f8fbff;
}

.index-card.active {
  border-color: var(--admin-primary);
  background: var(--admin-primary-soft);
}

.index-card strong,
.index-card small {
  display: block;
}

.index-card small {
  color: var(--admin-muted);
  margin-top: 0.15rem;
}

.index-card-count {
  min-width: 46px;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  color: #344054;
  background: #eef2f7;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
}

.index-focus {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid #c7d7ee;
  border-radius: 8px;
  background: #f8fbff;
}

.builder-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  gap: 1rem;
  align-items: start;
}

.builder-main-panel {
  min-width: 0;
}

.timeline-builder {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
}

.timeline-row {
  display: grid;
  grid-template-columns: 42px 42px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid #dfe7f2;
  border-radius: 8px;
  background: #ffffff;
}

.timeline-row.is-sortable {
  grid-template-columns: auto 42px 42px minmax(0, 1fr) auto auto;
}

.timeline-row.needs-work {
  border-color: #fecdca;
  background: #fffbfa;
}

.timeline-order,
.timeline-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-weight: 700;
}

.timeline-order {
  color: #344054;
  background: #eef2f7;
}

.timeline-icon {
  color: var(--admin-primary);
  background: var(--admin-primary-soft);
}

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

.timeline-body strong,
.timeline-body small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-body small {
  color: var(--admin-muted);
}

.timeline-alert {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  color: #b42318;
  font-size: 0.82rem;
  font-weight: 600;
}

.concept-map {
  display: grid;
  gap: 0.65rem;
  padding: 1rem;
}

.map-parent,
.map-center,
.map-children span {
  border: 1px solid #e4eaf3;
  border-radius: 8px;
  background: #ffffff;
}

.map-parent {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.65rem 0.75rem;
  color: #344054;
}

.map-center {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.85rem;
  border-color: var(--admin-primary);
  background: var(--admin-primary-soft);
}

.map-center span,
.map-children span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  font-weight: 700;
}

.map-center span {
  color: #084298;
  background: #ffffff;
}

.map-children {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.map-children span {
  color: #344054;
  font-size: 0.88rem;
}

.map-children small {
  color: var(--admin-muted);
  font-weight: 600;
}

.question-item {
  display: grid;
  gap: 0.25rem;
  padding: 0.75rem;
  border: 1px solid #e4eaf3;
  border-radius: 8px;
  background: #fbfcff;
}

.question-item small {
  color: var(--admin-muted);
}

.admin-mobile-sidebar {
  background: var(--admin-sidebar);
  color: #ffffff;
}

@media (max-width: 991.98px) {
  .admin-content {
    padding: 1rem;
  }

  .page-header {
    flex-direction: column;
  }

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

  .subject-workspace,
  .subject-main,
  .workspace-grid,
  .subject-metrics,
  .subject-flow,
  .builder-grid {
    grid-template-columns: 1fr;
  }

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

  .timeline-row.is-sortable {
    grid-template-columns: auto 36px minmax(0, 1fr) auto;
  }

  .timeline-icon {
    display: none;
  }

  .subject-rail {
    position: static;
    max-height: none;
  }

  .subject-hero {
    flex-direction: column;
  }
}

/* Subject workspace UX refresh */
.subject-workspace {
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 1.1rem;
}

.rail-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.9rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid #e4eaf3;
}

.rail-title strong,
.rail-title span {
  display: block;
}

.rail-title strong {
  color: #182230;
  font-size: 1rem;
}

.rail-title span {
  color: var(--admin-muted);
  font-size: 0.82rem;
}

.subject-list-item,
.index-card,
.timeline-row,
.metric-tile,
.build-step {
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.subject-list-item:hover,
.index-card:hover,
.timeline-row:hover {
  box-shadow: 0 8px 18px rgba(31, 41, 55, 0.05);
}

.subject-list-item.active,
.index-card.active {
  box-shadow: inset 4px 0 0 var(--admin-primary);
}

[dir="rtl"] .subject-list-item.active,
[dir="rtl"] .index-card.active {
  box-shadow: inset -4px 0 0 var(--admin-primary);
}

.subject-list-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.subject-list-meta span {
  padding: 0.18rem 0.42rem;
  border: 1px solid #d7e0ed;
  border-radius: 999px;
  color: #475467;
  background: #f8fafc;
  font-size: 0.72rem;
  font-weight: 700;
}

.subject-hero {
  border-color: #cfd9e8;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.metric-tile {
  box-shadow: 0 8px 20px rgba(31, 41, 55, 0.035);
}

.metric-tile span {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
}

.metric-tile span i {
  color: var(--admin-primary);
}

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

.build-step {
  min-height: 82px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 0.65rem;
  align-content: center;
  padding: 0.85rem;
  border: 1px solid #dfe7f2;
  border-radius: 8px;
  background: #ffffff;
}

.build-step span {
  grid-row: span 2;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: #344054;
  background: #eef2f7;
  font-weight: 800;
}

.build-step strong,
.build-step small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.build-step strong {
  color: #182230;
}

.build-step small {
  color: var(--admin-muted);
}

.build-step.done span {
  color: #067647;
  background: #dcfae6;
}

.build-step.attention {
  border-color: #fedf89;
  background: #fffcf5;
}

.build-step.attention span {
  color: #b54708;
  background: #fef0c7;
}

.workspace-panel-head h2 {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.section-number {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 8px;
  color: #7a4b00;
  border: 1px solid #fedf89;
  background: #fef0c7;
  font-size: 0.78rem;
  font-weight: 800;
}

.index-focus {
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
}

.action-empty {
  display: grid;
  justify-items: center;
  gap: 0.45rem;
  padding: 1.25rem;
  border: 1px dashed #b7c7dd;
  border-radius: 8px;
  color: #475467;
  background: #f8fbff;
  text-align: center;
}

.action-empty.compact {
  padding: 1rem;
}

.action-empty i {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--admin-primary);
  background: var(--admin-primary-soft);
}

.action-empty strong {
  color: #182230;
}

.action-empty span {
  max-width: 420px;
  color: var(--admin-muted);
  font-size: 0.9rem;
}

.content-type-note {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.9rem;
  border: 1px solid #d7e0ed;
  border-radius: 8px;
  color: #475467;
  background: #f8fbff;
}

.content-type-note i {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 8px;
  color: var(--admin-primary);
  background: var(--admin-primary-soft);
}

.selected-concept-card {
  display: grid;
  gap: 0.25rem;
  margin: 1rem 1rem 0;
  padding: 0.9rem;
  border: 1px solid #b7d8c5;
  border-radius: 8px;
  background: #f0fdf4;
}

.selected-concept-card span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: #067647;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.selected-concept-card strong {
  color: #182230;
  font-size: 1.05rem;
}

.selected-concept-card small {
  color: #475467;
}

.workspace-section-title {
  grid-column: 1 / -1;
  display: grid;
  gap: 0.2rem;
  padding: 0.85rem 1rem;
  border: 1px solid #cfd9e8;
  border-radius: 8px;
  background: #ffffff;
}

.step-title-line {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.workspace-section-title span {
  color: var(--admin-primary);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.workspace-section-title .section-number {
  color: #7a4b00;
  border: 1px solid #fedf89;
  background: #fef0c7;
  text-transform: none;
}

.workspace-section-title strong {
  color: #182230;
  font-size: 1rem;
}

.workspace-section-title small {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: #475467;
  font-size: 0.84rem;
  font-weight: 700;
}

.workspace-section-title small span {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.48rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.workspace-section-title-content {
  border-color: #c7d2fe;
  background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
}

.workspace-section-title-support {
  border-color: #bae6fd;
  background: linear-gradient(135deg, #f0f9ff 0%, #ecfeff 100%);
}

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

.subject-hero,
.subject-summary-panel,
.builder-grid,
.workspace-grid,
.related-concepts-panel,
.subject-main > .data-grid {
  grid-column: 1 / -1;
}

.subject-summary-panel .subject-metrics {
  padding: 1rem;
}

.workflow-panel {
  border-width: 2px;
}

.subject-summary-panel {
  border-color: #fde68a;
  background: linear-gradient(180deg, #ffffff 0%, #fffbeb 100%);
}

.workflow-panel-index {
  border-color: #bfdbfe;
  background: linear-gradient(180deg, #ffffff 0%, #eff6ff 100%);
}

.workflow-panel-concept {
  border-color: #bbf7d0;
  background: linear-gradient(180deg, #ffffff 0%, #f0fdf4 100%);
}

.builder-grid > .workspace-panel,
.workspace-grid > .workspace-panel {
  border-width: 2px;
}

.builder-grid > .workspace-panel:nth-child(1) {
  border-color: #c7d2fe;
  background: linear-gradient(180deg, #ffffff 0%, #eef2ff 100%);
}

.builder-grid > .workspace-panel:nth-child(2) {
  border-color: #fed7aa;
  background: linear-gradient(180deg, #ffffff 0%, #fff7ed 100%);
}

.builder-grid > .workspace-panel:nth-child(3) {
  border-color: #fbcfe8;
  background: linear-gradient(180deg, #ffffff 0%, #fdf2f8 100%);
}

.builder-grid > .workspace-panel:nth-child(4) {
  border-color: #ddd6fe;
  background: linear-gradient(180deg, #ffffff 0%, #f5f3ff 100%);
}

.builder-grid > .video-tools-panel {
  grid-column: 1 / -1;
}

.workspace-grid > .workspace-panel:nth-child(1) {
  border-color: #99f6e4;
  background: linear-gradient(180deg, #ffffff 0%, #f0fdfa 100%);
}

.workspace-grid > .workspace-panel:nth-child(2) {
  border-color: #fecaca;
  background: linear-gradient(180deg, #ffffff 0%, #fff1f2 100%);
}

.workspace-grid > .workspace-panel:nth-child(3) {
  border-color: #bae6fd;
  background: linear-gradient(180deg, #ffffff 0%, #f0f9ff 100%);
}

.workspace-section-title,
.workspace-section-title-content,
.workspace-section-title-support,
.workflow-panel,
.workflow-panel-index,
.workflow-panel-concept,
.builder-grid > .workspace-panel,
.builder-grid > .workspace-panel:nth-child(1),
.builder-grid > .workspace-panel:nth-child(2),
.builder-grid > .workspace-panel:nth-child(3),
.builder-grid > .workspace-panel:nth-child(4),
.workspace-grid > .workspace-panel,
.workspace-grid > .workspace-panel:nth-child(1),
.workspace-grid > .workspace-panel:nth-child(2),
.workspace-grid > .workspace-panel:nth-child(3),
.related-concepts-panel {
  border-color: #bfdbfe;
  background: linear-gradient(180deg, #ffffff 0%, #eff6ff 100%);
}

.workspace-section-title {
  border-width: 2px;
}

.selected-work-card {
  display: grid;
  gap: 0.25rem;
  padding: 0.8rem;
  border: 1px solid #93c5fd;
  border-radius: 8px;
  background: #dbeafe;
  position: relative;
  overflow: hidden;
}

.selected-work-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 0%, rgba(255, 255, 255, 0.58) 48%, transparent 72%);
  pointer-events: none;
  transform: translateX(-125%);
  animation: selected-work-shimmer 3.8s ease-in-out infinite;
}

.selected-work-card-concept {
  margin: 1rem 1rem 0;
  border-color: #86efac;
  background: #dcfce7;
}

.selected-work-card-concept::after {
  animation-delay: 0.75s;
}

.selected-work-card span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: #075985;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.selected-work-card-concept span {
  color: #067647;
}

.selected-work-card strong {
  color: #182230;
  font-size: 1rem;
}

.selected-work-card small {
  color: #475467;
}

.selected-path-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.45rem;
}

.selected-path-summary span {
  display: inline-flex;
  max-width: 100%;
  padding: 0.24rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--admin-primary) 22%, transparent);
  border-radius: 999px;
  color: #344054;
  background: rgba(255, 255, 255, 0.76);
  font-size: 0.78rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

@keyframes selected-work-shimmer {
  0%,
  42% {
    transform: translateX(-125%);
  }

  72%,
  100% {
    transform: translateX(125%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .selected-work-card::after {
    display: none;
    animation: none;
  }
}

.subject-list-item > .min-w-0 {
  min-width: 0;
  width: 100%;
}

.subject-list-subtitle {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.workspace-panel.is-collapsed .workspace-panel-head {
  border-bottom-color: transparent;
}

.workspace-panel.is-collapsed {
  box-shadow: 0 6px 0 color-mix(in srgb, var(--card-edge) 82%, transparent);
}

.workspace-panel-head > div {
  min-width: 0;
}

.workspace-panel-head .text-muted {
  overflow-wrap: anywhere;
}

.subject-hero .page-kicker,
.subject-hero h2,
.subject-hero p {
  overflow-wrap: anywhere;
}

.builder-grid,
.workspace-grid {
  align-items: start;
}

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

.video-tools-panel {
  border: 2px solid #bfdbfe !important;
  background: linear-gradient(180deg, #ffffff 0%, #eff6ff 100%) !important;
  box-shadow: 0 10px 28px rgba(31, 41, 55, 0.05) !important;
  overflow: hidden;
}

.video-tools-panel > .workspace-panel-head {
  margin-bottom: 0;
  border-bottom: 1px solid #e4eaf3;
}

.video-tool-box {
  min-width: 0;
  border: 1px solid #d7e0ed;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(31, 41, 55, 0.05);
}

.video-tool-box-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem;
  border-bottom: 1px solid #e4eaf3;
}

.video-tool-box > .stack-list {
  padding: 0.9rem;
}

.concept-pill,
.map-children span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  font-weight: 700;
}

.concept-pill {
  color: #344054;
  border: 1px solid #d7e0ed;
  background: #ffffff;
  text-decoration: none;
}

.concept-pill:hover {
  color: var(--admin-primary);
  border-color: #9ec5fe;
}

.concept-pill.active {
  color: #067647;
  border-color: #86d9a8;
  background: #dcfae6;
}

.drag-handle {
  width: 34px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #d7e0ed;
  border-radius: 8px;
  color: #667085;
  background: #f8fafc;
  cursor: grab;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle-sm {
  width: 28px;
  min-height: 28px;
  border-radius: 7px;
}

.dragging {
  opacity: 0.55;
  box-shadow: 0 12px 28px rgba(31, 41, 55, 0.12);
}

.btn-icon-sm {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  font-size: 0.8rem;
}

.concept-token {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem;
  border: 1px dashed transparent;
  border-radius: 8px;
}

.concept-token.dragging {
  border-color: #9ec5fe;
  background: #eef4ff;
}

.admin-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(248, 250, 252, 0.72);
  backdrop-filter: blur(3px);
}

.admin-loading-overlay.show {
  display: flex;
}

.admin-loading-card {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border: 1px solid #d7e0ed;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 18px 48px rgba(16, 24, 40, 0.16);
  color: #1f2937;
}

.content-preview-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.content-preview-thumb {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  border: 1px solid #d7e0ed;
  object-fit: cover;
  background: #f8fafc;
}

.content-preview-thumb-sm {
  width: 24px;
  height: 24px;
  border-radius: 6px;
}

.video-thumbnail-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.video-thumbnail-option {
  width: 124px;
  padding: 0.35rem;
  border: 2px solid #d7e0ed;
  border-radius: 8px;
  background: #ffffff;
  color: #344054;
  text-align: start;
}

.video-thumbnail-option.active {
  border-color: var(--admin-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--admin-primary) 18%, transparent);
}

.video-thumbnail-option img {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  border-radius: 6px;
  object-fit: cover;
  background: #f8fafc;
}

.video-thumbnail-option span {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  font-weight: 800;
}

.related-concept-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: inherit;
  font-weight: 700;
  text-decoration: none;
}

.related-concept-link:hover {
  color: var(--admin-primary);
  text-decoration: underline;
}

.math-input-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.math-input-hint {
  color: var(--admin-muted);
  font-size: 0.82rem;
}

.math-composer-field {
  display: block;
  width: 100%;
  min-height: 84px;
  padding: 0.75rem;
  border: 1px solid #d7e0ed;
  border-radius: 8px;
  background: #ffffff;
  font-size: 1.1rem;
}

.mobile-math-preview {
  width: min(100%, 360px);
  margin: 0 auto;
  padding: 0.75rem;
  border: 1px solid #d7e0ed;
  border-radius: 28px;
  background: #111827;
}

.mobile-preview-topbar {
  width: 72px;
  height: 6px;
  margin: 0 auto 0.9rem;
  border-radius: 999px;
  background: #344054;
}

.mobile-preview-card {
  min-height: 220px;
  padding: 1rem;
  border-radius: 18px;
  background: #ffffff;
}

.mobile-preview-label {
  margin-bottom: 0.75rem;
  color: var(--admin-muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.math-preview-content {
  color: #182230;
  font-size: 1rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.image-preview-modal .modal-body {
  display: grid;
  place-items: center;
  padding: 1rem;
  background: #0f172a;
}

.image-preview-large {
  max-width: 100%;
  max-height: min(78vh, 820px);
  border-radius: 8px;
  object-fit: contain;
  background: #ffffff;
}

.video-preview-modal .modal-body {
  display: grid;
  place-items: center;
  padding: 1rem;
  background: #0f172a;
}

.video-preview-player {
  width: 100%;
  max-height: min(76vh, 820px);
  border-radius: 8px;
  background: #000000;
}

.feedback-summary {
  display: grid;
  gap: 0.85rem;
}

.feedback-option {
  display: grid;
  gap: 0.35rem;
  padding: 0.85rem;
  border: 1px solid #d7e0ed;
  border-radius: 8px;
  background: #f8fafc;
}

.feedback-option-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: #182230;
  font-weight: 700;
}

.feedback-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4e7ec;
}

.feedback-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #14b8a6);
}

@media (max-width: 991.98px) {
  .build-path {
    grid-template-columns: 1fr;
  }

  .stack-item,
  .index-focus {
    flex-direction: column;
  }
}

@media (max-width: 767.98px) {
  .admin-content {
    padding: 0.75rem;
  }

  .page-header,
  .subject-hero,
  .index-focus,
  .workspace-panel-head,
  .stack-item {
    align-items: stretch;
  }

  .page-header > *,
  .subject-hero > *,
  .index-focus > * {
    min-width: 0;
  }

  .subject-workspace,
  .subject-main,
  .subject-flow,
  .workspace-grid,
  .builder-grid,
  .video-tools-grid,
  .subject-metrics {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
  }

  .subject-rail {
    position: static;
    max-height: 42vh;
    padding: 0.75rem;
  }

  .subject-list-item,
  .index-card,
  .stack-item,
  .flow-chip {
    align-items: stretch;
  }

  .teacher-guide-preview,
  .teacher-guide-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .timeline-row,
  .timeline-row.is-sortable {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 0.55rem;
    align-items: start;
    padding: 0.75rem;
  }

  .timeline-row .drag-handle {
    grid-column: 1;
    grid-row: 1;
  }

  .timeline-row .timeline-order {
    grid-column: 1;
    grid-row: 2;
  }

  .timeline-row .timeline-icon {
    display: none;
  }

  .timeline-row .timeline-body {
    grid-column: 2;
    grid-row: 1 / span 3;
  }

  .timeline-row > .badge {
    grid-column: 2;
    grid-row: 4;
    justify-self: start;
  }

  .timeline-row > .btn,
  .timeline-row > form {
    grid-column: 3;
    justify-self: end;
  }

  .timeline-row > .btn {
    grid-row: 1;
  }

  .timeline-row > form {
    grid-row: 2;
  }

  .index-card-row,
  .index-card-row.is-sortable {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 0.55rem;
    align-items: start;
  }

  .index-card-row .drag-handle {
    grid-column: 1;
    grid-row: 1;
  }

  .index-card-row .index-card {
    grid-column: 2;
    grid-row: 1 / span 3;
  }

  .index-card-row > .btn,
  .index-card-row > form {
    grid-column: 3;
    justify-self: end;
  }

  .index-card-row > .btn {
    grid-row: 1;
  }

  .index-card-row > form {
    grid-row: 2;
  }

  .subject-hero-actions,
  .panel-actions,
  .table-actions {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 0.1rem;
  }

  .subject-hero-actions .btn,
  .panel-actions .btn,
  .modal-footer .btn {
    flex: 1 0 auto;
  }

  .timeline-row > .btn,
  .timeline-row > form .btn,
  .index-card-row > .btn,
  .index-card-row > form .btn {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
  }

  .workspace-panel-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .video-tool-box-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .workspace-panel-head .table-actions,
  .workspace-panel-head > .btn {
    grid-column: 1 / -1;
  }

  .subject-hero-info {
    align-items: flex-start;
  }

  .subject-cover-image {
    width: 58px;
    height: 58px;
  }

  .timeline-order,
  .drag-handle,
  .index-card-count {
    justify-self: start;
  }

  .timeline-body strong,
  .timeline-body small,
  .record-subtitle,
  .subject-list-title,
  .subject-list-subtitle,
  .index-card strong,
  .index-card small {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .modal-dialog {
    margin: 0.5rem;
  }

  .modal-body {
    max-height: calc(100vh - 160px);
    overflow-y: auto;
  }

  .content-preview-strip {
    align-items: flex-start;
  }

  .math-input-toolbar .btn {
    flex: 1 0 auto;
  }
}
.diagnostic-pre {
    max-height: 28rem;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    font-size: .82rem;
}

/* Farha admin style guide: voxel surfaces, denim/gold/navy brand, RTL-safe density. */
:root {
  color-scheme: light;
  --denim: #5e8fc7;
  --denim-deep: #3f6ba0;
  --navy: #1f2a44;
  --gold: #e9b54d;
  --gold-deep: #c18a2a;
  --success: #5ba86f;
  --success-deep: #3f8252;
  --danger: #e2725b;
  --danger-deep: #be5341;
  --page: #eef0f3;
  --card: #ffffff;
  --card-edge: #dde1e8;
  --stroke: #e3e6ec;
  --fill: #f4f5f8;
  --ink: #1f2a44;
  --muted: #6b7488;
  --font: -apple-system, "SF Pro", system-ui, "Segoe UI", "Tajawal", "Cairo", sans-serif;
  --space-xs: 6px;
  --space-sm: 10px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --radius-sm: 5px;
  --radius-md: 7px;
  --radius-lg: 9px;
  --radius-pill: 999px;
  --admin-bg: var(--page);
  --admin-surface: var(--card);
  --admin-border: var(--stroke);
  --admin-muted: var(--muted);
  --admin-text: var(--ink);
  --admin-primary: var(--denim);
  --admin-primary-soft: color-mix(in srgb, var(--denim) 16%, transparent);
  --admin-sidebar: var(--navy);
  --admin-sidebar-muted: #c4ccda;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--gold) 13%, transparent) 0%, transparent 32%),
    linear-gradient(315deg, color-mix(in srgb, var(--denim) 12%, transparent) 0%, transparent 38%),
    var(--page);
}

.text-muted,
.form-text,
.record-subtitle,
.subject-list-subtitle,
.timeline-body small,
.index-card small,
.question-item small,
.math-input-hint {
  color: var(--muted) !important;
}

.admin-topbar {
  height: 70px;
  padding: 0 var(--space-lg);
  color: var(--ink);
  background: color-mix(in srgb, var(--card) 94%, transparent);
  border-bottom: 1px solid var(--stroke);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--card-edge) 75%, transparent);
}

.admin-shell {
  min-height: calc(100vh - 70px);
}

.admin-sidebar {
  top: 70px;
  height: calc(100vh - 70px);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--denim) 22%, transparent), transparent 24%),
    var(--navy);
  border-inline-end: 1px solid color-mix(in srgb, var(--denim) 18%, transparent);
}

.admin-brand,
.admin-nav-link {
  font-weight: 800;
}

.admin-topbar-logo,
.admin-brand-mark,
.admin-avatar,
.admin-nav-icon,
.summary-icon,
.empty-icon,
.editor-section-icon,
.subject-list-icon,
.timeline-icon {
  border-radius: var(--radius-md);
  background: var(--denim);
  color: #fff;
  box-shadow: 0 4px 0 var(--denim-deep);
}

.admin-avatar {
  color: var(--navy);
  background: var(--gold);
  box-shadow: 0 4px 0 var(--gold-deep);
  font-weight: 900;
}

.admin-collapse-btn,
.drag-handle,
.btn-icon,
.collapse-panel-toggle {
  border-radius: var(--radius-md);
}

.admin-nav-link {
  min-height: 46px;
  border-radius: var(--radius-md);
  color: var(--admin-sidebar-muted);
}

.admin-nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.admin-nav-link.active {
  color: #fff;
  background: var(--denim);
  box-shadow: 0 5px 0 var(--denim-deep);
}

.admin-nav-link.active .admin-nav-icon {
  color: var(--navy);
  background: var(--gold);
  box-shadow: none;
}

.admin-content {
  padding: var(--space-lg);
}

.page-header {
  align-items: center;
  margin-bottom: var(--space-lg);
}

.page-header h1,
.page-header .h3,
.page-header .h4,
.app-card h2,
.filter-panel h2,
.workspace-panel-head h2,
.record-title,
.subject-list-title,
.metric-tile strong,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6 {
  color: var(--ink);
  font-weight: 900;
  letter-spacing: 0;
}

.page-kicker {
  color: var(--denim);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0;
}

.app-card,
.filter-panel,
.data-grid,
.editor-main,
.editor-section,
.side-panel,
.form-panel,
.subject-rail,
.subject-hero,
.workspace-panel,
.summary-tile,
.metric-tile,
.content-card,
.stack-item,
.definition-item,
.question-item,
.selected-work-card,
.flow-chip,
.flow-empty,
.index-card,
.timeline-row,
.map-parent,
.map-center,
.map-children span,
.concept-pill,
.mobile-preview-card,
.admin-loading-card,
.app-logo-preview,
.teacher-guide-preview,
.status-switch {
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: 0 5px 0 var(--card-edge);
}

.filter-panel,
.data-grid,
.subject-hero,
.workspace-panel,
.subject-summary-panel,
.workflow-panel-index,
.workflow-panel-concept,
.builder-grid > .workspace-panel,
.workspace-grid > .workspace-panel {
  background: var(--card);
}

.app-card-body,
.filter-panel-body,
.workspace-panel > .row,
.workspace-panel > .stack-list,
.subject-flow,
.timeline-builder,
.concept-map {
  padding: var(--space-md);
}

.app-card-header,
.filter-panel-header,
.data-grid-toolbar,
.workspace-panel-head,
.panel-actions,
.subject-search,
.rail-title {
  border-color: var(--stroke);
  background: color-mix(in srgb, var(--fill) 68%, var(--card));
}

.btn {
  --btn-face: var(--denim);
  --btn-edge: var(--denim-deep);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  border: 0;
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  font-weight: 900;
  letter-spacing: 0;
  white-space: normal;
  color: #fff;
  background-color: var(--btn-face);
  background-image: linear-gradient(rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 5px);
  box-shadow: 0 6px 0 var(--btn-edge);
  transform: translateY(0);
  transition: transform 0.14s cubic-bezier(.2,.8,.2,1), box-shadow 0.14s, background-color 0.14s, color 0.14s;
}

.btn:hover {
  color: #fff;
  background-color: color-mix(in srgb, var(--btn-face) 92%, #fff);
}

.btn:active,
.btn.active,
.btn.show {
  transform: translateY(6px);
  box-shadow: 0 0 0 var(--btn-edge);
}

.btn:disabled,
.btn.disabled {
  transform: none;
  box-shadow: 0 6px 0 var(--btn-edge);
}

.btn-primary {
  --btn-face: var(--denim);
  --btn-edge: var(--denim-deep);
}

.btn-success,
.btn-outline-success {
  --btn-face: var(--success);
  --btn-edge: var(--success-deep);
}

.btn-danger,
.btn-outline-danger {
  --btn-face: var(--danger);
  --btn-edge: var(--danger-deep);
}

.btn-warning {
  --btn-face: var(--gold);
  --btn-edge: var(--gold-deep);
  color: var(--navy);
}

.btn-warning:hover {
  color: var(--navy);
}

.btn-outline-primary,
.btn-outline-secondary,
.btn-light,
.btn-secondary {
  --btn-face: var(--card);
  --btn-edge: var(--card-edge);
  color: var(--ink);
  border: 1px solid var(--stroke);
  background-image: none;
}

.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-light:hover,
.btn-secondary:hover {
  color: var(--ink);
  background-color: color-mix(in srgb, var(--fill) 78%, var(--card));
}

.btn-outline-danger,
.btn-outline-success {
  color: #fff;
  border: 0;
}

.btn-sm {
  min-height: 36px;
  padding: 0.45rem 0.75rem;
  box-shadow: 0 4px 0 var(--btn-edge);
}

.btn-sm:active,
.btn-sm.active,
.btn-sm.show {
  transform: translateY(4px);
}

.btn-icon,
.btn-icon-sm {
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  flex: 0 0 auto;
}

.btn-icon-sm {
  width: 30px;
  height: 30px;
  min-height: 30px;
}

.form-control,
.form-select,
.form-check-input,
.input-group-text,
.math-composer-field {
  min-height: 48px;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-md);
  color: var(--ink);
  background-color: var(--fill);
  font-weight: 700;
}

textarea.form-control {
  min-height: auto;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.math-composer-field:focus {
  border-color: var(--denim);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--denim) 26%, transparent);
  background-color: var(--card);
}

.form-check-input:checked,
.form-check-input:checked:focus {
  border-color: var(--denim);
  background-color: var(--denim);
}

.form-label {
  color: var(--ink);
  font-weight: 800;
}

.hint-icon,
.country-pill,
.index-card-count,
.subject-list-meta span,
.badge,
.badge-soft-success,
.badge-soft-danger,
.badge-soft-secondary,
.badge-soft-primary {
  border-radius: var(--radius-pill);
  font-weight: 900;
}

.badge-soft-primary {
  color: var(--denim);
  border: 1px solid color-mix(in srgb, var(--denim) 35%, transparent);
  background: color-mix(in srgb, var(--denim) 15%, transparent);
}

.badge-soft-success {
  color: #fff;
  background: var(--success);
}

.badge-soft-danger {
  color: #fff;
  background: var(--danger);
}

.badge-soft-secondary {
  color: var(--ink);
  border: 1px solid var(--stroke);
  background: var(--fill);
}

.app-table {
  color: var(--ink);
}

.app-table thead th {
  color: var(--muted);
  background: var(--fill);
  border-bottom-color: var(--stroke);
  font-weight: 900;
  letter-spacing: 0;
}

.app-table tbody td {
  border-color: var(--stroke);
}

.app-table tbody tr:hover {
  background: color-mix(in srgb, var(--denim) 8%, transparent);
}

.subject-list-item,
.index-card,
.timeline-row,
.metric-tile,
.build-step,
.concept-pill {
  transition: transform 0.14s cubic-bezier(.2,.8,.2,1), box-shadow 0.14s, border-color 0.14s, background 0.14s;
}

.subject-list-item:hover,
.index-card:hover,
.timeline-row:hover,
.concept-pill:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--card-edge);
}

.subject-list-item.active,
.index-card.active,
.concept-pill.active {
  border-color: var(--denim);
  background: color-mix(in srgb, var(--denim) 14%, var(--card));
  box-shadow: 0 5px 0 var(--denim-deep);
}

[dir="rtl"] .subject-list-item.active,
[dir="rtl"] .index-card.active,
.subject-list-item.active,
.index-card.active {
  box-shadow: 0 5px 0 var(--denim-deep);
}

.subject-summary-panel,
.build-step.attention,
.flow-warning {
  border-color: color-mix(in srgb, var(--gold) 64%, var(--stroke));
  background: color-mix(in srgb, var(--gold) 12%, var(--card));
}

.flow-warning,
.build-step.attention,
.build-step.attention span {
  color: var(--navy);
}

.build-step.done span,
.concept-pill.active,
.selected-work-card-concept span {
  color: var(--success);
}

.selected-work-card,
.selected-work-card-concept {
  overflow: hidden;
  border-color: color-mix(in srgb, var(--denim) 45%, var(--stroke));
  background: color-mix(in srgb, var(--denim) 12%, var(--card));
}

.section-number,
.timeline-order,
.build-step span {
  border-radius: var(--radius-md);
  color: var(--navy);
  background: var(--gold);
  box-shadow: 0 4px 0 var(--gold-deep);
  font-weight: 900;
}

.modal-content,
.offcanvas,
.swal2-popup,
.dropdown-menu {
  color: var(--ink);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: 0 5px 0 var(--card-edge), 0 18px 42px rgba(12, 19, 34, 0.16);
}

.modal-header,
.modal-footer,
.offcanvas-header {
  border-color: var(--stroke);
}

.admin-mobile-sidebar.offcanvas {
  width: min(320px, 88vw);
  color: #fff;
  border: 0;
  border-inline-end: 1px solid color-mix(in srgb, var(--denim) 18%, transparent);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--denim) 22%, transparent), transparent 24%),
    var(--navy);
  box-shadow: 0 18px 42px rgba(12, 19, 34, 0.28);
}

.admin-mobile-sidebar .admin-mobile-sidebar-head {
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid color-mix(in srgb, var(--denim) 18%, transparent);
}

.admin-mobile-sidebar .admin-brand {
  flex: 1 1 auto;
  min-width: 0;
}

.admin-mobile-sidebar .admin-mobile-close {
  flex: 0 0 auto;
}

.admin-mobile-sidebar .offcanvas-body {
  padding: 0.9rem 1rem 1rem;
}

.admin-mobile-sidebar .admin-nav {
  gap: 0.45rem;
}

.admin-mobile-sidebar .admin-nav-link {
  min-height: 46px;
}

.admin-loading-overlay {
  background: color-mix(in srgb, var(--page) 78%, transparent);
}

.admin-loading-card {
  color: var(--ink);
}

.diagnostic-pre {
  border-radius: var(--radius-lg);
  box-shadow: 0 5px 0 var(--card-edge);
}

@media (prefers-reduced-motion: reduce) {
  .btn,
  .subject-list-item,
  .index-card,
  .timeline-row,
  .concept-pill {
    transition: none;
  }
}

@media (max-width: 767.98px) {
  .admin-topbar {
    height: auto;
    min-height: 70px;
    flex-wrap: wrap;
    padding: var(--space-sm) var(--space-md);
  }

  .admin-topbar > .d-flex {
    width: 100%;
    justify-content: flex-end;
    gap: var(--space-sm) !important;
  }

  .admin-content {
    padding: var(--space-md);
  }

  .btn:not(.btn-icon):not(.btn-icon-sm) {
    min-height: 46px;
  }
}
