:root {
    --primary: #ff007a;
    --secondary: #7000ff;
    --bg-dark: #0a0a0c;
    --card-bg: rgba(255, 255, 255, 0.05);
    --text-main: #ffffff;
    --text-dim: #b0b0b0;
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent-glow: 0 0 20px rgba(255, 0, 122, 0.3);
}

.hidden { display: none !important; }

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Outfit', sans-serif; }

body {
    background: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
}

/* Background Glows */
body::before {
    content: '';
    position: fixed;
    top: -10%; right: -10%; width: 50%; height: 50%;
    background: radial-gradient(circle, rgba(112, 0, 255, 0.15) 0%, transparent 70%);
    z-index: -1;
}

body::after {
    content: '';
    position: fixed;
    bottom: -10%; left: -10%; width: 50%; height: 50%;
    background: radial-gradient(circle, rgba(255, 0, 122, 0.15) 0%, transparent 70%);
    z-index: -1;
}

/* Setup Overlay */
.overlay-view {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(30px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.setup-card {
    width: 90%;
    max-width: 450px;
    padding: 3rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 25px;
    backdrop-filter: blur(20px);
}

.logo { font-size: 3rem; font-weight: 800; letter-spacing: -1px; margin-bottom: 0.5rem; }
.logo span { color: var(--primary); }

.tab-container {
    display: flex;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 15px;
    padding: 0.4rem;
    margin: 2rem 0;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 0.8rem;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.3s;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.form-container input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.2rem;
    color: white;
    margin-bottom: 1rem;
    font-size: 1rem;
    outline: none;
}

/* Header & Tabs */
header {
    padding: 1.2rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

.app-tabs {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--glass-border);
}

.view-tab {
    background: none;
    border: none;
    color: var(--text-dim);
    padding: 0.6rem 2rem;
    border-radius: 40px;
    font-weight: 800;
    cursor: pointer;
    transition: 0.3s;
}

.view-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 15px var(--primary);
}

/* Main Layout */
#app-view { display: flex; flex-direction: column; height: 100vh; }

main {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(270px, 0.62fr) minmax(270px, 0.62fr);
    gap: 2rem;
    padding: 2rem;
    height: calc(100vh - 160px);
    overflow: hidden;
}

/* Search Section */
.search-bar { display: flex; gap: 1rem; margin-bottom: 2rem; }
.search-bar input { flex: 1; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--glass-border); border-radius: 12px; padding: 1rem; color: white; outline: none; }
.search-bar button { background: var(--primary); border: none; color: white; padding: 0 2rem; border-radius: 12px; font-weight: 800; cursor: pointer; }

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
    overflow-y: auto;
    height: calc(100% - 80px);
    padding-right: 1rem;
}

.track-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.2rem;
    cursor: pointer;
    transition: 0.3s;
}

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

/* Queue */
.queue-section {
    background: rgba(255, 255, 255, 0.02);
    border-left: 1px solid var(--glass-border);
    padding: 1.5rem;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: auto;
}

.queue-list { flex: 1; overflow-y: auto; min-height: 0; }
.queue-item { display: flex; align-items: center; gap: 1rem; padding: 0.8rem; background: rgba(255, 255, 255, 0.03); border-radius: 12px; margin-bottom: 0.8rem; border: 1px solid var(--glass-border); }
.q-img { width: 50px; height: 50px; border-radius: 8px; }

.queue-item.voted {
    border-color: rgba(255, 0, 122, 0.35);
    background: rgba(255, 0, 122, 0.08);
}

.vote-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Photo Gallery Grid */
#photos-view { display: block; height: calc(100vh - 160px); overflow-y: auto; }
.photos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 2.5rem; padding: 3rem; }
.photo-card { position: relative; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border); border-radius: 25px; overflow: hidden; transition: transform 0.3s; }
.photo-card img { width: 100%; height: 280px; object-fit: cover; cursor: zoom-in; }
.photo-card-footer { padding: 1.5rem; background: rgba(0, 0, 0, 0.5); display: flex; flex-direction: column; gap: 1rem; }
.photo-user { font-size: 0.85rem; font-weight: 800; color: var(--primary); text-transform: uppercase; }
.photo-card-reactions { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.photo-card-reactions button { background: rgba(255, 255, 255, 0.1); border: none; color: white; padding: 0.5rem 1rem; border-radius: 30px; font-size: 1rem; cursor: pointer; display: flex; align-items: center; gap: 6px; }

/* TV MODE UI */
.tv-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: #000;
    z-index: 5000;
    display: flex;
    flex-direction: column;
}

