:root {
    --bg: #090a11;
    --surface: #111320;
    --surface-2: #181b2a;
    --border: #282d42;
    --accent: #ffdb4d;
    --text: #f6f8ff;
    --text-dim: #9da5c0;
    --danger: #ff6f8f;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    color: var(--text);
    background:
        radial-gradient(900px 500px at 80% -20%, #283060 0%, transparent 70%),
        radial-gradient(700px 500px at -10% 0%, #28203f 0%, transparent 60%),
        var(--bg);
    overflow: hidden;
}

body.player-open {
    overflow: hidden;
}

.app-layout {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-header {
    position: relative;
    padding: 18px 16px 4px;
    z-index: 30;
}

.header-controls {
    position: relative;
}

.header-main-controls {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    z-index: 40;
    padding: 8px 10px 10px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, rgba(14, 18, 38, 0.92), rgba(10, 13, 28, 0.86));
    backdrop-filter: blur(8px);
    transition: transform 0.18s ease-out, opacity 0.18s ease-out;
    will-change: transform, opacity;
}

.header-main-controls.is-hidden {
    transform: translate3d(0, -120%, 0);
    opacity: 0;
    pointer-events: none;
}

.header-controls-spacer {
    height: var(--header-main-controls-height, 104px);
    pointer-events: none;
}

.is-searching .sync-banner {
    display: none !important;
}

.title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.service-label {
    margin: 0;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.app-title {
    margin: 2px 0 0;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    font-size: 16px;
}

.settings-menu {
    position: absolute;
    right: 16px;
    top: 58px;
    z-index: 90;
    width: min(300px, calc(100vw - 32px));
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 18, 32, 0.96);
    backdrop-filter: blur(10px);
    padding: 12px;
}

.settings-menu.hidden {
    display: none;
}

.settings-menu-title {
    margin: 0 0 8px;
    font-size: 12px;
    color: var(--text-dim);
}

.settings-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.settings-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.search-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    padding: 12px 14px;
}

.search-bar-container {
    margin-top: 0;
    overflow: hidden;
    max-height: 90px;
    opacity: 1;
    transform: translateY(0);
    will-change: max-height, opacity, transform;
}

.search-icon {
    color: var(--text-dim);
    font-size: 16px;
}

#searchInput {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 14px;
}

#searchInput::placeholder {
    color: #7e86a0;
}

#searchOverlayInput {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 14px;
}

#searchOverlayInput::placeholder {
    color: #7e86a0;
}

.tabs-container {
    margin-top: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    will-change: transform;
}

.sync-banner {
    margin-top: 116px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 180, 100, 0.35);
    background: rgba(255, 160, 60, 0.1);
}

.sync-banner[hidden] {
    display: none !important;
}

.sync-banner-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: rgba(255, 180, 100, 0.25);
    color: #ffb868;
    font-size: 13px;
    font-weight: 800;
    line-height: 22px;
    text-align: center;
}

.sync-banner-text {
    margin: 0;
    font-size: 12px;
    line-height: 1.45;
    color: #c9b896;
}

.tab {
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-dim);
    border-radius: 14px;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    width: 100%;
}

.tab.active {
    border-color: rgba(255, 255, 255, 0.55);
    color: #131313;
    background: rgba(255, 255, 255, 0.92);
}

.search-overlay {
    position: absolute;
    inset: 0;
    z-index: 120;
    display: flex;
    flex-direction: column;
    padding: 14px 0 0;
    background:
        radial-gradient(900px 520px at 60% -20%, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0)),
        rgba(9, 10, 17, 0.96);
    backdrop-filter: blur(10px);
}

.search-overlay.hidden {
    display: none;
}

.search-overlay-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
}

.search-overlay-input {
    flex: 1;
}

.search-overlay-content {
    margin-top: 14px;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0 16px;
}

.search-overlay-content .tracks-list {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 120px;
}

.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 4px 16px calc(100px + env(safe-area-inset-bottom));
    position: relative;
}

.app-content .panel.hidden {
    display: none;
}

.favorites-hint {
    margin: 0 0 12px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-dim);
}

.track-row-wrap {
    display: flex;
    align-items: stretch;
    gap: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.track-row-wrap:last-child {
    border-bottom: 0;
}

.track-row-main {
    flex: 1;
    min-width: 0;
    border-bottom: 0 !important;
}

.track-fav {
    flex-shrink: 0;
    width: 44px;
    border: 0;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-dim);
    border-radius: 10px;
    font-size: 18px;
    line-height: 1;
    margin: 8px 0;
}

