:root {
    --sidebar-bg: #34495e;
    --player-bg: #2c3e50;
    --accent: #f97316;
    --text-white: #ffffff;
    --bg-main: #f3f4f6;
    --text-dark: #0f172a;
    --text-grey: #6b7280;
    --sidebar-width: 260px;
    --player-height: 80px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

input, textarea, select {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

button,
input,
select {
    font-family: inherit;
}

button:focus,
input:focus,
select:focus {
    outline: none;
}

body {
    font-family: 'Open Sans', sans-serif;
    background: var(--bg-main);
    color: var(--text-dark);
    overflow: hidden;
    position: fixed; /* CRITICAL FIX: Prevents iOS background scroll when keyboard opens */
    width: 100%;
    height: 100%;
}

.app-container {
    display: flex;
    height: 100vh;
    padding-bottom: var(--player-height);
}

/* SIDEBAR */

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    padding: 20px;
    flex-shrink: 0;
    overflow-y: auto;
    transition: transform 0.3s ease;
    bottom: var(--player-height);
    z-index: 101;
}

.logo-area {
    font-size: 1.3rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}
.logo-icon {
    font-size: 1.8rem;
}
.logo-icon-img {
    width: 35px;
    height: 35px;
    object-fit: contain;
}

.online-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: default;
    animation: fadeIn 0.5s;
}

/* Icon Animation & Color */
.online-badge .material-icons {
    font-size: 18px;
    color: #4ade80; /* Green */
    animation: pulse-icon 2s infinite ease-in-out;
}
.online-count-num {
    color: #ffffff;
}

@keyframes pulse-icon {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

/* Mobile Positioning */
.mobile-badge {
    margin-left: auto; /* Pushes to the far right */
}

.sidebar-search {
    background: #ffffff;
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 6px 8px;
    margin-bottom: 12px;
    gap: 4px;
}
.sidebar-search .material-icons {
    color: #888;
}
.sidebar-search input {
    border: none;
    outline: none;
    width: 100%;
    font-size: 0.9rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #9ca3af;
    transition: .2s;
    border-radius: 999px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .2s;
    border-radius: 50%;
}
input:checked + .slider {
    background-color: var(--accent);
}
input:checked + .slider:before {
    transform: translateX(16px);
}

/* NAV */

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.nav-section-title {
    font-size: 0.75rem;
    font-weight: 700;
    opacity: 0.8;
    margin-top: 15px;
    margin-bottom: 5px;
    letter-spacing: 1px;
    color: #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}
.nav-section-title:hover {
    opacity: 1;
}
.nav-section-title .material-icons {
    font-size: 1.2rem;
    transition: transform 0.2s;
}
.nav-section-title.collapsed .material-icons {
    transform: rotate(-90deg);
}

.nav-item {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.9);
    text-align: left;
    padding: 10px;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 6px;
    transition: 0.2s;
}
.nav-item .material-icons {
    font-size: 1.1rem;
}
.nav-item:hover {
    background: rgba(255,255,255,0.12);
}
.nav-item.active {
    background: rgba(255,255,255,0.18);
    border-left: 4px solid var(--accent);
}

/* Accordion Content */
.accordion-container.collapsed {
    display: none;
}

/* Search history */

.history-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 4px;
}
.history-clear-btn {
    border: none;
    background: rgba(255,255,255,0.12);
    color: #f9fafb;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 999px;
    cursor: pointer;
}
.history-clear-btn:hover {
    background: rgba(255,255,255,0.2);
}
.history-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.history-item {
    border: none;
    background: rgba(255,255,255,0.12);
    color: #f9fafb;
    font-size: 0.8rem;
    padding: 4px 8px;
    border-radius: 4px;
    text-align: left;
    cursor: pointer;
}
.history-item:hover {
    background: rgba(255,255,255,0.2);
}

/* MAIN CONTENT */

.main-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 30px 40px;
    background: #ffffff;
    position: relative;
}

.hero-text h1 {
    font-size: 1.8rem;
    margin-bottom: 10px;
    color: var(--text-dark);
}
.hero-text p {
    font-size: 1rem;
    color: var(--text-grey);
    margin-bottom: 30px;
    max-width: 700px;
}
.section-heading {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: var(--text-grey);
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 10px;
    margin-bottom: 20px;
    margin-top: 10px;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
}

