:root {
    --vh: 1vh;

    --bg-dark: #2A1F1B;
    --bg-envelope: #352A25;
    --bg-envelope-light: #3D322C;
    --gold: #C2A26A;
    --gold-light: #D2B48C;
    --gold-gradient: linear-gradient(135deg, #C2A26A 0%, #D2B48C 50%, #C2A26A 100%);
    --paper: #F4EFE8;
    --paper-shadow: #E8E0D5;
    --text-dark: #2E2A28;
    --text-muted: #7A6A60;
    --text-label: #8A7A6F;
    --overlay: rgba(42, 31, 27, 0.92);

    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-body: 'Lora', Georgia, serif;
    --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);

    --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    height: 100dvh;
    height: calc(var(--vh, 1vh) * 100);
}

body {
    height: 100%;
    height: 100dvh;
    height: calc(var(--vh, 1vh) * 100);
    overflow: hidden;
    background: var(--bg-dark);
    font-family: var(--font-ui);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.envelope-container {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: max(16px, var(--safe-left));
    padding-top: max(20px, var(--safe-top));
    padding-bottom: max(20px, var(--safe-bottom));
    z-index: 100;
    transition: opacity 0.5s var(--ease-out), visibility 0.5s;
}

.envelope-container.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.envelope {
    position: relative;
    width: min(320px, 85vw);
    height: min(220px, 55vw);
    -webkit-perspective: 1000px;
    perspective: 1000px;
    cursor: pointer;
}

.envelope-back {
    position: absolute;
    inset: 0;
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E"),
        linear-gradient(180deg, var(--bg-envelope-light) 0%, var(--bg-envelope) 100%);
    border: 1px solid rgba(194, 162, 106, 0.25);
    border-radius: 4px;
}

.envelope-back::before {
    content: '';
    position: absolute;
    inset: 6px;
    border: 1px solid rgba(194, 162, 106, 0.3);
    border-radius: 2px;
    pointer-events: none;
}

.envelope-front {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65%;
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E"),
        linear-gradient(180deg, var(--bg-envelope-light) 0%, var(--bg-envelope) 100%);
    border: 1px solid rgba(194, 162, 106, 0.25);
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow:
        inset 0 2px 8px rgba(0, 0, 0, 0.15),
        inset 0 -1px 4px rgba(255, 255, 255, 0.05);
    z-index: 3;
}

.envelope-seal-wax {
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    width: 68px;
    height: 68px;
    z-index: 10;
    filter: drop-shadow(0 4px 8px rgba(42, 31, 27, 0.6));
}

.envelope-seal-wax::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: radial-gradient(
        ellipse at 35% 25%,
        #D4B896 0%,
        #C2A26A 30%,
        #B8956A 60%,
        #A8894F 100%
    );
    box-shadow:
        0 6px 20px rgba(42, 31, 27, 0.7),
        0 2px 6px rgba(42, 31, 27, 0.5),
        inset 0 -4px 10px rgba(0, 0, 0, 0.35),
        inset 0 4px 8px rgba(255, 255, 255, 0.15);
}

.seal-outer-ring {
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    border: 1.5px solid rgba(139, 109, 66, 0.5);
    box-shadow:
        inset 0 1px 2px rgba(255, 255, 255, 0.2),
        inset 0 -1px 3px rgba(0, 0, 0, 0.25);
}

