:root {
    --library-bg: #f6f7fb;
    --library-card: rgba(255, 255, 255, .96);
    --library-text: #181925;
    --library-muted: #76798c;
    --library-line: #e9eaf1;
    --library-primary: #7057c9;
    --library-primary-2: #8a68dc;
}

* { box-sizing: border-box; }

.library-body {
    margin: 0;
    color: var(--library-text);
    background:
        radial-gradient(circle at 10% 0%, rgba(111, 86, 202, .10), transparent 28rem),
        var(--library-bg);
    min-height: 100vh;
}

.library-shell,
.detail-shell {
    width: min(100%, 920px);
    margin: 0 auto;
    min-height: 100vh;
}

.library-topbar,
.detail-topbar {
    height: 68px;
    padding: max(10px, env(safe-area-inset-top)) 18px 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.detail-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    justify-content: space-between;
    background: rgba(246, 247, 251, .88);
    backdrop-filter: blur(16px);
}

.detail-topbar strong { font-size: 17px; }

.back-button,
.home-button {
    width: 40px;
    height: 40px;
    display: inline-grid;
    place-items: center;
    border-radius: 13px;
    color: #292a38;
    background: #fff;
    border: 1px solid var(--library-line);
    text-decoration: none;
    font-size: 23px;
    box-shadow: 0 7px 20px rgba(38, 34, 65, .06);
}

.home-button { font-size: 21px; }
.compact-brand { color: var(--library-text); text-decoration: none; }
.topbar-spacer { margin-left: auto; width: 40px; }

