/* ========== 기본 설정 ========== */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'NanumSquareRound', -apple-system, BlinkMacSystemFont, 'Noto Sans KR', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #0f172a;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #6366f1, #a855f7);
  border-radius: 10px;
}

/* ========== 언어별 원문 폰트 ==========
   나눔스퀘어라운드는 한글 전용 서체이므로 중국어/일본어 원문 표시에는
   각 언어에 최적화된 서체를 사용한다. (한국어 UI/뜻풀이는 body 기본값 유지) */
.font-zh {
  font-family: 'Noto Sans SC', 'NanumSquareRound', -apple-system, BlinkMacSystemFont, sans-serif;
}
.font-ja {
  font-family: 'Noto Sans JP', 'NanumSquareRound', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ========== 네비게이션 ========== */
.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
  transition: all 0.2s ease;
}
.nav-link:hover {
  background: #f1f5f9;
  color: #4338ca;
}

.mobile-nav-link {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-weight: 600;
  color: #334155;
}
.mobile-nav-link:hover {
  background: #f1f5f9;
}

.btn-solid {
  display: inline-flex;
  align-items: center;
  border-radius: 0.85rem;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  padding: 0.65rem 1.4rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: white;
  box-shadow: 0 8px 20px -6px rgba(79, 70, 229, 0.5);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn-solid:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -6px rgba(79, 70, 229, 0.6);
}

.footer-link {
  color: #94a3b8;
  transition: color 0.2s ease;
}
.footer-link:hover {
  color: white;
}

/* ========== 히어로 버튼 ========== */
.btn-hero-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  background: linear-gradient(135deg, #4f46e5, #a855f7);
  padding: 0.9rem 2rem;
  font-weight: 700;
  color: white;
  box-shadow: 0 10px 30px -8px rgba(99, 102, 241, 0.7);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn-hero-primary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 16px 40px -8px rgba(99, 102, 241, 0.8);
}

.btn-hero-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  padding: 0.9rem 2rem;
  font-weight: 600;
  color: white;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px);
  transition: all 0.25s ease;
}
.btn-hero-ghost:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.35);
}

/* ========== 도움말(FAQ) ========== */
.help-faq-item {
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  background: white;
  padding: 1.25rem 1.5rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.help-faq-item:hover {
  border-color: #c7d2fe;
  box-shadow: 0 8px 20px -8px rgba(79, 70, 229, 0.15);
}
.help-faq-question {
  display: flex;
  cursor: pointer;
  list-style: none;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-weight: 700;
  color: #0f172a;
}
.help-faq-question::-webkit-details-marker {
  display: none;
}
.help-faq-chevron {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: #94a3b8;
  transition: transform 0.2s ease;
}
.help-faq-item[open] .help-faq-chevron {
  transform: rotate(180deg);
  color: #4f46e5;
}
.help-faq-answer {
  margin: 0.9rem 0 0;
  font-size: 0.9rem;
  line-height: 1.7;
  color: #64748b;
}

/* ========== 섹션 라벨 ========== */
.section-eyebrow {
  display: inline-block;
  border-radius: 9999px;
  background: linear-gradient(135deg, #eef2ff, #fae8ff);
  padding: 0.35rem 1rem;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #4f46e5;
}

/* ========== 기능 카드 ========== */
.feature-card {
  border-radius: 1.5rem;
  background: white;
  padding: 2rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  border: 1px solid #f1f5f9;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.feature-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 40px -12px rgba(79, 70, 229, 0.18);
  border-color: #e0e7ff;
}
.feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 1rem;
  color: white;
  font-size: 1.35rem;
  box-shadow: 0 8px 16px -4px rgba(15, 23, 42, 0.25);
}

/* ========== 언어 카드 ========== */
.language-card {
  display: block;
  overflow: hidden;
  border-radius: 1.5rem;
  background: white;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  border: 1px solid #f1f5f9;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.language-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 24px 48px -12px rgba(15, 23, 42, 0.2);
}
.language-card-top {
  position: relative;
  display: flex;
  height: 9rem;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.language-card-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.35) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.8s ease;
}
.language-card:hover .language-card-shine {
  transform: translateX(100%);
}

/* ========== 학습 페이지: 통계 pill ========== */
.stat-pill {
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(6px);
  padding: 0.75rem 1rem;
  min-width: 4.5rem;
}
.stat-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: white;
}
.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
}

/* ========== 탭 ========== */
.learn-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  border-radius: 1rem;
  padding: 0.7rem 1.4rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #64748b;
  transition: all 0.2s ease;
}
.learn-tab:hover {
  color: #4f46e5;
  background: #f8fafc;
}
.learn-tab.is-active {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: white;
  box-shadow: 0 8px 16px -6px rgba(79, 70, 229, 0.5);
}