.track-fav.active {
    color: #ff6b9a;
    background: rgba(255, 107, 154, 0.12);
}

#fullFavBtn.active {
    color: #ff6b9a;
    border-color: rgba(255, 107, 154, 0.45);
}

.offline-pill {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    color: #7ee0b8;
    background: rgba(126, 224, 184, 0.12);
    border-radius: 999px;
    vertical-align: middle;
}

.hero-card {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 16px;
    margin-bottom: 18px;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02));
}

.hero-glow {
    position: absolute;
    width: 160px;
    height: 160px;
    right: -50px;
    top: -50px;
    background: radial-gradient(circle, rgba(255, 219, 77, 0.6) 0%, rgba(255, 219, 77, 0) 70%);
}

.hero-card h2 {
    position: relative;
    margin: 4px 0;
    font-size: 22px;
    letter-spacing: -0.03em;
}

.hero-caption,
.hero-subtitle {
    position: relative;
    margin: 0;
    color: var(--text-dim);
}

.hero-caption {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.hero-subtitle {
    font-size: 13px;
}

.results-section {
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(17, 19, 32, 0.6);
    backdrop-filter: blur(8px);
    padding: 14px;
}

.section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.section-title-row h3 {
    margin: 0;
    font-size: 15px;
}

.section-title-row span {
    color: var(--text-dim);
    font-size: 12px;
}

.tracks-list {
    display: flex;
    flex-direction: column;
}

.track-row {
    width: 100%;
    border: 0;
    color: inherit;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    padding: 11px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.track-row-wrap.playing {
    /* слабая белая подсветка */
    background: rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.track-row:last-child {
    border-bottom: 0;
}

.track-index {
    width: 24px;
    font-size: 11px;
    color: #7e86a0;
}

.track-meta {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.track-title-stub {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.track-artist-stub {
    margin-top: 3px;
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.track-action-stub {
    color: #8f97b2;
    font-size: 11px;
}

.state-message {
    margin: 10px 0;
    color: var(--text-dim);
    text-align: center;
    font-size: 13px;
}

.state-message.error {
    color: var(--danger);
}

.mini-player {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(20, 24, 38, 0.9);
    backdrop-filter: blur(18px);
    z-index: 190;
    transition: transform 0.28s ease;
    touch-action: pan-y;
}

.mini-slider {
    overflow: hidden;
    width: 100%;
    /* pan-x отдавал жест браузеру — в полноэкранном и мини свайп не доходил до pointermove */
    touch-action: none;
}

.mini-slider-track {
    display: flex;
    width: 300%;
    will-change: transform;
}

.mini-slide {
    width: 33.333333%;
    flex: 0 0 33.333333%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    box-sizing: border-box;
}

.mini-player.hidden {
    transform: translateY(calc(100% + 14px));
}

.mini-progress-wrap {
    height: 2px;
    background: rgba(255, 255, 255, 0.12);
}

.mini-progress {
    height: 100%;
    width: 0;
    background: rgba(255, 255, 255, 0.96);
}

.cover-frame--mini {
    position: relative;
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border-radius: 10px;
    overflow: hidden;
}

.cover-frame--full {
    position: relative;
    width: 100%;
    border-radius: 26px;
    overflow: hidden;
    transform-origin: center center;
}

@keyframes undercloud-cover-pause-pulse {
    0% {
        transform: scale(1);
    }
    55% {
        transform: scale(0.94);
    }
    100% {
        transform: scale(1);
    }
}

.cover-frame--full.cover-pause-pulse {
    animation: undercloud-cover-pause-pulse 0.28s cubic-bezier(0.34, 1.46, 0.64, 1) both;
}

.cover-gradient-ph {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: linear-gradient(155deg, #252a42 0%, #121625 55%, #0a0c14 100%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

.cover-gradient-ph.is-visible {
    opacity: 1;
}

.mini-cover-img {
    position: relative;
    z-index: 1;
    display: block;
    width: 46px;
    height: 46px;
    border-radius: 10px;
    background: transparent;
    object-fit: cover;
    flex-shrink: 0;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.mini-cover-img.is-cover-hidden {
    opacity: 0;
}

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

.mini-title {
    display: block;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-artist {
    display: block;
    margin-top: 2px;
    color: var(--text-dim);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-control-btn {
    border: 0;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.12);
    color: white;
    font-size: 16px;
    font-weight: 700;
}

.full-player {
    position: fixed;
    inset: 0;
    z-index: 200;
    background:
        radial-gradient(600px 350px at 50% -20%, rgba(255, 219, 77, 0.17), rgba(255, 219, 77, 0)),
        #090a11;
    display: flex;
    flex-direction: column;
    padding: calc(4px + env(safe-area-inset-top)) 16px 20px;
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.full-player.hidden {
    transform: translateY(100%);
}

.full-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    position: relative;
    z-index: 260;
}

.full-topbar-spacer {
    width: 36px;
    height: 36px;
}

.full-topbar-text p {
    margin: 0;
    color: var(--text-dim);
    font-size: 12px;
}

/* Зона тапа: ниже топбара, до обложки; z-index выше .cover-wrap, ниже #fullMenuBtn */
#fullDismissArea {
    position: absolute;
    background: transparent;
    pointer-events: auto;
    z-index: 265;
    /* размеры выставляются в js */
    left: 2px;
    top: 2px;
    width: 0;
    height: 0;
}

.full-player.hidden #fullDismissArea {
    display: none;
}

.ghost-btn {
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    width: 36px;
    height: 36px;
    border-radius: 999px;
    font-size: 16px;
}

#fullMenuBtn {
    position: relative;
    z-index: 270;
}

.cover-wrap {
    margin-top: 8px;
    position: relative;
    z-index: 1;
    border-radius: 26px;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.cover-slider {
    position: relative;
    z-index: 1;
    overflow: hidden;
    touch-action: none;
}

.cover-slider-track {
    display: flex;
    width: 300%;
    will-change: transform;
}

.cover-slide {
    width: 33.333333%;
    flex: 0 0 33.333333%;
}

.full-cover-img {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background: transparent;
    opacity: 1;
    transition: opacity 0.22s ease;
}

.full-cover-img.is-cover-hidden {
    opacity: 0;
}

.track-text-panel {
    position: absolute;
    inset: 0;
    z-index: 2;
    border-radius: 26px;
    border: 1px solid var(--border);
    background: rgba(14, 17, 30, 0.98);
    padding: 14px;
}

.track-text-panel.hidden {
    display: none;
}

.track-text-content {
    height: 100%;
    overflow-y: auto;
    white-space: pre-wrap;
    line-height: 1.45;
    font-size: 14px;
    color: #d6dcf3;
    padding-right: 4px;
}

.track-text-content .state-message {
    margin-top: 0;
}

.track-details {
    margin-top: 14px;
}

.track-details h2 {
    margin: 0;
    font-size: 25px;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.track-details p {
    margin: 6px 0 0;
    color: var(--text-dim);
    font-size: 14px;
}

.progress-wrap {
    margin-top: 16px;
}

.seek-bar {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 999px;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.96) var(--progress, 0%), rgba(255, 255, 255, 0.14) var(--progress, 0%));
}

.seek-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.98);
    border: 2px solid rgba(240, 242, 250, 0.95);
}

.time-row {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    color: var(--text-dim);
    font-size: 12px;
}

.controls-row {
    margin-top: auto;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    --controls-gap: clamp(10px, 3vw, 14px);
    column-gap: var(--controls-gap);
}

body.player-control-swipe .controls-row {
    display: none;
}

.controls-left {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: var(--controls-gap);
}

.controls-right {
    justify-self: start;
    display: flex;
    align-items: center;
    gap: var(--controls-gap);
}

.control-small {
    width: 48px;
    height: 48px;
}

.control-spacer {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    pointer-events: none;
    opacity: 0;
}

.control-main {
    width: 76px;
    height: 76px;
    font-size: 24px;
    border-color: rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.94);
    color: #111;
}

.playback-mode-row {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.mode-btn {
    border: 0;
    height: 48px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(245, 248, 255, 0.76);
    font-size: 23px;
    font-weight: 600;
}

.mode-btn.active {
    background: rgba(255, 255, 255, 0.9);
    color: #151821;
}

.full-history-overlay {
    position: absolute;
    inset: 0;
    z-index: 240;
    padding: calc(48px + env(safe-area-inset-top)) 16px 20px;
    background: rgba(8, 10, 17, 0.72);
    backdrop-filter: blur(7px);
}

.full-history-overlay.hidden {
    display: none;
}

.full-history-card {
    height: 100%;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(17, 20, 34, 0.95);
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.full-history-list {
    margin-top: 8px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.history-track-btn {
    width: 100%;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: transparent;
    color: inherit;
    text-align: left;
    padding: 10px 0;
}

.history-track-btn:last-child {
    border-bottom: 0;
}

.history-track-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
}

.history-track-meta {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-dim);
}