/* Shadow Slave Reader - Premium 3-Card Desktop Layout */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette - Warm & Muted */
    --bg-body: #d8d4ce;
    --dark-chrome: #2a2622;
    --dark-chrome-light: #3a3632;
    --parchment: #f5f0e6;
    --parchment-light: #faf8f4;
    --gold: #c9a227;
    --gold-muted: #b8943f;
    --gold-dim: #8a7535;
    --text-light: #e8e4dc;
    --text-muted: #9a958c;
    --text-dark: #2d2a26;
    --card-shadow: 0 4px 24px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.08);
    --card-border: 1px solid rgba(0, 0, 0, 0.06);
    --card-radius: 20px;
    --gap: 12px;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-dark);
    line-height: 1.5;
}

/* ==================== APP WRAPPER ==================== */
/* Soft gray background with centered app panel */
.app-wrapper {
    width: 100%;
    height: 100vh;
    padding: 12px;
    display: flex;
    align-items: stretch;
    justify-content: center;
}

/* The main panel that holds sidebar + right column */
.app-panel {
    width: 100%;
    max-width: 1400px;
    height: 100%;
    display: grid;
    grid-template-columns: 25% 1fr;
    gap: var(--gap);
    transition: grid-template-columns 0.3s ease;
    position: relative;
}

.app-panel.sidebar-collapsed {
    grid-template-columns: 0 1fr;
}

.app-panel.sidebar-collapsed .sidebar-card {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-100%);
    width: 0;
    overflow: hidden;
}

