/* Mobile layout: keep the reading flow compact and intentional. */
@media (max-width: 640px) {
    .tutorial-header {
        margin-bottom: 1.5rem !important;
        padding-top: 0.5rem !important;
    }

    .tutorial-header h1 {
        font-size: 1.875rem !important;
        line-height: 1.12 !important;
        letter-spacing: -0.02em;
    }

    .tutorial-header .bg-white\/80 {
        border-radius: 1rem !important;
        padding: 1rem !important;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08) !important;
    }

    .tutorial-meta {
        padding: 0.875rem !important;
        margin-bottom: 1rem !important;
        border: 1px solid rgba(148, 163, 184, 0.22);
        border-radius: 1rem;
        background: rgba(255, 255, 255, 0.72);
        box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
    }

    .tutorial-meta > .flex {
        gap: 0.75rem !important;
        margin-bottom: 0.75rem !important;
    }

    .tutorial-meta .flex.items-center.space-x-6 {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.5rem;
        margin-left: 0 !important;
        font-size: 0.75rem;
    }

    .tutorial-meta .flex.items-center.space-x-6 > * {
        min-width: 0;
    }

    .tutorial-meta .flex.items-center.space-x-6 > *:not(:first-child) {
        margin-left: 0 !important;
    }

    .tutorial-meta .flex.items-center.space-x-6 span {
        overflow-wrap: anywhere;
    }

    .tutorial-meta .action-btn,
    .tutorial-meta .like-button {
        min-height: 2.25rem;
        border-radius: 0.75rem;
    }

    .tutorial-meta + .glass-card {
        padding: 1rem !important;
        margin-bottom: 1.5rem !important;
        border-radius: 1.25rem !important;
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06) !important;
    }

    .tutorial-meta + .glass-card > div:first-child {
        margin-bottom: 1.25rem !important;
        padding-bottom: 1rem !important;
    }

    .tutorial-meta + .glass-card h2 {
        font-size: 1.35rem !important;
        line-height: 1.2;
    }

    .tutorial-meta + .glass-card h2 + p {
        font-size: 0.95rem;
        line-height: 1.5;
    }

    .tutorial-content {
        padding: 1rem !important;
        border-radius: 1rem !important;
        box-shadow: none !important;
    }

    .tutorial-content img {
        border-radius: 0.875rem;
    }

    .similar-tutorial-card {
        min-height: 112px;
        border-radius: 0.875rem;
    }

    .similar-tutorial-overlay {
        padding: 0.75rem;
    }

    .similar-tutorial-overlay p {
        margin-bottom: 0.4rem;
    }

    .tutorial-footer {
        margin-top: 1.5rem !important;
        padding: 1.5rem 1rem 1rem !important;
        background: #f8fafc !important;
    }

    html.dark.tikstar-theme body.tutorials-page .tutorial-footer,
    html.theme-dark.tikstar-theme body.tutorials-page .tutorial-footer {
        background: rgba(10, 14, 28, 0.96) !important;
        border-top-color: rgba(139, 92, 246, 0.2) !important;
    }

    .tutorial-footer p {
        color: #475569 !important;
        font-size: 0.875rem;
        line-height: 1.55;
    }

    html.dark.tikstar-theme body.tutorials-page .tutorial-footer p,
    html.theme-dark.tikstar-theme body.tutorials-page .tutorial-footer p {
        color: #cbd5e1 !important;
    }

    html.dark.tikstar-theme body.tutorials-page .tutorial-footer h3,
    html.theme-dark.tikstar-theme body.tutorials-page .tutorial-footer h3 {
        color: #f8fafc !important;
    }

    html.dark.tikstar-theme body.tutorials-page .tutorial-footer a,
    html.theme-dark.tikstar-theme body.tutorials-page .tutorial-footer a {
        color: #c4b5fd !important;
    }

    .tutorial-footer .mt-6 {
        margin-top: 1.25rem !important;
        padding-top: 1rem !important;
    }

    /* Article mobile: remove nested panels and keep the reading rhythm clean. */
    .tutorial-content {
        background: transparent !important;
        padding: 0 !important;
        font-size: 1rem !important;
        line-height: 1.75 !important;
    }

    .tutorial-content figure,
    .tutorial-content figure.image {
        margin: 0 0 2rem !important;
    }

    .tutorial-content figure img,
    .tutorial-content > img {
        display: block;
        width: 100% !important;
        max-height: 15rem;
        object-fit: cover;
        border-radius: 1rem;
        box-shadow: 0 12px 26px rgba(15, 23, 42, 0.12);
    }

    .tutorial-content h2 {
        display: block !important;
        margin: 2.25rem 0 1rem !important;
        padding: 0 0 0 0.75rem !important;
        border-left: 4px solid #6366f1;
        font-size: 1.35rem !important;
        line-height: 1.25 !important;
        color: #172554 !important;
    }

    .tutorial-content h2::before {
        display: none !important;
    }

    .tutorial-content h2 strong,
    .tutorial-content h3 strong,
    .tutorial-content h4 strong {
        padding: 0 !important;
        background: transparent !important;
        color: inherit !important;
    }

    .tutorial-content p,
    .tutorial-content p:first-of-type,
    .tutorial-content .tutorial-image-wrapper + p {
        margin: 0 0 1.5rem !important;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        font-size: 1rem !important;
        line-height: 1.85 !important;
        color: #334155 !important;
        font-weight: 400 !important;
    }

    .tutorial-content ul,
    .tutorial-content ol {
        margin: 0 0 1.75rem !important;
        padding: 1rem 1rem 1rem 2rem !important;
        border-radius: 0.875rem;
        background: #f8fafc;
    }

    .tutorial-content li {
        margin-bottom: 0.75rem !important;
        padding-left: 0.25rem !important;
        color: #334155 !important;
        line-height: 1.65 !important;
    }

    .tutorial-content li:last-child {
        margin-bottom: 0 !important;
    }

    .tutorial-content strong {
        background: transparent !important;
        padding: 0 !important;
        color: #1e293b !important;
    }
}

