:root {
    --bg: #f6f1ea;
    --card: #ffffff;
    --text: #1f2421;
    --muted: #5f6b64;
    --border: #e3dbd0;
    --primary: #b3261e;
    --primary-hover: #93201a;
    --primary-text: #ffffff;
    --secondary: #eef3ef;
    --secondary-hover: #dfe9e2;
    --secondary-text: #1e5434;
    --danger: #b3261e;
    --success-bg: #e5f2e8;
    --success-text: #1e5434;
    --error-bg: #fbe7e5;
    --error-text: #8c1d17;
    --tag-bg: #f3ece1;
    --radius: 12px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #141816;
        --card: #1d2320;
        --text: #ecefed;
        --muted: #a1aca6;
        --border: #2f3833;
        --primary: #e0574d;
        --primary-hover: #ea736a;
        --primary-text: #1a0d0c;
        --secondary: #26302b;
        --secondary-hover: #2f3b35;
        --secondary-text: #b9e0c6;
        --danger: #f0857c;
        --success-bg: #1f3427;
        --success-text: #b9e0c6;
        --error-bg: #3d1f1d;
        --error-text: #f6bdb7;
        --tag-bg: #2a302c;
        color-scheme: dark;
    }
}

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.page { max-width: 640px; margin: 0 auto; padding: 24px 16px 48px; }

.brand { margin-bottom: 20px; font-weight: 700; }
.brand a { color: var(--text); text-decoration: none; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
}

h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 8px; }
h2 { font-size: 1.15rem; margin: 20px 0 8px; }
.card > h2:first-child { margin-top: 0; }

.eyebrow { margin: 0 0 4px; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.center { text-align: center; }
.empty { color: var(--muted); font-style: italic; }

.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.stack > div { display: flex; flex-direction: column; gap: 4px; }

label { font-weight: 600; }

input[type=text], select {
    width: 100%;
    padding: 10px 12px;
    font: inherit;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
}
input[type=text]:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }

.options { border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; margin: 0; }
.options legend { padding: 0 4px; font-weight: 600; }
.options > div { display: flex; flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 8px; margin: 6px 0; }
.options label { font-weight: 400; }
.options ul { flex-basis: 100%; }

ul:has(> li) { margin: 0; }
.stack ul, .inline-form ul, .options ul { list-style: none; padding: 0; margin: 0; color: var(--error-text); font-size: .9rem; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    font: inherit;
    font-weight: 600;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--secondary); color: var(--secondary-text); }
.btn-secondary:hover { background: var(--secondary-hover); }
.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--error-bg); }
.btn-small { padding: 4px 10px; font-size: .9rem; }
.btn-block { width: 100%; }

.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--muted); }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; }
.flash-success { background: var(--success-bg); color: var(--success-text); }
.flash-error { background: var(--error-bg); color: var(--error-text); }

.link-row { display: flex; gap: 8px; }
.link-row input { font-size: .85rem; color: var(--muted); min-width: 0; }

.qr { margin-top: 6px; }
.qr summary { width: fit-content; color: var(--muted); font-size: .9rem; cursor: pointer; }
/* The code carries its own white background and quiet zone, so it scans in dark mode too. */
.qr img { display: block; width: 240px; max-width: 100%; height: auto; margin-top: 8px; border-radius: 8px; }

.people { list-style: none; padding: 0; margin: 12px 0 0; }
.person { padding: 12px 0; border-top: 1px solid var(--border); }
.person-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.person-actions { margin-left: auto; display: flex; gap: 4px; }
.person-actions form { margin: 0; }

.tag { background: var(--tag-bg); color: var(--muted); border-radius: 999px; padding: 2px 10px; font-size: .85rem; }

.actions { display: flex; gap: 8px; }

.result { margin-top: 16px; padding: 16px; border-radius: 8px; background: var(--success-bg); }
.result p { margin: 0; }
.result-name { font-size: 1.6rem; font-weight: 700; color: var(--success-text); }

.wishes { list-style: none; padding: 0; margin: 8px 0 0; }
.wishes li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.wishes li:last-child { border-bottom: 0; }
.wishes form { margin: 0; }

.inline-form { display: flex; gap: 8px; align-items: flex-end; margin-top: 16px; }
.inline-form > div { flex: 1; display: flex; flex-direction: column; gap: 4px; }

@media (max-width: 480px) {
    .card { padding: 18px; }
    .inline-form { flex-direction: column; align-items: stretch; }
}
