#download-queue {
    position: fixed;
    left: max(16px, env(safe-area-inset-left));
    bottom: max(24px, env(safe-area-inset-bottom));
    width: min(420px, calc(100vw - 32px));
    z-index: 100001;
    color: #f5f2ff;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.45;
    color-scheme: dark;
}

#download-queue *,
#download-queue *::before,
#download-queue *::after {
    box-sizing: border-box;
}

#download-queue [hidden],
#download-queue[hidden] {
    display: none !important;
}

#download-queue button {
    min-height: 36px;
    border: 1px solid rgba(190, 167, 255, .2);
    border-radius: 9px;
    padding: 6px 10px;
    background: rgba(185, 155, 255, .08);
    color: inherit;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

#download-queue button:hover:not(:disabled) {
    background: rgba(185, 155, 255, .18);
}

#download-queue button:focus-visible {
    outline: 2px solid #bda3ff;
    outline-offset: 3px;
}

#download-queue button:disabled {
    opacity: .4;
    cursor: default;
}

.download-queue-panel,
.download-queue-footer {
    border: 1px solid rgba(151, 115, 255, .45);
    background: linear-gradient(145deg, rgba(28, 24, 45, .97), rgba(15, 13, 28, .97));
    box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.download-queue-panel {
    margin-bottom: 8px;
    border-radius: 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: min(540px, calc(100vh - 130px));
    max-height: min(540px, calc(100dvh - 130px));
}

.download-queue-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 16px 10px;
    flex-shrink: 0;
}

#download-queue h2 {
    margin: 0;
    color: inherit;
    font: inherit;
    font-size: 16px;
    font-weight: 650;
}

.download-queue-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 14px;
    flex-shrink: 0;
}

#download-queue .download-queue-cancel-all,
#download-queue .download-queue-cancel {
    color: #ffd0db;
}

.download-queue-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: #786391 transparent;
}

.download-queue-item {
    padding: 14px 16px;
    border-top: 1px solid rgba(204, 188, 255, .1);
}

.download-queue-item[data-state="downloading"] {
    background: rgba(151, 115, 255, .08);
}

.download-queue-file,
.download-queue-details {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: space-between;
    min-width: 0;
}

.download-queue-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.download-queue-cancel {
    flex-shrink: 0;
}

.download-queue-progress {
    display: block;
    width: 100%;
    height: 6px;
    margin-top: 12px;
    border: 0;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, .1);
    accent-color: #a385ff;
}

.download-queue-progress::-webkit-progress-bar {
    background: rgba(255, 255, 255, .1);
}

.download-queue-progress::-webkit-progress-value {
    background: linear-gradient(90deg, #7c5cff, #bc9cff);
    border-radius: 8px;
}

.download-queue-progress::-moz-progress-bar {
    background: #a385ff;
    border-radius: 8px;
}

.download-queue-details {
    margin-top: 7px;
    font-size: 12px;
    color: #bcb3d0;
    align-items: flex-start;
}

.download-queue-status {
    overflow-wrap: anywhere;
}

.download-queue-percent {
    color: #c1a7ff;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.download-queue-item[data-state="completed"] .download-queue-status {
    color: #9bddbf;
}

.download-queue-item[data-state="error"] .download-queue-status {
    color: #ffb8c7;
}

.download-queue-footer {
    border-radius: 14px;
    display: flex;
    align-items: center;
    padding: 4px;
}

#download-queue .download-queue-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    min-height: 42px;
    padding: 8px 12px;
    border: 0;
    background: transparent;
    text-align: left;
}

.download-queue-label {
    font-size: 14px;
    font-weight: 600;
}

.download-queue-summary {
    margin-left: auto;
    font-size: 12px;
    color: #c5b3f0;
}

.download-queue-chevron {
    width: 7px;
    height: 7px;
    border-left: 1.5px solid currentColor;
    border-top: 1.5px solid currentColor;
    transform: rotate(45deg);
    margin: 3px 2px 0 4px;
    flex-shrink: 0;
}

[aria-expanded="true"] .download-queue-chevron {
    transform: rotate(225deg);
    margin-top: -3px;
}

#download-queue .download-queue-hide {
    font-size: 22px;
    line-height: 1;
    border: 0;
    min-width: 36px;
    background: transparent;
}

.download-queue-announcement {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@media (max-width: 600px) {
    #download-queue {
        bottom: calc(112px + env(safe-area-inset-bottom));
    }

    .download-queue-panel {
        max-height: calc(100vh - 200px - env(safe-area-inset-bottom));
        max-height: calc(100dvh - 200px - env(safe-area-inset-bottom));
    }

    #download-queue button {
        min-height: 44px;
    }
}

@media (max-height: 450px) {
    #download-queue {
        bottom: max(12px, env(safe-area-inset-bottom));
    }

    .download-queue-panel {
        max-height: calc(100vh - 90px - env(safe-area-inset-bottom));
        max-height: calc(100dvh - 90px - env(safe-area-inset-bottom));
    }
}
