:root {
  --lms-blue: #0d6efd;
  --lms-blue-dark: #0b5ed7;
  --lms-bg-soft: #f4f8ff;
  --lms-surface-glass: rgba(255, 255, 255, 0.72);
  --lms-border-soft: rgba(154, 188, 245, 0.42);
  --text-hero: clamp(2rem, 4vw, 3.2rem);
  --text-title: clamp(1.2rem, 2.2vw, 1.65rem);
  --text-body: 1rem;
  --text-small: 0.88rem;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --radius-sm: 0.55rem;
  --radius-md: 0.9rem;
  --radius-lg: 1.25rem;
  --elevation-1: 0 8px 18px rgba(13, 110, 253, 0.08);
  --elevation-2: 0 14px 30px rgba(13, 110, 253, 0.12);
  --elevation-3: 0 18px 34px rgba(13, 110, 253, 0.16);
  --font-display: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  --font-ui: "Avenir", "Segoe UI", "Helvetica Neue", sans-serif;
}

body {
  min-height: 100vh;
  font-family: var(--font-ui);
  background: radial-gradient(circle at 10% 10%, #e7f0ff 0%, #f8fbff 45%, #ffffff 100%);
  animation: pageFade 320ms ease;
}

.hero-card {
  max-width: 720px;
  width: 100%;
  border: 1px solid var(--lms-border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--elevation-2);
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.9) 0%, rgba(235, 245, 255, 0.8) 100%);
  backdrop-filter: blur(8px);
}

.hero-title {
  font-family: var(--font-display);
  font-size: var(--text-hero);
  line-height: 1.2;
}

.hero-copy {
  color: #42526b;
}

.cta-btn {
  background-color: var(--lms-blue);
  border-color: var(--lms-blue);
  min-width: 220px;
}

.cta-btn:hover,
.cta-btn:focus {
  background-color: var(--lms-blue-dark);
  border-color: var(--lms-blue-dark);
}

.avatar-initials {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background-color: var(--lms-blue);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.dashboard-shell {
  min-height: 100vh;
  background:
    radial-gradient(900px circle at 5% 15%, rgba(177, 209, 255, 0.35) 0%, rgba(177, 209, 255, 0) 52%),
    radial-gradient(800px circle at 96% 5%, rgba(160, 192, 247, 0.2) 0%, rgba(160, 192, 247, 0) 48%),
    linear-gradient(180deg, #f7fbff 0%, #ffffff 35%);
}

.hidden {
  display: none !important;
}

.exam-tile,
.subject-tile,
.chapter-tile {
  border-radius: var(--radius-md);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(239, 247, 255, 0.92));
  border: 1px solid var(--lms-border-soft);
  box-shadow: var(--elevation-1);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  animation: tileIn 340ms ease both;
}

.exam-tile:hover,
.exam-tile:focus,
.subject-tile:hover,
.subject-tile:focus,
.chapter-tile:hover,
.chapter-tile:focus {
  transform: translateY(-2px);
  border-color: #9dc0ff;
  box-shadow: var(--elevation-3);
}

.exam-tile.disabled {
  background: #f4f6fa;
  border-color: #e2e8f5;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.75;
}

.exam-tile.disabled:hover,
.exam-tile.disabled:focus {
  transform: none;
  border-color: #e2e8f5;
  box-shadow: none;
}

.profile-menu {
  position: relative;
}

.profile-trigger {
  border: 0;
  background: transparent;
  padding: 0;
  line-height: 0;
}

.profile-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 180px;
  background: #fff;
  border: 1px solid #dbe7ff;
  border-radius: var(--radius-md);
  box-shadow: 0 14px 28px rgba(17, 55, 122, 0.15);
  padding: 0.75rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  z-index: 20;
}

.profile-menu:hover .profile-dropdown,
.profile-menu.open .profile-dropdown,
.profile-trigger:focus + .profile-dropdown {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.profile-name-row {
  margin-bottom: 0.5rem;
}

.profile-name {
  font-size: 0.9rem;
  color: #1f2d3d;
  line-height: 1.35;
}

.profile-divider {
  border-top: 1px solid #e6ecfa;
  margin: 0.45rem 0 0.5rem;
}

.profile-admin-link,
.profile-logout {
  display: inline-block;
  color: var(--lms-blue-dark);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.profile-admin-link {
  margin-bottom: 0.4rem;
}

.profile-admin-link:hover,
.profile-admin-link:focus,
.profile-logout:hover,
.profile-logout:focus {
  text-decoration: underline;
}

.custom-sidebar {
  top: 1rem;
}

.custom-select-root {
  min-height: 160px;
}

.custom-chapter-list {
  display: grid;
  gap: 0.45rem;
}

.custom-chapter-row {
  padding: 0.35rem 0.25rem;
  border-radius: 0.5rem;
}

.custom-chapter-row:hover {
  background: #f6f9ff;
}

.attempt-option {
  border: 1px solid #dbe7ff;
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 0.8rem 0.95rem;
  display: flex;
  align-items: flex-start;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1.5;
}

.attempt-option:hover {
  border-color: #8eb7ff;
  background: #f7fbff;
}

.option-correct {
  border-color: #16a34a;
  background: #ecfdf3;
}

.option-wrong {
  border-color: #dc2626;
  background: #fef2f2;
}

.attempt-meta {
  font-size: 1.05rem;
  line-height: 1.35;
  font-weight: 600;
  color: #1f2d3d;
  font-family: var(--font-display);
}

.attempt-question {
  font-size: 1.18rem;
  line-height: 1.45;
}

.attempt-question figure.table,
#preview-question-html figure.table,
#review-question figure.table,
#review-explanation figure.table {
  margin: 1rem 0;
  overflow-x: auto;
}

.attempt-question table,
#preview-question-html table,
#review-question table,
#review-explanation table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #b8c8e6;
  table-layout: auto;
}

