/* SoftShop DPK Library — Clean Production Styles */

.library-page {
    direction: rtl;
    width: min(1400px, calc(100% - 48px));
    margin: 0 auto;
    padding: 32px 0 64px;
    box-sizing: border-box;
}

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

.library-heading h1 {
    margin: 6px 0 0;
    font-size: 34px;
}

.library-kicker {
    color: #55d6be;
    font-size: 12px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
}

.library-primary,
.library-secondary,
.library-remove,
.library-reader-button,
.library-collection-chip {
    font: inherit;
    cursor: pointer;
}

.library-primary,
.library-secondary,
.library-reader-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border: 0;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 700;
}

.library-primary {
    background: #55d6be;
    color: #07120f;
}

.library-secondary {
    background: #242a35;
    color: #f4f6fa;
}

.library-reader-button {
    width: 100%;
    box-sizing: border-box;
    background: #fff;
    color: #111827;
}

.library-primary:disabled,
.library-secondary:disabled,
.library-remove:disabled {
    opacity: .6;
    cursor: wait;
}

.library-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) repeat(5, minmax(130px, 1fr)) auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 18px;
}

.library-toolbar input,
.library-toolbar select {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    box-sizing: border-box;
    padding: 9px 12px;
    border: 1px solid #2b3240;
    border-radius: 10px;
    background: #171b23;
    color: #f4f6fa;
    font: inherit;
}

.library-favorite-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 9px 12px;
    border: 1px solid #2b3240;
    border-radius: 10px;
    background: #171b23;
    color: #c6cedb;
    white-space: nowrap;
    box-sizing: border-box;
}

.library-collection-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 18px 0 28px;
}

.library-collection-bar > div {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.library-collection-chip {
    padding: 7px 12px;
    border: 1px solid #354052;
    border-radius: 999px;
    background: #1d232d;
    color: #d7deea;
}

.library-import-status,
.library-status,
.library-error,
.library-empty {
    border: 1px solid #2b3240;
    border-radius: 16px;
    background: #171b23;
}

.library-import-status,
.library-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 18px;
    color: #b9c2d1;
}

.library-import-status {
    margin-bottom: 20px;
}

.library-error,
.library-empty {
    padding: 40px 24px;
    text-align: center;
}

.library-error {
    border-color: #56333c;
}

.library-error strong {
    color: #ffb0bc;
}

.library-error p {
    color: #aeb7c6;
}

.library-empty-icon {
    display: grid;
    place-items: center;
    width: 84px;
    height: 84px;
    margin: 0 auto 18px;
    border-radius: 24px;
    background: #252c39;
    color: #55d6be;
    font-weight: 900;
}

.library-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #394252;
    border-top-color: #55d6be;
    border-radius: 50%;
    animation: library-spin .8s linear infinite;
}

@keyframes library-spin {
    to { transform: rotate(360deg); }
}

.library-section {
    width: 100%;
    margin: 0 0 34px;
}

.library-section > h2 {
    margin: 0 0 14px;
    font-size: 20px;
}

.library-all-section {
    margin-top: 12px;
}

/* Horizontal shelves */
.library-row {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(210px, 240px);
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 10px;
    scroll-snap-type: x proximity;
}

.library-row .library-card {
    scroll-snap-align: start;
}

/* Main library grid */
.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 22px;
    align-items: start;
}

/* Cards */
.library-card {
    position: relative;
    min-width: 0;
    overflow: hidden;
    border: 1px solid #2b3240;
    border-radius: 16px;
    background: #171b23;
    transition: opacity .18s ease, transform .18s ease;
}

.library-card-removing {
    opacity: 0;
    transform: scale(.97);
    pointer-events: none;
}

.library-cover {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    background: linear-gradient(145deg, #252c39, #11141a);
    color: #55d6be;
    font-size: 28px;
    font-weight: 800;
}

.library-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.library-favorite {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 50%;
    background: rgba(7,10,15,.76);
    color: #fff;
    font-size: 23px;
    line-height: 1;
    cursor: pointer;
}

.library-favorite.is-active {
    color: #ffd76a;
}

.library-card-body {
    padding: 17px;
}

.library-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: #8792a5;
    font-size: 12px;
}

