@namespace epub "http://www.idpf.org/2007/ops";
/* CSS Version: 1767855363 - Fixed z-index for global buttons */
:root {
    --base-font-size: 16px;
    --primary-color: #0078d4;
    --primary-hover: #005a9c;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.8;
    max-width: 800px;
    margin: 20px auto;
    padding: 0 15px;
    background-color: #f9f9f9;
    color: #333;
    font-size: var(--base-font-size);
    overflow-x: hidden;
    word-wrap: break-word;
}
h1, h2 {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
}
.chapter-controls {
    display: flex;
    gap: 10px;
    margin: 10px 0;
    flex-wrap: wrap;
}
.chapter-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 10px 16px;
    font-size: 14px;
    border-radius: 5px;
    cursor: pointer;
    min-height: 44px;
    transition: background 0.2s;
}
.chapter-btn:hover { background: #218838; }
.chapter-btn:focus-visible { outline: 2px solid #28a745; outline-offset: 2px; }
.chapter-btn.infinite { background: #dc3545; }
.chapter-btn.infinite:hover { background: #c82333; }
.sentence-container {
    position: relative;
    margin-bottom: 20px;
    padding: 15px;
    padding-right: 70px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.sentence-container.difficult {
    border-left: 4px solid #ff6b6b;
    background-color: #fff5f5;
}
.sentence-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.right-buttons {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sentence-number {
    font-size: 1.1em;
    color: #666;
    font-weight: bold;
}
.skip-btn, .play-from-here-btn, .pause-here-btn, .mark-difficult-btn, .toggle-visibility-btn, .goto-mistakes-btn {
    color: white;
    border: none;
    border-radius: 50%;
    min-width: 36px;
    min-height: 36px;
    width: 36px;
    height: 36px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: all 0.2s;
    position: relative;
}
.skip-btn { background: #6c757d; }
.skip-btn:hover { background: #5a6268; }
.skip-btn:focus-visible { outline: 2px solid #6c757d; outline-offset: 2px; }
.play-from-here-btn { background: var(--primary-color); }
.play-from-here-btn:hover { background: var(--primary-hover); }
.play-from-here-btn:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.pause-here-btn { background: #d9534f; }
.pause-here-btn:hover { background: #c9302c; }
.mark-difficult-btn { background: #ff6b6b; }
.mark-difficult-btn:hover { background: #ff5252; }
.mark-difficult-btn.marked { background: #c92a2a; }
.toggle-visibility-btn { background: #868e96; }
.toggle-visibility-btn:hover { background: #495057; }
.goto-mistakes-btn { background: #ff6b6b; }
.goto-mistakes-btn:hover { background: #ff5252; }
button:active { transform: scale(0.95); }
.mastery-controls {
    display: flex;
    gap: 8px;
    margin-left: auto;
    align-items: center;
}
.mastery-btn {
    background: #51cf66;
    color: white;
    border: none;
    padding: 8px 12px;
    min-height: 36px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}
.mastery-btn:hover { background: #40c057; }
.mastery-btn:focus-visible { outline: 2px solid #51cf66; outline-offset: 2px; }
.mastery-btn.not-mastered { background: #ffa94d; }
.mastery-btn.not-mastered:hover { background: #ff922b; }
.sentence {
    cursor: pointer;
    padding: 8px;
    border-radius: 5px;
    transition: background-color 0.3s, color 0.3s;
    margin: 2px 0;
}
.sentence:hover { background-color: #e9f5ff; }
.sentence:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.sentence.playing {
    background-color: var(--highlight-color, var(--primary-color));
    color: white;
    font-weight: bold;
}
.sentence.hidden {
    color: transparent;
    user-select: none;
    background-color: #f1f3f5;
}
.sentence.hidden:hover { background-color: #e9ecef; }
.lang-cn.test-mode { 
    color: transparent !important;
    user-select: none;
    background-color: #f1f3f5;
}
.lang-cn.test-mode:hover { background-color: #e9ecef; }
.lang-jp { font-size: 1.1em; }
.lang-cn { font-size: 1em; color: #555; }
rt {
    font-size: 0.65em;
    color: #d9534f;
    font-weight: bold;
}
#controls {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 25px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.rule-text {
    font-style: italic;
    color: #555;
    margin-left: 20px;
    margin-top: 10px;
    padding: 5px;
    font-size: 0.9em;
    background-color: #f5f5f5;
    border-left: 3px solid #007bff;
}
.chapter-break {
    page-break-before: always;
    margin-top: 40px;
    border-top: 3px solid var(--primary-color);
    padding-top: 20px;
}
.audio-progress-container {
    margin: 10px 0;
    padding: 5px 0;
}
.audio-progress {
    width: 100%;
    height: 8px;
    background: #ddd;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
}
.audio-progress-bar {
    height: 100%;
    background: var(--highlight-color, var(--primary-color));
    border-radius: 4px;
    width: 0%;
    transition: width 0.1s linear;
}
.audio-time {
    display: flex;
    justify-content: space-between;
    font-size: 0.8em;
    color: #666;
    margin-top: 4px;
}
.progress-bar-container {
    width: 100%;
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    margin: 10px 0;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #51cf66, #40c057);
    transition: width 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75em;
    font-weight: bold;
}
.chapter-progress {
    font-size: 0.85em;
    color: #6c757d;
    margin: 10px 0;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 5px;
}
.floating-toc {
    position: fixed;
    top: max(20px, env(safe-area-inset-top));
    left: max(20px, env(safe-area-inset-left));
    z-index: 10001;
    pointer-events: none;
}
.toc-toggle-btn {
    pointer-events: auto;
}
.toc-toggle-btn, .global-play-btn, .global-stop-btn, .test-mode-btn {
    color: white;
    border: none;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5em;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s;
    position: fixed !important;
    z-index: 10001 !important;
    pointer-events: auto;
}
.toc-toggle-btn { background: var(--primary-color); }
.toc-toggle-btn:hover { background: var(--primary-hover); }
.toc-toggle-btn:focus-visible { outline: 3px solid var(--primary-color); outline-offset: 2px; }
.toc-panel {
    display: none;
    position: fixed;
    top: calc(max(20px, env(safe-area-inset-top)) + 90px);
    left: max(20px, env(safe-area-inset-left));
    width: min(300px, calc(100vw - 40px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    max-height: calc(100vh - max(20px, env(safe-area-inset-top)) - 110px - env(safe-area-inset-bottom));
    background: white;
    box-shadow: 2px 2px 12px rgba(0,0,0,0.15);
    border-radius: 12px;
    overflow-y: auto;
    padding: 20px;
    z-index: 9999;
    pointer-events: auto;
}
.toc-panel.open { display: block; }
.toc-panel h3 {
    margin-top: 0;
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    position: sticky;
    top: -20px;
    background: white;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.toc-panel .close-btn, .mistakes-panel .close-btn, .floating-control .close-btn {
    background: #f0f0f0;
    border: none;
    min-width: 36px;
    min-height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2em;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s;
}
.close-btn:hover { background: #e0e0e0; }
.close-btn:focus-visible { outline: 2px solid #666; outline-offset: 2px; }
.toc-item {
    padding: 12px;
    margin: 5px 0;
    cursor: pointer;
    border-radius: 5px;
    border-left: 3px solid var(--primary-color);
    background: #f8f9fa;
    transition: background 0.2s;
    min-height: 44px;
    display: flex;
    align-items: center;
}
.toc-item:hover { background: #e9ecef; }
.toc-item:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.mode-selector {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.mode-btn {
    flex: 1;
    min-width: 100px;
    min-height: 44px;
    background: #f8f9fa;
    color: #333;
    border: 2px solid #dee2e6;
    padding: 10px 12px;
    font-size: 0.85em;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
}
.mode-btn:hover { background: #e9ecef; }
.mode-btn:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.mode-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}
.floating-control {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    border: 2px solid var(--primary-color);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 9999;
    max-width: min(400px, calc(100vw - 40px));
    max-height: 60vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}
.global-play-btn {
    top: max(20px, env(safe-area-inset-top));
    right: 90px;
    background: #28a745;
    position: fixed !important;
    z-index: 999999 !important;
    transform: translateZ(0);
    will-change: transform;
}
.global-play-btn:hover { background: #218838; }
.global-play-btn:focus-visible { outline: 3px solid #28a745; outline-offset: 2px; }
.global-stop-btn {
    top: max(20px, env(safe-area-inset-top));
    right: 20px;
    background: #d9534f;
    position: fixed !important;
    z-index: 999999 !important;
    transform: translateZ(0);
    will-change: transform;
}
.global-stop-btn:hover { background: #c9302c; }
.global-stop-btn:focus-visible { outline: 3px solid #d9534f; outline-offset: 2px; }
.test-mode-btn {
    top: max(20px, env(safe-area-inset-top));
    right: 160px;
    background: #6f42c1;
    font-size: 0.7em;
    width: auto;
    min-width: 56px;
    height: 56px;
    padding: 0 16px;
    border-radius: 28px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: fixed !important;
    z-index: 999999 !important;
    transform: translateZ(0);
    will-change: transform;
}
.test-mode-btn:hover { background: #5a32a3; }
.test-mode-btn:focus-visible { outline: 3px solid #6f42c1; outline-offset: 2px; }
.floating-control.collapsed {
    padding: 0;
    max-width: auto;
    max-height: auto;
    overflow: visible;
    border: none;
    background: transparent;
    box-shadow: none;
}
.floating-control .toggle-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5em;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
    transition: all 0.2s;
}
.floating-control.collapsed .toggle-btn { display: flex; }
.floating-control .toggle-btn:hover { background: var(--primary-hover); }
.floating-control .toggle-btn:focus-visible { outline: 3px solid var(--primary-color); outline-offset: 2px; }
.floating-control .content {
    display: block;
    margin-top: 10px;
    overflow-y: auto;
}
.floating-control.collapsed .content { display: none; }
.floating-control h3 {
    margin: 0;
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding: 10px 0;
    position: sticky;
    top: -15px;
    background: white;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.floating-control h4 {
    margin: 15px 0 10px 0;
    font-size: 0.9em;
    color: var(--primary-color);
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 5px;
    position: sticky;
    top: 37px;
    background: white;
    z-index: 9;
    flex-shrink: 0;
}
.floating-control .control-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 8px 0;
    gap: 10px;
}
.floating-control .control-row label {
    font-size: 0.85em;
    color: #333;
    min-width: 60px;
}
.floating-control .mini-adjuster {
    display: flex;
    align-items: center;
    gap: 5px;
}
.floating-control .mini-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    min-width: 32px;
    min-height: 32px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s;
}
.floating-control .mini-btn:hover { background: var(--primary-hover); }
.floating-control .mini-btn:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.floating-control .mini-value {
    font-size: 0.85em;
    font-weight: bold;
    min-width: 45px;
    text-align: center;
}
.floating-control .mini-control-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 12px;
    min-height: 44px;
    font-size: 0.85em;
    border-radius: 5px;
    cursor: pointer;
    width: 100%;
    margin: 5px 0;
    transition: background 0.2s;
}
.floating-control .mini-control-btn:hover { background: var(--primary-hover); }
.floating-control .mini-control-btn:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }
.floating-control .mini-control-btn.stop { background: #d9534f; }
.floating-control .mini-control-btn.stop:hover { background: #c9302c; }
.floating-control .mini-control-btn.continue { background: #5cb85c; }
.floating-control .mini-control-btn.continue:hover { background: #4cae4c; }
.floating-control .mini-control-btn.pause { background: #f0ad4e; }
.floating-control .mini-control-btn.pause:hover { background: #ec971f; }
.floating-control .mini-control-btn.infinite { background: #6f42c1; }
.floating-control .mini-control-btn.infinite:hover { background: #5a32a3; }
.floating-mistakes {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10001;
    pointer-events: none;
}
.mistakes-toggle-btn { 
    background: #ff6b6b;
    color: white;
    border: none;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5em;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s;
    pointer-events: auto;
}
.mistakes-toggle-btn:hover { background: #ff5252; }
.mistakes-toggle-btn:focus-visible { outline: 3px solid #ff6b6b; outline-offset: 2px; }
.mistakes-panel {
    display: none;
    position: fixed;
    top: calc(max(20px, env(safe-area-inset-top)) + 90px);
    right: max(20px, env(safe-area-inset-right));
    width: min(350px, calc(100vw - 40px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    max-height: calc(100vh - max(20px, env(safe-area-inset-top)) - 110px - env(safe-area-inset-bottom));
    background: white;
    box-shadow: -2px 2px 12px rgba(0,0,0,0.15);
    border-radius: 12px;
    overflow-y: auto;
    padding: 20px;
    z-index: 9999;
    pointer-events: auto;
}
.mistakes-panel.open { display: block; }
.mistakes-panel h3 {
    margin-top: 0;
    color: #ff6b6b;
    border-bottom: 2px solid #ff6b6b;
    padding-bottom: 10px;
    position: sticky;
    top: -20px;
    background: white;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.mistakes-panel .mistake-list {
    max-height: none;
    overflow-y: visible;
}
.mistake-item {
    padding: 12px;
    margin: 5px 0;
    background: white;
    border-left: 3px solid #ff6b6b;
    border-radius: 3px;
    font-size: 0.9em;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
    position: relative;
}
.mistake-item > div:first-child {
    flex: 1;
    cursor: pointer;
}
.mistake-item:hover { background: #f8f9fa; }
.mistake-item:focus-visible { outline: 2px solid #ff6b6b; outline-offset: 2px; }
.mistake-item.priority-high {
    border-left-color: #c92a2a;
    background: #fff5f5;
}
.delete-mistake-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    min-width: 28px;
    min-height: 28px;
    width: 28px;
    height: 28px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s;
    flex-shrink: 0;
}
.delete-mistake-btn:hover { background: #c82333; }
.clear-mastered-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 12px;
    min-height: 36px;
    font-size: 0.85em;
    border-radius: 5px;
    cursor: pointer;
    width: 100%;
    margin: 10px 0;
    transition: background 0.2s;
}
.clear-mastered-btn:hover { background: #5a6268; }
.clear-mastered-btn:focus-visible { outline: 2px solid #6c757d; outline-offset: 2px; }
@keyframes highlight-flash {
    0%, 100% { background-color: #fff; }
    50% { background-color: #ffe066; }
}

/* 缓存进度浮动提示 */
.cache-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 120, 212, 0.95);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 10000;
    display: none;
    align-items: center;
    gap: 10px;
    min-width: 200px;
    max-width: calc(100vw - 40px);
    animation: slideUp 0.3s ease-out;
}
.cache-toast.show { display: flex; }
.cache-toast.success { background: rgba(40, 167, 69, 0.95); }
.cache-toast-text {
    flex: 1;
    font-size: 0.9em;
}
.cache-toast-progress {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 6px;
}
.cache-toast-progress-bar {
    height: 100%;
    background: white;
    width: 0%;
    transition: width 0.3s;
}
@keyframes slideUp {
    from { bottom: 60px; opacity: 0; }
    to { bottom: 80px; opacity: 1; }
}

/* 移动端适配 */
@media (max-width: 768px) {
    body { margin: 10px auto; padding: 0 10px; }
    .sentence-container { padding: 12px; padding-right: 60px; }
    .right-buttons { right: 8px; gap: 6px; }
    .skip-btn, .play-from-here-btn, .mark-difficult-btn, .toggle-visibility-btn {
        min-width: 40px;
        min-height: 40px;
        width: 40px;
        height: 40px;
    }
    .floating-control { 
        bottom: max(10px, env(safe-area-inset-bottom)); 
        right: max(10px, env(safe-area-inset-right)); 
        max-width: calc(100vw - 20px - env(safe-area-inset-left) - env(safe-area-inset-right)); 
    }
    .toc-panel, .mistakes-panel { 
        top: calc(max(15px, env(safe-area-inset-top)) + 80px); 
        max-height: calc(100vh - max(15px, env(safe-area-inset-top)) - 100px - env(safe-area-inset-bottom)); 
    }
    .global-play-btn, .global-stop-btn, .test-mode-btn { 
        height: 50px; 
        top: max(15px, env(safe-area-inset-top)); 
    }
    .global-play-btn { width: 50px; right: 75px; font-size: 1.3em; }
    .global-stop-btn { width: 50px; right: max(15px, env(safe-area-inset-right)); font-size: 1.3em; }
    .test-mode-btn { width: auto; right: 135px; padding: 0 12px; font-size: 0.55em; min-width: 50px; max-width: 80px; }
    .toc-toggle-btn, .mistakes-toggle-btn { width: 50px; height: 50px; font-size: 1.3em; }
    .floating-toc { 
        top: max(15px, env(safe-area-inset-top)); 
        left: max(15px, env(safe-area-inset-left)); 
    }
    .floating-mistakes { right: max(15px, env(safe-area-inset-right)); }
}

@media (max-width: 480px) {
    .sentence-header { gap: 6px; }
    .chapter-controls { gap: 8px; }
    .mode-selector { flex-direction: column; }
    .mode-btn { min-width: 100%; }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
    .sentence-number { color: #000; }
    button { border: 2px solid currentColor; }
}

/* 减少动画 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}