.envelope-seal-wax .seal-inner {
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    background: radial-gradient(
        ellipse at 30% 25%,
        #DBBF96 0%,
        #CBA872 35%,
        #B8956A 70%,
        #A88550 100%
    );
    box-shadow:
        inset 0 3px 6px rgba(255, 255, 255, 0.3),
        inset 0 -4px 8px rgba(0, 0, 0, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.seal-monogram {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: #5C4A35;
    letter-spacing: 0.12em;
    text-shadow:
        0 1px 1px rgba(255, 255, 255, 0.4),
        0 -1px 1px rgba(0, 0, 0, 0.2);
}

.seal-monogram-logo {
    width: 28px;
    height: auto;
    opacity: 0.85;
    filter: brightness(0) sepia(1) saturate(200%) hue-rotate(350deg) brightness(0.4);
}

.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E"),
        linear-gradient(180deg, var(--bg-envelope-light) 0%, var(--bg-envelope) 100%);
    border: 1px solid rgba(194, 162, 106, 0.25);
    -webkit-clip-path: polygon(0 0, 50% 100%, 100% 0);
    clip-path: polygon(0 0, 50% 100%, 100% 0);
    -webkit-transform-origin: top center;
    transform-origin: top center;
    -webkit-transform: rotateX(0deg);
    transform: rotateX(0deg);
    -webkit-transition: -webkit-transform 0.6s var(--ease-out);
    transition: transform 0.6s var(--ease-out);
    z-index: 4;
    will-change: transform;
}

.envelope-flap.open {
    -webkit-transform: rotateX(180deg);
    transform: rotateX(180deg);
}

.envelope-lining {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background-image:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 10px,
            rgba(194, 162, 106, 0.03) 10px,
            rgba(194, 162, 106, 0.03) 20px
        ),
        linear-gradient(180deg, #4A3C35 0%, #3D322C 100%);
    border-radius: 4px 4px 0 0;
    z-index: 1;
}

.envelope-letter {
    position: absolute;
    top: 10%;
    left: 8%;
    right: 8%;
    height: 80%;
    background: var(--paper);
    border-radius: 2px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-transform: translateY(0);
    transform: translateY(0);
    -webkit-transition: -webkit-transform 0.8s var(--ease-out) 0.4s;
    transition: transform 0.8s var(--ease-out) 0.4s;
    z-index: 2;
    will-change: transform;
}

.envelope-letter.rise {
    -webkit-transform: translateY(-120%);
    transform: translateY(-120%);
    z-index: 15;
}

.letter-preview {
    text-align: center;
}

.letter-preview-text {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 600;
    font-style: italic;
    color: var(--gold);
    letter-spacing: 0.02em;
}

.cta-open {
    margin-top: 40px;
    padding: 16px 32px;
    background: transparent;
    border: 1px solid var(--gold);
    border-radius: 4px;
    color: var(--gold);
    font-family: var(--font-ui);
    font-size: clamp(0.85rem, 2.5vw, 0.95rem);
    font-weight: 500;
    letter-spacing: 0.08em;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    -webkit-transition: all 0.3s var(--ease-out);
    transition: all 0.3s var(--ease-out);
}

.cta-open:hover,
.cta-open:focus {
    background: rgba(194, 162, 106, 0.1);
    outline: none;
}

.cta-icon {
    -webkit-animation: bounce 2s infinite;
    animation: bounce 2s infinite;
}

@-webkit-keyframes bounce {
    0%, 20%, 50%, 80%, 100% { -webkit-transform: translateY(0); }
    40% { -webkit-transform: translateY(5px); }
    60% { -webkit-transform: translateY(3px); }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(5px); }
    60% { transform: translateY(3px); }
}

.letter-container {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(12px, var(--safe-left));
    padding-top: max(12px, var(--safe-top));
    padding-bottom: max(12px, var(--safe-bottom));
    opacity: 0;
    visibility: hidden;
    -webkit-transform: translateY(20px);
    transform: translateY(20px);
    -webkit-transition: opacity 0.6s var(--ease-out), visibility 0.6s, -webkit-transform 0.6s var(--ease-out);
    transition: opacity 0.6s var(--ease-out), visibility 0.6s, transform 0.6s var(--ease-out);
    z-index: 50;
}

.letter-container.visible {
    opacity: 1;
    visibility: visible;
    -webkit-transform: translateY(0);
    transform: translateY(0);
}

.letter {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: calc(var(--vh, 1vh) * 100 - 24px);
    max-height: calc(100dvh - 24px);
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E"),
        linear-gradient(180deg, #F8F4EE 0%, #F4EFE8 50%, #EFE9E0 100%);
    border-radius: 4px;
    box-shadow:
        0 25px 50px -12px rgba(42, 31, 27, 0.6),
        0 0 0 1px rgba(194, 162, 106, 0.15),
        inset 0 1px 3px rgba(255, 255, 255, 0.8),
        inset 0 -2px 6px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.letter::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(194, 162, 106, 0.15);
    border-radius: 2px;
    pointer-events: none;
    z-index: 0;
}

.letter::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.1) 0%,
        transparent 50%,
        rgba(0, 0, 0, 0.02) 100%
    );
    pointer-events: none;
    z-index: 1;
}

