* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.listen-btn {
    position: fixed;
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    z-index: 10000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    display: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.listen-btn:hover {
    background: var(--primary-dark);
}

html, body {
    touch-action: manipulation;
}

:root {
    --primary: #7cb882;
    --primary-light: #a8d4b8;
    --primary-dark: #5a9a63;
    --bg-main: #f0f7f1;
    --bg-sidebar: #ffffff;
    --bg-main-content: #fafcfb;
    --text-primary: #2d5a3d;
    --text-secondary: #5a7d6a;
    --border-color: #d4e6da;
    --shadow: 0 2px 10px rgba(122, 184, 130, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Segoe UI SC', 'PingFang SC', sans-serif;
    background: var(--bg-main);
    height: 100vh;
    overflow: hidden;
    color: var(--text-primary);
    padding-top: 10px;
}

.app {
    display: flex;
    height: 100vh;
    gap: 1px;
    background: var(--border-color);
}

.sidebar-left {
    width: 220px;
    background: var(--bg-sidebar);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex-shrink: 0;
}

.sidebar-left h2 {
    font-size: 1.2rem;
    color: var(--primary-dark);
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.upload-box {
    border: 2px dashed var(--primary-light);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
    background: var(--bg-main);
}

.upload-box:hover {
    border-color: var(--primary);
}

.upload-formats {
    font-size: 12px;
    color: #888;
    margin-top: 10px;
}

.welcome-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
    text-align: center;
}

.welcome-icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.welcome-content h2 {
    color: var(--text-primary);
    font-size: 28px;
    margin: 0 0 16px 0;
}

.welcome-content p {
    color: #666;
    font-size: 16px;
    margin: 8px 0;
}

.welcome-hint {
    color: #999;
    font-size: 14px;
    margin-top: 24px;
}

.upload-box input[type="file"] {
    display: none;
}

.upload-box label {
    display: block;
    padding: 10px 15px;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.upload-box label:hover {
    background: var(--primary-dark);
}

.file-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 10px;
    background: var(--bg-main);
    border-radius: 8px;
    word-break: break-all;
}

.main-content {
    flex: 1;
    background: var(--bg-main-content);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 20px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.chapter-select {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chapter-select label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.chapter-select select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    min-width: 150px;
    background: white;
    cursor: pointer;
}

.chapter-select select:focus {
    outline: none;
    border-color: var(--primary);
}

.pagination {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-small {
    padding: 6px 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-small:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-small:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#pageInfo {
    font-size: 0.9rem;
    color: var(--text-secondary);
    min-width: 60px;
    text-align: center;
}

.position-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-left: auto;
}

.position-info input {
    width: 80px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    text-align: center;
}

.position-info input:focus {
    outline: none;
    border-color: var(--primary);
}

.text-display {
    flex: 1;
    padding: 30px 40px;
    overflow-y: auto;
    font-size: 1.05rem;
    line-height: 1.4;
    color: var(--text-primary);
    background: var(--bg-main-content);
    white-space: pre-wrap;
    word-wrap: break-word;
    -webkit-touch-callout: none;
}

.text-display p {
    margin-bottom: 0.3em;
    text-indent: 2em;
}

.text-display p {
    margin-bottom: 1em;
    text-indent: 2em;
}

.text-display p:first-child {
    text-indent: 0;
}

.text-display > p:first-of-type::first-letter {
    font-size: 1.5em;
    font-weight: bold;
    float: left;
    line-height: 1;
    margin-right: 0.3em;
}

.text-display::-webkit-scrollbar {
    width: 8px;
}

.text-display::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 4px;
}

.text-display .highlight {
    background: var(--primary-light);
    border-radius: 3px;
    padding: 2px 0;
}

.sidebar-right {
    width: 280px;
    background: var(--bg-sidebar);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex-shrink: 0;
}

.sidebar-right h2 {
    font-size: 1.2rem;
    color: var(--primary-dark);
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.audio-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn {
    padding: 14px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124, 184, 130, 0.3);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    color: var(--text-secondary);
}

#speedControl {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    background: var(--border-color);
    border-radius: 3px;
    cursor: pointer;
}

#speedControl::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

.progress-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.progress-bar-container {
    width: 100%;
}

#progressBar {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    background: var(--border-color);
    border-radius: 4px;
    cursor: pointer;
}

#progressBar::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

#audioPlayer {
    width: 100%;
    height: 38px;
}

.audio-status {
    padding: 15px;
    background: var(--bg-main);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    flex: 1;
}

.now-playing {
    padding: 15px;
    background: var(--primary-light);
    border-radius: 8px;
    margin: 10px;
}

