/* Modern Book Website Styles */
:root {
    /* Light mode colors */
    --primary-color: #1a1a2e;
    --primary-light: #16213e;
    --secondary-color: #0f3460;
    --accent-color: #e94560;
    --accent-light: #ff6b8a;
    --text-color: #2d3748;
    --text-light: #4a5568;
    --bg-color: #ffffff;
    --bg-secondary: #f7fafc;
    --border-color: #e2e8f0;
    --code-bg: #f1f5f9;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --gradient-primary: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    --gradient-accent: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-light) 100%);
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode colors */
[data-theme="dark"] {
    --primary-color: #f7fafc;
    --primary-light: #e2e8f0;
    --secondary-color: #cbd5e0;
    --accent-color: #f6ad55;
    --accent-light: #fbb042;
    --text-color: #f7fafc;
    --text-light: #cbd5e0;
    --bg-color: #1a202c;
    --bg-secondary: #2d3748;
    --border-color: #4a5568;
    --code-bg: #2d3748;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.3), 0 1px 2px 0 rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
}

* {
    box-sizing: border-box;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* Selection */
::selection {
    background: var(--accent-color);
    color: white;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.7;
    color: var(--text-color);
    margin: 0;
    padding: 0;
    background: var(--bg-color);
    transition: var(--transition);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Enhanced Header */
header {
    background: var(--gradient-primary);
    color: white;
    padding: 2rem 0;
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] header {
    background: linear-gradient(135deg, var(--bg-color) 0%, var(--bg-secondary) 100%);
    color: var(--text-color);
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="white" opacity="0.1"/><circle cx="75" cy="75" r="1" fill="white" opacity="0.1"/><circle cx="50" cy="10" r="0.5" fill="white" opacity="0.15"/><circle cx="90" cy="40" r="0.5" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    pointer-events: none;
}

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

header h1 {
    margin: 0;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] header h1 {
    color: var(--text-color);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

header h1 a {
    color: white;
    text-decoration: none;
    transition: var(--transition);
}

[data-theme="dark"] header h1 a {
    color: var(--text-color);
}

header h1 a:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

header p {
    margin: 0.5rem 0 0;
    font-size: 1.2rem;
    opacity: 0.95;
    font-weight: 300;
    color: white;
}

[data-theme="dark"] header p {
    color: var(--text-light);
    opacity: 1;
}

/* Modern Navigation */
nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: var(--transition);
}

[data-theme="dark"] nav {
    background: rgba(26, 32, 44, 0.95);
}

nav .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 20px;
    position: relative;
}

.nav-brand {
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
    font-size: 1.1rem;
}

[data-theme="dark"] .nav-brand {
    color: var(--text-color);
}

/* Mobile menu toggle */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    gap: 4px;
}

.mobile-menu-toggle span {
    width: 25px;
    height: 3px;
    background: var(--text-color);
    transition: var(--transition);
    border-radius: 2px;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Navigation menu */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Chapters dropdown */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.5rem 1rem;
    color: var(--text-color);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

.nav-dropdown-toggle:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-color);
}

.dropdown-arrow {
    transition: transform 0.3s ease;
}

.nav-dropdown.active .dropdown-arrow {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1rem;
    margin-top: 0.5rem;
    min-width: 320px;
    max-height: 70vh;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.nav-dropdown.active .nav-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chapters-grid {
    display: grid;
    gap: 0.5rem;
}

.chapter-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-color);
    transition: var(--transition);
    border: 1px solid transparent;
}

.chapter-dropdown-item:hover {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    transform: translateX(4px);
}

