:root {
  --bg-primary: #eef0f7;
  --bg-secondary: #dfe3ed;
  --shadow-dark: #c3c8d3;
  --shadow-light: #ffffff;
  --text-main: #1f2a44;
  --text-muted: #7b8496;
  --purple: #6d4cc2;
  --green: #22a05a;
  --red: #d94b42;
  --yellow: #f2b705;
}

.dark {
  --bg-primary: #343b4a;
  --bg-secondary: #1f2633;
  --shadow-dark: #151923;
  --shadow-light: #4a5263;
  --text-main: #f1f5f9;
  --text-muted: #aab3c2;
}

.dark .accordion-title {
  color: #f3e8ff;
}

.dark .question-number {
  color: #f3e8ff;
  box-shadow:
    4px 4px 8px #151923,
    -4px -4px 8px #4a5263;
}

.dark .tag {
  background: rgba(168, 85, 247, 0.25);
  color: #e9d5ff;
  border: 1px solid rgba(233, 213, 255, 0.2);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Noto Sans KR", sans-serif;
  background: linear-gradient(145deg, var(--bg-primary), var(--bg-secondary));
  color: var(--text-main);
  min-height: 100vh;
}

.app {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.neu-raised {
  background: linear-gradient(145deg, var(--bg-primary), var(--bg-secondary));
  box-shadow:
    8px 8px 16px var(--shadow-dark),
    -8px -8px 16px var(--shadow-light);
}

.neu-btn {
  border: 0;
  cursor: pointer;
  transition: 0.2s;
  color: var(--text-main);
}

.neu-btn:hover {
  transform: translateY(-2px);
}

.neu-btn:active {
  transform: scale(0.97);
}

.hidden {
  display: none !important;
}

/* 상단 */
.top-bar {
  display: grid;
  grid-template-columns: 180px 1fr 220px 70px;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 24px;
  margin-bottom: 22px;
}

.dark-toggle,
.home-btn {
  height: 54px;
  border-radius: 18px;
  font-weight: 700;
  font-size: 1rem;
}

.home-btn {
  font-size: 2rem;
}

.breadcrumb {
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.breadcrumb span {
  margin: 0 6px;
}

.progress-box {
  font-weight: 700;
}

.progress-track {
  height: 6px;
  background: rgba(120, 120, 150, 0.2);
  border-radius: 999px;
  margin-top: 8px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--purple);
  border-radius: 999px;
}

/* 문제 */
.question-panel {
  border-radius: 28px;
  padding: 28px;
  margin-bottom: 20px;
}

.question-head {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
}

.question-number {
  width: 58px;
  height: 58px;
  min-width: 58px;
  min-height: 58px;
  flex: 0 0 58px;

  border-radius: 50%;
  display: grid;
  place-items: center;

  color: var(--purple);
  font-weight: 900;
  font-size: 1.6rem;
  line-height: 1;
}

.question-head h1 {
  font-size: 1.45rem;
  line-height: 1.5;
  margin: 0;
}

.question-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

.image-card {
  order: -1;
}

.question-body.no-media {
  grid-template-columns: 1fr;
}

.answer-card,
.image-card {
  border-radius: 22px;
  padding: 22px;
}

.answer-card h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 1px solid rgba(120, 120, 150, 0.25);
  background: rgba(255, 255, 255, 0.25);
  color: var(--text-main);
  border-radius: 16px;
  padding: 16px;
  font-size: 1rem;
  outline: none;
}

textarea::placeholder {
  color: var(--text-muted);
}

.image-card img {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  display: block;
}

/* 정답 */
.answer-panel {
  border-radius: 24px;
  padding: 22px 26px;
  margin-bottom: 20px;
}

.answer-panel h2 {
  margin-top: 0;
  color: var(--purple);
}

/* 해설 */
.explain-panel {
  border-radius: 28px;
  padding: 20px 24px;
  margin-bottom: 20px;
}

.accordion-title {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--purple);
  font-size: 1.15rem;
  font-weight: 900;
  display: flex;
  justify-content: space-between;
  cursor: pointer;
}

.accordion-content {
  margin-top: 18px;
  border-radius: 18px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.18);
  line-height: 1.7;
}

