:root {
    /* ФОН. Россыпь из котиков и emoji генерируется скриптом tools/generate-background.py.
       Если хочешь свою картинку — укажи путь здесь, она ляжет под градиент и emoji:
         --bg-image: url("/images/background.jpg"); */
    --bg-image: none;

    /* Базовый цвет: им же заливается html, чтобы не мигало белым при загрузке. */
    --bg-base: #0a1030;

    /* Голубой градиент: индиго слева сверху, насыщенный синий справа снизу. */
    --bg-gradient: radial-gradient(110vmax 80vmax at 82% 88%, #4f8fe0 0%, transparent 62%),
    radial-gradient(90vmax 70vmax at 12% 8%, #1b2a6b 0%, transparent 60%),
    linear-gradient(152deg, #0a1030 0%, #152252 48%, #24509c 100%);

    /* Затемнение под карточкой, чтобы белый текст читался на любом краю градиента. */
    --bg-vignette: radial-gradient(58vmax 58vmax at 50% 50%, rgba(6, 10, 28, .62), transparent 72%);

    /* Россыпь emoji: три слоя, каждый тянется на весь экран (cover), повторов нет. */
    --bg-scatter-far: url("/images/bg-scatter-far.svg");
    --bg-scatter: url("/images/bg-scatter.svg");
    --bg-sparkles: url("/images/bg-sparkles.svg");
    --bg-scatter-mobile: none;

    --accent: #8fc4ff;
    --accent-2: #a5b4fc;
    --text: #ffffff;
    --muted: rgba(255, 255, 255, .72);
    --card: rgba(255, 255, 255, .1);
    --card-border: rgba(255, 255, 255, .18);
    --danger-bg: rgba(255, 107, 138, .16);
    --danger-border: rgba(255, 138, 165, .55);
    --radius: 22px;
    --shadow: 0 24px 60px rgba(0, 0, 0, .35);
    --font: "Neucha", "Comic Sans MS", cursive;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

html {
    background: var(--bg-base);
}

body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    font-family: "Neucha", "Comic Sans MS", cursive;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* Фоновый слой: изображение → затемнение → искры → дальняя россыпь → россыпь → градиент.
   Порядок важен: слои рисуются сверху вниз, поэтому непрозрачный градиент идёт последним,
   иначе он просто закрывает emoji. */
.bg {
    position: fixed;
    inset: -8%;
    z-index: -1;
    pointer-events: none;
    background-color: var(--bg-base);
    background-image: var(--bg-image), var(--bg-vignette), var(--bg-sparkles),
    var(--bg-scatter-far), var(--bg-scatter), var(--bg-gradient);
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    will-change: transform;
    animation: drift 15s ease-in-out infinite alternate;
}

@keyframes drift {
    from {
        transform: translate3d(-1.6%, -1.2%, 0) scale(1.03);
    }

    to {
        transform: translate3d(1.6%, 1.2%, 0) scale(1.03);
    }
}

.card {
    width: min(640px, 100%);
    max-height: 100%;
    overflow-y: auto;
    padding: clamp(20px, 5vw, 36px);
    border-radius: var(--radius);
    border: 1px solid var(--card-border);
    background: var(--card);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    text-align: center;
    animation: appear .35s ease both;
}

@keyframes appear {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(10px) scale(.98);
    }
}

.step {
    animation: rise .3s ease both;
}

h1,
h2 {
    margin: 0;
    line-height: 1.2;
    letter-spacing: -.01em;
}

.title {
    font-size: clamp(22px, 6vw, 32px);
}

.subtitle {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: clamp(14px, 3.6vw, 17px);
}

.subtitle-agree {
    color: var(--text);
    font-size: clamp(22px, 6vw, 32px);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -.01em;
    text-shadow: 0 1px 0 rgba(6, 10, 28, .35);
}

/* --- Точки прогресса --- */
.dots {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
}

.dot {
    flex: 1;
    height: 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .18);
    transition: background .3s ease;
}

.dot.is-done {
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.dot.is-active {
    background: var(--accent);
}

/* --- Кнопки --- */
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 26px;
}

button {
    font: inherit;
    color: inherit;
    cursor: pointer;
    border: 0;
}

.btn {
    flex: 1 1 160px;
    min-height: 56px;
    padding: 14px 22px;
    border-radius: 16px;
    font-size: 17px;
    font-weight: 600;
    background: linear-gradient(120deg, var(--accent), var(--accent-2));
    color: #0b1533;
    box-shadow: 0 10px 24px rgba(165, 180, 252, .28);
    transition: transform .15s ease, filter .2s ease, opacity .2s ease;
}

.btn:hover:not(:disabled) {
    filter: brightness(1.06);
}

.btn:active:not(:disabled) {
    transform: scale(.97);
}

.btn:disabled {
    opacity: .55;
    cursor: progress;
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    box-shadow: inset 0 0 0 1.5px var(--card-border);
}

.btn-ghost:hover:not(:disabled) {
    background: rgba(255, 255, 255, .08);
}

.btn-link {
    background: none;
    padding: 4px 0;
    color: var(--muted);
    font-size: 15px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

:where(button, a, input):focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

/* --- Ошибка --- */
.alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--danger-border);
    background: var(--danger-bg);
    color: #ffe3ea;
    font-size: 15px;
    animation: rise .25s ease both;
}

/* --- Места --- */
.places {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 22px;
}

.place {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 0;
    overflow: hidden;
    border-radius: 18px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, .06);
    transition: transform .15s ease, border-color .2s ease, background .2s ease;
}