.chapter-dropdown-item.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.chapter-number {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    background: var(--bg-secondary);
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.chapter-dropdown-item.active .chapter-number {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.chapter-title {
    font-weight: 500;
    line-height: 1.3;
}

/* Current section indicator */
.nav-current-section {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    color: var(--text-light);
}

.current-chapter-indicator {
    font-weight: 500;
}

/* Chapter progress indicators */
.chapter-progress {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
    transition: var(--transition);
    margin-left: auto;
}

.chapter-progress.visited {
    background: var(--accent-color);
}

.chapter-dropdown-item.active .chapter-progress {
    background: rgba(255, 255, 255, 0.7);
}

/* Enhanced dropdown scrollbar */
.nav-dropdown-menu::-webkit-scrollbar {
    width: 6px;
}

.nav-dropdown-menu::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.nav-dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* Chapter grouping for large books */
.chapter-group {
    margin-bottom: 1rem;
}

.chapter-group-header {
    font-weight: 600;
    color: var(--primary-color);
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chapter-group .chapters-grid {
    padding-left: 0.5rem;
    border-left: 2px solid var(--border-color);
}

/* Navigation breadcrumbs for complex navigation */
.nav-breadcrumbs {
    background: var(--bg-secondary);
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.nav-breadcrumbs a {
    color: var(--text-light);
    text-decoration: none;
}

.nav-breadcrumbs a:hover {
    color: var(--primary-color);
}

.nav-breadcrumbs .separator {
    margin: 0 0.5rem;
    color: var(--text-light);
}

/* Search within chapters dropdown */
.chapters-search {
    margin-bottom: 1rem;
    position: relative;
}

.chapters-search input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 0.9rem;
}

.chapters-search input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(233, 69, 96, 0.1);
}

/* Quick navigation shortcuts */
.nav-shortcuts {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.nav-shortcut {
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-color);
    font-size: 0.8rem;
    transition: var(--transition);
    flex: 1;
    text-align: center;
}

.nav-shortcut:hover {
    background: var(--accent-color);
    color: white;
}

nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

nav li {
    margin: 0;
}

nav a {
    color: var(--text-color);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-weight: 500;
    position: relative;
}

[data-theme="dark"] nav a {
    color: var(--text-color);
}

nav a:hover {
    background: var(--bg-secondary);
    transform: translateY(-1px);
}

[data-theme="dark"] nav a:hover {
    background: var(--border-color);
}

nav a.active {
    background: var(--gradient-accent);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 1rem;
}

.theme-toggle:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
    transform: rotate(180deg);
}

.theme-toggle::before {
    content: '🌙';
    font-size: 1.2rem;
}

[data-theme="dark"] .theme-toggle::before {
    content: '☀️';
}

/* Enhanced Main Content */
main {
    padding: 3rem 0;
    min-height: 70vh;
    background: linear-gradient(180deg, var(--bg-color) 0%, var(--bg-secondary) 100%);
}

.chapter-content {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 3rem;
    position: relative;
}

.chapter-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-accent);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

/* Beautiful Chapter Navigation */
.chapter-nav {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    margin: 3rem 0;
    padding: 0;
    background: none;
}

.chapter-nav-item {
    background: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    text-decoration: none;
    color: var(--text-color);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.chapter-nav-item:hover {
    background: var(--gradient-accent);
    border-color: var(--accent-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.chapter-nav-item span {
    position: relative;
    z-index: 1;
    color: inherit;
}

/* Ensure links within chapter nav items don't have underline effects */
.chapter-nav-item a::after {
    display: none !important;
}

.chapter-nav-item a {
    color: inherit;
    text-decoration: none;
}

.chapter-nav-item:hover a {
    color: white;
}

.chapter-nav-prev {
    text-align: left;
}

.chapter-nav-next {
    text-align: right;
}

.chapter-nav-center {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    padding: 0;
}

.chapter-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--border-color);
    transition: var(--transition);
}

.chapter-indicator.active {
    background: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(233, 69, 96, 0.2);
}

/* Enhanced Typography */
h1, h2, h3, h4, h5, h6 {
    color: var(--primary-color);
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    position: relative;
}

/* Dark mode heading improvements */
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6 {
    color: var(--text-color);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] h2 {
    background: linear-gradient(90deg, var(--bg-secondary) 0%, transparent 100%);
    border-left-color: var(--accent-color);
}

[data-theme="dark"] h3 {
    color: var(--text-color);
}

[data-theme="dark"] h4 {
    color: var(--text-color);
}

[data-theme="dark"] h5,
[data-theme="dark"] h6 {
    color: var(--text-light);
}

h1 {
    font-size: 2.5rem;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    position: relative;
    padding-bottom: 1rem;
}

h1::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 4px;
    background: var(--gradient-accent);
    border-radius: 2px;
}