.library-card h3 {
    margin: 10px 0 5px;
    font-size: 18px;
    overflow-wrap: anywhere;
}

.library-author {
    margin: 0 0 12px;
    color: #8f99aa;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.library-progress {
    height: 6px;
    overflow: hidden;
    border-radius: 99px;
    background: #303746;
}

.library-progress i {
    display: block;
    height: 100%;
    background: #55d6be;
}

.library-card small {
    display: block;
    margin: 8px 0 15px;
    color: #8792a5;
}

.library-card-actions {
    display: grid;
    gap: 9px;
}

.library-card-actions .library-secondary,
.library-remove {
    width: 100%;
    box-sizing: border-box;
}

.library-remove {
    padding: 9px 12px;
    border: 1px solid #4a3139;
    border-radius: 9px;
    background: transparent;
    color: #e99aa9;
}

.library-remove:hover {
    border-color: #75404c;
    background: #2a1d22;
}

[hidden] {
    display: none !important;
}

@media (max-width: 1200px) {
    .library-toolbar {
        grid-template-columns: repeat(3, minmax(150px, 1fr));
    }
}

@media (max-width: 700px) {
    .library-page {
        width: calc(100% - 24px);
    }

    .library-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .library-heading .library-primary {
        width: 100%;
    }

    .library-toolbar {
        grid-template-columns: 1fr 1fr;
    }

    .library-favorite-filter {
        grid-column: span 2;
    }

    .library-row {
        grid-auto-columns: minmax(190px, 72vw);
    }

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

@media (max-width: 480px) {
    .library-toolbar {
        grid-template-columns: 1fr;
    }

    .library-favorite-filter {
        grid-column: auto;
    }

    .library-grid {
        grid-template-columns: 1fr;
    }
}

/* Smart Library Card v2 */
.library-state-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 10px;
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 999px;
    background: rgba(7, 10, 15, .82);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    backdrop-filter: blur(8px);
}

.library-state-new .library-state-badge {
    color: #55d6be;
}

.library-state-reading .library-state-badge {
    color: #ffd76a;
}

.library-state-finished .library-state-badge {
    color: #a9d2ff;
}

.library-card-action-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    gap: 8px;
    align-items: stretch;
}

.library-menu-trigger {
    display: inline-grid;
    place-items: center;
    width: 42px;
    min-height: 42px;
    padding: 0;
    border: 1px solid #354052;
    border-radius: 10px;
    background: #242a35;
    color: #f4f6fa;
    font: inherit;
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
}

.library-menu-trigger:hover,
.library-menu-trigger[aria-expanded="true"] {
    border-color: #55d6be;
    background: #29313c;
}

.library-card-menu {
    display: grid;
    gap: 4px;
    margin-top: 8px;
    padding: 6px;
    border: 1px solid #354052;
    border-radius: 12px;
    background: #11161e;
    box-shadow: 0 14px 30px rgba(0, 0, 0, .24);
}

.library-card-menu[hidden] {
    display: none !important;
}

.library-menu-item {
    width: 100%;
    min-height: 38px;
    padding: 8px 11px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #dce3ee;
    font: inherit;
    text-align: right;
    cursor: pointer;
}

.library-menu-item:hover {
    background: #242a35;
}

.library-menu-item.is-danger {
    color: #f0a0ae;
}

.library-menu-item.is-danger:hover {
    background: #2a1d22;
}

.library-card-compact .library-card-body {
    padding: 14px;
}

.library-card-compact .library-card-menu {
    font-size: 13px;
}

@media (max-width: 700px) {
    .library-state-badge {
        top: 9px;
        right: 9px;
    }

    .library-card-action-row {
        grid-template-columns: minmax(0, 1fr) 44px;
    }
}


/* Smart Library Card v2.1 fixes */
.library-state-badge {
    top: auto;
    right: 12px;
    bottom: 12px;
}

.library-cover-menu-trigger {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 4;
    width: 38px;
    min-height: 38px;
    border-color: rgba(255,255,255,.22);
    border-radius: 50%;
    background: rgba(7,10,15,.78);
    backdrop-filter: blur(8px);
}

