:root {
    --bg: #eef2fb;
    --panel: rgba(255, 255, 255, 0.78);
    --card: #ffffff;
    --card-border: rgba(108, 125, 182, 0.15);
    --text: #1e2b4d;
    --muted: #657094;
    --primary: #4c6ef5;
    --primary-dark: #3b5bdb;
    --accent: #ffb15c;
    --success: #2ecc71;
    --danger: #e85959;
    --shadow-soft: 0 26px 64px rgba(30, 51, 110, 0.12);
    --shadow-card: 0 14px 40px rgba(30, 51, 110, 0.08);
    --border: rgba(108, 125, 182, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
    min-height: 100vh;
    background: radial-gradient(120% 120% at 15% 20%, #fefefe 0%, #e8ecfb 55%, #d9ddf0 100%);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 28px 24px 48px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.page-hero {
    background: linear-gradient(135deg, rgba(76, 110, 245, 0.18), rgba(76, 110, 245, 0.04));
    border-radius: 18px;
    padding: 22px 26px;
    box-shadow: var(--shadow-soft);
    position: relative;
    overflow: hidden;
}

.page-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(90% 90% at 100% 0%, rgba(255, 255, 255, 0.65) 0%, transparent 70%);
    pointer-events: none;
}

.page-hero h1 {
    font-size: 2rem;
    letter-spacing: -0.3px;
    margin-bottom: 8px;
}

.page-hero p {
    color: rgba(30, 43, 77, 0.78);
    margin-bottom: 10px;
    max-width: 520px;
}

.intro-highlights {
    list-style: none;
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.88rem;
}

.intro-highlights li {
    display: flex;
    align-items: center;
    gap: 10px;
}

.intro-highlights li::before {
    content: '●';
    color: var(--accent);
    font-size: 0.7rem;
    transform: translateY(-1px);
}

.hero-actions {
    margin-top: 14px;
}

.hero-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(76, 110, 245, 0.88), rgba(58, 89, 220, 0.92));
    color: #ffffff;
    text-decoration: none;
    font-weight: 600;
    box-shadow: 0 12px 26px rgba(76, 110, 245, 0.25);
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.hero-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 32px rgba(76, 110, 245, 0.28);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
}

.form-group input[type="text"] {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(96, 117, 186, 0.2);
    background: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(76, 110, 245, 0.15);
}

.drop-zone {
    border: 2px dashed rgba(96, 117, 186, 0.35);
    border-radius: 14px;
    padding: 28px;
    text-align: center;
    background: rgba(255, 255, 255, 0.72);
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
    cursor: pointer;
}

.drop-zone:hover {
    transform: translateY(-1px);
}

.drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(76, 110, 245, 0.11);
}

.image-preview {
    margin-top: 12px;
    min-height: 110px;
    border-radius: 14px;
    border: 1px dashed rgba(96, 117, 186, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.8);
    overflow: hidden;
}

.image-preview.has-image {
    border-style: solid;
    border-color: var(--primary);
}

.image-preview img,
.image-preview video {
    max-width: 100%;
    max-height: 140px;
}

.help-text {
    font-size: 0.85rem;
    color: rgba(101, 112, 148, 0.9);
}

.workspace {
    backdrop-filter: blur(18px);
    background: rgba(255, 255, 255, 0.78);
    border-radius: 16px;
    padding: 18px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: 16px;
    border: 1px solid rgba(96, 117, 186, 0.14);
}

.workspace-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
}

.tab-buttons {
    display: inline-flex;
    background: rgba(76, 110, 245, 0.1);
    padding: 6px;
    border-radius: 14px;
    gap: 4px;
}

.tab-button {
    border: none;
    background: transparent;
    padding: 10px 18px;
    font-weight: 600;
    border-radius: 10px;
    cursor: pointer;
    color: var(--muted);
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.tab-button:hover {
    color: var(--primary-dark);
}

.tab-button.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 10px 24px rgba(76, 110, 245, 0.25);
}