h2 {
    font-size: 2rem;
    margin-top: 3rem;
    padding-left: 1rem;
    border-left: 4px solid var(--accent-color);
    background: linear-gradient(90deg, var(--bg-secondary) 0%, transparent 100%);
    padding: 0.75rem 0 0.75rem 1.5rem;
    margin-left: -1.5rem;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

h3 {
    font-size: 1.5rem;
    color: var(--secondary-color);
}

h4 {
    font-size: 1.25rem;
    color: var(--text-color);
}

h5, h6 {
    font-size: 1.1rem;
    color: var(--text-light);
}

/* Enhanced Paragraphs */
p {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-color);
}

[data-theme="dark"] p {
    color: var(--text-color);
}

.lead {
    font-size: 1.25rem;
    font-weight: 300;
    color: var(--text-light);
    margin-bottom: 2rem;
}

[data-theme="dark"] .lead {
    color: var(--text-light);
}

/* Beautiful Lists */
ul, ol {
    margin: 1.5rem 0;
    padding-left: 1.5rem;
    color: var(--text-color);
}

[data-theme="dark"] ul,
[data-theme="dark"] ol {
    color: var(--text-color);
}

li {
    margin-bottom: 0.75rem;
    padding-left: 0;
    position: static;
    color: var(--text-color);
}

[data-theme="dark"] li {
    color: var(--text-color);
}

ol:not(.chapter-list) {
    counter-reset: none;
}

ol:not(.chapter-list) li {
    counter-increment: none;
}

/* Enhanced Code Blocks */
code {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Consolas', monospace;
    font-size: 0.9em;
    background: var(--code-bg);
    color: var(--accent-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

[data-theme="dark"] code {
    background: var(--bg-secondary);
    color: var(--accent-light);
    border-color: var(--border-color);
}

pre {
    background: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    overflow-x: auto;
    position: relative;
    margin: 2rem 0;
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] pre {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-color);
}

pre::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-accent);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

pre code {
    background: none;
    padding: 0;
    color: var(--text-color);
    font-weight: normal;
    border: none;
}

[data-theme="dark"] pre code {
    color: var(--text-color);
}

/* Prism.js Syntax Highlighting */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: #708090;
    font-style: italic;
}

.token.punctuation {
    color: #999;
}

.token.namespace {
    opacity: .7;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
    color: #e74c3c;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
    color: #27ae60;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
    color: #3498db;
}

.token.atrule,
.token.attr-value,
.token.keyword {
    color: #9b59b6;
}

.token.function,
.token.class-name {
    color: #f39c12;
}

.token.regex,
.token.important,
.token.variable {
    color: #e67e22;
}

.token.important,
.token.bold {
    font-weight: bold;
}

.token.italic {
    font-style: italic;
}

.token.entity {
    cursor: help;
}

/* Dark theme syntax highlighting */
[data-theme="dark"] .token.comment,
[data-theme="dark"] .token.prolog,
[data-theme="dark"] .token.doctype,
[data-theme="dark"] .token.cdata {
    color: #6c7b7f;
}

[data-theme="dark"] .token.punctuation {
    color: #c9d1d9;
}

[data-theme="dark"] .token.property,
[data-theme="dark"] .token.tag,
[data-theme="dark"] .token.boolean,
[data-theme="dark"] .token.number,
[data-theme="dark"] .token.constant,
[data-theme="dark"] .token.symbol,
[data-theme="dark"] .token.deleted {
    color: #ff6b8a;
}

[data-theme="dark"] .token.selector,
[data-theme="dark"] .token.attr-name,
[data-theme="dark"] .token.string,
[data-theme="dark"] .token.char,
[data-theme="dark"] .token.builtin,
[data-theme="dark"] .token.inserted {
    color: #7ee787;
}

[data-theme="dark"] .token.operator,
[data-theme="dark"] .token.entity,
[data-theme="dark"] .token.url,
[data-theme="dark"] .language-css .token.string,
[data-theme="dark"] .style .token.string {
    color: #79c0ff;
}

[data-theme="dark"] .token.atrule,
[data-theme="dark"] .token.attr-value,
[data-theme="dark"] .token.keyword {
    color: #d2a8ff;
}

[data-theme="dark"] .token.function,
[data-theme="dark"] .token.class-name {
    color: #ffa657;
}

[data-theme="dark"] .token.regex,
[data-theme="dark"] .token.important,
[data-theme="dark"] .token.variable {
    color: #ffa657;
}

