:root,
html[data-theme="dark"] {
    --bg-base: #141517;
    --bg-sidebar: #181a1d;
    --bg-surface: #1e2024;
    --bg-surface-hover: #25282e;
    --bg-input: #121315;
    --border-subtle: rgba(255, 255, 255, 0.09);
    --border-hover: rgba(255, 255, 255, 0.22);
    --text-primary: #f1f3f5;
    --text-secondary: #adb5bd;
    --text-muted: #868e96;
    --accent-color: #38bdf8;
    --accent-hover: #7dd3fc;
    --code-bg: #0f1114;
    --glass-bg: rgba(28, 30, 35, 0.96);
    color-scheme: dark;
}

html[data-theme="light"] {
    --bg-base: #fafafa;
    --bg-sidebar: #f2f3f5;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f8f9fa;
    --bg-input: #ffffff;
    --border-subtle: rgba(0, 0, 0, 0.09);
    --border-hover: rgba(0, 0, 0, 0.22);
    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-muted: #71717a;
    --accent-color: #0284c7;
    --accent-hover: #0369a1;
    --code-bg: #f4f4f5;
    --glass-bg: rgba(255, 255, 255, 0.96);
    color-scheme: light;
}

html[data-theme="dark"] .theme-icon-dark { display: none; }
html[data-theme="dark"] .theme-icon-light { display: inline-block; }
html[data-theme="light"] .theme-icon-dark { display: inline-block; }
html[data-theme="light"] .theme-icon-light { display: none; }

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent-color);
    transition: color 0.15s ease;
}

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

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.border-subtle {
    border-color: var(--border-subtle) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

/* ==========================================
   Layout: Persistent Left Sidebar + Reading Area
   ========================================== */
.blog-shell {
    display: flex;
    min-height: 100vh;
}

.blog-sidebar {
    width: 270px;
    flex-shrink: 0;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    padding: 2.25rem 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary) !important;
    letter-spacing: -0.025em;
}

.sidebar-bio {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.sidebar-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.45rem 0.65rem;
    border-radius: 8px;
    color: var(--text-secondary) !important;
    text-decoration: none;
    font-size: 0.94rem;
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-link:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-primary) !important;
}

.sidebar-link.active {
    background-color: var(--bg-surface);
    color: var(--text-primary) !important;
    font-weight: 600;
    border: 1px solid var(--border-subtle);
}

.sidebar-search-input {
    background-color: var(--bg-input) !important;
    border: 1px solid var(--border-subtle) !important;
    color: var(--text-primary) !important;
    border-radius: 8px;
    font-size: 0.875rem;
}

.sidebar-search-input:focus {
    border-color: var(--accent-color) !important;
    box-shadow: none !important;
}

