 :root {
     /* --- Colors (Clean White) --- */
     --bg-body: #ffffff;
     /* Putih Bersih */
     --text-main: #2c3e50;
     --text-secondary: #7f8c8d;
     /* Kembali ke abu-abu netral */
     --accent: #0288d1;
     /* Aksen tetap Biru Laut */
     --ui-bg: #ffffff;
     --ui-border: #e0e0e0;
     /* Border abu-abu halus */
     --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
     --overlay-bg: rgba(0, 0, 0, 0.5);

     /* --- Typography Defaults --- */
     --font-body: 'Georgia', 'Merriweather', serif;
     --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
     --font-size: 18px;
     --line-height: 1.8;
 }

 /* Dark Mode (Neutral Black) */
 [data-theme="dark"] {
     --bg-body: #121212;
     /* Hitam Netral (bukan biru) */
     --text-main: #e0e0e0;
     --text-secondary: #a0a0a0;
     --accent: #38bdf8;
     /* Sky Blue untuk kontras gelap */
     --ui-bg: #1e1e1e;
     /* Sedikit lebih terang dari bg untuk membedakan elemen */
     --ui-border: #333333;
     --overlay-bg: rgba(0, 0, 0, 0.8);
 }

 * {
     box-sizing: border-box;
     margin: 0;
     padding: 0;
     outline: none;
     -webkit-tap-highlight-color: transparent;
 }

 body {
     font-family: var(--font-ui);
     background: var(--bg-body);
     color: var(--text-main);
     height: 100vh;
     display: flex;
     flex-direction: column;
     overflow: hidden;
     transition: background 0.3s, color 0.3s;
 }

 /* --- Header --- */
 header {
     background-color: var(--ui-bg);
     border-bottom: 1px solid var(--ui-border);
     padding: 0.8rem 1.5rem;
     display: flex;
     justify-content: space-between;
     align-items: center;
     box-shadow: var(--shadow);
     z-index: 20;
     position: relative;
 }

 .logo {
     font-weight: 700;
     font-size: 1.4rem;
     color: var(--accent);
     letter-spacing: -0.5px;
 }

 .controls {
     display: flex;
     gap: 0.5rem;
     align-items: center;
 }

 /* Icon Buttons */
 .btn-icon {
     cursor: pointer;
     border: none;
     background: transparent;
     color: var(--text-main);
     padding: 0.5rem;
     border-radius: 6px;
     display: flex;
     align-items: center;
     justify-content: center;
     transition: background 0.2s;
 }

 .btn-icon:hover {
     background-color: rgba(0, 0, 0, 0.05);
 }

 .btn-icon svg {
     width: 22px;
     height: 22px;
     stroke: currentColor;
     fill: none;
     stroke-width: 2;
     pointer-events: none;
 }

 #reset-btn:hover {
     color: var(--accent);
     background-color: rgba(2, 136, 209, 0.1);
 }

 /* Top Progress Bar */
 .top-progress-container {
     position: absolute;
     bottom: 0;
     left: 0;
     width: 100%;
     height: 3px;
     background: transparent;
 }

 .progress-bar-fill {
     height: 100%;
     background-color: var(--accent);
     width: 0%;
     transition: width 0.3s ease;
 }

 /* --- Main Content --- */
 main {
     flex: 1;
     overflow-y: auto;
     position: relative;
     scroll-behavior: smooth;
 }

 /* Upload View */
 #upload-view {
     display: flex;
     flex-direction: column;
     align-items: center;
     justify-content: center;
     height: 100%;
     padding: 2rem;
     text-align: center;
 }

 .upload-box {
     border: 2px dashed var(--ui-border);
     padding: 3rem;
     border-radius: 12px;
     background-color: var(--ui-bg);
     cursor: pointer;
     transition: 0.3s;
 }

 .upload-box:hover {
     border-color: var(--accent);
     transform: translateY(-2px);
 }

 /* Reader View */
 #reader-view {
     display: none;
     max-width: 800px;
     margin: 0 auto;
     padding: 2rem 2rem 5rem 2rem;
 }

 #chapter-title {
     font-size: 1.4rem;
     margin-bottom: 2.5rem;
     color: var(--accent);
     border-bottom: 1px solid var(--ui-border);
     padding-bottom: 0.8rem;
     text-align: center;
 }

 #reader-content {
     font-family: var(--font-body);
     font-size: var(--font-size);
     line-height: var(--line-height);
     text-align: justify;
 }

 #reader-content p {
     margin-bottom: 1.2em;
     text-indent: 0;
 }

 /* --- Footer Nav --- */
 .reader-footer {
     position: fixed;
     bottom: 0;
     left: 0;
     width: 100%;
     background-color: var(--ui-bg);
     border-top: 1px solid var(--ui-border);
     height: 60px;
     display: none;
     justify-content: center;
     align-items: center;
     gap: 1.5rem;
     box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
     z-index: 15;
 }

 .nav-arrow {
     font-size: 1.5rem;
     padding: 0.5rem 1.5rem;
     color: var(--text-secondary);
     cursor: pointer;
     background: none;
     border: none;
 }

 .nav-arrow:hover {
     color: var(--accent);
 }

 .nav-arrow:disabled {
     color: #ccc;
     cursor: not-allowed;
 }

 .toc-trigger-btn {
     background-color: var(--ui-bg);
     border: 1px solid var(--ui-border);
     color: var(--accent);
     padding: 0.5rem 1.5rem;
     border-radius: 20px;
     font-weight: 600;
     cursor: pointer;
     display: flex;
     align-items: center;
     gap: 8px;
 }

 .toc-trigger-btn:hover {
     background-color: var(--accent);
     color: white;
     border-color: var(--accent);
 }

 /* --- Sidebar ToC --- */
 .toc-overlay {
     position: fixed;
     top: 0;
     left: 0;
     width: 100%;
     height: 100%;
     background: var(--overlay-bg);
     z-index: 99;
     opacity: 0;
     visibility: hidden;
     transition: 0.3s;
 }

 .toc-sidebar {
     position: fixed;
     top: 0;
     left: -320px;
     width: 280px;
     height: 100%;
     background: var(--ui-bg);
     z-index: 100;
     transition: left 0.3s;
     display: flex;
     flex-direction: column;
     border-right: 1px solid var(--ui-border);
 }

 .toc-open .toc-overlay {
     opacity: 1;
     visibility: visible;
 }

 .toc-open .toc-sidebar {
     left: 0;
 }

 .toc-header {
     padding: 1.2rem;
     border-bottom: 1px solid var(--ui-border);
     font-weight: bold;
     display: flex;
     justify-content: space-between;
 }

 .toc-list {
     flex: 1;
     overflow-y: auto;
     list-style: none;
 }

 .toc-item {
     padding: 0.8rem 1.2rem;
     border-bottom: 1px solid var(--ui-border);
     cursor: pointer;
     font-size: 0.9rem;
     color: var(--text-secondary);
 }

 .toc-item:hover {
     color: var(--accent);
     background: rgba(0, 0, 0, 0.02);
 }

 .toc-item.active {
     background: var(--accent);
     color: white;
 }

 /* --- CUSTOM MODAL (Pengganti alert/confirm) --- */
 .modal-wrap {
     position: fixed;
     top: 0;
     left: 0;
     width: 100%;
     height: 100%;
     background: rgba(0, 0, 0, 0.6);
     z-index: 200;
     display: none;
     align-items: center;
     justify-content: center;
     opacity: 0;
     transition: opacity 0.2s ease;
 }

 .modal-wrap.active {
     display: flex;
     opacity: 1;
 }

 .modal-box {
     background: var(--ui-bg);
     padding: 2rem;
     border-radius: 12px;
     max-width: 380px;
     width: 90%;
     text-align: center;
     box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
     transform: scale(0.9);
     transition: transform 0.2s ease;
 }

 .modal-wrap.active .modal-box {
     transform: scale(1);
 }

 .modal-title {
     font-size: 1.2rem;
     font-weight: bold;
     margin-bottom: 0.5rem;
     color: var(--text-main);
 }

 .modal-msg {
     color: var(--text-secondary);
     margin-bottom: 1.5rem;
     font-size: 0.95rem;
 }

 .modal-actions {
     display: flex;
     gap: 1rem;
     justify-content: center;
 }

 .btn-modal {
     padding: 0.6rem 1.2rem;
     border-radius: 8px;
     font-weight: 600;
     cursor: pointer;
     border: none;
     font-size: 0.9rem;
 }

 .btn-cancel {
     background: transparent;
     border: 1px solid var(--ui-border);
     color: var(--text-secondary);
 }

 .btn-confirm {
     background: var(--accent);
     color: white;
 }

 .btn-confirm:hover {
     opacity: 0.9;
 }

 /* Spinner */
 .loader {
     display: none;
     border: 4px solid var(--ui-border);
     border-top: 4px solid var(--accent);
     border-radius: 50%;
     width: 40px;
     height: 40px;
     animation: spin 1s linear infinite;
     margin-top: 1rem;
 }

 @keyframes spin {
     100% {
         transform: rotate(360deg);
     }
 }