/* KAOS-FM standalone — layout modeled after mobile home / carousel / bottom-nav apps. */
:root {
    --kaosfm-topbar-h: 52px;
    --kaosfm-bottomnav-h: 58px;
    --kaosfm-miniplayer-h: 0px;
    --kaosfm-card-w: 132px;
    --kaos-accent: #00ff41;
    --kaos-accent-dim: #00cc34;
    --kaos-surface: #0a0b0d;
    --kaos-surface-2: #14161a;
    --kaos-surface-3: #1c1f26;
    --kaos-border: rgba(255, 255, 255, 0.08);
    --kaos-text: #f1f3f5;
    --kaos-text-muted: #9aa0a6;
    color-scheme: dark;
}

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

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--kaos-surface);
    color: var(--kaos-text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html.gccr-kaos-fm-standalone {
    --gccr-menu-bar-height: var(--kaosfm-topbar-h);
    --gccr-menu-chrome-height: calc(var(--kaosfm-topbar-h) + env(safe-area-inset-top, 0px));
    --gccr-kaos-player-bar-height: var(--kaosfm-miniplayer-h);
    --kaosfm-miniplayer-h: 56px;
}

html.gccr-kaos-fm-standalone.gccr-kaos-fm-standalone-playing {
    --kaosfm-miniplayer-h: 56px;
}

body.gccr-kaos-fm-standalone-body {
    min-height: 100dvh;
}

.kaosfm-shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--kaos-surface);
}

/* ── Top bar ── */
.kaosfm-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: 44px 1fr;
    align-items: center;
    gap: 0.5rem;
    min-height: calc(var(--kaosfm-topbar-h) + env(safe-area-inset-top, 0px));
    padding: env(safe-area-inset-top, 0px) 0.75rem 0;
    background: var(--kaos-surface-2);
    border-bottom: 1px solid var(--kaos-border);
}

.kaosfm-topbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
}

.kaosfm-topbar-btn img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    pointer-events: none;
}

.kaosfm-topbar-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    text-align: left;
    letter-spacing: 0.01em;
}

.kaosfm-miniplayer-play {
    flex: 0 0 auto;
}

#kaosWidget.kaos-widget {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

#kaosButton {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

#kaosButtonIcon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    pointer-events: none;
}

#kaosButtonIcon .kaos-icon-play,
#kaosButtonIcon .kaos-icon-stop {
    width: 26px;
    height: 26px;
    display: block;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
    fill: #fff;
}

#kaosButton .kaos-icon-stop {
    display: none;
}

#kaosButton[data-kaos-state="playing"] .kaos-icon-play {
    display: none;
}

#kaosButton[data-kaos-state="playing"] .kaos-icon-stop {
    display: block;
}

#kaosButton[data-kaos-buffering="true"] .kaos-icon-play,
#kaosButton[data-kaos-buffering="true"] .kaos-icon-stop {
    display: none;
}

#kaosButton[data-kaos-buffering="true"] #kaosButtonIcon::after {
    content: "";
    box-sizing: border-box;
    width: 20px;
    height: 20px;
    border: 2px solid #fff;
    border-right-color: transparent;
    border-radius: 50%;
    filter: none;
    animation: kaosSpin 0.75s linear infinite;
}

@keyframes kaosSpin {
    to {
        transform: rotate(360deg);
    }
}

#kaosListenerBadge.kaos-listener-badge {
    position: absolute;
    right: -4px;
    bottom: -2px;
    z-index: 2;
    display: none;
    padding: 0.12em 0.35em;
    border-radius: 0.25rem;
    background: #fff;
    color: #000;
    font-size: 0.55rem;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
}

#kaosListenerBadge.kaos-listener-badge.active {
    display: inline-flex;
}

/* ── Scrollable feed ── */
.kaosfm-main {
    flex: 1 1 auto;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.35rem 0 calc(var(--kaosfm-bottomnav-h) + var(--kaosfm-miniplayer-h) + env(safe-area-inset-bottom, 0px) + 0.75rem);
}

.kaosfm-panel[hidden] {
    display: none !important;
}

.kaosfm-section {
    padding: 0.85rem 0 1.15rem;
}

.kaosfm-section--stack {
    padding-inline: 1rem;
}

.kaosfm-section-head {
    display: grid;
    grid-template-columns: 52px 1fr;
    align-items: start;
    gap: 0.35rem 0;
    margin-bottom: 0.75rem;
    padding-inline: 0.75rem 1rem;
}

.kaosfm-section-head--solo {
    grid-template-columns: 1fr;
    padding-inline: 0;
}