.tv-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 5rem;
    position: relative;
    min-height: 0;
    overflow: auto;
}

.now-playing-huge {
    display: flex;
    align-items: center;
    gap: 2rem;
    width: 100%;
    max-width: 1400px;
    margin-bottom: 4rem;
}

.huge-artwork-container { display: none; }

.huge-info h1 { font-size: 4.5rem; font-weight: 800; margin-bottom: 0.5rem; line-height: 1.1; }
.huge-artist { font-size: 2.5rem; color: var(--primary); font-weight: 600; margin-bottom: 1rem; }
.added-by-huge { font-size: 1.5rem; color: var(--text-dim); margin-bottom: 2rem; }
.huge-info { width: 100%; max-width: 1200px; }

/* THE DEDICATION FIX */
.dedication-quote {
    font-family: 'Dancing Script', cursive;
    font-size: 3.5rem;
    color: #fff;
    text-shadow: 0 0 20px var(--primary);
    margin: 2rem 0;
    padding: 1.5rem 3rem;
    background: rgba(255, 255, 255, 0.1);
    border-left: 8px solid var(--primary);
    border-radius: 0 25px 25px 0;
    display: inline-block;
    max-width: 1000px;
    animation: dedicationPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dedication-quote::before { content: '“ '; color: var(--primary); font-size: 4rem; vertical-align: middle; }
.dedication-quote::after { content: ' ”'; color: var(--primary); font-size: 4rem; vertical-align: middle; }
#tv-mobile-dedication { display: none; }

@keyframes dedicationPop {
    from { transform: scale(0.8) translateX(-50px); opacity: 0; }
    to { transform: scale(1) translateX(0); opacity: 1; }
}

/* TV Footer & Exit */
.tv-footer {
    height: 120px;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5rem;
    gap: 3rem;
    border-top: 1px solid var(--glass-border);
    position: relative;
    z-index: 5;
}

.tv-reactions-box { display: flex; gap: 1rem; background: rgba(255,255,255,0.05); padding: 0.8rem 1.5rem; border-radius: 50px; }
.tv-reactions-box button { background: none; border: none; font-size: 2.2rem; cursor: pointer; transition: 0.2s; }
.tv-reactions-box button:hover { transform: scale(1.3); }

.ticker-wrap { flex: 1; overflow: hidden; }
.ticker { white-space: nowrap; display: inline-block; animation: tickerLoop 25s linear infinite; font-size: 1.8rem; font-weight: 600; color: var(--text-dim); }
@keyframes tickerLoop { 0% { transform: translateX(100%); } 100% { transform: translateX(-100%); } }

.exit-tv {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 1rem 2rem;
    border-radius: 15px;
    cursor: pointer;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: 0.3s;
}
.exit-tv:hover { background: var(--primary); border-color: var(--primary); transform: scale(1.05); }

/* Playbar */
.tv-playbar-container { width: 100%; max-width: 1000px; display: flex; align-items: center; gap: 2rem; margin-top: 1rem; color: var(--text-dim); font-weight: 800; }
.tv-progress-bg { flex: 1; height: 16px; background: rgba(255,255,255,0.1); border-radius: 10px; overflow: hidden; }
.tv-progress-fill { height: 100%; width: 0%; background: var(--primary); box-shadow: 0 0 20px var(--primary); transition: width 0.3s linear; }

/* Photo Stream */
.photo-stream { position: absolute; right: 4rem; top: 80px; bottom: 160px; width: 300px; display: flex; flex-direction: column; gap: 2rem; overflow: hidden; }
.stream-photo { width: 100%; border-radius: 30px; border: 4px solid rgba(255,255,255,0.1); }

/* Floating Reactions Overlay */
.global-reaction-layer { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 9999; }
.floating-reaction { position: absolute; display: flex; flex-direction: column; align-items: center; pointer-events: none; animation: reactionFloat 12s linear forwards; }
@keyframes reactionFloat {
    0% { transform: translateY(0) scale(0); opacity: 0; }
    5% { transform: translateY(-50px) scale(1.5); opacity: 1; }
    100% { transform: translateY(-900px) scale(1); opacity: 0; }
}

/* Modals */
.modal { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.9); backdrop-filter: blur(20px); display: flex; justify-content: center; align-items: center; z-index: 9000; }
.modal-content { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--glass-border); border-radius: 30px; padding: 3rem; max-width: 500px; width: 90%; }
#zoom-img { max-width: 90vw; max-height: 55vh; border-radius: 20px; margin-bottom: 2rem; object-fit: contain; }