.place:hover:not(:disabled) {
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, .45);
    background: rgba(255, 255, 255, .12);
}

.place:disabled {
    opacity: .55;
    cursor: progress;
}

.place-wide {
    grid-column: 1 / -1;
}

.place img {
    display: block;
    flex: 0 0 auto;
    width: 100%;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    background: linear-gradient(120deg, rgba(143, 196, 255, .5), rgba(165, 180, 252, .5));
}

.place-body {
    padding: 12px 14px 16px;
}

.place-title {
    font-size: 17px;
    font-weight: 600;
}

.place-desc {
    margin-top: 4px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.35;
}

.place-check {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: #0b1533;
    font-size: 15px;
    font-weight: 700;
}

/* --- Свой вариант --- */
.custom {
    grid-column: 1 / -1;
    margin-top: 0;
    animation: rise .25s ease both;
}

.custom-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

input[type="text"] {
    flex: 1 1 180px;
    min-height: 52px;
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, .1);
    color: var(--text);
    font: inherit;
    text-align: center;
}

input[type="text"]::placeholder {
    color: rgba(255, 255, 255, .5);
}

input[type="text"]:focus {
    border-color: var(--accent);
    outline: none;
}

.custom .btn {
    flex: 0 0 auto;
}

/* --- Календарь --- */
.calendar {
    margin-top: 20px;
    padding: 14px;
    border-radius: 18px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, .06);
}

.calendar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.calendar-title {
    font-size: 17px;
    font-weight: 600;
    text-transform: capitalize;
}

.nav {
    min-width: 44px;
    min-height: 44px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .12);
    font-size: 18px;
    line-height: 1;
}

.nav:disabled {
    opacity: .3;
    cursor: default;
}

.weekdays,
.days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.weekdays span {
    text-align: center;
    padding-bottom: 4px;
    color: var(--muted);
    font-size: 13px;
}

.day {
    aspect-ratio: 1 / 1;
    min-height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, .08);
    font-size: 15px;
    transition: transform .12s ease, background .2s ease;
}

.day:hover:not(:disabled) {
    background: rgba(255, 255, 255, .2);
    transform: translateY(-2px);
}

.day:disabled {
    color: rgba(255, 255, 255, .3);
    background: transparent;
    text-decoration: line-through;
    cursor: not-allowed;
}

.day.is-selected {
    background: linear-gradient(120deg, var(--accent), var(--accent-2));
    color: #0b1533;
    font-weight: 700;
}

.legend {
    margin: 12px 2px 0;
    color: var(--muted);
    font-size: 13px;
}

/* --- Время --- */
.times {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
    gap: 10px;
    margin-top: 22px;
}

.time {
    min-height: 54px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .1);
    border: 1px solid var(--card-border);
    font-size: 17px;
    font-weight: 600;
    transition: transform .12s ease, background .2s ease;
}

.time:hover:not(:disabled) {
    background: rgba(255, 255, 255, .2);
    transform: translateY(-2px);
}

.time:disabled {
    opacity: .55;
    cursor: progress;
}

.time.is-selected {
    background: linear-gradient(120deg, var(--accent), var(--accent-2));
    color: #0b1533;
    border-color: transparent;
}

/* --- Итог --- */
.summary {
    margin: 24px 0 0;
    display: grid;
    gap: 10px;
}

.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .08);
    border: 1px solid var(--card-border);
}

.summary-label {
    color: var(--muted);
    font-size: 14px;
}

.summary-value {
    font-size: 17px;
    font-weight: 600;
    text-align: right;
}

.summary-edit {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .12);
    font-size: 14px;
}

.summary-edit:hover {
    background: rgba(255, 255, 255, .22);
}

.chosen {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}

.chip {
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .1);
    border: 1px solid var(--card-border);
    font-size: 14px;
}

.chip:hover {
    background: rgba(255, 255, 255, .2);
}

.heart {
    font-size: 34px;
    margin-bottom: 6px;
}

/* --- Финальный экран --- */
.waiting {
    text-align: center;
    padding: 24px 0 12px;
}

.waiting-title {
    font-size: clamp(26px, 8vw, 40px);
}

/* сводка на экране ожидания: без кнопок правки, поэтому по центру */
.waiting .summary-row {
    justify-content: center;
    text-align: center;
}

.waiting .summary-value {
    text-align: center;
}

.sign {
    margin-top: 24px;
}

.sign-thanks,
.sign-author {
    color: var(--text);
    font-size: 20px;
    font-weight: 600;
    text-shadow: 0 1px 0 rgba(6, 10, 28, .35);
}

.sign-author {
    margin-top: 2px;
    padding-right: 8px;
    text-align: right;
}

.btn:disabled {
    opacity: .6;
}

/* --- Загрузка --- */
.loader {
    display: grid;
    justify-items: center;
    gap: 14px;
    padding: 30px 0;
    color: var(--muted);
}

.spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, .2);
    border-top-color: var(--accent);
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* На телефоне широкие слои срезались бы по бокам — берём портретную россыпь. */
@media (max-width: 760px) {
    :root {
        --bg-scatter-mobile: url("/images/bg-scatter-mobile.svg");
    }

    .bg {
        background-image: var(--bg-image), var(--bg-vignette), var(--bg-scatter-mobile), var(--bg-gradient);
    }
}

@media (max-width: 400px) {
    .card {
        padding: 18px;
    }

    .day {
        min-height: 38px;
    }

    .btn {
        flex: 1 1 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}
