/* ── Book preview page ────────────────────────────────────────── */
.page-preview {
    background: #fff;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.06);
    position: relative;
    transition: width 0.2s, min-height 0.2s, padding 0.2s;
}

.page-preview p {
    text-align: inherit;
    margin-top: 0;
    hyphens: auto;
    word-break: break-word;
}

.page-preview p:first-of-type {
    margin-top: 0;
}

/* ── Tool sections ───────────────────────────────────────────── */
.tool-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 0.625rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    user-select: none;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #64748b;
}

.tool-section-header:hover {
    background: #f1f5f9;
}

/* ── Form controls ───────────────────────────────────────────── */
.tool-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: #64748b;
    margin-bottom: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tool-input {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    padding: 0.375rem 0.625rem;
    font-size: 0.8125rem;
    color: #1e293b;
    background: #fff;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.tool-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.tool-input-sm {
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4rem 0.875rem;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    white-space: nowrap;
}

.btn-primary:hover:not(:disabled) {
    background: #4f46e5;
}

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

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4rem 0.875rem;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.btn-secondary:hover:not(:disabled) {
    background: #e2e8f0;
}

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

.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.35rem 0.75rem;
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-danger:hover {
    background: #fee2e2;
}

/* ── Paste area ──────────────────────────────────────────────── */
.paste-area {
    width: 100%;
    min-height: 90px;
    border: 2px dashed #c7d2fe;
    border-radius: 0.5rem;
    padding: 0.625rem;
    font-size: 0.8125rem;
    color: #475569;
    background: #f8f9ff;
    resize: vertical;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}

.paste-area:focus {
    border-color: #6366f1;
    background: #fff;
}

/* ── Notification toast ──────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.625rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast-success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.toast-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.toast-info {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

/* ── Scrollbar (tools panel) ─────────────────────────────────── */
.tools-panel::-webkit-scrollbar {
    width: 5px;
}

.tools-panel::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.tools-panel::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* ── Range inputs ────────────────────────────────────────────── */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: #e2e8f0;
    outline: none;
}

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

/* ── Alignment buttons ───────────────────────────────────────── */
.align-btn {
    flex: 1;
    padding: 0.3rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s, border-color 0.12s;
    color: #64748b;
}

.align-btn.active {
    background: #ede9fe;
    border-color: #a5b4fc;
    color: #4f46e5;
}

/* ── Preset size buttons ─────────────────────────────────────── */
.preset-btn {
    padding: 0.3rem 0.5rem;
    font-size: 0.7rem;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 0.25rem;
    cursor: pointer;
    color: #475569;
    transition: background 0.12s, border-color 0.12s;
    white-space: nowrap;
}

.preset-btn:hover {
    background: #ede9fe;
    border-color: #a5b4fc;
    color: #4f46e5;
}

/* ── Loading overlay ─────────────────────────────────────────── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e2e8f0;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    .main-layout {
        flex-direction: column;
    }

    .tools-panel {
        width: 100% !important;
        max-height: 50vh;
        border-left: none !important;
        border-top: 1px solid #e2e8f0;
    }

    .preview-area {
        padding: 1rem !important;
    }
}