/* ==========================================================================
   Themes. Each theme only sets tokens; everything below uses the tokens.
   To add a theme: copy the christmas block, change the values, and set
   data-theme="yourtheme" on <html> in Pages/Shared/_Layout.cshtml.
   ========================================================================== */

:root[data-theme="christmas"] {
    --bg: #fbf5ea;
    --surface: #fffdf8;
    --surface-2: #f6ecdc;
    --text: #2b2118;
    --muted: #7a6a58;
    --border: #ead9bf;
    --primary: #b3261e;
    --primary-hover: #951c15;
    --primary-ink: #ffffff;
    --accent: #1f6b43;
    --accent-hover: #17573a;
    --accent-ink: #ffffff;
    --gold: #c8a04a;
    --header-bg: #14432b;
    --header-ink: #fdf6e7;
    --ribbon-a: #b3261e;
    --ribbon-b: #fdf6e7;
    --ok-bg: #e5f3ea;
    --ok-ink: #17573a;
    --error-bg: #fbe6e3;
    --error-ink: #951c15;
    --notice-bg: #fff6dc;
    --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 6px 20px rgba(60, 40, 20, .07);
    --snow: rgba(255, 255, 255, .9);
    --font-display: "Georgia", "Iowan Old Style", "Palatino Linotype", serif;
}

@media (prefers-color-scheme: dark) {
    :root[data-theme="christmas"] {
        --bg: #0d1d15;
        --surface: #142a1f;
        --surface-2: #1b3628;
        --text: #f3ebdd;
        --muted: #b3a68f;
        --border: #2a4a39;
        --primary: #e0473c;
        --primary-hover: #f05c51;
        --accent: #49b07a;
        --accent-hover: #5cc48d;
        --accent-ink: #08170f;
        --gold: #e2bf6c;
        --header-bg: #0a1711;
        --ribbon-b: #f3ebdd;
        --ok-bg: #173a27;
        --ok-ink: #9fe0bb;
        --error-bg: #3d1714;
        --error-ink: #ffb4ac;
        --notice-bg: #2d2814;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    }
}

/* ========================================================================== */

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

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

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.3rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }

