/* ========== Resources page ========== */
.upload-status {
    margin: 0.5rem 0 0;
    padding: 0.55rem 0.65rem;
    font-size: 0.82rem;
    line-height: 1.45;
    border-radius: 8px;
    background: #eff6ff;
    color: #1e40af;
    word-break: break-word;
}
.upload-status.is-error {
    background: #fee2e2;
    color: #991b1b;
}

.resources-page {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-bottom: 1.5rem;
}

.lib-section {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.04);
    position: relative;
}

.section-label {
    position: absolute;
    top: 0;
    left: 0;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.25rem 0.65rem;
    border-radius: 0 0 8px 0;
    z-index: 1;
}

.section-label-global {
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    color: #4338ca;
}

.section-label-devices {
    position: static;
    display: inline-block;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    color: #047857;
    border-radius: 6px;
    margin-bottom: 0.35rem;
}

.lib-global {
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

.lib-devices {
    border: 1px solid #bbf7d0;
    padding: 1.15rem 1.25rem 1.25rem;
}

.devices-section-head {
    margin-bottom: 1rem;
}

.devices-section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.2rem;
}

.device-back-link {
    font-size: 0.82rem;
    color: #6366f1;
    text-decoration: none;
    padding: 0.3rem 0.55rem;
    border-radius: 6px;
    background: #eef2ff;
    border: 1px solid #e0e7ff;
    white-space: nowrap;
}

.device-back-link:hover {
    background: #e0e7ff;
    text-decoration: none;
    color: #4338ca;
}

.device-blocks-focused {
    grid-template-columns: 1fr !important;
}

.device-not-found {
    grid-column: 1 / -1;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.2rem;
}

.section-desc {
    font-size: 0.82rem;
    color: #64748b;
}

/* ---- 资源库 split ---- */
.lib-split {
    display: flex;
    min-height: 280px;
    padding-top: 1.5rem;
}