.primary-btn { background: linear-gradient(135deg, var(--primary), var(--secondary)); border: none; color: white; padding: 1.2rem; border-radius: 15px; font-size: 1.1rem; font-weight: 800; cursor: pointer; box-shadow: var(--accent-glow); }
.secondary-btn { background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border); color: white; padding: 1.2rem; border-radius: 15px; cursor: pointer; }

/* Photo Spotlight */
.photo-spotlight { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.95); z-index: 10000; display: flex; justify-content: center; align-items: center; backdrop-filter: blur(40px); }
.spotlight-card { text-align: center; animation: spinIn 1.5s cubic-bezier(0.2, 0.8, 0.2, 1.2) forwards; }
@keyframes spinIn { 0% { transform: scale(0) rotate(-720deg); opacity: 0; } 100% { transform: scale(1) rotate(0deg); opacity: 1; } }
.spotlight-card img { max-width: 80vw; max-height: 75vh; border: 8px solid var(--primary); border-radius: 40px; box-shadow: 0 0 100px rgba(255,0,122,0.5); object-fit: contain; }
.spotlight-user { font-size: 2.5rem; color: white; margin-top: 2rem; font-weight: 800; text-shadow: 0 0 20px var(--primary); }

.pop { animation: popScale 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes popScale { 0% { transform: scale(1); } 50% { transform: scale(1.4); } 100% { transform: scale(1); } }

/* --- Mobile-first refinements and cleanup --- */
body {
    background:
        radial-gradient(circle at top right, rgba(112, 0, 255, 0.24), transparent 32%),
        radial-gradient(circle at bottom left, rgba(255, 0, 122, 0.18), transparent 34%),
        linear-gradient(180deg, #09090b 0%, #111118 100%);
    min-height: 100dvh;
}

#app-view {
    min-height: 100dvh;
    overflow: hidden;
}

header {
    position: sticky;
    top: 0;
    z-index: 300;
    background: rgba(10, 10, 12, 0.72);
    backdrop-filter: blur(20px);
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.logo-sm {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.badge,
.count-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.06);
    padding: 0.45rem 0.8rem;
    color: var(--text-dim);
    font-weight: 700;
    font-size: 0.82rem;
}

.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.06);
    color: white;
    cursor: pointer;
    font-size: 1.05rem;
}

.queue-header,
.now-playing-mini,
.playback-btns,
.modal-btns,
.setting-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.queue-header {
    justify-content: space-between;
    margin-bottom: 1rem;
}

.search-section,
.queue-section {
    min-width: 0;
}

.search-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 1rem;
    backdrop-filter: blur(18px);
}

.history-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: auto;
}

.history-item {
    width: 100%;
    text-align: left;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    color: white;
    padding: 0.9rem;
    margin-bottom: 0.8rem;
    cursor: pointer;
}

.queue-section {
    position: relative;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.search-bar {
    flex-wrap: wrap;
}

.search-bar input {
    min-width: 0;
    border-radius: 16px;
}

.search-bar button,
.primary-btn,
.secondary-btn,
.vote-btn {
    min-height: 48px;
}

.search-bar button {
    border-radius: 16px;
}

.results-grid {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.artwork-container {
    position: relative;
}

.duration-badge {
    position: absolute;
    bottom: 0.8rem;
    right: 0.8rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    font-size: 0.8rem;
    font-weight: 800;
}

.track-info h4,
.q-info h5 {
    line-height: 1.25;
    font-size: 1rem;
}

.track-info p,
.q-info p,
.added-by,
.placeholder-text {
    color: var(--text-dim);
    font-size: 0.92rem;
}

.placeholder-text {
    display: grid;
    place-items: center;
    min-height: 180px;
    text-align: center;
    padding: 1rem;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.02);
}

.track-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: 1rem 1.1rem;
    border-radius: 18px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.track-row:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.22);
}

.track-row-info {
    min-width: 0;
}

.track-row-info h4 {
    font-size: 1rem;
    line-height: 1.25;
    margin-bottom: 0.25rem;
}

.track-row-info p {
    color: var(--text-dim);
    font-size: 0.88rem;
}

.track-row-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.track-row-btn,
.host-launch-btn {
    border: none;
    border-radius: 14px;
    font-weight: 800;
    cursor: pointer;
}