.library-cover-favorite {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 4;
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 50%;
    background: rgba(7,10,15,.78);
    color: #fff;
    font: inherit;
    font-size: 23px;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(8px);
}

.library-cover-favorite.is-active {
    border-color: rgba(255,215,106,.7);
    color: #ffd76a;
    box-shadow: 0 0 0 3px rgba(255,215,106,.12);
}

.library-card-actions {
    position: static;
}

.library-card-action-row {
    grid-template-columns: 1fr;
}

.library-card-menu {
    position: absolute;
    top: 54px;
    left: 16px;
    z-index: 20;
    width: min(220px, calc(100% - 32px));
    margin-top: 0;
}

.library-card:has(.library-card-menu.is-open) {
    overflow: visible;
    z-index: 30;
}

@media (max-width: 700px) {
    .library-state-badge {
        top: auto;
        right: 9px;
        bottom: 9px;
    }

    .library-cover-menu-trigger,
    .library-cover-favorite {
        top: 8px;
    }

    .library-cover-menu-trigger { left: 8px; }
    .library-cover-favorite { right: 8px; }
}

/* DM-01 — Device-local package states */
.library-state-cloud .library-state-badge {
    background: rgba(35, 48, 68, .92);
    color: #d8e5ff;
}

.library-state-downloading .library-state-badge {
    background: rgba(19, 78, 74, .94);
    color: #b8fff2;
}

.library-state-update .library-state-badge {
    background: rgba(92, 63, 18, .94);
    color: #ffe29a;
}

.library-state-error .library-state-badge {
    background: rgba(92, 30, 42, .94);
    color: #ffc0ca;
}

.library-reader-button:disabled {
    opacity: .68;
    cursor: wait;
}

