:root {
  /* Aurora Purple (default) */
  --bg: #05010f;
  --fg: #ebe8ff;
  --accent: #f7aef8;
  --accent-contrast: #1f1a2e;
  --surface: rgba(26, 7, 48, 0.9);
  --surface-alt: rgba(26, 7, 48, 0.75);
  --muted-text: rgba(255, 255, 255, 0.64);
  --body-gradient-top: rgba(74, 0, 114, 0.55);
  --body-gradient-bottom: rgba(14, 116, 144, 0.45);
  --header-gradient: linear-gradient(135deg, #1a0730 0%, #5d3492 50%, #fcbd49 100%);
  --header-border: rgba(182, 119, 255, 0.35);
  --badge-bg: #7c6af7;
  --select-bg: rgba(26, 7, 48, 0.8);
  --select-border: rgba(182, 119, 255, 0.3);
  --select-hover-border: rgba(182, 119, 255, 0.5);
  --select-focus-border: rgba(252, 189, 73, 0.6);
  --select-focus-ring: rgba(252, 189, 73, 0.2);
  --card-border: rgba(182, 119, 255, 0.35);
  --link-color: #f7aef8;
  --link-hover-color: #fbe6ff;
  --pill-bg: rgba(255, 255, 255, 0.08);
  --pill-border: rgba(255, 255, 255, 0.15);
}

body.theme-default {
  /* Ensure CSS variables reset if body carries theme class explicitly */
  --bg: #05010f;
  --fg: #ebe8ff;
  --accent: #f7aef8;
  --accent-contrast: #1f1a2e;
  --surface: rgba(26, 7, 48, 0.9);
  --surface-alt: rgba(26, 7, 48, 0.75);
  --muted-text: rgba(255, 255, 255, 0.64);
  --body-gradient-top: rgba(74, 0, 114, 0.55);
  --body-gradient-bottom: rgba(14, 116, 144, 0.45);
  --header-gradient: linear-gradient(135deg, #1a0730 0%, #5d3492 50%, #fcbd49 100%);
  --header-border: rgba(182, 119, 255, 0.35);
  --badge-bg: #7c6af7;
  --select-bg: rgba(26, 7, 48, 0.8);
  --select-border: rgba(182, 119, 255, 0.3);
  --select-hover-border: rgba(182, 119, 255, 0.5);
  --select-focus-border: rgba(252, 189, 73, 0.6);
  --select-focus-ring: rgba(252, 189, 73, 0.2);
  --card-border: rgba(182, 119, 255, 0.35);
  --link-color: #f7aef8;
  --link-hover-color: #fbe6ff;
  --pill-bg: rgba(255, 255, 255, 0.08);
  --pill-border: rgba(255, 255, 255, 0.15);
}

body.theme-light {
  --bg: #f8fafc;
  --fg: #030712;
  --accent: #2563eb;
  --accent-contrast: #ffffff;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --muted-text: #6b7280;
  --body-gradient-top: rgba(148, 163, 184, 0.25);
  --body-gradient-bottom: rgba(59, 130, 246, 0.2);
  --header-gradient: linear-gradient(135deg, #e2e8f0 0%, #c7d2fe 50%, #facc15 100%);
  --header-border: rgba(148, 163, 184, 0.4);
  --badge-bg: #3b82f6;
  --select-bg: rgba(255, 255, 255, 0.95);
  --select-border: rgba(148, 163, 184, 0.45);
  --select-hover-border: rgba(59, 130, 246, 0.55);
  --select-focus-border: rgba(37, 99, 235, 0.7);
  --select-focus-ring: rgba(59, 130, 246, 0.25);
  --card-border: rgba(148, 163, 184, 0.35);
  --link-color: #1d4ed8;
  --link-hover-color: #1e40af;
  --pill-bg: rgba(3, 7, 18, 0.05);
  --pill-border: rgba(148, 163, 184, 0.35);
}

body.theme-light a {
  color: var(--link-color);
}

body.theme-light a:hover,
body.theme-light a:focus {
  color: var(--link-hover-color);
}

body.theme-light .app-header,
body.theme-light header {
  color: var(--fg);
}

/* Landing page styles - default dark theme */
*:not(.theme-light):not(.theme-default):not(.theme-admin-default), *::before, *::after {
    box-sizing: border-box;
}

/* Prevent flash of unstyled content - default dark theme */
body:not(.theme-light):not(.theme-default):not(.theme-admin-default),
body.theme-default {
    margin: 0;
    padding: 0;
    font-family: 'Georgia', 'Garamond', 'Times New Roman', serif;
    background: radial-gradient(circle at top, var(--body-gradient-top), transparent 55%),
                radial-gradient(circle at bottom, var(--body-gradient-bottom), transparent 60%),
                var(--bg);
    color: var(--fg);
    line-height: 1.7;
    letter-spacing: 0.01em;
    min-height: 100vh;
    /* Hide content initially to prevent flash */
    visibility: hidden;
}

/* Light theme body needs the same treatment with its palette */
body.theme-light {
    margin: 0;
    padding: 0;
    font-family: 'Georgia', 'Garamond', 'Times New Roman', serif;
    background: radial-gradient(circle at top, var(--body-gradient-top), transparent 55%),
                radial-gradient(circle at bottom, var(--body-gradient-bottom), transparent 60%),
                var(--bg);
    color: var(--fg);
    line-height: 1.7;
    letter-spacing: 0.01em;
    min-height: 100vh;
    visibility: hidden;
}

/* Show content once CSS is loaded */
body.loaded {
    visibility: visible;
}

header {
    padding: 2.75rem 1.5rem 2rem 1.5rem;
    background: var(--header-gradient);
    width: 100%;
    border-bottom: 1px solid var(--header-border);
    position: relative;
    overflow: hidden;
    text-align: center;
}

.header-content {
    position: relative;
    z-index: 1;
}

h1 {
    font-size: 2.5rem;
    font-weight: 300;
    color: var(--fg);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin: 0 0 1rem 0;
}

.header-description {
    font-size: 1.1rem;
    color: var(--muted-text);
    line-height: 1.6;
    margin: 0;
}

.selectors {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.selector label {
    font-size: 0.9rem;
    color: var(--muted-text);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.selector select {
    padding: 0.75rem 1rem;
    background: var(--select-bg);
    border: 1px solid var(--select-border);
    border-radius: 8px;
    color: var(--fg);
    font-size: 1rem;
    font-family: inherit;
    min-width: 200px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.selector select:hover {
    border-color: var(--select-hover-border);
    background: var(--surface);
}

.selector select:focus {
    outline: none;
    border-color: var(--select-focus-border);
    box-shadow: 0 0 0 3px var(--select-focus-ring);
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

.chapters-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 2rem;
}

.chapter {
    background: var(--surface);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 2rem;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.chapter::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-contrast));
}

.chapter:hover {
    transform: translateY(-2px);
    border-color: var(--select-hover-border);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.chapter h3 {
    margin: 0 0 1rem 0;
    font-size: 1.5rem;
    font-weight: 400;
}

.chapter h3 a {
    color: var(--fg);
    text-decoration: none;
    transition: color 0.3s ease;
}

.chapter h3 a:hover {
    color: var(--accent);
}

.chapter p {
    margin: 0 0 1.5rem 0;
    color: var(--muted-text);
    line-height: 1.6;
}

.read-more {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.read-more:hover {
    color: var(--accent);
    transform: translateX(2px);
}

.read-more::after {
    content: '→';
    transition: transform 0.3s ease;
}

.read-more:hover::after {
    transform: translateX(2px);
}

@media (max-width: 768px) {
    header {
        padding: 2rem 1rem 1.5rem 1rem;
    }
    
    .selectors {
        gap: 1rem;
        margin-top: 1.5rem;
    }
    
    .selector select {
        min-width: 150px;
        padding: 0.6rem 0.8rem;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    main {
        padding: 2rem 1rem;
    }
    
    .chapter {
        padding: 1.5rem;
    }
}
