:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-sidebar: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --accent-color: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.2);
    --border-color: #e5e7eb;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.3);
    --sidebar-width: 280px;
    --header-height: 64px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

body.dark-mode {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-sidebar: rgba(15, 23, 42, 0.95);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #818cf8;
    --accent-glow: rgba(129, 140, 248, 0.3);
    --border-color: #334155;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

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

p, li {
  margin-bottom: 0.5rem;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
}

h1, h2, h3, h4 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    margin-top: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* Sidebar Styling */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    padding: 1rem 0.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease;
}

.sidebar-header {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
}

.logo i {
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.nav-links {
    list-style: none;
}

.pdf-link-container {
    padding: 0.75rem 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 4px;
}

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

.sidebar-footer {
    flex-shrink: 0;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.nav-links li {
    margin-bottom: 0.5rem;
}

.nav-item-with-lang {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-item-with-lang > a:first-child {
    flex: 1;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: 12px;
    transition: all 0.2s ease;
    font-weight: 500;
}

.nav-links a:hover, .nav-links a.active {
    background: var(--accent-glow);
    color: var(--accent-color);
}

.submenu {
    list-style: none;
    padding-left: 0.75rem;
    margin-top: 0.25rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.submenu.open {
    max-height: 100000px;
}

.submenu li {
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.submenu li > a:first-child {
    flex: 1;
}

.submenu a {
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
}

.lang-tag {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.lang-alt {
    font-size: 0.75rem;
    padding: 0.4rem 1rem !important;
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
    line-height: 1;
    display: inline !important;
    border: none;
    width: auto;
    gap: 0;
    flex: none !important;
}

.lang-alt:hover {
    background: var(--accent-glow);
    color: var(--accent-color);
}

.toggle-icon {
    margin-left: auto;
    font-size: 0.8rem;
    transition: transform 0.3s;
}

.has-submenu.open .toggle-icon {
    transform: rotate(180deg);
}

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.theme-btn {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    background: transparent;
    border-radius: 12px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.theme-btn:hover {
    background: var(--bg-secondary);
}

/* Audio Buttons */
.audio-list {
    list-style: none;
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pdf-link-container {
    padding: 0.75rem 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.pdf-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 1rem;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.pdf-link i {
    color: #ef4444;
    font-size: 1.1rem;
}

.pdf-link:hover {
    background: var(--accent-glow);
}

.pdf-link .external-icon {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.audio-button {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.audio-button i {
    width: 1.25rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--accent-color);
    transition: color 0.2s;
}

.audio-button:hover {
    background: var(--accent-glow);
    border-color: var(--accent-color);
}

.audio-button:hover i {
    color: var(--accent-color);
}

.audio-button:active {
    transform: scale(0.97);
}

/* Main Content Area */
.content-wrapper {
    margin-left: var(--sidebar-width);
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-bar {
    height: var(--header-height);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 900;
}

.breadcrumb {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.github-link {
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background: var(--bg-secondary);
    transition: background 0.2s;
}

.github-link:hover {
    background: var(--border-color);
}

.markdown-body {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 2rem;
    flex-grow: 1;
}

.main-footer {
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.creator-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.creator-link:hover {
    background: var(--accent-glow);
    border-color: var(--accent-color);
}

/* Markdown Specifics */
.markdown-body h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--accent-color), #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 2rem;
}

.markdown-body h2 {
    font-size: 1.75rem;
    margin-top: 3rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.markdown-body blockquote {
    background: var(--bg-secondary);
    border-left: 4px solid var(--accent-color);
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0 12px 12px 0;
    font-style: italic;
}

.markdown-body a {
    color: #94a3b8; /* Slate 400 - bluish gray */
    text-decoration: underline;
    text-underline-offset: 4px;
    transition: color 0.2s;
}

.markdown-body a:hover {
    color: var(--accent-color);
}

.markdown-body code:not(pre code) {
    background: var(--bg-secondary);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9em;
    color: var(--accent-color);
}

.markdown-body h1 code,
.markdown-body h2 code,
.markdown-body h3 code,
.markdown-body h4 code {
    background: transparent;
    color: inherit;
    padding: 0;
    font-size: inherit;
    -webkit-text-fill-color: currentcolor;
    font-weight: inherit;
}

.markdown-body pre {
    margin: 1.5rem 0;
    border-radius: 12px;
    overflow: hidden;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
}

.markdown-body th, .markdown-body td {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    text-align: left;
}

.markdown-body th {
    background: var(--bg-secondary);
}

/* Mermaid Wrapper */
.mermaid-container {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: 16px;
    margin: 2rem 0;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: center;
    overflow-x: auto;
}

.mermaid-container .mermaid svg {
    max-width: 100% !important;
    height: auto !important;
}

/* Mobile Adjustments */
.mobile-menu, .mobile-close {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .content-wrapper {
        margin-left: 0;
    }
    .mobile-menu {
        display: block;
    }
    .mobile-close {
        display: block;
    }
}

/* Loader */
.loader-container {
    position: fixed;
    top: var(--header-height);
    left: var(--sidebar-width);
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    display: none;
}

.loader-container.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-secondary);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.modal-hidden {
    display: none !important;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9000;
}

.modal-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9001;
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 8px 48px var(--shadow);
    width: 440px;
    max-width: 96vw;
    max-height: 96vh;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
}

.modal-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-dialog-header h3 {
    margin: 0;
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 22px;
    color: var(--text-secondary);
    line-height: 1;
    padding: 0 4px;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-dialog form {
    padding: 20px;
    overflow-y: auto;
}

.modal-field {
    margin-bottom: 14px;
}

.modal-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.modal-field input,
.modal-field textarea {
    width: 100%;
    box-sizing: border-box;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    outline: none;
}

.modal-field input:focus,
.modal-field textarea:focus {
    border-color: var(--accent-color);
}

.modal-field textarea {
    resize: vertical;
    min-height: 90px;
}

.modal-submit {
    background: var(--accent-color);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
}

.modal-submit:hover {
    filter: brightness(1.1);
}

.modal-submit:disabled {
    opacity: 0.5;
    cursor: default;
}

[data-fs-success] {
    display: none;
    padding: 40px 20px;
    text-align: center;
}

.fs-success-title {
    color: #49cc90;
    font-weight: 700;
    font-size: 15px;
    margin: 0 0 4px;
    font-family: 'Outfit', sans-serif;
}

.fs-success-msg {
    color: var(--text-secondary);
    font-size: 13px;
    margin: 0;
}

[data-fs-error] {
    display: none;
    padding: 8px 20px 0;
    color: #f48771;
    font-size: 12px;
}

.fs-error-msg {
    color: #f48771;
    font-size: 11px;
}

.github-link {
    cursor: pointer;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: inherit;
}