/* Language-specific highlighting */
.language-go .token.keyword {
    color: #00add8;
}

.language-go .token.function {
    color: #ac4142;
}

.language-go .token.string {
    color: #90a959;
}

[data-theme="dark"] .language-go .token.keyword {
    color: #79c0ff;
}

[data-theme="dark"] .language-go .token.function {
    color: #ff6b8a;
}

[data-theme="dark"] .language-go .token.string {
    color: #7ee787;
}

/* JavaScript specific */
.language-javascript .token.template-string {
    color: #27ae60;
}

.language-javascript .token.template-punctuation {
    color: #e74c3c;
}

[data-theme="dark"] .language-javascript .token.template-string {
    color: #7ee787;
}

[data-theme="dark"] .language-javascript .token.template-punctuation {
    color: #ff6b8a;
}

/* JSON specific */
.language-json .token.property {
    color: #3498db;
}

.language-json .token.string {
    color: #27ae60;
}

[data-theme="dark"] .language-json .token.property {
    color: #79c0ff;
}

[data-theme="dark"] .language-json .token.string {
    color: #7ee787;
}

/* Language-specific colors */
pre.language-go[data-language]::before {
    background: #00add8 !important;
    color: white !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9) !important;
    border-color: rgba(0, 173, 216, 0.4) !important;
}

pre.language-javascript[data-language]::before {
    background: #f7df1e !important;
    color: #1a1a1a !important;
    font-weight: 800 !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7) !important;
    border-color: rgba(247, 223, 30, 0.4) !important;
}

pre.language-typescript[data-language]::before {
    background: #3178c6 !important;
    color: white !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9) !important;
    border-color: rgba(49, 120, 198, 0.4) !important;
}

pre.language-json[data-language]::before {
    background: #2d3748 !important;
    color: white !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

pre.language-bash[data-language]::before,
pre.language-shell[data-language]::before {
    background: #4eaa25 !important;
    color: white !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9) !important;
    border-color: rgba(78, 170, 37, 0.4) !important;
}

pre.language-yaml[data-language]::before {
    background: #cb171e !important;
    color: white !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9) !important;
    border-color: rgba(203, 23, 30, 0.4) !important;
}

pre.language-python[data-language]::before {
    background: #3776ab !important;
    color: white !important;
    font-weight: 800 !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9) !important;
    border-color: rgba(55, 118, 171, 0.4) !important;
}

pre.language-dockerfile::before {
    content: "Docker";
    background: #2496ed;
}

/* Copy button for code blocks */
.copy-button {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition);
    z-index: 20;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    font-family: monospace;
    color: var(--text-color);
    font-weight: 600;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Show copy button on hover over the entire pre element OR when focusing within */
pre:hover .copy-button,
pre:focus-within .copy-button {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.copy-button:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

[data-theme="dark"] .copy-button {
    background: rgba(45, 55, 72, 0.95);
    border-color: var(--border-color);
    color: var(--text-color);
}

[data-theme="dark"] .copy-button:hover {
    background: var(--accent-light);
    color: var(--bg-color);
    border-color: var(--accent-light);
}

/* Enhanced language label positioning */
pre[class*="language-"][data-language]::before {
    content: attr(data-language);
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: #1a1a2e;
    color: white;
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 0.5rem;
    opacity: 1;
    z-index: 15;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.15);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] pre[class*="language-"][data-language]::before {
    background: #f7fafc;
    color: #1a202c;
    border: 1px solid rgba(0, 0, 0, 0.1);
    text-shadow: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Adjust language label position when hovering over pre (copy button visible) */
pre:hover[class*="language-"][data-language]::before {
    right: 4.5rem;
    opacity: 1;
    transform: scale(1.05);
}

/* Enhanced Blockquotes */
blockquote {
    margin: 2rem 0;
    padding: 1.5rem 2rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    border-left: 5px solid var(--accent-color);
    font-style: italic;
    font-size: 1.1rem;
    position: relative;
    box-shadow: var(--shadow-sm);
    color: var(--text-color);
}

[data-theme="dark"] blockquote {
    background: var(--bg-secondary);
    color: var(--text-color);
    border-left-color: var(--accent-light);
}

blockquote::before {
    content: '"';
    font-size: 4rem;
    color: var(--accent-color);
    position: absolute;
    top: -10px;
    left: 10px;
    opacity: 0.3;
    line-height: 1;
}

[data-theme="dark"] blockquote::before {
    color: var(--accent-light);
}

blockquote p {
    margin-bottom: 0;
}

/* Enhanced Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 2rem 0;
    background: var(--bg-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

[data-theme="dark"] table {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

th, td {
    border: none;
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

th {
    background: var(--gradient-primary);
    color: white;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-size: 0.9rem;
}

[data-theme="dark"] th {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--border-color) 100%);
    color: var(--text-color);
}

tr:hover {
    background: var(--bg-secondary);
}

[data-theme="dark"] tr:hover {
    background: var(--border-color);
}

tr:last-child td {
    border-bottom: none;
}

/* Enhanced Images */
img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2rem auto;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

img:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-lg);
}

