:root {
  --bg: #f3f5f7;
  --panel: #ffffff;
  --muted: #718096;
  --text: #1f2937;
  --blue: #2d6388;
  --blue-dark: #224a66;
  --ok-bg: #d9f4df;
  --ok-border: #2bbf5f;
  --bad-bg: #fde8e8;
  --bad-border: #ef4444;
  --line: #d6dde5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top right, #f8fbff 0%, var(--bg) 60%);
  color: var(--text);
  font-family: Arial, Helvetica, "Avenir Next", "Trebuchet MS", "Gill Sans", sans-serif;
}

.app-skeleton {
  position: fixed;
  inset: 0;
  z-index: 12000;
  background: radial-gradient(circle at top right, #f8fbff 0%, var(--bg) 60%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.app-skeleton.hidden {
  display: none;
}

.app-skeleton-shell {
  width: min(960px, 100%);
}

.skeleton-card {
  margin-top: 14px;
  background: #fff;
  border: 1px solid #dbe5ef;
  border-radius: 14px;
  padding: 18px;
}

.skeleton-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.skeleton-bar,
.skeleton-tile {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  background: #e2e8f0;
}

.skeleton-bar::after,
.skeleton-tile::after {
  content: '';
  position: absolute;
  top: 0;
  left: -140px;
  width: 140px;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.75), transparent);
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

.skeleton-title {
  height: 24px;
  width: min(260px, 70%);
}

.skeleton-line {
  height: 14px;
  width: 100%;
  margin-top: 10px;
}

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

.skeleton-tile {
  height: 120px;
}

@keyframes skeleton-shimmer {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(1100px);
  }
}

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: min(520px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
}

.auth-card h1 {
  margin: 0 0 8px;
}

.auth-label {
  display: block;
  font-size: 15px;
  margin-top: 12px;
}

.auth-label input {
  margin-top: 6px;
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 16px;
}

.password-input-wrap {
  position: relative;
  margin-top: 6px;
}

.password-input-wrap input {
  margin-top: 0;
  padding-right: 42px;
}

.password-toggle-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  padding: 0;
  width: 24px;
  height: 24px;
  border-radius: 0;
  color: #5b6f83;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.password-toggle-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.password-toggle-btn .eye-closed {
  display: none;
}

.password-toggle-btn.is-visible .eye-open {
  display: none;
}

.password-toggle-btn.is-visible .eye-closed {
  display: block;
}

.auth-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.register-progress {
  margin-top: 12px;
  margin-bottom: 10px;
}

.register-progress-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.register-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2d6388, #3b82f6);
  transition: width 0.2s ease;
}

.register-progress-steps {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.register-step {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px;
  margin-top: 12px;
  background: #f8fafc;
}

.step-title {
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #cbd5e1;
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.step-badge.done {
  background: #16a34a;
  color: #fff;
}

.step-badge.active {
  background: #2d6388;
  color: #fff;
}

.hidden-form {
  display: none;
}

.google-login-section {
  margin-top: 12px;
}

.google-login-divider {
  display: flex;
  align-items: center;
  color: #94a3b8;
  font-size: 13px;
  margin-bottom: 10px;
}

.google-login-divider::before,
.google-login-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid #e2e8f0;
}

.google-login-divider span {
  padding: 0 10px;
}

.apple-login-btn {
  margin-top: 10px;
  width: 100%;
  border: 1px solid #111827;
  background: #111827;
  color: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 15px;
}

.apple-login-btn:hover {
  background: #000;
  border-color: #000;
}

.link-btn {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  font-size: inherit;
  text-decoration: underline;
  border-radius: 0;
}

.layout.hidden {
  display: none;
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.confirm-dialog {
  width: min(460px, 100%);
  background: #fff;
  border-radius: 12px;
  border: 1px solid #d1d9e1;
  padding: 18px;
}

.confirm-dialog h3 {
  margin: 0 0 8px;
  font-size: 20px;
}

.confirm-dialog p {
  margin: 0;
  color: #475569;
  line-height: 1.5;
}

.confirm-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 340px 1fr;
  position: relative;
}

.mobile-menu-btn,
.mobile-backdrop {
  display: none;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f6 100%);
  padding: 24px;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-top {
  flex: 0 0 auto;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.sidebar-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-top: 12px;
}

.content {
  /*padding: 28px 32px;*/
}

.category-title {
  font-size: 32px;
  margin: 0 0 18px;
  letter-spacing: 0.5px;
}

.category-section + .category-section {
  margin-top: 18px;
}

.category-subtitle {
  font-size: 18px;
  margin: 0 0 10px;
  letter-spacing: 0.2px;
  color: #2b4e67;
}

.tree-root {
  margin-top: 8px;
}

.tree-toggle {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
  color: #26465d;
  padding: 8px 2px;
  cursor: pointer;
}

.tree-toggle:hover {
  color: #17384f;
}

.tree-children.collapsed {
  display: none;
}

.exam-list {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.exam-row {
  display: grid;
  grid-template-columns: 1fr 40px;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  padding: 11px 10px;
  font-size: 18px;
  color: var(--text);
  cursor: pointer;
}

.exam-row:hover {
  background: rgba(45, 99, 136, 0.08);
}

.exam-row.active {
  background: rgba(45, 99, 136, 0.14);
  color: #184664;
}

.exam-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.exam-title-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.exam-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #4d6478;
}

.status-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: conic-gradient(
    var(--gauge-color, #2d6388) calc(var(--progress, 0) * 1%),
    #d5dde6 calc(var(--progress, 0) * 1%)
  );
  position: relative;
}

.status-circle::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #f8fafc;
}