.container { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.main { flex: 1; padding-top: 28px; padding-bottom: 40px; position: relative; z-index: 1; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- Header -------------------------------------------------------------- */

.site-header { background: var(--header-bg); color: var(--header-ink); position: relative; z-index: 2; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; flex-wrap: wrap; }
.brand { color: var(--header-ink); text-decoration: none; font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.brand:hover { color: var(--header-ink); }
.brand-icon { font-size: 1.6rem; }
.nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.nav a { color: var(--header-ink); text-decoration: none; opacity: .9; }
.nav a:hover { opacity: 1; text-decoration: underline; color: var(--header-ink); }
.nav a.btn { opacity: 1; text-decoration: none; color: var(--primary-ink); }
.nav a.nav-user { color: var(--gold); font-weight: 600; opacity: 1; }
.nav a.nav-user:hover { color: var(--gold); }
.nav form { margin: 0; }
.nav .link-btn { color: var(--header-ink); opacity: .9; }

/* candy-cane ribbon under the header */
.ribbon { height: 8px; background: repeating-linear-gradient(-45deg, var(--ribbon-a) 0 12px, var(--ribbon-b) 12px 24px); }

/* --- Snow ---------------------------------------------------------------- */

.snow {
    position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .55;
    background-image:
        radial-gradient(3px 3px at 20px 30px, var(--snow) 50%, transparent 51%),
        radial-gradient(2px 2px at 120px 80px, var(--snow) 50%, transparent 51%),
        radial-gradient(4px 4px at 200px 160px, var(--snow) 50%, transparent 51%),
        radial-gradient(2px 2px at 280px 40px, var(--snow) 50%, transparent 51%),
        radial-gradient(3px 3px at 60px 200px, var(--snow) 50%, transparent 51%);
    background-size: 300px 240px;
    animation: snowfall 90s linear infinite;
}
:root[data-theme="christmas"] .snow { filter: drop-shadow(0 0 1px rgba(120, 140, 160, .5)); }
/* Ends exactly whole tiles away (300 = 1 × width, 1200 = 5 × height) so the loop restart is invisible.
   Same speed and angle as before: 60px sideways per 240px down, 240px per 18s. */
@keyframes snowfall { from { background-position: 0 0; } to { background-position: 300px 1200px; } }
@media (prefers-reduced-motion: reduce) { .snow { animation: none; } }

/* --- Buttons ------------------------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px; border-radius: 999px; border: 2px solid var(--primary);
    background: var(--primary); color: var(--primary-ink);
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-ink); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .link-btn:focus-visible {
    outline: 3px solid var(--gold); outline-offset: 2px;
}
.btn-small { padding: 6px 14px; font-size: .9rem; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-danger { background: var(--error-ink); border-color: var(--error-ink); color: var(--surface); }
.btn-danger-text { color: var(--error-ink); }
.link-btn { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: underline; color: inherit; }

/* Two-step "Are you sure?" without browser popups (some browsers block confirm()).
   <details class="confirm"><summary>Delete</summary><div class="confirm-box">question, yes form, cancel</div></details> */
.confirm { display: inline-block; }
.confirm > summary { list-style: none; }
.confirm > summary::-webkit-details-marker { display: none; }
.confirm[open] > summary { display: none; }
.confirm-box { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.confirm-box p { margin: 0; font-weight: 600; }
.confirm-box form { margin: 0; }

/* --- Cards & layout ------------------------------------------------------ */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); }
.card.narrow { max-width: 560px; margin: 0 auto; }
.card.empty { text-align: center; padding: 32px 20px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.crumb { margin-bottom: 6px; font-size: .9rem; }
.crumb a { text-decoration: none; }
.description { max-width: 60ch; }
.section-title { margin-top: 36px; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.list-card { text-decoration: none; color: var(--text); transition: transform .12s, box-shadow .12s; border-top: 5px solid var(--accent); }
.list-card:nth-child(3n+2) { border-top-color: var(--primary); }
.list-card:nth-child(3n+3) { border-top-color: var(--gold); }
.list-card:hover { transform: translateY(-2px); color: var(--text); }
.list-card p:last-child { margin-bottom: 0; }

.hero { text-align: center; padding: 48px 0 24px; max-width: 680px; margin: 0 auto; }
.hero .lead { font-size: 1.15rem; color: var(--muted); }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }

/* --- Alerts -------------------------------------------------------------- */

.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 20px; font-weight: 500; }
.alert-ok { background: var(--ok-bg); color: var(--ok-ink); }
.alert-error { background: var(--error-bg); color: var(--error-ink); }
.notice { background: var(--notice-bg); border: 1px dashed var(--gold); border-radius: 12px; padding: 12px 16px; margin-bottom: 20px; }
.notice-compact { display: flex; align-items: flex-start; gap: 8px; padding: 8px 8px 8px 14px; font-size: .9rem; }
.notice-compact > span { flex: 1; padding-top: 4px; }
.notice-close {
    flex-shrink: 0; width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent;
    color: var(--muted); font: inherit; cursor: pointer;
}
.notice-close:hover { background: var(--surface-2); color: var(--text); }

/* --- Items --------------------------------------------------------------- */

.items { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.item { display: flex; flex-direction: column; padding: 0; overflow: hidden; scroll-margin-top: 20px; }
.item:target { outline: 3px solid var(--gold); }
/* Fixed height so tall product photos can't stretch the card. */
.item-image { height: 160px; flex-shrink: 0; background: var(--surface-2); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.item-image img { max-width: 100%; max-height: 100%; object-fit: contain; }
.item-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.item-name { margin: 0; overflow-wrap: anywhere; }
.item-meta { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: .9rem; }
.item-notes { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.item-link { font-weight: 600; text-decoration: none; }
.item.is-taken .item-name { color: var(--muted); }
.item.is-taken .item-image { opacity: .55; }

.badge { flex-shrink: 0; font-size: .75rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.prio-high { background: var(--primary); color: var(--primary-ink); }
.prio-mid { background: var(--accent); color: var(--accent-ink); }
.prio-low { background: var(--surface-2); color: var(--muted); }

.reservations { margin-top: auto; padding-top: 10px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 8px; }
.reservation { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .95rem; }
.reservation.is-bought { color: var(--accent); }
.reservation-actions { display: flex; gap: 6px; }
.reservation-actions form, .item-owner-actions form { margin: 0; }
.reservation.is-group { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.group-members { flex-basis: 100%; }
.group-join { flex-basis: 100%; }
.group-join > summary { list-style: none; display: inline-flex; }
.group-join > summary::-webkit-details-marker { display: none; }
.group-join[open] > summary { display: none; }
.group-join form { margin: 6px 0 0; }
.group-join .inline-form input { font-size: 16px; }
.profiles { padding: 12px 16px; margin-bottom: 16px; }
.profiles > summary { cursor: pointer; font-weight: 600; }
.profile-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-top: 10px; }
.profile { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; }
.profile dt { color: var(--muted); font-size: .85rem; padding-top: 2px; }
.profile dd { margin: 0; overflow-wrap: anywhere; }
.profile .profile-name { grid-column: 1 / -1; color: var(--text); font-weight: 700; font-size: 1rem; }
.household-check { flex-basis: 100%; display: flex; align-items: center; gap: 8px; }
.secret-tag { margin: 0; padding: 6px 10px; border-radius: 10px; background: var(--notice-bg); border: 1px dashed var(--gold); }
.res-note { flex-basis: 100%; font-size: .9rem; }
.res-note > summary { cursor: pointer; color: var(--muted); overflow-wrap: anywhere; }
.res-note form { margin-top: 6px; }
.chat { border-top: 1px dashed var(--border); padding-top: 8px; }
.chat > summary { cursor: pointer; font-weight: 600; font-size: .95rem; padding: 4px 0; }
.chat-messages { list-style: none; padding: 0; margin: 6px 0 8px; display: flex; flex-direction: column; gap: 6px; }
.chat-messages li { background: var(--surface-2); border-radius: 12px 12px 12px 4px; padding: 6px 10px; display: flex; flex-direction: column; max-width: 90%; }
.chat-messages li.is-mine { align-self: flex-end; border-radius: 12px 12px 4px 12px; background: var(--ok-bg); }
.chat-who { font-size: .8rem; font-weight: 600; }
.chat-text { white-space: pre-line; overflow-wrap: anywhere; }
.chat-delete { margin: 0; align-self: flex-end; }
.chat-form input { font-size: 16px; }
.reserve-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.qty { display: flex; align-items: center; gap: 6px; }
.qty input { width: 64px; padding: 5px 8px; }
.item-owner-actions { margin-top: auto; padding-top: 10px; display: flex; gap: 8px; }

.guest-bar { margin-bottom: 20px; }
.guest-bar p:last-child { margin-bottom: 0; }
.guest-bar label { display: block; margin-bottom: 8px; font-weight: 500; }

.leave-form { margin-top: 32px; text-align: center; }

/* Tools above the wishes: reorder, print, Cards / List */
.list-tools { display: flex; justify-content: flex-end; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.list-tools .view-toggle { margin: 0; }
.section-heading { margin: 22px 0 10px; font-size: 1.15rem; display: flex; align-items: center; gap: 10px; }
.section-heading::after { content: ""; flex: 1; border-top: 1px dashed var(--border); }
.items + .section-heading { margin-top: 26px; }
.reorder-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.reorder-head p { margin: 0; }
.reorder-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.reorder-section { font-family: var(--font-display); font-weight: 700; margin-top: 12px; }
.reorder-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px 6px 14px; scroll-margin-top: 80px; }
.reorder-item:target { outline: 3px solid var(--gold); }
.reorder-name { min-width: 0; overflow-wrap: anywhere; }
.reorder-buttons { display: flex; gap: 6px; margin: 0; flex-shrink: 0; }
.reorder-buttons .btn { min-width: 44px; font-size: 1.1rem; }
.reorder-buttons .btn:disabled { opacity: .3; cursor: default; }
.closed-wishes { margin-top: 24px; }
.closed-wishes > summary { cursor: pointer; font-weight: 600; }

/* Cards / List switch */
.view-toggle { display: flex; justify-content: flex-end; gap: 4px; margin-bottom: 12px; }
.view-toggle a { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 600; }
.view-toggle a:hover { color: var(--text); background: var(--surface-2); }
.view-toggle a.is-active { background: var(--surface-2); color: var(--text); border-color: var(--gold); }

/* List layout: one slim row per wish (_ItemRow). Click a row to open details and buttons. */
.items.is-list { grid-template-columns: 1fr; gap: 6px; }
.item-row { padding: 0; overflow: hidden; scroll-margin-top: 20px; }
.item-row:target { outline: 3px solid var(--gold); }
.row-summary {
    display: flex; align-items: center; gap: 12px; padding: 6px 14px 6px 6px;
    cursor: pointer; list-style: none;
}
.row-summary::-webkit-details-marker { display: none; }
.row-summary:hover { background: var(--surface-2); }
.row-summary:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; }
.row-thumb {
    width: 40px; height: 40px; flex-shrink: 0; border-radius: 8px; overflow: hidden;
    background: var(--surface-2); display: flex; align-items: center; justify-content: center;
}
.row-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
/* Names may wrap to two lines before being cut off. */
.row-name {
    font-weight: 600; min-width: 0; overflow: hidden; line-height: 1.3;
    display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow-wrap: anywhere;
}
.row-right { margin-left: auto; display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.row-status { font-size: .85rem; font-weight: 600; color: var(--gold); white-space: nowrap; }
.row-status.is-bought { color: var(--accent); }
.row-qty { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.row-price { min-width: 70px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-chevron { color: var(--muted); transition: transform .15s; }
.item-row[open] .row-chevron { transform: rotate(180deg); }
.item-row.is-taken .row-name { color: var(--muted); }
.item-row.is-taken .row-thumb { opacity: .55; }
.row-details { display: flex; gap: 16px; padding: 12px 16px 16px; border-top: 1px dashed var(--border); }
.row-image { width: 120px; height: 120px; flex-shrink: 0; border-radius: 10px; overflow: hidden; background: var(--surface-2); display: flex; align-items: center; justify-content: center; }
.row-image img { max-width: 100%; max-height: 100%; object-fit: contain; }
.row-details-body { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.row-details-body p { margin: 0; }
.row-details .reservations { margin-top: 4px; }
.row-details .item-owner-actions { margin-top: 0; padding-top: 2px; }
.row-prio-icon { display: none; flex-shrink: 0; font-size: 1rem; line-height: 1; }
@media (max-width: 560px) {
    .row-prio, .row-qty { display: none; }
    .row-prio-icon { display: inline; }
    .row-right { gap: 8px; }
    .row-price { min-width: 0; }
    .row-details { flex-direction: column; }
    .row-image { width: 100%; height: 140px; }
}

/* --- Forms --------------------------------------------------------------- */

.form { display: flex; flex-direction: column; gap: 16px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.form label .small, .form label .muted { font-weight: 400; }
.form-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-actions form { margin: 0; }

input, select, textarea {
    font: inherit; color: var(--text); background: var(--surface);
    border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%;
}
textarea { resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; flex-shrink: 0; accent-color: var(--accent); }

.lookup { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1.5px dashed var(--gold); border-radius: 12px; background: var(--notice-bg); }
.lookup-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.image-preview { width: 120px; height: 120px; border-radius: 10px; overflow: hidden; background: var(--surface-2); display: flex; align-items: center; justify-content: center; margin-top: -6px; }
.image-preview[hidden] { display: none; }
.image-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }

.field-error { color: var(--error-ink); }
.field-error ul { margin: 0; padding-left: 18px; }
.field-error:empty, .validation-summary-valid { display: none; }

fieldset.coowners { border: 1.5px solid var(--border); border-radius: 12px; padding: 12px 16px; margin: 0; }
fieldset.coowners legend { font-weight: 600; padding: 0 6px; }
.form label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; }
.inline-form input, .inline-form select { flex: 1; min-width: 180px; width: auto; }

/* --- Settings ------------------------------------------------------------ */

.settings { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.people { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 8px; }
.people li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface-2); border-radius: 10px; }
.people form { margin: 0; }
.add-everyone { margin: 10px 0 0; }
.share-link { display: flex; gap: 8px; margin-bottom: 12px; }
.share-link input { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.share-buttons { display: flex; gap: 8px; flex-shrink: 0; }
.danger-zone { border-color: var(--error-ink); }

/* Card that folds open (rarely used settings). */
.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary h2 { margin: 0; }
.fold > summary::after { content: "▾"; color: var(--muted); transition: transform .15s; }
.fold[open] > summary::after { transform: rotate(180deg); }
.fold[open] > summary { margin-bottom: 14px; }

/* --- Admin --------------------------------------------------------------- */

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; border-bottom: 2px solid var(--border); }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

.stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin-bottom: 16px; }
.stat { display: flex; flex-direction: column; align-items: flex-start; padding: 16px 20px; }
.stat-num { font-family: var(--font-display); font-size: 2rem; font-weight: 700; line-height: 1.1; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--border); }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table td .badge { margin-left: 6px; }
.table .right { text-align: right; }

.user-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 1.6rem; margin-bottom: 16px; }
.new-password { margin-bottom: 16px; border: 2px dashed var(--gold); }
.password-display { font-family: ui-monospace, Consolas, monospace; font-size: 1.5rem; font-weight: 700; letter-spacing: .03em; background: var(--surface-2); padding: 10px 14px; border-radius: 10px; display: inline-block; }
.form label.radio { align-items: flex-start; }
.form label.radio input { margin-top: 5px; }
.invites li { flex-wrap: wrap; align-items: flex-start; }
.invite-info { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.invite-info .share-link { margin: 4px 0 0; }
.backups-card { grid-column: 1 / -1; }
code.path { overflow-wrap: anywhere; }
.fold-inline > summary { cursor: pointer; font-weight: 600; color: var(--primary); padding: 6px 0; }
.restore-steps { padding-left: 20px; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .85em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
hr { border: 0; border-top: 1px dashed var(--border); margin: 16px 0; }

/* --- Footer -------------------------------------------------------------- */

.site-footer { text-align: center; color: var(--muted); font-size: .875rem; padding-top: 16px; padding-bottom: 24px; position: relative; z-index: 1; }

/* --- Secret Santa -------------------------------------------------------- */

.santa-list { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 8px; }
.santa-card { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--text); border-left: 5px solid var(--primary); }
.santa-new { margin-top: 8px; }
.santa-match { text-align: center; margin-bottom: 16px; border: 2px dashed var(--gold); }
.santa-match p { margin: 0 0 6px; }
.santa-name { font-family: var(--font-display); font-size: 2rem; font-weight: 700; }
.santa-match .form-actions { justify-content: center; margin-top: 10px; }
.santa-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px 12px; }
.santa-actions .confirm { margin: 6px 6px 0 0; }

/* --- My gifts ------------------------------------------------------------ */

.gift-summary { display: grid; gap: 10px; grid-template-columns: 1fr 1fr 2fr; margin-bottom: 20px; }
.gift-total { font-size: 1.4rem; overflow-wrap: anywhere; }
.gift-person h2 { margin: 18px 0 8px; }
.gift-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.gift { display: flex; gap: 12px; padding: 12px 14px; align-items: flex-start; }
.gift.is-bought { opacity: .75; }
.gift-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.gift-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.gift-name { font-weight: 700; color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.gift-price { white-space: nowrap; font-variant-numeric: tabular-nums; }
.gift-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.gift-actions form { margin: 0; }
.home-gifts { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; text-decoration: none; color: var(--text); border-left: 5px solid var(--gold); }
.home-gifts strong { font-size: 1.05rem; }
.home-santa { border-left-color: var(--primary); }
.home-extra { margin-top: 28px; }
@media (max-width: 560px) {
    .gift-summary { grid-template-columns: 1fr 1fr; }
    .gift-summary .stat:last-child { grid-column: 1 / -1; }
}

/* --- Notification settings ----------------------------------------------- */

.notify-card { grid-column: 1 / -1; }
.push-device { background: var(--surface-2); border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; }
.push-device p { margin: 0 0 6px; }
.push-device .form-actions:not(:has(button:not([hidden]))) { display: none; }
.notify-table { width: 100%; border-collapse: collapse; }
.notify-table th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 6px 8px; border-bottom: 2px solid var(--border); }
.notify-table th:not(:first-child), .notify-table td:not(:first-child) { text-align: center; width: 64px; }
.notify-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.notify-table td:first-child { display: flex; flex-direction: column; gap: 2px; }
.notify-table input[type="checkbox"] { width: 22px; height: 22px; }

/* --- Import -------------------------------------------------------------- */

.import-options { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
.import-options textarea { font-size: 16px; }
.import-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.import-rows { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 8px; }
.import-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; }
.import-check { display: flex; align-items: center; justify-content: center; width: 32px; height: 40px; flex-shrink: 0; cursor: pointer; }
.import-check input { width: 22px; height: 22px; }
.import-row:has(.import-include:not(:checked)) { opacity: .5; }
.import-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.import-name { font-weight: 600; }
/* Price and quantity share a line; priority takes the next line on narrow screens. */
.import-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.import-meta input, .import-meta select { padding: 6px 10px; min-width: 0; }
.import-price { flex: 1 1 90px; width: auto; }
.import-qty { flex: 0 0 64px; width: 64px; }
.import-prio { flex: 1 1 150px; width: auto; }
.import-link { text-decoration: none; overflow-wrap: anywhere; }
.import-notes { margin: 0; }
.import-hint { margin: -4px 0 4px; }

/* --- Share target ("Add to which list?") ---------------------------------- */

.choice-list { display: flex; flex-direction: column; gap: 10px; }
.choice-list .btn { justify-content: flex-start; padding: 14px 18px; }
.share-link-preview { overflow-wrap: anywhere; }

/* --- Phones -------------------------------------------------------------- */

@media (max-width: 560px) {
    /* Header on one line: logo + Admin + 👤 name. "My lists" and "Log out" live elsewhere on phones. */
    .header-inner { flex-wrap: nowrap; min-height: 56px; gap: 8px; }
    .brand { font-size: 1.2rem; min-width: 0; }
    .brand-icon { font-size: 1.35rem; }
    .nav { flex-wrap: nowrap; gap: 4px; min-width: 0; }
    .nav-wide { display: none; }
    .nav a:not(.btn) { padding: 12px 8px; }
    .nav-user { display: flex; align-items: center; gap: 4px; min-width: 0; }
    .nav-user-name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    .main { padding-top: 16px; }

    /* List page head: compact title and buttons side by side. */
    .page-head { gap: 10px; margin-bottom: 12px; }
    .page-head p { margin-bottom: .3em; }
    .head-actions { width: 100%; flex-wrap: nowrap; }
    .head-actions .btn { flex: 1; padding: 8px 12px; font-size: .95rem; }

    /* Comfortable tap targets (about 44px). */
    .crumb a, .item-link, .tap { display: inline-block; padding: 10px 0; }
    .crumb { margin-bottom: 0; }
    .view-toggle a { padding: 10px 14px; }
    .btn-small { padding: 9px 16px; }
    .people li { padding: 4px 4px 4px 12px; }

    .settings { grid-template-columns: 1fr; }
    .items { grid-template-columns: 1fr; }

    /* Share link: big buttons, and 16px text so iPhones don't zoom in when tapped. */
    .share-link { flex-direction: column; }
    .share-link input, .qty input { font-size: 16px; }
    .share-buttons .btn { flex: 1; }

    /* Save bar stays at the bottom of the screen on long forms. */
    .form-actions.sticky {
        position: sticky; bottom: 0; z-index: 3; margin: 0 -20px -20px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
        background: var(--surface); border-top: 1px solid var(--border); border-radius: 0 0 16px 16px;
    }
    .form-actions.sticky .btn { flex: 1; }

    /* Admin users table: one small card per person. */
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; }
    .table-cards tr { padding: 12px 0; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
    .table-cards td { padding: 0; border: 0; }
    .table-cards td.cell-main { grid-column: 1; }
    .table-cards td.right { grid-column: 2; grid-row: 1 / span 4; align-self: center; }
    .table-cards td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .85rem; }
    .table-cards td[data-label] { font-size: .9rem; }
    .stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .stat { padding: 10px 12px; }
    .stat-num { font-size: 1.5rem; }
}

.lang-switch { margin: 0 0 6px; }
.lang-switch a { color: var(--muted); padding: 10px 4px; display: inline-block; }
.lang-switch a.is-active { color: var(--text); font-weight: 700; text-decoration: none; }

/* Room for the iPhone home bar when installed as an app. */
.site-footer { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
