:root {
    --ink: #202124;
    --muted: #65707f;
    --line: #dde4ea;
    --paper: #fffdf7;
    --soft: #f5efe3;
    --mint: #dcefe5;
    --blue: #dbeafe;
    --rose: #ffe1df;
    --gold: #f8c65d;
    --green: #2f7d65;
    --red: #bd3b3b;
    --shadow: 0 18px 42px rgba(34, 37, 41, 0.12);
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--paper);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.55;
}

a {
    color: inherit;
}

img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

button,
input,
select,
textarea {
    font: inherit;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px clamp(18px, 4vw, 56px);
    border-bottom: 1px solid rgba(32, 33, 36, 0.08);
    background: rgba(255, 253, 247, 0.94);
    backdrop-filter: blur(18px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: 800;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border-radius: 8px;
    background: var(--green);
    color: white;
}

.top-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
}

.top-nav a,
.back-link {
    color: var(--muted);
    font-size: 0.94rem;
    font-weight: 700;
    text-decoration: none;
}

main {
    width: min(1160px, calc(100% - 32px));
    margin: 0 auto;
}

.catalog-hero,
.story-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
    gap: clamp(28px, 6vw, 74px);
    align-items: center;
    min-height: 520px;
    padding: clamp(42px, 8vw, 86px) 0;
}

.catalog-hero h1,
.story-hero h1 {
    max-width: 760px;
    margin: 0 0 18px;
    font-size: clamp(2.35rem, 5vw, 5.6rem);
    line-height: 0.96;
    letter-spacing: 0;
}

.catalog-hero p,
.story-hero p {
    max-width: 650px;
    color: var(--muted);
    font-size: 1.08rem;
}

.eyebrow,
.scene-number {
    color: var(--green);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-visual,
.story-cover,
.card-art,
.scene-art {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: var(--mint);
    box-shadow: var(--shadow);
    isolation: isolate;
}

.hero-visual {
    min-height: 390px;
}

.hero-visual::before,
.story-cover::before,
.card-art::before,
.scene-art::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(circle at 20% 25%, rgba(248, 198, 93, 0.95), transparent 25%),
        radial-gradient(circle at 80% 20%, rgba(255, 225, 223, 0.9), transparent 27%),
        linear-gradient(135deg, #dcefe5, #dbeafe 58%, #fff4cf);
}

.hero-visual span {
    position: absolute;
    display: block;
    border: 3px solid rgba(32, 33, 36, 0.75);
    background: rgba(255, 255, 255, 0.55);
}

.hero-visual span:nth-child(1) {
    left: 13%;
    top: 22%;
    width: 38%;
    height: 54%;
    border-radius: 8px 8px 48px 8px;
    transform: rotate(-5deg);
}

.hero-visual span:nth-child(2) {
    right: 13%;
    top: 28%;
    width: 34%;
    height: 44%;
    border-radius: 50%;
}

.hero-visual span:nth-child(3) {
    left: 26%;
    bottom: 13%;
    width: 48%;
    height: 16%;
    border-radius: 999px;
    background: rgba(47, 125, 101, 0.25);
}

.story-cover {
    aspect-ratio: 4 / 3;
}

.age-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 8px 0 26px;
}

.age-filter a,
.age-pill {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    min-height: 34px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: white;
    color: var(--green);
    font-size: 0.84rem;
    font-weight: 850;
    text-decoration: none;
}

.age-filter a.active {
    border-color: var(--green);
    background: var(--green);
    color: white;
}

.story-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
    padding: 18px 0 72px;
}

.story-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
}

.card-art {
    display: block;
    aspect-ratio: 16 / 10;
    box-shadow: none;
}

.card-body {
    padding: 18px;
}

.card-body h2 {
    margin: 10px 0 8px;
    font-size: 1.24rem;
    line-height: 1.18;
}

.card-body h2 a {
    text-decoration: none;
}

.card-body p {
    margin: 0;
    color: var(--muted);
}

.story-page {
    width: min(1080px, calc(100% - 32px));
}

.story-hero {
    grid-template-columns: minmax(0, 0.95fr) minmax(320px, 0.9fr);
    min-height: 500px;
}