/* Enhanced Links */
a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    position: relative;
    transition: var(--transition);
}

a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--gradient-accent);
    transition: var(--transition);
}

a:hover::after {
    width: 100%;
}

a:visited {
    color: var(--secondary-color);
}

/* Home Page Styles */
.home-content {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.book-description {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: var(--border-radius-lg);
    margin: 2rem 0;
    box-shadow: var(--shadow-sm);
}

.chapter-list {
    text-align: left;
    background: var(--bg-color);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    margin: 2rem 0;
}

.chapter-list li {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    transition: var(--transition);
    border-left: 4px solid transparent;
    padding-left: 1rem; /* Reset padding since no pseudo-element */
    position: static; /* Reset position since no pseudo-element */
}

.chapter-list li:hover {
    border-left-color: var(--accent-color);
    transform: translateX(8px);
    background: var(--bg-color);
    box-shadow: var(--shadow-sm);
}

.chapter-list a {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
}

.book-info {
    background: var(--gradient-primary);
    color: white;
    padding: 2rem;
    border-radius: var(--border-radius-lg);
    margin: 2rem 0;
    box-shadow: var(--shadow-md);
}

.book-info h1, .book-info h2, .book-info h3, .book-info h4, .book-info h5, .book-info h6 {
    color: white;
}

.book-info p {
    color: white;
    opacity: 0.95;
}

[data-theme="dark"] .book-info {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--border-color) 100%);
    color: var(--text-color);
}

[data-theme="dark"] .book-info h1,
[data-theme="dark"] .book-info h2,
[data-theme="dark"] .book-info h3,
[data-theme="dark"] .book-info h4,
[data-theme="dark"] .book-info h5,
[data-theme="dark"] .book-info h6 {
    color: var(--text-color);
}

[data-theme="dark"] .book-info p {
    color: var(--text-color);
    opacity: 1;
}

/* Authors Detail Section */
.authors-detail {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .authors-detail {
    border-top-color: var(--border-color);
}

.author-info {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: var(--border-radius);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .author-info {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.author-info:last-child {
    margin-bottom: 0;
}

.author-info h4 {
    margin: 0 0 0.5rem 0;
    color: var(--text-color);
    font-size: 1.2rem;
}

[data-theme="dark"] .author-info h4 {
    color: var(--text-color);
}

.author-info .author-bio {
    margin: 0.5rem 0;
    opacity: 0.9;
    line-height: 1.5;
    color: var(--text-color);
}

[data-theme="dark"] .author-info .author-bio {
    color: var(--text-light);
    opacity: 1;
}

.author-info a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}

[data-theme="dark"] .author-info a {
    color: var(--accent-light);
}

.author-info a:hover {
    text-decoration: underline;
}

/* Reading Progress */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--gradient-accent);
    z-index: 1000;
    transition: width 0.3s ease;
}

/* Enhanced Footer */
footer {
    background: var(--gradient-primary);
    color: white;
    text-align: center;
    padding: 3rem 0;
    margin-top: 4rem;
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] footer {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--border-color) 100%);
    color: var(--text-color);
}

footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="dots" width="20" height="20" patternUnits="userSpaceOnUse"><circle cx="10" cy="10" r="1" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23dots)"/></svg>');
    pointer-events: none;
}

[data-theme="dark"] footer::before {
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="dots-dark" width="20" height="20" patternUnits="userSpaceOnUse"><circle cx="10" cy="10" r="1" fill="white" opacity="0.05"/></pattern></defs><rect width="100" height="100" fill="url(%23dots-dark)"/></svg>');
}

