/* ==========================================================================
   Main Stylesheet - Layout, Header, Footer, Pages
   ========================================================================== */

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-height) + var(--sp-4));
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg-primary);
    min-height: 100vh;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Container */
.container {
    width: 100%;
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 0 var(--sp-6);
}

/* ---------- Site Header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    background: rgba(13, 17, 23, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-default);
    height: var(--header-height);
}

.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.site-brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    text-decoration: none;
    flex-shrink: 0;
}

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

.site-brand .brand-name {
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.site-brand .brand-tagline {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    display: none;
}

@media (min-width: 768px) {
    .site-brand .brand-tagline {
        display: block;
    }
}

/* Navigation */
.nav-menu {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: var(--sp-1);
}

.nav-menu li {
    margin: 0;
}

.nav-menu a {
    display: inline-flex;
    align-items: center;
    padding: var(--sp-2) var(--sp-3);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    text-decoration: none;
}

.nav-menu a:hover,
.nav-menu .current-menu-item a {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

/* Header search */
.header-search {
    margin-left: var(--sp-4);
}

.header-search input {
    width: 200px;
    padding: var(--sp-2) var(--sp-3);
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--fs-sm);
    transition: all var(--transition-fast);
}

.header-search input:focus {
    outline: none;
    width: 280px;
    border-color: var(--accent-blue);
    background: var(--bg-input);
}

/* Mobile menu toggle */
.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
}

.menu-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    position: relative;
}

.menu-toggle span::before,
.menu-toggle span::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: currentColor;
}

.menu-toggle span::before {
    top: -6px;
}

.menu-toggle span::after {
    top: 6px;
}

/* ---------- Hero Section (Homepage) ---------- */
.hero-section {
    text-align: center;
    padding: var(--sp-16) 0 var(--sp-12);
    border-bottom: 1px solid var(--border-muted);
    margin-bottom: var(--sp-10);
}

.hero-section h1 {
    font-size: var(--fs-4xl);
    margin-bottom: var(--sp-4);
    border-bottom: none;
    padding-bottom: 0;
}

.hero-section .hero-subtitle {
    font-size: var(--fs-lg);
    color: var(--text-secondary);
    margin-bottom: var(--sp-8);
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
}

.hero-section .search-form {
    margin: 0 auto;
}

/* Category quick links */
.category-links {
    display: flex;
    justify-content: center;
    gap: var(--sp-3);
    margin-top: var(--sp-8);
    flex-wrap: wrap;
}

/* ---------- Articles Grid ---------- */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--grid-gap);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-6);
}

