:root {
  --bg-top: #f8fafc;
  --bg-bottom: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --primary: #3b82f6;
  --panel-bg: rgba(255, 255, 255, 0.6);
  --panel-border: rgba(255, 255, 255, 0.4);
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.05);
  --serif: 'Noto Serif KR', serif;
  --sans: 'Pretendard', sans-serif;
  --glass-blur: 20px;
}

.dark-mode {
  --bg-top: #0f172a;
  --bg-bottom: #020617;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #60a5fa;
  --panel-bg: rgba(30, 41, 59, 0.5);
  --panel-border: rgba(255, 255, 255, 0.05);
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--sans);
  color: var(--text-main);
  background: linear-gradient(135deg, var(--bg-top), var(--bg-bottom));
  min-height: 100vh;
  display: flex;
  transition: color 0.4s, background 0.4s;
  overflow: hidden;
}

/* Background animated mesh */
.mesh-bg {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background-image: radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.08), transparent 50%),
                    radial-gradient(circle at 85% 30%, rgba(139, 92, 246, 0.08), transparent 50%);
  z-index: -1;
  pointer-events: none;
}

.dark-mode .mesh-bg {
  background-image: radial-gradient(circle at 15% 50%, rgba(96, 165, 250, 0.05), transparent 50%),
                    radial-gradient(circle at 85% 30%, rgba(167, 139, 250, 0.05), transparent 50%);
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--panel-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-right: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  padding: 2.5rem 1.5rem;
  box-shadow: 10px 0 30px rgba(0,0,0,0.02);
  z-index: 10;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 3rem;
  letter-spacing: -0.5px;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.nav-btn {
  background: transparent;
  border: none;
  text-align: left;
  padding: 1rem 1.2rem;
  border-radius: 12px;
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.nav-btn:hover {
  background: rgba(128,128,128,0.05);
  color: var(--text-main);
}
.dark-mode .nav-btn:hover { background: rgba(255,255,255,0.05); }

.nav-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}

.settings { margin-top: auto; }
#theme-toggle {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  width: 45px; height: 45px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  transition: transform 0.3s, background 0.3s;
}
#theme-toggle:hover {
  transform: rotate(30deg);
  background: rgba(128,128,128,0.1);
}

/* Main Content */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 3rem 5rem;
  overflow-y: auto;
}

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3rem;
  gap: 2rem;
}

.search-section {
  display: flex;
  background: var(--panel-bg);
  backdrop-filter: blur(var(--glass-blur));
  padding: 0.5rem;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  gap: 0.5rem;
}

.input-group {
  display: flex;
  align-items: center;
  background: rgba(128,128,128,0.05);
  padding: 0.5rem 1rem;
  border-radius: 12px;
  gap: 0.8rem;
}
.input-group i { color: var(--primary); font-size: 0.9rem; }
.input-group select, .input-group input {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}
.input-group select { width: 120px; }
.input-group input { width: 100px; }
.input-group select option { background: var(--bg-top); color: var(--text-main); }
.input-group input::placeholder { color: var(--text-muted); font-weight: 500; }

#search-btn {
  background: var(--text-main);
  color: var(--bg-top);
  border: none;
  padding: 0 1.5rem;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
#search-btn:hover { transform: scale(1.02); }

.date-display h1 {
  font-size: 2.2rem;
  font-weight: 300;
  letter-spacing: -1px;
}

/* Views */
.view-container { position: relative; flex: 1; }
.view {
  position: absolute;
  top: 0; left: 0; width: 100%;
  opacity: 0; visibility: hidden;
  transform: translateY(20px);
  transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.view.active {
  opacity: 1; visibility: visible;
  transform: translateY(0);
  position: relative;
}

/* Bible Viewer Specifics */
.verse-header .title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.bible-version-tabs {
  display: flex;
  gap: 0.4rem;
  background: rgba(128,128,128,0.08);
  padding: 0.3rem;
  border-radius: 10px;
}
.ver-tab {
  background: transparent;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: 0.2s;
}
.ver-tab.active {
  background: white;
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.dark-mode .ver-tab.active { background: var(--bg-top); }

.verse-header h2 { font-size: 2rem; font-family: var(--serif); font-weight: 600; }

.verse-content {
  font-family: var(--serif);
  font-size: 1.4rem;
  line-height: 2.2;
  max-width: 850px;
}
.verse {
  margin-bottom: 1.5rem;
  color: var(--text-main);
  transition: color 0.3s;
}
.verse-num {
  font-family: var(--sans);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.6em;
  top: -0.6em;
  margin-right: 0.5rem;
}

/* Sheet Music View */
.sheet-music-wrapper {
  background: #ffffff; /* Always white for visibility */
  padding: 2rem;
  border-radius: 20px;
  box-shadow: var(--shadow);
  text-align: center;
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dark-mode .sheet-music-wrapper { opacity: 0.9; }
.sheet-music-wrapper img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
}

/* Insight Cards */
.insight-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2rem;
}
.insight-card {
  background: var(--panel-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--panel-border);
  padding: 2.5rem;
  border-radius: 24px;
  box-shadow: var(--shadow);
  transition: transform 0.3s;
}
.insight-card:hover { transform: translateY(-5px); }
.insight-card .tag {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
  padding: 0.4rem 1rem;
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 700;
  display: inline-block;
  margin-bottom: 1.5rem;
}
.insight-card h3 { font-size: 1.4rem; margin-bottom: 1rem; }
.insight-card p { line-height: 1.7; color: var(--text-muted); }

.original-word { margin-bottom: 1rem; display: flex; align-items: baseline; gap: 0.5rem; }
.original-word .word { font-family: 'Times New Roman', serif; font-size: 2rem; color: var(--text-main); }
.original-word .pronounce { font-style: italic; color: var(--text-muted); }

/* Error & Loading State */
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(59, 130, 246, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 2rem auto;
}

.error-box {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  padding: 2rem;
  border-radius: 16px;
  text-align: center;
  color: #ef4444;
}
.error-box i { font-size: 2rem; margin-bottom: 1rem; display: block; }
.retry-btn {
  margin-top: 1.5rem;
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  body { flex-direction: column; overflow-y: auto; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--panel-border); padding: 1.5rem; flex-direction: row; align-items: center; justify-content: space-between; }
  .logo { margin-bottom: 0; }
  .nav-links { flex-direction: row; gap: 0.5rem; }
  .nav-btn { padding: 0.6rem 1rem; }
  .nav-btn i { display: none; }
  .app-main { padding: 2rem 1.5rem; }
  .top-header { flex-direction: column; align-items: flex-start; gap: 1.5rem; margin-bottom: 2rem; }
}
