:root {
    font-size: 17px;
    /* Becomes base for rem (approx 106%) */
    --bg-color: #0c0e14;
    --sidebar-bg: #151921;
    --accent-color: #4f46e5;
    --accent-color-rgb: 79, 70, 229;
    --accent-glow: rgba(79, 70, 229, 0.3);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #37455e;
    --glass-bg: rgba(21, 25, 33, 0.8);
    --sidebar-width: 360px;
    --code-bg: #1e293b;
    --code-text: #f8fafc;
    --code-inline-bg: rgba(255, 255, 255, 0.1);
    --ripple-start: rgba(255, 255, 255, 0.8);
    --ripple-end: rgba(255, 255, 255, 0);
}

:root[data-theme="light"] {
    --bg-color: #f3f4f6;
    --sidebar-bg: #ffffff;
    --accent-color: #4f46e5;
    --accent-color-rgb: 79, 70, 229;
    --accent-glow: rgba(79, 70, 229, 0.15);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #b0b9c4;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --code-bg: #e2e8f0;
    --code-text: #1e293b;
    --code-inline-bg: rgba(0, 0, 0, 0.05);
    --ripple-start: rgba(0, 0, 0, 0.8);
    --ripple-end: rgba(0, 0, 0, 0);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    line-height: 1.6;
}

.app-container {
    display: flex;
    height: 100vh;
    /* Fallback */
    height: 100dvh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-direction: column;
    z-index: 100;
}

/* Right Sidebar */
.right-sidebar {
    width: 260px;
    background-color: var(--glass-bg);
    /* Match existing aesthetic */
    border-left: 1px solid var(--border-color);
    display: none;
    /* Hidden on mobile */
    flex-direction: column;
    z-index: 90;
    overflow-y: auto;
    padding: 2rem 1rem;
}

.sidebar-header {
    padding: 2rem 1rem;
}

.logo-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.logo {
    font-family: 'Outfit', sans-serif;
    font-size: 1.4rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;

}

.logo-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    /* For ripple */
    overflow: hidden;
    /* For ripple */
    flex-shrink: 0;
    /* Prevent icons from being squeezed */
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-color);
}

.btn {
    display: inline-block;
    padding: 0.8rem 1.5rem;
    background: var(--accent-color);
    color: white;
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    margin-top: 1rem;
    transition: all 0.2s ease;
    position: relative;
    /* For ripple */
    overflow: hidden;
    /* For ripple */
}

/* ============ Ripple Effect ============ */
.ripple {
    position: absolute;
    border-radius: 100%;
    transform: scale(0);
    animation: ripple-animation 0.8s ease-out forwards;
    background: radial-gradient(circle, var(--ripple-start) 0%, var(--ripple-end) 70%);
    pointer-events: none;
    filter: blur(2px);
    /* Soften the edges for mist effect */
}

@keyframes ripple-animation {
    0% {
        transform: scale(0);
        opacity: 0.5;
        background: radial-gradient(circle, var(--ripple-start) 0%, var(--ripple-end) 70%);
    }

    100% {
        transform: scale(2.5);
        opacity: 0;
        background: radial-gradient(circle, var(--ripple-start) 0%, var(--ripple-end) 70%);
    }
}

/* Ripple Colors */
.ripple-dark .ripple {
    background: radial-gradient(circle, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0) 70%);
}

.ripple-accent .ripple {
    background: radial-gradient(circle, var(--accent-glow) 0%, rgba(79, 70, 229, 0) 70%);
}


button,
.article-item,
.article-card,
.nav-btn,
.attachment-download-btn,
.article-image-wrapper {
    position: relative;
    overflow: hidden;
}

.article-image-wrapper {
    display: block;
    width: fit-content;
    margin: 1rem auto;
    cursor: pointer;
    border-radius: 8px;
    /* Optional: Match image radius if any */
}

/* Ensure image respects wrapper */
.article-image-wrapper img {
    display: block;
    /* Remove bottom space */
    max-width: 100%;
}

/* =========================== */