footer .container {
    position: relative;
    z-index: 1;
}

footer p {
    color: white;
    margin: 0.5rem 0;
}

footer h1, footer h2, footer h3, footer h4, footer h5, footer h6 {
    color: white;
}

[data-theme="dark"] footer p,
[data-theme="dark"] footer h1,
[data-theme="dark"] footer h2,
[data-theme="dark"] footer h3,
[data-theme="dark"] footer h4,
[data-theme="dark"] footer h5,
[data-theme="dark"] footer h6 {
    color: var(--text-color);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeInUp 0.6s ease-out;
}

/* Loading State */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 1s linear infinite;
}

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

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        padding: 0 15px;
    }
    
    .chapter-content {
        padding: 2rem;
        margin: 1rem;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    header p {
        font-size: 1rem;
    }
    
    /* Mobile navigation */
    .mobile-menu-toggle {
        display: flex;
    }
    
    .nav-menu {
        position: fixed;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-color);
        border-top: 1px solid var(--border-color);
        flex-direction: column;
        padding: 1rem;
        gap: 1rem;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-10px);
        transition: all 0.3s ease;
        z-index: 1000;
        max-height: calc(100vh - 80px);
        overflow-y: auto;
    }
    
    .nav-menu.active {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
    
    /* Mobile dropdown adjustments */
    .nav-dropdown-menu {
        position: static;
        box-shadow: none;
        border: 1px solid var(--border-color);
        transform: none;
        opacity: 1;
        visibility: visible;
        margin-top: 0;
        max-height: 50vh;
    }
    
    .chapters-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .chapter-dropdown-item {
        padding: 1rem;
        border: 1px solid var(--border-color);
    }
    
    .chapter-number {
        min-width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }
    
    .chapter-title {
        font-size: 0.95rem;
    }
    
    nav .container {
        flex-direction: column;
        gap: 1rem;
    }
    
    nav ul {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .chapter-nav {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .chapter-nav-prev,
    .chapter-nav-next {
        text-align: center;
    }
    
    .chapter-content {
        padding: 1.5rem;
        margin: 0.5rem;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.25rem;
        margin-left: 0;
        padding-left: 1rem;
    }
    
    ol, ul {
        padding-left: 1rem;
    }
    
    pre {
        padding: 1rem;
        font-size: 0.8rem;
    }
    
    blockquote {
        margin: 1rem 0;
        padding: 1rem;
    }
    
    table {
        font-size: 0.9rem;
    }
    
    th, td {
        padding: 0.5rem;
    }
    
    /* TOC Sidebar mobile adjustments */
    .toc-sidebar {
        display: none;
    }
    
    .toc-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Enhanced mobile TOC styles */
    .toc-sidebar.mobile-active {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 100vh;
        background: var(--bg-color);
        z-index: 999;
        border-radius: 0;
        border: none;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }
    
    .toc-sidebar.mobile-active .toc-content {
        max-height: calc(100vh - 80px);
        padding: 2rem;
    }
    
    .toc-sidebar.mobile-active .toc-link {
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }
    
    .toc-sidebar.mobile-active .toc-marker {
        min-width: 24px;
        height: 24px;
        font-size: 0.8rem;
    }
    
    .mobile-toc-close {
        position: absolute;
        top: 1rem;
        right: 1rem;
        background: var(--accent-color);
        color: white;
        border: none;
        border-radius: 50%;
        width: 44px;
        height: 44px;
        cursor: pointer;
        font-size: 1.5rem;
        z-index: 1000;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: var(--transition);
    }
    
    .mobile-toc-close:hover {
        background: var(--accent-light);
        transform: rotate(90deg);
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    header {
        padding: 1.5rem 0;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .chapter-content {
        padding: 1rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.2rem;
    }
    
    p {
        font-size: 1rem;
    }
}

/* Desktop layout adjustments for TOC sidebar */
@media (min-width: 769px) {
    .chapter-content {
        margin-right: 360px; /* Make room for the enhanced TOC sidebar */
        padding-right: 2rem;
    }
    
    main .container {
        margin-right: 360px; /* Ensure main content doesn't overlap TOC */
    }
    
    .toc-toggle {
        display: none;
    }
    
    /* Ensure TOC is visible on desktop and always shown */
    .toc-sidebar {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
    }
    
    /* Make sure TOC doesn't conflict with sticky nav */
    nav {
        z-index: 100;
    }
    
    .toc-sidebar {
        z-index: 90; /* Below nav to respect the navigation hierarchy */
    }
}

/* Print Styles */
@media print {
    header, nav, footer, .chapter-nav, .theme-toggle {
        display: none;
    }
    
    body {
        background: white;
        color: black;
        font-size: 12pt;
        line-height: 1.5;
    }
    
    .chapter-content {
        box-shadow: none;
        border: none;
        margin: 0;
        padding: 0;
    }
    
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
        color: black;
    }
    
    pre, blockquote {
        page-break-inside: avoid;
    }
    
    a {
        color: black;
        text-decoration: underline;
    }
    
    a::after {
        display: none;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* Focus states for keyboard navigation */
a:focus, button:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
        --text-color: #000;
        --bg-color: #fff;
    }
    
    [data-theme="dark"] {
        --border-color: #fff;
        --text-color: #fff;
        --bg-color: #000;
    }
}

/* Enhanced Interactive Features */

/* Search Container */
.search-container {
    position: relative;
    margin-left: 1rem;
}

#search-input {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 0.9rem;
    transition: var(--transition);
    width: 200px;
}

[data-theme="dark"] #search-input {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-color);
}

[data-theme="dark"] #search-input::placeholder {
    color: var(--text-light);
}

