:root {
    --bg-color: #1a1a1a;
    --text-color: #e0e0e0;
    --link-color: #4da6ff;
    --border-color: #333;
    --hover-bg: #2a2a2a;
    --code-bg: #111;
}

:root.light-mode {
    --bg-color: #ffffff;
    --text-color: #1a1a1a;
    --link-color: #0066cc;
    --border-color: #e0e0e0;
    --hover-bg: #f5f5f5;
    --code-bg: #f5f5f5;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    max-width: 1240px;
    margin: 0 auto;
    padding: 20px;
}

.app-shell {
    display: flex;
    align-items: flex-start;
    gap: 24px;
}

.left-rail {
    width: 25%;
    min-width: 250px;
    max-width: 320px;
    position: sticky;
    top: 20px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    background: linear-gradient(180deg, rgba(77, 166, 255, 0.06) 0%, rgba(77, 166, 255, 0.02) 100%);
}

.main-panel {
    width: 75%;
    min-width: 0;
}

.page-header {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
    padding-bottom: 12px;
}

.page-header-slim {
    margin-bottom: 10px;
}

.rail-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    margin-bottom: 14px;
}

.rail-brand span {
    font-size: 1.5rem;
    line-height: 1.1;
}

.rail-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.rail-nav a {
    display: inline-block;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.85rem;
    text-decoration: none;
}

.rail-nav a:hover,
.rail-nav a:focus-visible {
    background-color: var(--hover-bg);
    text-decoration: none;
}

.rail-nav a.active {
    border-color: var(--link-color);
    background-color: rgba(77, 166, 255, 0.18);
}

.rail-widget {
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}

.rail-section-title {
    font-size: 0.95rem;
    margin: 0 0 10px 0;
}

.rail-hat-tip {
    font-size: 0.82rem;
    color: #999;
    margin: 12px 0 0;
}

.heatmap-widget {
    overflow-x: auto;
}

.heatmap-months,
.heatmap-row {
    display: grid;
    grid-template-columns: 36px repeat(12, 13px);
    gap: 4px;
    align-items: center;
    min-width: 220px;
}

.heatmap-months {
    margin-bottom: 6px;
}

.heatmap-month-label {
    font-size: 0.65rem;
    color: #9aa3ad;
    text-align: center;
}

.heatmap-year-label {
    font-size: 0.7rem;
    color: #9aa3ad;
}

.heatmap-cell {
    width: 13px;
    height: 13px;
    border-radius: 3px;
    border: 1px solid var(--border-color);
}

.heatmap-level-0 { background-color: #1f2937; }
.heatmap-level-1 { background-color: #1f4d2d; }
.heatmap-level-2 { background-color: #1f7a3f; }
.heatmap-level-3 { background-color: #2ea44f; }
.heatmap-level-4 { background-color: #56d364; }

:root.light-mode .heatmap-level-0 { background-color: #ebedf0; }
:root.light-mode .heatmap-level-1 { background-color: #9be9a8; }
:root.light-mode .heatmap-level-2 { background-color: #40c463; }
:root.light-mode .heatmap-level-3 { background-color: #30a14e; }
:root.light-mode .heatmap-level-4 { background-color: #216e39; }

.heatmap-empty {
    margin: 0;
    color: #9aa3ad;
    font-size: 0.82rem;
}

.heatmap-legend {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 5px;
    font-size: 0.72rem;
    color: #9aa3ad;
}

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

nav {
    display: flex;
    gap: 20px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 15px;
}

.site-logo {
    height: 50px;
    width: auto;
}

h1, h2, h3 {
    margin-top: 0;
}

a {
    color: var(--link-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.search-container {
    margin-bottom: 30px;
}

#searchInput {
    width: 100%;
    padding: 10px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 16px;
    border-radius: 4px;
}

.post-list {
    list-style: none;
    padding: 0;
}

.post-item {
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
}

.post-date {
    color: #888;
    margin-left: 10px;
    font-size: 0.9em;
}

.pagination {
    margin-top: 30px;
    display: flex;
    justify-content: space-between;
}

.nav-btn {
    padding: 8px 16px;
    background: var(--border-color);
    color: var(--text-color);
    border: none;
    cursor: pointer;
    border-radius: 4px;
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Markdown Content Styles */
.markdown-body {
    padding-top: 20px;
}

.markdown-body pre {
    background-color: var(--code-bg);
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
}

.markdown-body blockquote {
    border-left: 4px solid var(--border-color);
    margin: 0;
    padding-left: 15px;
    color: #aaa;
}

.back-link {
    display: inline-block;
    margin-bottom: 20px;
}

.post-nav {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
}

/* Tags & Filters */
.tag-and-surprise-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.tag-filter-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1;
}

.tag-filter-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color);
    cursor: pointer;
    border-radius: 15px;
    font-size: 0.9em;
    transition: all 0.2s ease;
}

.tag-filter-btn:hover {
    background-color: var(--hover-bg);
    filter: brightness(1.2);
}

.tag-filter-btn.tag-reflection {
    color: #27ae60;
    border-color: #27ae60;
}

.tag-filter-btn.tag-reflection.active {
    background-color: #27ae60;
    color: #fff;
    border: 1px solid #27ae60;
}

.surprise-btn {
    padding: 8px 16px;
    border: 1px solid var(--link-color);
    background-color: var(--bg-color);
    color: var(--link-color);
    cursor: pointer;
    border-radius: 15px;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.surprise-btn:hover {
    background-color: var(--link-color);
    color: var(--bg-color);
    transform: scale(1.05);
}

.post-tag {
    font-size: 0.85em;
    margin-left: 8px;
    font-weight: bold;
}

.post-meta {
    margin-top: -15px;
    margin-bottom: 30px;
    color: #888;
    font-size: 0.9em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.post-meta .post-tag {
    margin-left: 0;
    margin-right: 10px;
}

/* Tag color styles */
.post-tag.tag-reflection {
    color: #27ae60;
}

/* Navigation link styles */
.post-nav a {
    display: none;
}

.post-nav a.visible {
    display: inline-block;
}

/* Footer styles */
.site-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: #888;
    font-size: 0.8rem;
}

/* Theme Toggle */
.theme-toggle-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    padding: 15px 0;
}

.theme-toggle-label {
    font-size: 0.9rem;
    color: var(--text-color);
}

.theme-toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.theme-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: 0.3s;
    border-radius: 24px;
}

.theme-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-color);
    transition: 0.3s;
    border-radius: 50%;
}

.theme-toggle-switch input:checked + .theme-toggle-slider {
    background-color: var(--link-color);
}

.theme-toggle-switch input:checked + .theme-toggle-slider:before {
    transform: translateX(26px);
}

.theme-toggle-slider:hover {
    background-color: var(--hover-bg);
    filter: brightness(1.3);
}

.theme-toggle-switch input:checked + .theme-toggle-slider:hover {
    background-color: var(--link-color);
    filter: brightness(1.2);
}

.theme-toggle-switch input:focus-visible + .theme-toggle-slider {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

/* Table Styles */
.projects-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 20px 10px;
    margin: 20px 0;
}

.projects-table th,
.projects-table td {
    text-align: left;
    padding: 12px;
}

.projects-table th {
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

.projects-table td {
    border-bottom: 1px solid var(--border-color);
}

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

@media (max-width: 940px) {
    body {
        padding: 14px;
    }

    .app-shell {
        flex-direction: column;
        gap: 18px;
    }

    .left-rail {
        width: 100%;
        min-width: 0;
        max-width: none;
        position: static;
    }

    .main-panel {
        width: 100%;
    }
}