/* VIEWS - FIXED POSITIONING */

.view {
    display: none;
    width: 100%;
    animation: fadeIn 0.3s ease-out;
}

#view-social {
    height: 100%;
}

.view.active-view {
    display: block;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* LIST VIEW */

.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
}


/* SCROLL TO TOP BUTTON */
.scroll-top-btn {
    position: fixed;
    bottom: 100px; /* Above player bar (80px) + 20px gap */
    right: 30px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    cursor: pointer;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    transform: translateY(10px);
}
.scroll-top-btn.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.scroll-top-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

/* HORIZONTAL SCROLL GRID (For Top Voted) */
.horizontal-grid {
    display: flex;
    overflow-x: auto;
    gap: 14px;
    padding-bottom: 14px; /* Space for scrollbar */
    scroll-behavior: smooth;
}
.horizontal-grid .card {
    min-width: 160px;
    width: 160px;
    flex-shrink: 0;
}
.horizontal-grid::-webkit-scrollbar { height: 6px; }
.horizontal-grid::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }

.card {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border-radius: 8px;
    padding: 6px;
    background: #f9fafb;
    box-shadow: 0 1px 3px rgba(15,23,42,0.06);
    position: relative;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(15,23,42,0.12);
}

.card-img-wrap {
    width: 100%;
    aspect-ratio: 1/1;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    background: #e5e7eb;
    margin-bottom: 6px;
}
.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-dark);
    margin-bottom: 2px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-subtitle {
    font-size: 0.75rem;
    color: var(--text-grey);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-votes {
    font-size: 0.7rem;
    color: var(--accent);
    font-weight: 600;
    margin-top: 2px;
}

.card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}
.card-actions-left,
.card-actions-right {
    display: flex;
    gap: 4px;
}
.card-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    padding: 2px;
}
.card-icon-btn:hover {
    color: var(--accent);
}

/* DASHBOARD STYLES */
.dash-section {
    margin-bottom: 40px;
}
.dash-header {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.horizontal-chip-grid {
    display: grid;
    grid-template-rows: repeat(3, min-content);
    grid-auto-flow: column;
    overflow-x: auto;
    gap: 10px;
    padding-bottom: 10px;
    scroll-behavior: smooth;
}
.horizontal-chip-grid::-webkit-scrollbar { height: 4px; }
.horizontal-chip-grid::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.chip {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 0.9rem;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    white-space: nowrap;
    flex-shrink: 0;
}
.chip:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* PLAYER BAR - UPDATED LAYOUT */

.player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--player-height);
    background: var(--player-bg);
    color: var(--text-white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 200;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
}

.player-left {
    display: flex;
    align-items: center;
    width: 60%;
    cursor: pointer;
}
.player-art-wrap {
    position: relative;
}
#player-art {
    width: 52px;
    height: 52px;
    border-radius: 4px;
    margin-right: 10px;
    background: #4b5563;
    object-fit: cover;
}

.track-info {
    flex: 1;
    min-width: 0;
}
.p-title {
    font-weight: 700;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.p-artist {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-right {
    width: 40%;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
}

/* VOLUME CONTROL */
.volume-wrap {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-right: 10px;
}
.volume-wrap input[type=range] {
    width: 70px;
    cursor: pointer;
    accent-color: var(--accent);
    height: 4px;
}

/* --- PLAYER BAR BUTTONS --- */

.icon-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.9);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    color: #ffffff;
    transform: scale(1.1);
}

/* SHARED: Circle Buttons (Grey Bubble -> Orange Hover) */
.circle-icon-btn {
    color: #374151;
    background: #f3f4f6;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.circle-icon-btn:hover {
    background: #e5e7eb;
    color: var(--accent);
    transform: scale(1.05);
}

/* Standard size for normal icons (Fav, Chat) */
.icon-btn .material-icons {
    font-size: 24px;
}

/* --- THE PLAY BUTTON (Orange Circle) --- */
.play-circle {
    background: var(--accent); /* Orange Background */
    color: white;              /* White Icon */
    width: 42px;               /* Fixed Width */
    height: 42px;              /* Fixed Height */
    border-radius: 50%;        /* Perfect Circle */
    margin-right: 10px;        /* Spacing from other buttons */
    box-shadow: 0 4px 10px rgba(249, 115, 22, 0.4); /* Nice Glow */
}