.current-text {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-primary);
    margin-bottom: 10px;
    max-height: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.playback-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.btn-play {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-play:hover {
    background: var(--primary-dark);
}

.voice-select {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.voice-select select {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
}

@media (max-width: 768px) {
    body {
        overflow: auto;
        height: auto;
    }
    
    .sidebar-left,
    .sidebar-right {
        display: none;
    }
    
    .app {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }
    
    .main-content {
        flex: 1;
        margin-top: 75px;
        margin-bottom: 60px;
        display: flex;
        flex-direction: column;
    }
    
    .toolbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
        background: var(--bg-sidebar);
        padding: 12px 12px;
        display: flex;
        align-items: center;
        gap: 8px;
        border-bottom: 1px solid var(--border-color);
        box-sizing: border-box;
        height: 56px;
    }
    
    .chapter-select {
        flex: 1;
    }
    
    .chapter-select select {
        width: 100%;
    }
    
    .chapter-select label {
        display: none;
    }
    
    .pagination {
        display: flex;
        gap: 5px;
    }
    
    .pagination .btn-small {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
    
    #pageInfo {
        font-size: 0.8rem;
        min-width: 45px;
    }
    
    .content-wrapper {
        flex-direction: column;
        flex: 1;
    }
    
    .text-display {
        flex: 1;
        overflow-y: scroll;
        padding: 15px;
        font-size: 1.05rem;
        line-height: 1.7;
        -webkit-touch-callout: none;
    }
    
    .welcome-content {
        padding: 30px 20px;
    }
    
    .welcome-icon {
        font-size: 60px;
    }
    
    .welcome-content h2 {
        font-size: 24px;
    }
    
    .welcome-content p {
        font-size: 14px;
    }
    
    .sentence-list,
    .sentence-list * {
        display: none !important;
    }
    
    .mobile-status-bar {
        display: block;
        position: fixed;
        bottom: 60px;
        left: 0;
        right: 0;
        background: var(--primary);
        color: white;
        padding: 6px 15px;
        text-align: center;
        font-size: 13px;
        z-index: 98;
        min-height: 52px;
    }
    
    .mobile-status-line {
        line-height: 1.6;
    }
    
    .mobile-player-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-sidebar);
        border-top: 1px solid var(--border-color);
        padding: 8px 15px;
        z-index: 99;
        justify-content: center;
        align-items: center;
        gap: 15px;
    }
    
    .mobile-player-btn {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: var(--primary);
        color: white;
        border: none;
        font-size: 14px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .mobile-player-btn-play {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: var(--primary);
        color: white;
        border: none;
        font-size: 18px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .mobile-fab {
        display: flex;
        position: fixed;
        right: 15px;
        top: 60px;
        flex-direction: column;
        gap: 10px;
        z-index: 150;
    }
    
    .mobile-fab-btn {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: var(--primary);
        color: white;
        border: none;
        font-size: 18px;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .mobile-fab-btn {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: var(--primary);
        color: white;
        border: none;
        font-size: 18px;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0,0,0,0.3);
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .mobile-settings-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 199;
    }
    
    .mobile-settings-panel {
        display: block;
        position: fixed;
        top: 0;
        right: -280px;
        width: 280px;
        height: 100%;
        background: var(--bg-sidebar);
        z-index: 200;
        padding: 20px;
        transition: right 0.3s ease;
    }
    
    .mobile-settings-panel.open {
        right: 0;
    }
    
    .mobile-settings-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        padding-bottom: 15px;
        border-bottom: 1px solid var(--border-color);
    }
    
    .mobile-settings-header h3 {
        font-size: 1.1rem;
        color: var(--primary-dark);
    }
    
    .mobile-close-btn {
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
        color: var(--text-secondary);
    }
}

@media (max-width: 900px) {
    .app {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .sidebar-left,
    .sidebar-right {
        width: 100%;
        flex: none;
    }

    .main-content {
        min-height: 400px;
    }
}

/* PC端隐藏移动端悬浮元素（通过媒体查询排除移动端） */
@media (min-width: 769px) {
    .mobile-fab,
    .mobile-player-bar,
    .mobile-status-bar,
    .mobile-settings-overlay,
    .mobile-settings-panel {
        display: none !important;
    }
}

.content-wrapper {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.sentence-list {
    width: 280px;
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sentence-header {
    padding: 15px;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-main);
}

.sentence-items {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.sentence-item {
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 6px;
    font-size: 0.85rem;
    line-height: 1.5;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-main);
    color: var(--text-secondary);
}

.sentence-item:hover {
    background: var(--primary-light);
    color: var(--text-primary);
}

.sentence-item.active {
    background: var(--primary);
    color: white;
}

.sentence-item.playing {
    background: var(--primary-dark);
    color: white;
    border-left: 3px solid #fff;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 10px;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    z-index: 100;
}

.site-footer a {
    color: var(--text-secondary);
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--primary);
}

@media (max-width: 768px) {
    .site-footer {
        display: none;
    }
}