.workspace-stats {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.stat-pill {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    padding: 6px 12px;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    border: 1px solid rgba(96, 117, 186, 0.18);
}

.stat-pill span {
    font-weight: 700;
    color: var(--text);
}

#generateBtn {
    background: linear-gradient(135deg, #2ecc71, #28b365);
    color: #0f4a2a;
    border: none;
    border-radius: 10px;
    padding: 9px 18px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(46, 204, 113, 0.22);
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

#generateBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 30px rgba(46, 204, 113, 0.28);
}

.workspace-surface {
    background: rgba(255, 255, 255, 0.85);
    border-radius: 14px;
    padding: 20px;
    min-height: 480px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    border: 1px solid rgba(210, 221, 255, 0.35);
}

.tab-panel {
    display: none;
    flex: 1;
    flex-direction: column;
    gap: 20px;
}

.tab-panel.active {
    display: flex;
}

.details-tab {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
    align-items: start;
}

.details-tab .image-preview {
    min-height: 150px;
}

.pages-toolbar {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.control-buttons {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.btn {
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 600;
    cursor: pointer;
    background: rgba(76, 110, 245, 0.12);
    color: var(--primary-dark);
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.btn:hover {
    background: rgba(76, 110, 245, 0.18);
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 10px 20px rgba(76, 110, 245, 0.2);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid rgba(76, 110, 245, 0.35);
}

.btn-outline:hover {
    background: rgba(76, 110, 245, 0.08);
}

.btn-small {
    padding: 8px 12px;
    font-size: 0.85rem;
}

.pages-board {
    flex: 1;
    background: linear-gradient(135deg, rgba(240, 242, 255, 0.65), rgba(247, 248, 255, 0.88));
    border-radius: 12px;
    padding: 16px;
    border: 1px dashed rgba(96, 117, 186, 0.24);
    overflow-y: auto;
    min-height: 340px;
}

.pages-board .help-text {
    text-align: center;
    color: var(--muted);
}

.page-spread {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.spread-label {
    grid-column: 1 / -1;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.page-card {
    background: var(--card);
    border-radius: 14px;
    border: 1px solid var(--card-border);
    box-shadow: 0 8px 22px rgba(30, 51, 110, 0.06);
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.page-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 30px rgba(30, 51, 110, 0.12);
}

.page-card-header {
    display: flex;
    justify-content: space-between;
    padding: 14px 16px 0;
    font-weight: 600;
}

.page-number {
    color: var(--primary);
}

.page-card-body {
    display: flex;
    gap: 12px;
    padding: 14px 16px 16px;
}

.page-thumbnail {
    width: 90px;
    height: 120px;
    border-radius: 10px;
    object-fit: cover;
    background: rgba(76, 110, 245, 0.08);
    flex-shrink: 0;
}

.page-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.page-actions {
    display: flex;
    gap: 10px;
    padding: 0 16px 16px;
}

.design-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 24px;
}

.preview-panel,
.theme-panel {
    display: flex;
    flex-direction: column;
    gap: 18px;
    background: var(--card);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 26px rgba(30, 51, 110, 0.1);
    border: 1px solid rgba(96, 117, 186, 0.1);
}

.preview-header h2 {
    margin-bottom: 6px;
}

.preview-canvas {
    background: linear-gradient(140deg, rgba(240, 242, 255, 0.85), rgba(255, 255, 255, 0.9));
    border-radius: 16px;
    padding: 26px;
    border: 1px solid rgba(96, 117, 186, 0.12);
    min-height: 360px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-canvas .preview-page {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 16px;
    padding: 26px;
    box-shadow: 0 18px 44px rgba(30, 51, 110, 0.12);
    border: 1px solid rgba(96, 117, 186, 0.08);
}

.theme-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.theme-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.theme-group {
    border-top: 1px solid rgba(96, 117, 186, 0.15);
    padding-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.theme-group:first-of-type {
    border-top: none;
    padding-top: 0;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.theme-column {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.theme-column h3 {
    font-size: 1.05rem;
}

.split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
}

.effects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.status-message {
    padding: 12px 14px;
    border-radius: 10px;
    font-weight: 600;
    display: none;
}

.status-message.info {
    display: block;
    background: #e6efff;
    color: #2850a8;
}

.status-message.success {
    display: block;
    background: #d8f5e5;
    color: #1c7c44;
}

.status-message.error {
    display: block;
    background: #fde4e4;
    color: #b24b4b;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(12, 19, 43, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px;
    width: min(720px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-soft);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    font-size: 1.6rem;
    cursor: pointer;
    color: var(--muted);
}

@media (max-width: 960px) {
    .workspace-stats {
        order: 3;
    }

    .design-layout {
        grid-template-columns: 1fr;
    }

    .theme-panel {
        max-height: unset;
    }

        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 26px 18px 48px;
    }

    .workspace-toolbar {
        flex-wrap: wrap;
        gap: 12px;
    }

    .workspace-stats {
        width: 100%;
        justify-content: flex-start;
    }

    #generateBtn {
        width: 100%;
    }

    .control-buttons {
        flex-direction: column;
        width: 100%;
    }

    .control-buttons .btn {
        width: 100%;
    }
}
