:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --accent-color: #3b82f6;
    --text-color: #1f2937;
    --light-text: #6b7280;
    --background-color: #ffffff;
    --light-background: #f9fafb;
    --border-color: #e5e7eb;
    --code-background: #f3f4f6;
    --header-height: 70px;
    --toc-width: 260px;
    --max-content-width: 800px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    padding-top: 0;
}

header {
    position: relative;
    /* /* top: 0; */ */
    left: 0;
    right: 0;
    height: var(--header-height);
    background-color: var(--background-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 1000;
    transition: box-shadow 0.3s ease;
}

header.shadow {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.logo:hover {
    opacity: 0.8;
    text-decoration: none;
}

nav ul {
    display: flex;
    list-style: none;
}

nav li {
    margin-left: 1.5rem;
}

nav a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
    position: relative;
    padding-bottom: 3px;
}

nav a:hover {
    color: var(--primary-color);
    text-decoration: none;
}

nav a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: var(--primary-color);
    transition: width 0.2s ease;
}

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

.container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.toc {
    width: var(--toc-width);
    position: sticky;
    top: 2rem;
    height: calc(100vh - 4rem);
    overflow-y: auto;
    padding-right: 1.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

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

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

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

.toc-list {
    list-style: none;
    border-left: 2px solid var(--border-color);
}

.toc-item {
    margin: 0.75rem 0;
    padding-left: 1rem;
    line-height: 1.3;
    transition: all 0.2s ease;
}

.toc-item.active {
    border-left: 2px solid var(--primary-color);
    margin-left: -2px;
    font-weight: 600;
}

.toc-link {
    color: var(--light-text);
    text-decoration: none;
    font-size: 0.95rem;
    display: block;
    transition: color 0.2s ease;
}

.toc-link:hover {
    color: var(--primary-color);
    text-decoration: none;
}

.toc-item.active .toc-link {
    color: var(--primary-color);
}

.toc-h2 {
    font-weight: 600;
    margin-top: 1rem;
}

.toc-h3 {
    padding-left: 1rem;
    font-size: 0.9rem;
}

.content {
    width: calc(100% - var(--toc-width));
    max-width: var(--max-content-width);
    padding-left: 2rem;
}

.progress-container {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--light-background);
    z-index: 1000;
}

.progress-bar {
    height: 4px;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.1s ease;
}

.article-meta {
    margin-bottom: 2rem;
    color: var(--light-text);
    font-size: 0.95rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.article-meta span {
    display: flex;
    align-items: center;
}

.article-meta svg {
    margin-right: 0.5rem;
}

.article-meta .author {
    font-weight: 500;
}

h1 {
    font-size: 2.5rem;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

h2 {
    font-size: 1.75rem;
    margin-top: 3rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    scroll-margin-top: calc(var(--header-height) + 1rem);
}

h3 {
    font-size: 1.35rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    scroll-margin-top: calc(var(--header-height) + 1rem);
}

p {
    margin-bottom: 1.25rem;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: text-decoration 0.2s ease;
}

a:hover {
    text-decoration: underline;
}

ul, ol {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

li {
    margin-bottom: 0.5rem;
}

code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    background-color: var(--code-background);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-size: 0.9em;
}

pre {
    background-color: var(--code-background);
    padding: 1rem;
    border-radius: 5px;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

pre code {
    background-color: transparent;
    padding: 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

blockquote {
    border-left: 4px solid var(--accent-color);
    padding-left: 1rem;
    margin-left: 0;
    margin-bottom: 1.5rem;
    color: var(--light-text);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    border-radius: 5px;
    overflow: hidden;
}

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

table th {
    background-color: var(--light-background);
    font-weight: 600;
}

table tr:nth-child(even) {
    background-color: var(--light-background);
}

.note {
    background-color: rgba(59, 130, 246, 0.1);
    border-left: 4px solid var(--accent-color);
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 0 5px 5px 0;
}

.note-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
}

.note-title svg {
    margin-right: 0.5rem;
}

.related-posts {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.related-posts h3 {
    margin-bottom: 1.5rem;
}

.related-posts-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.related-post {
    background-color: var(--light-background);
    border-radius: 5px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.related-post:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.related-post a {
    text-decoration: none;
}

.related-post-title {
    padding: 1rem;
    font-weight: 600;
    color: var(--text-color);
}

.copy-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background-color: var(--light-background);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.code-container {
    position: relative;
}

.code-container:hover .copy-button {
    opacity: 1;
}

.copy-button:hover {
    background-color: var(--border-color);
}

.copy-feedback {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background-color: var(--primary-color);
    color: white;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

footer {
    background-color: var(--light-background);
    padding: 2rem 0;
    margin-top: 4rem;
    border-top: 1px solid var(--border-color);
}

.footer-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-links {
    display: flex;
    list-style: none;
}

.footer-links li {
    margin-left: 1.5rem;
}

.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--primary-color);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
}

.back-to-top:hover {
    background-color: var(--secondary-color);
}

/* Dark mode support for future implementation */
@media (prefers-color-scheme: dark) {
    :root {
        /* Dark mode variables can be added here later */
    }
}

/* Media queries */
@media (max-width: 1024px) {
    .container {
        flex-direction: column;
    }
    
    .toc {
        width: 100%;
        position: relative;
        top: 0;
        height: auto;
        margin-bottom: 2rem;
        padding-right: 0;
    }
    
    .toc-list {
        border-left: none;
        display: flex;
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .toc-item {
        padding-left: 0;
        margin: 0;
        border-left: none;
    }
    
    .toc-item.active {
        margin-left: 0;
        border-left: none;
        border-bottom: 2px solid var(--primary-color);
    }
    
    .toc-h3 {
        padding-left: 0;
    }
    
    .content {
        width: 100%;
        padding-left: 0;
    }
}

@media (max-width: 768px) {
    header {
        padding: 0 1rem;
    }
    
    .container {
        padding: 1.5rem 1rem;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .footer-container {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .footer-links {
        flex-direction: column;
        align-items: center;
    }
    
    .footer-links li {
        margin: 0.5rem 0;
    }
    
    .back-to-top {
        bottom: 1rem;
        right: 1rem;
    }
}

/* Print styles */
@media print {
    .toc, .progress-container, .back-to-top, header, footer {
        display: none;
    }
    
    body {
        padding-top: 0;
    }
    
    .container {
        display: block;
    }
    
    .content {
        width: 100%;
        max-width: 100%;
        padding: 0;
    }
    
    h2, h3 {
        page-break-after: avoid;
    }
    
    pre, blockquote, table {
        page-break-inside: avoid;
    }
}