@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Noto+Sans+JP:wght@300;400;500;700;900&display=swap');

body {
  font-family: 'Outfit', 'Noto Sans JP', "Yu Gothic", "Meiryo", sans-serif;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.sql-block {
  font-family: Consolas, "Courier New", monospace;
}

/* Glassmorphism utilities */
.glass-panel {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.dark .glass-panel {
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Modern scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(100, 116, 139, 0.2);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.4);
}
.dark ::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.15);
}
.dark ::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.3);
}

/* Premium Card hover glow effects */
.premium-card {
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.premium-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 20px -8px rgba(99, 102, 241, 0.15);
}
.dark .premium-card:hover {
  box-shadow: 0 12px 20px -8px rgba(99, 102, 241, 0.3);
}

/* Button micro-animations */
button {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
button:active {
  transform: scale(0.97);
}

/* Selection item active glows */
.choice-item {
  transition: all 0.2s ease;
}

/* Voice Guide - playing animation */
.voice-playing {
  animation: voice-pulse 1.5s ease-in-out infinite;
}

@keyframes voice-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(59, 130, 246, 0);
  }
}

.dark .voice-playing {
  animation: voice-pulse-dark 1.5s ease-in-out infinite;
}

@keyframes voice-pulse-dark {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(99, 102, 241, 0);
  }
}

/* ==========================================================================
   Comprehensive Dark Mode High-Contrast & Readability Enhancements
   ========================================================================== */

/* Dark Mode General Background and Text */
.dark body {
  background-color: #020617 !important;
  color: #f8fafc !important;
}

/* Category Panel Dark Mode */
.dark #categoryPanel {
  background-color: #0f172a !important;
  border: 1px solid #1e293b !important;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5) !important;
}

.dark #categoryPanel h3 {
  color: #f8fafc !important;
}

.dark #categoryPanel span {
  color: #94a3b8 !important;
}

.dark #categoryPanel label {
  color: #cbd5e1 !important;
}

.dark #quizCategorySelect {
  background-color: #020617 !important;
  border-color: #334155 !important;
  color: #ffffff !important;
}

.dark #quizCategorySelect option {
  background-color: #0f172a !important;
  color: #ffffff !important;
}

/* Title Card and Tab Containers */
.dark #quiz-tab > div.bg-white,
.dark #quizSection,
.dark #resultSection,
.dark #weakSection,
.dark #glossary-tab > div,
.dark #import-tab > div,
.dark #manage-tab > div {
  background-color: #0f172a !important;
  border-color: #1e293b !important;
  color: #f8fafc !important;
}

/* Inputs, Textareas, and Selects in Dark Mode */
.dark input[type="text"],
.dark input[type="number"],
.dark textarea,
.dark select {
  background-color: #020617 !important;
  border-color: #334155 !important;
  color: #ffffff !important;
}

.dark input::placeholder,
.dark textarea::placeholder {
  color: #64748b !important;
}

/* Search Bar Dark Mode */
.dark #customSearchBar {
  background-color: #0f172a !important;
  border-color: #1e293b !important;
}

.dark #customSearchInput {
  background-color: #020617 !important;
  border-color: #334155 !important;
  color: #ffffff !important;
}

/* Card Question Items in Dark Mode */
.dark [data-quiz-index],
.dark .quiz-card {
  background-color: #0f172a !important;
  border-color: #1e293b !important;
  color: #f8fafc !important;
}

.dark [data-quiz-index] .text-slate-900,
.dark .quiz-card .text-slate-900 {
  color: #ffffff !important;
}

.dark [data-quiz-index] .text-slate-800,
.dark .quiz-card .text-slate-800 {
  color: #f1f5f9 !important;
}

.dark [data-quiz-index] .text-slate-600,
.dark .quiz-card .text-slate-600 {
  color: #cbd5e1 !important;
}

.dark [data-quiz-index] .bg-slate-100,
.dark .quiz-card .bg-slate-100 {
  background-color: #1e293b !important;
  color: #cbd5e1 !important;
}

.dark [data-quiz-index] .bg-slate-50,
.dark .quiz-card .bg-slate-50 {
  background-color: #020617 !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
}

