:root {
    --fg: #ffffff;
    --fg-dim: rgba(255, 255, 255, 0.6);
    --cream: #fdfbf7;
    --panel-green: #1c2e22;
    --grain: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.04'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
}

body {
    display: grid;
    grid-template-columns: 420px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto auto;
    grid-template-areas:
        "form stage"
        "play stage"
        "foot stage";
    min-height: 100dvh;
    font-family: 'Josefin Sans', sans-serif;
    background: #0d0d0d;
    color: var(--cream);
}

.sidebar-body,
.actions,
.sidebar-foot {
    color: var(--cream);
    background-color: var(--panel-green);
    background-image: var(--grain);
    border-right: 4px solid #111;
}

.sidebar-body {
    grid-area: form;
    min-height: 0;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.6);
}

.brand {
    padding-bottom: 1rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.brand h1 {
    margin: 0;
    font-family: 'Fascinate Inline', cursive;
    font-size: 2.25rem;
    font-weight: 400;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.brand p {
    margin: 0.5rem 0 0;
    font-size: 0.75rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.sidebar-body section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.field-label,
.options label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.8);
}

.sample,
.btn-play,
.btn-export {
    cursor: pointer;
}

.sample {
    font-family: inherit;
    text-align: left;
    padding: 0.55rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #ccc;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-left: 3px solid transparent;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.sample:hover {
    color: var(--cream);
    background: rgba(0, 0, 0, 0.5);
    border-left-color: var(--fg);
}

textarea {
    width: 100%;
    height: 6.5rem;
    resize: none;
    padding: 0.75rem;
    font-family: inherit;
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--cream);
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    transition: border-color 0.2s, background 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--fg);
    background: rgba(0, 0, 0, 0.6);
}

.options {
    gap: 0.75rem;
    padding: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #eee;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 2px;
}

.options label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-weight: 600;
    color: #eee;
    transition: color 0.2s;
}

.options label:hover {
    color: var(--fg);
}

input[type="checkbox"] {
    appearance: none;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border: 2px solid var(--fg-dim);
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
    position: relative;
    border-radius: 2px;
}

input[type="checkbox"]:checked {
    background: var(--fg);
    border-color: var(--fg);
}

input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid #111;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.actions {
    grid-area: play;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0 2rem 1rem;
}

.btn-play {
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-family: 'Fascinate Inline', cursive;
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #111;
    background: var(--fg);
    border: 2px solid #fff;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.btn-play:hover {
    background: #e0e0e0;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.4);
}

.sidebar-foot {
    grid-area: foot;
    padding: 1.25rem 2rem 1.5rem;
    background-color: var(--panel-green);
    background-image: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)), var(--grain);
    border-top: 2px solid rgba(255, 255, 255, 0.1);
}

.exports {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.btn-export {
    padding: 0.5rem 0.4rem;
    font-family: 'Fascinate Inline', cursive;
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--cream);
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.btn-export:hover {
    border-color: var(--fg);
    color: var(--fg);
    background: rgba(255, 255, 255, 0.05);
}

.credit {
    margin: 0;
    text-align: center;
    font-size: 0.62rem;
    letter-spacing: 0.16em;
    color: rgba(255, 255, 255, 0.4);
}

.stage {
    grid-area: stage;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    position: relative;
    background: var(--panel-green);
}

.poster {
    display: flex;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 3 / 4;
    padding: 4px;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.9);
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#toasts {
    position: absolute;
    right: 1.5rem;
    bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    padding: 0.7rem 1rem;
    font-size: 0.8rem;
    background: #111;
    border: 2px solid #fff;
    border-left-width: 4px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8);
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideIn {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.3); }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg); }

@media (min-width: 901px) {
    html, body {
        height: 100dvh;
        overflow: hidden;
    }
}

@media (max-width: 900px) {
    html, body {
        height: auto;
        min-height: 100dvh;
        overflow-x: hidden;
        overflow-y: auto;
    }

    body {
        display: flex;
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    .sidebar-body,
    .actions,
    .sidebar-foot {
        border-right: none;
        box-shadow: none;
        width: 100%;
        flex: none;
    }

    .sidebar-body {
        overflow: visible;
        padding: 2rem 1.5rem 1.75rem;
        gap: 1.75rem;
    }

    textarea {
        height: 5.5rem;
    }

    .stage {
        flex: none;
        width: 100%;
        height: auto;
        min-height: 0;
        overflow: visible;
        padding: 2.25rem 1.5rem;
    }

    .poster {
        display: block;
        width: min(100%, 28rem);
        max-height: none;
        height: auto;
    }

    canvas {
        height: auto;
        aspect-ratio: 3 / 4;
    }

    .actions {
        padding: 1.5rem 1.5rem 1.75rem;
        gap: 0.85rem;
    }

    .sidebar-foot {
        padding: 0.5rem 1.5rem 2.75rem;
        background-color: var(--panel-green);
        background-image: var(--grain);
        border-top: none;
    }
}
