:root {
    --bg: #f0f0f0;
    --fg: #1a1a1a;
    --border: #e0e0e0;
    --accent: #000000;
    --secondary: #666666;
    --date-bg: #ffffff;
    --subtitle: #605c39;
    
    /* Code colors - LIGHT THEME */
    --code-bg: #f5f5f5;
    --code-fg: #1a1a1a;
    --code-block-bg: #f8f9fa;
    --code-block-fg: #000000;
    --code-block-border: #000000;
    --code-line-number: #181a15;
    --code-scrollbar-track: #e2e8f0;
    --code-scrollbar-thumb: #e0decb;
    --code-scrollbar-thumb-hover: #c0b3a0;
    --code-header-bg: #cfd3c3;
    --code-color: #020202;
    --code-hover: #e4e1cf;
}

[data-theme="dark"] {
    --bg: #1a1a1a;
    --fg: #e8e8e8;
    --border: #333333;
    --accent: #ffffff;
    --secondary: #a0a0a0;
    --date-bg: #000000;
    --subtitle: #b5c199;
    
    /* Code colors - DARK THEME */
    --code-bg: #2a2a2a;
    --code-fg: #e8e8e8;
    --code-block-bg: #1e1e1e;
    --code-block-fg: #d4d4d4;
    --code-block-border: #000000;
    --code-line-number: #97ff00;
    --code-scrollbar-track: #2a2a2a;
    --code-scrollbar-thumb: #464646;
    --code-scrollbar-thumb-hover: #5a5a5a;
    --code-header-bg: rgba(0, 0, 0, 0.2);
    --code-color: #f8f9fa;
    --code-hover: #292420;
}

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

body {
    font-family: 'Noto Serif', 'Iowan Old Style', 'Palatino Linotype', serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.7;
    transition: background 0.3s, color 0.3s;
}

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

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

/* Navigation links */
nav a {
    color: var(--fg);
}

nav a:hover {
    color: var(--secondary);
}

/* Footer links */
footer a {
    color: var(--secondary);
}

footer a:hover {
    color: var(--fg);
}

/* Content links */
.content a {
    color: var(--fg);
}

.content a:hover {
    color: var(--secondary);
}

/* Read more link */
.read-more {
    display: inline-block;
    margin-top: 12px;
    font-size: 14px;
    color: var(--secondary);
    text-align: right;
    float: right;
}

.read-more:hover {
    color: var(--fg);
}

.read-more::after {
    content: ' →';
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 24px;
}

header {
    border-bottom: 1px solid var(--border);
    padding: 48px 0 24px;
    margin-bottom: 64px;
}

nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

nav ul {
    display: flex;
    justify-content: center;
    gap: 48px;
    list-style: none;
}

nav li {
    display: flex;
    flex-direction: column;
    align-items: center;
}

nav a {
    font-family: 'Manjari', sans-serif;
    color: var(--fg);
    text-decoration: none;
    font-size: 20px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    transition: color 0.2s;
}

nav a:hover {
    color: var(--secondary);
}

.nav-dots {
    display: flex;
    gap: 4px;
    height: 6px;
    opacity: 0;
    visibility: hidden;
}

nav li:has(a.active) .nav-dots {
    opacity: 1;
    visibility: visible;
}

.dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.2;
}

nav li:has(a.active) .dot:nth-child(1) {
    animation: pulse 1.5s ease-in-out infinite;
}

nav li:has(a.active) .dot:nth-child(2) {
    animation: pulse 1.5s ease-in-out infinite 0.5s;
}

nav li:has(a.active) .dot:nth-child(3) {
    animation: pulse 1.5s ease-in-out infinite 1s;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.2;
    }
    50% {
        opacity: 1;
    }
}

.theme-toggle {
    position: fixed;
    top: 24px;
    right: 24px;
    width: 30px;
    height: 30px;
    overflow: hidden;
    cursor: pointer;
    z-index: 100;
}

.theme-icon {
    width: 30px;
    height: 60px;
    display: block;
    transition: transform 0.4s ease;
    transform: translateY(-30px);
}

[data-theme="dark"] .theme-icon {
    transform: translateY(0);
}