.kaosfm-timeline {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 44px;
    color: var(--kaos-text-muted);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.kaosfm-timeline-dot {
    width: 10px;
    height: 10px;
    margin-top: 0.15rem;
    border-radius: 50%;
    background: var(--kaos-text-muted);
}

.kaosfm-timeline-label {
    margin-top: 0.2rem;
}

.kaosfm-timeline-line {
    flex: 1 1 auto;
    width: 2px;
    min-height: 18px;
    margin-top: 0.35rem;
    background: linear-gradient(var(--kaos-text-muted), transparent);
    opacity: 0.45;
}

.kaosfm-timeline--muted .kaosfm-timeline-dot {
    background: rgba(255, 255, 255, 0.28);
}

.kaosfm-section-title {
    margin: 0;
    padding-top: 0.05rem;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.2;
}

.kaosfm-section-title span {
    display: inline-block;
}

.kaosfm-section-note {
    margin: 0.35rem 0 0;
    color: var(--kaos-text-muted);
    font-size: 0.82rem;
}

/* ── Horizontal carousels ── */
.kaosfm-carousel {
    display: flex;
    gap: 0.85rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    padding: 0 1rem 0.15rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.kaosfm-carousel::-webkit-scrollbar {
    display: none;
}

.kaosfm-card {
    flex: 0 0 var(--kaosfm-card-w);
    scroll-snap-align: start;
    cursor: pointer;
}

.kaosfm-card-art {
    width: var(--kaosfm-card-w);
    height: var(--kaosfm-card-w);
    border-radius: 0.35rem;
    overflow: hidden;
    background: var(--kaos-surface-3);
    border: 1px solid var(--kaos-border);
}

.kaosfm-card-art img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.kaosfm-card-art img.kaosfm-card-art-fallback {
    object-fit: contain;
    padding: 0.65rem;
}

.kaosfm-card-body {
    margin-top: 0.45rem;
    min-width: 0;
}

.kaosfm-card-title {
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kaosfm-card-subtitle {
    margin-top: 0.12rem;
    color: var(--kaos-text-muted);
    font-size: 0.76rem;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kaosfm-card.is-on-air .kaosfm-card-art {
    border-color: rgba(0, 255, 65, 0.55);
    box-shadow: 0 0 0 1px rgba(0, 255, 65, 0.25);
}

/* ── Browse grid ── */
.kaosfm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--kaosfm-card-w), 1fr));
    gap: 1rem 0.85rem;
}

.kaosfm-card--grid {
    flex: initial;
}

/* ── Schedule list ── */
.kaosfm-schedule-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.kaosfm-schedule-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 0.5rem;
    border-bottom: 1px solid var(--kaos-border);
    cursor: pointer;
}

.kaosfm-schedule-item:nth-child(even) {
    background: rgba(255, 255, 255, 0.03);
}

.kaosfm-schedule-item.is-on-air {
    background: rgba(0, 255, 65, 0.06);
    margin-inline: 0;
    padding-inline: 0.5rem;
    border-radius: 0.35rem;
}

.kaosfm-schedule-meta {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.kaosfm-schedule-meta strong {
    font-size: 0.92rem;
}

.kaosfm-schedule-meta span {
    color: var(--kaos-text-muted);
    font-size: 0.78rem;
}

.kaosfm-schedule-time {
    flex: 0 0 auto;
    color: var(--kaos-text);
    font-size: 0.74rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

/* ── About panel ── */
.kaosfm-about {
    text-align: center;
    padding-top: 1.5rem;
}

.kaosfm-about-logo {
    margin: 0 auto 1rem;
    display: block;
}

.kaosfm-about h2 {
    margin: 0 0 0.65rem;
    font-size: 1.35rem;
    color: var(--kaos-accent);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.kaosfm-about p {
    margin: 0 0 0.85rem;
    color: var(--kaos-text-muted);
    font-size: 0.92rem;
    line-height: 1.5;
}

.kaosfm-about-tip {
    font-size: 0.82rem !important;
    opacity: 0.9;
}

/* ── Mini player (above bottom nav) ── */
#gccrKaosNowPlaying.gccr-kaos-now-playing.kaosfm-miniplayer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--kaosfm-bottomnav-h) + env(safe-area-inset-bottom, 0px));
    z-index: 25;
    height: var(--kaosfm-miniplayer-h);
    pointer-events: auto;
}

.kaosfm-miniplayer-shell {
    display: flex;
    align-items: stretch;
    width: 100%;
    height: 100%;
    color: var(--kaos-text);
    background: var(--kaos-surface-2);
    border-top: 1px solid var(--kaos-border);
}

.kaosfm-miniplayer-track {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: stretch;
    overflow: hidden;
}

.kaosfm-miniplayer-play {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    margin-left: auto;
    padding: 0 0.75rem 0 0.35rem;
}

#gccrKaosNowPlaying.gccr-kaos-now-playing[hidden] {
    display: none !important;
}

#gccrKaosNowPlaying .gccr-kaos-np-toast {
    pointer-events: auto;
    display: flex;
    align-items: stretch;
    width: 100%;
    height: 100%;
    color: var(--kaos-text);
    background: transparent;
    border-top: 0;
}

#gccrKaosNowPlaying .gccr-kaos-np-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    height: 100%;
    padding: 0 0.5rem 0 0.75rem;
}

#gccrKaosNowPlaying .gccr-kaos-np-art {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 0.25rem;
    border: 1px solid rgba(0, 255, 65, 0.25);
    background: #000;
    overflow: hidden;
}

