:root {
    --background: #fdf8f7;
    --on-background: #201a19;

    --icon-background: #f1e9e7;
    --icon-color: #514542;

    --primary-container: #ffdad2;
    --on-primary-container: #3a0b04;

    --primary: #8c4a3c;
    --on-primary: #ffffff;

--theme-button-background: #e8dedb;

    --icon-size: 56px;
    --icon-symbol-size: 34px;

    --item-width: 72px;

    --column-gap: 12px;
    --row-gap: 28px;

    --section-gap: 52px;
}


/* 深色模式 */

@media (prefers-color-scheme: dark) {
    html:not([data-theme]) {
        --background: #171312;
        --on-background: #f5e9e6;

        --icon-background: #39302d;
        --icon-color: #f0dfdb;

        --primary-container: #8f493c;
        --on-primary-container: #fff0ec;

        --primary: #ffb4a4;
        --on-primary: #561f15;

        --theme-button-background: #453b38;

    }

    html:not([data-theme]) .icon img {
        filter: brightness(0) invert(1);
    }
}

/* 强制白天 */

html[data-theme="light"] {
    --background: #fdf8f7;
    --on-background: #201a19;

    --icon-background: #f1e9e7;
    --icon-color: #514542;

    --primary-container: #ffdad2;
    --on-primary-container: #3a0b04;

    --primary: #8c4a3c;
    --on-primary: #ffffff;

    --theme-button-background: #e8dedb;
}


/* 强制黑夜 */

html[data-theme="dark"] {
    --background: #171312;
    --on-background: #f5e9e6;

    --icon-background: #39302d;
    --icon-color: #f0dfdb;

    --primary-container: #8f493c;
    --on-primary-container: #fff0ec;

    --primary: #ffb4a4;
    --on-primary: #561f15;

    --theme-button-background: #453b38;
}


/* 强制黑夜时，让 SVG 变成浅色 */

html[data-theme="dark"] .icon img {
    filter: brightness(0) invert(1);
}


/* 基础 */

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--background);
}

body {
    margin: 0;
    min-height: 100%;

    background: var(--background);
    color: var(--on-background);

    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;

    -webkit-font-smoothing: antialiased;
}


/* 页面 */

#app {
    width: min(100%, 1100px);

    margin: 0 auto;

    padding:
        52px
        24px
        72px;
}


/* 分类 */

.section {
    margin-bottom: var(--section-gap);
}

.section:last-child {
    margin-bottom: 0;
}


/* 分类标题 */

.section-title {
    margin: 0 0 22px;

    font-size: 20px;
    line-height: 28px;

    font-weight: 600;
    letter-spacing: 0;

    color: var(--on-background);
}


/* 书签网格 */

.bookmarks {
    display: grid;

    grid-template-columns:
        repeat(auto-fill, var(--item-width));

    column-gap: var(--column-gap);
    row-gap: var(--row-gap);

    justify-content: start;
}


/* 单个书签 */

.bookmark {
    width: var(--item-width);

    display: flex;
    flex-direction: column;
    align-items: center;

    gap: 8px;

    padding: 0;
    margin: 0;

    border: 0;

    background: transparent;
    color: inherit;

    font: inherit;

    cursor: pointer;
    text-decoration: none;
}


/* 图标圆 */

.icon {
    width: var(--icon-size);
    height: var(--icon-size);

    flex-shrink: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: var(--icon-background);
    color: var(--icon-color);

    transition:
        background-color 160ms ease,
        color 160ms ease,
        transform 100ms ease;
}


/* Arcticons SVG */

.icon img {
    display: block;

    width: var(--icon-symbol-size);
    height: var(--icon-symbol-size);

    flex-shrink: 0;

    object-fit: contain;
}


/* 书签文字 */

.label {
    width: 100%;

    font-size: 13px;
    line-height: 18px;

    text-align: center;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    color: var(--on-background);
}


/* 鼠标悬停 */

.bookmark:hover .icon {
    background: var(--primary-container);
    color: var(--on-primary-container);
}


/* 点击 */

.bookmark:active .icon {
    background: var(--primary);
    color: var(--on-primary);

    transform: scale(0.94);
}


/* 键盘焦点 */

.bookmark:focus-visible {
    outline: none;
}

.bookmark:focus-visible .icon {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
}


/* 手机 */

@media (max-width: 600px) {

    #app {
        width: 100%;

        padding:
            36px
            18px
            56px;
    }


    .section {
        margin-bottom: 48px;
    }


    .section-title {
        margin-bottom: 20px;

        font-size: 20px;
        line-height: 28px;

        font-weight: 600;
    }


    .bookmarks {
        grid-template-columns:
            repeat(4, minmax(0, 1fr));

        column-gap: 8px;
        row-gap: 28px;
    }


    .bookmark {
        width: 100%;
    }
}

/* ============================================================
   顶部主题按钮
   ============================================================ */


.top-bar {

    width: 100%;

    display: flex;

    justify-content: flex-end;

    padding:

        18px

        18px

        0;

}



.theme-toggle {

    width: 42px;

    height: 42px;


    display: flex;

    align-items: center;

    justify-content: center;


    padding: 0;


    border: none;

    border-radius: 50%;


    background: var(--theme-button-background);


    cursor: pointer;


    transition:

        transform 120ms ease,

        filter 160ms ease;

}



.theme-toggle:active {

    transform: scale(0.92);

}



.theme-toggle img {

    width: 24px;

    height: 24px;


    object-fit: contain;

}

/* 主题按钮 SVG 深色适配 */

html[data-theme="dark"] .theme-toggle img {

    filter: brightness(0) invert(1);

}


@media (prefers-color-scheme: dark) {

    html:not([data-theme]) .theme-toggle img {

        filter: brightness(0) invert(1);

    }

}