/* Remove the default transparent hover and add a brightness effect instead */
.play-circle:hover {
    background: #ea580c;       /* Darker Orange on Hover */
    color: white;
    transform: scale(1.1);
}

/* Ensure the icon inside fits the circle */
.play-circle .material-icons {
    font-size: 28px; /* Bigger icon inside the circle */
}

/* --- EXTENDED NOW PLAYING VIEW --- */

.np-layout {
    padding: 20px 0 40px;
    max-width: 800px;
    margin: 0 auto;
}

.np-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 10px;
}

.np-header-row h2 {
    font-size: 1.2rem;
    color: var(--text-dark);
    margin: 0;
}

/* FIX: Make header buttons visible on the white background */
.np-header-row .icon-btn {
    color: #374151; /* Dark Grey (fixes the invisible button issue) */
    background: #f3f4f6; /* Light Grey Bubble */
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.np-header-row .icon-btn:hover {
    background: #e5e7eb;
    color: var(--accent);
    transform: scale(1.05);
}

.np-header-row .icon-btn:hover {
    color: #f97316; /* Orange on hover */
    transform: scale(1.1);
}

/* Remove the old margin since the button is gone from the bottom */
.np-actions {
    margin-top: 0;
}

.np-main-row {
    display: flex;
    gap: 40px;
    align-items: center; /* Vertically center art and text */
}

/* Artwork Styling */
.np-art-col img {
    width: 300px;
    height: 300px;
    border-radius: 16px;
    object-fit: cover;
    box-shadow: 0 15px 35px rgba(0,0,0,0.15); /* "Music Player" Shadow */
}

/* VISUALIZER */
#visualizer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 16px;
    pointer-events: none;
}

/* ARTWORK SEARCH OVERLAY */
.np-art-wrapper {
    position: relative;
    width: fit-content;
    margin: 0 auto; /* Ensures it stays centered if parent flex aligns it */
}

.art-actions {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

.art-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.art-action-btn:hover {
    background: var(--accent);
    transform: scale(1.1);
}

.sleep-active {
    background: var(--accent);
    border-color: var(--accent);
}

/* RECORDING STATE */
.recording-active {
    background: #ef4444 !important; /* Red */
    border-color: #ef4444 !important;
    animation: pulse-red 1.5s infinite;
}
@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.art-menu-dropdown {
    position: absolute;
    bottom: 60px;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    min-width: 140px;
    z-index: 20;
    overflow: hidden;
}
.art-menu-dropdown button {
    background: none;
    border: none;
    text-align: left;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-dark);
    width: 100%;
}
.art-menu-dropdown button:hover {
    background: #f3f4f6;
    color: var(--accent);
}

/* Sleep Menu Specifics */
.menu-separator {
    height: 1px;
    background: #e5e7eb;
    margin: 4px 0;
}
.sleep-option.selected {
    color: var(--accent);
    font-weight: 700;
    background: #fff7ed;
}
.art-menu-dropdown::-webkit-scrollbar { width: 4px; }
.art-menu-dropdown::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* Text Styling */
.np-info-col {
    flex: 1;
    max-width: 400px; /* Constrain width for proper ellipsis */
}

.np-info-col h3 {
    font-size: 1.8rem; /* Bigger Title */
    margin-bottom: 8px;
    line-height: 1.2;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.np-info-col p#np-artist {
    font-size: 1.1rem;
    color: var(--accent); /* Highlight Artist/Status */
    margin-bottom: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%; /* Ensure it respects parent width */
}

.np-meta {
    margin-top: 5px;
    font-size: 0.9rem;
    color: #6b7280;
    background: #f8fafc;
    padding: 10px;
    border-radius: 8px;
    display: inline-block;
}

/* ABOUT VIEW */

.about-layout {
    padding: 10px 0 40px;
    max-width: 600px;
    margin: 0 auto;
}
.about-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
}
.about-app-icon {
    width: 85px;
    height: 85px;
    object-fit: contain;
}
.about-layout h2 {
    font-size: 1.4rem;
    margin-bottom: 4px;
}
.about-version {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 10px;
}
.about-text {
    margin-top: 10px;
    font-size: 0.95rem;
    color: #4b5563;
}