/* Dark mode overrides the mobile article palette above. */
.dark .tutorial-content,
.dark .tutorial-content p,
.dark .tutorial-content li,
.dark .tutorial-content em,
.dark .tutorial-content i {
    color: #e2e8f0 !important;
}

.dark .tutorial-content h1,
.dark .tutorial-content h2,
.dark .tutorial-content h3,
.dark .tutorial-content h4,
.dark .tutorial-content h5,
.dark .tutorial-content h6,
.dark .tutorial-content strong {
    color: #f8fafc !important;
}

.dark .tutorial-content h1 strong,
.dark .tutorial-content h2 strong,
.dark .tutorial-content h3 strong,
.dark .tutorial-content h4 strong,
.dark .tutorial-content h5 strong,
.dark .tutorial-content h6 strong {
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
}

.dark .tutorial-content ul,
.dark .tutorial-content ol {
    background: #0f172a !important;
    border: 1px solid rgba(148, 163, 184, 0.2) !important;
    box-shadow: inset 3px 0 0 #38bdf8 !important;
}

.dark .tutorial-content ul li::before,
.dark .tutorial-content ol li::marker {
    color: #67e8f9 !important;
}

.dark .tutorial-content blockquote {
    background: linear-gradient(135deg, #172554 0%, #1e1b4b 100%) !important;
    border: 1px solid rgba(96, 165, 250, 0.35) !important;
    border-left: 4px solid #60a5fa !important;
    color: #dbeafe !important;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.35) !important;
}

.dark .tutorial-content blockquote h3,
.dark .tutorial-content blockquote strong {
    color: #bfdbfe !important;
}

.dark .tutorial-content blockquote p,
.dark .tutorial-content blockquote i {
    color: #dbeafe !important;
}

.dark .tutorial-content a {
    color: #93c5fd !important;
}

.dark .tutorial-content li::marker,
.dark .tutorial-content ol li::marker {
    color: #c4b5fd !important;
}

/* Remove footer bottom spacing */
.tutorial-footer {
    padding-bottom: 1.5rem !important;
    margin-bottom: 0 !important;
}

body {
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

@media (max-width: 640px) {
    body.tutorials-page {
        background-color: #060712 !important;
        background-image: radial-gradient(circle at 50% 0%, rgba(124, 77, 255, 0.2), transparent 38%) !important;
    }

    main .max-w-7xl > .grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    main .max-w-7xl > .grid > .lg\:col-span-3,
    main .max-w-7xl > .grid > .lg\:col-span-1,
    .tutorial-sidebar {
        display: contents !important;
    }

    main .max-w-7xl > .grid > .lg\:col-span-3 > * {
        order: 3 !important;
    }

    main .max-w-7xl > .grid > .lg\:col-span-3 > .tutorial-meta {
        order: 0 !important;
    }

    #toc-card {
        order: 1 !important;
        margin: 0 0 0.15rem !important;
        padding: 0.75rem !important;
    }

    #toc-card h3 {
        margin-bottom: 0.4rem !important;
        font-size: 0.7rem !important;
    }

    #toc-mobile-toggle {
        min-height: 2.4rem;
    }

    main .max-w-7xl > .grid > .lg\:col-span-3 > .tutorial-meta + .glass-card {
        order: 2 !important;
    }

    .tutorial-sidebar > * {
        order: 4 !important;
    }

    .tutorial-header {
        margin: 0 0 0.75rem !important;
        padding: 0.25rem 0.9rem 0.9rem !important;
        border-bottom: 1px solid rgba(139, 92, 246, 0.18);
        border-radius: 0 0 1.25rem 1.25rem;
        background: linear-gradient(180deg, rgba(10, 14, 28, 0.98), rgba(6, 7, 18, 0.72));
    }

    .tutorial-header > .text-center {
        text-align: left !important;
    }

    .tutorial-header > .text-center > .absolute {
        display: none;
    }

    .tutorial-header h1 {
        margin: 0 0 0.75rem !important;
        padding: 0 !important;
        font-size: 1.45rem !important;
        line-height: 1.18 !important;
        color: #f8fafc !important;
        background-image: linear-gradient(100deg, #fff 10%, #ddd6fe 90%) !important;
    }

    .tutorial-header .inline-flex {
        margin-bottom: 0.85rem !important;
        padding: 0.4rem 0.7rem !important;
        border: 1px solid rgba(167, 139, 250, 0.28);
        background: rgba(124, 77, 255, 0.16) !important;
        box-shadow: none !important;
    }

    .tutorial-header .bg-white\/80 {
        padding: 0.75rem !important;
        border: 1px solid rgba(148, 163, 184, 0.16) !important;
        border-radius: 0.875rem !important;
        background: rgba(15, 19, 36, 0.82) !important;
        box-shadow: none !important;
        backdrop-filter: blur(16px);
    }

    .tutorial-header .bg-white\/80 p {
        color: #cbd5e1 !important;
        display: -webkit-box;
        overflow: hidden;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 3;
        font-size: 0.85rem !important;
        line-height: 1.45 !important;
    }

    .tutorial-header .max-w-4xl {
        padding-bottom: 0 !important;
    }

    .tutorial-header .bg-white\/80 .justify-center {
        display: none !important;
    }

    .breadcrumb-mobile {
        margin-top: calc(3rem + env(safe-area-inset-top, 0px)) !important;
        margin-bottom: 0.9rem !important;
        padding: 0 !important;
    }

    .breadcrumb-mobile-view {
        width: fit-content;
        max-width: 100%;
        min-height: 2.25rem;
        padding: 0.4rem 0.7rem;
        border: 1px solid rgba(148, 163, 184, 0.16);
        border-radius: 999px;
        background: rgba(15, 19, 36, 0.82);
        color: #cbd5e1;
        font-size: 0.8rem;
    }

    .breadcrumb-home,
    .breadcrumb-current,
    .breadcrumb-mobile .breadcrumb-separator {
        color: #cbd5e1 !important;
    }

    .tutorial-meta {
        padding: 0.85rem !important;
        border-color: rgba(139, 92, 246, 0.2) !important;
        background: rgba(10, 14, 28, 0.88) !important;
        box-shadow: none !important;
    }

    .tutorial-meta button,
    .tutorial-meta .like-button {
        min-height: 2.75rem !important;
        border-radius: 0.8rem !important;
    }

    .tutorial-meta + .glass-card {
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    .tutorial-meta + .glass-card > div:first-child {
        margin: 0 0 1rem !important;
        padding: 1rem 1.5rem 0.85rem !important;
        border-color: rgba(148, 163, 184, 0.16) !important;
    }

    .tutorial-meta + .glass-card > div:first-child > p {
        display: none;
    }

    .tutorial-content {
        color: #e2e8f0 !important;
        padding: 0 0.75rem !important;
        min-width: 0;
        max-width: 100%;
        overflow-x: clip;
        overflow-wrap: anywhere;
    }

    .tutorial-content pre,
    .tutorial-content table,
    .tutorial-content .image-container {
        display: block;
        max-width: 100%;
        overflow-x: auto;
    }

    #panelSwitcher {
        display: none !important;
    }

    .tutorial-content ul,
    .tutorial-content ol {
        background: rgba(15, 23, 42, 0.72) !important;
        border: 1px solid rgba(148, 163, 184, 0.14) !important;
        box-shadow: inset 3px 0 0 #8b5cf6 !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page {
        background: #ffffff !important;
        background-image: none !important;
        color: #1e293b !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page .tutorial-header {
        border-bottom-color: #e2e8f0;
        background: #ffffff;
    }

    html.theme-light.tikstar-theme body.tutorials-page .tutorial-header h1 {
        color: #1e293b !important;
        background-image: linear-gradient(100deg, #0f172a 10%, #5b21b6 90%) !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page .tutorial-header .inline-flex {
        color: #5b21b6 !important;
        border-color: rgba(124, 77, 255, 0.2);
        background: #ede9fe !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page .tutorial-header .bg-white\/80 {
        border-color: #e2e8f0 !important;
        background: #ffffff !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page .tutorial-header .bg-white\/80 p {
        color: #475569 !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page .breadcrumb-mobile-view {
        color: #475569;
        border-color: #e2e8f0;
        background: rgba(255, 255, 255, 0.94);
    }

    html.theme-light.tikstar-theme body.tutorials-page .breadcrumb-home,
    html.theme-light.tikstar-theme body.tutorials-page .breadcrumb-current,
    html.theme-light.tikstar-theme body.tutorials-page .breadcrumb-mobile .breadcrumb-separator {
        color: #475569 !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page .tutorial-meta {
        color: #334155 !important;
        border-color: #e2e8f0 !important;
        background: #ffffff !important;
        box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05) !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page .tutorial-meta .text-gray-900,
    html.theme-light.tikstar-theme body.tutorials-page .tutorial-meta .text-gray-800,
    html.theme-light.tikstar-theme body.tutorials-page .tutorial-meta .text-gray-700,
    html.theme-light.tikstar-theme body.tutorials-page .tutorial-meta .text-gray-600,
    html.theme-light.tikstar-theme body.tutorials-page .tutorial-meta .text-gray-500,
    html.theme-light.tikstar-theme body.tutorials-page .tutorial-meta .text-gray-400 {
        color: #334155 !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page #toc-card {
        color: #1e293b !important;
        border-color: #e2e8f0 !important;
        background: #ffffff !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page .tutorial-meta + .glass-card > div:first-child {
        border-color: #e2e8f0 !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page .tutorial-meta + .glass-card {
        padding: 1rem !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 1rem !important;
        background: #ffffff !important;
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06) !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page .tutorial-content {
        color: #334155 !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page .tutorial-content p,
    html.theme-light.tikstar-theme body.tutorials-page .tutorial-content li,
    html.theme-light.tikstar-theme body.tutorials-page .tutorial-content strong {
        color: #334155 !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page .tutorial-content h1,
    html.theme-light.tikstar-theme body.tutorials-page .tutorial-content h2,
    html.theme-light.tikstar-theme body.tutorials-page .tutorial-content h3,
    html.theme-light.tikstar-theme body.tutorials-page .tutorial-content h4 {
        color: #172554 !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page .tutorial-content ul,
    html.theme-light.tikstar-theme body.tutorials-page .tutorial-content ol {
        background: #f8fafc !important;
        border-color: #e2e8f0 !important;
        box-shadow: inset 3px 0 0 #7c3aed !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page .tutorial-footer {
        background: #ffffff !important;
        border-top-color: #e2e8f0 !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page .tutorial-footer h3 {
        color: #1e293b !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page .tutorial-footer p {
        color: #475569 !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page .tutorial-footer a {
        color: #6d28d9 !important;
    }

    html.theme-light.tikstar-theme body.tutorials-page .tutorial-footer .border-gray-200 {
        border-color: #e2e8f0 !important;
    }
}