.letter-header {
    padding: clamp(10px, 2.5vw, 16px);
    padding-bottom: clamp(8px, 2vw, 12px);
    text-align: center;
    border-bottom: 1px solid rgba(194, 162, 106, 0.2);
    flex-shrink: 0;
}

.letter-logo {
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-img {
    height: clamp(35px, 8vw, 50px);
    width: auto;
    filter: brightness(0) saturate(100%) invert(67%) sepia(20%) saturate(600%) hue-rotate(10deg) brightness(90%);
}

.logo-text {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 5vw, 2rem);
    font-weight: 600;
    color: var(--gold);
    letter-spacing: 0.15em;
}

.logo-subtext {
    font-family: var(--font-ui);
    font-size: clamp(0.6rem, 2vw, 0.75rem);
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.35em;
    text-transform: uppercase;
}

.letter-ornament {
    width: 50px;
    height: 1px;
    background: var(--gold-gradient);
    margin: 8px auto 0;
}

.letter-content {
    position: relative;
    padding: clamp(12px, 3vw, 20px);
    flex: 1;
    min-height: 0;
}

.letter-content::before {
    content: 'IPS';
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%) rotate(-15deg);
    transform: translate(-50%, -50%) rotate(-15deg);
    font-family: var(--font-display);
    font-size: clamp(5rem, 20vw, 8rem);
    font-weight: 700;
    color: rgba(194, 162, 106, 0.03);
    pointer-events: none;
    z-index: 0;
}

.letter-title {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 5vw, 1.9rem);
    font-weight: 600;
    color: var(--text-dark);
    text-align: center;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}

.letter-subtitle {
    font-family: var(--font-display);
    font-size: clamp(1.1rem, 4vw, 1.4rem);
    font-weight: 500;
    font-style: italic;
    color: var(--gold);
    text-align: center;
    letter-spacing: 0.02em;
    margin-bottom: clamp(10px, 2.5vw, 16px);
}

.letter-body {
    margin-bottom: clamp(10px, 2.5vw, 14px);
}

.letter-body p {
    font-family: var(--font-body);
    font-size: clamp(1rem, 3.2vw, 1.1rem);
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-dark);
    margin-bottom: 12px;
    text-align: justify;
}

.letter-body p:last-child {
    margin-bottom: 0;
}

.letter-body strong {
    font-family: var(--font-display);
    font-size: 1.35em;
    color: var(--gold);
    font-weight: 600;
    font-style: italic;
}

.letter-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 10px;
    padding: clamp(8px, 2vw, 12px);
    background: rgba(194, 162, 106, 0.06);
    border: 1px solid rgba(194, 162, 106, 0.15);
    border-radius: 4px;
    margin-bottom: clamp(10px, 2.5vw, 14px);
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.info-item-full {
    grid-column: 1 / -1;
    text-align: center;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px solid rgba(194, 162, 106, 0.15);
}