.explain-img {
  width: 100%;
  margin-top: 16px;
  border-radius: 14px;
}

.tag-box {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(109, 76, 194, 0.15);
  color: var(--purple);
  font-size: 0.82rem;
  font-weight: 700;
}

/* 하단 */
.bottom-bar {
  border-radius: 24px;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 12px;
}

.control-btn {
  height: 54px;
  border-radius: 16px;
  font-weight: 900;
  font-size: 1rem;
}

.correct {
  background: rgba(34, 160, 90, 0.12);
  border: 1px solid rgba(34, 160, 90, 0.4);
  color: var(--green);
}

.wrong {
  background: rgba(217, 75, 66, 0.12);
  border: 1px solid rgba(217, 75, 66, 0.4);
  color: var(--red);
}

.saved {
  background: rgba(242, 183, 5, 0.14);
  border: 1px solid rgba(242, 183, 5, 0.45);
  color: var(--yellow);
}


.dot-progress {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  /*margin-bottom: 20px;*/
  margin-bottom: 0;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #9ca3af;
  opacity: 0.45;
}

.dot.current {
  width: 24px;
  border-radius: 999px;
  background: var(--purple);
  opacity: 1;
}

.dot.correct-dot {
  background: var(--green);
  opacity: 1;
}

.dot.wrong-dot {
  background: var(--red);
  opacity: 1;
}

.dot.saved-dot {
  background: var(--yellow);
  opacity: 1;
}

.dot-progress-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  font-weight: 700;
  color: var(--text-main);
}


/* 모바일 */
@media (max-width: 768px) {
  .image-card {
    order: -1;
  }
  .app {
    padding: 12px;
  }

  .top-bar {
    grid-template-columns: 1fr 64px;
    gap: 10px;
  }

  .dark-toggle {
    grid-column: 1 / 2;
  }

  .home-btn {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
  }

  .breadcrumb,
  .progress-box {
    grid-column: 1 / 3;
  }

  .question-body {
    grid-template-columns: 1fr;
  }

  .question-head {
    align-items: flex-start;
  }

  .question-head h1 {
    font-size: 1.1rem;
  }

  .bottom-bar {
    grid-template-columns: 1fr 1fr;
  }

  #nextBtn {
    grid-column: 1 / 3;
  }
}

/*메인세션*/
.main-section {
  min-height: 100vh;
  padding-bottom: 20px;
}

.main-hero {
  display: grid;
  grid-template-columns: 120px 1fr 120px;
  align-items: start;
  margin-bottom: 24px;
}

.main-title-box {
  text-align: center;
  padding-top: 12px;
}

.main-title-box h1 {
  margin: 0;
  font-size: 2.7rem;
  font-weight: 900;
  letter-spacing: -1px;
}

.main-title-box p {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-weight: 700;
}

.main-dark-btn {
  width: 92px;
  height: 82px;
  border-radius: 24px;
  font-weight: 900;
  display: grid;
  place-items: center;
  gap: 2px;
  justify-self: end;
}

.main-dark-btn span {
  font-size: 0.8rem;
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr 1.18fr;
  gap: 24px;
  margin-bottom: 24px;
}

.tree-panel,
.selected-panel,
.guide-panel {
  border-radius: 30px;
  padding: 28px;
}

.tree-panel h2,
.selected-panel h2 {
  margin: 0 0 24px;
  color: var(--purple);
  font-size: 1.15rem;
  font-weight: 900;
}

.tree-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tree-parent,
.tree-item {
  width: 100%;
  border: 0;
  color: var(--text-main);
  cursor: pointer;
  transition: 0.2s;
  font-weight: 800;
}

.tree-parent {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(109, 76, 194, 0.1);
  border: 1px solid rgba(109, 76, 194, 0.15);
  padding: 13px 16px;
  border-radius: 16px;
  font-size: 1rem;
}

.tree-item {
  background: transparent;
  padding: 10px 14px;
  border-radius: 14px;
  text-align: left;
  font-size: 0.98rem;
}

.tree-parent:hover,
.tree-item:hover {
  transform: translateY(-2px);
  background: rgba(109, 76, 194, 0.13);
}