.header-logo {
    height: 209px;
    margin-bottom: 24px;
    background: url('../images/hla.png') center center no-repeat;
    background-size: contain;
}

[data-theme="dark"] .header-logo {
    background-image: url('../images/hlb.png');
}

article {
    position: relative;
    margin-bottom: 96px;
    margin-top: 40px;
}

article .subtitle {
    font-family: 'Noto Serif', serif;
    font-size: 18px;
    font-weight: 300;
    color: var(--subtitle);
    margin-top: -12px;
    margin-bottom: 24px;
    line-height: 1.4;
    font-style: italic;
}

article h1 {
    font-family: 'Noto Serif', serif;
    font-size: 42px;
    font-weight: 300;
    margin-bottom: 20px;
    line-height: 1.2;
}

article .meta {
    color: var(--secondary);
    font-size: 14px;
    margin-bottom: 48px;
    letter-spacing: 0.02em;
}

article h2,
.content h2 {
    font-family: 'Noto Serif', serif;
    font-size: 28px;
    font-weight: 300;
    margin: 48px 0 24px;
}

.content h3 {
    font-family: 'Noto Serif', serif;
    font-size: 22px;
    font-weight: 300;
    margin: 36px 0 18px;
}

article p {
    margin-bottom: 24px;
    font-size: 18px;
}

article .katex-display {
    margin: 32px 0;
}

article .katex {
    font-size: 1.1em;
}

.excerpt {
    color: var(--fg);
    font-size: 16px;
    margin-top: 12px;
    line-height: 1.6;
}

.excerpt p {
    margin-bottom: 12px;
}

.excerpt p:last-child {
    margin-bottom: 0;
}

.date-box {
    position: absolute;
    left: -86px;
    top: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 6px;
    background: var(--date-bg);
    border: 1px solid var(--border);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    width: 62px;
}

.date-top {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
    white-space: nowrap;
}

.date-year {
    font-size: 10px;
    color: var(--secondary);
    letter-spacing: 0.05em;
}

.content img {
    max-width: 100%;
    height: auto;
}

.content img[style*="float"] {
    margin-bottom: 10px;
}

.content div:has(img) + * {
    clear: both;
}

/* Inline code */
.content code {
    font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Monaco, 'Cascadia Code', monospace;
    background: var(--code-bg);
    color: var(--code-fg);
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.88em;
    font-weight: 500;
}

/* Code blocks */
.content pre {
    position: relative;
    background: var(--code-block-bg);
    border: 1px solid var(--code-block-border);
    padding: 0;
    margin: 32px 0;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .content pre {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.content pre code {
    display: block;
    background: transparent;
    padding: 20px;
    border-radius: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--code-block-fg);
    font-weight: 400;
    overflow-x: auto;
}

/* Code header with language badge and copy button */
.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--code-header-bg);
    border-bottom: 1px solid var(--code-block-border);
}

.code-language {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--code-line-number);
    font-weight: 600;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