.section-header h2 {
    font-size: var(--fs-xl);
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.section-header .view-all {
    font-size: var(--fs-sm);
}

/* ---------- Single Article Layout ---------- */
.single-layout {
    display: grid;
    grid-template-columns: 220px var(--content-max) 1fr;
    gap: var(--sp-8);
    max-width: var(--page-max);
    margin: 0 auto;
    padding: var(--sp-8) var(--sp-6);
}

/* TOC Sidebar */
.toc-sidebar {
    position: sticky;
    top: calc(var(--header-height) + var(--sp-6));
    align-self: start;
    max-height: calc(100vh - var(--header-height) - var(--sp-12));
    overflow-y: auto;
}

.toc-sidebar h3 {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: var(--sp-4);
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-list li {
    margin-bottom: var(--sp-1);
}

.toc-list a {
    display: block;
    padding: var(--sp-1) var(--sp-3);
    font-size: var(--fs-xs);
    color: var(--text-muted);
    border-left: 2px solid transparent;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.toc-list a:hover {
    color: var(--text-secondary);
    border-left-color: var(--border-default);
}

.toc-list a.active {
    color: var(--text-link);
    border-left-color: var(--accent-blue);
}

.toc-list .toc-h3 {
    padding-left: var(--sp-6);
}

/* Mobile TOC */
.toc-mobile {
    display: none;
    margin-bottom: var(--sp-6);
}

.toc-mobile-toggle {
    width: 100%;
    padding: var(--sp-3) var(--sp-4);
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    cursor: pointer;
    text-align: left;
}

.toc-mobile-content {
    display: none;
    padding: var(--sp-4);
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.toc-mobile-content.open {
    display: block;
}

/* Article Header */
.article-header {
    margin-bottom: var(--sp-8);
}

.article-header .article-meta {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
    flex-wrap: wrap;
}

.article-header h1 {
    margin-bottom: var(--sp-4);
}

.article-header .article-info {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

/* Article Content */
.article-content {
    max-width: var(--content-max);
}

.article-content > *:first-child {
    margin-top: 0;
}

.article-content img {
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    margin: var(--sp-6) 0;
}

/* Article Tags */
.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin-top: var(--sp-8);
    padding-top: var(--sp-6);
    border-top: 1px solid var(--border-default);
}

/* Article Navigation */
.article-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-4);
    margin-top: var(--sp-8);
    padding-top: var(--sp-6);
    border-top: 1px solid var(--border-default);
}

.article-nav a {
    padding: var(--sp-4);
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: border-color var(--transition-fast);
}

.article-nav a:hover {
    border-color: var(--border-active);
}

.article-nav .nav-label {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.article-nav .nav-title {
    color: var(--text-primary);
    font-weight: var(--fw-medium);
    margin-top: var(--sp-1);
}

.article-nav .nav-next {
    text-align: right;
}

/* Related Articles Sidebar */
.article-sidebar {
    position: sticky;
    top: calc(var(--header-height) + var(--sp-6));
    align-self: start;
}

/* ---------- Archive Page ---------- */
.archive-header {
    margin-bottom: var(--sp-8);
    padding-bottom: var(--sp-6);
    border-bottom: 1px solid var(--border-muted);
}

.archive-header h1 {
    margin-bottom: var(--sp-2);
}

.archive-header .archive-description {
    color: var(--text-secondary);
    font-size: var(--fs-md);
}

.archive-header .archive-count {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-top: var(--sp-2);
}

/* ---------- Site Footer ---------- */
.site-footer {
    margin-top: var(--sp-16);
    padding: var(--sp-12) 0 var(--sp-8);
    border-top: 1px solid var(--border-default);
    background: var(--bg-secondary);
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: var(--sp-10);
    margin-bottom: var(--sp-10);
}

.footer-brand .brand-name {
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
    color: var(--text-primary);
    margin-bottom: var(--sp-3);
}

.footer-brand .brand-desc {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    line-height: var(--lh-relaxed);
}

.footer-col h4 {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--sp-4);
}

.footer-col ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-col li {
    margin-bottom: var(--sp-2);
}

.footer-col a {
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    transition: color var(--transition-fast);
}

.footer-col a:hover {
    color: var(--text-link);
}

.footer-bottom {
    padding-top: var(--sp-6);
    border-top: 1px solid var(--border-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

/* ---------- 404 Page ---------- */
.page-404 {
    text-align: center;
    padding: var(--sp-16) var(--sp-4);
}

.page-404 .error-code {
    font-size: 6rem;
    font-weight: var(--fw-bold);
    font-family: var(--font-mono);
    color: var(--text-muted);
    line-height: 1;
    margin-bottom: var(--sp-4);
}

/* ---------- Screen Reader Text ---------- */
.screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    position: absolute;
    height: 1px;
    width: 1px;
    overflow: hidden;
    word-wrap: normal;
}

.screen-reader-text:focus {
    clip: auto;
    display: block;
    height: auto;
    width: auto;
    position: static;
}

/* ---------- Utility ---------- */
.visually-hidden {
    position: absolute;
    clip: rect(0 0 0 0);
    width: 1px;
    height: 1px;
    overflow: hidden;
    white-space: nowrap;
}

.site-main {
    min-height: calc(100vh - var(--header-height) - 200px);
    padding: var(--sp-8) 0;
}

/* ==========================================================================
   AIトラブル解決ナビ カスタムスタイル
   ========================================================================== */

/* Hero Section Enhancement */
.hero-section {
    background: linear-gradient(180deg, rgba(31, 111, 235, 0.08) 0%, transparent 100%);
    position: relative;
}

.hero-section h1 {
    background: linear-gradient(135deg, #58a6ff 0%, #bc8cff 50%, #3fb950 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-section .search-form {
    display: flex;
    max-width: 600px;
    gap: 0;
}

.hero-section .search-input {
    flex: 1;
    padding: var(--sp-4) var(--sp-5);
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-right: none;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    color: var(--text-primary);
    font-size: var(--fs-md);
}

.hero-section .search-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.15);
}

.hero-section .search-submit {
    padding: var(--sp-4) var(--sp-6);
    background: var(--accent-blue);
    color: #fff;
    border: 1px solid var(--accent-blue);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.hero-section .search-submit:hover {
    background: var(--accent-blue-dim);
}

/* Article Card Hover Enhancement */
.article-card {
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.article-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card-hover);
}

/* Category Badge Colors */
.category-badge {
    display: inline-flex;
    align-items: center;
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--radius-full);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    text-decoration: none;
    transition: opacity var(--transition-fast);
}

.category-badge:hover {
    opacity: 0.85;
}

.category--error {
    background: rgba(248, 81, 73, 0.15);
    color: var(--cat-error);
    border: 1px solid rgba(248, 81, 73, 0.3);
}

.category--guide {
    background: rgba(88, 166, 255, 0.15);
    color: var(--cat-guide);
    border: 1px solid rgba(88, 166, 255, 0.3);
}

.category--prompt {
    background: rgba(188, 140, 255, 0.15);
    color: var(--cat-prompt);
    border: 1px solid rgba(188, 140, 255, 0.3);
}

.category--news {
    background: rgba(63, 185, 80, 0.15);
    color: var(--cat-news);
    border: 1px solid rgba(63, 185, 80, 0.3);
}

/* Tag badges */
.tag-badge {
    display: inline-flex;
    align-items: center;
    padding: var(--sp-1) var(--sp-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.tag-badge:hover {
    background: var(--bg-card-hover);
    color: var(--text-link);
    border-color: var(--text-link);
}

/* Tool tags section */
.tool-tags__list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
}

/* Helpful widget */
.helpful-widget {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-4) var(--sp-5);
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    margin-top: var(--sp-8);
}

.helpful-widget__buttons {
    display: flex;
    gap: var(--sp-2);
}

.helpful-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.helpful-btn:hover {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

/* Widget in sidebar */
.widget {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    margin-bottom: var(--sp-6);
}

.widget-title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    margin-bottom: var(--sp-4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Source info */
.source-info {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
    margin-bottom: var(--sp-3);
}

.source-info__label {
    color: var(--text-muted);
}

.source-info__link {
    color: var(--text-link);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
}

.source-info__link:hover {
    color: var(--text-link-hover);
}

/* Difficulty badges */
.difficulty-badge {
    display: inline-flex;
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--radius-full);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
}

.difficulty--beginner {
    background: rgba(63, 185, 80, 0.15);
    color: var(--diff-beginner);
}

.difficulty--intermediate {
    background: rgba(210, 153, 34, 0.15);
    color: var(--diff-intermediate);
}

.difficulty--advanced {
    background: rgba(248, 81, 73, 0.15);
    color: var(--diff-advanced);
}

/* Error badge */
.error-badge {
    display: inline-flex;
    padding: var(--sp-1) var(--sp-3);
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.3);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    color: var(--accent-red);
}

/* No results */
.no-results {
    text-align: center;
    padding: var(--sp-16) var(--sp-4);
    color: var(--text-secondary);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: var(--sp-2);
    margin-top: var(--sp-10);
}

.pagination a,
.pagination span {
    padding: var(--sp-2) var(--sp-4);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    text-decoration: none;
}

.pagination a:hover {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

.pagination .current {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #fff;
}

/* Affiliate section styling */
.article-content h2:last-of-type {
    margin-top: var(--sp-10);
}

.article-content ul:last-of-type li {
    padding: var(--sp-3) 0;
}

.article-content ul:last-of-type li strong {
    color: var(--text-link);
}

/* ---------- Article Navigation Fix ---------- */
.article-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-4);
    margin-top: var(--sp-8);
    padding-top: var(--sp-6);
    border-top: 1px solid var(--border-default);
}