.info-label {
    font-family: var(--font-ui);
    font-size: clamp(0.6rem, 1.7vw, 0.7rem);
    font-weight: 500;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.info-value {
    font-family: var(--font-ui);
    font-size: clamp(0.8rem, 2.3vw, 0.9rem);
    font-weight: 500;
    color: var(--text-dark);
}

.letter-footer {
    text-align: center;
    margin-bottom: clamp(10px, 2.5vw, 14px);
}

.footer-note {
    font-family: var(--font-body);
    font-size: clamp(1.2rem, 4vw, 1.35rem);
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 10px;
}

.footer-signature {
    font-family: var(--font-display);
    font-size: clamp(1.3rem, 4.5vw, 1.5rem);
    font-style: italic;
    color: var(--text-dark);
    line-height: 1.4;
}

.footer-signature strong {
    font-family: var(--font-display);
    font-size: 1.5em;
    font-weight: 600;
    font-style: italic;
    color: var(--gold);
    letter-spacing: 0.02em;
}

.btn-confirm {
    width: 100%;
    padding: clamp(12px, 2.8vw, 16px);
    background: var(--bg-dark);
    border: 1.5px solid var(--gold);
    border-radius: 4px;
    font-family: var(--font-ui);
    font-size: clamp(1rem, 2.8vw, 1.1rem);
    font-weight: 600;
    color: var(--gold);
    letter-spacing: 0.08em;
    cursor: pointer;
    -webkit-transition: all 0.3s var(--ease-out);
    transition: all 0.3s var(--ease-out);
    box-shadow: 0 4px 15px rgba(42, 31, 27, 0.2);
}

.btn-confirm:hover,
.btn-confirm:focus {
    background: var(--gold);
    color: var(--bg-dark);
    -webkit-transform: translateY(-2px);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(194, 162, 106, 0.3);
    outline: none;
}

.btn-confirm:active {
    -webkit-transform: translateY(0);
    transform: translateY(0);
}

.letter-seal {
    position: absolute;
    bottom: 80px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: var(--gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(194, 162, 106, 0.25);
    opacity: 0.12;
    pointer-events: none;
}

.seal-inner {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--bg-dark);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(16px, var(--safe-left));
    padding-top: max(16px, var(--safe-top));
    padding-bottom: max(16px, var(--safe-bottom));
    opacity: 0;
    visibility: hidden;
    -webkit-transition: opacity 0.3s var(--ease-out), visibility 0.3s;
    transition: opacity 0.3s var(--ease-out), visibility 0.3s;
    z-index: 200;
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal {
    width: 100%;
    max-width: 380px;
    max-height: calc(var(--vh, 1vh) * 100 - 32px);
    max-height: calc(100dvh - 32px);
    background: var(--paper);
    border-radius: 8px;
    box-shadow: 0 25px 50px -12px rgba(42, 31, 27, 0.6);
    -webkit-transform: scale(0.95) translateY(20px);
    transform: scale(0.95) translateY(20px);
    -webkit-transition: -webkit-transform 0.3s var(--ease-out-back);
    transition: transform 0.3s var(--ease-out-back);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-overlay.visible .modal {
    -webkit-transform: scale(1) translateY(0);
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid rgba(194, 162, 106, 0.2);
}

.modal-header h3 {
    font-family: var(--font-display);
    font-size: clamp(1.1rem, 3.5vw, 1.3rem);
    font-weight: 600;
    color: var(--text-dark);
    letter-spacing: 0.02em;
}

.modal-close {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-transition: all 0.2s var(--ease-out);
    transition: all 0.2s var(--ease-out);
}

.modal-close:hover,
.modal-close:focus {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-dark);
    outline: none;
}

.modal-body {
    padding: 20px;
}

.input-label {
    display: block;
    font-family: var(--font-ui);
    font-size: clamp(0.8rem, 2.5vw, 0.875rem);
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.input-field {
    width: 100%;
    padding: 14px 16px;
    background: #FDFCFA;
    border: 2px solid rgba(194, 162, 106, 0.3);
    border-radius: 4px;
    font-family: var(--font-ui);
    color: var(--text-dark);
    -webkit-transition: border-color 0.2s var(--ease-out);
    transition: border-color 0.2s var(--ease-out);
}

.input-field:focus {
    outline: none;
    border-color: var(--gold);
}

.input-field::placeholder {
    color: #999;
}

.input-hint {
    font-size: clamp(0.7rem, 2vw, 0.75rem);
    color: var(--text-muted);
    margin-top: 8px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 20px;
    padding-top: 0;
}

.btn-cancel,
.btn-submit {
    flex: 1;
    padding: 14px;
    border-radius: 4px;
    font-family: var(--font-ui);
    font-size: clamp(0.85rem, 2.5vw, 0.9rem);
    font-weight: 600;
    letter-spacing: 0.05em;
    cursor: pointer;
    -webkit-transition: all 0.2s var(--ease-out);
    transition: all 0.2s var(--ease-out);
}

.btn-cancel {
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: var(--text-muted);
}

.btn-cancel:hover,
.btn-cancel:focus {
    background: rgba(0, 0, 0, 0.05);
    outline: none;
}

.btn-submit {
    background: var(--gold);
    border: none;
    color: var(--bg-dark);
}

.btn-submit:hover,
.btn-submit:focus {
    background: var(--gold-light);
    box-shadow: 0 4px 15px rgba(194, 162, 106, 0.35);
    outline: none;
}

.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.toast {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--overlay);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    -webkit-transition: opacity 0.4s var(--ease-out), visibility 0.4s;
    transition: opacity 0.4s var(--ease-out), visibility 0.4s;
    z-index: 300;
}

.toast.visible {
    opacity: 1;
    visibility: visible;
    cursor: pointer;
}

.toast-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 48px;
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E"),
        linear-gradient(180deg, #F8F4EE 0%, #F4EFE8 50%, #EFE9E0 100%);
    border-radius: 8px;
    border: 1px solid rgba(194, 162, 106, 0.2);
    box-shadow:
        0 25px 60px rgba(42, 31, 27, 0.5),
        inset 0 1px 2px rgba(255, 255, 255, 0.8);
    max-width: 340px;
    -webkit-transform: scale(0.9) translateY(20px);
    transform: scale(0.9) translateY(20px);
    -webkit-transition: -webkit-transform 0.5s var(--ease-out-back);
    transition: transform 0.5s var(--ease-out-back);
}

.toast.visible .toast-card {
    -webkit-transform: scale(1) translateY(0);
    transform: scale(1) translateY(0);
}

.toast-signature {
    width: 180px;
    height: 75px;
    margin-bottom: 24px;
    position: relative;
}

.toast-signature svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.signature-icon {
    fill: var(--gold);
}

.toast-signature {
    -webkit-clip-path: inset(0 100% 0 0);
    clip-path: inset(0 100% 0 0);
}

.toast.visible .toast-signature {
    -webkit-animation: revealWrite 2.5s cubic-bezier(0.4, 0, 0.2, 1) 0.2s forwards;
    animation: revealWrite 2.5s cubic-bezier(0.4, 0, 0.2, 1) 0.2s forwards;
}

@-webkit-keyframes revealWrite {
    to { -webkit-clip-path: inset(0 0 0 0); }
}

@keyframes revealWrite {
    to { clip-path: inset(0 0 0 0); }
}

@-webkit-keyframes expandLine {
    to { -webkit-transform: scaleX(1); }
}

@keyframes expandLine {
    to { transform: scaleX(1); }
}

.toast-title {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
    letter-spacing: 0.02em;
    opacity: 0;
    -webkit-transform: translateY(10px);
    transform: translateY(10px);
}

.toast.visible .toast-title {
    -webkit-animation: fadeInUp 0.6s ease-out 2.5s forwards;
    animation: fadeInUp 0.6s ease-out 2.5s forwards;
}

.toast.success .toast-title {
    color: var(--gold);
}

.toast.error .toast-title {
    color: #a34444;
}

.toast-message {
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 20px;
    opacity: 0;
    -webkit-transform: translateY(10px);
    transform: translateY(10px);
}

.toast.visible .toast-message {
    -webkit-animation: fadeInUp 0.6s ease-out 2.8s forwards;
    animation: fadeInUp 0.6s ease-out 2.8s forwards;
}

.toast-ornament {
    width: 60px;
    height: 1px;
    background: var(--gold-gradient);
    opacity: 0;
}

.toast.visible .toast-ornament {
    -webkit-animation: fadeIn 0.5s ease-out 3.1s forwards;
    animation: fadeIn 0.5s ease-out 3.1s forwards;
}

@-webkit-keyframes fadeInUp {
    to {
        opacity: 1;
        -webkit-transform: translateY(0);
    }
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@-webkit-keyframes fadeIn {
    to { opacity: 1; }
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.toast.error .toast-signature {
    display: none;
}

.toast.error .toast-icon {
    display: flex;
}

.toast.success .toast-icon {
    display: none;
}

.toast-icon {
    display: none;
    position: relative;
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
}

.toast.error .toast-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(145deg, #c45c5c 0%, #a34444 100%);
    border-radius: 50%;
    box-shadow:
        0 4px 15px rgba(164, 68, 68, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.2),
        inset 0 -3px 6px rgba(0, 0, 0, 0.2);
}

.toast.error .toast-icon::after {
    content: '!';
    position: absolute;
    top: 50%;
    left: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 600;
    color: #fff;
}

.toast.error .toast-title,
.toast.error .toast-message {
    -webkit-animation-delay: 0.3s;
    animation-delay: 0.3s;
}

.toast.error .toast-ornament {
    -webkit-animation-delay: 0.5s;
    animation-delay: 0.5s;
}

.confirmation-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    -webkit-transition: opacity 0.8s ease, visibility 0.8s;
    transition: opacity 0.8s ease, visibility 0.8s;
}

.confirmation-screen.visible {
    opacity: 1;
    visibility: visible;
}

.confirmation-content {
    text-align: center;
    padding: 40px 30px;
    max-width: 400px;
}

.confirmation-seal {
    margin-bottom: 30px;
    opacity: 0;
    -webkit-transform: scale(0.5) rotate(-20deg);
    transform: scale(0.5) rotate(-20deg);
}

.confirmation-screen.visible .confirmation-seal {
    -webkit-animation: stampIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s forwards;
    animation: stampIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s forwards;
}

@-webkit-keyframes stampIn {
    0% {
        opacity: 0;
        -webkit-transform: scale(1.5) rotate(-20deg);
    }
    60% {
        opacity: 1;
        -webkit-transform: scale(0.9) rotate(5deg);
    }
    100% {
        opacity: 1;
        -webkit-transform: scale(1) rotate(0deg);
    }
}

@keyframes stampIn {
    0% {
        opacity: 0;
        transform: scale(1.5) rotate(-20deg);
    }
    60% {
        opacity: 1;
        transform: scale(0.9) rotate(5deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

.seal-circle {
    width: 100px;
    height: 100px;
    margin: 0 auto 15px;
    background: linear-gradient(145deg, var(--gold-light) 0%, var(--gold) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 8px 30px rgba(194, 162, 106, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.3),
        inset 0 -3px 6px rgba(0, 0, 0, 0.2);
}

.seal-logo {
    width: 60px;
    height: auto;
    object-fit: contain;
}

.seal-text {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gold);
    letter-spacing: 0.3em;
    text-transform: uppercase;
}

.confirmation-title {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--paper);
    margin-bottom: 10px;
    opacity: 0;
    -webkit-transform: translateY(20px);
    transform: translateY(20px);
}

.confirmation-screen.visible .confirmation-title {
    -webkit-animation: fadeInUp 0.6s ease-out 0.8s forwards;
    animation: fadeInUp 0.6s ease-out 0.8s forwards;
}

.confirmation-subtitle {
    font-family: var(--font-body);
    font-size: 1.1rem;
    color: var(--gold-light);
    margin-bottom: 8px;
    opacity: 0;
    -webkit-transform: translateY(20px);
    transform: translateY(20px);
}

.confirmation-screen.visible .confirmation-subtitle {
    -webkit-animation: fadeInUp 0.6s ease-out 1s forwards;
    animation: fadeInUp 0.6s ease-out 1s forwards;
}

.confirmation-guest {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-style: italic;
    color: var(--paper);
    margin-bottom: 30px;
    opacity: 0;
    -webkit-transform: translateY(20px);
    transform: translateY(20px);
}

.confirmation-screen.visible .confirmation-guest {
    -webkit-animation: fadeInUp 0.6s ease-out 1.2s forwards;
    animation: fadeInUp 0.6s ease-out 1.2s forwards;
}

.confirmation-details {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
    opacity: 0;
    -webkit-transform: translateY(20px);
    transform: translateY(20px);
}

.confirmation-screen.visible .confirmation-details {
    -webkit-animation: fadeInUp 0.6s ease-out 1.4s forwards;
    animation: fadeInUp 0.6s ease-out 1.4s forwards;
}

.detail-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.detail-icon {
    color: var(--gold);
    display: flex;
    align-items: center;
}

.detail-text {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--paper-shadow);
}

.confirmation-ornament {
    width: 80px;
    height: 1px;
    background: var(--gold-gradient);
    margin: 0 auto 20px;
    opacity: 0;
}

.confirmation-screen.visible .confirmation-ornament {
    -webkit-animation: fadeIn 0.5s ease-out 1.6s forwards;
    animation: fadeIn 0.5s ease-out 1.6s forwards;
}

.confirmation-footer {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-style: italic;
    color: var(--gold);
    opacity: 0;
}

.confirmation-screen.visible .confirmation-footer {
    -webkit-animation: fadeIn 0.5s ease-out 1.8s forwards;
    animation: fadeIn 0.5s ease-out 1.8s forwards;
}

.letter-container.closing {
    -webkit-animation: letterClose 0.8s ease-in forwards;
    animation: letterClose 0.8s ease-in forwards;
}

@-webkit-keyframes letterClose {
    0% {
        opacity: 1;
        -webkit-transform: scale(1) rotateX(0);
    }
    100% {
        opacity: 0;
        -webkit-transform: scale(0.8) rotateX(20deg);
    }
}

@keyframes letterClose {
    0% {
        opacity: 1;
        transform: scale(1) rotateX(0);
    }
    100% {
        opacity: 0;
        transform: scale(0.8) rotateX(20deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        -webkit-animation-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        -webkit-animation-iteration-count: 1 !important;
        animation-iteration-count: 1 !important;
        -webkit-transition-duration: 0.1s !important;
        transition-duration: 0.1s !important;
    }
}

@media (max-height: 700px) {
    .letter-header {
        padding: 8px 10px;
        padding-bottom: 6px;
    }

    .logo-text {
        font-size: 1.2rem;
    }

    .letter-ornament {
        margin: 5px auto 0;
    }

    .letter-content {
        padding: 10px 12px;
    }

    .letter-title {
        font-size: 1rem;
        margin-bottom: 2px;
    }

    .letter-subtitle {
        font-size: 0.8rem;
        margin-bottom: 8px;
    }

    .letter-body {
        margin-bottom: 8px;
    }

    .letter-body p {
        font-size: 0.7rem;
        line-height: 1.4;
        margin-bottom: 5px;
    }

    .letter-info {
        padding: 6px 8px;
        gap: 4px 8px;
        margin-bottom: 8px;
    }

    .info-label {
        font-size: 0.5rem;
    }

    .info-value {
        font-size: 0.65rem;
    }

    .letter-footer {
        margin-bottom: 8px;
    }

    .footer-note {
        font-size: 0.6rem;
        margin-bottom: 4px;
    }

    .footer-signature {
        font-size: 0.75rem;
        line-height: 1.3;
    }

    .footer-signature strong {
        font-size: 0.85rem;
    }

    .btn-confirm {
        padding: 8px;
        font-size: 0.7rem;
    }

    .letter-seal {
        display: none;
    }

    .letter-content::before {
        font-size: 4rem;
    }
}

@media (max-height: 550px) {
    .letter-header {
        padding: 6px 8px;
        padding-bottom: 4px;
    }

    .logo-text {
        font-size: 1rem;
    }

    .logo-subtext {
        font-size: 0.5rem;
    }

    .letter-ornament {
        display: none;
    }

    .letter-content {
        padding: 8px 10px;
    }

    .letter-title {
        font-size: 0.9rem;
    }

    .letter-subtitle {
        font-size: 0.7rem;
        margin-bottom: 6px;
    }

    .letter-body p {
        font-size: 0.65rem;
        line-height: 1.35;
        margin-bottom: 4px;
    }

    .letter-info {
        padding: 5px 6px;
        gap: 3px 6px;
        margin-bottom: 6px;
    }

    .info-label {
        font-size: 0.45rem;
    }

    .info-value {
        font-size: 0.6rem;
    }

    .letter-footer {
        margin-bottom: 6px;
    }

    .footer-note {
        font-size: 0.55rem;
        margin-bottom: 3px;
    }

    .footer-signature {
        font-size: 0.7rem;
    }

    .footer-signature strong {
        font-size: 0.75rem;
    }

    .btn-confirm {
        padding: 6px;
        font-size: 0.65rem;
    }

    .letter-content::before {
        font-size: 3rem;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    .letter {
        max-width: 500px;
        max-height: calc(100dvh - 16px);
    }

    .letter-header {
        padding: 4px 8px;
    }

    .logo-text {
        font-size: 0.9rem;
    }

    .letter-ornament {
        display: none;
    }

    .letter-content {
        padding: 6px 10px;
    }

    .letter-title {
        font-size: 0.85rem;
        margin-bottom: 2px;
    }

    .letter-subtitle {
        font-size: 0.65rem;
        margin-bottom: 5px;
    }

    .letter-body p {
        font-size: 0.55rem;
        line-height: 1.3;
        margin-bottom: 3px;
    }

    .letter-info {
        padding: 4px 6px;
        gap: 2px 6px;
        margin-bottom: 5px;
    }

    .info-label {
        font-size: 0.4rem;
    }

    .info-value {
        font-size: 0.55rem;
    }

    .letter-footer {
        margin-bottom: 5px;
    }

    .footer-note {
        font-size: 0.5rem;
        margin-bottom: 2px;
    }

    .footer-signature {
        font-size: 0.6rem;
        line-height: 1.2;
    }

    .footer-signature strong {
        font-size: 0.65rem;
    }

    .btn-confirm {
        padding: 5px;
        font-size: 0.55rem;
    }

    .letter-seal {
        display: none;
    }

    .letter-content::before {
        font-size: 2.5rem;
    }
}

@media (min-width: 768px) and (min-height: 600px) {
    .envelope {
        width: min(380px, 85vw);
        height: min(260px, 55vw);
    }

    .envelope-seal-wax {
        width: 76px;
        height: 76px;
    }

    .seal-monogram-logo {
        width: 32px;
    }

    .cta-open {
        margin-top: 45px;
        padding: 16px 36px;
        font-size: 0.95rem;
    }

    .letter {
        max-width: 480px;
        max-height: calc(100dvh - 40px);
    }

    .letter-header {
        padding: 14px 20px;
        padding-bottom: 10px;
    }

    .logo-img {
        height: 45px;
    }

    .letter-ornament {
        width: 50px;
        margin: 8px auto 0;
    }

    .letter-content {
        padding: 16px 24px;
    }

    .letter-title {
        font-size: 1.6rem;
        margin-bottom: 4px;
    }

    .letter-subtitle {
        font-size: 1.15rem;
        margin-bottom: 12px;
    }

    .letter-body {
        margin-bottom: 12px;
    }

    .letter-body p {
        font-size: 0.95rem;
        line-height: 1.55;
        margin-bottom: 10px;
    }

    .letter-info {
        padding: 10px 14px;
        gap: 6px 12px;
        margin-bottom: 12px;
    }

    .info-label {
        font-size: 0.65rem;
    }

    .info-value {
        font-size: 0.85rem;
    }

    .info-item-full {
        margin-top: 4px;
        padding-top: 6px;
    }

    .letter-footer {
        margin-bottom: 12px;
    }

    .footer-signature {
        font-size: 1.2rem;
    }

    .btn-confirm {
        padding: 12px;
        font-size: 0.95rem;
    }

    .letter-seal {
        width: 45px;
        height: 45px;
        bottom: 70px;
        right: 20px;
    }

    .letter-content::before {
        font-size: 7rem;
    }

    .modal {
        max-width: 400px;
    }

    .modal-header {
        padding: 20px;
    }

    .modal-header h3 {
        font-size: 1.2rem;
    }

    .modal-body {
        padding: 20px;
    }

    .input-field {
        padding: 14px 16px;
        font-size: 0.95rem;
    }

    .modal-footer {
        padding: 20px;
        padding-top: 0;
    }

    .btn-cancel,
    .btn-submit {
        padding: 14px;
        font-size: 0.9rem;
    }

    .confirmation-content {
        padding: 40px 30px;
        max-width: 420px;
    }

    .seal-circle {
        width: 100px;
        height: 100px;
    }

    .seal-logo {
        width: 60px;
    }

    .confirmation-subtitle {
        font-size: 1.1rem;
    }

    .confirmation-guest {
        font-size: 1.3rem;
    }

    .detail-text {
        font-size: 1rem;
    }

    .confirmation-footer {
        font-size: 1.2rem;
    }
}

@media (min-width: 768px) and (min-height: 800px) {
    .letter {
        max-width: 520px;
    }

    .letter-header {
        padding: 18px 24px;
        padding-bottom: 12px;
    }

    .logo-img {
        height: 50px;
    }

    .letter-content {
        padding: 20px 28px;
    }

    .letter-title {
        font-size: 1.8rem;
        margin-bottom: 5px;
    }

    .letter-subtitle {
        font-size: 1.25rem;
        margin-bottom: 14px;
    }

    .letter-body p {
        font-size: 1.05rem;
        line-height: 1.6;
        margin-bottom: 12px;
    }

    .letter-info {
        padding: 12px 16px;
        gap: 8px 14px;
        margin-bottom: 14px;
    }

    .info-label {
        font-size: 0.7rem;
    }

    .info-value {
        font-size: 0.9rem;
    }

    .footer-signature {
        font-size: 1.35rem;
    }

    .btn-confirm {
        padding: 14px;
        font-size: 1rem;
    }
}