body {
    overflow-x: hidden;
    overflow-y: auto;
    min-width: 0;
}

body::-webkit-scrollbar {
    height: 10px;
    background: transparent;
}

body::-webkit-scrollbar-track {
    background: var(--subtle-border);
    border-radius: 3px;
}

body::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 3px;
}

body::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

body::-webkit-scrollbar-button {
    display: none;
}


.layout {
    margin: 30px auto;
    overflow: visible;
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-wrap: nowrap;
    gap: 30px;
    padding: 0 20px;
}

/* 左侧目录 */
.post-sidebar {
    width: 260px;
    height: 500px;
    flex-shrink: 0;
    background: var(--surface);
    backdrop-filter: blur(10px); 
    border-radius: 16px;
    padding: 20px;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    max-height: calc(100vh - 40px);
    transition: all 0.25s ease;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

.post-sidebar::-webkit-scrollbar {
    display: none;
    width: 0;
    background: transparent;
}

.post-sidebar:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-raised);
    background: var(--surface-hover);
}

.site-info h2 {
    font-size: 1.3rem;
    margin-bottom: 0.2rem;
}

.post-nav {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

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

.post-nav a:hover {
    text-decoration: none;
}

/* 中间文章内容 */
.post-content {
    width: 720px;
    min-width: 0;
    flex-shrink: 0;
}

.post-article {
    background: var(--surface);
    backdrop-filter: blur(12px);
    border-radius: 24px;
    padding: 32px 40px;
    box-shadow: var(--shadow-soft);
    transition: all 0.25s ease;
    border: 1px solid var(--border);
}

.post-article:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-raised);
    background: var(--surface-hover);
}

.post-article h1 {
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
    color: var(--text-heading);
}

.post-date {
    color: var(--text-muted);
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--subtle-border);
    padding-bottom: 0.75rem;
}

.post-article .content {
    line-height: 1.7;
    font-size: 1.05rem;
    color: var(--text-primary);
    min-width: 0;
    overflow-wrap: anywhere;
}

.post-article .content h2 {
    margin-top: 1.8em;
    margin-bottom: 0.5em;
    font-size: 1.6rem;
    border-left: 4px solid var(--accent);
    padding-left: 1rem;
}

.post-article .content h3 {
    margin-top: 1.5em;
    margin-bottom: 0.4em;
    font-size: 1.3rem;
}

.post-article .content p {
    margin-bottom: 1.2em;
}

.post-article .content ul,
.post-article .content ol {
    margin: 0 0 1.2em 1.5em;
    padding-left: 0.6em;
}

.post-article .content li {
    margin-bottom: 0.55em;
    padding-left: 0.2em;
}

.problem-list {
    list-style: none;
    margin-left: 0 !important;
    padding-left: 0 !important;
}

.post-article .content .problem-list li {
    margin-bottom: 1rem;
    padding: 14px 16px;
    background: var(--subtle-border);
    border-radius: 10px;
}

.problem-list a,
.problem-list span {
    display: block;
}

.problem-list span {
    margin-top: 0.35rem;
    color: var(--text-primary);
}

.post-article .content p code,
.post-article .content li code,
.post-article .content td code,
.post-article .content dd code {
    padding: 0.12em 0.38em;
    color: var(--text-heading);
    background: var(--subtle-border);
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
    font-size: 0.9em;
}

.concept-list {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 12px 18px;
    margin: 1.2rem 0 1.5rem;
}

.concept-list dt {
    color: var(--text-heading);
    font-weight: 700;
}

.concept-list dd {
    margin: 0;
}

.note-box {
    margin: 1.4rem 0;
    padding: 16px 18px;
    background: var(--subtle-border);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    line-height: 1.7;
}

.note-box.warning {
    background: rgba(245, 158, 11, 0.1);
    border-left-color: #f59e0b;
}

/* 排序文章中的步骤图 */
.sort-figure {
    margin: 1.35rem 0;
    padding: 18px;
    background: var(--subtle-border);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow-x: auto;
}

.sort-figure figcaption {
    margin-bottom: 14px;
    color: var(--text-heading);
    font-weight: 700;
}

.sort-step {
    display: grid;
    grid-template-columns: 76px max-content minmax(130px, 1fr);
    align-items: center;
    gap: 12px;
    min-width: 520px;
    margin: 10px 0;
}

.sort-label {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: right;
}

.sort-array {
    display: inline-flex;
    align-items: flex-end;
    gap: 5px;
}

.sort-cell {
    min-width: 34px;
    height: 34px;
    padding: 0 6px;
    display: inline-grid;
    place-items: center;
    color: var(--text-heading);
    background: var(--surface-solid);
    border: 1px solid var(--subtle-border);
    border-radius: 7px;
    font: 700 0.92rem/1 Consolas, monospace;
    box-shadow: 0 2px 5px rgba(15, 23, 42, 0.06);
}

.sort-cell.is-active {
    color: #8a4b00;
    background: #fde68a;
    border-color: #f59e0b;
}

