:root {
  --bg: #f5f6fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #6b7280;
  --accent: linear-gradient(135deg, #3b82f6, #6366f1);
  --accent-solid: #4f46e5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Poppins', 'Spoqa Han Sans Neo', system-ui;
  background: var(--bg);
  color: var(--text);
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px 64px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 32px;
}

.app-header h1 {
  margin: 0 0 8px;
  font-size: 32px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.version-chip {
  font-size: 14px;
  background: rgba(79, 70, 229, 0.12);
  color: #4f46e5;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.app-header p {
  margin: 0;
  color: var(--muted);
}

/* Language Toggle Switch */
.lang-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: var(--accent-solid);
}

input:checked+.slider:before {
  transform: translateX(24px);
}


.ghost-btn,
.primary-btn {
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.ghost-btn {
  background: rgba(79, 70, 229, 0.1);
  color: #4f46e5;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 25px rgba(79, 70, 229, 0.25);
}

.ghost-btn:hover,
.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(79, 70, 229, 0.3);
}

.curriculum-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
}

.category-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab-btn {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  background: #f8fafc;
  color: var(--text);
}

.tab-btn.active {
  background: var(--accent-solid);
  color: #fff;
  border-color: var(--accent-solid);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.exam-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.exam-card {
  background: var(--panel);
  border-radius: 20px;
  padding: 18px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 200ms ease, border 200ms ease, box-shadow 200ms ease;
}

.exam-card:hover {
  transform: translateX(6px);
}

.exam-card.active {
  border-color: rgba(79, 70, 229, 0.35);
  box-shadow: 0 12px 28px rgba(79, 70, 229, 0.15);
}

.exam-card h3 {
  margin: 0 0 4px;
}

.exam-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.roadmap-panel {
  background: var(--panel);
  border-radius: 28px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.roadmap-header {
  display: flex;
  gap: 24px;
  align-items: center;
}

.character-badge {
  position: relative;
  width: 96px;
  height: 96px;
}

.character-badge img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 12px 20px rgba(37, 99, 235, 0.35));
  animation: floaty 3.5s ease-in-out infinite;
}

.ripple {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(59, 130, 246, 0.35);
  animation: pulse 2.4s ease-out infinite;
}

@keyframes floaty {
  0% {
    transform: translateY(0px);
  }

  50% {
    transform: translateY(-8px);
  }

  100% {
    transform: translateY(0px);
  }
}

@keyframes pulse {
  0% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(0.8);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.4);
  }
}

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

.domain-roadmap {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.domain-block {
  border-radius: 22px;
  background: #f8f9ff;
  border: 1px solid rgba(79, 70, 229, 0.1);
  overflow: visible;
}

.domain-header {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  gap: 16px;
}

.domain-header h4 {
  margin: 0 0 6px;
}

.domain-summary {
  color: var(--muted);
  margin: 0;
}

.chevron {
  font-size: 28px;
  color: #4f46e5;
  font-weight: 600;
}

.domain-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 240ms ease;
  padding: 0 22px;
}

.domain-content.open {
  padding: 12px 22px 24px;
  max-height: none;
  /* Allow full expansion */
  overflow: visible;
}

.node-track {
  display: flex;
  flex-direction: column;
  /* Vertical Stack */
  gap: 0;
  /* Gap handled by padding/margin for timeline */
  padding: 20px 0 20px 24px;
  /* Left padding for timeline line */
  position: relative;
}

/* Timeline Vertical Line */
.node-track::before {
  content: '';
  position: absolute;
  top: 20px;
  bottom: 20px;
  left: 7px;
  /* Align with circle center */
  width: 2px;
  background: #e2e8f0;
  border-radius: 2px;
}