.code-copy {
    background: transparent;
    border: 1px solid var(--code-block-border);
    color: var(--code-color);
    padding: 4px 12px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

.code-copy:hover {
    background: var(--code-hover);
    border-color: var(--code-block-fg);
}

.code-copy:active {
    transform: scale(0.95);
}

/* Scrollbar styling */
.content pre code::-webkit-scrollbar {
    height: 8px;
}

.content pre code::-webkit-scrollbar-track {
    background: var(--code-scrollbar-track);
    border-radius: 4px;
}

.content pre code::-webkit-scrollbar-thumb {
    background: var(--code-scrollbar-thumb);
    border-radius: 4px;
}

.content pre code::-webkit-scrollbar-thumb:hover {
    background: var(--code-scrollbar-thumb-hover);
}

blockquote {
    border-left: 2px solid var(--accent);
    padding-left: 24px;
    margin: 32px 0;
    color: var(--secondary);
    font-style: italic;
}

footer {
    border-top: 1px solid var(--border);
    padding: 48px 0;
    text-align: center;
    color: var(--secondary);
    font-size: 14px;
}

@media (max-width: 768px) {
    header {
        padding: 32px 0 16px;
        margin-bottom: 48px;
    }

    nav ul {
        gap: 24px;
        flex-wrap: wrap;
    }

    article h1 {
        font-size: 32px;
    }

    article h2 {
        font-size: 24px;
    }

    article p {
        font-size: 17px;
    }
    
    .code-header {
        padding: 6px 12px;
    }
    
    .content pre code {
        padding: 16px 12px;
        font-size: 13px;
    }
}

article h1 a {
    color: inherit;
    text-decoration: none;
}

article h1 a:hover {
    color: var(--secondary);
}

.meta .tags {
    margin-left: 16px;
}

.meta .tags a {
    color: var(--secondary);
    text-decoration: none;
    font-size: 12px;
    margin-right: 8px;
}

.meta .tags a:hover {
    color: var(--fg);
}

.meta .tags a::before {
    content: '#';
}

.content h2 {
    font-size: 28px;
    font-weight: 400;
    margin: 48px 0 24px;
}

.content h3 {
    font-size: 22px;
    font-weight: 400;
    margin: 36px 0 18px;
}

.content p {
    margin-bottom: 24px;
    font-size: 18px;
}

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

.content li {
    margin-bottom: 8px;
}

/* Tables */
.content table {
    width: 100%;
    border-collapse: collapse;
    margin: 32px 0;
    font-size: 16px;
}

.content th,
.content td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.content th {
    font-weight: 600;
    border-bottom: 2px solid var(--fg);
}

.content tr:hover {
    background: rgba(128, 128, 128, 0.05);
}

@media (max-width: 1100px) {
    .date-box {
        position: static;
        margin-bottom: 16px;
    }
}

/* Image Gallery */
.image-gallery {
    display: grid;
    gap: 12px;
    margin: 32px 0;
}

.image-gallery.gallery-2x1 {
    grid-template-columns: repeat(2, 1fr);
}

.image-gallery.gallery-3x1 {
    grid-template-columns: repeat(3, 1fr);
}

.image-gallery.gallery-2x2 {
    grid-template-columns: repeat(2, 1fr);
}

.image-gallery.gallery-2x3 {
    grid-template-columns: repeat(2, 1fr);
}

.image-gallery.gallery-3x3 {
    grid-template-columns: repeat(3, 1fr);
}

.image-gallery img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-gallery figure {
    margin: 0;
    display: flex;
    flex-direction: column;
}

.image-gallery figcaption {
    font-size: 13px;
    color: var(--secondary);
    padding: 8px 4px;
    text-align: center;
    font-style: italic;
}

.gallery-caption {
    text-align: center;
    font-size: 14px;
    color: var(--secondary);
    margin-top: 12px;
    font-style: italic;
}

@media (max-width: 768px) {
    .image-gallery {
        grid-template-columns: 1fr !important;
    }
}

/* Image zoom functionality */
.content img {
    cursor: zoom-in;
}

.content img.zoomed {
    position: fixed;
    cursor: zoom-out;
    z-index: 1000;
    border: 5px solid var(--code-block-border);
    border-radius: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0 !important;
}

body.image-zoomed {
    overflow: hidden;
}

/* Text Cards */
.text-cards {
    display: grid;
    gap: 20px;
    margin: 32px 0;
}

.text-cards.cards-2x1 {
    grid-template-columns: repeat(2, 1fr);
}

.text-cards.cards-2x2 {
    grid-template-columns: repeat(2, 1fr);
}

.text-cards.cards-3x1 {
    grid-template-columns: repeat(3, 1fr);
}

.text-cards.cards-3x2 {
    grid-template-columns: repeat(3, 1fr);
}

.text-card {
    border: 1px solid var(--border);
    padding: 24px;
    background: var(--bg);
    transition: border-color 0.2s;
}

.text-card:hover {
    border-color: var(--fg);
}

.text-card h3 {
    font-size: 18px;
    font-weight: 400;
    margin: 0 0 12px 0;
}

.text-card p {
    font-size: 15px;
    margin: 0;
    line-height: 1.6;
}

@media (max-width: 768px) {
    .text-cards {
        grid-template-columns: 1fr !important;
    }
}