.hero-actions,
.video-controls,
.sticky-actions,
.cover-tools,
.panel-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    color: var(--ink);
    font-weight: 850;
    text-decoration: none;
    cursor: pointer;
}

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

.button.ghost {
    background: transparent;
}

.button.compact {
    min-height: 36px;
    padding: 8px 12px;
}

.button.danger {
    border-color: rgba(189, 59, 59, 0.24);
    background: #fff4f4;
    color: var(--red);
}

.video-studio {
    display: grid;
    gap: 12px;
    margin: 0 0 42px;
}

#storyCanvas {
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f4f0e8;
}

.video-controls {
    justify-content: space-between;
    color: var(--muted);
    font-weight: 700;
}

.hidden {
    display: none !important;
}

.story-scenes {
    display: grid;
    gap: 28px;
    padding: 22px 0 72px;
}

.scene {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 28px;
    align-items: center;
}

.scene-art {
    aspect-ratio: 4 / 3;
    box-shadow: none;
}

.scene h2 {
    margin: 4px 0 10px;
    font-size: 1.8rem;
    line-height: 1.12;
}

.scene p {
    margin: 0;
    color: #3d444d;
    font-size: 1.08rem;
}

.ad-slot {
    width: min(1160px, calc(100% - 32px));
    min-height: 88px;
    margin: 18px auto;
    padding: 18px;
    border: 1px dashed #b8c4ce;
    border-radius: 8px;
    background: white;
    color: var(--muted);
    text-align: center;
}

.site-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    padding: 32px clamp(18px, 4vw, 56px);
    border-top: 1px solid var(--line);
    color: var(--muted);
}

.admin-body {
    background: #f7f4ed;
}

.admin-shell {
    width: min(1240px, calc(100% - 32px));
    padding: 28px 0 72px;
}

.login-panel,
.editor-panel,
.settings-panel,
.admin-list {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    box-shadow: 0 12px 26px rgba(34, 37, 41, 0.06);
}

.login-panel {
    width: min(460px, 100%);
    margin: 64px auto;
    padding: 26px;
}

.admin-grid {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
}

.admin-list,
.editor-panel,
.settings-panel {
    padding: 20px;
}

.panel-heading {
    justify-content: space-between;
    margin-bottom: 14px;
}

.panel-heading h1,
.panel-heading h2,
.panel-heading h3,
.editor-panel h2,
.settings-panel h2 {
    margin: 0;
    line-height: 1.15;
}

.admin-story-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.admin-story-row span {
    display: block;
    color: var(--muted);
    font-size: 0.88rem;
}

.stack-form,
.story-form,
.scene-editor {
    display: grid;
    gap: 14px;
}

.story-form label,
.stack-form label,
.scene-editor label {
    display: grid;
    gap: 6px;
    color: #4d5662;
    font-size: 0.92rem;
    font-weight: 800;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cfd8df;
    border-radius: 8px;
    background: white;
    color: var(--ink);
    padding: 10px 12px;
}

textarea {
    resize: vertical;
}

.form-row {
    display: grid;
    gap: 14px;
}

.form-row.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-row.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mini-canvas {
    width: min(420px, 100%);
    aspect-ratio: 16 / 9;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbf7ed;
}

.scene-editor {
    margin: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fffdf8;
}

.sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: 10;
    margin: 8px -20px -20px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(12px);
}

.settings-panel,
.delete-form {
    margin-top: 22px;
}

.notice {
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: 800;
}

.notice.success {
    background: #e6f5ec;
    color: #1d6d54;
}

.notice.error {
    background: #ffe7e7;
    color: #9c3030;
}

@media (max-width: 920px) {
    .catalog-hero,
    .story-hero,
    .admin-grid,
    .scene {
        grid-template-columns: 1fr;
    }

    .catalog-hero,
    .story-hero {
        min-height: auto;
    }

    .story-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .scene-art {
        width: min(460px, 100%);
    }
}

@media (max-width: 640px) {
    .site-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .story-grid,
    .form-row.two,
    .form-row.three {
        grid-template-columns: 1fr;
    }

    .catalog-hero h1,
    .story-hero h1 {
        font-size: 2.45rem;
    }

    .hero-visual {
        min-height: 280px;
    }

    .admin-shell,
    main,
    .story-page {
        width: min(100% - 24px, 1160px);
    }
}

