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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #fafafa;
    color: #333;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 320px;
    flex-shrink: 0;
    background: #1e1e1e;
    color: #ccc;
    overflow-y: auto;
    padding: 16px;
    border-right: 1px solid #333;
}

.sidebar h2 {
    font-size: 13px;
    color: #e92063;
    margin: 16px 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.sidebar h2:first-child {
    margin-top: 0;
}

/* Book Info */
.book-info {
    background: #2d2d2d;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 16px;
    border-left: 3px solid #e92063;
}

.book-info .title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    word-break: break-word;
    color: #fff;
}

.book-info .author {
    color: #888;
    font-size: 12px;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed #444;
    border-radius: 6px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 16px;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: #e92063;
    background: rgba(233, 32, 99, 0.1);
}

.drop-zone-icon {
    font-size: 32px;
    margin-bottom: 8px;
    color: #666;
}

.drop-zone-text {
    font-size: 13px;
    color: #888;
}

/* File List */
.file-list {
    max-height: 150px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #2d2d2d;
    border-radius: 4px;
    margin-bottom: 4px;
    font-size: 12px;
}

.file-item.active {
    background: #e92063;
    color: #fff;
}

.file-item .name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.file-item .remove {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 4px;
    margin-left: 8px;
}

.file-item .remove:hover {
    color: #e92063;
}

/* Control Groups */
.control-group {
    margin-bottom: 12px;
}

.control-group label {
    display: block;
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
}

.control-group select,
.control-group input[type="text"],
.control-group input[type="number"] {
    width: 100%;
    padding: 8px;
    background: #2d2d2d;
    border: 1px solid #444;
    border-radius: 4px;
    color: #eee;
    font-size: 13px;
}

.control-group select:focus,
.control-group input:focus {
    outline: none;
    border-color: #e92063;
}

/* Slider Row */
.slider-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.slider-row input[type="range"] {
    flex: 1;
}

.slider-row input[type="number"] {
    width: 60px;
}

input[type="range"] {
    -webkit-appearance: none;
    background: #444;
    border-radius: 4px;
    height: 6px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #e92063;
    border-radius: 50%;
    cursor: pointer;
}

/* Checkbox */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #e92063;
}

.checkbox-group label {
    font-size: 13px;
    color: #ccc;
    margin: 0;
}

/* Checkbox row for multiple checkboxes */
.checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-bottom: 8px;
}

.checkbox-row .checkbox-group {
    margin-bottom: 0;
}

/* Progress bar settings row */
.progress-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.progress-bar-row .checkbox-group {
    margin-bottom: 0;
}

.progress-bar-row select {
    padding: 6px 8px;
    background: #2d2d2d;
    border: 1px solid #444;
    border-radius: 4px;
    color: #eee;
    font-size: 12px;
}

/* Orientation Buttons */
.orientation-buttons {
    display: flex;
    gap: 4px;
}

.orientation-buttons button {
    flex: 1;
    padding: 8px;
    background: #2d2d2d;
    border: 1px solid #444;
    border-radius: 4px;
    color: #ccc;
    cursor: pointer;
    font-size: 12px;
}

.orientation-buttons button:hover {
    background: #3d3d3d;
}

.orientation-buttons button.active {
    border-color: #e92063;
    background: rgba(233, 32, 99, 0.2);
    color: #e92063;
}

/* Chapter List */
.chapter-list {
    max-height: 200px;
    overflow-y: auto;
    background: #2d2d2d;
    border-radius: 6px;
}

.chapter-item {
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    border-bottom: 1px solid #3d3d3d;
    color: #aaa;
}

.chapter-item:hover {
    background: #3d3d3d;
    color: #fff;
}

.chapter-item.active {
    background: #e92063;
    color: #fff;
}

.chapter-item:last-child {
    border-bottom: none;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fafafa;
    overflow: hidden;
}

/* Preview Header */
.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #1e1e1e;
    border-bottom: 1px solid #333;
}

.nav-buttons {
    display: flex;
    gap: 8px;
}

.nav-buttons button,
.export-buttons button {
    padding: 8px 16px;
    background: #2d2d2d;
    border: none;
    border-radius: 4px;
    color: #ccc;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.nav-buttons button:hover,
.export-buttons button:hover {
    background: #3d3d3d;
}

.nav-buttons button:disabled,
.export-buttons button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.export-buttons button.primary {
    background: #e92063;
    color: #fff;
    font-weight: 600;
}

.export-buttons button.primary:hover {
    background: #d61a58;
}

.page-info {
    font-size: 14px;
    color: #aaa;
}

.export-buttons {
    display: flex;
    gap: 8px;
}

/* Preview Area */
.preview-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow: auto;
    background: #2d3748;
}

#previewCanvas {
    background: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    /* Scale controlled by JS via transform */
    transform: scale(var(--preview-scale, 0.5));
    transform-origin: center center;
}

/* Progress Bar */
.progress-container {
    padding: 12px 16px;
    background: #2d3748;
    border-top: 1px solid #3d4758;
}

.progress-bar {
    height: 6px;
    background: #1e2738;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #e92063;
    width: 0%;
    transition: width 0.3s;
}

.progress-text {
    font-size: 12px;
    color: #aaa;
    margin-top: 4px;
    text-align: center;
}

/* Hidden file input */
#fileInput, #customFontInput {
    display: none;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.tabs button {
    flex: 1;
    padding: 8px;
    background: #2d2d2d;
    border: none;
    border-radius: 4px;
    color: #888;
    cursor: pointer;
    font-size: 12px;
}

.tabs button.active {
    background: #e92063;
    color: #fff;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1e1e1e;
}

::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive */
@media (max-width: 800px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        max-height: 50vh;
    }
}