.attempt-question th,
.attempt-question td,
#preview-question-html th,
#preview-question-html td,
#review-question th,
#review-question td,
#review-explanation th,
#review-explanation td {
  border: 1px solid #b8c8e6;
  padding: 0.6rem 0.7rem;
  vertical-align: top;
  text-align: left;
}

.attempt-question th,
#preview-question-html th,
#review-question th,
#review-explanation th {
  background: #f4f8ff;
  font-weight: 700;
}

.attempt-question sub,
.attempt-question sup,
#preview-question-html sub,
#preview-question-html sup,
#review-question sub,
#review-question sup,
#review-explanation sub,
#review-explanation sup {
  line-height: 0;
}

.tag-box {
  position: relative;
  display: inline-flex;
  justify-content: flex-end;
  min-width: 120px;
}

.tag-select-floating {
  position: absolute;
  right: calc(100% + 8px);
  top: 0;
  width: 170px;
  z-index: 30;
}

.review-outcome-wrong {
  color: #b42318;
  font-weight: 600;
}

.review-explanation {
  font-size: 1rem;
  line-height: 1.5;
}

.card-btn {
  text-align: left;
}

#pending-attempts .card {
  border-left: 4px solid #90b6ff !important;
  background: var(--lms-surface-glass);
  backdrop-filter: blur(6px);
}

.empty-state {
  display: grid;
  place-items: center;
  text-align: center;
  gap: var(--space-2);
  color: #60728a;
}

.empty-icon {
  font-size: 1.6rem;
  color: #6f95d8;
}

.skeleton-line {
  height: 12px;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #eef4ff 0%, #e0ecff 45%, #eef4ff 100%);
  background-size: 240% 100%;
  animation: shimmer 1.15s linear infinite;
}

.skeleton-line.short {
  width: 62%;
}

.skeleton-tile {
  border-radius: var(--radius-md);
  border: 1px solid #e4edff;
  padding: var(--space-6);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(243, 249, 255, 0.88));
  box-shadow: var(--elevation-1);
}

.skeleton-stack {
  display: grid;
  gap: var(--space-3);
}

.motion-stagger {
  animation: tileIn 320ms ease both;
}

.app-title {
  font-family: var(--font-display);
  font-size: var(--text-title);
}

.glass-card {
  background: var(--lms-surface-glass);
  backdrop-filter: blur(7px);
  border: 1px solid var(--lms-border-soft);
  box-shadow: var(--elevation-1);
}

.admin-builder-shell {
  max-width: 1200px;
}

.admin-writing-lane {
  max-width: 980px;
  margin: 0 auto;
}

.admin-editor-card .card-body {
  padding: 1.1rem 1.1rem 1.35rem;
}

.admin-editor-card .ck-editor__editable_inline {
  min-height: 8.5rem;
  line-height: 1.6;
  color: #1f2d3d !important;
  caret-color: #1f2d3d;
  font-size: 1rem;
}

@keyframes shimmer {
  0% {
    background-position: 240% 0;
  }
  100% {
    background-position: -20% 0;
  }
}

@keyframes tileIn {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes pageFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.admin-editor-card .ck-content {
  color: #1f2d3d !important;
}

.admin-editor-card .ck.ck-toolbar {
  border-color: #d7e4ff;
}

.admin-editor-card .ck.ck-editor__main > .ck-editor__editable {
  background: #ffffff;
  border-color: #d7e4ff;
}

.admin-editor-card-question .ck-editor__editable_inline {
  min-height: 14rem;
}

.admin-editor-card-explanation .ck-editor__editable_inline {
  min-height: 12rem;
}

@media (max-width: 768px) {
  .admin-writing-lane {
    max-width: 100%;
  }

  .admin-editor-card-question .ck-editor__editable_inline {
    min-height: 11rem;
  }

  .admin-editor-card-explanation .ck-editor__editable_inline {
    min-height: 9.5rem;
  }
}

@media (max-width: 992px) {
  .dashboard-shell > header .container {
    flex-wrap: wrap;
    row-gap: 0.65rem;
  }

  .dashboard-shell > header h1 {
    font-size: 1.15rem;
    line-height: 1.3;
  }

  #attempt-title + .d-flex {
    width: 100%;
    justify-content: space-between;
  }

  #attempt-progress {
    font-size: 0.85rem;
    white-space: nowrap;
  }

  #resume-box {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  #resume-box .btn {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .profile-dropdown {
    width: min(240px, calc(100vw - 1rem));
    right: -0.25rem;
  }

  .attempt-top-row,
  .review-top-row {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.6rem;
  }

  .tag-box {
    align-self: flex-end;
    min-width: 0;
  }

  .tag-select-floating {
    right: 0;
    top: calc(100% + 6px);
  }

  .attempt-question {
    font-size: 1.08rem;
  }

  .attempt-option {
    font-size: 1rem;
  }

  .attempt-nav,
  .review-nav {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .attempt-nav .btn,
  .review-nav .btn {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 0;
  }

  #finish-btn {
    flex: 1 1 100%;
    order: 3;
  }

  .admin-editor-card .card-body {
    padding: 0.95rem;
  }

  #load-question-btn,
  #delete-question-btn,
  #save-btn,
  #preview-btn,
  #reset-btn {
    flex: 1 1 calc(50% - 0.25rem);
  }
}

#preview-feedback {
  border: 1px solid #d7e4ff;
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  background: #f8fbff;
}

#preview-feedback.correct {
  border-color: #16a34a;
  background: #ecfdf3;
}

#preview-feedback.wrong {
  border-color: #dc2626;
  background: #fef2f2;
}