/* Choice Item Styling in Dark Mode */
.dark .choice-item {
  background-color: #0b1120 !important;
  border-color: #1e293b !important;
  color: #e2e8f0 !important;
}

.dark .choice-item:hover {
  background-color: #1e293b !important;
  border-color: #38bdf8 !important;
}

/* Correct Answer Highlights in Dark Mode */
.dark .choice-item.correct,
.dark .bg-emerald-50 {
  background-color: rgba(6, 78, 59, 0.4) !important;
  border-color: #059669 !important;
  color: #6ee7b7 !important;
}

/* Wrong Answer Highlights in Dark Mode */
.dark .choice-item.incorrect,
.dark .bg-rose-50 {
  background-color: rgba(136, 19, 55, 0.4) !important;
  border-color: #e11d48 !important;
  color: #fda4af !important;
}

/* Explanation Box in Dark Mode */
.dark .explanation-box,
.dark .bg-blue-50 {
  background-color: #0b1528 !important;
  border-color: #1d4ed8 !important;
  color: #e2e8f0 !important;
}

/* SweetAlert2 Dialogs in Dark Mode */
.dark .swal2-popup {
  background-color: #0f172a !important;
  color: #ffffff !important;
  border: 1px solid #334155 !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7) !important;
}

.dark .swal2-title {
  color: #ffffff !important;
}

.dark .swal2-html-container {
  color: #cbd5e1 !important;
}

.dark .swal2-input,
.dark .swal2-textarea {
  background-color: #020617 !important;
  color: #ffffff !important;
  border-color: #334155 !important;
}

/* Modal Dialogs in Dark Mode */
.dark #titleModal > div,
.dark #helpModal > div {
  background-color: #0f172a !important;
  border-color: #334155 !important;
  color: #ffffff !important;
}

.dark #helpModal .bg-slate-50 {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #ffffff !important;
}

/* Navigation Bar in Dark Mode */
.dark nav {
  background-color: #0f172a !important;
  border-color: #1e293b !important;
}

.dark nav button {
  color: #94a3b8 !important;
}

.dark nav button.text-blue-600,
.dark nav button.text-indigo-600 {
  color: #818cf8 !important;
  border-color: #818cf8 !important;
}

/* ==========================================================================
   Glossary High-Contrast Dark Mode & Light Mode Enforcements
   ========================================================================== */
.glossary-card {
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  position: relative;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.glossary-card:hover {
  box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.dark .glossary-card {
  background-color: #0f172a !important;
  border: 1px solid #334155 !important;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3) !important;
}

.dark .glossary-card:hover {
  background-color: #1e293b !important;
  border-color: #475569 !important;
  box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.5) !important;
}

.glossary-term-title {
  color: #0f172a;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.dark .glossary-term-title {
  color: #ffffff !important;
}

.glossary-term-desc {
  color: #334155;
  font-size: 0.8125rem;
  line-height: 1.6;
}

.dark .glossary-term-desc {
  color: #cbd5e1 !important;
}

.glossary-header-divider {
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 0.5rem;
}

.dark .glossary-header-divider {
  border-bottom: 1px solid #334155 !important;
}

.glossary-icon-btn {
  color: #64748b;
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.glossary-icon-btn:hover {
  background-color: #f1f5f9;
}

.dark .glossary-icon-btn {
  color: #94a3b8 !important;
}

.dark .glossary-icon-btn:hover {
  background-color: #334155 !important;
  color: #38bdf8 !important;
}

/* Glossary Search Input */
.glossary-search-box {
  background-color: #f8fafc;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}

.dark .glossary-search-box {
  background-color: #020617 !important;
  color: #ffffff !important;
  border: 1px solid #334155 !important;
}

.dark .glossary-search-box::placeholder {
  color: #64748b !important;
}

/* iOS PWA Safe Area & Touch Ergonomics */
body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
@media (max-width: 640px) {
  input[type="text"], input[type="number"], textarea, select {
    font-size: 16px !important; /* Prevent iOS Safari auto-zoom on focus */
  }
}