.article-nav > div {
    min-width: 0;
}

.article-nav a {
    display: block;
    padding: var(--sp-4) var(--sp-5);
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    text-decoration: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    overflow: hidden;
}

.article-nav a:hover {
    border-color: var(--accent-blue);
    box-shadow: var(--shadow-md);
}

.article-nav .nav-label {
    display: block;
    font-size: var(--fs-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--sp-2);
}

.article-nav .nav-title {
    display: block;
    color: var(--text-primary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    line-height: var(--lh-tight);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.article-nav .nav-next {
    text-align: right;
}

/* ---------- Header Nav Fix ---------- */
.site-nav {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
}

.nav-menu {
    flex-wrap: nowrap;
}

.nav-menu a {
    white-space: nowrap;
}

.site-brand {
    max-width: 360px;
}

/* ---------- Single Article Mobile Fix ---------- */
@media (max-width: 1023px) {
    .single-layout {
        grid-template-columns: 1fr !important;
    }

    .toc-sidebar {
        display: none;
    }

    .article-sidebar {
        position: static;
    }
}

@media (max-width: 767px) {
    .single-layout {
        padding: var(--sp-4) var(--sp-4);
        gap: var(--sp-4);
    }
}

/* ---------- Share Widget ---------- */
.share-widget {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-4);
    padding: var(--sp-4) var(--sp-6);
    background: var(--bg-secondary);
    border: 1px solid var(--border-muted);
    border-radius: var(--radius-lg);
    margin-top: var(--sp-2);
}

.share-widget__label {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    white-space: nowrap;
}

.share-widget__buttons {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-muted);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-size: 0;
    line-height: 1;
}

.share-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.share-btn--x:hover {
    background: #000;
    color: #fff;
    border-color: #000;
}

.share-btn--fb:hover {
    background: #1877f2;
    color: #fff;
    border-color: #1877f2;
}

.share-btn--line:hover {
    background: #06c755;
    color: #fff;
    border-color: #06c755;
}

.share-btn--hatena:hover {
    background: #00a4de;
    color: #fff;
    border-color: #00a4de;
}

