/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0f0f23;
    --bg-card: #1a1a2e;
    --bg-input: #16213e;
    --primary: #e94560;
    --primary-dark: #c73e54;
    --text: #eee;
    --text-secondary: #999;
    --border: #2a2a4a;
    --success: #4ade80;
    --nav-height: 72px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
    font-size: 18px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    overflow-x: hidden;
    padding-bottom: calc(var(--nav-height) + var(--safe-bottom));
}

/* === Views === */
.view { display: block; }
.view.hidden { display: none; }
.hidden { display: none !important; }

/* === Search Bar === */
.search-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 12px;
    background: var(--bg);
}

.search-bar input {
    width: 100%;
    padding: 14px 16px;
    font-size: 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-input);
    color: var(--text);
    outline: none;
    -webkit-appearance: none;
}

.search-bar input:focus {
    border-color: var(--primary);
}

.search-bar input::placeholder {
    color: var(--text-secondary);
}

/* === Song List === */
.song-list {
    padding: 0 12px 12px;
}

.song-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    margin-bottom: 8px;
    background: var(--bg-card);
    border-radius: 12px;
    gap: 12px;
}

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

.song-title {
    font-size: 20px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-artist {
    font-size: 18px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.song-duration {
    font-size: 15px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.btn-add {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.btn-add:active {
    background: var(--primary-dark);
    transform: scale(0.92);
}

/* === Artist List === */
.artist-list {
    padding: 12px;
}

.artist-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    margin-bottom: 8px;
    background: var(--bg-card);
    border-radius: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.artist-item:active {
    background: var(--bg-input);
}

.artist-item-name {
    font-size: 22px;
    font-weight: 600;
}

.artist-item-count {
    font-size: 17px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* === Sub Header (Artist Songs) === */
.sub-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 10;
}

.sub-header h2 {
    font-size: 24px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-back {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.btn-back:active {
    background: var(--bg-card);
}

/* === Queue Page === */
.now-playing {
    margin: 12px;
    padding: 20px;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 1px solid var(--primary);
    border-radius: 16px;
    text-align: center;
}

.now-playing-label {
    font-size: 16px;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.now-playing-title {
    font-size: 26px;
    font-weight: 700;
}

.now-playing-artist {
    font-size: 19px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.now-playing-empty {
    font-size: 20px;
    color: var(--text-secondary);
}

/* === Progress Bar === */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    margin-top: 14px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.5s linear;
}

.progress-time {
    display: flex;
    justify-content: space-between;
    font-size: 15px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* === Player Controls === */
.player-controls {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    justify-content: center;
}

.btn-ctrl {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    background: var(--primary);
    color: #fff;
    -webkit-tap-highlight-color: transparent;
}

.btn-ctrl:active {
    background: var(--primary-dark);
    transform: scale(0.95);
}

.btn-ctrl-secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-ctrl-secondary:active {
    background: var(--bg-input);
}

.queue-actions {
    display: flex;
    gap: 10px;
    padding: 0 12px;
    margin-bottom: 16px;
}

.btn {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.btn-next {
    background: var(--primary);
    color: #fff;
}

.btn-next:active {
    background: var(--primary-dark);
}

.btn-clear {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-clear:active {
    background: var(--bg-input);
}

.queue-title {
    padding: 0 16px;
    margin-bottom: 8px;
    font-size: 19px;
    color: var(--text-secondary);
}

.btn-remove {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #3a2030;
    color: var(--primary);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.btn-remove:active {
    background: #4a2040;
}

/* === Bottom Navigation === */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: #111128;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-secondary);
    padding: 6px 16px;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

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

.nav-icon {
    font-size: 28px;
    line-height: 1;
}

.nav-label {
    font-size: 14px;
    margin-top: 2px;
}

.badge {
    position: absolute;
    top: 0;
    right: 4px;
    background: var(--primary);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* === Toast === */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--success);
    color: #000;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 19px;
    font-weight: 600;
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
}

/* === Download Page === */
.download-form {
    display: flex;
    gap: 10px;
    padding: 12px;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg);
}

.download-form input {
    flex: 1;
    padding: 14px 16px;
    font-size: 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-input);
    color: var(--text);
    outline: none;
    -webkit-appearance: none;
}

.download-form input:focus {
    border-color: var(--primary);
}

.download-form input::placeholder {
    color: var(--text-secondary);
}

.btn-download {
    flex-shrink: 0;
    padding: 14px 20px;
    background: var(--primary);
    color: #fff;
}

.btn-download:active {
    background: var(--primary-dark);
}

.task-list {
    padding: 0 12px 12px;
}

.task-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    margin-bottom: 8px;
    background: var(--bg-card);
    border-radius: 12px;
    gap: 12px;
}

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

.task-title {
    font-size: 20px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-artist {
    font-size: 18px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.task-status {
    font-size: 16px;
    font-weight: 600;
    margin-top: 4px;
}

.task-active {
    color: #f59e0b;
}

.task-done {
    color: var(--success);
}

.task-error {
    color: var(--primary);
}

.task-progress {
    font-size: 15px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.task-error-msg {
    font-size: 15px;
    color: var(--primary);
    margin-top: 2px;
    word-break: break-all;
}

/* === Audio Toggle === */
.audio-toggle {
    background: #1a3a2e;
    color: var(--success);
    border: 1px solid var(--success);
}

.audio-toggle:active {
    background: #2a4a3e;
}

/* === Empty State === */
.empty-state {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 20px;
    font-size: 19px;
}