/* PAGINATION */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 24px 0 10px;
}
.page-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid #d1d5db;
    background: #f3f4f6;
    color: #1e293b;
    cursor: pointer;
    font-size: 0.85rem;
}
.page-btn:disabled {
    opacity: 0.4;
    cursor: default;
}
.page-info {
    font-size: 0.9rem;
    color: #555;
}

/* MODALS */

.modal {
    position: fixed;
    inset: 0;
    z-index: 300;
}
.modal.hidden {
    display: none;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15,23,42,0.35);
}
.modal-content {
    position: relative;
    max-width: 480px;
    margin: 60px auto;
    background: #ffffff;
    border-radius: 12px;
    padding: 20px 20px 18px;
    box-shadow: 0 18px 45px rgba(15,23,42,0.25);
}
.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    border: none;
    background: none;
    cursor: pointer;
    color: #6b7280;
}
.modal-close:hover {
    color: #111827;
}
.modal-header {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}
#modal-art {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    background: #e5e7eb;
}
.modal-header-text {
    min-width: 0;
}
.modal-header h3 {
    margin-bottom: 4px;
    word-wrap: break-word;
    word-break: break-word;
}
.modal-body p {
    font-size: 0.9rem;
    margin-bottom: 6px;
    word-wrap: break-word;
    word-break: break-word;
}
.modal-body a {
    color: var(--accent);
    text-decoration: none;
    word-break: break-all;
}
.modal-body a:hover {
    text-decoration: underline;
}
.modal-tags span {
    word-wrap: break-word;
}
.modal-station .modal-body-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 20px;
}

.modal-actions {
    text-align: right;
    margin-top: 10px;
}

