/* ==========================================================
   upx8wiki · library
   收藏夹页（/library.html）
   数据全在 localStorage，这里只管排版
   ========================================================== */

.lib {
    /* 只写上下内边距。写成 padding: 28px 0 60px 会把 .wrap 的左右 24px 抹成 0，
       视口一窄内容就直接贴边，这是「没做自适应」的第一层原因 */
    padding-top: 28px;
    padding-bottom: 60px;
    /* 收藏列表是单行标题，900 比正文的 820 略宽一点，宽屏不显空、窄屏也不挤 */
    max-width: 900px;
}

.lib-hd {
    margin-bottom: 18px;
}

.lib-t {
    margin: 0 0 8px;
    /* 26 在桌面刚好，21 在手机刚好，中间交给视口连续过渡，省一个断点 */
    font-size: clamp(21px, 2.6vw, 26px);
    font-weight: 700;
    letter-spacing: -.2px;
    color: var(--tx);
}

.lib-sub {
    margin: 0;
    font-size: 13.5px;
    color: var(--tx-3);
}

.lib-intro {
    margin-bottom: 20px;
    font-size: 14.5px;
    color: var(--tx-2);
}

/* ---------------- 工具条 ---------------- */

.lib-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
}

.lib-count {
    font-size: 13px;
    color: var(--tx-2);
    font-variant-numeric: tabular-nums;
}

.lib-acts {
    display: flex;
    gap: 8px;
}

.lib-btn {
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    color: var(--tx-2);
    font-family: inherit;
    font-size: 12.5px;
    line-height: 1.4;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}

.lib-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.lib-btn--warn:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* ---------------- 列表 ---------------- */

.lib-list {
    display: grid;
    gap: 10px;
    /* grid/flex 子项默认 min-width:auto，内容再长也会把轨道顶宽，必须显式归零 */
    min-width: 0;
}

.lib-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
    transition: border-color .15s, background .15s;
}

.lib-item:hover {
    border-color: var(--accent);
    background: var(--surface-2);
}

.lib-a {
    flex: 1;
    min-width: 0;
    text-decoration: none;
}

.lib-it {
    display: block;
    margin: 0 0 4px;
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--tx);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lib-item:hover .lib-it {
    color: var(--accent);
}

.lib-iu {
    display: block;
    font-size: 11.5px;
    color: var(--tx-4);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lib-side {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: none;
}

.lib-date {
    font-size: 11.5px;
    color: var(--tx-3);
    font-variant-numeric: tabular-nums;
}

.lib-del {
    padding: 4px 9px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background: none;
    color: var(--tx-4);
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}

.lib-del:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* ---------------- 空态 ---------------- */

.lib-empty {
    padding: 56px 20px;
    text-align: center;
    border: 1px dashed var(--line);
    border-radius: var(--r);
    background: var(--surface);
}

.lib-empty svg {
    width: 34px;
    height: 34px;
    margin-bottom: 10px;
    fill: none;
    stroke: var(--tx-4);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.lib-empty-t {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 600;
    color: var(--tx-2);
}

.lib-empty-s {
    margin: 0 0 14px;
    font-size: 13px;
    color: var(--tx-3);
}

.lib-empty-l {
    font-size: 13px;
    color: var(--accent);
    text-decoration: none;
}

.lib-empty-l:hover {
    text-decoration: underline;
}

.lib-note {
    margin: 18px 0 0;
    font-size: 12px;
    line-height: 1.7;
    color: var(--tx-4);
}

/* 860 而不是 760：卡片是 900 封顶，视口掉到 950 以下横排就开始截标题，
   768/820 这类平板竖屏走竖排能读全两行标题。只影响本页，不动全局断点 */
@media (max-width: 860px) {
    .lib {
        padding-top: 18px;
        padding-bottom: 28px;
    }

    .lib-hd {
        margin-bottom: 14px;
    }

    .lib-intro {
        margin-bottom: 16px;
    }

    .lib-bar {
        padding: 10px 12px;
        gap: 10px;
    }

    /* 竖排时子项默认是 stretch，一旦写成 flex-start 子项就退化成「内容宽度」，
       标题的 nowrap 会把整张卡片撑出视口 —— 别加 align-items */
    .lib-item {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 13px 14px;
    }

    /* 竖排后 flex 已无意义，用 width 把行宽锁死在容器内 */
    .lib-a {
        flex: none;
        width: 100%;
        min-width: 0;
    }

    /* 窄屏标题折两行，比截断更能看清是什么；overflow-wrap 兜住没有空格的长串 */
    .lib-it {
        white-space: normal;
        overflow-wrap: anywhere;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        overflow: hidden;
    }

    .lib-iu {
        max-width: 100%;
    }

    .lib-side {
        width: 100%;
        justify-content: space-between;
        gap: 12px;
    }

    .lib-date,
    .lib-del {
        flex: none;
    }

    .lib-acts {
        width: 100%;
        gap: 8px;
    }

    /* 三个按钮等分一行，min-width:0 防止文字把按钮顶宽 */
    .lib-btn {
        flex: 1 1 0;
        min-width: 0;
        padding: 8px 6px;
        text-align: center;
    }

    .lib-empty {
        padding: 40px 16px;
    }

    .lib-empty-s {
        margin-bottom: 12px;
    }

    .lib-note {
        margin-top: 14px;
    }
}
