.hg-audio-player {
    --hg-audio-accent: #f05a18;
    --hg-audio-bg: #171717;
    --hg-audio-text: #ffffff;
    --hg-audio-muted: rgba(255, 255, 255, 0.64);
    box-sizing: border-box;
    width: 100%;
    margin: 0.85rem 0 1.35rem;
    color: var(--hg-audio-text);
}

.hg-audio-player[hidden] {
    display: none !important;
}

/* Совпадает с шириной видеоблока темы и не наследует текстовый предел 820px. */
.hp-prose > .hg-audio-player {
    width: min(calc(100% - 32px), 882px) !important;
    max-width: none !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

.hp-pad-single > .hg-audio-player {
    width: min(100%, 640px) !important;
    max-width: none !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

.hg-audio-player *,
.hg-audio-player *::before,
.hg-audio-player *::after {
    box-sizing: border-box;
}

.hg-audio-player__card {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    align-items: stretch;
    gap: 0.7rem;
    min-height: 118px;
    padding: 0.65rem;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 12px;
    background: var(--hg-audio-bg);
}

.hg-audio-player__play {
    appearance: none;
    align-self: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 2px solid rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    background: transparent;
    color: var(--hg-audio-text);
    font: inherit;
    cursor: pointer;
    transition: border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.hg-audio-player__play:hover,
.hg-audio-player__play:focus-visible {
    border-color: var(--hg-audio-accent);
    color: var(--hg-audio-accent);
}

.hg-audio-player__play:active {
    transform: scale(0.97);
}

.hg-audio-player__play-icon {
    display: block;
    padding-left: 0.15em;
    font-size: 1.38rem;
    line-height: 1;
}

.hg-audio-player__main {
    display: grid;
    grid-template-rows: auto minmax(46px, 1fr) auto;
    gap: 0.3rem;
    min-width: 0;
}

.hg-audio-player__title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.7rem;
    min-width: 0;
}

.hg-audio-player__title-copy {
    min-width: 0;
}

.hg-audio-player .hg-audio-player__title-copy h2 {
    display: block;
    max-height: none;
    margin: 0 !important;
    overflow: visible;
    color: var(--hg-audio-text) !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif !important;
    font-size: clamp(13px, 1.3vw, 17px) !important;
    font-stretch: normal;
    font-weight: 800 !important;
    letter-spacing: 0;
    line-height: 1.18 !important;
    overflow-wrap: anywhere;
    text-overflow: clip;
    white-space: normal;
}

.hg-audio-player__title-copy p {
    margin: 0.15rem 0 0 !important;
    color: var(--hg-audio-muted);
    font-size: 11px !important;
    line-height: 1.15 !important;
}

.hg-audio-player__playback-meta {
    display: flex;
    flex: 0 0 auto;
    flex-direction: row;
    align-self: flex-end;
    align-items: baseline;
    gap: 0.65rem;
    min-width: 0;
    padding-bottom: 0.05rem;
}

.hg-audio-player__time {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.25rem;
    padding-top: 0;
    color: var(--hg-audio-muted);
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    white-space: nowrap;
}

.hg-audio-player__wave {
    position: relative;
    min-width: 0;
    min-height: 46px;
    cursor: pointer;
}

.hg-audio-player__bars {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(480, minmax(0, 1fr));
    align-items: center;
    gap: 0.5px;
    overflow: hidden;
    pointer-events: none;
}

.hg-audio-player__bars span {
    width: 100%;
    min-width: 0;
    height: var(--hg-bar-height, 50%);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.34);
    transition: background-color 100ms linear;
}

.hg-audio-player__bars span.is-played {
    background: var(--hg-audio-accent);
}

.hg-audio-player__wave::after {
    content: "";
    position: absolute;
    z-index: 1;
    inset: 0 auto 0 0;
    width: var(--hg-wave-hover, 0%);
    border-right: 1px solid rgba(255, 255, 255, 0.82);
    background: linear-gradient(90deg, rgba(240, 90, 24, 0.02), rgba(240, 90, 24, 0.13));
    opacity: 0;
    pointer-events: none;
    transition: opacity 90ms ease;
}

.hg-audio-player__wave.is-hovering::after {
    opacity: 1;
}

.hg-audio-player__wave input {
    position: absolute;
    z-index: 2;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.hg-audio-player__wave:has(input:focus-visible) {
    outline: 2px solid var(--hg-audio-accent);
    outline-offset: 3px;
}

.hg-audio-player__actions {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    min-width: 0;
    min-height: 28px;
    height: 28px;
}

.hg-audio-player__action {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    height: 22px;
    min-height: 22px;
    margin: 0;
    padding: 0 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 999px;
    background: transparent;
    color: var(--hg-audio-text);
    font: inherit;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 10.5px;
    font-weight: 650;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.hg-audio-player__action:hover,
.hg-audio-player__action:focus-visible {
    border-color: var(--hg-audio-accent);
    color: var(--hg-audio-accent);
}

.hg-audio-player__action:disabled {
    cursor: wait;
    opacity: 0.45;
}

.hg-audio-player__page-link {
    position: absolute;
    top: 50%;
    right: calc(60px + 0.55rem);
    transform: translateY(-50%);
}

.hg-audio-player__download {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
}

.hg-audio-player__like[aria-pressed="true"] {
    border-color: var(--hg-audio-accent);
    color: var(--hg-audio-accent);
}

.hg-audio-player__volume {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.25rem;
    height: 26px;
    margin-inline: 1.35rem;
}

.hg-audio-player__mute {
    appearance: none;
    display: inline-grid;
    width: 24px;
    height: 24px;
    padding: 0;
    place-items: center;
    border: 0;
    background: transparent;
    color: var(--hg-audio-text);
    font: inherit;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}

.hg-audio-player__mute:hover,
.hg-audio-player__mute:focus-visible {
    color: var(--hg-audio-accent);
}

.hg-audio-player__volume input {
    appearance: none;
    display: block;
    flex: 0 0 104px;
    width: 104px;
    height: 24px;
    margin: 0;
    padding: 0;
    border-radius: 999px;
    background:
        linear-gradient(
            to right,
            var(--hg-audio-accent) 0 var(--hg-volume-level, 75%),
            rgba(255, 255, 255, 0.34) var(--hg-volume-level, 75%) 100%
        )
        center / 100% 4px no-repeat;
    cursor: pointer;
}

.hg-audio-player__volume input::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 999px;
    background: transparent;
}

.hg-audio-player__volume input::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    margin-top: -5px;
    border: 0;
    border-radius: 50%;
    background: var(--hg-audio-accent);
}

.hg-audio-player__volume input::-moz-range-track {
    height: 4px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.34);
}

