:root {
  --bg-primary: #0f0a1a;
  --bg-secondary: #1a1128;
  --bg-card: #231a33;
  --bg-hover: #2d2240;
  --bg-active: #3a2d52;
  --text-primary: #e8e0f0;
  --text-secondary: #b8a8d0;
  --text-muted: #7a6a95;
  --accent-gold: #d4a856;
  --accent-gold-light: #e8c878;
  --accent-purple: #9b6dff;
  --accent-purple-light: #b898ff;
  --border: #2d2240;
  --shadow: rgba(0, 0, 0, 0.4);
  --sidebar-width: 320px;
  --header-height: 64px;
  --font-body: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-heading: Georgia, 'Times New Roman', serif;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 100;
  gap: 16px;
}

.header__logo {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--accent-gold);
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.header__search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.header__search input {
  width: 100%;
  padding: 8px 16px 8px 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.header__search input:focus {
  border-color: var(--accent-purple);
}

.header__search input::placeholder {
  color: var(--text-muted);
}

.header__search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.header__progress {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  white-space: nowrap;
}

.header__progress-bar {
  width: 120px;
  height: 6px;
  background: var(--bg-card);
  border-radius: 3px;
  overflow: hidden;
}

.header__progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-gold));
  border-radius: 3px;
  transition: width 0.4s ease;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 0;
  z-index: 90;
  transition: transform 0.3s ease;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.sidebar__module {
  margin-bottom: 4px;
}

.sidebar__module-title {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  color: var(--accent-gold);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
  gap: 8px;
}

.sidebar__module-title:hover {
  background: var(--bg-hover);
}

.sidebar__module-title .arrow {
  font-size: 0.7rem;
  transition: transform 0.2s;
  color: var(--text-muted);
}

.sidebar__module-title .arrow.open {
  transform: rotate(90deg);
}

.sidebar__module-title .module-num {
  background: var(--bg-active);
  color: var(--accent-gold-light);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-family: var(--font-body);
  flex-shrink: 0;
}

.sidebar__lessons {
  display: none;
  padding: 2px 0;
}

.sidebar__lessons.open {
  display: block;
}

.sidebar__lesson {
  display: flex;
  align-items: center;
  padding: 8px 20px 8px 52px;
  font-size: 0.87rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  gap: 10px;
  text-decoration: none;
  position: relative;
}

.sidebar__lesson:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar__lesson.active {
  background: var(--bg-active);
  color: var(--accent-gold-light);
}

.sidebar__lesson.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent-gold);
}

.sidebar__lesson-check {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--text-muted);
  border-radius: 4px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s;
}

.sidebar__lesson-check.completed {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  color: white;
}

/* Main Content */
.main {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
  padding: 40px 60px 80px;
  max-width: 900px;
}

.content {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Markdown Content Styles */
.content h1 {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  color: var(--accent-gold);
  margin-bottom: 8px;
  line-height: 1.3;
}

.content h2 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  color: var(--accent-gold-light);
  margin-top: 48px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.content h3 {
  font-size: 1.2rem;
  color: var(--accent-purple-light);
  margin-top: 32px;
  margin-bottom: 12px;
}

.content h4 {
  font-size: 1.05rem;
  color: var(--text-primary);
  margin-top: 24px;
  margin-bottom: 8px;
}

.content p {
  margin-bottom: 16px;
  color: var(--text-primary);
}

.content strong {
  color: var(--accent-gold-light);
  font-weight: 600;
}

.content em {
  color: var(--accent-purple-light);
  font-style: italic;
}

.content ul, .content ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.content li {
  margin-bottom: 6px;
  color: var(--text-primary);
}

.content li::marker {
  color: var(--accent-gold);
}

.content blockquote {
  border-left: 3px solid var(--accent-purple);
  background: var(--bg-card);
  padding: 16px 20px;
  margin: 20px 0;
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
  font-style: italic;
}

.content code {
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  color: var(--accent-purple-light);
}

.content pre {
  background: var(--bg-card);
  padding: 20px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 20px 0;
  border: 1px solid var(--border);
}

.content pre code {
  background: none;
  padding: 0;
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.92rem;
}

.content table th {
  background: var(--bg-card);
  color: var(--accent-gold);
  padding: 12px 16px;
  text-align: left;
  border-bottom: 2px solid var(--accent-purple);
  font-family: var(--font-heading);
}

.content table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.content table tr:hover td {
  background: var(--bg-hover);
}

.content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 16px 0;
  box-shadow: 0 4px 20px var(--shadow);
}

.content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

.content a {
  color: var(--accent-purple-light);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.content a:hover {
  border-bottom-color: var(--accent-purple-light);
}

/* Card image layout for tarot card pages */
.content .card-image-container {
  text-align: center;
  margin: 24px 0;
}

.content .card-image-container img {
  max-height: 400px;
  width: auto;
}

/* Navigation buttons */
.nav-buttons {
  display: flex;
  justify-content: space-between;
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  gap: 16px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  text-decoration: none;
}

.nav-btn:hover {
  background: var(--bg-hover);
  color: var(--accent-gold);
  border-color: var(--accent-gold);
}

.nav-btn--next {
  margin-left: auto;
}

/* Search results overlay */
.search-results {
  display: none;
  position: fixed;
  top: var(--header-height);
  left: var(--sidebar-width);
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  z-index: 80;
  padding: 40px 60px;
  overflow-y: auto;
}

.search-results.visible {
  display: block;
}

.search-results__title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--accent-gold);
  margin-bottom: 24px;
}

.search-results__item {
  padding: 16px 20px;
  background: var(--bg-card);
  border-radius: 8px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--border);
}

.search-results__item:hover {
  border-color: var(--accent-purple);
  background: var(--bg-hover);
}

.search-results__item-title {
  color: var(--accent-gold-light);
  font-weight: 600;
  margin-bottom: 4px;
}

.search-results__item-excerpt {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.5;
}

.search-results__item-excerpt mark {
  background: var(--accent-purple);
  color: white;
  padding: 1px 3px;
  border-radius: 2px;
}

/* Loading state */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px var(--shadow);
  }

  .main {
    margin-left: 0;
    padding: 24px 20px 60px;
  }

  .search-results {
    left: 0;
    padding: 24px 20px;
  }

  .menu-toggle {
    display: block;
  }

  .header__progress-bar {
    display: none;
  }

  .content h1 {
    font-size: 1.7rem;
  }

  .content h2 {
    font-size: 1.3rem;
  }
}

/* Print styles */
@media print {
  .header, .sidebar, .nav-buttons, .search-results {
    display: none !important;
  }

  .main {
    margin: 0;
    padding: 20px;
    max-width: none;
  }

  .content h1 { color: #333; }
  .content h2 { color: #444; }
  .content h3 { color: #555; }
  .content { color: #222; }
  .content strong { color: #333; }
  .content blockquote {
    border-left-color: #999;
    background: #f5f5f5;
  }

  body {
    background: white;
    color: #222;
  }
}
