/*
  ==============================================================================
  SUNO PRO — HISTORY WORKSPACE (2026 UI KIT ARCHITECTURE)
  Scoped component layer integrating with uikit.css & tokens.css
  ==============================================================================
*/

.history-workspace {
    --history-gap: var(--space-4, 1rem);
    --history-content-max: 100%;
    color: var(--color-text-base);
    container-type: inline-size;
    container-name: history-workspace;
    width: 100%;
    box-sizing: border-box;
}

/* Context Variants */
.history-workspace[data-history-context="composer"] {
    --history-gap: var(--space-3, 0.75rem);
}

.history-workspace[data-history-context="library"] {
    --history-gap: var(--space-4, 1rem);
}

/* --------------------------------------------------------------------------
   1. HEADER & ACTIONS
   -------------------------------------------------------------------------- */
.history-workspace__header {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.75rem;
    margin-bottom: 0.875rem;
}

.history-workspace__title-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.history-workspace .history-header-title {
    margin: 0;
    font-family: 'Unbounded', var(--font-sans);
    font-size: clamp(1.2rem, 2vw, 1.5rem);
    font-weight: 750;
    line-height: 1.25;
    letter-spacing: -0.02em;
    color: var(--color-text-base);
}

.index-history-section,
.history-workspace,
.history-workspace__header {
    overflow: visible !important;
}

.history-workspace__header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.history-workspace__header-actions .ui-btn {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    color: var(--color-text-base) !important;
    background: var(--surface-glass-base) !important;
    border: none !important;
    border-radius: var(--radius-pill) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
}

.history-workspace__header-actions .ui-btn svg {
    width: 18px !important;
    height: 18px !important;
    fill: currentColor !important;
}

.history-workspace__header-actions .ui-btn:hover {
    background: var(--surface-glass-hover) !important;
    color: var(--color-text-base) !important;
}

.history-workspace .ui-dropdown {
    position: relative;
    display: inline-block;
}

.history-workspace .ui-dropdown__menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 2000;
    width: 220px;
    padding: 6px;
    border: none;
    border-radius: var(--radius-xl);
    background: var(--color-surface-2);
    box-shadow: var(--shadow-float-lg);
    display: none;
    flex-direction: column;
    gap: 2px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.history-workspace .ui-dropdown__menu.is-open {
    display: flex !important;
}

.history-workspace .ui-dropdown__item {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100% !important;
    min-height: 40px !important;
    padding: 8px 10px !important;
    border-radius: var(--radius-md) !important;
    background: transparent !important;
    border: none !important;
    color: var(--color-text-muted) !important;
    font-family: inherit !important;
    font-size: 0.88rem !important;
    font-weight: 650 !important;
    line-height: 1.2 !important;
    cursor: pointer !important;
    text-align: left !important;
    text-decoration: none !important;
    box-shadow: none !important;
    transition: background 0.15s ease, color 0.15s ease !important;
}

.history-workspace .ui-dropdown__item svg {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    min-height: 18px !important;
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 2 !important;
    flex-shrink: 0 !important;
    color: inherit !important;
    display: inline-block !important;
    vertical-align: middle !important;
    margin: 0 !important;
}

.history-workspace .ui-dropdown__item span {
    display: inline-block !important;
    line-height: 1 !important;
    vertical-align: middle !important;
}

.history-workspace .ui-dropdown__item:hover {
    background: var(--surface-glass-hover) !important;
    color: var(--color-text-base) !important;
}

.history-workspace .ui-dropdown__item--danger {
    color: var(--color-danger) !important;
}

.history-workspace .ui-dropdown__item--danger svg {
    stroke: var(--color-danger) !important;
    color: var(--color-danger) !important;
}

.history-workspace .ui-dropdown__item--danger:hover {
    background: var(--surface-glass-hover) !important;
    color: var(--color-danger) !important;
}

.history-workspace .ui-dropdown__divider {
    height: 1px;
    background: var(--color-border-subtle);
    margin: 4px 0;
}

/* --------------------------------------------------------------------------
   2. TABS & FILTER NAVIGATION
   -------------------------------------------------------------------------- */