#search-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.1);
}

[data-theme="dark"] #search-input:focus {
    border-color: var(--accent-light);
    box-shadow: 0 0 0 3px rgba(246, 173, 85, 0.2);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

[data-theme="dark"] .search-results {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

.search-result {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

.search-result:hover {
    background: var(--bg-secondary);
}

[data-theme="dark"] .search-result:hover {
    background: var(--border-color);
}

.search-result:last-child {
    border-bottom: none;
}

.search-result a {
    color: var(--text-color);
    text-decoration: none;
}

[data-theme="dark"] .search-result a {
    color: var(--text-color);
}

.no-results {
    padding: 1rem;
    text-align: center;
    color: var(--text-light);
    font-style: italic;
}

/* Table of Contents Sidebar */
.toc-sidebar {
    position: fixed;
    top: 120px; /* Position below the sticky navigation */
    right: 20px;
    width: 320px;
    max-height: calc(100vh - 160px); /* Adjusted for navigation height */
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 90; /* Below navigation but above content */
    overflow: hidden;
    transition: var(--transition);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 1;
    visibility: visible;
}

.toc-sidebar.collapsed {
    max-height: 60px;
}

.toc-header {
    background: var(--gradient-primary);
    color: white;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

[data-theme="dark"] .toc-header {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-light) 100%);
    color: var(--bg-color);
}

.toc-collapse {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: var(--transition);
}

[data-theme="dark"] .toc-collapse {
    color: var(--bg-color);
}

.toc-collapse:hover {
    background: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .toc-collapse:hover {
    background: rgba(0, 0, 0, 0.2);
}

.toc-content {
    padding: 1rem;
    max-height: calc(100vh - 240px); /* Adjusted for navigation and header spacing */
    overflow-y: auto;
    overflow-x: hidden;
}

.toc-content::-webkit-scrollbar {
    width: 4px;
}

.toc-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

.toc-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

.toc-content ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-content li {
    margin: 0;
    padding: 0;
    position: relative;
}

.toc-link {
    display: flex;
    align-items: flex-start;
    padding: 0.6rem 0.75rem;
    color: var(--text-color);
    text-decoration: none;
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 0.25rem;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] .toc-link {
    color: var(--text-color);
}

.toc-link::after {
    display: none; /* Remove the default link underline effect */
}

.toc-link:hover {
    background: var(--bg-secondary);
    transform: translateX(4px);
    color: var(--primary-color);
}

[data-theme="dark"] .toc-link:hover {
    background: var(--border-color);
    color: var(--text-color);
}

.toc-link.active {
    background: var(--accent-color);
    color: white;
    transform: translateX(4px);
    box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .toc-link.active {
    background: var(--accent-light);
    color: var(--bg-color);
}

.toc-link.active .toc-marker {
    background: white;
    color: var(--accent-color);
}

[data-theme="dark"] .toc-link.active .toc-marker {
    background: var(--bg-color);
    color: var(--accent-light);
}

/* TOC Markers */
.toc-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    flex-shrink: 0;
    text-align: center;
    transition: var(--transition);
}

.toc-marker-h1 {
    background: var(--primary-color);
    color: white;
    font-size: 0.75rem;
}

[data-theme="dark"] .toc-marker-h1 {
    background: var(--accent-light);
    color: var(--bg-color);
    font-weight: bold;
}

.toc-marker-h2 {
    background: var(--secondary-color);
    color: white;
    font-size: 0.7rem;
}

[data-theme="dark"] .toc-marker-h2 {
    background: var(--accent-color);
    color: var(--bg-color);
    font-weight: bold;
}

.toc-marker-h3 {
    background: var(--accent-color);
    color: white;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    font-size: 0.6rem;
}

[data-theme="dark"] .toc-marker-h3 {
    background: var(--text-color);
    color: var(--bg-color);
}

.toc-marker-h4 {
    background: var(--text-light);
    color: white;
    width: 10px;
    height: 2px;
    border-radius: 1px;
    font-size: 0.5rem;
}

[data-theme="dark"] .toc-marker-h4 {
    background: var(--text-color);
    color: var(--bg-color);
}

.toc-text {
    flex: 1;
    word-break: break-word;
    line-height: 1.3;
}

/* Level-specific styles */
.toc-level-1 .toc-link {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.toc-level-2 .toc-link {
    font-weight: 500;
    font-size: 0.85rem;
}

.toc-level-3 .toc-link {
    font-size: 0.8rem;
    opacity: 0.9;
}

.toc-level-4 .toc-link,
.toc-level-5 .toc-link,
.toc-level-6 .toc-link {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Initialize counter */
.toc-content {
    counter-reset: h2-counter;
}

/* Toggle button for mobile */
.toc-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--gradient-accent);
    color: white;
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
    font-size: 1.4rem;
    z-index: 101;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.toc-toggle:hover {
    background: var(--accent-light);
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(233, 69, 96, 0.4);
}

.toc-toggle::before {
    content: '📑';
}

.toc-toggle:active {
    transform: scale(0.95);
}

/* Copy Code Button */
.copy-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition);
    opacity: 0.7;
    color: var(--text-color);
}

[data-theme="dark"] .copy-button {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-color);
}

