.offline-control,
.offline-collection-control,
.offline-current-episode-bar {
    display: none !important;
}

.offline-download-icon {
    position: relative;
    display: inline-grid;
    flex: 0 0 54px;
    width: 54px;
    height: 54px;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--panel-bg);
    color: var(--text);
    box-shadow: 0 10px 24px rgba(10, 14, 24, 0.08);
    cursor: pointer;
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.offline-download-icon:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}

.offline-download-icon svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.offline-icon-dot {
    position: absolute;
    right: 7px;
    bottom: 7px;
    width: 8px;
    height: 8px;
    border: 2px solid var(--panel-bg);
    border-radius: 50%;
    background: transparent;
}

.offline-download-icon.is-active .offline-icon-dot {
    background: var(--accent);
    animation: offline-pulse 1.3s ease-in-out infinite;
}

.offline-download-icon.is-ready {
    border-color: rgba(25, 169, 116, 0.35);
    color: var(--green, #19a974);
}

.offline-download-icon.is-ready .offline-icon-dot {
    background: var(--green, #19a974);
}

.offline-download-icon.is-error {
    border-color: rgba(229, 82, 104, 0.35);
    color: #e55268;
}

.offline-download-icon.is-error .offline-icon-dot {
    background: #e55268;
}

@keyframes offline-pulse {
    50% { opacity: 0.25; transform: scale(0.78); }
}

.detail-actions > .offline-download-icon,
.collection-hero-actions > .offline-download-icon {
    align-self: stretch;
}

.offline-sheet-backdrop[hidden],
[data-offline-delete][hidden],
[data-offline-scope-wrap][hidden],
[data-offline-sheet-progress][hidden],
[data-offline-item-play][hidden],
[data-offline-item-retry][hidden] {
    display: none !important;
}

.offline-sheet-backdrop {
    position: fixed;
    z-index: 4000;
    inset: 0;
    display: grid;
    place-items: end center;
    padding: 18px;
    background: rgba(7, 10, 16, 0.54);
    backdrop-filter: blur(8px);
}

.offline-sheet-open {
    overflow: hidden;
}

.offline-sheet {
    width: min(520px, 100%);
    max-height: min(720px, calc(100dvh - 36px));
    overflow: auto;
    padding: 10px 20px calc(20px + env(safe-area-inset-bottom));
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--panel-bg);
    box-shadow: 0 30px 90px rgba(4, 7, 13, 0.32);
}

.offline-sheet-handle {
    width: 42px;
    height: 4px;
    margin: 2px auto 14px;
    border-radius: 99px;
    background: rgba(130, 140, 160, 0.34);
}

.offline-sheet-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.offline-sheet-header h2 {
    margin: 4px 0 2px;
    font-size: clamp(22px, 5vw, 30px);
}

.offline-sheet-header p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.offline-sheet-close {
    display: grid;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    place-items: center;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
}

.offline-sheet fieldset {
    min-width: 0;
    margin: 0 0 18px;
    padding: 0;
    border: 0;
}

.offline-sheet legend {
    margin-bottom: 9px;
    color: var(--muted-2);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.offline-scope-options,
.offline-retention-options > div {
    display: grid;
    gap: 8px;
}

.offline-scope-options label,
.offline-retention-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 58px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: var(--surface-2);
    cursor: pointer;
}

.offline-scope-options input,
.offline-retention-option input {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.offline-scope-options span,
.offline-retention-option span {
    display: grid;
    gap: 2px;
}

.offline-scope-options strong,
.offline-retention-option strong {
    font-size: 12px;
}

.offline-scope-options small,
.offline-retention-option small {
    color: var(--muted);
    font-size: 10px;
    line-height: 1.35;
}

.offline-scope-options label:has(input:checked),
.offline-retention-option:has(input:checked) {
    border-color: color-mix(in srgb, var(--accent) 60%, var(--border));
    background: color-mix(in srgb, var(--accent) 8%, var(--panel-bg));
}

.offline-sheet-progress {
    display: grid;
    gap: 7px;
    margin: 4px 0 12px;
}

.offline-sheet-progress > div {
    height: 7px;
    overflow: hidden;
    border-radius: 99px;
    background: rgba(125, 135, 155, 0.16);
}

.offline-sheet-progress i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 220ms ease;
}

.offline-sheet-progress span,
.offline-sheet-status {
    color: var(--muted);
    font-size: 10px;
}

.offline-sheet-status {
    min-height: 16px;
    margin: 0 0 14px;
}

.offline-sheet-status.is-error {
    color: #e55268;
}

.offline-sheet-status.is-ready {
    color: var(--green, #19a974);
}

.offline-sheet-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
}

.offline-sheet-actions .button-primary {
    min-width: 170px;
}

.offline-page {
    padding-bottom: 100px;
}

.offline-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}

.offline-summary-card {
    min-width: 0;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--panel-bg);
}

.offline-summary-card span {
    display: block;
    color: var(--muted-2);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.offline-summary-card strong {
    display: block;
    margin-top: 8px;
    overflow: hidden;
    font-size: clamp(18px, 3vw, 28px);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.offline-storage-path {
    margin: -12px 0 28px;
    color: var(--muted-2);
    font-size: 9px;
    overflow-wrap: anywhere;
}

.offline-list {
    display: grid;
    gap: 12px;
}

.offline-item {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    min-height: 170px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--panel-bg);
}

.offline-item-poster {
    position: relative;
    min-height: 100%;
    overflow: hidden;
    background: linear-gradient(145deg, #252c39, #0a0d12);
}

.offline-item-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.offline-item-poster::after {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(5, 7, 10, 0.58), transparent 65%);
    content: "";
}

.offline-item-copy {
    display: flex;
    min-width: 0;
    justify-content: space-between;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
}

.offline-item-copy h2 {
    margin: 5px 0 0;
    font-size: clamp(17px, 2.6vw, 24px);
}

.offline-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 13px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 10px;
}

.offline-progress {
    display: grid;
    gap: 6px;
}

.offline-progress > div {
    height: 7px;
    overflow: hidden;
    border-radius: 99px;
    background: rgba(125, 135, 155, 0.16);
}

.offline-progress i {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width 220ms ease;
}

.offline-progress small {
    color: var(--muted-2);
    font-size: 9px;
}

.offline-item-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.offline-status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 27px;
    padding: 0 9px;
    border-radius: 99px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
}

.offline-status-pill.completed {
    background: rgba(21, 160, 111, 0.12);
    color: var(--green, #19a974);
}

.offline-status-pill.failed,
.offline-status-pill.paused {
    background: rgba(229, 82, 104, 0.1);
    color: #e55268;
}

@media (min-width: 761px) {
    .offline-sheet-backdrop {
        place-items: center;
    }

    .offline-sheet {
        border-radius: 22px;
    }
}

@media (max-width: 760px) {
    .offline-download-icon {
        flex-basis: 52px;
        width: 52px;
        height: 52px;
        border-radius: 15px;
    }

    .detail-actions > .offline-download-icon,
    .collection-hero-actions > .offline-download-icon {
        align-self: auto;
    }

    .offline-sheet-backdrop {
        padding: 0;
    }

    .offline-sheet {
        width: 100%;
        max-height: min(78dvh, 680px);
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 24px 24px 0 0;
    }

    .offline-sheet-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .offline-sheet-actions .button {
        width: 100%;
    }

    .offline-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .offline-item {
        grid-template-columns: 92px minmax(0, 1fr);
        min-height: 150px;
    }

    .offline-item-copy {
        padding: 14px;
    }
}
