:root {
    --bg-color: #000000;
    --card-bg: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(20, 20, 25, 0.7);
    --accent-color: #007aff;
    /* Classic iOS Blue */
    --accent-gradient: linear-gradient(135deg, #007aff, #5ac8fa);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.5);
    --border-color: rgba(255, 255, 255, 0.15);
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);
}

.material-symbols-rounded {
    font-family: 'Material Symbols Rounded' !important;
    font-weight: normal;
    font-style: normal;
    font-size: 28px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'liga' 1;
    font-variation-settings: 'wght' 200;
}

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

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-weight: 300;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
}

/* Top Bar */
#top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(44px + var(--safe-top));
    padding-top: var(--safe-top);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: border-color 0.3s, background 0.3s, backdrop-filter 0.3s, -webkit-backdrop-filter 0.3s;
}

/* Show background, border and title when scrolled past large header */
#app.scrolled #top-bar {
    background: var(--glass-bg);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-bottom: 0.5px solid var(--border-color);
}

#top-bar-title {
    font-size: 17px;
    font-weight: 600;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
}

#app.scrolled #top-bar-title {
    opacity: 1;
    transform: translateY(0);
}

/* Back button shown on nested views */
.top-back-btn {
    position: absolute;
    left: 12px;
    background: none;
    border: none;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    font-size: 17px;
    font-weight: 300;
    gap: 0;
    padding: 0;
}

.top-back-btn.hidden {
    display: none;
}

.top-back-btn .material-symbols-rounded {
    font-size: 30px;
    margin-right: -4px;
}

/* Large titles inside views */
.large-view-title {
    margin: 0 0 16px 0;
    font-size: 34px;
    font-weight: 300;
    letter-spacing: -0.5px;
    padding-top: 4px;
    transition: opacity 0.25s;
}

#app.scrolled .view.active .large-view-title {
    opacity: 0;
    pointer-events: none;
}

h2 {
    font-weight: 400;
}

main {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: calc(44px + var(--safe-top) + 16px) 20px 140px 20px;
}

.view {
    display: none;
}

.view.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Bottom Nav */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(55px + var(--safe-bottom));
    background: var(--glass-bg);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 0.5px solid var(--border-color);
    z-index: 100;
    padding-bottom: var(--safe-bottom);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

#bottom-nav.hidden,
#bottom-nav.nav-hide {
    transform: translateY(100%) !important;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    font-weight: 400;
    transition: color 0.2s;
    width: 33%;
}

.nav-item.active {
    color: var(--accent-color);
}

.nav-item .icon {
    font-size: 26px;
    font-variation-settings: 'wght' 200;
}

/* Player */
#player-container {
    position: fixed;
    bottom: calc(70px + var(--safe-bottom));
    left: 10px;
    right: 10px;
    z-index: 90;
    transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Slide mini-player down when bottom nav is gone */
#player-container.nav-gone {
    bottom: calc(12px + var(--safe-bottom));
}

#mini-player {
    background: var(--glass-bg);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-radius: 12px;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 0.5px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    touch-action: none;
    /* Required for pointer events on mobile */
    cursor: pointer;
    user-select: none;
}

.track-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    overflow: hidden;
}

#mini-artwork {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: cover;
}

.track-info .text {
    overflow: hidden;
}

#mini-title {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#mini-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#mini-play-pause {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 32px;
    cursor: pointer;
    padding: 0;
    font-variation-settings: 'wght' 200;
}

/* Full Player */
#full-player {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-color);
    z-index: 200;
    display: flex;
    flex-direction: column;
    padding: 60px 40px;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
    touch-action: none;
}

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

#close-player {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
}

.full-artwork-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#full-artwork {
    width: 100%;
    max-width: 300px;
    aspect-ratio: 1;
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    object-fit: cover;
}

.full-info {
    margin: 40px 0;
}

#full-title {
    font-size: 24px;
    margin: 0 0 8px 0;
}

#full-subtitle {
    font-size: 18px;
    color: var(--accent-color);
    margin: 0;
}

.full-controls {
    width: 100%;
}

.progress-container {
    margin-bottom: 30px;
}

#progress-bar {
    width: 100%;
    margin-bottom: 10px;
    accent-color: var(--accent-color);
}

.time-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.buttons button {
    background: none;
    border: none;
    color: var(--accent-color);
    font-size: 32px;
    font-variation-settings: 'wght' 200;
}

#main-play-pause {
    font-size: 72px !important;
}

.text-btn {
    font-size: 16px !important;
    font-weight: 300;
    font-family: 'Inter';
}

/* Search */
.search-bar {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 20px;
}

#search-input {
    background: none;
    border: none;
    color: var(--text-primary);
    width: 100%;
    font-size: 16px;
    outline: none;
}

.podcast-card {
    display: flex;
    gap: 16px;
    padding: 12px;
    background: var(--card-bg);
    border-radius: 12px;
    margin-bottom: 12px;
    align-items: center;
}

.podcast-card img {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    background: var(--card-bg);
    /* Fallback */
}

.podcast-info {
    flex: 1;
}

.podcast-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.podcast-artist {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Episode List */
.episode-item {
    padding: 16px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.episode-title {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
}

.episode-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Podcast Detail View */
.nav-header {
    display: flex;
    align-items: center;
    padding: 10px 0;
}

.back-btn {
    background: none;
    border: none;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    font-size: 17px;
    font-weight: 300;
    padding: 0;
    margin-left: -8px;
}

.back-btn .material-symbols-rounded {
    font-size: 32px;
    margin-right: -4px;
}

.podcast-header {
    text-align: center;
    padding: 20px 0;
}

.large-artwork {
    width: 200px;
    height: 200px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
}

.sub-btn {
    background: var(--accent-gradient);
    border: none;
    color: white;
    padding: 10px 24px;
    border-radius: 20px;
    font-weight: 600;
    margin: 10px 0 30px 0;
}

.loading,
.error,
.empty-state {
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
}

.episodes-list {
    margin-top: 20px;
}

/* Featured Grid */
.featured-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.featured-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 12px;
    text-align: center;
}

.featured-card img {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 12px;
    margin-bottom: 8px;
    object-fit: cover;
}

.featured-card .podcast-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.featured-card .podcast-artist {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Toast */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 400;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}