/* === Library Scene — Hotspot map, bookshelf overlay, donate dialog, desk === */

/* ─── CSS Fallback layout (no background image) ─── */
.library-fallback {
    width: 100%; height: 100%;
    position: relative;
    background: linear-gradient(180deg, #2A1A0A 0%, #3A2A1A 40%, #2A1A0A 100%);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.library-title {
    text-align: center;
    font-size: 22px;
    font-weight: bold;
    color: #D4B896;
    letter-spacing: 6px;
    padding: 14px 0 8px;
    text-shadow: 0 2px 8px rgba(180, 130, 60, 0.3);
}

.library-zones {
    flex: 1;
    display: flex;
    gap: 12px;
    padding: 8px 20px 16px;
    min-height: 0;
}

.library-zone {
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s;
    gap: 8px;
}
.library-zone:hover {
    transform: scale(1.03);
    filter: brightness(1.2);
}
.library-zone:active {
    transform: scale(0.98);
}

.library-zone--shelf {
    flex: 2;
    background: linear-gradient(180deg, #3A2A14, #2A1A0A);
    border: 2px solid #5A4A30;
    box-shadow: inset 0 0 40px rgba(150, 100, 30, 0.15), 0 4px 16px rgba(0, 0, 0, 0.4);
}

.library-zone-side {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.library-zone--donate {
    flex: 1;
    background: linear-gradient(180deg, #2A3A20, #1A2A14);
    border: 2px solid #3A5A30;
    box-shadow: inset 0 0 20px rgba(80, 160, 60, 0.1), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.library-zone--desk {
    flex: 1;
    background: linear-gradient(180deg, #1A2A40, #152030);
    border: 2px solid #2A4060;
    box-shadow: inset 0 0 20px rgba(50, 100, 200, 0.1), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.library-zone-icon {
    font-size: 36px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

.library-zone-label {
    font-size: 15px;
    color: #D4C0A8;
    letter-spacing: 3px;
    font-weight: bold;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* ─── Bookshelf overlay ─── */
.library-bookshelf-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.library-bookshelf-panel {
    width: 560px;
    max-width: 92%;
    max-height: 85%;
    background: #1A1410;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    border: 1px solid #3A2A1A;
}

.library-bookshelf-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: linear-gradient(180deg, #2A1A0E, #1A0E04);
    color: #D4B896;
    font-size: 15px;
    font-weight: bold;
    letter-spacing: 2px;
    border-bottom: 1px solid #5A4A30;
}

.library-bookshelf-close {
    background: none;
    border: none;
    color: #AAA;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
}
.library-bookshelf-close:hover {
    background: #FF4444;
    color: #FFF;
}

.library-book-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: #5A4A30 #1A1410;
}
.library-book-grid::-webkit-scrollbar { width: 5px; }
.library-book-grid::-webkit-scrollbar-track { background: #1A1410; }
.library-book-grid::-webkit-scrollbar-thumb { background: #5A4A30; border-radius: 3px; }

.library-bookshelf-empty {
    text-align: center;
    color: #666;
    padding: 40px 0;
    font-size: 14px;
    grid-column: 1 / -1;
}

.library-book-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    padding: 10px 8px;
    transition: all 0.2s;
    gap: 6px;
}
.library-book-card:hover {
    background: rgba(180, 130, 60, 0.15);
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}
.library-book-card:active {
    transform: translateY(-1px);
}

.library-book-cover {
    width: 120px;
    height: 160px;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #3A2A1A, #2A1A0E);
    border: 1px solid #4A3A2A;
    flex-shrink: 0;
}
.library-book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.library-book-cover-emoji {
    font-size: 48px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.library-book-name {
    font-size: 12px;
    color: #C8B090;
    text-align: center;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ─── Donate dialog ─── */
.library-donate-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.library-donate-panel {
    width: 400px;
    max-width: 90%;
    background: #1A1410;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    border: 1px solid #3A2A1A;
}

.library-donate-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: linear-gradient(180deg, #2A1A0E, #1A0E04);
    color: #D4B896;
    font-size: 15px;
    font-weight: bold;
    letter-spacing: 2px;
    border-bottom: 1px solid #5A4A30;
}

.library-donate-close {
    background: none;
    border: none;
    color: #AAA;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
}
.library-donate-close:hover {
    background: #FF4444;
    color: #FFF;
}

.library-donate-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.library-donate-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.library-donate-label {
    font-size: 13px;
    color: #C8B090;
    font-weight: bold;
}

.library-donate-input {
    padding: 8px 12px;
    border: 1px solid #5A4A30;
    border-radius: 6px;
    background: #2A1A0E;
    color: #E8D8B8;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.library-donate-input:focus {
    border-color: #8A7A50;
}

.library-donate-file-btn {
    padding: 8px 16px;
    border: 1px dashed #5A4A30;
    border-radius: 6px;
    background: rgba(42, 26, 14, 0.6);
    color: #C8B090;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}
.library-donate-file-btn:hover {
    background: rgba(90, 74, 48, 0.4);
    border-color: #8A7A50;
}
.library-donate-file-btn.selected {
    border-style: solid;
    border-color: #6A8A40;
    color: #A0D060;
}

.library-donate-preview {
    width: 100%;
    max-height: 160px;
    border-radius: 6px;
    overflow: hidden;
    display: none;
}
.library-donate-preview.visible {
    display: block;
}
.library-donate-preview img {
    width: 100%;
    max-height: 160px;
    object-fit: contain;
    display: block;
}

.library-donate-submit {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    background: linear-gradient(180deg, #5A7A3A, #4A6A2A);
    color: #E8F0D8;
    font-size: 14px;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 2px;
}
.library-donate-submit:hover {
    background: linear-gradient(180deg, #6A8A4A, #5A7A3A);
    transform: translateY(-1px);
}
.library-donate-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ─── Desk overlay (borrow/return) ─── */
.library-desk-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.library-desk-panel {
    width: 460px;
    max-width: 90%;
    max-height: 80%;
    background: #1A1410;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    border: 1px solid #3A2A1A;
}

.library-desk-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: linear-gradient(180deg, #2A1A0E, #1A0E04);
    color: #D4B896;
    font-size: 15px;
    font-weight: bold;
    letter-spacing: 2px;
    border-bottom: 1px solid #5A4A30;
}

.library-desk-close {
    background: none;
    border: none;
    color: #AAA;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
}
.library-desk-close:hover {
    background: #FF4444;
    color: #FFF;
}

.library-desk-list {
    overflow-y: auto;
    padding: 8px;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: #5A4A30 #1A1410;
}
.library-desk-list::-webkit-scrollbar { width: 5px; }
.library-desk-list::-webkit-scrollbar-track { background: #1A1410; }
.library-desk-list::-webkit-scrollbar-thumb { background: #5A4A30; border-radius: 3px; }

.library-desk-empty {
    text-align: center;
    color: #666;
    padding: 40px 0;
    font-size: 14px;
}

.library-desk-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin-bottom: 4px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: background 0.2s;
}
.library-desk-item:hover {
    background: rgba(180, 130, 60, 0.15);
}

.library-desk-item-name {
    flex: 1;
    color: #DDD;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-desk-item-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    background: #664422;
    color: #DDAA66;
    flex-shrink: 0;
}
.library-desk-item-badge--perm {
    background: #225544;
    color: #66DDAA;
}

.library-desk-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.library-desk-btn {
    width: 28px; height: 28px;
    border: none;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.08);
    color: #CCC;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.library-desk-btn:hover {
    transform: scale(1.1);
}
.library-desk-btn--save:hover {
    background: rgba(50, 180, 120, 0.3);
    color: #6FE0A0;
}
.library-desk-btn--del:hover {
    background: rgba(220, 60, 60, 0.3);
    color: #FF6666;
}

/* ─── Player overlay (reused from old library) ─── */
.lib-player-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lib-player-overlay.hidden { display: none; }

.lib-player-box {
    width: 85%;
    max-width: 780px;
    max-height: 90%;
    background: #1A1A2A;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
}

.lib-player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: #2A2A3A;
    color: #D4B896;
    font-size: 14px;
    font-weight: bold;
    border-bottom: 1px solid #3A3A4A;
}

.lib-player-close {
    background: none;
    border: none;
    color: #AAA;
    font-size: 18px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
}
.lib-player-close:hover {
    background: #FF4444;
    color: #FFF;
}

.lib-player-content {
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    min-height: 300px;
}

.lib-media {
    max-width: 100%;
    max-height: 420px;
    display: block;
}

/* ─── Scene NPC sprites (shared across public scenes) ─── */

/* NPC 容器 — 由 JS 动态定位到 .scene-npc-row 中 */
.scene-npc {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    z-index: 20;
    transition: transform 0.25s, filter 0.25s;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
}
.scene-npc:hover {
    transform: scale(1.08) translateY(-4px);
    filter: drop-shadow(0 6px 16px rgba(0,0,0,0.6));
}

/* 立绘展示行 — 底部居中排列 */
.scene-npc-row {
    position: absolute;
    bottom: 12px;
    right: 16px;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    z-index: 20;
}

/* 立绘图片 — 全身展示 */
.scene-npc-avatar {
    height: 160px;
    max-width: 120px;
    object-fit: contain;
    object-position: bottom center;
    border-radius: 0;
    border: none;
    background: none;
    box-shadow: none;
}

.scene-npc-name {
    font-size: 11px;
    font-weight: 600;
    color: #f0e8ff;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    padding: 2px 10px;
    border-radius: 8px;
    white-space: nowrap;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