/* CONFIRMATION MODAL STYLES */
.admin-modal-content {
    text-align: center;
    max-width: 320px;
}
.modal-title {
    margin-bottom: 8px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-dark);
}
.modal-text {
    font-size: 0.95rem;
    color: var(--text-grey);
    margin-bottom: 24px;
    line-height: 1.5;
}
.modal-actions.center-actions {
    justify-content: center;
    display: flex;
    gap: 12px;
}
.modal-btn {
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    transition: opacity 0.2s;
}
.modal-btn:hover { opacity: 0.9; }
.modal-btn.cancel { background: #f3f4f6; color: #1e293b; }
.modal-btn.delete { background: #ef4444; color: white; }

.settings-select {
    width: 100%;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: var(--text-dark);
    font-size: 0.95rem;
}

/* MOBILE */

.mobile-header {
    display: none;
}
.sidebar-overlay {
    display: none;
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .mobile-header {
        display: flex;
        align-items: center;
        height: 60px;
        background: var(--sidebar-bg);
        color: #ffffff;
        padding: 0 15px;
        flex-shrink: 0;
    }
    .mobile-logo {
        font-size: 1.2rem;
        font-weight: 700;
        display: flex;
        align-items: center;
        gap: 10px;
        margin-left: 15px;
    }
    .mobile-logo-icon {
        width: 30px;
        height: 30px;
        object-fit: contain;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: var(--sidebar-width);
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
        -webkit-overflow-scrolling: touch;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        bottom: var(--player-height);
        z-index: 400;
    }
    .history-list {
        max-height: 40vh;
        overflow-y: auto;
        overscroll-behavior: contain;
        margin-bottom: 1rem;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.active {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: var(--player-height);
        background: rgba(0,0,0,0.35);
        cursor: pointer;
        z-index: 350;
    }
    .main-content,
    .view { /* Keep selector for specificity but rely on main-content padding */
        padding: 0; 
    }
    .main-content {
        padding: 20px 15px 90px;
    }

    .hero-text h1 {
        font-size: 1.4rem;
    }

    .modal-content {
        margin: 40px auto;
        width: 90%;
    }

    .np-layout {
        position: fixed;
        left: 0;
        right: 0;
        top: 60px; /* below the mobile header */
        bottom: var(--player-height); /* above the player bar */
        width: auto;
        max-width: 600px;
        margin: 0 auto;
        z-index: 300;
        background: #fff;
        overflow-y: auto;
        box-shadow: 0 0 40px rgba(0,0,0,0.18);
        display: flex;
        flex-direction: column;
        height: auto;
        left: 0;
        right: 0;
        padding-left: 12px;
        padding-right: 12px;
    }

    .np-main-row {
        flex-direction: column;
        text-align: center; /* Center all text */
        gap: 25px;
        margin-top: 20px;
    }

    .np-art-col img {
        width: 260px; /* Slightly smaller on mobile */
        height: 260px;
        margin: 0 auto; /* Center the image */
    }

    .np-info-col {
        width: 100%;
    }

    .np-info-col h3 {
        font-size: 1.5rem;
    }

    /* MOBILE PLAYER ADJUSTMENTS */
    .player-bar {
        padding: 0 8px;
    }
    .player-left {
        width: 65%;
    }
    .track-info {
        max-width: 140px;
    }
    .player-right {
        width: 35%;
        justify-content: flex-end;
        gap: 6px;
    }
    .volume-wrap {
        display: none; /* Hide volume slider on mobile */
    }

    /* MOBILE GRID ADJUSTMENTS */
    .channel-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }

    /* Hide the desktop badge that sits in player bar on mobile */
    .desktop-badge {
        display: none !important;
    }

    /* Hide duplicate online count in chat header on mobile */
    .chat-status {
        display: none !important;
    }

    /* FIXED CHAT ON MOBILE */
    #view-chat, #view-social {
        position: fixed;
        top: 60px;
        bottom: 80px; /* Ensure it sits above player bar */
        left: 0;
        right: 0;
        height: auto; /* Override desktop 100% height to respect top/bottom anchors */
        background: #ffffff;
        z-index: 150; /* Ensure it is above main content but below player bar (200) */
        display: none;
        flex-direction: column;
        overflow: hidden; /* Critical: Prevents iframe from expanding parent on iOS */
    }
    #view-chat.active-view, #view-social.active-view {
        display: flex;
    }
    .chat-layout {
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 10px;
        display: flex;
        flex-direction: column;
        overflow: hidden; /* Critical: Prevents layout from expanding beyond viewport */
    }
    .chat-messages {
        flex: 1;
        min-height: 0; /* Critical for scrolling inside flex */
    }
    .chat-header,
    .chat-input-area {
        flex-shrink: 0; /* Prevent input from being squashed */
    }

    /* Hide custom emoji picker on mobile (use keyboard instead) */
    .emoji-toggle-btn {
        display: none !important;
    }
}

/* ZEN MODE */
body.zen-mode .sidebar,
body.zen-mode .player-bar,
body.zen-mode .mobile-header,
body.zen-mode .hero-text {
    display: none !important;
}

body.zen-mode .app-container {
    height: 100vh;
    padding: 0;
}

body.zen-mode .np-layout {
    position: fixed;
    inset: 0;
    max-width: none;
    background: #111827; /* Very Dark Blue/Grey */
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px;
}

body.zen-mode .np-header-row {
    position: absolute;
    top: 20px;
    right: 20px;
    left: 20px;
    border: none;
    justify-content: flex-end;
}
body.zen-mode .np-header-row h2 { display: none; }
body.zen-mode .np-header-row .icon-btn {
    background: rgba(255,255,255,0.1);
    color: white;
}

body.zen-mode .np-header-row .icon-btn:not(#zen-btn) {
    display: none;
}

/* TOAST NOTIFICATION */
.toast {
    position: fixed;
    bottom: 100px; /* Above player bar */
    left: 50%;
    transform: translateX(-50%);
    background: rgba(31, 41, 55, 0.95);
    color: white;
    padding: 12px 24px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 2000;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    animation: fadeUp 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 8px;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* CHAT VIEW */
.chat-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--player-height) - 60px); /* Full height minus player & padding */
    max-width: 800px;
    margin: 0 auto;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 15px;
}
.chat-header h2 { font-size: 1.2rem; color: var(--text-dark); }
.chat-status { font-size: 0.85rem; color: var(--text-grey); display: flex; align-items: center; gap: 6px; }
.status-dot { width: 8px; height: 8px; background: #4ade80; border-radius: 50%; display: inline-block; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 5px;
    margin-bottom: 15px;
}

.chat-msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

