:root {
    --library-accent: #7565de;
    --library-accent-deep: #5d4fc2;
    --library-ink: #171723;
    --library-muted: #6f7081;
    --library-line: #e8e7ee;
    --library-panel: rgba(255, 255, 255, 0.9);
    --library-shadow: 0 18px 50px rgba(35, 29, 74, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: light;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-width: 320px;
    color: var(--library-ink);
    background:
        radial-gradient(circle at 8% 7%, rgba(132, 111, 235, 0.11), transparent 25rem),
        linear-gradient(180deg, #faf9ff 0, #f7f7fa 34rem, #f6f6f8 100%);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(117, 101, 222, 0.28);
    outline-offset: 3px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.library-shell {
    width: min(1600px, calc(100% - 64px));
    margin: 0 auto;
}

.library-header {
    position: sticky;
    top: 0;
    z-index: 30;
    border-bottom: 1px solid rgba(232, 231, 238, 0.9);
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(18px);
}

.library-header-inner {
    display: flex;
    min-height: 68px;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
}

.library-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.library-brand img {
    display: block;
    border-radius: 10px;
}

.library-nav {
    display: flex;
    align-items: center;
    gap: 28px;
    color: var(--library-muted);
    font-size: 14px;
}

.library-nav a {
    position: relative;
    padding: 24px 0;
}

.library-nav a:hover,
.library-nav a[aria-current="page"] {
    color: var(--library-ink);
}

.library-nav a[aria-current="page"]::after {
    position: absolute;
    right: 0;
    bottom: 13px;
    left: 0;
    height: 3px;
    border-radius: 99px;
    background: var(--library-accent);
    content: "";
}

.library-main {
    min-height: 70vh;
    padding-top: 28px;
    padding-bottom: 70px;
}

.library-breadcrumb {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 28px;
    color: #8b8b98;
    font-size: 13px;
}

.library-breadcrumb a:hover {
    color: var(--library-accent-deep);
}

.library-intro {
    margin-bottom: 28px;
}

.library-eyebrow {
    margin: 0 0 12px;
    color: var(--library-accent-deep);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.18em;
}

.library-intro-copy {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}

.library-intro h1 {
    margin: 0;
    font-size: clamp(32px, 4.2vw, 58px);
    line-height: 1.08;
    letter-spacing: -0.035em;
}

.library-intro p:not(.library-eyebrow) {
    max-width: 680px;
    margin: 16px 0 0;
    color: var(--library-muted);
    font-size: 15px;
    line-height: 1.8;
}

.library-home-link {
    flex: 0 0 auto;
    padding: 11px 16px;
    border: 1px solid var(--library-line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: #4e4e5b;
    font-size: 13px;
    font-weight: 650;
}

.library-home-link:hover {
    border-color: rgba(117, 101, 222, 0.38);
    color: var(--library-accent-deep);
}

.library-controls {
    padding: 20px;
    border: 1px solid rgba(230, 228, 239, 0.86);
    border-radius: 22px;
    background: var(--library-panel);
    box-shadow: var(--library-shadow);
}

.library-tabs {
    display: flex;
    gap: 8px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--library-line);
}

.library-tabs button {
    min-height: 42px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 999px;
    color: #6b6b78;
    background: transparent;
    cursor: pointer;
    font-weight: 700;
}

.library-tabs button:hover {
    color: var(--library-ink);
    background: #f4f2ff;
}

.library-tabs button[aria-selected="true"] {
    color: #fff;
    background: var(--library-ink);
    box-shadow: 0 7px 18px rgba(23, 23, 35, 0.18);
}

.library-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 10px;
    margin-top: 18px;
}

.library-search input {
    width: 100%;
    min-height: 48px;
    padding: 0 16px;
    border: 1px solid #dedde6;
    border-radius: 14px;
    color: var(--library-ink);
    background: #fff;
}

.library-search input::placeholder {
    color: #a4a3ad;
}

.library-search button {
    min-height: 48px;
    padding: 0 20px;
    border: 0;
    border-radius: 14px;
    color: #fff;
    background: var(--library-accent);
    cursor: pointer;
    font-weight: 750;
}

.library-search button:hover {
    background: var(--library-accent-deep);
}

.library-search .library-search-clear {
    color: #5d5d69;
    background: #efeff4;
}

.library-search .library-search-clear:hover {
    background: #e5e5ec;
}

.library-color-filter {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 18px;
}

.library-filter-label {
    flex: 0 0 auto;
    color: #666673;
    font-size: 13px;
    font-weight: 700;
}

.library-color-list {
    display: flex;
    min-width: 0;
    gap: 9px;
    overflow-x: auto;
    padding: 4px;
    scrollbar-width: thin;
}

.library-color-button {
    position: relative;
    display: inline-flex;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid rgba(24, 24, 32, 0.12);
    border-radius: 50%;
    background: var(--swatch, #ddd);
    cursor: pointer;
}

.library-color-button[data-color="palette"] {
    background: conic-gradient(#ef4444, #facc15, #22c55e, #22d3ee, #3b82f6, #a855f7, #ef4444);
}

.library-color-button[aria-pressed="true"]::after {
    position: absolute;
    inset: -5px;
    border: 2px solid var(--library-accent);
    border-radius: inherit;
    content: "";
}

.library-color-button[data-color="white"] {
    border-color: #c8c8d0;
}

.library-color-red { --swatch: #ef4444; }
.library-color-orange { --swatch: #f97316; }
.library-color-yellow { --swatch: #facc15; }
.library-color-green { --swatch: #22c55e; }
.library-color-cyan { --swatch: #22d3ee; }
.library-color-blue { --swatch: #3b82f6; }
.library-color-purple { --swatch: #a855f7; }
.library-color-brown { --swatch: #92400e; }
.library-color-black { --swatch: #111827; }
.library-color-gray { --swatch: #9ca3af; }
.library-color-white { --swatch: #fff; }

.library-results {
    padding-top: 42px;
}

.library-results-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.library-results-heading h2 {
    margin: 0;
    font-size: clamp(24px, 3vw, 34px);
    letter-spacing: -0.025em;
}

.library-results-heading p {
    margin: 8px 0 0;
    color: var(--library-muted);
    font-size: 13px;
}

.library-results-heading > a {
    color: var(--library-accent-deep);
    font-size: 13px;
    font-weight: 700;
}

.library-results-heading > a:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
}

.library-status {
    padding: 52px 24px;
    border: 1px dashed #d7d5e1;
    border-radius: 18px;
    color: var(--library-muted);
    background: rgba(255, 255, 255, 0.65);
    text-align: center;
}

.library-status[hidden] {
    display: none;
}

.library-status.is-error {
    border-color: #f1caca;
    color: #a33c3c;
    background: #fff7f7;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}

.library-card {
    min-width: 0;
    grid-column: span 1;
    overflow: hidden;
    border: 1px solid rgba(226, 225, 232, 0.92);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 6px 20px rgba(28, 25, 43, 0.06);
    cursor: pointer;
    transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.library-card.is-horizontal {
    grid-column: span 2;
}

.library-card:hover {
    z-index: 1;
    border-color: rgba(117, 101, 222, 0.3);
    box-shadow: 0 14px 30px rgba(28, 25, 43, 0.13);
    transform: translateY(-4px);
}

.library-card-media {
    position: relative;
    width: 100%;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    background: linear-gradient(145deg, #f1f0f5, #fafafa);
}

.library-card.is-horizontal .library-card-media {
    aspect-ratio: 16 / 10;
}

.library-card-media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 260ms ease;
}

.library-card:hover img {
    transform: scale(1.025);
}

.library-card-media::after {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 70%, rgba(18, 17, 25, 0.05));
    content: "";
    pointer-events: none;
}

.library-card-fallback {
    opacity: 0.72;
}

.library-load-more-wrap {
    display: flex;
    justify-content: center;
    min-height: 58px;
    margin-top: 32px;
}

.library-load-more {
    min-width: 168px;
    min-height: 48px;
    padding: 0 24px;
    border: 1px solid #d9d7e3;
    border-radius: 999px;
    color: #4b465f;
    background: #fff;
    box-shadow: 0 7px 18px rgba(33, 29, 51, 0.07);
    cursor: pointer;
    font-weight: 750;
}

.library-load-more:hover {
    border-color: rgba(117, 101, 222, 0.45);
    color: var(--library-accent-deep);
}

.library-load-more:disabled {
    cursor: wait;
    opacity: 0.65;
}

.library-footer {
    border-top: 1px solid var(--library-line);
    background: #fff;
}

.library-footer-inner {
    display: flex;
    min-height: 84px;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    color: #777784;
    font-size: 13px;
}

.library-footer-inner nav {
    display: flex;
    gap: 22px;
}

.library-footer-inner a:hover {
    color: var(--library-ink);
}

@media (min-width: 768px) and (max-width: 1100px) {
    .library-shell {
        width: min(100% - 40px, 1120px);
    }

    .library-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .library-shell {
        width: calc(100% - 28px);
    }

    .library-header-inner {
        min-height: 60px;
    }

    .library-nav {
        gap: 16px;
    }

    .library-nav a {
        display: none;
        padding: 20px 0;
    }

    .library-nav a[aria-current="page"],
    .library-nav a:first-child {
        display: block;
    }

    .library-nav a[aria-current="page"]::after {
        bottom: 10px;
    }

    .library-main {
        padding-top: 20px;
        padding-bottom: 48px;
    }

    .library-breadcrumb {
        margin-bottom: 20px;
    }

    .library-intro-copy {
        display: block;
    }

    .library-intro h1 {
        font-size: clamp(32px, 11vw, 44px);
    }

    .library-home-link {
        display: inline-flex;
        margin-top: 18px;
    }

    .library-controls {
        padding: 15px;
        border-radius: 18px;
    }

    .library-tabs {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 5px;
    }

    .library-tabs button {
        min-width: 0;
        min-height: 40px;
        padding: 0 6px;
        font-size: 12px;
    }

    .library-search {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .library-search button {
        padding: 0 16px;
    }

    .library-search .library-search-clear {
        grid-column: 1 / -1;
        min-height: 40px;
    }

    .library-color-filter {
        display: block;
    }

    .library-filter-label {
        display: block;
        margin-bottom: 10px;
    }

    .library-color-button {
        width: 32px;
        height: 32px;
        flex-basis: 32px;
    }

    .library-results {
        padding-top: 34px;
    }

    .library-results-heading {
        display: block;
    }

    .library-results-heading > a {
        display: inline-flex;
        margin-top: 13px;
    }

    .library-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .library-card {
        border-radius: 11px;
    }

    .library-footer-inner {
        min-height: 110px;
        flex-direction: column;
        justify-content: center;
        align-items: flex-start;
        gap: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
