@font-face {
    font-family: "Hanken Grotesk";
    src: url("../assets/HankenGrotesk-Variable.ttf") format("truetype");
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
}

:root {
    color-scheme: dark;
    --ink: #090713;
    --navy: #100b1d;
    --panel: rgba(17, 12, 31, 0.9);
    --panel-soft: rgba(21, 15, 38, 0.72);
    --cream: #fff9ef;
    --pink: #ff5c8c;
    --muted: #c9bdcb;
    --line: rgba(255, 249, 239, 0.12);
    --line-strong: rgba(255, 92, 140, 0.34);
    --blue: #2677d7;
    --radius-lg: 28px;
    --radius-md: 18px;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--ink);
}

body {
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    color: var(--cream);
    background:
        radial-gradient(circle at 10% 12%, rgba(38, 119, 215, 0.17), transparent 32%),
        radial-gradient(circle at 92% 10%, rgba(255, 92, 140, 0.16), transparent 30%),
        linear-gradient(145deg, #080711 0%, #100b1d 50%, #090713 100%);
    font-family: "Hanken Grotesk", Arial, sans-serif;
}

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

button,
select,
input[type="radio"],
input[type="file"] {
    cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
    outline: 3px solid rgba(255, 92, 140, 0.42);
    outline-offset: 2px;
}

.ambient {
    position: fixed;
    z-index: -1;
    width: 38vw;
    height: 70vh;
    filter: blur(90px);
    opacity: 0.13;
    pointer-events: none;
}

.ambient-left {
    top: 20vh;
    left: -22vw;
    background: #197cff;
}

.ambient-right {
    right: -20vw;
    bottom: 2vh;
    background: #ff2d73;
}

.app-header {
    display: flex;
    align-items: center;
    gap: 32px;
    width: min(1500px, calc(100% - 64px));
    margin: 0 auto;
    padding: 42px 0 30px;
}

.app-header-logo {
    width: 270px;
    height: auto;
}

.kicker,
.section-number {
    margin: 0 0 6px;
    color: var(--pink);
    font-size: 12px;
    font-weight: 850;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 4px;
    font-family: "Arial Black", Arial, sans-serif;
    font-size: clamp(30px, 3vw, 48px);
    line-height: 1;
    letter-spacing: -0.035em;
}

.header-copy {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 16px;
}

.app-layout {
    display: grid;
    grid-template-columns: minmax(460px, 1fr) minmax(440px, 0.9fr);
    gap: 24px;
    width: min(1500px, calc(100% - 64px));
    margin: 0 auto;
    padding-bottom: 64px;
}

.editor-panel,
.preview-panel {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: rgba(9, 7, 19, 0.74);
    box-shadow: var(--shadow);
    backdrop-filter: blur(26px);
}

.editor-panel {
    padding: 28px;
}

.preview-panel {
    position: sticky;
    top: 20px;
    align-self: start;
    padding: 28px;
}

.panel-heading,
.preview-heading,
.section-title-row,
.event-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.panel-heading h2,
.preview-heading h2 {
    margin: 0;
    font-size: 25px;
    letter-spacing: -0.02em;
}

.save-state,
.format-chip,
.count-badge {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 12px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.035);
    font-size: 12px;
    font-weight: 750;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.form-section {
    margin-top: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 22px;
    background: var(--panel-soft);
}

.section-title-row {
    margin-bottom: 18px;
}

.section-title-row h3 {
    margin: 0;
    font-size: 17px;
}

.section-title-row p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.count-badge {
    color: var(--pink);
}

.format-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 0 0 18px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.2);
}

.format-switch label {
    position: relative;
}

.format-switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.format-switch span {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    border-radius: 10px;
    padding: 8px 13px;
    color: var(--muted);
    font-weight: 760;
    transition: 160ms ease;
}

.format-switch small {
    font-size: 10px;
    font-weight: 600;
    opacity: 0.7;
}

.format-switch input:checked + span {
    color: var(--cream);
    background: rgba(255, 92, 140, 0.16);
    box-shadow: inset 0 0 0 1px rgba(255, 92, 140, 0.36);
}

.field {
    position: relative;
    display: grid;
    gap: 7px;
    margin-top: 14px;
}

.field-label {
    color: var(--cream);
    font-size: 12px;
    font-weight: 760;
    letter-spacing: 0.025em;
}

.field-label em {
    color: var(--muted);
    font-style: normal;
    font-weight: 500;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid rgba(255, 249, 239, 0.13);
    border-radius: 11px;
    padding: 12px 13px;
    color: var(--cream);
    background: rgba(5, 4, 12, 0.56);
    transition: border-color 150ms ease, background 150ms ease;
}

input:hover,
select:hover,
textarea:hover {
    border-color: rgba(255, 249, 239, 0.24);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--pink);
    background: rgba(5, 4, 12, 0.78);
}

textarea {
    min-height: 84px;
    resize: vertical;
}

select {
    appearance: auto;
}

.story-only {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 10px;
}

.story-only.is-hidden {
    display: none;
}

.events-list {
    display: grid;
    gap: 14px;
}

.event-editor-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(6, 4, 14, 0.44);
}

.event-card-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(90deg, rgba(255, 92, 140, 0.08), transparent 60%);
}

.event-card-header h4 {
    margin: 0;
    font-size: 15px;
}