.hg-audio-player__volume input::-moz-range-progress {
    height: 4px;
    border-radius: 999px;
    background: var(--hg-audio-accent);
}

.hg-audio-player__volume input::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 0;
    border-radius: 50%;
    background: var(--hg-audio-accent);
}

.hg-audio-player__status:empty {
    display: none;
}

.hg-audio-player__status {
    display: inline-flex;
    align-items: baseline;
    min-width: 0;
    margin-left: 0;
    overflow: visible;
    color: var(--hg-audio-muted);
    font-size: 10px;
    line-height: 1.1;
    text-align: right;
    text-overflow: clip;
    white-space: nowrap;
}

.hg-audio-player__cover {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 96px;
    overflow: hidden;
    border-radius: 8px;
    background: #0d0d0d;
}

.hg-audio-player__cover img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    object-position: center;
}

.hg-audio-player audio {
    display: none;
}

.hg-audio-page {
    padding: clamp(1rem, 3vw, 2.5rem);
}

.hg-audio-page__inner {
    width: min(100%, 1040px);
    margin: 0 auto;
}

.hg-audio-page__inner > h1 {
    margin: 0 0 1rem;
    font-size: clamp(1.35rem, 3vw, 2.25rem);
    line-height: 1.15;
}

.hg-audio-page__back {
    margin: 0 0 0.75rem;
}

.hg-audio-page__back a {
    color: inherit;
    font-weight: 650;
}