.sort-cell.is-picked {
    color: #064e3b;
    background: #a7f3d0;
    border-color: #10b981;
}

.sort-cell.is-fixed {
    color: #1e3a8a;
    background: #bfdbfe;
    border-color: #3b82f6;
}

:root[data-theme="dark"] .sort-cell.is-active {
    color: #fff7d6;
    background: #7c4a03;
}

:root[data-theme="dark"] .sort-cell.is-picked {
    color: #d1fae5;
    background: #065f46;
}

:root[data-theme="dark"] .sort-cell.is-fixed {
    color: #dbeafe;
    background: #1e40af;
}

.sort-note {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.45;
}

.bucket-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-width: 500px;
    margin: 8px 0;
}

.bucket-name {
    width: 90px;
    flex: 0 0 auto;
    padding-top: 7px;
    color: var(--text-muted);
    text-align: right;
    font-size: 0.9rem;
}

.bucket-box {
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    background: var(--surface);
    border: 1px dashed var(--accent);
    border-radius: 8px;
}

.legend-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 12px;
    color: var(--text-muted);
    font-size: 0.86rem;
}

.legend-row span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: #fde68a;
    border: 1px solid #f59e0b;
}

.legend-dot.picked {
    background: #a7f3d0;
    border-color: #10b981;
}

.legend-dot.fixed {
    background: #bfdbfe;
    border-color: #3b82f6;
}

/* 右侧留白 */
.post-right {
    width: 80px;
    flex-shrink: 0;
}

/* 目录容器样式 */
#toc-container {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--subtle-border);
}

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

.toc-list ul {
    list-style: none;
    padding-left: 1.2rem;
}

.toc-item-h2 {
    margin: 8px 0;
    font-weight: 600;
}

.toc-item-h3 {
    margin: 4px 0 4px 0.5rem;
    font-size: 0.9rem;
}

.toc-item-h4 {
    margin: 2px 0 2px 1rem;
    font-size: 0.85rem;
}

.toc-link {
    text-decoration: none;
    color: var(--text-link);
    display: inline-block;
    padding: 2px 0;
    transition: all 0.2s;
}

.toc-link:hover {
    color: var(--accent-strong);
    transform: translateX(3px);
}

.table-scroll {
    max-width: 100%;
    margin: 1.3rem 0;
    overflow-x: auto;
    border: 1px solid var(--subtle-border);
    border-radius: 12px;
}

.post-article .content table {
    width: 100%;
    min-width: 680px;
    border-collapse: collapse;
}

.post-article .content th,
.post-article .content td {
    padding: 12px 14px;
    text-align: left;
    vertical-align: top;
    border-right: 1px solid var(--subtle-border);
    border-bottom: 1px solid var(--subtle-border);
}

.post-article .content th {
    color: var(--text-heading);
    background: var(--subtle-border);
    font-weight: 700;
}

.post-article .content th:last-child,
.post-article .content td:last-child {
    border-right: 0;
}

.post-article .content tbody tr:last-child td {
    border-bottom: 0;
}

.post-article .content mjx-container[display="true"] {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

@media (max-width: 1024px) {
    .layout {
        max-width: 900px;
    }

    .post-sidebar {
        width: 230px;
    }

    .post-content {
        width: auto;
        flex: 1 1 auto;
    }

    .post-right {
        display: none;
    }
}

@media (max-width: 768px) {
    .layout {
        margin: 18px auto;
        padding: 0 12px;
        gap: 16px;
        flex-direction: column;
    }

    .post-sidebar {
        position: static;
        width: 100%;
        height: auto;
        max-height: 320px;
        padding: 16px;
        border-radius: 12px;
        overflow-y: auto;
        scrollbar-color: var(--scroll-thumb) transparent;
    }

    .post-sidebar::-webkit-scrollbar {
        display: block;
        width: 6px;
    }

    .post-sidebar::-webkit-scrollbar-thumb {
        background: var(--scroll-thumb);
        border-radius: 3px;
    }

    #toc-container {
        margin-top: 0;
        padding-top: 0;
        border-top: 0;
    }

    .post-content {
        width: 100%;
    }

    .post-article {
        padding: 24px 18px;
        border-radius: 18px;
    }

    .post-article h1 {
        font-size: 1.8rem;
        line-height: 1.25;
    }

    .post-article .content {
        font-size: 1rem;
        line-height: 1.75;
    }

    .post-article .content h2 {
        font-size: 1.4rem;
        padding-left: 0.75rem;
    }

    .post-article .content h3 {
        font-size: 1.2rem;
    }

    .concept-list {
        display: block;
    }

    .concept-list dt {
        margin-top: 1rem;
        margin-bottom: 0.25rem;
    }

    .note-box {
        padding: 14px;
    }

    .toc-list ul {
        padding-left: 0.8rem;
    }
}

@media (hover: none) {
    .post-sidebar:hover,
    .post-article:hover {
        transform: none;
    }
}