.tree-item.selected {
  background: rgba(109, 76, 194, 0.18);
  color: var(--purple);
  box-shadow:
    inset 3px 3px 6px var(--shadow-dark),
    inset -3px -3px 6px var(--shadow-light);
}

.tree-children {
  margin-left: 22px;
  padding-left: 14px;
  border-left: 2px dotted rgba(120, 130, 160, 0.45);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.selected-card {
  border-radius: 26px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(150, 150, 180, 0.18);
}

.selected-icon {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2.4rem;
  margin-bottom: 18px;
}

.selected-card h3 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 900;
}

.selected-card > div > p,
#selectedDesc {
  margin: 8px 0 20px;
  color: var(--text-muted);
  font-weight: 700;
}

.selected-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 20px 0;
}

.selected-stats div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 18px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.18);
  box-shadow:
    inset 2px 2px 5px rgba(0, 0, 0, 0.05),
    inset -2px -2px 5px rgba(255, 255, 255, 0.35);
}

.selected-stats span {
  color: var(--text-main);
  font-weight: 800;
}

.selected-stats strong {
  font-weight: 900;
}

.selected-desc-box {
  margin-top: 20px;
  padding: 16px;
  border-top: 1px solid rgba(120, 130, 160, 0.25);
}

.selected-desc-box h4 {
  margin: 0 0 8px;
  color: var(--purple);
}

.selected-desc-box p {
  margin: 0;
  color: var(--text-main);
  line-height: 1.6;
}

.start-btn {
  width: 100%;
  height: 66px;
  border-radius: 20px;
  border: 0;
  background: linear-gradient(145deg, #9b6df0, var(--purple));
  color: white;
  font-size: 1.2rem;
  font-weight: 900;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  box-shadow:
    5px 5px 12px var(--shadow-dark),
    -5px -5px 12px var(--shadow-light);
}

.start-btn span {
  font-size: 2rem;
}

.start-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.guide-panel {
  display: flex;
  align-items: center;
  gap: 22px;
}

.guide-icon {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2rem;
  flex: 0 0 70px;
}

.guide-panel h3 {
  margin: 0 0 6px;
  color: var(--purple);
}

.guide-panel p {
  margin: 0;
  color: var(--text-main);
  font-weight: 600;
  line-height: 1.6;
}

@media (max-width: 768px) {
  .main-hero {
    grid-template-columns: 1fr auto;
  }

  .main-hero > div:first-child {
    display: none;
  }

  .main-title-box {
    text-align: left;
  }

  .main-title-box h1 {
    font-size: 2rem;
  }

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

  .main-dark-btn {
    width: 76px;
    height: 68px;
  }

  .tree-panel,
  .selected-panel,
  .guide-panel {
    padding: 22px;
  }
}

.tree-folder {
  width: 100%;
  border: 0;
  color: var(--text-main);
  cursor: pointer;
  transition: 0.2s;
  font-weight: 800;
  background: transparent;
  padding: 10px 14px;
  border-radius: 14px;
  text-align: left;
  font-size: 0.98rem;

  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tree-folder:hover {
  transform: translateY(-2px);
  background: rgba(109, 76, 194, 0.13);
}

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

/*줄바꿈*/
#questionText,
#answerText,
#explainText {
  white-space: pre-line;
  font-weight: 700;
}

/* 학습 메뉴 스크롤 영역 */
.tree-panel {
  max-height: calc(100vh - 190px);
  overflow: hidden;
}

.tree-list {
  max-height: calc(100vh - 285px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 8px;
  scrollbar-width: thin;
}

.tree-list::-webkit-scrollbar {
  width: 8px;
}

.tree-list::-webkit-scrollbar-thumb {
  background: rgba(109, 76, 194, 0.35);
  border-radius: 999px;
}

.tree-list::-webkit-scrollbar-track {
  background: rgba(120, 130, 160, 0.12);
  border-radius: 999px;
}

/* 다크/라이트 모드 버튼 이모티콘 체감 크기 */
.main-dark-btn {
  font-size: 1.8rem;
}

.main-dark-btn span {
  font-size: 0.9rem;
}

.dark-toggle {
  font-size: 1.15rem;
}

.dark-toggle span {
  font-size: 1rem;
}