.btn-theme-toggle {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.btn-theme-toggle:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.mobile-header {
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.blog-main-wrapper {
    flex-grow: 1;
    min-width: 0;
    padding: 3rem 1.5rem 4rem 1.5rem;
}

@media (min-width: 992px) {
    .blog-main-wrapper {
        padding: 3.75rem 3.5rem 5rem 3.5rem;
    }
}

.blog-main-content {
    max-width: 720px;
    margin: 0 auto;
}

.blog-main-content.blog-main-wide {
    max-width: 980px;
}

/* ==========================================
   Typography & Home / Post List Styles
   ========================================== */
.page-heading {
    font-size: 2.1rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.section-heading {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.year-heading {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0.4rem;
}

.intro-prose {
    font-size: 1.08rem;
    color: var(--text-secondary);
    line-height: 1.75;
}

.intro-prose p {
    margin-bottom: 1rem;
}

.intro-prose a {
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.blog-surface {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
}

.glass-effect {
    background: var(--glass-bg) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle) !important;
    color: var(--text-primary) !important;
}

.project-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 1rem 1.15rem;
    transition: border-color 0.15s ease, transform 0.15s ease, background-color 0.15s ease;
}

.project-card:hover {
    border-color: var(--border-hover);
    background-color: var(--bg-surface-hover);
    transform: translateY(-2px);
}

.project-card-large {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 1.5rem 1.75rem;
    transition: border-color 0.15s ease;
}

.project-card-large:hover {
    border-color: var(--border-hover);
}

.project-card-title {
    color: var(--text-primary) !important;
}

.project-card-title:hover {
    color: var(--accent-color) !important;
}

/* Chronological Post Feed (garry.net style) */
.post-list {
    display: flex;
    flex-direction: column;
}

.post-list-item {
    padding: 1.15rem 0;
    border-bottom: 1px solid var(--border-subtle);
}

.post-list-item:first-child {
    padding-top: 0.25rem;
}

.post-list-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.post-list-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.post-list-title a {
    color: var(--text-primary);
    text-decoration: none;
}

.post-list-title a:hover {
    color: var(--accent-color);
}

.post-list-desc {
    color: var(--text-secondary);
    font-size: 0.96rem;
    line-height: 1.6;
}

.filter-pill {
    display: inline-block;
    padding: 0.3rem 0.85rem;
    border-radius: 50rem;
    font-size: 0.83rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text-secondary);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    transition: all 0.15s ease;
}

.filter-pill:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.filter-pill.active {
    background-color: var(--accent-color);
    color: #0b0f14;
    border-color: var(--accent-color);
}

.tag-chip {
    display: inline-block;
    font-size: 0.78rem;
    color: var(--text-muted);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    padding: 0.15rem 0.55rem;
    border-radius: 6px;
    text-decoration: none;
}

.tag-chip:hover {
    color: var(--text-primary);
    border-color: var(--border-hover);
}

/* ==========================================
   Single Post Reading View
   ========================================== */
.admin-post-bar {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
}

.post-article-title {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.post-cover-image {
    max-height: 440px;
    object-fit: cover;
    border: 1px solid var(--border-subtle);
}

.post-body-content {
    font-size: 1.08em;
    line-height: 1.8;
    color: var(--text-primary);
    word-wrap: break-word;
}

.post-body-content p {
    margin-bottom: 1.35rem;
}

.post-body-content h2 {
    font-size: 1.6rem;
    margin-top: 2.25rem;
    margin-bottom: 0.85rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border-subtle);
}

.post-body-content h3 {
    font-size: 1.3rem;
    margin-top: 1.85rem;
    margin-bottom: 0.65rem;
}

.post-body-content ul,
.post-body-content ol {
    padding-left: 1.65rem;
    margin-bottom: 1.35rem;
}

.post-body-content li {
    margin-bottom: 0.45rem;
}

.post-body-content blockquote {
    border-left: 4px solid var(--accent-color);
    padding: 0.5rem 0 0.5rem 1.25rem;
    margin: 1.5rem 0;
    color: var(--text-secondary);
    font-style: italic;
}

.post-body-content pre {
    background-color: var(--code-bg);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 1.1rem 1.25rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.9rem;
    line-height: 1.6;
}

.post-body-content code {
    background-color: var(--code-bg);
    padding: 0.15rem 0.4rem;
    border-radius: 5px;
    font-size: 0.88em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.post-body-content pre code {
    background: none;
    padding: 0;
}

.post-body-content img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin: 1.25rem 0;
}

#resizable-content.text-size-small { font-size: 0.9rem; }
#resizable-content.text-size-standard { font-size: 1rem; }
#resizable-content.text-size-large { font-size: 1.2rem; }

#textSizePopup.is-visible,
#sharePopup.is-visible {
    display: block !important;
}

/* ==========================================
   Form & Rich Text Editor Styles
   ========================================== */
.form-control,
.form-select {
    background-color: var(--bg-input);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--accent-color);
    box-shadow: 0 0 0 0.2rem rgba(56, 189, 248, 0.15);
}

.rich-text-editor-instance {
    position: relative;
}

.editor-toolbar {
    background-color: var(--bg-sidebar);
    border: 1px solid var(--border-subtle);
    border-bottom: 0;
    border-radius: 10px 10px 0 0;
}

.btn-editor-tool {
    color: var(--text-secondary);
    border: none;
    background: transparent;
    padding: 0.35rem 0.6rem;
    border-radius: 6px;
}

.btn-editor-tool:hover {
    color: var(--text-primary);
    background-color: var(--bg-surface-hover);
}

.editor-content {
    position: relative;
    background-color: var(--bg-input) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 0 0 10px 10px;
    color: var(--text-primary) !important;
}

.editor-content.is-empty::before {
    content: attr(data-placeholder);
    color: var(--text-muted);
    pointer-events: none;
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
}

.editor-content pre {
    background-color: var(--code-bg);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 1rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.editor-content blockquote {
    border-left: 4px solid var(--accent-color);
    padding-left: 1rem;
    color: var(--text-secondary);
}

.editor-content img {
    display: block;
    max-width: 100%;
    height: auto;
    cursor: pointer;
    border-radius: 8px;
}

.editor-content img.image-selected {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.resize-overlay {
    position: absolute;
    border: 1px dashed var(--accent-color);
    pointer-events: none;
    z-index: 10;
    display: none;
}

.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: var(--accent-color);
    border: 1px solid #fff;
    border-radius: 50%;
    pointer-events: auto;
    z-index: 11;
}

.resize-handle.handle-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.resize-handle.handle-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.resize-handle.handle-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.resize-handle.handle-nw { top: -5px; left: -5px; cursor: nwse-resize; }

.rich-text-editor-instance.rte-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2500;
    background-color: var(--bg-base);
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0 !important;
}

.rte-fullscreen .editor-toolbar {
    border-radius: 0;
    padding: 0.75rem 1.5rem;
}

.rte-fullscreen .editor-content {
    flex-grow: 1;
    border-radius: 0;
    border: none !important;
    padding: 2.5rem 4rem !important;
}

.rte-fullscreen .editor-footer {
    padding: 0.75rem 1.5rem;
    background-color: var(--bg-sidebar);
    border-top: 1px solid var(--border-subtle);
    margin-top: 0 !important;
}

@media print {
    .no-print {
        display: none !important;
    }
    body {
        background: #fff !important;
        color: #000 !important;
    }
    .blog-main-content {
        max-width: 100% !important;
    }
}