.difficulty-chip {
  border-radius: 9999px;
  border: 1.5px solid #e2e8f0;
  background: white;
  padding: 0.5rem 1.1rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #475569;
  transition: all 0.2s ease;
}
.difficulty-chip:hover {
  border-color: #c7d2fe;
  color: #4f46e5;
}
.difficulty-chip.is-active {
  border-color: transparent;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: white;
}

/* JLPT 급수 선택 칩 (difficulty-chip과 동일한 스타일) */
.level-chip {
  border-radius: 9999px;
  border: 1.5px solid #e2e8f0;
  background: white;
  padding: 0.5rem 1.1rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #475569;
  transition: all 0.2s ease;
}
.level-chip:hover {
  border-color: #f9a8d4;
  color: #db2777;
}
.level-chip.is-active {
  border-color: transparent;
  background: linear-gradient(135deg, #db2777, #f472b6);
  color: white;
}

/* ========== 콘텐츠 카드 (그리드) ========== */
.content-card {
  position: relative;
  cursor: pointer;
  border-radius: 1.25rem;
  background: white;
  padding: 1.5rem;
  border: 1px solid #f1f5f9;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.content-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 32px -10px rgba(79, 70, 229, 0.2);
  border-color: #e0e7ff;
}
.content-card.is-done {
  border-color: #a7f3d0;
  background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 60%);
}
.done-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 9999px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  font-size: 0.7rem;
  box-shadow: 0 4px 10px -3px rgba(5, 150, 105, 0.6);
}

/* ========== 학습완료 토글 버튼 ========== */
.mark-done-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 0.85rem;
  border: 1.5px solid #e2e8f0;
  background: white;
  color: #64748b;
  padding: 0.6rem 1.25rem;
  font-weight: 700;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}
.mark-done-btn:hover {
  border-color: #a7f3d0;
  color: #059669;
}
.mark-done-btn.is-done {
  border-color: transparent;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
}

.skeleton-card {
  height: 140px;
  border-radius: 1.25rem;
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========== 플래시카드 뷰어 ========== */
.flashcard-panel {
  border-radius: 1.75rem;
  background: white;
  box-shadow: 0 20px 50px -15px rgba(15, 23, 42, 0.15);
  border: 1px solid #f1f5f9;
  overflow: hidden;
}

.flashcard-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 0.85rem;
  padding: 0.75rem 1.5rem;
  font-weight: 700;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}
.flashcard-nav-btn.primary {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: white;
  box-shadow: 0 8px 20px -8px rgba(79, 70, 229, 0.6);
}
.flashcard-nav-btn.primary:hover {
  transform: translateY(-2px);
}
.flashcard-nav-btn.secondary {
  background: #f1f5f9;
  color: #475569;
}
.flashcard-nav-btn.secondary:hover {
  background: #e2e8f0;
}
.flashcard-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

.speak-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.85rem;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  padding: 0.65rem 1.25rem;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 8px 16px -6px rgba(5, 150, 105, 0.5);
  transition: all 0.2s ease;
}
.speak-btn:hover {
  transform: translateY(-2px);
}
.speak-btn.is-speaking {
  animation: pulse-speak 1s ease-in-out infinite;
}
@keyframes pulse-speak {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.progress-track {
  height: 8px;
  border-radius: 9999px;
  background: #e2e8f0;
  overflow: hidden;
}
.progress-track-light {
  background: rgba(255, 255, 255, 0.25);
}
.progress-fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, #4f46e5, #a855f7);
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ========== 퀴즈 진입 버튼 ========== */
.quiz-launch-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 1rem;
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: white;
  padding: 0.75rem 1.5rem;
  font-weight: 800;
  font-size: 0.9rem;
  box-shadow: 0 10px 24px -8px rgba(234, 88, 12, 0.6);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.quiz-launch-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 14px 30px -8px rgba(234, 88, 12, 0.7);
}

/* ========== 퀴즈 카드 ========== */
.quiz-card {
  border-radius: 1.75rem;
  background: white;
  box-shadow: 0 20px 50px -15px rgba(15, 23, 42, 0.15);
  border: 1px solid #f1f5f9;
  padding: 2rem;
}

.quiz-option-btn {
  border-radius: 1rem;
  border: 1.5px solid #e2e8f0;
  background: #f8fafc;
  padding: 1rem 1.25rem;
  font-weight: 700;
  font-size: 0.95rem;
  color: #334155;
  text-align: left;
  transition: all 0.2s ease;
}
.quiz-option-btn:hover:not(:disabled) {
  border-color: #c7d2fe;
  background: #eef2ff;
  color: #4338ca;
  transform: translateY(-2px);
}
.quiz-option-btn:disabled {
  cursor: not-allowed;
}
.quiz-option-btn.is-correct {
  border-color: transparent;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
}
.quiz-option-btn.is-wrong {
  border-color: transparent;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
}