.logo-text span {
    color: var(--accent-color);
    margin-left: 2px;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.3s ease;
}

.search-box input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px var(--accent-glow);
    background: var(--bg-color);
}

.article-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.article-item {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.article-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-color);
}

.article-item.active {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.category-header {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    margin: 1.5rem 0 0.5rem 0.5rem;
    font-weight: 700;
}

.subcategory-header {
    font-size: 0.7rem;
    color: var(--accent-color);
    margin: 1rem 0 0.25rem 1rem;
    font-weight: 600;
    opacity: 0.8;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

/* Content Area */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    /* Enable global scrolling for content area */
    overflow-y: auto;
    /* scroll-behavior: smooth; スクロール時のガクガクを防ぐため無効化 */
}

/* Background effects */
.content-area::before {
    content: '';
    position: fixed;
    top: -10%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    z-index: -1;
    filter: blur(80px);
    will-change: transform;
    pointer-events: none;
}

.content-header {
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    /* backdrop-filter: blur(10px); スクロール時のパフォーマンス低下を防ぐため無効化 */
    background: var(--glass-bg);
    will-change: transform;
}

.breadcrumb {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.breadcrumb a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

.markdown-body {
    flex: 1;
    padding: 3rem 10%;
    /* Remove independent scroll, handled by content-area */
    /* overflow-y: auto; */
    /* scroll-behavior: smooth; */
}

/* Markdown Styling */
.markdown-body h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 800;
}

.article-tags {
    margin-bottom: 2rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag {
    position: relative;
    overflow: hidden;
    /* Default Dark Mode Colors */
    background: hsla(var(--tag-hue, 0), 70%, 30%, 0.2);
    color: hsla(var(--tag-hue, 0), 80%, 90%, 1);
    border: 1px solid hsla(var(--tag-hue, 0), 70%, 60%, 0.3);

    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    padding: 0.2rem 0.8rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.02em;
}

:root[data-theme="light"] .tag {
    /* Light Mode Colors - More saturated text, lighter background */
    background: hsla(var(--tag-hue, 0), 70%, 90%, 0.6);
    color: hsla(var(--tag-hue, 0), 90%, 35%, 1);
    border-color: hsla(var(--tag-hue, 0), 60%, 80%, 0.5);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.markdown-body h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.8rem;
    margin: 2rem 0 1rem 0;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.markdown-body h3 {
    font-size: 1.4rem;
    margin: 1.5rem 0 0.75rem 0;
    color: var(--accent-color);
}

.markdown-body p {
    margin-bottom: 1.25rem;
    color: var(--text-secondary);
}

.markdown-body ul {
    margin-bottom: 1.25rem;
    padding-left: 1.5rem;
}

.markdown-body li {
    margin-bottom: 0.5rem;
}

.markdown-body a {
    color: var(--accent-color);
    text-decoration: none;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body code {
    background: var(--code-inline-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--code-text);
}

.markdown-body pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    color: inherit;
}

.markdown-body pre {
    margin: 0;
    /* Reset margin for inner pre */
    padding: 1.5rem;
    background: transparent;
    border: none;
    border-radius: 0;
    overflow-x: auto;
}

/* Mac-style Code Block Container */
.code-block-container {
    background: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin: 1.5rem 0;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.08) 0%, rgba(128, 80, 255, 0.1) 100%);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(4px);
}

.mac-buttons {
    display: flex;
    gap: 0.5rem;
}

.mac-btn {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.mac-btn.red {
    background-color: #ff5f56;
}

.mac-btn.yellow {
    background-color: #ffbd2e;
}

.mac-btn.green {
    background-color: #27c93f;
}

.code-lang {
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.copy-code-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

.copy-code-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

/* Block Icon Styling */
.block-icon {
    height: 24px;
    vertical-align: middle;
    margin: 0 4px;
    transition: transform 0.2s ease;
}

.block-icon:hover {
    transform: scale(1.2);
    cursor: help;
}

/* Home View Styling */
.home-container {
    flex: 1;
    padding: 3rem 10%;
    /* overflow-y: auto; Remove independent scroll */
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.logo {
    cursor: pointer;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
    margin: 2.5rem 0;
}

.category-card {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.category-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.category-card .cat-icon {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.category-card h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.category-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

.category-card .accent-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.info-sections {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-top: 4rem;
}

.info-card {
    background: var(--glass-bg);
    border: 1px dashed var(--border-color);
    padding: 2rem;
    border-radius: 20px;
}

.info-card h3 {
    margin-bottom: 1rem;
    color: var(--accent-color);
}



.btn:hover {
    filter: brightness(1.2);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.loading,
.error {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.error {
    color: #ef4444;
}

.hero {
    text-align: center;
    padding: 4rem 2rem;
}

.hero p {
    font-size: 1.2rem;
    max-width: 600px;
    margin: 0 auto;
}

.mobile-only {
    display: none;
}

.mobile-only-flex {
    display: none;
}

@media (max-width: 1024px) {
    .info-sections {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        padding-top: 75px;
        /* Space for fixed header */
        transition: padding-top 0.3s ease;
    }

    .app-container.header-hidden {
        padding-top: 0;
    }

    .sidebar {
        display: block;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1000;
        transition: transform 0.3s ease;
        background: var(--glass-bg);
        backdrop-filter: blur(10px);
    }

    .app-container.header-hidden .sidebar {
        transform: translateY(-100%);
        pointer-events: none;
    }


    .article-list {
        display: none;
        max-height: 400px;
        overflow-y: auto;
        background: var(--sidebar-bg);
        border-radius: 0 0 12px 12px;
        border: 1px solid var(--border-color);
        border-top: none;
    }

    .article-list.search-active {
        display: block;
    }

    .mobile-only {
        display: block;
    }

    .mobile-only-flex {
        display: flex;
    }

    .search-box {
        display: none;
        padding-top: 1rem;
        animation: slideDown 0.2s ease-out;
    }

    .search-box.active {
        display: block;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .sidebar-header {
        padding: 1rem;
    }

    .logo-area {
        margin-bottom: 0.5rem;
    }

    .content-header {
        /* Keep visible for breadcrumbs */
        padding: 0.75rem 1rem;
    }

    /* Let's keep content-header for breadcrumbs but remove hamburger */
    .content-header .mobile-only {
        display: none;
    }


    .home-container,
    .markdown-body {
        padding: 2rem 5%;
    }

    /* Compact Category Cards for Mobile */
    .category-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        margin: 1.5rem 0;
    }

    .category-card {
        display: grid;
        grid-template-areas:
            "icon title"
            "desc desc";
        grid-template-columns: auto 1fr;
        column-gap: 0.75rem;
        row-gap: 0.25rem;
        padding: 0.75rem 1rem;
        border-radius: 12px;
        align-items: center;
    }

    .category-card .cat-icon {
        grid-area: icon;
        font-size: 1.5rem;
        margin-bottom: 0;
    }

    .category-card h3 {
        grid-area: title;
        font-size: 1rem;
    }

    .category-card p {
        grid-area: desc;
        font-size: 0.8rem;
        line-height: 1.4;
        display: -webkit-box;
        line-clamp: 2;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* Article Navigation for Mobile */
    .article-nav {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-btn {
        width: 100%;
        max-width: none;
        min-height: auto;
        padding: 1.25rem;
    }

    .nav-btn.next {
        text-align: left;
    }

    .nav-btn .nav-title {
        font-size: 1rem;
    }
}

/* Category View Styling */
.category-view-container {
    padding: 3rem 10%;
    flex: 1;
    /* overflow-y: auto; Remove independent scroll */
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.article-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
}

.article-card {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.article-card:hover {
    border-color: var(--accent-color);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.article-card h4 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
}

.article-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.article-card-thumb {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 8px;
    background-color: var(--code-bg);
}

.article-excerpt {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    line-clamp: 3;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

.article-card .meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: auto;
}

.article-card .tag {
    font-size: 0.7rem;
    padding: 0.1rem 0.6rem;
}

/* Search Autocomplete */
.search-container {
    position: relative;
    width: 100%;
}

.search-autocomplete {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--sidebar-bg);
    border: 1px solid var(--border-color);
    border-radius: 0 0 12px 12px;
    margin-top: 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: none;
}

.search-autocomplete.active {
    display: block;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: var(--accent-glow);
    /* Removed color: white to ensure text is readable in light mode */
}

.autocomplete-match {
    color: var(--accent-color);
    font-weight: 700;
}

.category-view-subheader {
    font-size: 1.2rem;
    color: var(--accent-color);
    margin: 2rem 0 0.5rem 0rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    font-family: 'Outfit', sans-serif;
}

.category-view-subheader:first-child {
    margin-top: 0;
}

/* Article Image Styling */
.article-image {
    max-width: 100%;
    max-height: 50vh;
    /* Limit height for vertical screenshots */
    height: auto;
    border-radius: 8px;
    margin: 1rem auto;
    /* Center image */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: block;
    /* Ensure margin works */
}

/* Responsive Iframe Container */
.iframe-container {
    margin: 2rem auto;
    width: 100%;
    display: flex;
    justify-content: center;
    background: var(--code-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
}

.iframe-container iframe {
    max-width: 100%;
    display: block;
}

/* Attachment Download Button */
.attachment-download-btn {
    display: flex;
    /* Changed from inline-flex to fill width */
    width: 100%;
    /* Full width */
    justify-content: center;
    /* Center content */
    align-items: center;
    gap: 0.5rem;
    background: var(--code-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary) !important;
    /* Override default link color */
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    margin: 1rem 0;
    text-decoration: none !important;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.attachment-download-btn:hover {
    background: var(--bg-color);
    border-color: var(--accent-color);
    color: var(--accent-color) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

/* Article View Meta Header */
.article-view-meta {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.article-date {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
}

.article-tags-list {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.attachment-download-btn i {
    color: var(--accent-color);
    font-size: 1.1em;
}

/* Article View Layout */
.article-view-layout {
    display: flex;
    flex-direction: column;
    /* gap: 2rem; */
    padding: 2rem 5%;
    flex: 1;
    /* overflow-y: auto; Remove independent scroll */
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

@media (min-width: 1024px) {

    /* Right Sidebar Visible on PC */
    .right-sidebar {
        display: flex;
    }

    .article-view-layout {
        display: block;
        /* Remove Grid */
        /* padding-right: 0; */
        /* Let container handle padding */
        max-width: 1000px;
        /* Optimal reading width */
    }

    .mobile-only-toc {
        display: none !important;
    }

    /* Style the TOC inside the sidebar */
    #pc-toc {
        background: transparent;
        border: none;
        padding: 0;
    }

    #pc-toc h3 {
        margin-top: 0;
        font-size: 0.9rem;
    }
}

.article-main {
    min-width: 0;
    /* Prevent overflow */
}

/* TOC Styling */
.article-toc {
    display: block;
    background: var(--glass-bg);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.article-toc h3 {
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    font-family: 'Outfit', sans-serif;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.article-toc ul {
    list-style: none;
    padding: 0;
}

.article-toc li {
    margin-bottom: 0.25rem;
}

.article-toc a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: color 0.2s;
    display: block;
    padding: 4px 0;
    line-height: 1.4;
}

.article-toc a:hover,
.article-toc a.active {
    color: var(--accent-color);
}

.article-toc .toc-h2 {
    font-weight: 500;
}

.article-toc .toc-h3 {
    padding-left: 1rem;
    font-size: 0.85rem;
    opacity: 0.9;
}

/* Navigation Buttons */
.article-nav {
    display: flex;
    /* Use flex for space between */
    justify-content: space-between;
    align-items: stretch;
    gap: 1.5rem;
    margin: 3rem 0;
    width: 100%;
}

.nav-btn {
    flex: 1;
    /* Grow to fill space */
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    /* max-width: 48%; */
    /* Ensure they don't touch if they wrap or flex */
}

.nav-btn:hover {
    border-color: var(--accent-color);
    background: rgba(var(--accent-color-rgb), 0.05);
    /* Assuming rgb var exists, else fallback style */
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.1);
}

.nav-btn.prev {
    text-align: left;
    grid-column: 1;
}

.nav-btn.next {
    text-align: right;
    grid-column: 2;
}

/* Handle missing siblings logic visually if needed, though JS renders spacer */

.nav-btn .nav-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.nav-btn .nav-title {
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1.4;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Adjust markdown body padding since it's now wrapped */
.markdown-body {
    padding: 0 !important;
    /* Remove override padding */
}

/* Lightbox Styling */
.lightbox-overlay {
    position: fixed;
    z-index: 2000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    /* Passes clicks through when hidden */
    transition: opacity 0.3s ease;
    flex-direction: column;
}

.lightbox-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Lightbox Content Wrapper */
.lightbox-content-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    /* optional: clips zoomed image to screen */
}

/* Lightbox Image & Video */
.lightbox-image,
.lightbox-video {
    max-width: 90%;
    max-height: 85vh;
    border-radius: 4px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.5);
    /* Initial state for animation */
    transform: scale(0.9);
    transition: transform 0.3s ease;
    transform-origin: center center;
}

.lightbox-overlay.active .lightbox-image,
.lightbox-overlay.active .lightbox-video {
    transform: scale(1);
}

.lightbox-image.zoomed {
    cursor: grab;
    transition: transform 0.1s ease-out;
    /* Smoother for drag */
}

.lightbox-image.zoomed:active {
    cursor: grabbing;
}

.lightbox-video {
    width: auto;
    height: auto;
    background: black;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    background: transparent;
    border: none;
    line-height: 1;
    z-index: 1001;
}

.lightbox-close:hover,
.lightbox-close:focus {
    color: var(--accent-color);
    text-decoration: none;
    cursor: pointer;
}

.lightbox-caption {
    margin-top: 1rem;
    color: #ccc;
    text-align: center;
    font-size: 1rem;
    max-width: 80%;
}

/* Article Image Cursor */
.article-image {
    cursor: zoom-in;
}

/* Dark Mode Image Inversion */
img.article-image,
.lightbox-image {
    filter: invert(1) hue-rotate(180deg);
    transition: filter 0.3s ease;
}

:root[data-theme="light"] img.article-image,
:root[data-theme="light"] .lightbox-image {
    filter: none;
}

/* Ensure video is not inverted */
.lightbox-video {
    filter: none !important;
}

/* -------------------------------------------------------------------------- */
/* New Styles for Markdown Enhancements                                       */
/* -------------------------------------------------------------------------- */

/* Blockquotes */
blockquote {
    border-left: 4px solid var(--border-color);
    padding-left: 1rem;
    color: var(--text-secondary);
    font-style: italic;
    margin: 1.5rem 0;
    opacity: 0.9;
}

/* GitHub Alerts (Refined Glassmorphism + Material Icons) */
.alert {
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    border-radius: 12px;
    position: relative;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid transparent;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

/* Semi-transparent background overlay */
.alert::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--alert-bg, rgba(255, 255, 255, 0.05));
    z-index: -1;
    opacity: 0.1;
}

.alert-title {
    font-weight: 800;
    /* Bolder text */
    margin-bottom: 0.5rem;
    color: var(--alert-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-transform: uppercase;
    /* Uppercase like the mockup */
    font-size: 1.1rem;
    /* Larger text */
    line-height: 1;
    letter-spacing: 0.05em;
}

.alert-icon {
    font-size: 1.75rem;
    /* Much larger icon */
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    /* Ensure full visibility */
}

/* Specific adjustment for Material Icons to look sharp */
.material-icons-round.alert-icon {
    font-size: 28px;
    width: 28px;
    height: 28px;
    overflow: hidden;
}

.alert-content {
    font-size: 0.95rem;
    color: var(--text-primary);
    padding-left: 0.25rem;
    /* Slight adjustment */
    line-height: 1.7;
}

.alert-content p {
    margin-bottom: 0;
    opacity: 0.95;
}

.alert-content p+p {
    margin-top: 0.75rem;
}

/* Alert Variants (Glass Styles) */
.alert-note {
    --alert-color: #3b82f6;
    border-left: 4px solid #3b82f6;
    background: linear-gradient(to right, rgba(59, 130, 246, 0.1), rgba(59, 130, 246, 0.02));
}

.alert-tip {
    --alert-color: #10b981;
    border-left: 4px solid #10b981;
    background: linear-gradient(to right, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.02));
}

.alert-important {
    --alert-color: #8b5cf6;
    border-left: 4px solid #8b5cf6;
    background: linear-gradient(to right, rgba(139, 92, 246, 0.1), rgba(139, 92, 246, 0.02));
}

.alert-warning {
    --alert-color: #f59e0b;
    border-left: 4px solid #f59e0b;
    background: linear-gradient(to right, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.02));
}

.alert-caution {
    --alert-color: #ef4444;
    border-left: 4px solid #ef4444;
    background: linear-gradient(to right, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.02));
}

/* Dark Mode Adjustments */
:root[data-theme="dark"] .alert-note {
    --alert-color: #60a5fa;
}

:root[data-theme="dark"] .alert-tip {
    --alert-color: #34d399;
}

:root[data-theme="dark"] .alert-important {
    --alert-color: #a78bfa;
}

:root[data-theme="dark"] .alert-warning {
    --alert-color: #fbbf24;
}

:root[data-theme="dark"] .alert-caution {
    --alert-color: #f87171;
}


/* Definition Lists (Custom Style) */
dl {
    margin-bottom: 1.5rem;
}

dt {
    font-weight: 700;
    margin-top: 1rem;
    color: var(--text-primary);
    font-size: 0.95rem;
}

dd {
    margin-left: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    line-height: 1.6;
    font-size: 0.9rem;
}

/* Highlighted Terms in Definition Lists */
dt em,
dt strong {
    font-style: normal;
    color: var(--accent-color);
}




/* -------------------------------------------------------------------------- */
/* Automate UI Block Styling                                                  */
/* -------------------------------------------------------------------------- */

.automate-ui-container {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin: 2rem 0;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    font-family: 'Noto Sans JP', 'Noto Sans', sans-serif;
}

.automate-header {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    color: white;
    padding: 0.7rem 1rem !important;
    position: relative;
}

:root[data-theme="dark"] .automate-header {
    background: linear-gradient(135deg, #37455e 0%, #2d3748 100%);
}

.automate-header-top {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.automate-btn-close {
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.automate-btn-close:hover {
    opacity: 0.8;
}

.automate-btn-close .material-icons-round {
    font-size: 1rem;
}

.automate-title {
    margin: 0 !important;
    flex: 1 !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    color: #ffffff !important;
    font-family: 'Noto Sans JP', 'Noto Sans', sans-serif !important;
    display: block;
    /* Ensure it behaves like a block/header */
}

.automate-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.automate-btn-icon {
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.automate-btn-icon:hover {
    opacity: 0.8;
}

.automate-btn-icon .material-icons-round {
    font-size: 1rem;
}

.automate-btn-save {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    font-family: 'Noto Sans JP', 'Noto Sans', sans-serif;
    letter-spacing: 0.05em;
    transition: opacity 0.2s ease;
}

.automate-btn-save:hover {
    opacity: 0.8;
}

.automate-desc {
    margin: 0rem 0rem 0rem 2.5rem !important;
    font-size: 0.8rem !important;
    color: #ffffff !important;
    line-height: 1.5 !important;
    font-family: 'Noto Sans JP', 'Noto Sans', sans-serif !important;
}

.automate-inputs {
    padding: 0 2rem;
}

.automate-section-title {
    font-size: 1rem;
    color: var(--text-primary);
    margin: 1.25rem 0 0.75rem 0;
    font-weight: 600;
    font-family: 'Noto Sans JP', 'Noto Sans', sans-serif;
}

.automate-inputs:first-of-type .automate-section-title {
    margin-top: 1.5rem;
}

.automate-input-group {
    margin-bottom: 1.25rem;
}

.automate-input-label {
    position: absolute;
    top: -10px;
    left: 10px;
    background: #151921;
    /* Default dark base */
    padding: 0 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-family: 'Noto Sans JP', 'Noto Sans', sans-serif;
    z-index: 2;
    transition: all 0.3s ease;
}

:root[data-theme="light"] .automate-input-label {
    background: #ffffff;
}

.automate-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
    margin-top: 0.5rem;
}

.automate-input-wrapper:focus-within {
    border-color: #2196F3;
    box-shadow: 0 0 0 1px #2196F3;
}

.automate-input-wrapper.has-icon {
    padding-right: 2.5rem;
}

.automate-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    font-family: 'Noto Sans JP', 'Noto Sans', sans-serif;
    padding: 0.25rem 0;
}

.automate-input.fx-value,
.automate-input.fx-force {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    width: 100%;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace !important;
}

.fx-equals-icon {
    color: var(--text-secondary);
    font-size: 1.2rem;
    margin-right: 0.5rem;
}

.fx-value-text {
    color: var(--text-primary);
    font-family: 'Noto Sans JP', 'Noto Sans', monospace;
    font-size: 0.9rem;
    flex: 1;
    word-break: break-all;
    line-height: 1.5;
}

.fx-icon {
    position: absolute;
    right: 12px;
    font-family: 'Times New Roman', serif;
    font-style: italic;
    font-size: 1.1rem;
    color: var(--text-secondary);
    pointer-events: none;
}

.fx-icon.fx-force-icon {
    color: var(--text-secondary);
    opacity: 0.7;
}

.fx-icon.fx-force-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -2px;
    width: calc(100% + 4px);
    height: 1.5px;
    background: var(--text-secondary);
    transform: translateY(-50%) rotate(45deg);
    opacity: 0.8;
}

.fx-icon.fx-value-icon {
    color: #1976D2;
}

.automate-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid #ef4444;
    color: #ef4444;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
}

.automate-checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
}

.automate-checkbox-icon {
    font-size: 1.5rem;
    color: var(--text-secondary);
}

.automate-checkbox-desc {
    font-size: 1rem;
    color: var(--text-primary);
}


/* =====================================
    Automate UI end
===================================== */


/* Tags View Styling */
.tags-view-container {
    padding: 3rem 10%;
    flex: 1;
    overflow-y: auto;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.tags-view-container h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: var(--text-primary);
    font-weight: 800;
}

.tags-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 3rem;
}

.tag-card {
    background: var(--glass-bg);
    border: 1px solid var(--border-color);
    padding: 0.8rem 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    /* Dynamic hue color similar to tags */
    /* We use the variable set in inline style */
    border-left: 4px solid hsla(var(--tag-hue, 0), 70%, 60%, 0.8);
    position: relative;
    overflow: hidden;
}

.tag-card:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    border-color: hsla(var(--tag-hue, 0), 70%, 60%, 0.5);
}

.tag-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.tag-count {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    min-width: 24px;
    text-align: center;
}

@media (max-width: 768px) {
    .tags-view-container {
        padding: 2rem 5%;
    }

    .tags-view-container h1 {
        font-size: 2rem;
    }

    .tag-card {
        padding: 0.6rem 1rem;
    }

    .tag-name {
        font-size: 1rem;
    }
}

/* Mobile Menu Styling */
.desktop-icons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mobile-popup-menu {
    display: none;
    position: absolute;
    top: 60px;
    /* Adjust based on header height */
    right: 1rem;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    min-width: 180px;
    flex-direction: column;
    animation: fadeIn 0.2s ease;
}

.mobile-popup-menu.active {
    display: flex;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.95rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.menu-item .material-icons-round {
    font-size: 1.2rem;
    color: var(--accent-color);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .desktop-icons {
        display: none;
    }
}