:root {
    --bg: #fbeef0;
    --bg2: #f4d3db;
    --ink: #3b1d2e;
    --soft: #7b5266;
    --rose: #c4456b;
    --gold: #b98a2e;
    --card: #fff8f8;
    --line: #e8c3cd;
    color-scheme: light;
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px)
}

@media (prefers-color-scheme:dark) {
    :root:not([data-theme="light"]) {
        --bg: #1b1026;
        --bg2: #2b1636;
        --ink: #f6e9ec;
        --soft: #c9a6b6;
        --rose: #f08ba8;
        --gold: #e9c37a;
        --card: #2a1835;
        --line: #4a2a55;
        color-scheme: dark
    }
}

:root[data-theme="dark"] {
    --bg: #1b1026;
    --bg2: #2b1636;
    --ink: #f6e9ec;
    --soft: #c9a6b6;
    --rose: #f08ba8;
    --gold: #e9c37a;
    --card: #2a1835;
    --line: #4a2a55;
    color-scheme: dark
}

html {
    scroll-padding-top: env(safe-area-inset-top, 0px);
    scroll-behavior: smooth
}

*,
*::before,
*::after {
    box-sizing: inherit
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%
}

body {
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent
}

body {
    margin: 0;
    background: radial-gradient(120% 80% at 50% 0%, var(--bg2), var(--bg));
    color: var(--ink);
    font: 400 1.05rem/1.7 "Nunito Sans", system-ui, sans-serif;
    min-height: 100vh;
    min-height: 100dvh
}

h1,
h2,
.serif {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-weight: 500;
    overflow-wrap: break-word
}

canvas#petals {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0
}

main,
#cover,
footer {
    position: relative;
    z-index: 1
}

#cover {
    min-height: calc(100vh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    min-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    transition: opacity .9s, transform .9s
}

#cover.gone {
    opacity: 0;
    transform: scale(1.06);
    pointer-events: none
}

#cover h1 {
    font-size: clamp(2.4rem, 9vw, 4.5rem);
    line-height: 1.1;
    margin: 0 0 .5rem;
    font-style: italic
}

#cover p {
    color: var(--soft);
    margin: 0 0 2.2rem
}

.seal {
    width: 112px;
    height: 112px;
    border-radius: 50%;
    border: 0;
    cursor: pointer;
    background: radial-gradient(circle at 35% 30%, #e0607f, #8c1f45 70%);
    color: #fff;
    font: 600 1.15rem "Cormorant Garamond", serif;
    box-shadow: 0 10px 30px rgba(140, 31, 69, .45), inset 0 -6px 12px rgba(0, 0, 0, .25);
    transition: transform .25s
}

.seal:hover {
    transform: scale(1.06) rotate(-4deg)
}

.seal:active {
    transform: scale(.94)
}

.seal:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 3px
}

.wrap {
    max-width: 640px;
    margin: 0 auto;
    padding: 0 1.4rem
}

section {
    padding: 4.5rem 0 2rem
}

h2 {
    font-size: clamp(1.9rem, 6vw, 2.6rem);
    margin: 0 0 1.2rem;
    text-align: center
}

.letter {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 6px 6px 18px 18px;
    padding: 2.2rem 1.8rem;
    box-shadow: 0 18px 40px -22px rgba(120, 30, 70, .45);
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: 1.4rem;
    line-height: 1.75
}

.letter p {
    margin: 0 0 1.1rem;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 1s, transform 1s
}

.letter p.on {
    opacity: 1;
    transform: none
}

.letter p:last-child {
    margin: 1.6rem 0 0;
    text-align: right;
    font-style: italic;
    color: var(--rose);
    font-size: 1.7rem
}

.gallery {
    display: flex;
    gap: 1.4rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 1.2rem 1.4rem 2rem;
    margin: 0 -1.4rem;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none
}

.gallery::-webkit-scrollbar {
    display: none
}

.gallery figure {
    flex: 0 0 78%;
    max-width: 300px;
    margin: 0;
    scroll-snap-align: center;
    background: #fffdfb;
    padding: .7rem .7rem 2.4rem;
    border-radius: 3px;
    box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .45);
    transform: rotate(var(--r))
}