.history-workspace__tabs-wrap {
    margin-bottom: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.history-workspace__tabs-wrap::-webkit-scrollbar {
    display: none;
}

.history-workspace .history-tabs.ui-segmented {
    width: 100%;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
    background: var(--color-surface-0) !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: var(--radius-pill) !important;
    box-shadow: var(--shadow-inset-soft) !important;
    box-sizing: border-box;
}

.history-workspace .history-tab.ui-segmented__item {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    min-height: 36px !important;
    padding: 8px 14px !important;
    border-radius: var(--radius-pill) !important;
    border: none !important;
    font-size: 0.88rem !important;
    font-weight: 750 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    line-height: 1.2 !important;
    box-sizing: border-box !important;
}

/* Короткие вкладки (Все, Музыка, Тексты, Видео) сохраняют читаемость в первую очередь */
.history-workspace .history-tab[data-history-tab="all"],
.history-workspace .history-tab[data-history-tab="music"],
.history-workspace .history-tab[data-history-tab="lyrics"],
.history-workspace .history-tab[data-history-tab="video"] {
    flex: 1 0 auto !important;
}

/* Самая длинная вкладка ("Изображения") плавно ужимается с многоточием при нехватке места */
.history-workspace .history-tab[data-history-tab="image"] {
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

/* --------------------------------------------------------------------------
   3. COMPACT TOOLBAR (Page Size & Favorite Filter)
   -------------------------------------------------------------------------- */
.history-workspace__toolbar {
    margin-bottom: 0.75rem;
}

.history-workspace__toolbar-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
}

.history-workspace__toolbar-left {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

.history-workspace__toolbar-right {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.history-workspace__meta-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-subtle);
    font-variant-numeric: tabular-nums;
}

.history-workspace .history-page-size.ui-chip-group {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: var(--color-surface-0);
    border: none;
    border-radius: var(--radius-pill);
    box-sizing: border-box;
}

.history-workspace .history-page-size__option.ui-chip {
    padding: 4px 10px !important;
    font-size: 0.76rem !important;
    font-weight: 700 !important;
    min-height: 26px !important;
    height: 26px !important;
    border-radius: var(--radius-pill) !important;
    border: none !important;
    background: transparent;
    color: var(--color-text-muted);
    box-sizing: border-box;
}

.history-workspace .history-page-size__option.ui-chip.is-active,
.history-workspace .history-page-size__option.ui-chip.ui-chip--active {
    background: color-mix(in oklch, var(--color-premium-gold) 22%, transparent) !important;
    color: var(--color-premium-gold) !important;
    box-shadow: 0 0 14px color-mix(in oklch, var(--color-premium-gold) 35%, transparent) !important;
}

.history-workspace .history-filter-toggle.ui-chip {
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 700;
    min-height: 32px;
    border-radius: var(--radius-pill);
    background: var(--color-surface-0);
    border: none;
    color: var(--color-text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-workspace .history-filter-toggle.ui-chip:hover {
    color: var(--color-text-base);
    background: var(--surface-glass-hover);
}

.history-workspace .history-filter-toggle.ui-chip.is-active,
.history-workspace .history-filter-toggle.ui-chip.ui-chip--active {
    color: var(--color-premium-gold) !important;
    background: color-mix(in oklch, var(--color-premium-gold) 14%, transparent) !important;
}

.history-workspace .history-filter-toggle.ui-chip.is-active svg,
.history-workspace .history-filter-toggle.ui-chip.ui-chip--active svg {
    fill: currentColor;
}

/* --------------------------------------------------------------------------
   4. TASK GROUPS & CARDS (.ui-card container)
   -------------------------------------------------------------------------- */
.history-workspace__list {
    display: grid;
    gap: var(--history-gap);
    width: 100%;
    box-sizing: border-box;
}

.history-workspace .history-music-group,
.history-workspace .history-content-group {
    padding: clamp(14px, 2.5cqi, 20px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-sizing: border-box;
}

.history-workspace .history-music-group__header,
.history-workspace .history-content-group__header {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-workspace .history-task-meta__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.history-workspace .history-task-meta__title-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.history-workspace .history-task-actions.ui-chip-group {
    gap: 6px;
}

.history-workspace .history-task-action-panel {
    padding: 12px 14px;
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
    font-size: 0.86rem;
    line-height: 1.55;
    color: var(--color-text-muted);
}

.history-workspace .history-music-group__songs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* --------------------------------------------------------------------------
   5. NATIVE UI TRACK CARD REFINEMENT (.ui-track-card — SUNO 2026 PATTERN)
   -------------------------------------------------------------------------- */
.history-workspace .ui-track-card {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    max-width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-xl);
    background: var(--color-surface-1);
    border: none;
    box-shadow: var(--shadow-float-sm);
    min-height: 72px;
    box-sizing: border-box;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.history-workspace .ui-track-card:hover {
    background: var(--color-surface-2);
    transform: translateY(-1px);
    box-shadow: var(--shadow-float-md);
}

/* Cover Wrapper */
.history-workspace .ui-track-card__cover-wrap {
    position: relative;
    width: 52px;
    height: 52px;
    min-width: 52px;
    max-width: 52px;
    border-radius: var(--radius-md);
    overflow: hidden;
    flex-shrink: 0;
    margin-top: 2px;
    background: var(--color-surface-0);
    box-shadow: 0 4px 12px var(--color-overlay-backdrop);
}

.history-workspace .ui-track-card__cover-wrap img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    display: block;
}

.history-workspace .ui-track-card__cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface-2);
    color: var(--color-text-subtle);
}

.history-workspace .ui-track-card__cover-placeholder svg {
    width: 22px;
    height: 22px;
}

.history-workspace .ui-track-card__play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-overlay-backdrop);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.2s ease;
    cursor: pointer;
    color: var(--color-text-base);
    z-index: 2;
}