.status-value {
  position: relative;
  z-index: 1;
  font-size: 9px;
  font-weight: 700;
  color: #2d6388;
}

.status-circle.done {
  background: conic-gradient(#1b9445 100%, #1b9445 100%);
}

.status-circle.done .status-value {
  color: #1b9445;
  font-size: 12px;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 14px;
  gap: 10px;
  padding: 22px;
}

.toolbar small {
  color: var(--muted);
  font-size: 14px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 24px;
  font-size: 20px;
  cursor: pointer;
}

button.primary {
  background: var(--blue);
  color: #fff;
}

button.primary:hover {
  background: var(--blue-dark);
}

button.secondary {
  background: #dde2e9;
  color: #374151;
}

button.success {
  background: #18921a;
  color: #fff;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.exam-title {
  font-size: 32px;
  margin: 0 0 24px;
  padding: 22px;
}

.center-card {
  margin: 70px auto;
  max-width: 1200px;
  text-align: center;
}

.quiz-card,
.results-card,
.review-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  max-width: 1320px;
}

.review-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px);
  min-height: 0;
}

.review-head {
  flex: 0 0 auto;
}

.review-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
}

.quiz-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 18px;
  color: #374151;
  margin-bottom: 14px;
}

.quiz-head b {
  font-size: 20px;
}

.question-text {
  font-size: 18px;
  color: #175178;
  font-weight: 700;
  margin-bottom: 16px;
  line-height: 1.35;
}

.option {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 14px;
  margin-bottom: 10px;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: #fff;
}

.option.correct {
  background: var(--ok-bg);
  border-color: var(--ok-border);
}

.option.incorrect {
  background: var(--bad-bg);
  border-color: var(--bad-border);
}

input[type='radio'] {
  width: 28px;
  height: 28px;
  accent-color: var(--blue);
  flex: 0 0 auto;
}

.choice-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.6ch;
  font-weight: 700;
  color: #19425d;
  letter-spacing: 0.3px;
}

.choice-text {
  flex: 1;
  line-height: 1.35;
}

.feedback {
  margin-top: 14px;
  background: #eef2f5;
  border: 1px solid #d0d8e1;
  border-radius: 8px;
  padding: 12px;
  font-size: 20px;
  line-height: 1.55;
}

.feedback .label {
  font-size: 24px;
  text-align: center;
  font-weight: 700;
  margin-bottom: 8px;
}

.feedback .label.ok {
  color: #1b9445;
}

.feedback .label.bad {
  color: #b91c1c;
}

.controls {
  margin-top: 18px;
  display: flex;
  gap: 12px;
}

.quiz-nav-btn {
  min-width: 0;
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: #1f5f86;
  font-size: 16px;
  line-height: 1.3;
  text-decoration: none;
}

.quiz-nav-btn:hover:not(:disabled) {
  color: #174a69;
  text-decoration: none;
}

.quiz-nav-btn:disabled {
  background: transparent;
  color: #9aa8b4;
  text-decoration: none;
  opacity: 1;
  cursor: not-allowed;
}

.summary {
  text-align: center;
  font-size: 24px;
  line-height: 1.6;
}

.summary h3 {
  margin: 10px 0;
  font-size: 34px;
}

.review-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  background: #fbfcfd;
}

.review-title {
  font-size: 34px;
  color: #175178;
  font-weight: 700;
  margin-bottom: 10px;
}

.note {
  color: var(--muted);
  font-size: 24px;
}

.resource-offer {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #f8fbff;
  font-size: 16px;
}

.resource-offer p {
  margin: 0 0 10px;
  color: #334155;
}

.resource-offer-group + .resource-offer-group {
  margin-top: 10px;
}

