:root {
    --red: #b3261e;
    --red-dark: #8c1d17;
    --green: #1e5631;
    --green-dark: #14401f;
    --gold: #d4a017;
    --cream: #fff8ee;
    --white: #ffffff;
    --text: #222222;
    --muted: #555555;
    --radius: 16px;
}

* { box-sizing: border-box; }

html { font-size: 20px; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--green);
    background-image:
        radial-gradient(circle at 20% 10%, rgba(255,255,255,.06) 0 2px, transparent 3px),
        radial-gradient(circle at 70% 40%, rgba(255,255,255,.06) 0 2px, transparent 3px);
    background-size: 60px 60px, 90px 90px;
}

/* ---------- Header ---------- */
.site-header {
    position: relative;
    background: var(--red);
    color: var(--white);
    text-align: center;
    padding: 1.8rem 1rem 1.2rem;
    border-bottom: 6px solid var(--gold);
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

.lights {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 14px;
    background: radial-gradient(circle, var(--gold) 0 5px, transparent 6px) 0 0 / 40px 14px repeat-x,
                radial-gradient(circle, #7fd36b 0 5px, transparent 6px) 20px 0 / 40px 14px repeat-x;
}

.site-title {
    font-family: "Mountains of Christmas", Georgia, serif;
    font-size: 2.3rem;
    line-height: 1.15;
    margin: .4rem 0 .3rem;
    text-shadow: 2px 2px 0 rgba(0,0,0,.25);
}

.event-info {
    margin: .4rem 0 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .4rem 1.4rem;
    font-size: 1rem;
}

/* ---------- Layout ---------- */
.container {
    max-width: 640px;
    margin: 1.5rem auto;
    padding: 0 1rem;
    position: relative;
    z-index: 1;
}
.container-wide { max-width: 900px; }

.card {
    background: var(--cream);
    border-radius: var(--radius);
    padding: 1.4rem 1.3rem;
    margin-bottom: 1.4rem;
    border: 3px solid var(--gold);
    box-shadow: 0 6px 18px rgba(0,0,0,.25);
}

.card-gift { border-color: var(--red); border-width: 4px; }

.card-title {
    margin: 0 0 .8rem;
    font-size: 1.45rem;
    color: var(--red);
}

h3 { font-size: 1.15rem; color: var(--green); margin: 1.2rem 0 .5rem; }

.big-text { font-size: 1.1rem; margin: .4rem 0 1rem; }
.muted { color: var(--muted); }
.hint { font-size: 1rem; color: var(--muted); text-align: center; margin-top: 0; }

.greeting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    color: var(--white);
    margin-bottom: 1rem;
}
.greeting h2 { margin: 0; font-size: 1.6rem; }

.friend-name {
    font-family: "Mountains of Christmas", Georgia, serif;
    font-size: 3rem;
    font-weight: 700;
    color: var(--green);
    text-align: center;
    margin: .2rem 0 .4rem;
    line-height: 1.1;
    word-break: break-word;
}

.gift-list { list-style: none; padding: 0; margin: 0; }
.gift-list li {
    font-size: 1.15rem;
    background: var(--white);
    border-left: 6px solid var(--red);
    border-radius: 10px;
    padding: .7rem .9rem;
    margin-bottom: .8rem;
}
.gift-text { margin: 0 0 .5rem; overflow-wrap: anywhere; }
.gift-image img {
    display: block;
    max-width: 100%;
    max-height: 320px;
    border-radius: 10px;
    margin: .3rem 0 .6rem;
    border: 2px solid #eee;
}
.gift-link { margin-top: .2rem; }

/* ---------- Forms ---------- */
.form .field { margin-bottom: 1.2rem; }

label {
    display: block;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: .4rem;
    color: var(--green-dark);
}

input[type="text"],
input[type="password"],
input[type="date"],
select {
    width: 100%;
    min-height: 56px;
    font-size: var(--input-font, 1rem);
    padding: .5rem .9rem;
    border: 3px solid #8a8a8a;
    border-radius: 12px;
    background: var(--white);
    color: var(--text);
}

input:focus, select:focus, .btn:focus-visible {
    outline: 4px solid var(--gold);
    outline-offset: 2px;
    border-color: var(--green);
}

.pin-input {
    max-width: 200px;
    font-size: calc(var(--input-font, 1rem) * 1.6) !important;
    letter-spacing: .5em;
    text-align: center;
}

.error {
    color: var(--red-dark);
    font-weight: 700;
    font-size: 1.05rem;
    margin: .4rem 0 0;
}

.optional { font-weight: 400; color: var(--muted); font-size: .9rem; }

/* Link y foto opcionales: botones pequeños que despliegan el campo */
.idea { min-width: 0; }
.extras { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .45rem; }
.extra { min-width: 0; }
.extra[open] { flex: 1 1 100%; }
.extra summary {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    list-style: none;
    cursor: pointer;
    font-size: .8rem;
    font-weight: 600;
    color: var(--green-dark);
    background: #eef5ef;
    border: 1px solid #b9d3bf;
    border-radius: 999px;
    padding: .25rem .75rem;
    user-select: none;
}
.extra summary::-webkit-details-marker { display: none; }
.extra summary::after { content: "+"; font-weight: 700; }
.extra[open] summary::after { content: "−"; }
.extra-body { margin-top: .45rem; padding-left: .2rem; }
.extra-body input[type="text"] { min-height: 46px; font-size: calc(var(--input-font, 1rem) * .9); }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
.file-picker {
    display: flex;
    align-items: center;
    gap: .6rem;
    min-width: 0;
    margin: 0;
    font-weight: 400;
    cursor: pointer;
}
.file-picker-btn {
    flex: none;
    font-size: .85rem;
    font-weight: 700;
    padding: .45rem .9rem;
    border: 2px solid var(--green);
    border-radius: 10px;
    background: var(--white);
    color: var(--green-dark);
}
.file-picker:focus-within .file-picker-btn { outline: 3px solid var(--gold); outline-offset: 2px; }
.file-picker-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .8rem;
    color: var(--muted);
}