.history-workspace .ui-track-card:hover .ui-track-card__play-overlay,
.history-workspace .ui-track-card.is-playing .ui-track-card__play-overlay {
    opacity: 1;
}

.history-workspace .ui-track-card__cover-duration {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: var(--color-surface-0);
    backdrop-filter: blur(4px);
    color: var(--color-text-base);
    font-size: 0.65rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    padding: 1px 4px;
    border-radius: var(--radius-xs);
    line-height: 1.2;
    pointer-events: none;
    z-index: 3;
}

/* Track Metadata */
.history-workspace .ui-track-card__meta {
    flex: 1 1 0%;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-workspace .ui-track-card__meta-top {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    max-width: 100%;
}

.history-workspace .ui-track-card__title {
    flex: 0 1 auto;
    min-width: 0;
    font-size: 0.92rem;
    font-weight: 750;
    color: var(--color-text-base);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
    transition: color 0.18s ease;
}

.history-workspace .ui-track-card__title:hover {
    color: var(--color-premium-gold);
    text-decoration: none;
}

.history-workspace .ui-track-card__badges {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    max-width: 100%;
    flex-wrap: wrap;
    margin-top: 1px;
}

.history-workspace .ui-track-card__badges .ui-badge {
    cursor: pointer;
    border: none;
    font-family: inherit;
    padding: 2px 7px;
    min-height: 19px;
    font-size: 0.66rem;
    font-weight: 600;
    line-height: 1.15;
    white-space: nowrap;
    border-radius: var(--radius-pill);
    transition: transform 0.15s ease, filter 0.15s ease;
}

.history-workspace .ui-track-card__badges .ui-badge:hover {
    filter: brightness(1.2);
    transform: scale(1.04);
}

.history-workspace .ui-track-card__date {
    font-size: 0.7rem;
    color: var(--color-text-subtle);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    line-height: 1.2;
    margin-top: 2px;
}

/* Actions Row — Uses standard .ui-track-card__actions from uikit.css */
.history-workspace .ui-track-card__actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   6. LYRICS & MEDIA CONTENT CARDS (MATCHING TRACK CARD AESTHETICS)
   -------------------------------------------------------------------------- */
.history-workspace .history-content-card {
    padding: 12px 14px;
    border-radius: var(--radius-xl);
    background: var(--color-surface-1);
    border: none;
    box-shadow: var(--shadow-float-sm);
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-sizing: border-box;
    transition: background 0.2s ease, transform 0.2s ease;
}

.history-workspace .history-content-card:hover {
    background: var(--color-surface-2);
    transform: translateY(-1px);
}

.history-workspace .history-content-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.history-workspace .history-content-card__title-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.history-workspace .history-content-card__title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 750;
    color: var(--color-text-base);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-workspace .history-content-card__actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.history-workspace .history-content-card__media-wrap {
    width: 100%;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-surface-0);
    border: none;
}

.history-workspace .history-content-card__media {
    width: 100%;
    max-height: min(26rem, 50vh);
    display: block;
    object-fit: contain;
    background: var(--color-surface-0);
}