.quiz-feedback-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 1rem;
  padding: 1rem 1.25rem;
  font-weight: 700;
  font-size: 0.95rem;
}
.quiz-feedback-box.is-correct {
  background: #ecfdf5;
  color: #059669;
}
.quiz-feedback-box.is-wrong {
  background: #fef2f2;
  color: #dc2626;
}

.quiz-review-item {
  border-radius: 1rem;
  background: #f8fafc;
  padding: 0.9rem 1.1rem;
  margin-bottom: 0.6rem;
  border: 1px solid #f1f5f9;
}

/* ========== 검색 결과 드롭다운 ========== */
.search-result-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-radius: 0.85rem;
  padding: 0.75rem 1rem;
  transition: background 0.15s ease;
  cursor: pointer;
}
.search-result-item:hover {
  background: #f8fafc;
}

/* ========== 애니메이션: reveal ========== */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  animation: revealUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.reveal-delay-1 { animation-delay: 0.1s; }
.reveal-delay-2 { animation-delay: 0.2s; }
.reveal-delay-3 { animation-delay: 0.3s; }
.reveal-delay-4 { animation-delay: 0.4s; }

@keyframes revealUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.reveal-on-scroll {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ========== 토스트 ========== */
#toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.toast-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-radius: 1rem;
  padding: 0.85rem 1.25rem;
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
  box-shadow: 0 10px 30px -8px rgba(15, 23, 42, 0.3);
  animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast-item.info { background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.toast-item.warning { background: linear-gradient(135deg, #f59e0b, #ea580c); }
.toast-item.error { background: linear-gradient(135deg, #ef4444, #dc2626); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 640px) {
  #toast-container {
    left: 1rem;
    right: 1rem;
  }
}

/* ========== PWA 설치 배너 ========== */
.pwa-install-banner {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  max-width: 30rem;
  margin: 0 auto;
  border-radius: 1.25rem;
  background: white;
  padding: 1rem 1.1rem;
  box-shadow: 0 20px 45px -12px rgba(15, 23, 42, 0.35);
  border: 1px solid #eef2ff;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
.pwa-install-banner.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.pwa-install-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.9rem;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: white;
  font-size: 1.15rem;
}
.pwa-install-text {
  flex: 1;
  min-width: 0;
}
.pwa-install-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 800;
  color: #0f172a;
}
.pwa-install-sub {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: #64748b;
}
.pwa-install-btn {
  flex-shrink: 0;
  border: none;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: white;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.55rem 1rem;
}
.pwa-dismiss-btn {
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 1rem;
  padding: 0.25rem;
}
.pwa-dismiss-btn:hover {
  color: #64748b;
}

/* ========== 관리자 페이지 ========== */
.admin-select {
  border-radius: 0.75rem;
  border: 1.5px solid #e2e8f0;
  background: white;
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
}
.admin-btn-primary {
  border-radius: 0.75rem;
  border: none;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  transition: opacity 0.2s ease;
}
.admin-btn-primary:hover {
  opacity: 0.9;
}
.admin-btn-secondary {
  border-radius: 0.75rem;
  border: 1.5px solid #e2e8f0;
  background: white;
  color: #475569;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.6rem 1.2rem;
  cursor: pointer;
}
.admin-btn-secondary:hover {
  border-color: #cbd5e1;
}
.admin-btn-danger {
  border-radius: 0.6rem;
  border: none;
  background: #fef2f2;
  color: #dc2626;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}
.admin-btn-danger:hover {
  background: #fee2e2;
}
.admin-btn-edit {
  border-radius: 0.6rem;
  border: none;
  background: #eef2ff;
  color: #4f46e5;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  margin-right: 0.4rem;
}
.admin-btn-edit:hover {
  background: #e0e7ff;
}
.admin-table-row td {
  padding: 0.85rem 1rem;
  border-top: 1px solid #f1f5f9;
  vertical-align: middle;
}
.admin-table-row:hover {
  background: #f8fafc;
}
.admin-thumb {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  object-fit: cover;
  background: #f1f5f9;
}
.admin-form-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #475569;
}
.admin-form-input,
.admin-form-textarea,
.admin-form-select {
  width: 100%;
  border-radius: 0.65rem;
  border: 1.5px solid #e2e8f0;
  padding: 0.55rem 0.8rem;
  font-size: 0.88rem;
  color: #1e293b;
}
.admin-form-input:focus,
.admin-form-textarea:focus,
.admin-form-select:focus {
  outline: none;
  border-color: #818cf8;
}
.admin-form-textarea {
  resize: vertical;
  min-height: 4.5rem;
}
.admin-image-preview {
  width: 100%;
  max-height: 10rem;
  object-fit: contain;
  border-radius: 0.65rem;
  background: #f8fafc;
  margin-top: 0.5rem;
}
.admin-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border-radius: 0.6rem;
  border: 1.5px dashed #cbd5e1;
  background: #f8fafc;
  color: #64748b;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
}
.admin-upload-btn:hover {
  border-color: #a5b4fc;
  color: #4f46e5;
}