.gallery img {
    display: block;
    width: 100%;
    aspect-ratio: 4/5;
    object-fit: cover;
    border-radius: 2px
}

.empty {
    border: 2px dashed var(--line);
    border-radius: 14px;
    padding: 2.4rem 1.2rem;
    text-align: center;
    color: var(--soft)
}

.player {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: .7rem 1.2rem .7rem .7rem;
    max-width: 420px;
    margin: 0 auto 1.6rem
}

.player button {
    flex: none;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 0;
    background: var(--rose);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer
}

.player b {
    display: block;
    font-family: "Cormorant Garamond", serif;
    font-size: 1.25rem;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.player small {
    color: var(--soft);
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.songs {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: .6rem
}

.songs a {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .8rem 1.1rem;
    border-radius: 12px;
    background: var(--card);
    border: 1px solid var(--line);
    color: var(--ink);
    text-decoration: none
}

.songs a:hover {
    border-color: var(--rose)
}

.songs span {
    color: var(--soft)
}

.days {
    text-align: center;
    margin-top: 3rem
}

.days .n {
    font: italic 500 clamp(3.2rem, 16vw, 6rem)/1 "Cormorant Garamond", serif;
    color: var(--rose)
}

footer {
    text-align: center;
    padding: 3rem 1rem 2.5rem;
    color: var(--soft);
    font-size: .9rem
}

footer button {
    background: none;
    border: 0;
    color: var(--soft);
    text-decoration: underline;
    cursor: pointer;
    font: inherit;
    padding: .8rem 1rem
}

dialog {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--card);
    color: var(--ink);
    width: min(520px, 92vw);
    padding: 1.4rem
}

dialog::backdrop {
    background: rgba(20, 8, 28, .6)
}

dialog label {
    display: block;
    margin: .9rem 0 .3rem;
    font-weight: 600
}

dialog input[type=text],
dialog input[type=date],
dialog textarea {
    width: 100%;
    padding: .6rem .8rem;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--bg);
    color: var(--ink);
    font: inherit
}

dialog textarea {
    min-height: 160px
}

dialog .row {
    display: flex;
    gap: .6rem;
    justify-content: flex-end;
    margin-top: 1.2rem
}

dialog .row button {
    padding: .6rem 1.2rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: none;
    color: var(--ink);
    cursor: pointer;
    font: inherit
}

dialog .row .ok {
    background: var(--rose);
    border-color: var(--rose);
    color: #fff
}

.hint {
    font-size: .88rem;
    color: var(--soft);
    margin: .3rem 0 0
}

.add {
    min-height: 48px;
    padding: .75rem 1.6rem;
    border-radius: 999px;
    border: 0;
    background: var(--rose);
    color: #fff;
    font: 600 1rem "Nunito Sans", sans-serif;
    cursor: pointer
}

.gallery figure {
    position: relative
}

.del {
    position: absolute;
    top: .4rem;
    right: .4rem;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 0;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer
}

dialog {
    max-height: 88vh;
    max-height: 88dvh;
    overflow-y: auto
}

@media (max-width:420px) {
    .wrap {
        padding: 0 1.1rem
    }

    section {
        padding: 3.2rem 0 1.2rem
    }

    .letter {
        padding: 1.5rem 1.2rem;
        font-size: 1.28rem
    }

    .gallery {
        margin: 0 -1.1rem;
        padding: 1rem 1.1rem 1.6rem
    }

    .gallery figure {
        flex-basis: 84%
    }

    .seal {
        width: 104px;
        height: 104px
    }

    .player {
        gap: .8rem
    }
}

@media (max-height:480px) {
    #cover {
        padding: 1rem
    }

    .seal {
        width: 84px;
        height: 84px
    }

    #cover p {
        margin-bottom: 1.2rem
    }
}

@media (prefers-reduced-motion:reduce) {
    * {
        transition-duration: .01s !important;
        scroll-behavior: auto !important
    }
}