:root {
    --primary: #0ea5e9;
    --primary-hover: #0284c7;
    --background: #ffffff;
    --foreground: #020617;
    --muted: #f1f5f9;
    --muted-foreground: #64748b;
    --border: #e2e8f0;
    --radius: 0.5rem;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: system-ui, -apple-system, sans-serif;
    background-color: var(--background);
    color: var(--foreground);
    line-height: 1.5;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, var(--primary), var(--primary-hover));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.subtitle {
    color: var(--muted-foreground);
    font-size: 1.1rem;
}

.story-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
}

.input {
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--background);
    color: var(--foreground);
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.1);
}

textarea.input {
    min-height: 100px;
    resize: vertical;
}

.range {
    width: 100%;
    height: 4px;
    background: var(--muted);
    border-radius: var(--radius);
    appearance: none;
    cursor: pointer;
}

.range::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.range::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--background);
    color: var(--foreground);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:hover {
    background-color: var(--muted);
    border-color: var(--muted-foreground);
}

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

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

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

.generate-section {
    text-align: center;
    margin-bottom: 2rem;
}

.output-section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    margin-top: 2rem;
    background-color: var(--background);
    box-shadow: var(--shadow);
}

.story-chunk {
    margin-bottom: 3rem;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--background);
    box-shadow: var(--shadow);
    transition: transform 0.2s ease;
}

.story-chunk:hover {
    transform: translateY(-2px);
}

.story-text {
    font-size: 1.1rem;
    line-height: 1.7;
    margin-bottom: 1.5rem;
    color: var(--foreground);
}

.story-image {
    margin: 1.5rem 0;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.story-image img {
    width: 100%;
    height: auto;
    object-fit: cover;
    aspect-ratio: 16/9;
    transition: transform 0.3s ease;
}

.story-image:hover img {
    transform: scale(1.05);
}

.audio-player {
    margin-top: 1rem;
    padding: 1rem;
    background-color: var(--muted);
    border-radius: var(--radius);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.audio-player audio {
    width: 100%;
}

.audio-player audio::-webkit-media-controls-panel {
    background-color: var(--background);
}

.audio-player audio::-webkit-media-controls-play-button,
.audio-player audio::-webkit-media-controls-volume-slider,
.audio-player audio::-webkit-media-controls-mute-button {
    cursor: pointer;
}

.story-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.hidden {
    display: none;
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 2rem;
    }

    .story-controls {
        grid-template-columns: 1fr;
    }

    .output-section {
        padding: 1rem;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --background: #0f172a;
        --foreground: #f8fafc;
        --muted: #1e293b;
        --muted-foreground: #94a3b8;
        --border: #334155;
        --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.2);
    }

    .story-chunk {
        background-color: #1e293b;
    }

    .audio-player {
        background-color: #0f172a;
    }

    .btn:not(.primary) {
        background-color: #1e293b;
        color: var(--foreground);
    }

    .btn:not(.primary):hover {
        background-color: #334155;
    }
}