:root {
    --bg: #0f172a;
    --surface: #111827;
    --panel: #0b1220;
    --border: #1f2937;
    --primary: #3b82f6;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --success: #22c55e;
    --error: #ef4444;
    --shadow: rgba(0, 0, 0, 0.25);
    --radius: 12px;
    --animation-speed: 0.3s;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f8fafc;
        --surface: #ffffff;
        --panel: #ffffff;
        --border: #d1d5db;
        --primary: #2563eb;
        --text: #0f172a;
        --muted: #64748b;
        --shadow: rgba(0, 0, 0, 0.1);
    }
}

[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #111827;
    --panel: #0b1220;
    --border: #1f2937;
    --primary: #3b82f6;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --shadow: rgba(0, 0, 0, 0.25);
}

[data-theme="light"] {
    --bg: #f8fafc;
    --surface: #ffffff;
    --panel: #ffffff;
    --border: #d1d5db;
    --primary: #2563eb;
    --text: #0f172a;
    --muted: #64748b;
    --shadow: rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: all var(--animation-speed) ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 16px 64px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.tool-header { text-align: center; }
.header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 8px;
}
.tool-header h1 { margin: 0; font-size: 32px; }
.theme-toggle {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all var(--animation-speed) ease;
    font-size: 18px;
    color: var(--text);
}
.theme-toggle:hover {
    background: var(--panel);
    transform: scale(1.1);
}

.subtitle { margin: 0; color: var(--muted); }
.notice {
    margin-top: 12px;
    display: inline-flex;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(59, 130, 246, 0.12);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text);
}

.layout {
    display: grid;
    grid-template-columns: 280px 1fr 360px;
    gap: 20px;
    min-height: 600px;
}

@media (max-width: 1200px) {
    .layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

.sidebar, .editor, .preview {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 4px 6px var(--shadow);
    transition: all var(--animation-speed) ease;
}

.sidebar:hover, .editor:hover, .preview:hover {
    box-shadow: 0 8px 25px var(--shadow);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.slide-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.slides-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 540px;
    overflow-y: auto;
    padding-right: 4px;
}

.slide-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel);
    cursor: pointer;
    transition: all var(--animation-speed) ease;
    position: relative;
}

.slide-item:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}
.slide-item.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
    background: rgba(59, 130, 246, 0.1);
}
.slide-item-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}
.slide-item-preview {
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.form-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px 16px;
    align-items: start;
}

.form-grid label {
    font-weight: 500;
    color: var(--text);
    padding-top: 8px;
    font-size: 14px;
}

.background-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.background-controls input[type="color"] {
    width: 50px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
}

.input, .textarea {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text);
    font-size: 14px;
    transition: all var(--animation-speed) ease;
    width: 100%;
}

.input:focus, .textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.textarea {
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
    line-height: 1.5;
}

.editor-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.action-group, .export-group, .import-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.image-upload-area {
    margin-top: 16px;
    padding: 16px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    text-align: center;
    transition: all var(--animation-speed) ease;
    cursor: pointer;
}

.image-upload-area:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.upload-zone p {
    margin: 0 0 4px;
    color: var(--text);
    font-weight: 500;
}

.upload-zone small {
    color: var(--muted);
}

.export-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.preview-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px;
}

.zoom-controls button {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    border-radius: 4px;
    transition: all var(--animation-speed) ease;
}

.zoom-controls button:hover {
    background: var(--border);
}

#zoom-level {
    min-width: 45px;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
}

.preview-navigation {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
}

.btn {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 16px;
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--animation-speed) ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    white-space: nowrap;
    justify-content: center;
}

.btn:hover {
    background: var(--surface);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--shadow);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px var(--shadow);
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
}

.btn-secondary {
    background: var(--surface);
    border-color: var(--border);
}

.btn-small {
    padding: 6px 10px;
    font-size: 12px;
    min-width: auto;
}

.btn-nav {
    min-width: 100px;
    justify-content: center;
}