@media (max-width: 700px) {
    .hg-audio-player__card {
        grid-template-columns: 46px minmax(0, 1fr);
        gap: 0.5rem;
        min-height: 112px;
        padding: 0.55rem;
    }

    .hg-audio-player__play {
        width: 42px;
        height: 42px;
    }

    .hg-audio-player__bars {
        gap: 0.5px;
    }

    .hg-audio-player__action {
        min-height: 22px;
        padding: 0 0.42rem;
        font-size: 9.5px;
    }

    .hg-audio-player__volume input {
        flex-basis: 82px;
        width: 82px;
    }

    .hg-audio-player__status {
        font-size: 9px;
    }

    .hg-audio-player__cover {
        min-height: 78px;
    }
}

@media (max-width: 500px) {
    .hg-audio-player {
        margin: 0.65rem 0 1rem;
    }

    .hg-audio-player__card {
        grid-template-columns: 40px minmax(0, 1fr);
        gap: 0.4rem;
        min-height: 108px;
        padding: 0.45rem;
        border-radius: 9px;
    }

    .hg-audio-player__play {
        width: 36px;
        height: 36px;
    }

    .hg-audio-player__play-icon {
        font-size: 1.08rem;
    }

    .hg-audio-player__main {
        grid-template-rows: auto 40px auto;
        gap: 0.22rem;
    }

    .hg-audio-player__title-row {
        gap: 0.35rem;
    }

    .hg-audio-player .hg-audio-player__title-copy h2 {
        font-size: clamp(10px, 3.2vw, 13px) !important;
        line-height: 1.12 !important;
    }

    .hg-audio-player__title-copy p {
        font-size: 9px !important;
    }

    .hg-audio-player__time {
        font-size: 8.5px;
    }

    .hg-audio-player__actions {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.3rem;
        height: auto;
    }

    .hg-audio-player__action {
        height: 20px;
        min-height: 20px;
        padding: 0 0.35rem;
        font-size: 8.5px;
    }

    .hg-audio-player__volume {
        height: 22px;
        margin-inline: 0.54rem;
    }

    .hg-audio-player__mute {
        width: 20px;
        height: 20px;
        font-size: 11px;
    }

    .hg-audio-player__volume input {
        flex-basis: 62px;
        width: 62px;
    }

    .hg-audio-player__cover {
        min-height: 64px;
        border-radius: 6px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hg-audio-player__play,
    .hg-audio-player__bars span {
        transition: none;
    }
}

/* На узком PAD-блоке сохраняем одну строку и те же увеличенные поля громкости. */
.hp-pad-single > .hg-audio-player .hg-audio-player__actions {
    gap: 0.4rem;
}

.hg-audio-player__title-copy p .hg-audio-player__status {
    display: inline;
    margin-left: 0;
    color: inherit;
    font-size: inherit;
    line-height: inherit;
    white-space: nowrap;
}

.hg-audio-player__title-copy p .hg-audio-player__status:not(:empty)::before {
    content: " · ";
}

.hp-pad-single > .hg-audio-player .hg-audio-player__actions {
    padding-right: 8.75rem;
}

.hp-pad-single > .hg-audio-player .hg-audio-player__action {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif !important;
    font-size: 10.5px !important;
    font-weight: 650 !important;
    line-height: 1 !important;
}

.hg-audio-player__audio-label {
    color: #f2c94c;
    font-weight: 700;
}

@media (max-width: 500px) {
    .hg-audio-player__page-link,
    .hg-audio-player__download {
        position: static;
        transform: none;
    }
}

/* Расширенный SoundCloud-подобный режим только для отдельной аудиостраницы. */
.hg-audio-page__inner {
    width: min(100%, 1180px);
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__card {
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 1.25rem;
    min-height: 340px;
    padding: 1.4rem;
    border-color: rgba(255, 255, 255, 0.13);
    border-radius: 18px;
    background: linear-gradient(135deg, #111b25 0%, #0b141d 100%);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.16);
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__play {
    align-self: start;
    width: 68px;
    height: 68px;
    border-width: 2px;
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__play-icon {
    font-size: 2rem;
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__main {
    grid-template-rows: auto minmax(190px, 1fr) auto;
    gap: 1rem;
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__title-copy h2 {
    font-size: clamp(21px, 2.2vw, 30px) !important;
    line-height: 1.12 !important;
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__title-copy p {
    margin-top: 0.35rem !important;
    font-size: 13px !important;
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__time {
    font-size: 13px;
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__wave {
    min-height: 190px;
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__wave::before {
    content: "";
    position: absolute;
    z-index: 1;
    top: 50%;
    right: 0;
    left: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.42);
    pointer-events: none;
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__bars {
    gap: 1px;
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__bars span {
    border-radius: 1px;
    background: rgba(255, 255, 255, 0.28);
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__bars span.is-played {
    background: var(--hg-audio-accent);
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__actions {
    min-height: 36px;
    height: 36px;
    gap: 0.8rem;
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__action {
    height: 30px;
    min-height: 30px;
    padding-inline: 0.7rem;
    font-size: 12px;
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__volume {
    height: 30px;
    margin-inline: 1.5rem;
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__volume input {
    flex-basis: 140px;
    width: 140px;
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__page-link {
    right: calc(68px + 0.8rem);
}

@media (max-width: 700px) {
    .hg-audio-player[data-layout="expanded"] .hg-audio-player__card {
        grid-template-columns: 52px minmax(0, 1fr);
        gap: 0.75rem;
        min-height: 250px;
        padding: 0.8rem;
        border-radius: 13px;
    }

    .hg-audio-player[data-layout="expanded"] .hg-audio-player__play {
        width: 48px;
        height: 48px;
    }

    .hg-audio-player[data-layout="expanded"] .hg-audio-player__play-icon {
        font-size: 1.45rem;
    }

    .hg-audio-player[data-layout="expanded"] .hg-audio-player__main {
        grid-template-rows: auto minmax(120px, 1fr) auto;
        gap: 0.55rem;
    }

    .hg-audio-player[data-layout="expanded"] .hg-audio-player__wave {
        min-height: 120px;
    }
}

@media (max-width: 500px) {
    .hg-audio-player[data-layout="expanded"] .hg-audio-player__card {
        grid-template-columns: 42px minmax(0, 1fr);
        min-height: 230px;
    }

    .hg-audio-player[data-layout="expanded"] .hg-audio-player__play {
        width: 40px;
        height: 40px;
    }

    .hg-audio-player[data-layout="expanded"] .hg-audio-player__actions {
        height: auto;
    }

    .hg-audio-player[data-layout="expanded"] .hg-audio-player__action {
        height: 24px;
        min-height: 24px;
        font-size: 9px;
    }
}


/* Загрузка: светлые столбики и тонкая полоса показывают реально буферизованную часть. */
.hg-audio-player__bars span.is-buffered:not(.is-played) {
    background: rgba(255, 255, 255, 0.52);
}

.hg-audio-player__bars::after {
    content: "";
    position: absolute;
    z-index: 3;
    right: auto;
    bottom: 0;
    left: 0;
    width: var(--hg-buffer-progress, 0%);
    height: 2px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.68);
    pointer-events: none;
    transition: width 180ms linear;
}

/* Большая страница: заголовок с Play наверху, осциллограмма отдельным широким рядом под ними. */
.hg-audio-player[data-layout="expanded"] .hg-audio-player__card {
    grid-template-columns: 76px minmax(0, 1fr);
    grid-template-rows: auto minmax(190px, 1fr) auto;
    align-items: start;
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__play {
    grid-column: 1;
    grid-row: 1;
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__main {
    display: contents;
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__title-row {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__wave {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-height: 190px;
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__actions {
    grid-column: 1 / -1;
    grid-row: 3;
    width: 100%;
}

.hg-audio-player[data-layout="expanded"] .hg-audio-player__bars::after {
    height: 3px;
}

@media (max-width: 700px) {
    .hg-audio-player[data-layout="expanded"] .hg-audio-player__card {
        grid-template-columns: 52px minmax(0, 1fr);
        grid-template-rows: auto minmax(120px, 1fr) auto;
    }
}

@media (max-width: 500px) {
    .hg-audio-player[data-layout="expanded"] .hg-audio-player__card {
        grid-template-columns: 42px minmax(0, 1fr);
        grid-template-rows: auto minmax(112px, 1fr) auto;
    }
}