.node-btn {
  position: relative;
  width: 100%;
  text-align: left;
  padding: 16px 20px;
  margin-bottom: 16px;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  background: #fff;
  cursor: pointer;
  transition: all 200ms ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.node-btn:last-child {
  margin-bottom: 0;
}

.node-btn:hover {
  transform: translateX(4px);
  border-color: var(--accent-solid);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.node-btn.active {
  background: #f8fafc;
  border-color: var(--accent-solid);
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
  transform: translateX(4px);
}

/* Timeline Circle Marker */
.node-btn::before {
  content: '';
  position: absolute;
  left: -24px;
  /* Position on the timeline */
  top: 24px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid #cbd5e1;
  z-index: 2;
  transition: all 200ms ease;
}

.node-btn:hover::before {
  border-color: var(--accent-solid);
  transform: scale(1.1);
}

.node-btn.active::before {
  background: var(--accent-solid);
  border-color: var(--accent-solid);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.2);
}

/* Remove old horizontal connector */
.node-btn::after {
  display: none;
}

.node-btn .badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 2px;
}

.node-btn.active .badge {
  color: var(--accent-solid);
}

.node-btn strong {
  font-size: 15px;
  color: var(--text);
  line-height: 1.4;
  display: block;
}

.node-btn.active strong {
  color: var(--accent-solid);
}

.lesson-panel {
  border-radius: 24px;
  padding: 24px;
  background: #0d1b3f;
  color: white;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.lesson-panel h3 {
  margin-top: 0;
}

.lesson-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
  color: rgba(255, 255, 255, 0.8);
}

@media (max-width: 768px) {
  .page {
    padding: 20px 16px 80px;
  }

  .app-header {
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
  }

  .app-header h1 {
    font-size: 24px;
    flex-wrap: wrap;
  }

  .curriculum-shell {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  /* Horizontal Exam List (Tabs) */
  .exam-list {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 4px;
    gap: 12px;
    margin: 0 -16px;
    /* Negative margin to bleed to edges */
    padding: 0 16px 12px;
    /* Padding to compensate */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Firefox */
  }

  .exam-list::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
  }

  .exam-card {
    width: 85%;
    /* Show part of the next card to hint scrolling */
    min-width: 260px;
    max-width: 300px;
    flex-shrink: 0;
    padding: 16px;
    margin-right: 8px;
    /* Add spacing between cards */
  }

  .exam-card:last-child {
    margin-right: 16px;
    /* Add end padding */
  }

  .exam-card:hover {
    transform: none;
    /* Disable hover effect on touch */
  }

  .exam-card.active {
    border-color: var(--accent-solid);
    background: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.1);
  }

  /* Roadmap Adjustments */
  .roadmap-panel {
    padding: 20px;
    border-radius: 24px;
  }

  .roadmap-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .character-badge {
    width: 72px;
    height: 72px;
  }

  .domain-header {
    padding: 16px;
  }

  .domain-content.open {
    padding: 0 16px 20px;
  }

  .node-track {
    padding-left: 20px;
    /* Adjust padding for mobile */
  }

  .node-btn {
    padding: 14px;
  }
}

/* Visual Enhancement for Topic Grouping */
.domain-block:hover {
  background: #fff;
  box-shadow: 0 8px 24px rgba(149, 157, 165, 0.1);
  /* Lift effect on hover */
  border-color: rgba(79, 70, 229, 0.2);
}

.domain-block.expanded {
  background: #fff;
  border-color: rgba(79, 70, 229, 0.3);
  box-shadow: 0 12px 32px rgba(79, 70, 229, 0.08);
}

/* ==================== NEW CURRICULUM NAVIGATOR STYLES ==================== */

/* Filter Bar (System Tabs + Grade Dropdown) */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 24px;
  grid-column: 1 / -1;
}

.system-tabs {
  display: flex;
  gap: 8px;
}