.copy-button:hover {
    opacity: 1;
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Social Links */
.social-links {
    margin-top: 1rem;
}

.social-links a {
    display: inline-block;
    margin: 0 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    text-decoration: none;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

[data-theme="dark"] .social-links a {
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-color);
}

.social-links a:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    color: var(--text-color);
}

[data-theme="dark"] .social-links a:hover {
    background: rgba(0, 0, 0, 0.4);
    color: var(--text-color);
}

/* Keyboard Navigation Hints */
.keyboard-hints {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    font-size: 0.8rem;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 100;
}

.keyboard-hints.visible {
    opacity: 1;
    visibility: visible;
}

.keyboard-hints h5 {
    margin: 0 0 0.5rem;
    font-size: 0.9rem;
}

.keyboard-hints ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.keyboard-hints li {
    margin: 0.25rem 0;
    padding: 0;
}

.kbd {
    background: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 0.1rem 0.3rem;
    font-family: monospace;
    font-size: 0.8rem;
}

/* Enhanced mobile responsiveness for new features */
@media (max-width: 768px) {
    .search-container {
        margin: 0.5rem 0;
    }
    
    #search-input {
        width: 100%;
    }
    
    .floating-toc {
        position: fixed;
        bottom: 20px;
        right: 20px;
        top: auto;
        transform: none;
    }
    
    .toc-content {
        position: fixed;
        bottom: 80px;
        right: 20px;
        left: 20px;
        max-width: none;
    }
    
    .social-links {
        text-align: center;
    }
    
    .social-links a {
        display: block;
        margin: 0.5rem 0;
    }
}

@media (max-width: 480px) {
    .floating-toc {
        right: 10px;
        bottom: 10px;
    }
    
    .toc-toggle {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .keyboard-hints {
        left: 10px;
        right: 10px;
        bottom: 10px;
    }
}