.track-row-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.85rem 1rem;
}

.host-launch-btn {
    margin-top: 1.25rem;
    width: 100%;
    padding: 1rem 1.1rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: var(--accent-glow);
}

.host-admin-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.host-admin-actions .secondary-btn {
    width: 100%;
}

.reaction-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin: 0 2rem 1rem;
    padding: 0.9rem 1rem;
    border-radius: 22px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(16px);
}

.reaction-group {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.reaction-group span {
    color: var(--text-dim);
    font-weight: 700;
    font-size: 0.85rem;
    margin-right: 0.25rem;
}

.reaction-btn,
.photo-reaction-btn {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: white;
    border-radius: 14px;
    padding: 0.7rem 0.9rem;
    font-size: 1.05rem;
    cursor: pointer;
}

.photo-reaction-btn {
    padding: 0.7rem 0.85rem;
}

.track-card,
.photo-card,
.queue-item,
.modal-content,
.setup-card {
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
}

.tv-bg,
#tv-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: blur(40px) saturate(120%);
    opacity: 0.22;
}

.tv-content {
    z-index: 4;
}

.tv-player-shell {
    max-width: 1100px;
    margin: 0 auto 1.5rem;
}

.tv-overlay.video-mode .now-playing-huge {
    flex-direction: column;
    align-items: stretch;
    gap: 1.25rem;
    max-width: 1200px;
    margin-bottom: 1.5rem;
}

.tv-overlay.video-mode .tv-content {
    justify-content: flex-start;
    padding-top: 1rem;
    align-items: stretch;
}

.tv-overlay.video-mode .tv-player-shell {
    max-height: 46vh;
    min-height: 220px;
    margin-bottom: 0.8rem;
}

.tv-overlay.video-mode .huge-artwork-container {
    display: none;
}

.tv-overlay.video-mode .huge-info {
    width: 100%;
    text-align: left;
}

.tv-overlay.video-mode .huge-info h1 {
    font-size: clamp(2.4rem, 4.2vw, 4rem);
}

.tv-overlay.video-mode .huge-artist {
    font-size: clamp(1.4rem, 2.4vw, 2.2rem);
}

.tv-overlay.video-mode .added-by-huge {
    font-size: 1.1rem;
}

.tv-overlay.video-mode .dedication-quote {
    max-width: 100%;
    font-size: clamp(1.8rem, 3.5vw, 3rem);
}

.now-playing-mini {
    width: 100%;
}

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

.mini-info p,
.mini-info #mini-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.host-controls .now-playing-mini {
    display: none;
}

.host-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
    position: sticky;
    bottom: 0;
    padding-top: 1rem;
    padding-bottom: 0.25rem;
    background: linear-gradient(180deg, rgba(18, 12, 32, 0) 0%, rgba(18, 12, 32, 0.94) 22%, rgba(18, 12, 32, 0.98) 100%);
    backdrop-filter: blur(18px);
    z-index: 4;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.tv-player-shell {
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 190px;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.45);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.24);
}

.tv-player-shell.video-hidden {
    height: 0;
    min-height: 0;
    opacity: 0;
    margin: 0;
    border: 0;
    box-shadow: none;
    pointer-events: none;
    overflow: hidden;
}

.tv-player-shell.hidden { display: none; }

.tv-player-shell.audio-compact {
    position: absolute;
    width: 2px;
    height: 2px;
    top: 0.5rem;
    left: 0.5rem;
    opacity: 0.02;
    pointer-events: none;
    overflow: hidden;
    margin: 0;
    border-width: 0;
    box-shadow: none;
}

.youtube-player {
    width: 100%;
    height: 100%;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    margin: 0.9rem 0 0.25rem;
    color: var(--text-dim);
    font-size: 0.95rem;
    font-weight: 600;
}

.toggle-row input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.playback-btns {
    justify-content: flex-start;
}

.modal-btns {
    justify-content: flex-end;
    flex-wrap: wrap;
    margin-top: 1.25rem;
}

.setting-item {
    justify-content: space-between;
    margin: 0.9rem 0;
}