.share-btn--copy {
    gap: var(--sp-1);
    width: auto;
    padding: 0 var(--sp-3);
    border-radius: var(--radius-md);
    font-size: var(--fs-xs);
}

.share-btn--copy:hover {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
}

.share-btn--copy .copy-label {
    font-size: var(--fs-xs);
}

.share-btn--copy.copied {
    background: var(--accent-success);
    border-color: var(--accent-success);
    color: #fff;
}

.share-btn--copy.copied .copy-label::after {
    content: "✓";
    margin-left: 4px;
}

@media (max-width: 767px) {
    .share-widget {
        flex-direction: column;
        gap: var(--sp-2);
        padding: var(--sp-3) var(--sp-4);
    }

    .share-btn {
        width: 36px;
        height: 36px;
    }
}

/* ---------- Article Cards Mobile Fix ---------- */
@media (max-width: 767px) {
    .articles-grid {
        grid-template-columns: 1fr !important;
        gap: var(--sp-4) !important;
    }

    .article-card {
        padding: var(--sp-4);
    }

    .article-card h3 {
        font-size: var(--fs-md);
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .articles-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ---------- Footer Mobile Fix ---------- */
@media (max-width: 767px) {
    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: var(--sp-6) !important;
    }

    .footer-brand {
        text-align: center;
    }

    .footer-brand p {
        font-size: var(--fs-sm);
    }

    .footer-bottom {
        flex-direction: column;
        text-align: center;
        gap: var(--sp-2);
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .footer-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: var(--sp-6) !important;
    }
}

/* ---------- Mobile Header Nav Fix ---------- */
@media (max-width: 1023px) {
    .menu-toggle {
        display: flex !important;
    }

    .site-nav .nav-menu {
        display: none !important;
        position: fixed;
        top: var(--header-height, 60px);
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--bg-primary);
        padding: var(--sp-6);
        z-index: 9999;
        flex-direction: column;
        overflow-y: auto;
        border-top: 1px solid var(--border-muted);
    }

    .site-nav .nav-menu.active {
        display: flex !important;
    }

    .site-nav .nav-menu li {
        margin: 0;
        border-bottom: 1px solid var(--border-muted);
    }

    .site-nav .nav-menu a {
        display: block;
        padding: var(--sp-4) var(--sp-2);
        font-size: var(--fs-md);
        color: var(--text-primary);
    }

    .site-nav .nav-menu a:hover {
        background: var(--bg-tertiary);
    }

    .header-search {
        display: none !important;
    }

    /* Hamburger animation when open */
    .menu-toggle[aria-expanded=true] span {
        background: transparent;
    }

    .menu-toggle[aria-expanded=true] span::before {
        top: 0;
        transform: rotate(45deg);
    }

    .menu-toggle[aria-expanded=true] span::after {
        top: 0;
        transform: rotate(-45deg);
    }
}

/* ---------- Mobile Menu Overlay Fix ---------- */
@media (max-width: 1023px) {
    .site-nav .nav-menu.active {
        display: flex !important;
        position: fixed !important;
        top: var(--header-height, 56px) !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        height: calc(100vh - var(--header-height, 56px)) !important;
        height: calc(100dvh - var(--header-height, 56px)) !important;
        background: var(--bg-primary) !important;
        flex-direction: column !important;
        align-items: stretch !important;
        padding: 0 !important;
        z-index: 9999 !important;
        overflow-y: auto !important;
        border-top: 1px solid var(--border-muted);
    }

    .site-nav .nav-menu.active li {
        border-bottom: 1px solid var(--border-muted);
    }

    .site-nav .nav-menu.active a {
        display: block !important;
        padding: 16px 24px !important;
        font-size: 16px !important;
        color: var(--text-primary) !important;
        border-radius: 0 !important;
    }

    .site-nav .nav-menu.active a:hover,
    .site-nav .nav-menu.active a:active {
        background: var(--bg-tertiary) !important;
    }
}

/* ---------- Single Article Mobile Layout Fix ---------- */
@media (max-width: 1023px) {
    .single-layout {
        grid-template-columns: 1fr !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }

    .single-layout > * {
        min-width: 0 !important;
    }

    .article-single {
        min-width: 0 !important;
        max-width: 100% !important;
    }

    .article-content {
        min-width: 0 !important;
        max-width: 100% !important;
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .article-content pre,
    .article-content code,
    .code-block-wrapper {
        max-width: 100% !important;
        overflow-x: auto !important;
    }

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

    .article-content table {
        display: block;
        max-width: 100% !important;
        overflow-x: auto !important;
    }

    .article-header h1 {
        font-size: clamp(1.25rem, 5vw, 1.75rem) !important;
        word-break: break-word;
    }

    .category-badge {
        position: static !important;
        float: none !important;
    }
}