.btn.ghost {
    background: transparent;
    border-color: transparent;
}

.btn.ghost:hover {
    background: var(--panel);
    border-color: var(--border);
}

.btn.danger {
    color: var(--error);
    border-color: var(--error);
}

.btn.danger:hover {
    background: var(--error);
    color: white;
}

.slide {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    aspect-ratio: 16 / 9;
    min-height: 200px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    overflow: hidden;
    transition: all var(--animation-speed) ease;
    color: #333;
}

.slide:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transform: scale(1.02);
}

.slide h3 {
    margin-top: 0;
    font-size: 28px;
    color: inherit;
}
.slide p {
    font-size: 18px;
    line-height: 1.5;
    white-space: pre-line;
    color: inherit;
}
.slide ul,
.slide ol {
    margin: 16px 0;
    padding-left: 24px;
    font-size: 18px;
    line-height: 1.5;
    color: inherit;
}
.slide li + li { margin-top: 6px; }
.slide .checkbox-list { list-style: none; padding-left: 0; }
.slide .checkbox-list li { position: relative; padding-left: 28px; }
.slide .checkbox-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    top: 0;
    line-height: 1.4;
    color: var(--success);
}

.slide.theme-dark {
    background: linear-gradient(135deg, #1e293b, #334155);
    color: white;
}

.slide.theme-sunrise {
    background: linear-gradient(135deg, #f59e0b, #f97316, #ef4444);
    color: white;
}

.slide.theme-forest {
    background: linear-gradient(135deg, #166534, #15803d, #16a34a);
    color: white;
}

.slide.theme-ocean {
    background: linear-gradient(135deg, #0c4a6e, #0369a1, #0284c7);
    color: white;
}

.slide.theme-minimal {
    background: #fefefe;
    border: 2px solid #e2e8f0;
    color: #1e293b;
}

/* Slide animations */
.slide.animate-fadeIn {
    animation: slideFadeIn 0.6s ease-out;
}

.slide.animate-slideUp {
    animation: slideUp 0.5s ease-out;
}

.slide.animate-bounceIn {
    animation: bounceIn 0.8s ease-out;
}

.slide.animate-typewriter .slide p {
    overflow: hidden;
    border-right: 3px solid;
    white-space: nowrap;
    animation: typewriter 3s steps(40) 1s both, blink-caret 0.75s step-end infinite;
}

@keyframes slideFadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); opacity: 0.8; }
    70% { transform: scale(0.9); opacity: 0.9; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: currentColor; }
}

/* Slide transitions */
.slide-transition-fade {
    transition: opacity 0.5s ease-in-out;
}

.slide-transition-slide {
    transition: transform 0.4s ease-in-out;
}

.slide-transition-zoom {
    transition: transform 0.4s ease-in-out, opacity 0.3s ease-in-out;
}

.slide-transition-flip {
    transition: transform 0.6s ease-in-out;
}

/* Status and notifications */
.status {
    font-size: 13px;
    color: var(--muted);
    text-align: center;
    padding: 8px;
    border-radius: 6px;
    background: var(--panel);
    transition: all var(--animation-speed) ease;
    min-height: 18px;
}

.status.success {
    color: var(--success);
    background: rgba(34, 197, 94, 0.1);
}

.status.error {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.hint {
    font-size: 12px;
    color: var(--muted);
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 16px 12px;
    }

    .header-top {
        flex-direction: column;
        gap: 12px;
    }

    .tool-header h1 {
        font-size: 24px;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .form-grid label {
        padding-top: 0;
        margin-bottom: 4px;
    }

    .action-group, .export-group {
        flex-direction: column;
    }

    .btn {
        justify-content: center;
    }

    .slides-list {
        max-height: 280px;
    }
}

@media (max-width: 1200px) {
    .layout {
        grid-template-columns: 220px 1fr;
        grid-template-rows: auto auto;
    }
    .preview {
        grid-column: 1 / -1;
    }
}

@media (max-width: 880px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .sidebar, .editor, .preview {
        order: initial;
    }
}