#gccrKaosNowPlaying .gccr-kaos-np-art-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#gccrKaosNowPlaying .gccr-kaos-np-art-img--splash {
    object-fit: contain;
    padding: 3px;
}

#gccrKaosNowPlaying .gccr-kaos-np-body {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
}

#gccrKaosNowPlaying .gccr-kaos-np-title {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#gccrKaosNowPlaying .gccr-kaos-np-artist,
#gccrKaosNowPlaying .gccr-kaos-np-album {
    margin-top: 0.05rem;
    font-size: 0.72rem;
    color: var(--kaos-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#gccrKaosNowPlaying .gccr-kaos-np-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 0 0 auto;
}

#gccrKaosNowPlaying .gccr-kaos-np-skip,
#gccrKaosNowPlaying .gccr-kaos-np-close,
#gccrKaosNowPlaying .gccr-kaos-np-download {
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 0;
    border-radius: 0.25rem;
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.75;
    cursor: pointer;
}

#gccrKaosNowPlaying .gccr-kaos-np-skip {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23ffffff'%3E%3Cpath d='M3.5 3.5v9l6.5-4.5L3.5 3.5zm7.5 0h1.5v9H11V3.5z'/%3E%3C/svg%3E");
    background-size: 1.15rem auto;
}

#gccrKaosNowPlaying .gccr-kaos-np-close {
    background-image: url("img/embedded/asset-a26eb1279a.svg");
    background-size: 0.75em auto;
}

#gccrKaosNowPlaying .gccr-kaos-np-download {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23ffffff'%3E%3Cpath d='M.5 9.9a.5.5 0 0 1 .5.5v2.5a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-2.5a.5.5 0 0 1 1 0v2.5a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2v-2.5a.5.5 0 0 1 .5-.5z'/%3E%3Cpath d='M7.646 11.854a.5.5 0 0 0 .708 0l3-3a.5.5 0 0 0-.708-.708L8.5 10.293V1.5a.5.5 0 0 0-1 0v8.793L5.354 8.146a.5.5 0 1 0-.708.708l3 3z'/%3E%3C/svg%3E");
    background-size: 1.05rem auto;
}

html.gccr-ios-shell .gccr-kaos-np-download {
    display: none !important;
}

/* ── Bottom navigation ── */
.kaosfm-bottomnav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: stretch;
    min-height: calc(var(--kaosfm-bottomnav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--kaos-surface-2);
    border-top: 1px solid var(--kaos-border);
}

.kaosfm-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.18rem;
    padding: 0.35rem 0.25rem 0.45rem;
    border: 0;
    background: transparent;
    color: var(--kaos-text-muted);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.kaosfm-nav-item.is-active {
    color: var(--kaos-text);
}

.kaosfm-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.kaosfm-nav-icon svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.kaosfm-nav-label {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Side tips disabled in standalone — kept for main GCCR menu bar only */
body.gccr-kaos-fm-standalone-body > #kaosSideTip.kaos-side-tip {
    display: none !important;
}

/* ── Side tips & toast ── */
body:not(.gccr-kaos-fm-standalone-body) > #kaosSideTip.kaos-side-tip {
    position: fixed;
    z-index: 40;
    left: 50%;
    bottom: calc(var(--kaosfm-bottomnav-h) + var(--kaosfm-miniplayer-h) + env(safe-area-inset-bottom, 0px) + 0.75rem);
    transform: translate(-50%, -4px);
    max-width: min(80vw, 320px);
    padding: 8px 12px;
    border-radius: 0.375rem;
    background: rgba(255, 255, 255, 0.96);
    color: #1a1a1a;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

body:not(.gccr-kaos-fm-standalone-body) > #kaosSideTip.kaos-side-tip.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

body:not(.gccr-kaos-fm-standalone-body) > #kaosSideTip.kaos-side-tip.hiding {
    opacity: 0;
    transform: translate(-50%, -4px);
}

#toastNotification.gccr-toast-container {
    position: fixed;
    left: 50%;
    bottom: calc(var(--kaosfm-bottomnav-h) + var(--kaosfm-miniplayer-h) + env(safe-area-inset-bottom, 0px) + 0.75rem);
    transform: translateX(-50%);
    z-index: 45;
    max-width: min(92vw, 420px);
    padding: 0.65rem 0.9rem;
    border-radius: 0.5rem;
    background: rgba(18, 20, 24, 0.96);
    border: 1px solid var(--kaos-border);
    color: var(--kaos-text);
    font-size: 0.85rem;
    line-height: 1.35;
    text-align: center;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

#toastNotification.gccr-toast-container[hidden] {
    display: none !important;
}

@media (min-width: 720px) {
    :root {
        --kaosfm-card-w: 148px;
    }

    .kaosfm-main {
        max-width: 720px;
        margin-inline: auto;
        width: 100%;
    }

    .kaosfm-bottomnav,
    #gccrKaosNowPlaying.gccr-kaos-now-playing.kaosfm-miniplayer {
        max-width: 720px;
        margin-inline: auto;
    }
}