/* CHAKADFLOW public catalog adapter v2 */
.chakad-library-shell { padding-bottom: 24px; }
.chakad-library-heading { padding: 24px 28px; border: 1px solid rgba(145,83,255,.32); border-radius: 22px; background: linear-gradient(135deg, rgba(69,30,116,.52), rgba(8,14,27,.94) 55%); }
.chakad-library-intro { max-width: 720px; margin: 12px 0 0; color: #aeb8c9; line-height: 1.9; }
.chakad-section-heading { display:flex; align-items:center; justify-content:space-between; gap:14px; margin-bottom:16px; }
.chakad-section-heading h2 { margin:0; }
.library-count-badge { display:inline-flex; align-items:center; min-height:30px; padding:4px 11px; border:1px solid rgba(85,214,190,.3); border-radius:999px; color:#55d6be; background:rgba(85,214,190,.08); font-size:12px; }
.chakad-public-catalog { margin-top: 28px; }
.chakad-public-card .library-card-body { display:flex; flex-direction:column; min-height:225px; }
.chakad-public-card .library-reader-button { margin-top:auto; }
.chakad-public-facts { display:flex; justify-content:space-between; gap:10px; margin:4px 0 12px; color:#8792a5; font-size:12px; }
.chakad-public-description { margin:0 0 16px; color:#aeb7c6; font-size:13px; line-height:1.8; display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }
.chakad-personal-library { padding-top: 22px; border-top:1px solid rgba(255,255,255,.08); }
.chakad-personal-library .library-heading h2 { margin:6px 0 0; font-size:30px; }
.chakad-library-dialog { position:fixed; inset:0; z-index:9999; display:grid; place-items:center; padding:20px; background:rgba(3,7,14,.76); backdrop-filter:blur(8px); }
.chakad-library-dialog-panel { position:relative; width:min(520px,100%); padding:28px; border:1px solid #354052; border-radius:18px; background:#131923; color:#f4f6fa; box-shadow:0 30px 80px rgba(0,0,0,.48); }
.chakad-library-dialog-close { position:absolute; top:12px; left:12px; width:36px; height:36px; border:1px solid #354052; border-radius:50%; background:#242a35; color:#fff; font-size:24px; cursor:pointer; }
.chakad-library-dialog-panel h2 { margin:0 0 14px; padding-left:42px; }
.chakad-library-dialog-panel p { color:#aeb7c6; line-height:1.8; }
.chakad-library-dialog-panel dl { display:grid; gap:8px; margin:18px 0 0; }
.chakad-library-dialog-panel dl div { display:flex; justify-content:space-between; gap:18px; padding:10px 0; border-bottom:1px solid #29313c; }
.chakad-library-dialog-panel dt { color:#8792a5; }
.chakad-library-dialog-panel dd { margin:0; color:#fff; }
@media (max-width:700px){ .chakad-library-heading{padding:20px}.chakad-section-heading{align-items:flex-start;flex-direction:column}.chakad-public-card .library-card-body{min-height:0} }

/* CHAKAD Library Engine v3: public favorites */
.chakad-public-heading-actions{display:flex;align-items:center;gap:12px;flex-wrap:wrap}
.chakad-public-favorite-filter{margin:0}
.chakad-public-card[hidden]{display:none!important}
.library-cover-favorite:disabled{opacity:.55;cursor:wait}

/* CHAKAD Library Engine v3.3 — visible public-card states */
.chakad-public-card .library-card-menu a.library-menu-item {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 11px 13px;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: right;
    text-decoration: none;
    font: inherit;
}

.chakad-public-card .library-progress {
    margin-top: 14px;
}

.chakad-public-progress-label {
    display: block;
    margin: 7px 0 12px;
    color: #8f99aa;
    font-size: 12px;
}

.chakad-public-card[data-owned-item-id]:not([data-owned-item-id="0"]) .library-state-badge {
    background: rgba(85, 214, 190, .16);
    color: #6ee7cf;
    border-color: rgba(85, 214, 190, .35);
}

/* CHAKAD Library Engine v3.4 — functional card */
.chakad-public-grid{grid-template-columns:repeat(auto-fill,minmax(250px,290px));justify-content:flex-start;gap:22px}
.chakad-public-card{overflow:hidden;min-height:0}
.chakad-public-card .library-cover{aspect-ratio:4/5;min-height:290px}
.chakad-public-card .library-card-body{min-height:250px}
.chakad-public-card .library-progress{margin-top:auto}
.library-add-button{border:0;font:inherit;cursor:pointer}
.library-add-button:disabled{opacity:.65;cursor:wait}
@media(max-width:700px){.chakad-public-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.chakad-public-card .library-cover{min-height:230px}}
@media(max-width:480px){.chakad-public-grid{grid-template-columns:1fr}.chakad-public-card .library-cover{min-height:300px}}


/* CHAKAD Library — Phase 2 publication card */
.library-grid {
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 22px;
}

.library-card {
    overflow: visible;
    border: 1px solid rgba(125, 139, 166, .18);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(25, 30, 40, .96), rgba(18, 22, 30, .98));
    box-shadow: 0 12px 34px rgba(2, 6, 14, .18);
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.library-card:hover {
    transform: translateY(-3px);
    border-color: rgba(85, 214, 190, .34);
    box-shadow: 0 18px 42px rgba(2, 6, 14, .28);
}

.library-cover {
    border-radius: 17px 17px 0 0;
    background: linear-gradient(145deg, #252c39, #11141a);
}

.library-cover::after {
    content: '';
    position: absolute;
    inset: auto 0 0;
    height: 30%;
    background: linear-gradient(180deg, transparent, rgba(4, 7, 12, .38));
    pointer-events: none;
}

.library-cover img {
    transition: transform .28s ease;
}

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

.library-cover-fallback {
    position: relative;
    z-index: 1;
    letter-spacing: .16em;
    font-size: 20px;
    color: #55d6be;
}

.library-state-badge {
    position: absolute;
    z-index: 3;
    right: 12px;
    bottom: 12px;
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 10px;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 999px;
    background: rgba(8, 12, 18, .74);
    backdrop-filter: blur(10px);
    color: #eef4f8;
    font-size: 11px;
    font-weight: 700;
}

.library-cover-favorite,
.library-cover-menu-trigger {
    position: absolute;
    z-index: 4;
    top: 12px;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 50%;
    background: rgba(7, 10, 15, .72);
    backdrop-filter: blur(10px);
    color: #fff;
    cursor: pointer;
    transition: background .18s ease, transform .18s ease, color .18s ease;
}

.library-cover-favorite { left: 12px; font-size: 21px; }
.library-cover-menu-trigger { right: 12px; font-size: 24px; line-height: 1; }
.library-cover-favorite:hover,
.library-cover-menu-trigger:hover { background: rgba(14, 20, 29, .92); transform: translateY(-1px); }
.library-cover-favorite.is-active { color: #ffd76a; }

.library-card-body {
    padding: 16px 16px 17px;
}

.library-meta {
    align-items: center;
    min-height: 25px;
    color: #8f9aac;
}

.library-category-label {
    display: inline-flex;
    align-items: center;
    max-width: 58%;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(85, 214, 190, .09);
    color: #7de2cf;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-card h3 {
    min-height: 48px;
    margin: 12px 0 3px;
    color: #f4f7fb;
    font-size: 18px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.library-author {
    min-height: 21px;
    margin-bottom: 15px;
    color: #98a3b4;
}

.library-progress {
    height: 5px;
    margin-top: 3px;
    background: rgba(130, 144, 168, .2);
}

.library-progress i {
    background: linear-gradient(90deg, #55d6be, #7c6cf2);
}

.library-progress-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 29px;
}

.library-progress-row small,
.library-card small {
    margin: 7px 0 10px;
    color: #929cad;
}

.library-card-actions {
    position: relative;
    display: block;
}

.library-reader-button {
    min-height: 43px;
    border: 1px solid rgba(85, 214, 190, .2);
    border-radius: 11px;
    background: linear-gradient(135deg, #f8fbff, #e9f7f4);
    color: #101821;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .12);
    transition: transform .18s ease, box-shadow .18s ease;
}

.library-reader-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 11px 25px rgba(0, 0, 0, .18);
}

.library-reader-button:disabled {
    opacity: .68;
    cursor: wait;
}

.library-card-menu {
    position: absolute;
    z-index: 20;
    top: 54px;
    right: 12px;
    min-width: 190px;
    overflow: hidden;
    border: 1px solid rgba(132, 145, 168, .22);
    border-radius: 13px;
    background: rgba(20, 25, 34, .98);
    box-shadow: 0 18px 40px rgba(0, 0, 0, .34);
    backdrop-filter: blur(14px);
}

.library-card-menu.is-open { display: block; }

.library-menu-item {
    display: flex;
    width: 100%;
    min-height: 40px;
    align-items: center;
    padding: 9px 13px;
    border: 0;
    border-bottom: 1px solid rgba(255,255,255,.055);
    background: transparent;
    color: #dce3ec;
    text-decoration: none;
    text-align: right;
    font: inherit;
    cursor: pointer;
}

.library-menu-item:last-child { border-bottom: 0; }
.library-menu-item:hover { background: rgba(85, 214, 190, .08); color: #fff; }
.library-menu-item.is-danger { color: #f0a6b4; }

@media (max-width: 700px) {
    .library-card h3 { min-height: auto; }
    .library-card-body { padding: 13px; }
    .library-state-badge { right: 9px; bottom: 9px; }
    .library-cover-favorite { left: 9px; }
    .library-cover-menu-trigger { right: 9px; }
}

/* CHAKAD Library Phase 2 — Publication Card (actual implementation) */
.chakad-unified-grid {
    grid-template-columns: repeat(auto-fill, minmax(224px, 1fr));
    gap: 24px;
}

.chakad-public-card {
    overflow: visible;
    border: 1px solid rgba(139, 92, 246, .15);
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(24, 29, 41, .96), rgba(15, 19, 29, .98));
    box-shadow: 0 12px 34px rgba(0, 0, 0, .16);
    transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
}

.chakad-public-card:hover {
    transform: translateY(-4px);
    border-color: rgba(139, 92, 246, .38);
    box-shadow: 0 20px 50px rgba(0, 0, 0, .28);
}

.chakad-public-card .library-cover {
    width: calc(100% - 20px);
    min-height: 0;
    margin: 10px 10px 0;
    aspect-ratio: 4 / 5;
    border-radius: 14px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05);
}

.chakad-public-card .library-cover img {
    transform: scale(1.001);
    transition: transform .28s ease;
}

.chakad-public-card:hover .library-cover img {
    transform: scale(1.035);
}

.library-cover-scrim {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(3, 7, 18, .12) 48%, rgba(3, 7, 18, .74) 100%);
}

.chakad-public-card .library-state-badge {
    right: 12px;
    bottom: 12px;
    z-index: 3;
    min-height: 26px;
    padding: 3px 9px;
    border-color: rgba(255, 255, 255, .13);
    background: rgba(12, 17, 27, .78);
    color: #f1f5f9;
    font-size: 10px;
    backdrop-filter: blur(12px);
}

.chakad-public-card.is-owned .library-state-badge,
.chakad-public-card.library-state-reading .library-state-badge,
.chakad-public-card.library-state-finished .library-state-badge {
    border-color: rgba(45, 212, 191, .24);
    background: rgba(15, 71, 68, .82);
    color: #ccfbf1;
}

.chakad-public-card .library-cover-favorite,
.chakad-public-card .library-cover-menu-trigger {
    top: 12px;
    width: 36px;
    min-height: 36px;
    height: 36px;
    border-color: rgba(255, 255, 255, .14);
    background: rgba(12, 17, 27, .72);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
    backdrop-filter: blur(12px);
}

.chakad-public-card .library-cover-favorite { right: 12px; }
.chakad-public-card .library-cover-menu-trigger { left: 12px; }

.chakad-public-card .library-cover-favorite:hover,
.chakad-public-card .library-cover-menu-trigger:hover,
.chakad-public-card .library-cover-menu-trigger[aria-expanded="true"] {
    border-color: rgba(167, 139, 250, .64);
    background: rgba(47, 35, 78, .9);
}

.chakad-public-card .library-card-body {
    min-height: 0;
    padding: 14px 16px 16px;
}

.chakad-public-card .library-meta {
    align-items: center;
    min-height: 26px;
    color: #8792a5;
}

.chakad-public-card .library-category-label {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 9px;
    border: 1px solid rgba(139, 92, 246, .22);
    border-radius: 999px;
    background: rgba(139, 92, 246, .08);
    color: #c4b5fd;
    font-size: 11px;
    font-weight: 700;
}

.library-edition-label {
    color: #768196;
    font-size: 11px;
    direction: ltr;
    white-space: nowrap;
}

.library-card-copy {
    min-height: 70px;
}

.chakad-public-card h3 {
    display: -webkit-box;
    margin: 12px 0 6px;
    overflow: hidden;
    color: #f8fafc;
    font-size: 18px;
    line-height: 1.55;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.chakad-public-card .library-author {
    margin-bottom: 0;
    color: #98a3b5;
    font-size: 12px;
}

.library-reading-state {
    margin-top: 13px;
}

.chakad-public-card .library-progress {
    height: 5px;
    margin: 0;
    background: rgba(148, 163, 184, .16);
}

.chakad-public-card .library-progress i {
    background: linear-gradient(90deg, #8b5cf6, #2dd4bf);
}

.chakad-public-card .library-progress-row {
    display: flex;
    justify-content: flex-end;
    min-height: 25px;
}

.chakad-public-card .library-progress-row small {
    margin: 6px 0 0;
    color: #8f9bad;
    font-size: 11px;
}

.library-card-primary {
    margin-top: 14px;
}

.chakad-public-card .library-reader-button {
    min-height: 43px;
    border: 1px solid rgba(139, 92, 246, .4);
    border-radius: 11px;
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
    color: #fff;
    box-shadow: 0 9px 22px rgba(91, 33, 182, .22);
    transition: transform .18s ease, filter .18s ease, box-shadow .18s ease;
}

.chakad-public-card.is-owned .library-reader-button {
    border-color: rgba(45, 212, 191, .3);
    background: linear-gradient(135deg, #0f766e, #115e59);
    box-shadow: 0 9px 22px rgba(15, 118, 110, .18);
}

.chakad-public-card .library-reader-button:hover {
    transform: translateY(-1px);
    filter: brightness(1.08);
    box-shadow: 0 12px 28px rgba(91, 33, 182, .3);
}

.chakad-public-card .library-card-menu {
    top: 58px;
    left: 12px;
    width: min(230px, calc(100% - 24px));
    padding: 7px;
    border-color: rgba(139, 92, 246, .25);
    border-radius: 14px;
    background: rgba(15, 20, 31, .98);
    box-shadow: 0 22px 54px rgba(0, 0, 0, .46);
    backdrop-filter: blur(16px);
}

.chakad-public-card .library-menu-item {
    min-height: 40px;
    border-radius: 9px;
    color: #e2e8f0;
}

.chakad-public-card .library-menu-item:hover {
    background: rgba(139, 92, 246, .12);
}

@media (max-width: 700px) {
    .chakad-unified-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }

    .chakad-public-card .library-cover {
        width: calc(100% - 14px);
        margin: 7px 7px 0;
    }

    .chakad-public-card .library-card-body {
        padding: 12px;
    }

    .library-card-copy {
        min-height: 64px;
    }
}

@media (max-width: 480px) {
    .chakad-unified-grid {
        grid-template-columns: 1fr;
    }
}

/* CHAKAD Library — Phase 3 card refinement */
.chakad-public-card .library-cover,
.library-card .library-cover {
    position: relative;
    overflow: hidden;
}

.library-cover-copy {
    position: absolute;
    z-index: 3;
    right: 16px;
    left: 16px;
    bottom: 16px;
    min-width: 0;
    text-align: right;
    pointer-events: none;
}

.library-cover-copy h3,
.chakad-public-card .library-cover-copy h3 {
    min-height: 0;
    margin: 0 0 5px;
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.45;
    text-shadow: 0 2px 12px rgba(0, 0, 0, .72);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.library-cover-copy .library-author,
.chakad-public-card .library-cover-copy .library-author {
    min-height: 0;
    margin: 0;
    color: rgba(255, 255, 255, .78);
    font-size: 11px;
    line-height: 1.5;
    text-shadow: 0 1px 8px rgba(0, 0, 0, .8);
}

/* State/category/version remain in data-* attributes for filtering and search. */
.chakad-public-card .library-state-badge,
.chakad-public-card .library-meta,
.chakad-public-card .library-card-copy,
.chakad-public-card .library-reading-state {
    display: none !important;
}

.chakad-public-card .library-card-body {
    min-height: 0;
    padding: 10px;
}

.chakad-public-card .library-card-primary {
    margin: 0;
}

.library-reader-button {
    --button-progress: 0%;
    position: relative;
    overflow: hidden;
    gap: 10px;
    isolation: isolate;
}

.library-reader-button > span,
.library-reader-button > small {
    position: relative;
    z-index: 2;
}

.library-reader-button > small {
    margin: 0;
    color: currentColor;
    font-size: 11px;
    opacity: .82;
}

.library-reader-button::after,
.library-reader-button::before {
    content: '';
    position: absolute;
    z-index: 3;
    right: 0;
    bottom: 0;
    height: 4px;
    pointer-events: none;
}

.library-reader-button::after {
    left: 0;
    background: rgba(8, 15, 25, .22);
}

.library-reader-button::before {
    width: var(--button-progress);
    background: linear-gradient(90deg, #8b5cf6, #2dd4bf);
    transition: width .24s ease;
}

.library-reader-button:not(.has-progress)::before {
    width: 0;
}

.chakad-public-card .library-cover-favorite {
    right: 12px;
    left: auto;
}

.chakad-public-card .library-cover-menu-trigger {
    right: auto;
    left: 12px;
}

@media (max-width: 700px) {
    .library-cover-copy {
        right: 12px;
        left: 12px;
        bottom: 12px;
    }

    .library-cover-copy h3,
    .chakad-public-card .library-cover-copy h3 {
        font-size: 16px;
    }
}