.current-image { display: flex; align-items: center; gap: .8rem; margin-bottom: .5rem; flex-wrap: wrap; }
.current-image img { width: 80px; height: 80px; object-fit: cover; border-radius: 8px; border: 2px solid #ddd; }
.checkbox { display: flex; align-items: center; gap: .4rem; font-weight: 400; font-size: .85rem; margin: 0; cursor: pointer; color: var(--text); }
.checkbox input { width: 20px; height: 20px; }

.form-grid { display: grid; gap: 0 1rem; }
@media (min-width: 640px) { .form-grid { grid-template-columns: repeat(3, 1fr); align-items: end; } }

.form-inline { display: grid; gap: 0 1rem; }
@media (min-width: 640px) {
    .form-inline { grid-template-columns: 1fr 200px auto; align-items: start; }
    .form-inline .btn { margin-top: 2.05rem; }
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    width: 100%;
    min-height: 60px;
    padding: .6rem 1.4rem;
    font-size: 1.25rem;
    font-weight: 700;
    border: 3px solid transparent;
    border-radius: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: transform .05s, background-color .15s;
}
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--red); color: var(--white); border-color: var(--red-dark); }
.btn-primary:hover:not(:disabled) { background: var(--red-dark); }

.btn-secondary { background: var(--green); color: var(--white); border-color: var(--green-dark); }
.btn-secondary:hover { background: var(--green-dark); }

.btn-outline { background: var(--white); color: var(--green-dark); border-color: var(--green); }
.btn-outline:hover { background: #eef5ef; }

.btn-danger { background: var(--white); color: var(--red-dark); border-color: var(--red); }
.btn-danger:hover { background: #fdeceb; }

.btn-small { width: auto; min-height: 48px; font-size: 1rem; padding: .4rem 1rem; }

.button-row { display: flex; flex-wrap: wrap; gap: .8rem; }
.button-row > *, .button-row form { flex: 1 1 200px; }
.button-row form .btn { width: 100%; }

/* ---------- Alerts ---------- */
.alert {
    border-radius: 12px;
    padding: 1rem 1.1rem;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.2rem;
}
.alert-success { background: #e3f4e6; color: var(--green-dark); border: 3px solid var(--green); }
.alert-error   { background: #fdeceb; color: var(--red-dark); border: 3px solid var(--red); }
.alert-warning { background: #fff4d6; color: #6b4e00; border: 3px solid var(--gold); }

/* ---------- Admin ---------- */
.share { display: flex; gap: .6rem; }
.share input { flex: 1; min-height: 48px; font-size: 1rem; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 1rem; }
.table th, .table td { padding: .7rem .5rem; text-align: left; border-bottom: 2px solid #e6dcc8; vertical-align: middle; }
.table th { color: var(--green-dark); }
.table code { font-size: 1.1rem; font-weight: 700; }
.table .actions { display: flex; gap: .5rem; justify-content: flex-end; }
.table .actions form { margin: 0; }

.admin-link { text-align: center; }
.admin-link a { color: var(--white); font-size: 1rem; }

/* ---------- Footer ---------- */
.site-footer { text-align: center; color: var(--white); padding: 1rem 0 2rem; font-size: 1rem; }

/* ---------- Snow ---------- */
.snow { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.snow span {
    position: absolute;
    top: -2rem;
    color: rgba(255,255,255,.75);
    font-size: 1.2rem;
    animation: fall linear infinite;
}
.snow span:nth-child(1)  { left: 3%;  animation-duration: 14s; animation-delay: 0s; }
.snow span:nth-child(2)  { left: 10%; animation-duration: 18s; animation-delay: 4s; font-size: .9rem; }
.snow span:nth-child(3)  { left: 18%; animation-duration: 12s; animation-delay: 2s; }
.snow span:nth-child(4)  { left: 26%; animation-duration: 20s; animation-delay: 7s; font-size: 1.5rem; }
.snow span:nth-child(5)  { left: 34%; animation-duration: 16s; animation-delay: 1s; }
.snow span:nth-child(6)  { left: 42%; animation-duration: 13s; animation-delay: 9s; font-size: .8rem; }
.snow span:nth-child(7)  { left: 50%; animation-duration: 19s; animation-delay: 3s; }
.snow span:nth-child(8)  { left: 58%; animation-duration: 15s; animation-delay: 6s; font-size: 1.4rem; }
.snow span:nth-child(9)  { left: 66%; animation-duration: 17s; animation-delay: 0s; }
.snow span:nth-child(10) { left: 74%; animation-duration: 12s; animation-delay: 5s; font-size: .9rem; }
.snow span:nth-child(11) { left: 82%; animation-duration: 21s; animation-delay: 2s; }
.snow span:nth-child(12) { left: 88%; animation-duration: 14s; animation-delay: 8s; font-size: 1.3rem; }
.snow span:nth-child(13) { left: 94%; animation-duration: 18s; animation-delay: 1s; }
.snow span:nth-child(14) { left: 98%; animation-duration: 16s; animation-delay: 10s; font-size: .8rem; }

@keyframes fall {
    to { transform: translateY(110vh) rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .snow { display: none; }
}

@media (max-width: 480px) {
    html { font-size: 19px; }
    .site-title { font-size: 1.9rem; }
    .friend-name { font-size: 2.4rem; }
    .table .actions { flex-direction: column; }
}