.history-workspace .history-content-card__image {
    aspect-ratio: 1 / 1;
}

.history-workspace .history-pre-wrap {
    width: 100%;
    max-height: 220px;
    overflow-y: auto;
    border-radius: var(--radius-md);
    background: var(--color-surface-0);
    border: none;
    padding: 10px 12px;
    box-sizing: border-box;
}

.history-workspace .history-pre {
    margin: 0;
    white-space: pre-wrap;
    font-family: var(--font-mono, monospace);
    font-size: 0.82rem;
    color: var(--color-text-muted);
    line-height: 1.55;
}

/* --------------------------------------------------------------------------
   7. PAGINATION & NAVIGATION
   -------------------------------------------------------------------------- */
.history-workspace__pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 1.25rem;
}

.history-workspace .history-pagination__inner {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    flex-wrap: wrap;
}

.history-workspace .history-pagination__button {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 32px !important;
    height: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
    padding: 0 10px !important;
    border-radius: var(--radius-pill) !important;
    background: var(--surface-glass-base) !important;
    border: 1px solid var(--border-base) !important;
    font-size: 0.84rem !important;
    font-weight: 600 !important;
    color: var(--color-text-muted) !important;
    cursor: pointer !important;
    box-shadow: none !important;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
    box-sizing: border-box !important;
    user-select: none;
}

.history-workspace .history-pagination__button:hover:not(:disabled):not(.is-disabled) {
    background: var(--surface-glass-hover) !important;
    color: var(--color-text-base) !important;
    border-color: var(--color-border-strong) !important;
    transform: translateY(-1px) !important;
}

.history-workspace .history-pagination__button.is-active,
.history-workspace .history-pagination__button.ui-chip--active,
.history-workspace .history-pagination__button[aria-current="page"] {
    background: color-mix(in oklch, var(--color-premium-gold) 15%, transparent) !important;
    border-color: var(--color-premium-gold) !important;
    color: var(--color-premium-gold) !important;
    font-weight: 750 !important;
    box-shadow: 0 0 12px color-mix(in oklch, var(--color-premium-gold) 20%, transparent) !important;
}

.history-workspace .history-pagination__button:disabled,
.history-workspace .history-pagination__button.is-disabled {
    opacity: 0.35 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    transform: none !important;
}

.history-workspace .history-pagination__button svg {
    width: 14px !important;
    height: 14px !important;
    stroke-width: 2.2 !important;
}

.history-workspace .history-pagination__ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    font-size: 0.84rem;
    color: var(--color-text-subtle);
}