/* ==================== SIDEBAR CARD ==================== */
.sidebar-card {
    background: linear-gradient(180deg, #3a3632 0%, #2a2622 100%);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    border: var(--card-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Sidebar backdrop - Hidden on desktop */
.sidebar-backdrop {
    display: none; /* Hidden on desktop */
}

/* Hamburger Button - Positioned on top of sidebar card */
.hamburger-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 44px;
    height: 44px;
    background: var(--dark-chrome);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0;
    z-index: 1001;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.hamburger-btn:hover {
    background: var(--dark-chrome-light);
    border-color: rgba(201, 162, 39, 0.3);
}

/* When sidebar is collapsed, make button more visible with better contrast */
.app-panel.sidebar-collapsed .hamburger-btn {
    position: absolute;
    top: 30px;
    left: 32px;
    background: var(--dark-chrome);
    border: 2px solid var(--gold);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 0 0 4px rgba(201, 162, 39, 0.1);
}

.app-panel.sidebar-collapsed .hamburger-btn span {
    background: var(--gold);
}

.hamburger-btn span {
    width: 24px;
    height: 2.5px;
    background: var(--text-muted);
    border-radius: 2px;
    transition: all 0.2s ease;
}

.hamburger-btn:hover span {
    background: var(--gold);
}

/* Title Section */
.sidebar-title {
    text-align: center;
    padding: 70px 20px 24px;
}

.app-name {
    font-family: 'Crimson Text', Georgia, serif;
    font-size: 2em;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 4px;
    line-height: 1.1;
}

.author-line {
    font-size: 0.85em;
    color: var(--text-muted);
    font-style: italic;
}

/* Stats Row */
.stats-row {
    display: flex;
    justify-content: center;
    gap: 50px;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-block {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2.4em;
    font-weight: 700;
    color: var(--gold);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.75em;
    color: var(--text-muted);
    text-transform: capitalize;
    letter-spacing: 0.5px;
}

/* Bot Status */
.bot-status {
    padding: 16px 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.bot-status-main {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #d4a72c;
    flex-shrink: 0;
}

.status-dot.idle {
    background: #d4a72c;
}

.status-dot.running {
    background: #4ade80;
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
    animation: pulse 2s ease-in-out infinite;
}

.status-dot.error {
    background: #ef4444;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-label {
    font-size: 1em;
    font-weight: 600;
    color: var(--text-light);
}

.status-subtext {
    font-size: 0.8em;
    color: var(--text-muted);
    margin-left: 22px;
}

/* Chapter List */
.chapter-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 20px;
}

.chapter-pill {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: transparent;
}

.chapter-pill:hover {
    background: rgba(255, 255, 255, 0.06);
}

.chapter-pill.active {
    background: rgba(255, 255, 255, 0.15);
}

.chapter-pill.active .pill-badge {
    background: rgba(201, 162, 39, 0.15);
    border-color: rgba(201, 162, 39, 0.3);
}

.chapter-pill.active .pill-title {
    color: var(--text-light);
    font-weight: 600;
}

.pill-badge {
    min-width: 54px;
    height: 30px;
    background: rgba(201, 162, 39, 0.15);
    border: 1px solid rgba(201, 162, 39, 0.3);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85em;
    font-weight: 600;
    color: var(--gold);
    flex-shrink: 0;
}

.pill-title {
    flex: 1;
    font-size: 0.92em;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chapter List Scrollbar */
.chapter-list::-webkit-scrollbar {
    width: 6px;
}

.chapter-list::-webkit-scrollbar-track {
    background: transparent;
}

.chapter-list::-webkit-scrollbar-thumb {
    background: rgba(201, 162, 39, 0.25);
    border-radius: 3px;
}

.chapter-list::-webkit-scrollbar-thumb:hover {
    background: rgba(201, 162, 39, 0.4);
}

/* ==================== RIGHT COLUMN ==================== */
.right-column {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    min-height: 0;
}

/* ==================== PLAYER CARD ==================== */
.player-card {
    background: linear-gradient(180deg, #3a3632 0%, #2a2622 100%);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    border: var(--card-border);
    padding: 20px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.player-left {
    flex: 1;
    min-width: 0;
    padding-left: 0;
    transition: padding-left 0.3s ease;
}

/* When sidebar is collapsed, add padding to avoid hamburger button */
.app-panel.sidebar-collapsed .player-left {
    padding-left: 64px;
}

.player-chapter {
    font-size: 1.15em;
    font-weight: 600;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.player-wordcount {
    font-size: 0.85em;
    color: var(--text-muted);
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.player-extras {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: 8px;
    padding-left: 16px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.speed-control-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.speed-control-inline label {
    font-size: 0.85em;
    color: var(--text-muted);
}

.speed-control-inline select {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: var(--text-light);
    font-size: 0.9em;
    outline: none;
    cursor: pointer;
}

.speed-control-inline select:hover {
    background: rgba(255, 255, 255, 0.15);
}

.sleep-btn-inline {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: var(--text-light);
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sleep-btn-inline:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--gold);
}

.skip-btn {
    width: 52px;
    height: 52px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

.skip-btn svg {
    margin-bottom: -4px;
}

.skip-btn:hover {
    color: var(--text-light);
}

.skip-btn:hover svg {
    stroke: var(--gold);
}

.skip-label {
    font-size: 0.7em;
    font-weight: 600;
    color: inherit;
    margin-top: 2px;
}

.play-btn {
    width: 64px;
    height: 64px;
    background: var(--gold);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--dark-chrome);
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(201, 162, 39, 0.3);
}

.play-btn:hover {
    background: #d4b033;
    transform: scale(1.05);
}

.play-btn:disabled {
    background: var(--gold-dim);
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.play-btn svg {
    margin-left: 3px;
}

.pause-icon.hidden,
.play-icon.hidden {
    display: none;
}

/* ==================== READER CARD ==================== */
.reader-card {
    flex: 1;
    background: var(--parchment);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    border: var(--card-border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
}

/* Subtle inner vignette effect */
.reader-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.03) 100%);
    z-index: 1;
}

.reader-content {
    flex: 1;
    overflow-y: auto;
    padding: 50px 80px 60px;
    position: relative;
    z-index: 0;
}

/* Chapter Header */
.chapter-header {
    text-align: center;
    margin-bottom: 40px;
}

.chapter-number {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--gold-dim);
    text-transform: uppercase;
    letter-spacing: 4px;
    margin-bottom: 12px;
}

.chapter-title {
    font-family: 'Crimson Text', Georgia, serif;
    font-size: 2.4em;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.25;
    margin-bottom: 24px;
}

.title-divider {
    width: 100%;
    max-width: 600px;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(0, 0, 0, 0.12) 20%, rgba(0, 0, 0, 0.12) 80%, transparent 100%);
    margin: 0 auto;
}

/* Chapter Text */
.chapter-text {
    font-family: 'Crimson Text', Georgia, serif;
    font-size: 1.2em;
    line-height: 1.85;
    color: #3d3832;
    text-align: justify;
    max-width: 720px;
    margin: 0 auto;
}

.chapter-text p {
    margin-bottom: 1.25em;
    text-indent: 2em;
}

.chapter-text p:first-of-type {
    text-indent: 0;
}

.chapter-text p:first-of-type::first-letter {
    font-size: 3.8em;
    float: left;
    line-height: 0.78;
    margin-right: 10px;
    margin-top: 6px;
    color: var(--gold-dim);
    font-weight: 700;
}

/* Reader Scrollbar */
.reader-content::-webkit-scrollbar {
    width: 8px;
}

.reader-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 4px;
    margin: 10px;
}

.reader-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 4px;
}

.reader-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* ==================== FLOATING ELEMENTS ==================== */

/* Resume Prompt */
.resume-prompt {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--dark-chrome);
    color: var(--text-light);
    padding: 18px 22px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 1000;
    max-width: 420px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.resume-prompt.hidden {
    display: none;
}

.resume-icon {
    color: var(--gold);
    flex-shrink: 0;
}

#resumePromptText {
    flex: 1;
    font-size: 0.9em;
}

.resume-actions {
    display: flex;
    gap: 8px;
}

.resume-btn,
.start-over-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.resume-btn {
    background: var(--gold);
    color: var(--dark-chrome);
}

.resume-btn:hover {
    background: #d4b033;
}

.start-over-btn {
    background: transparent;
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.start-over-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.close-prompt-btn {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4em;
    cursor: pointer;
    line-height: 1;
}

.close-prompt-btn:hover {
    color: var(--text-light);
}

/* Save Indicator */
.save-indicator {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark-chrome);
    color: var(--text-light);
    padding: 10px 18px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85em;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 999;
    animation: slideUp 0.3s ease;
}

.save-indicator.hidden {
    display: none;
}

.save-indicator svg {
    color: var(--gold);
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* ==================== SLEEP PANEL ==================== */
.sleep-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--dark-chrome);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px;
    z-index: 2000;
    min-width: 400px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* Sleep panel backdrop - Hidden on desktop, only shown on mobile */
.sleep-panel-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    display: none; /* Hidden on desktop by default */
}

.sleep-panel-backdrop.active {
    opacity: 1;
    pointer-events: all;
}

/* Show backdrop on mobile/tablet */
@media (max-width: 1024px) {
    .sleep-panel-backdrop {
        display: block;
    }
}

.sleep-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.sleep-header h3 {
    color: var(--text-light);
    font-size: 1.2em;
    margin: 0;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5em;
    cursor: pointer;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
}

.close-btn:active {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(0.95);
}

.sleep-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.sleep-option {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sleep-option label {
    font-size: 0.9em;
    color: var(--text-muted);
}

.sleep-option select {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: var(--text-light);
    font-size: 0.95em;
    outline: none;
    cursor: pointer;
}

.sleep-option select:hover {
    background: rgba(255, 255, 255, 0.15);
}

.start-sleep-btn {
    width: 100%;
    padding: 12px;
    background: var(--gold);
    color: var(--dark-chrome);
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.start-sleep-btn:hover {
    background: #d4b033;
    transform: translateY(-1px);
}

.sleep-timer-display {
    margin-top: 16px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#timerCountdown {
    color: var(--gold);
    font-size: 1.2em;
    font-weight: 600;
}

.sleep-timer-display button {
    padding: 6px 16px;
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s ease;
}

.sleep-timer-display button:hover {
    background: rgba(239, 68, 68, 0.3);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1100px) {
    .app-panel {
        grid-template-columns: 280px 1fr;
    }

    .reader-content {
        padding: 40px 50px 50px;
    }

    .chapter-title {
        font-size: 2em;
    }
}

@media (max-width: 900px) {
    .app-wrapper {
        padding: 8px;
    }

    .app-panel {
        grid-template-columns: 260px 1fr;
    }

    .player-card {
        padding: 16px 24px;
    }

    .player-chapter {
        font-size: 1em;
    }

    .reader-content {
        padding: 30px 30px 40px;
    }

    .chapter-text {
        font-size: 1.1em;
    }
}

/* ==================== TABLET/iPAD (768px - 1024px) ==================== */
@media (min-width: 768px) and (max-width: 1024px) {
    .app-wrapper {
        padding: 8px;
    }

    .app-panel {
        grid-template-columns: 35% 1fr;
        max-width: 100%;
    }

    .sidebar-title {
        padding: 50px 15px 20px;
    }

    .app-name {
        font-size: 1.6em;
    }

    .stats-row {
        gap: 30px;
        padding: 16px;
    }

    .stat-value {
        font-size: 2em;
    }

    .player-card {
        padding: 16px 24px;
        flex-wrap: wrap;
        gap: 12px;
    }

    .player-extras {
        width: 100%;
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding-top: 12px;
        margin-top: 8px;
    }

    .reader-content {
        padding: 40px 40px 50px;
    }

    .chapter-title {
        font-size: 2em;
    }

    .chapter-text {
        font-size: 1.1em;
        line-height: 1.75;
    }

    .chapter-text p:first-of-type::first-letter {
        font-size: 3em;
    }

    .hamburger-btn {
        top: 16px;
        left: 16px;
        width: 40px;
        height: 40px;
    }

    /* Sleep panel - Better positioned on tablet */
    .sleep-panel {
        min-width: 450px;
        max-width: 85vw;
        padding: 28px;
    }

    .sleep-header h3 {
        font-size: 1.3em;
    }

    .close-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
    }
}

/* ==================== MOBILE (< 768px) ==================== */
@media (max-width: 768px) {
    html, body {
        overflow: auto;
    }

    .app-wrapper {
        padding: 0;
    }

    .app-panel {
        grid-template-columns: 1fr;
        gap: 0;
        border-radius: 0;
        max-width: 100%;
        height: 100vh;
    }

    .app-panel.sidebar-collapsed {
        grid-template-columns: 1fr;
    }

    /* Sidebar - Hidden by default, slides in from left */
    .sidebar-card {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        z-index: 1002;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        border-radius: 0;
        overflow-y: auto;
    }

    .sidebar-card.open {
        transform: translateX(0);
    }

    /* Sidebar backdrop overlay - Only on mobile */
    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1001;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        display: block; /* Only visible on mobile */
    }

    .sidebar-card.open ~ .sidebar-backdrop,
    .sidebar-backdrop.active {
        opacity: 1;
        pointer-events: all;
    }

    .sidebar-title {
        padding: 60px 15px 20px;
    }

    .app-name {
        font-size: 1.5em;
    }

    .author-line {
        font-size: 0.8em;
    }

    .stats-row {
        gap: 20px;
        padding: 14px;
    }

    .stat-value {
        font-size: 1.8em;
    }

    .stat-label {
        font-size: 0.7em;
    }

    .bot-status {
        padding: 12px 16px 16px;
    }

    .chapter-list {
        padding: 12px 10px 16px;
    }

    .chapter-pill {
        padding: 14px 16px;
        gap: 12px;
        min-height: 48px; /* Better touch target */
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
    }

    .chapter-pill:active {
        background: rgba(255, 255, 255, 0.1);
        transform: scale(0.98);
    }

    .pill-badge {
        min-width: 52px;
        height: 32px;
        font-size: 0.85em;
    }

    .pill-title {
        font-size: 0.85em;
    }

    /* Hamburger button - Always visible on mobile */
    .hamburger-btn {
        position: fixed;
        top: 16px;
        left: 16px;
        width: 44px;
        height: 44px;
        z-index: 1003;
        background: var(--dark-chrome);
        border: 2px solid var(--gold);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    }

    .hamburger-btn span {
        background: var(--gold);
    }

    /* Right column - Full width on mobile */
    .right-column {
        width: 100%;
        height: 100vh;
        display: flex;
        flex-direction: column;
    }

    /* Player card - Stacked layout on mobile */
    .player-card {
        padding: 14px 16px;
        border-radius: 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .player-left {
        width: 100%;
        padding-left: 56px; /* Space for hamburger button */
    }

    .app-panel.sidebar-collapsed .player-left {
        padding-left: 56px;
    }

    .player-chapter {
        font-size: 0.95em;
        margin-bottom: 4px;
    }

    .player-wordcount {
        font-size: 0.75em;
    }

    .player-controls {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 12px;
    }

    .skip-btn {
        width: 48px;
        height: 48px;
    }

    .play-btn {
        width: 56px;
        height: 56px;
    }

    .player-extras {
        width: 100%;
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding-top: 12px;
        margin-top: 8px;
        justify-content: space-between;
    }

    .speed-control-inline {
        gap: 6px;
    }

    .speed-control-inline label {
        font-size: 0.8em;
    }

    .speed-control-inline select {
        padding: 6px 10px;
        font-size: 0.85em;
    }

    .sleep-btn-inline {
        padding: 6px 12px;
        font-size: 0.85em;
    }

    /* Reader card - Full width on mobile */
    .reader-card {
        border-radius: 0;
        flex: 1;
        min-height: 0;
    }

    .reader-content {
        padding: 24px 20px 40px;
    }

    .chapter-header {
        margin-bottom: 24px;
    }

    .chapter-number {
        font-size: 0.75em;
        letter-spacing: 2px;
        margin-bottom: 8px;
    }

    .chapter-title {
        font-size: 1.6em;
        line-height: 1.2;
        margin-bottom: 16px;
    }

    .title-divider {
        max-width: 100%;
    }

    .chapter-text {
        font-size: 1em;
        line-height: 1.7;
        text-align: left; /* Left align on mobile for better readability */
    }

    .chapter-text p {
        margin-bottom: 1em;
        text-indent: 1.5em;
    }

    .chapter-text p:first-of-type {
        text-indent: 0;
    }

    .chapter-text p:first-of-type::first-letter {
        font-size: 2.5em;
        line-height: 0.8;
        margin-right: 8px;
        margin-top: 4px;
    }

    /* Floating elements - Adjust for mobile */
    .resume-prompt {
        bottom: 16px;
        right: 16px;
        left: 16px;
        max-width: none;
        flex-direction: column;
        align-items: flex-start;
        padding: 16px;
    }

    .resume-actions {
        width: 100%;
        justify-content: space-between;
        margin-top: 8px;
    }

    .resume-btn,
    .start-over-btn {
        flex: 1;
    }

    .save-indicator {
        bottom: 16px;
        left: 50%;
        transform: translateX(-50%);
        padding: 8px 16px;
    }

    /* Sleep panel - Full screen bottom sheet on mobile */
    .sleep-panel {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        transform: translate(0, 100%);
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        max-height: 85vh;
        border-radius: 20px 20px 0 0;
        padding: 24px 20px;
        border: none;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sleep-panel[style*="block"] {
        transform: translate(0, 0);
    }

    .sleep-panel-backdrop {
        z-index: 1998;
    }

    .sleep-header {
        margin-bottom: 24px;
        padding-bottom: 16px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .sleep-header h3 {
        font-size: 1.25em;
    }

    .close-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        font-size: 1.6em;
    }

    .sleep-options {
        gap: 20px;
        margin-bottom: 24px;
    }

    .sleep-option select {
        padding: 12px 16px;
        font-size: 1em;
        min-height: 44px; /* Better touch target */
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23e8e4dc' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        padding-right: 40px;
    }

    .start-sleep-btn {
        padding: 16px;
        font-size: 1.05em;
        min-height: 48px; /* Better touch target */
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .start-sleep-btn:active {
        transform: scale(0.98);
    }

    .sleep-timer-display {
        margin-top: 20px;
        padding: 16px;
    }

    #timerCountdown {
        font-size: 1.3em;
    }

    .sleep-timer-display button {
        padding: 10px 20px;
        font-size: 0.95em;
        min-height: 44px; /* Better touch target */
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
}

/* ==================== SMALL MOBILE (< 480px) ==================== */
@media (max-width: 480px) {
    .sidebar-card {
        width: 260px;
    }

    .hamburger-btn {
        top: 12px;
        left: 12px;
        width: 40px;
        height: 40px;
    }

    .player-left {
        padding-left: 52px;
    }

    .player-card {
        padding: 12px 14px;
    }

    .player-controls {
        gap: 8px;
    }

    .skip-btn {
        width: 44px;
        height: 44px;
    }

    .play-btn {
        width: 52px;
        height: 52px;
    }

    .reader-content {
        padding: 20px 16px 36px;
    }

    .chapter-title {
        font-size: 1.4em;
    }

    .chapter-text {
        font-size: 0.95em;
    }

    .stats-row {
        gap: 16px;
        padding: 12px;
    }

    .stat-value {
        font-size: 1.6em;
    }
}

/* Hidden utility */
.hidden {
    display: none !important;
}
