:root {
    --bg: #111111;
    --bg-elev: #1a1a1a;
    --bg-elev-2: #222222;
    --text: #eeeeee;
    --text-dim: #9a9a9a;
    --accent: #e8c97a;
    --danger: #d76d6d;
    --border: #2a2a2a;
    --tap-min: 48px;
    --radius: 10px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 17px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    /* Honour the iPhone safe area in standalone PWA mode. */
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
             env(safe-area-inset-bottom) env(safe-area-inset-left);
}

a {
    color: var(--accent);
    text-decoration: none;
}

button, input[type="submit"] {
    font: inherit;
    color: var(--text);
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: var(--tap-min);
    padding: 0 18px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

button:active {
    background: var(--bg-elev-2);
}

button[aria-pressed="true"] {
    background: var(--accent);
    color: #111;
    border-color: var(--accent);
}

input[type="password"], input[type="text"] {
    font: inherit;
    width: 100%;
    color: var(--text);
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: var(--tap-min);
    padding: 0 14px;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: var(--tap-min);
    background: transparent;
    margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    background: var(--bg-elev-2);
    border-radius: 3px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: -8px;
}

input[type="range"]::-moz-range-track {
    height: 6px;
    background: var(--bg-elev-2);
    border-radius: 3px;
}

input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
}

/* --- Layout shells ------------------------------------------------ */

.page {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 16px 40px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.page-header h1 {
    font-size: 22px;
    margin: 0;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.muted {
    color: var(--text-dim);
}

.error {
    color: var(--danger);
    min-height: 1.4em;
    margin-top: 10px;
    font-size: 15px;
}

/* --- Login -------------------------------------------------------- */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.login-card h1 {
    margin: 0 0 18px;
    font-size: 20px;
    text-align: center;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-card button {
    background: var(--accent);
    color: #111;
    border-color: var(--accent);
    font-weight: 600;
}

/* --- Track list --------------------------------------------------- */

.track-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border-top: 1px solid var(--border);
}

.track-list li {
    border-bottom: 1px solid var(--border);
}

.track-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--text);
    padding: 14px 6px;
    min-height: var(--tap-min);
}

.track-list .duration {
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    font-size: 14px;
    flex-shrink: 0;
}

/* --- Player ------------------------------------------------------- */

.player {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.player .title {
    font-size: 20px;
    font-weight: 600;
    word-break: break-word;
}

.player .times {
    display: flex;
    justify-content: space-between;
    font-variant-numeric: tabular-nums;
    color: var(--text-dim);
    font-size: 14px;
}

.player .controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 8px;
}

.player .play-btn {
    width: 84px;
    height: 84px;
    min-height: 84px;
    border-radius: 50%;
    font-size: 28px;
    background: var(--accent);
    color: #111;
    border-color: var(--accent);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.player .secondary {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 4px;
}

.player .secondary button {
    min-width: 96px;
}

/* --- Library shell (drawer + main) -------------------------------- */

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}

.top-bar .app-name {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.hamburger {
    background: none;
    border: none;
    color: #eee;
    font-size: 1.5rem;
    cursor: pointer;
    min-width: 48px;
    min-height: 48px;
    padding: 0;
    border-radius: 0;
}

.hamburger:active {
    background: none;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
}

.drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    height: 100%;
    background: #1a1a1a;
    border-right: 1px solid var(--border);
    transform: translateX(-320px);
    transition: transform 0.25s ease;
    z-index: 110;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.drawer.open {
    transform: translateX(0);
}

.main {
    padding: 16px;
    max-width: 720px;
}

.section-title {
    font-size: 16px;
    margin: 8px 0 12px;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.upload-section {
    margin-bottom: 32px;
}

.upload-section .hint {
    margin-top: 12px;
    font-size: 13px;
}

.status-section {
    margin-top: 32px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

@media (min-width: 769px) {
    .hamburger {
        display: none;
    }
    .overlay {
        display: none !important;
    }
    .drawer {
        transform: none;
        transition: none;
    }
    .top-bar {
        margin-left: 320px;
    }
    .main {
        margin-left: 320px;
    }
}

/* --- Library: search / count / select-all ------------------------- */

.search {
    width: 100%;
    height: 48px;
    background: #1a1a1a;
    color: #eee;
    border: none;
    border-bottom: 1px solid #333;
    padding: 0 12px;
    font-size: 1rem;
    border-radius: 0;
    outline: none;
}

.search::placeholder {
    color: var(--text-dim);
}

.library-meta {
    padding: 8px 12px;
    color: #999;
    font-size: 0.85rem;
}

.track-count {
    color: #999;
    font-size: 0.85rem;
}

.select-all-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    color: #999;
    font-size: 0.85rem;
    border-bottom: 1px solid #222;
}

.select-all-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.delete-selected {
    min-height: 36px;
    padding: 0 12px;
    background: var(--bg-elev-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
}

.delete-selected:disabled,
.delete-selected[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.library-status {
    padding: 12px;
    font-size: 0.9rem;
}

/* --- Library: track rows ------------------------------------------ */

#tracks.track-list {
    border-top: none;
}

.track-row {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0 12px;
    gap: 12px;
    border-bottom: 1px solid #222;
}

.track-row:hover {
    background: #222;
}

.track-checkbox {
    min-width: 20px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
}

.track-link {
    flex: 1;
    color: var(--text);
    display: flex;
    align-items: center;
    min-height: 48px;
    word-break: break-word;
}

/* --- Upload button + progress ------------------------------------- */

.upload-btn {
    width: 100%;
    min-height: 56px;
    background: #e8c97a;
    color: #111;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    border-radius: var(--radius);
    font-weight: 600;
}

.upload-btn:active {
    background: #d9b86b;
}

.progress-list {
    margin-top: 16px;
    list-style: none;
    padding: 0;
}

.progress-item {
    padding: 8px 0;
    border-bottom: 1px solid #222;
}

.progress-name {
    font-size: 0.9rem;
    margin-bottom: 6px;
    word-break: break-all;
}

.progress-bar {
    height: 4px;
    background: #333;
    position: relative;
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    background: #e8c97a;
    height: 100%;
    width: 0%;
    transition: width 0.1s;
}

.progress-status {
    font-size: 0.8rem;
    color: #999;
    margin-top: 4px;
}

.progress-status.ok {
    color: #6c6;
}

.progress-status.err {
    color: #c66;
}

/* --- Confirmation card -------------------------------------------- */

.confirmation-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #1a1a1a;
    padding: 24px;
    z-index: 200;
    min-width: 280px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.confirm-message {
    margin: 0 0 16px;
    font-size: 1rem;
}

.confirm-actions {
    display: flex;
    justify-content: center;
}

.confirmation-card button {
    min-height: 48px;
    min-width: 100px;
    margin: 8px;
    border-radius: var(--radius);
}

.confirmation-card .confirm-btn {
    background: var(--danger);
    color: #111;
    border-color: var(--danger);
    font-weight: 600;
}

.confirm-spinner {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-top: 8px;
}