/* --------------------------------------------------------------------------
   8. CONTAINER & ACCESSIBILITY QUERIES
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .history-workspace .history-tabs.ui-segmented {
        padding: 3px !important;
        gap: 3px !important;
    }

    .history-workspace .history-tab.ui-segmented__item {
        padding: 6px 6px !important;
        font-size: 0.8rem !important;
        min-height: 34px !important;
    }

    .history-workspace__toolbar-controls {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .history-workspace .history-page-size.ui-chip-group {
        gap: 3px;
    }

    .history-workspace .history-page-size__option.ui-chip {
        padding: 3px 7px;
        font-size: 0.72rem;
    }
}

@media (max-width: 640px) {
    .history-workspace .history-tabs.ui-segmented {
        padding: 3px !important;
        gap: 2.5px !important;
    }

    .history-workspace .history-tab.ui-segmented__item {
        padding: 6px 4px !important;
        min-height: 32px !important;
        font-size: 0.76rem !important;
        letter-spacing: -0.01em !important;
        line-height: 18px !important;
    }

    .history-workspace .history-filter-toggle.ui-chip {
        padding: 0 !important;
        width: 32px !important;
        min-width: 32px !important;
        height: 32px !important;
        min-height: 32px !important;
        justify-content: center !important;
    }

    /* Прячем слово, но не счётчик: «2 из 3» короче любой надписи и полезнее
       её. Класс вешает скрипт, когда счётчику есть что показать. */
    .history-workspace .history-filter-toggle.ui-chip span:not(.history-slots-counter) {
        display: none !important;
    }

    .history-workspace .history-filter-toggle.ui-chip.has-slots {
        width: auto !important;
        padding: 0 8px !important;
        gap: 4px !important;
    }

    .history-workspace .history-filter-toggle.ui-chip:not(.has-slots) .history-slots-counter {
        display: none !important;
    }

    .history-workspace .history-music-group,
    .history-workspace .history-content-group {
        padding: 12px 10px !important;
        gap: 10px !important;
        border-radius: var(--radius-lg) !important;
    }

    .history-workspace .history-content-card {
        padding: 10px 10px !important;
        border-radius: var(--radius-lg) !important;
        gap: 6px !important;
    }

    .history-workspace .ui-track-card {
        padding: 8px 10px !important;
        gap: 8px !important;
        min-height: 60px !important;
        border-radius: var(--radius-lg) !important;
    }

    .history-workspace .ui-track-card__cover-wrap {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        max-width: 44px !important;
        border-radius: var(--radius-sm) !important;
    }
    
    .history-workspace .ui-track-card__cover-duration {
        font-size: 0.6rem !important;
        padding: 0 3px !important;
    }

    .history-workspace .ui-track-card__title {
        font-size: 0.88rem !important;
    }
    
    .history-workspace .ui-track-card__meta-top {
        max-width: calc(100vw - 190px);
    }
    
    .history-workspace .ui-track-card__badges {
        max-width: calc(100vw - 190px);
    }

    .history-workspace .ui-track-card__badges .ui-badge {
        padding: 1px 6px !important;
        min-height: 17px !important;
        font-size: 0.62rem !important;
    }

    .history-workspace .ui-track-card__date {
        font-size: 0.66rem !important;
    }

    .history-workspace .ui-track-card__actions {
        gap: 2px !important;
    }

    .history-workspace .ui-track-card__actions .ui-btn {
        width: 28px !important;
        min-width: 28px !important;
        height: 28px !important;
        min-height: 28px !important;
    }
    
    .history-workspace .ui-track-card__actions .ui-btn svg {
        width: 14px !important;
        height: 14px !important;
    }
}

.track-menu--desktop-floating.ui-dropdown__menu {
    border-radius: var(--radius-lg) !important;
    background: color-mix(in oklch, var(--color-surface-0) 96%, transparent) !important;
    border: none !important;
    padding: 6px !important;
    box-shadow: var(--shadow-float-lg) !important;
    backdrop-filter: blur(24px) saturate(120%) !important;
    -webkit-backdrop-filter: blur(24px) saturate(120%) !important;
    gap: 2px !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
}

.track-menu--desktop-floating.ui-dropdown__menu:not(.is-open) {
    display: none !important;
}

.track-menu--desktop-floating.ui-dropdown__menu.is-open {
    display: flex !important;
}