.resource-offer-group h4 {
  margin: 0 0 6px;
  font-size: 16px;
  color: #1f3342;
}

.resource-offer-group ul {
  margin: 0;
  padding-left: 18px;
  color: #48627a;
}

.resource-offer-group li {
  margin: 2px 0;
}

.category-card-grid {
  --card-size: 160px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-size), var(--card-size)));
  gap: 14px;
}

.category-card {
  width: var(--card-size);
  height: var(--card-size);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  gap: 8px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.category-card:hover {
  transform: translateY(-2px);
  border-color: #b4c5d6;
  box-shadow: 0 10px 22px rgba(17, 36, 53, 0.08);
}

.category-card-media {
  height: 88px;
  border-radius: 10px;
  overflow: hidden;
  background: #edf2f7;
  display: grid;
  place-items: center;
}

.category-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.category-card-media-empty {
  background: linear-gradient(145deg, #d8e3ed 0%, #e8eff6 100%);
}

.category-card-media-empty span {
  font-size: 30px;
  font-weight: 700;
  color: #36566f;
}

.category-card h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
  color: #1f3342;
}

.category-card p {
  margin: 0;
  font-size: 12px;
  color: #617488;
}

.category-card.text-only .category-card-media {
  height: 100px;
}

.wm-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
}

.wm-grid {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  animation: wmDrift 26s ease-in-out infinite alternate;
}

.wm-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  color: rgba(15, 23, 42, var(--wm-alpha, 0.16));
  font-size: 14px;
  transform: translate(var(--wm-tx, 0), var(--wm-ty, 0)) rotate(var(--wm-rot, -20deg));
  user-select: none;
  white-space: nowrap;
  animation: wmFloat var(--wm-duration, 5s) ease-in-out var(--wm-delay, 0s) infinite;
}

.wm-cell i {
  font-style: normal;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  letter-spacing: 0.2px;
}

.wm-char {
  display: inline-block;
  animation: wmTextWave var(--wm-duration, 5s) ease-in-out
    calc(var(--wm-delay, 0s) + (var(--wm-i) * 0.035s)) infinite;
}

.wm-ripple {
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  transform: scale(0.6);
  animation: wmRipple var(--wm-duration, 5s) ease-out var(--wm-delay, 0s) infinite;
}

@keyframes wmRipple {
  0% {
    opacity: 0;
    transform: scale(0.55);
  }
  35% {
    opacity: 0.35;
    transform: scale(0.95);
  }
  100% {
    opacity: 0;
    transform: scale(1.2);
  }
}

@keyframes wmFloat {
  0%,
  100% {
    transform: translate(var(--wm-tx, 0), var(--wm-ty, 0)) rotate(var(--wm-rot, -20deg));
  }
  50% {
    transform: translate(calc(var(--wm-tx, 0) + 8px), calc(var(--wm-ty, 0) - 8px))
      rotate(calc(var(--wm-rot, -20deg) + 2deg));
  }
}

@keyframes wmDrift {
  0% {
    transform: translate(-1.2%, -0.8%);
  }
  50% {
    transform: translate(1.1%, 0.9%);
  }
  100% {
    transform: translate(-0.9%, 1.1%);
  }
}

@keyframes wmTextWave {
  0%,
  100% {
    transform: translateY(0);
  }
  25% {
    transform: translateY(-3px);
  }
  50% {
    transform: translateY(2px);
  }
  75% {
    transform: translateY(-2px);
  }
}

.security-banner {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  background: rgba(127, 29, 29, 0.92);
  color: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  display: none;
  pointer-events: none;
}

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

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

  .mobile-menu-btn {
    display: inline-flex;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 60;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #24465f;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    line-height: 1;
    box-shadow: 0 4px 14px rgba(17, 24, 39, 0.12);
  }

  .mobile-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    opacity: 0;
    pointer-events: none;
    z-index: 49;
    transition: opacity 0.2s ease;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(88vw, 360px);
    max-height: none;
    border-bottom: 0;
    border-right: 1px solid var(--line);
    z-index: 50;
    transform: translateX(-102%);
    transition: transform 0.22s ease;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.22);
  }

  .layout.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .layout.sidebar-open .mobile-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .content {
    padding-top: 64px;
  }

  .category-title {
    font-size: 26px;
  }

  .exam-row {
    font-size: 18px;
  }

  .exam-title {
    font-size: 24px;
  }

  .question-text,
  .option,
  .feedback,
  .review-title,
  .summary {
    font-size: 22px;
  }

  .quiz-head b {
    font-size: 20px;
  }

  button {
    font-size: 18px;
    padding: 10px 18px;
  }
}

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