.setting-item input[type="number"] {
    width: 110px;
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

@media (max-width: 900px) {
    body {
        overflow-y: auto;
        overflow-x: hidden;
    }

    #app-view {
        overflow: visible;
    }

    header {
        padding: 1rem 1rem;
    }

    .app-tabs {
        position: sticky;
        top: 74px;
        z-index: 250;
        padding: 0.7rem 1rem 0.9rem;
        gap: 0.7rem;
    }

    main {
        grid-template-columns: 1fr;
        height: auto;
        min-height: auto;
        padding: 1rem;
        gap: 1rem;
    }

    .queue-section {
        order: 2;
    }

    .search-section {
        order: 1;
    }

    .history-section {
        order: 3;
    }

    .results-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        height: auto;
        padding-right: 0;
        max-height: none;
    }

    .queue-list {
        max-height: 42vh;
    }

    .queue-section {
        max-height: none;
    }

    .reaction-bar {
        margin: 0 1rem 1rem;
    }

    .tv-content {
        padding: 1.25rem;
    }

    .now-playing-huge {
        flex-direction: column;
        gap: 1.5rem;
        margin-bottom: 2rem;
    }

    .huge-info h1 {
        font-size: clamp(2.2rem, 7vw, 3.5rem);
    }

    .dedication-quote {
        font-size: clamp(1.9rem, 5vw, 2.8rem);
        padding: 1rem 1.4rem;
    }

    .tv-footer {
        padding: 1rem;
        flex-wrap: wrap;
        height: auto;
    }

    .ticker-wrap {
        order: 3;
        width: 100%;
    }

    .photo-stream {
        position: static;
        width: 100%;
        max-width: 340px;
        margin: 0 auto;
        max-height: 220px;
    }

    #tv-mobile-dedication {
        display: inline-block;
        margin: 0 0 1rem 0;
    }

    #huge-dedication {
        display: none !important;
    }
}

@media (max-width: 640px) {
    .setup-card {
        width: 94%;
        padding: 1.5rem;
        border-radius: 22px;
    }

    .logo {
        font-size: 2.4rem;
    }

    .tab-container {
        margin: 1.25rem 0;
    }

    .search-section,
    .queue-section,
    .photo-card,
    .track-card,
    .modal-content {
        border-radius: 18px;
    }

    .search-bar {
        flex-direction: column;
    }

    .search-bar button {
        width: 100%;
    }

    .results-grid {
        gap: 0.75rem;
    }

    .track-row {
        align-items: flex-start;
    }

    .track-row-meta {
        align-items: flex-end;
    }

    .host-admin-actions {
        grid-template-columns: 1fr;
    }

    .queue-item {
        align-items: flex-start;
    }

    .queue-section {
        overflow: auto;
    }

    .queue-item {
        padding: 0.7rem;
        gap: 0.75rem;
    }

    .vote-controls {
        min-width: 44px;
        justify-content: center;
    }

    .q-img {
        width: 58px;
        height: 58px;
    }

    .header-left,
    .header-right {
        gap: 0.6rem;
    }

    .logo-sm {
        font-size: 1.35rem;
    }

    .icon-btn {
        width: 38px;
        height: 38px;
        border-radius: 12px;
    }

    .reaction-bar {
        gap: 0.65rem;
    }

    .reaction-group {
        gap: 0.45rem;
    }

    .reaction-btn,
    .photo-reaction-btn {
        padding: 0.65rem 0.78rem;
        border-radius: 12px;
    }

    .modal-btns {
        justify-content: stretch;
    }

    .modal-btns .primary-btn,
    .modal-btns .secondary-btn {
        width: 100%;
    }
}

#app-view {
    display: flex;
    flex-direction: column;
    height: 100dvh;
}

main {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
}

.app-tabs,
.reaction-bar {
    flex-shrink: 0;
}

@media (orientation: landscape) and (max-height: 540px) {
    header {
        padding: 0.7rem 1rem;
    }

    .app-tabs {
        top: 58px;
        padding: 0.55rem 1rem 0.7rem;
    }

    main {
        grid-template-columns: minmax(0, 1.4fr) minmax(230px, 0.7fr) minmax(230px, 0.7fr);
        padding: 0.9rem;
        gap: 0.9rem;
        height: calc(100dvh - 128px);
    }

    .queue-section {
        max-height: calc(100dvh - 150px);
    }

    .tv-content {
        padding: 0.8rem 1rem;
    }

    .tv-player-shell {
        max-width: 100%;
        min-height: 140px;
    }

    .tv-overlay.video-mode .now-playing-huge {
        gap: 0.8rem;
        margin-bottom: 1rem;
    }

    .tv-footer {
        height: auto;
        padding: 0.75rem 1rem;
    }
}