@media (prefers-reduced-motion: reduce) {
    .history-workspace * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* Остаток ячеек библиотеки рядом с фильтром. Мельче основной надписи: это
   уточнение, а не заголовок, и глаз не должен спотыкаться о него каждый раз. */
.history-slots-counter {
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: var(--radius-pill);
    background: var(--color-surface-2);
    font-size: var(--text-xs);
    font-variant-numeric: tabular-nums;
    color: var(--color-text-subtle);
}

/* Срок хранения медиафайла. В истории карточек много, поэтому строка самая
   мелкая и приглушённая — она информирует, но не перехватывает внимание. */
.history-media-retention {
    margin: 0;
    font-size: var(--text-xs);
    line-height: 1.4;
    color: var(--color-text-subtle);
}

/* Слово-действие внутри строки о сроке. Это кнопка, но выглядеть должна
   частью предложения: иначе она перетянет внимание с самой даты. */
/* Слово-действие внутри строки о сроке. Цветом не выделяем: он перетягивал
   внимание с самой даты, а она там главное. Подчёркивания достаточно, чтобы
   понять, что на слово можно нажать. */
.history-retention-link {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}

.history-retention-link:hover {
    color: var(--color-text-base);
}

/* Объяснение про хранение. Было четыре абзаца подряд — такое пробегают
   глазами и закрывают. Сверху показываем саму кнопку: показать быстрее, чем
   описать. Ниже пары «что / сколько»: глаз идёт по левому столбцу и
   останавливается там, где нужно. */
.storage-help__hint {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 14px;
    border-radius: var(--radius-md);
    background: var(--color-surface-2);
    font-size: var(--text-sm);
    text-wrap: pretty;
}

.storage-help__star {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: var(--radius-pill);
    background: var(--color-surface-1);
    border: 1px solid var(--color-border-base);
    color: var(--color-premium-gold);
}

.storage-help__star svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.storage-help__grid {
    display: grid;
    grid-template-columns: minmax(88px, auto) 1fr;
    gap: 8px 14px;
    margin: 0;
    font-size: var(--text-sm);
    line-height: 1.45;
}

.storage-help__grid dt {
    color: var(--color-text-subtle);
    white-space: nowrap;
}

.storage-help__grid dd {
    margin: 0;
    color: var(--color-text-base);
    text-wrap: pretty;
}

@media (max-width: 420px) {
    .storage-help__grid {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .storage-help__grid dd {
        margin-bottom: 8px;
    }
}

/* За три дня до удаления и после него строка меняет цвет: это единственный
   момент, когда она должна попасться на глаза. */
.history-media-retention--soon {
    color: var(--color-warning);
}

.history-media-retention--gone {
    color: var(--color-text-subtle);
    text-decoration: line-through;
}

/* Карточка, у которой срок вышел. Надпись о сроке стоит мелко и внизу, а
   карточек в истории десятки — глаз её проскакивает. Поэтому приглушаем то,
   что относится к пропавшему файлу: обложку и значки. Сам текст не трогаем —
   выцветший текст это уже не приглушение, а испорченная читаемость. Кнопки
   гаснут сами: они помечены disabled и подчиняются правилу uikit. */
.history-card--expired .ui-track-card__cover-wrap,
.history-card--expired .history-content-card__media-wrap {
    filter: grayscale(0.9);
    opacity: 0.55;
}

.history-card--expired .ui-track-card__badges {
    opacity: 0.6;
}

/* Название больше не запускает трек, поэтому и выглядеть кнопкой не должно. */
.history-card--expired .ui-track-card__title {
    color: var(--color-text-subtle);
}

/* --------------------------------------------------------------------------
   ПАНЕЛЬ ИНСТРУМЕНТОВ ТРЕКА
   Раньше это был плоский список из пятнадцати пунктов без групп и без цен:
   продвинутыми режимами разделения за всё время не воспользовались ни разу,
   потому что их не было видно. Стили привязаны к содержимому, а не к
   контейнеру — одна и та же разметка копируется и в шторку на телефоне,
   и в выпадающую панель на компьютере.
   -------------------------------------------------------------------------- */
#globalDesktopTrackMenu {
    width: min(420px, calc(100vw - 24px));
    max-height: min(72vh, 720px);
    padding: 10px;
    gap: 0;
}

.track-tools__group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 2px 4px;
}

.track-tools__group + .track-tools__group {
    border-top: 1px solid var(--color-border-subtle);
    margin-top: 4px;
}

.track-tools__label {
    display: flex;
    align-items: baseline;
    gap: 7px;
    padding: 0 6px 2px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-subtle);
}

.track-tools__label span {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--color-text-subtle);
    opacity: 0.75;
}

.ui-dropdown__item.track-tool {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 52px;
    padding: 0 12px;
    border-radius: var(--radius-md);
    background: var(--color-surface-1);
    border: 1px solid var(--color-border-base);
    text-align: left;
    transition: background var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out);
}

.ui-dropdown__item.track-tool:hover {
    background: var(--color-surface-2);
    border-color: var(--color-border-strong);
}

.track-tool__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    background: var(--color-surface-2);
    color: var(--color-text-muted);
}

.track-tool__icon svg {
    width: 16px;
    height: 16px;
}

.track-tool__name {
    flex-grow: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text-base);
}

.track-tool__price {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 800;
    color: var(--color-premium-gold);
    font-variant-numeric: tabular-nums;
}

.track-tool__price--free {
    color: var(--color-success);
}

.ui-dropdown__item.track-tool.ui-dropdown__item--danger .track-tool__icon,
.ui-dropdown__item.track-tool.ui-dropdown__item--danger .track-tool__name {
    color: var(--color-danger);
}

/* Места хватает — раскладываем плитки в два столбца. Порог по ширине самого
   блока, а не окна: в студии история занимает узкую колонку, на своей
   странице — всю ширину. */
@container history-workspace (min-width: 760px) {
    .track-tools__group {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }
    .track-tools__label {
        grid-column: 1 / -1;
    }
}