.lib-sidebar {
    width: 272px;
    min-width: 240px;
    flex-shrink: 0;
    padding: 1.25rem 1.35rem 1.35rem;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.global-sidebar {
    background: linear-gradient(180deg, #fafbff 0%, #f4f6fb 100%);
    border-right: 1px solid #e0e7ff;
    box-shadow: inset -1px 0 0 rgba(99, 102, 241, 0.06);
}

.lib-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    letter-spacing: -0.01em;
}

.lib-desc {
    font-size: 0.78rem;
    color: #64748b;
    line-height: 1.6;
    padding-bottom: 0.15rem;
}

.sidebar-tip {
    font-size: 0.72rem;
    color: #94a3b8;
    line-height: 1.45;
    padding: 0.5rem 0.6rem;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    border: 1px solid #e8ecf4;
}

.lib-content {
    flex: 1;
    min-width: 0;
    padding: 1rem 1.15rem;
    position: relative;
    display: flex;
    flex-direction: column;
}

.global-content {
    background: #ffffff;
}

.drop-overlay {
    display: none;
    position: absolute;
    inset: 8px;
    background: rgba(79, 70, 229, 0.06);
    border: 2px dashed #6366f1;
    border-radius: 10px;
    z-index: 10;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.global-content.drag-over .drop-overlay { display: flex; }

.drop-overlay span {
    background: #4f46e5;
    color: #fff;
    padding: 0.55rem 1.1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.global-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
    gap: 0.6rem;
    align-content: start;
    align-items: start;
    padding: 0.15rem;
}

.global-grid:empty { display: none; }

.marquee-active {
    user-select: none;
    cursor: crosshair;
}

.marquee-box {
    position: absolute;
    border: 1px solid #6366f1;
    background: rgba(99, 102, 241, 0.12);
    border-radius: 4px;
    pointer-events: none;
    z-index: 20;
}

.audio-tile.marquee-preview {
    border-color: #818cf8;
    background: #eef2ff;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.audio-tile {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.55rem 0.6rem;
    cursor: grab;
    user-select: none;
    transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s, background 0.12s;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-height: 72px;
    height: auto;
    position: relative;
}

.audio-tile.selected {
    border-color: #a5b4fc;
    background: #eef2ff;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.tile-select {
    position: absolute;
    top: 0.28rem;
    right: 0.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 3;
    width: 18px;
    height: 18px;
    margin: 0;
}

.tile-select input {
    width: 14px;
    height: 14px;
    accent-color: #6366f1;
    cursor: pointer;
    margin: 0;
}

.tile-remove {
    position: absolute;
    top: 0.28rem;
    right: 0.3rem;
    width: 18px;
    height: 18px;
    border: none;
    background: #fee2e2;
    color: #dc2626;
    border-radius: 4px;
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.12s, background 0.12s;
    z-index: 2;
    padding: 0;
}

.audio-tile:hover .tile-remove { opacity: 1; }

.tile-remove:hover { background: #dc2626; color: #fff; }

.audio-tile:hover {
    background: #fff;
    border-color: #c7d2fe;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

.audio-tile.dragging { opacity: 0.45; cursor: grabbing; transform: scale(0.97); }

.audio-tile-icon {
    width: 22px;
    height: 22px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    flex-shrink: 0;
}

.audio-tile-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: #334155;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.4;
}

.audio-tile-meta {
    font-size: 0.62rem;
    color: #94a3b8;
    line-height: 1.35;
}

/* ---- 设备卡片：左右分栏，一行两个 ---- */
.device-blocks {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    align-items: stretch;
}

.device-card {
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    transition: box-shadow 0.2s, border-color 0.2s;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.06);
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.device-card:hover {
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.1);
}

.device-card.drag-over {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.device-split {
    display: flex;
    flex: 1;
    min-height: 200px;
}

.device-sidebar {
    width: 36%;
    min-width: 148px;
    max-width: 200px;
    flex-shrink: 0;
    padding: 0.75rem 0.85rem;
    background: linear-gradient(180deg, #eff6ff 0%, #f0f9ff 100%);
    border-right: 1px solid #dbeafe;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.device-content {
    flex: 1;
    min-width: 0;
    padding: 0.65rem 0.75rem;
    background: #fafbfc;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.device-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

.device-card-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.device-card-info {
    flex: 1;
    min-width: 0;
}

.device-card-title {
    font-weight: 600;
    font-size: 0.88rem;
    color: #1e3a5f;
    word-break: break-word;
    line-height: 1.35;
}

.device-card-meta {
    font-size: 0.68rem;
    color: #64748b;
    margin-top: 0.1rem;
}

.device-audio-count {
    font-size: 0.68rem;
    font-weight: 600;
    color: #2563eb;
    background: #fff;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    border: 1px solid #bfdbfe;
    flex-shrink: 0;
}

.device-zone-search {
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: 1px solid #dbeafe;
    border-radius: 6px;
    font-size: 0.72rem;
    background: #fff;
    min-width: 0;
}

.device-zone-search:focus {
    outline: none;
    border-color: #6366f1;
}

.device-zone-trash {
    padding: 0.35rem 0.5rem;
    border: 1px dashed #fca5a5;
    border-radius: 6px;
    background: #fff;
    color: #ef4444;
    font-size: 0.68rem;
    text-align: center;
    transition: all 0.15s;
    margin-top: auto;
}

.device-zone-trash.drag-over {
    background: #fee2e2;
    border-color: #ef4444;
    border-style: solid;
}

/* 设备资源区 */
.device-resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 0.4rem;
    align-content: start;
    align-items: start;
    flex: 1;
}

.device-audio-chip {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.4rem 0.45rem 0.35rem;
    position: relative;
    cursor: grab;
    min-width: 0;
    min-height: 56px;
}

.device-audio-chip:hover { border-color: #a5b4fc; }
.device-audio-chip.selected {
    border-color: #6366f1;
    background: #eef2ff;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}
.device-audio-chip.marquee-preview {
    border-color: #818cf8;
    background: #eef2ff;
}
.device-audio-chip.dragging { opacity: 0.45; }

.device-batch-bar {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.device-content.marquee-active {
    user-select: none;
    cursor: crosshair;
}

.chip-remove {
    position: absolute;
    top: 1px;
    right: 1px;
    width: 14px;
    height: 14px;
    border: none;
    background: #fee2e2;
    color: #dc2626;
    border-radius: 50%;
    font-size: 0.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.12s;
}

.device-audio-chip:hover .chip-remove { opacity: 1; }
.chip-remove:hover { background: #dc2626; color: #fff; }

.chip-name {
    font-size: 0.68rem;
    font-weight: 500;
    color: #334155;
    padding-right: 0.75rem;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.4;
}

.chip-meta {
    font-size: 0.58rem;
    color: #94a3b8;
}

.device-resource-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 0.75rem;
    text-align: center;
    padding: 1.5rem 0.75rem;
    border: 1px dashed #e2e8f0;
    border-radius: 8px;
    background: #fff;
    min-height: 100px;
}

.device-sidebar-pagination {
    font-size: 0.68rem;
    color: #64748b;
    line-height: 1.4;
    padding-top: 0.25rem;
}

.device-content-pagination {
    padding-top: 0;
    justify-content: flex-end;
}

/* Common */
.search-input,
.filter-select,
.page-size-select {
    width: 100%;
    padding: 0.48rem 0.65rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.82rem;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.global-sidebar .search-input,
.global-sidebar .filter-select,
.global-sidebar .page-size-select {
    border-color: #e0e7ff;
    background: #fff;
}

.global-sidebar .upload-btn {
    padding: 0.55rem 1rem;
    font-size: 0.85rem;
    border-radius: 9px;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.18);
}

.global-batch-bar {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.global-batch-actions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.global-batch-actions .btn-text {
    color: #64748b;
}

.global-batch-actions .btn-danger:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.global-zone-trash {
    width: 100%;
    min-height: 2.6rem;
    padding: 0.65rem 0.75rem;
    border: 2px dashed #fca5a5;
    border-radius: 10px;
    background: #fff;
    color: #ef4444;
    font-size: 0.78rem;
    font-weight: 500;
    text-align: center;
    transition: all 0.15s;
    box-sizing: border-box;
}

.global-zone-trash.drag-over {
    background: #fee2e2;
    border-color: #ef4444;
    border-style: solid;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
    transform: scale(1.01);
}

.global-grid.batch-mode .audio-tile {
    cursor: pointer;
}

.global-grid.batch-mode .audio-tile[draggable="true"] {
    cursor: grab;
}

.search-input:focus,
.filter-select:focus,
.page-size-select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.count-badge {
    font-size: 0.7rem;
    font-weight: 500;
    color: #6366f1;
    background: #eef2ff;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    vertical-align: middle;
}

.btn-block { width: 100%; text-align: center; }

.zone-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    padding: 2rem 1rem;
    text-align: center;
}

.devices-empty {
    border: 1px dashed #d1d5db;
    border-radius: 10px;
    background: #f9fafb;
    padding: 2.5rem;
}

.zone-empty-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.6;
}

.zone-empty-sub {
    font-size: 0.8rem;
    margin-top: 0.3rem;
    color: #cbd5e1;
}

.zone-empty-sub a { color: #4f46e5; }

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    flex-wrap: wrap;
    padding-top: 0.55rem;
}

.pagination-bar:empty { display: none; }

.sidebar-pagination {
    margin-top: auto;
    font-size: 0.72rem;
    color: #64748b;
    line-height: 1.45;
    padding-top: 0.65rem;
    border-top: 1px solid #e2e8f0;
}

.page-btn {
    min-width: 26px;
    height: 26px;
    padding: 0 0.35rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 5px;
    font-size: 0.72rem;
    color: #475569;
    cursor: pointer;
}

.page-btn:hover:not(:disabled) { border-color: #6366f1; color: #6366f1; }
.page-btn.active { background: #4f46e5; border-color: #4f46e5; color: #fff; }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.page-info { font-size: 0.72rem; color: #94a3b8; }

@media (max-width: 1024px) {
    .device-blocks {
        grid-template-columns: 1fr;
    }

    .device-sidebar {
        width: 220px;
        max-width: none;
    }
}

@media (max-width: 768px) {
    .lib-split { flex-direction: column; padding-top: 1.75rem; }

    .lib-sidebar {
        width: 100%;
        min-width: 0;
        border-right: none;
        border-bottom: 1px solid #f1f5f9;
    }

    .device-split {
        flex-direction: column;
    }

    .device-sidebar {
        width: 100%;
        min-width: 0;
        border-right: none;
        border-bottom: 1px solid #dbeafe;
    }
}

@media (max-width: 480px) {
    .global-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .device-resource-grid {
        grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    }
}