/* Messages from others */
.chat-msg.received {
    align-self: flex-start;
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 2px;
    cursor: pointer;
}

/* Messages from me */
.chat-msg.sent {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-sender {
    font-size: 0.7rem;
    margin-bottom: 2px;
    opacity: 0.7;
    font-weight: 700;
}

/* Reply Preview (Above Input) */
.reply-preview {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 2px;
    animation: slideUp 0.2s ease-out;
}
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.reply-info {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    border-left: 4px solid var(--accent);
    padding-left: 8px;
    max-width: 90%;
}
.reply-to-user {
    font-weight: 700;
    color: var(--accent);
    font-size: 0.8rem;
}
.reply-to-text {
    color: var(--text-grey);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Reply Context inside Message Bubble */
.msg-reply-context {
    background: rgba(0,0,0,0.05);
    border-left: 4px solid rgba(0,0,0,0.1);
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 6px;
    font-size: 0.8rem;
    cursor: pointer;
}
.chat-msg.sent .msg-reply-context {
    background: rgba(255,255,255,0.2);
    border-left-color: rgba(255,255,255,0.5);
    color: rgba(255,255,255,0.9);
}
.reply-sender {
    font-weight: 700;
    display: block;
    font-size: 0.75rem;
    margin-bottom: 2px;
}
.reply-snippet {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.8;
}

/* Mentions */
.mention {
    font-weight: 600;
    padding: 0 2px;
    border-radius: 3px;
}
.chat-msg.sent .mention {
    color: #fff !important;
    background: rgba(255,255,255,0.2);
}

.chat-system-msg {
    text-align: center;
    font-size: 0.8rem;
    color: #9ca3af;
    margin: 10px 0;
}

.chat-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f9fafb;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    position: relative;
}
#chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.95rem;
}

/* SETTINGS VIEW */
.settings-layout {
    max-width: 600px;
    margin: 0 auto;
    padding: 10px 0 40px;
}
.settings-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e7eb;
}
.settings-header h2 {
    font-size: 1.4rem;
    color: var(--text-dark);
    margin: 0;
}
.settings-content {
    display: flex;
    flex-direction: column;
    gap: 25px;
}
.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.setting-group.row {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}
.setting-label {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 1rem;
}
.setting-desc {
    font-size: 0.85rem;
    color: var(--text-grey);
    margin-bottom: 5px;
}
.settings-actions {
    margin-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}
.danger-btn {
    background: transparent;
    border: 1px solid #ef4444;
    color: #ef4444;
}
.danger-btn:hover {
    background: #fef2f2;
}
.primary-btn {
    background: var(--accent);
    color: white;
    border: none;
    font-weight: 600;
}
.primary-btn:hover {
    opacity: 0.9;
}

/* Emoji Picker Container */
.emoji-picker {
    position: absolute;
    bottom: 100%;
    margin-bottom: 10px;
    left: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    z-index: 100;
    width: 320px;
    height: 350px; /* Fixed height to enable internal scrolling */
    display: flex;
    flex-direction: column; /* Stack tabs on top of content */
    overflow: hidden; 
}

/* Fixed Top Bar */
.emoji-tabs {
    display: flex;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 6px;
    gap: 4px;
    flex-shrink: 0; /* Prevents the header from scrolling away */
}

.emoji-tab {
    flex: 1;
    background: none;
    border: none;
    padding: 8px 0;
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-tab:hover { background: #edf2f7; }
.emoji-tab.active {
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Scrollable Emoji Grid */
.emoji-content {
    flex-grow: 1; /* Takes up all remaining space */
    padding: 10px;
    overflow-y: auto; /* Only this part scrolls */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 4px;
    align-content: start;
}

.emoji-content::-webkit-scrollbar { width: 6px; }
.emoji-content::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }

.emoji-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    border-radius: 8px;
    transition: background 0.2s, transform 0.1s;
}

.emoji-btn:hover {
    background: #f3f4f6;
    transform: scale(1.1);
}

/* UTILS */

.hidden {
    display: none !important;
}
.loader {
    width: 30px;
    height: 30px;
    border: 3px solid #ddd;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s infinite linear;
    margin: 20px auto;
}
@keyframes spin {
    100% { transform: rotate(360deg); }
}