.system-tab {
  padding: 10px 24px;
  border-radius: 999px;
  border: 2px solid #e2e8f0;
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.system-tab:hover {
  border-color: var(--accent-solid);
  color: var(--accent-solid);
}

.system-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.tab-divider {
  width: 1px;
  height: 24px;
  background: #e2e8f0;
  margin: 0 8px;
  align-self: center;
}

.grade-selector {
  display: flex;
  align-items: center;
  gap: 12px;
}

.grade-selector label {
  font-weight: 600;
  color: var(--muted);
  font-size: 14px;
}

.grade-dropdown {
  padding: 10px 16px;
  border-radius: 12px;
  border: 2px solid #e2e8f0;
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  min-width: 140px;
  color: var(--text);
}

.grade-dropdown:focus {
  outline: none;
  border-color: var(--accent-solid);
}

/* Content Grid (2-column layout) */
.content-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  min-height: 500px;
}

/* Category Panel (Left sidebar) */
.category-panel {
  background: var(--panel);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
  height: fit-content;
}

.panel-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 0 0 16px;
  font-weight: 600;
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.category-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: #f8f9ff;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
}

.category-item:hover {
  background: #fff;
  border-color: rgba(79, 70, 229, 0.2);
  transform: translateX(4px);
}

.category-item.active {
  background: #fff;
  border-color: var(--accent-solid);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.1);
}

.category-name {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.category-count {
  font-size: 12px;
  font-weight: 600;
  background: rgba(79, 70, 229, 0.1);
  color: var(--accent-solid);
  padding: 4px 10px;
  border-radius: 999px;
}

/* Topics Panel (Right main content) */
.topics-panel {
  background: var(--panel);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.06);
}

.topics-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e2e8f0;
}

.topics-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.character-badge.small {
  width: 48px;
  height: 48px;
}

.character-badge.small img {
  width: 100%;
  height: 100%;
}

.topics-header h2 {
  margin: 0;
  font-size: 24px;
}

#topicCount {
  font-size: 14px;
  color: var(--muted);
  margin: 4px 0 0;
}

/* Topics Tree */
.topics-tree {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Topic Groups (Accordion) */
.topic-group {
  border-radius: 16px;
  background: #f8f9ff;
  border: 1px solid rgba(79, 70, 229, 0.1);
  overflow: hidden;
  transition: all 0.2s ease;
}

.topic-group:hover {
  background: #fff;
  border-color: rgba(79, 70, 229, 0.2);
}

.topic-group.expanded {
  background: #fff;
  border-color: rgba(79, 70, 229, 0.25);
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.08);
}

.topic-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.topic-info h4 {
  margin: 0 0 4px;
  font-size: 16px;
  color: var(--text);
}

.sub-count {
  font-size: 13px;
  color: var(--muted);
}

.topic-header .chevron {
  font-size: 20px;
  color: var(--muted);
  font-weight: 300;
}

.topic-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 0 20px;
}

.topic-content.open {
  max-height: 2000px;
  padding: 0 20px 20px;
}

/* Sub-topic Items */
.subtopic-btn {
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  margin-bottom: 8px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.subtopic-btn:last-child {
  margin-bottom: 0;
}

.subtopic-btn:hover {
  border-color: var(--accent-solid);
  transform: translateX(4px);
}

.subtopic-btn.active {
  background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
  border-color: var(--accent-solid);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.subtopic-btn .badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--accent-solid);
  letter-spacing: 0.05em;
}

.subtopic-btn strong {
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
}

/* Empty, Loading, Error States */
.empty-state,
.loading-state,
.error-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 14px;
}

.error-state {
  color: #dc2626;
}

/* Updated curriculum-shell for new layout */
.curriculum-shell {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Responsive Design */
@media (max-width: 900px) {
  .filter-bar {
    flex-direction: column;
    gap: 16px;
    align-items: stretch;
  }

  .system-tabs {
    justify-content: center;
  }

  .grade-selector {
    justify-content: center;
  }

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

  .category-panel {
    order: 1;
  }

  .topics-panel {
    order: 2;
  }
}

@media (max-width: 600px) {
  .system-tab {
    padding: 8px 16px;
    font-size: 13px;
  }

  .topics-header-left {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .character-badge.small {
    display: none;
  }

  .topic-header {
    padding: 14px 16px;
  }

  .subtopic-btn {
    padding: 12px 14px;
  }
}