.event-index {
    margin: 0 0 2px;
    color: var(--pink);
    font-size: 10px;
    font-weight: 850;
    letter-spacing: 0.12em;
}

.event-card-actions {
    display: flex;
    gap: 5px;
}

.icon-button {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 9px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.035);
}

.icon-button:hover:not(:disabled) {
    color: var(--cream);
    border-color: rgba(255, 92, 140, 0.45);
}

.icon-button:disabled {
    cursor: default;
    opacity: 0.24;
}

.remove-event:hover:not(:disabled) {
    color: var(--pink);
}

.event-card-body {
    padding: 16px;
}

.event-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.character-count {
    position: absolute;
    right: 9px;
    bottom: 8px;
    color: rgba(201, 189, 203, 0.7);
    font-size: 10px;
}

.logo-control {
    display: grid;
    grid-template-columns: 118px 1fr;
    gap: 14px;
    align-items: center;
    margin-top: 16px;
    border-top: 1px solid var(--line);
    padding-top: 16px;
}

.logo-preview-shell {
    display: grid;
    width: 118px;
    height: 92px;
    place-items: center;
    overflow: hidden;
    border: 1px dashed rgba(255, 249, 239, 0.28);
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
}

.logo-preview {
    display: none;
    width: 88%;
    height: 80%;
    object-fit: contain;
}

.logo-preview.is-visible {
    display: block;
}

.logo-placeholder {
    color: var(--muted);
    font-family: "Arial Black", Arial, sans-serif;
    font-size: 13px;
}

.logo-placeholder.is-hidden {
    display: none;
}

.logo-control-title {
    margin: 0 0 3px;
    font-size: 13px;
    font-weight: 800;
}

.logo-control-copy {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
}

.file-button {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 7px 11px;
    color: var(--cream);
    background: rgba(255, 255, 255, 0.05);
    font-size: 11px;
    font-weight: 750;
}

.file-button:hover {
    border-color: var(--pink);
}

.file-button input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.text-button {
    margin-left: 8px;
    border: 0;
    padding: 7px 0;
    color: var(--pink);
    background: transparent;
    font-size: 11px;
    font-weight: 800;
}

.add-event-button,
.primary-button,
.secondary-button {
    border-radius: 12px;
    padding: 12px 16px;
    font-weight: 820;
    transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.add-event-button {
    width: 100%;
    margin-top: 14px;
    border: 1px dashed rgba(255, 92, 140, 0.42);
    color: var(--pink);
    background: rgba(255, 92, 140, 0.055);
}

.add-event-button:hover:not(:disabled),
.secondary-button:hover,
.primary-button:hover {
    transform: translateY(-1px);
}

.add-event-button:disabled {
    cursor: default;
    opacity: 0.35;
}

.primary-button {
    border: 1px solid var(--pink);
    color: #160a13;
    background: var(--pink);
}

.secondary-button {
    border: 1px solid var(--line);
    color: var(--cream);
    background: rgba(255, 255, 255, 0.045);
}

.compact-button {
    min-height: 43px;
    padding: 10px 13px;
    font-size: 12px;
}

.footer-section {
    padding: 0;
}

.footer-section summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 800;
    list-style: none;
}

.footer-section summary::-webkit-details-marker {
    display: none;
}

.summary-hint {
    color: var(--muted);
    font-size: 11px;
    font-weight: 520;
}

.details-content {
    border-top: 1px solid var(--line);
    padding: 4px 20px 20px;
}

.preview-heading {
    margin-bottom: 18px;
}

.canvas-stage {
    position: relative;
    display: grid;
    width: 100%;
    max-height: calc(100vh - 240px);
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 18px;
    background:
        linear-gradient(45deg, rgba(255,255,255,.025) 25%, transparent 25%) 0 0 / 18px 18px,
        linear-gradient(-45deg, rgba(255,255,255,.025) 25%, transparent 25%) 0 9px / 18px 18px,
        #06040e;
}

#preview-canvas {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 280px);
    width: auto;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.58);
}

.canvas-loading {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--muted);
    background: rgba(8, 6, 18, 0.74);
    font-size: 13px;
    transition: opacity 180ms ease;
}

.canvas-loading.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.preview-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    margin-top: 16px;
}

.status-message {
    min-height: 20px;
    margin: 10px 2px 0;
    color: var(--muted);
    font-size: 12px;
}

.status-message.is-error {
    color: #ff9cb9;
}

[hidden] {
    display: none !important;
}

@media (max-width: 1080px) {
    .app-layout {
        grid-template-columns: 1fr;
    }

    .preview-panel {
        position: static;
        order: -1;
    }

    .canvas-stage,
    #preview-canvas {
        max-height: 72vh;
    }
}

@media (max-width: 680px) {
    .app-header,
    .app-layout {
        width: min(100% - 28px, 100%);
    }

    .app-header {
        align-items: flex-start;
        gap: 18px;
        padding-top: 24px;
    }

    .app-header-logo {
        width: 150px;
    }

    .header-copy {
        display: none;
    }

    .editor-panel,
    .preview-panel {
        padding: 18px;
        border-radius: 20px;
    }

    .form-section {
        padding: 16px;
    }

    .event-grid,
    .story-only,
    .logo-control {
        grid-template-columns: 1fr;
    }

    .logo-preview-shell {
        width: 100%;
    }

    .preview-actions {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition: none !important;
    }
}
