* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    background: #16141c;
    color: #eae7f0;
}
.hidden { display: none !important; }

/* ---------- Upload screen ---------- */
#upload-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.upload-card {
    max-width: 520px;
    text-align: center;
    padding: 2.5rem;
}
.upload-card h1 { font-size: 1.8rem; margin-bottom: 0.3rem; }
.upload-card .sub { color: #a89fc2; margin-bottom: 1.5rem; }
#dropzone {
    border: 2px dashed #6b5b95;
    border-radius: 10px;
    padding: 3rem 1.5rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
#dropzone:hover, #dropzone.dragover {
    background: rgba(107, 91, 149, 0.15);
    border-color: #9b30c9;
}
#upload-status { margin-top: 1rem; color: #c9a8f0; min-height: 1.4em; }

#upload-progress-wrap { margin-top: 1.25rem; }
#upload-progress-bar {
    width: 100%;
    height: 8px;
    background: #2a2537;
    border-radius: 4px;
    overflow: hidden;
}
#upload-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #9b30c9, #c9a8f0);
    transition: width 0.2s ease-out;
}

/* ---------- Workspace ---------- */
#workspace { display: flex; flex-direction: column; height: 100vh; }
#topbar {
    height: 52px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    background: #1f1c28;
    border-bottom: 1px solid #322c3f;
}
#book-title { font-weight: 600; }
#topbar-actions button {
    background: #9b30c9;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    margin-left: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}
#topbar-actions button:hover { background: #b13bd6; }
#topbar-actions button:disabled { background: #4a4458; cursor: default; }

#main { flex: 1; display: flex; min-height: 0; }

#sidebar {
    width: 240px;
    flex-shrink: 0;
    overflow-y: auto;
    background: #1a1722;
    border-right: 1px solid #322c3f;
    padding: 0.75rem;
}
#outline .chapter { font-weight: 700; margin: 0.9rem 0 0.2rem 0; font-size: 0.82rem; color: #c9a8f0; text-transform: uppercase; letter-spacing: 0.04em; }
#outline .note { padding: 0.25rem 0.4rem; border-radius: 4px; cursor: pointer; font-size: 0.88rem; color: #d8d2e6; }
#outline .note:hover { background: #2a2537; }

#preview-pane {
    flex: 1;
    overflow: auto;
    background: #0d0c11;
    display: flex;
    justify-content: center;
    padding: 1.5rem;
}
#preview-frame {
    width: 850px;
    max-width: 100%;
    height: 100000px; /* iframe content sizes the real height; see app.js resize logic */
    border: none;
    background: white;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
}

#property-panel {
    width: 260px;
    flex-shrink: 0;
    background: #1a1722;
    border-left: 1px solid #322c3f;
    padding: 1rem;
    overflow-y: auto;
}
#property-panel .hint { color: #7a7290; font-size: 0.85rem; }
#property-panel h3 { font-size: 0.9rem; margin: 0 0 0.75rem 0; color: #eae7f0; }
#property-panel label { display: block; font-size: 0.8rem; color: #a89fc2; margin: 0.75rem 0 0.25rem 0; }
#property-panel input[type="range"] { width: 100%; }
#property-panel .align-buttons { display: flex; gap: 0.4rem; }
#property-panel .align-buttons button {
    flex: 1; padding: 0.4rem; background: #2a2537; border: 1px solid #4a4458;
    color: #eae7f0; border-radius: 4px; cursor: pointer; font-size: 0.8rem;
}
#property-panel .align-buttons button.active { background: #9b30c9; border-color: #9b30c9; }

#loading-overlay {
    position: fixed; inset: 0; background: rgba(13,12,17,0.75);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 1rem; z-index: 50;
}
.spinner {
    width: 36px; height: 36px; border: 4px solid #4a4458; border-top-color: #9b30c9;
    border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