.category-hero {
    position: relative;
    overflow: hidden;
    min-height: 178px;
    margin: 8px 18px 18px;
    padding: 28px;
    border-radius: 28px;
    display: flex;
    align-items: center;
    gap: 22px;
    color: #fff;
    background: linear-gradient(135deg, #596eda, #6b5bc8 58%, #8c61cd);
    box-shadow: 0 22px 50px rgba(84, 68, 177, .24);
}

.category-hero::after {
    content: "";
    position: absolute;
    width: 220px;
    height: 220px;
    right: -80px;
    top: -100px;
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 50%;
    box-shadow: 0 0 0 34px rgba(255, 255, 255, .05), 0 0 0 72px rgba(255, 255, 255, .04);
}

.category-hero.theme-green { background: linear-gradient(135deg, #1b9b78, #39b67e); }
.category-hero.theme-amber { background: linear-gradient(135deg, #d88a22, #e9ae38); }
.category-hero.theme-violet { background: linear-gradient(135deg, #7554ca, #a258d0); }
.category-hero.theme-rose { background: linear-gradient(135deg, #c74373, #e05d70); }

.category-hero-icon {
    position: relative;
    z-index: 1;
    flex: 0 0 76px;
    width: 76px;
    height: 76px;
    padding: 17px;
    border-radius: 23px;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, .18);
    border: 1px solid rgba(255, 255, 255, .24);
    backdrop-filter: blur(10px);
}

.category-hero-icon svg { width: 100%; height: 100%; }
.category-hero > div { position: relative; z-index: 1; }
.category-hero p { margin: 0 0 5px; opacity: .72; font-size: 13px; }
.category-hero h1 { margin: 0; font-size: clamp(28px, 6vw, 40px); }
.category-hero div > span { display: block; margin-top: 7px; opacity: .84; }

.library-tools { padding: 0 18px 14px; }
.software-search {
    height: 50px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--library-line);
    border-radius: 17px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(38, 34, 65, .045);
}
.software-search svg { width: 20px; fill: none; stroke: #8b8d9c; stroke-width: 2; }
.software-search input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 15px; color: var(--library-text); }
.category-meta { padding: 12px 4px 0; color: var(--library-muted); font-size: 12px; }
.category-meta strong { color: var(--library-primary); }

.library-notice {
    margin: 2px 18px 14px;
    padding: 13px 15px;
    border-radius: 14px;
    color: #745e20;
    background: #fff7da;
    font-size: 13px;
}
.library-notice.is-error { display: grid; gap: 5px; color: #8d3346; background: #fff0f2; }
.library-notice a { color: inherit; font-weight: 700; }

.software-list { padding: 0 18px 36px; display: grid; gap: 11px; }
.software-card {
    min-width: 0;
    padding: 13px;
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--library-line);
    border-radius: 20px;
    background: var(--library-card);
    box-shadow: 0 9px 26px rgba(38, 34, 65, .04);
    transition: transform .18s ease, box-shadow .18s ease;
}
.software-card:hover { transform: translateY(-2px); box-shadow: 0 15px 34px rgba(38, 34, 65, .09); }
.software-card[hidden] { display: none; }

.software-icon-wrap,
.detail-icon-wrap {
    position: relative;
    overflow: hidden;
    flex: 0 0 62px;
    width: 62px;
    height: 62px;
    border-radius: 17px;
    background: linear-gradient(145deg, #f0edff, #ded7ff);
    box-shadow: inset 0 0 0 1px rgba(74, 60, 134, .09);
}
.software-icon-fallback { position: absolute; inset: 0; display: grid; place-items: center; color: var(--library-primary); font-size: 22px; font-weight: 800; }
.software-icon,
.detail-icon-wrap img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; }
.software-card-copy { min-width: 0; flex: 1; display: grid; gap: 4px; }
.software-card-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.software-card-copy > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--library-muted); font-size: 13px; }
.software-card-copy small { color: #989aaa; font-size: 11px; }
.software-card-arrow { color: #a4a5b3; font-size: 30px; font-weight: 300; }
.software-empty { display: none; padding: 60px 20px; text-align: center; color: var(--library-muted); }
.software-empty.is-visible { display: block; }
.load-more-sentinel {
    grid-column: 1 / -1;
    min-height: 48px;
    padding: 10px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: var(--library-muted);
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.load-more-sentinel[hidden] { display: none; }
.load-more-sentinel.is-finished { cursor: default; opacity: .78; }
.load-more-sentinel.is-error { color: #b53b54; }
.load-more-spinner {
    display: none;
    width: 17px;
    height: 17px;
    border: 2px solid #ddd7f5;
    border-top-color: var(--library-primary);
    border-radius: 50%;
    animation: library-spin .7s linear infinite;
}
.load-more-sentinel.is-loading .load-more-spinner { display: inline-block; }
@keyframes library-spin { to { transform: rotate(360deg); } }

.detail-body { background: #f5f5f8; }
.detail-shell { width: min(100%, 720px); padding-bottom: 112px; }
.detail-content { padding: 8px 16px 32px; display: grid; gap: 16px; }
.detail-card {
    border-radius: 22px;
    border: 1px solid var(--library-line);
    background: #fff;
    box-shadow: 0 10px 28px rgba(38, 34, 65, .045);
}
.app-summary-card { padding: 16px; display: flex; align-items: center; gap: 15px; }
.detail-icon-wrap { flex-basis: 68px; width: 68px; height: 68px; border-radius: 18px; }
.app-summary-copy { min-width: 0; }
.app-summary-copy h1 { margin: 0 0 9px; overflow-wrap: anywhere; font-size: 18px; }
.app-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.app-badges span { padding: 4px 9px; border-radius: 999px; color: var(--library-primary); background: #f1edff; font-size: 10px; }
.detail-card h2 { margin: 0; padding: 17px 17px 12px; font-size: 15px; }
.software-description { padding: 0 17px 18px; color: #555765; font-size: 14px; line-height: 1.78; overflow-wrap: anywhere; }
.screenshot-gallery { padding: 0 14px 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.screenshot-button { overflow: hidden; padding: 0; border: 0; border-radius: 14px; background: #f3f3f6; cursor: zoom-in; }
.screenshot-button img { display: block; width: 100%; height: auto; max-height: 620px; object-fit: contain; }
.no-screenshot { margin: 0; padding: 4px 17px 22px; color: var(--library-muted); font-size: 13px; }

.download-dock {
    position: fixed;
    z-index: 15;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: min(100%, 720px);
    padding: 12px 16px max(14px, env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, .94);
    border-top: 1px solid var(--library-line);
    backdrop-filter: blur(18px);
}
.download-actions { display: grid; grid-template-columns: minmax(112px, .38fr) minmax(160px, .62fr); gap: 10px; }
.download-button,
.share-button { height: 52px; border-radius: 26px; font-size: 15px; font-weight: 700; }
.download-button { display: grid; place-items: center; color: #fff; text-decoration: none; background: linear-gradient(100deg, var(--library-primary), var(--library-primary-2)); box-shadow: 0 12px 28px rgba(112, 87, 201, .28); }
.share-button { display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--library-primary); border: 1px solid #d8d0f2; background: #f4f0ff; cursor: pointer; }
.share-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.download-dock small { display: block; margin-top: 5px; text-align: center; color: #a0a1ae; font-size: 10px; }

.share-sheet { position: fixed; z-index: 70; inset: 0; display: flex; align-items: flex-end; justify-content: center; }
.share-sheet[hidden] { display: none; }
.share-sheet-backdrop { position: absolute; inset: 0; border: 0; background: rgba(15, 13, 23, .52); backdrop-filter: blur(3px); }
.share-sheet-panel {
    position: relative;
    width: min(100%, 720px);
    padding: 10px 18px max(24px, env(safe-area-inset-bottom));
    border-radius: 26px 26px 0 0;
    background: #fff;
    box-shadow: 0 -18px 50px rgba(25, 19, 50, .18);
    animation: share-sheet-in .22s ease-out;
}
.share-sheet-handle { display: block; width: 38px; height: 4px; margin: 0 auto 13px; border-radius: 3px; background: #dedee6; }
.share-sheet-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.share-sheet-header h2 { margin: 0; font-size: 19px; }
.share-sheet-header p { margin: 4px 0 0; color: var(--library-muted); font-size: 12px; }
.share-sheet-header > button { flex: 0 0 34px; width: 34px; height: 34px; border: 0; border-radius: 50%; color: #777887; background: #f3f3f6; font-size: 23px; line-height: 1; cursor: pointer; }
.share-options { margin-top: 20px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.share-options > button { min-width: 0; padding: 0; display: grid; justify-items: center; gap: 7px; color: #555765; border: 0; background: transparent; font-size: 12px; cursor: pointer; }
.share-app-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 17px; color: #fff; font-size: 20px; font-weight: 800; box-shadow: 0 7px 18px rgba(35, 31, 58, .1); }
.share-app-icon svg { width: 27px; height: 27px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.share-app-icon.is-qq { background: linear-gradient(145deg, #29a5f8, #147bdc); font-family: Arial, sans-serif; }
.share-app-icon.is-wechat { background: linear-gradient(145deg, #35cf70, #18a850); }
.share-app-icon.is-wechat svg { fill: none; }
.share-app-icon.is-douyin { color: #fff; background: linear-gradient(145deg, #22232a, #050506); text-shadow: -2px 0 #25f4ee, 2px 0 #fe2c55; }
.share-app-icon.is-douyin svg { filter: drop-shadow(-1px 0 #25f4ee) drop-shadow(1px 0 #fe2c55); }
.share-app-icon.is-more { color: #6d5cc8; background: #eeeafd; letter-spacing: 1px; }
.share-app-icon.is-copy { color: #565969; background: #f0f1f5; }
.share-status { min-height: 18px; margin: 18px 0 0; text-align: center; color: #9a9ba8; font-size: 11px; }
.share-status.is-success { color: #159556; }
.share-status.is-error { color: #c44059; }
.share-toast {
    position: fixed;
    z-index: 90;
    left: 50%;
    bottom: max(104px, calc(env(safe-area-inset-bottom) + 88px));
    transform: translate(-50%, 12px);
    width: max-content;
    max-width: calc(100% - 36px);
    padding: 11px 17px;
    border-radius: 22px;
    color: #fff;
    background: rgba(28, 27, 34, .92);
    box-shadow: 0 10px 28px rgba(15, 13, 23, .2);
    opacity: 0;
    pointer-events: none;
    font-size: 13px;
    transition: opacity .18s ease, transform .18s ease;
}
.share-toast[hidden] { display: none; }
.share-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
@keyframes share-sheet-in { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.detail-error { margin: 50px 20px; padding: 34px 20px; text-align: center; border-radius: 24px; background: #fff; }
.detail-error > span { display: inline-grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; color: #c43c58; background: #fff0f3; font-size: 25px; font-weight: 800; }
.detail-error h1 { margin: 18px 0 8px; font-size: 20px; }
.detail-error p { color: var(--library-muted); }
.detail-error a { display: inline-block; margin-top: 10px; color: var(--library-primary); font-weight: 700; }

.lightbox { position: fixed; z-index: 50; inset: 0; padding: 55px 14px 20px; background: rgba(8, 8, 12, .92); }
.lightbox[hidden] { display: none; }
.lightbox img { width: 100%; height: 100%; object-fit: contain; }
.lightbox button { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 16px; width: 42px; height: 42px; border: 0; border-radius: 50%; color: #fff; background: rgba(255, 255, 255, .14); font-size: 28px; }

@media (min-width: 700px) {
    .software-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .category-hero { padding: 34px 42px; }
}

@media (max-width: 480px) {
    .category-hero { min-height: 152px; padding: 22px; border-radius: 24px; }
    .category-hero-icon { flex-basis: 64px; width: 64px; height: 64px; border-radius: 19px; }
    .category-hero h1 { font-size: 27px; }
    .software-card { border-radius: 18px; }
    .share-app-icon { width: 48px; height: 48px; border-radius: 15px; }
    .share-options { gap: 3px; }
}
