:root {
    --bg: #faf6f0;
    --surface: #ffffff;
    --text: #2b2420;
    --muted: #7a6e66;
    --border: #e8dfd4;
    --accent: #b3261e;
    --accent-dark: #8c1d17;
    --green: #2e6b4a;
    --green-bg: #e6f2eb;
    --error-bg: #fbe9e7;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(60, 40, 20, .08), 0 4px 12px rgba(60, 40, 20, .05);
}

* { box-sizing: border-box; }

html {
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

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

a { color: var(--accent); }

h1 { font-size: 1.75rem; margin: 1.5rem 0 .5rem; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; }

.wrap {
    max-width: 860px; margin: 0 auto;
    /* Safe Areas: Notch und abgerundete Ecken im Querformat der Homescreen-App */
    padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}

/* Kopfzeile (reicht in der Homescreen-App unter die Statusleiste) */
.site-header { background: var(--accent); color: #fff; padding-top: env(safe-area-inset-top); }
.header-inner {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    gap: .5rem 1.5rem; padding-top: .9rem; padding-bottom: .9rem;
}
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
.main-nav { display: flex; align-items: center; gap: 1.25rem; }
.main-nav a, .main-nav .link-button { color: #fff; text-decoration: none; opacity: .9; }
.site-footer {
    color: var(--muted); text-align: center; font-size: .9rem;
    padding-top: 2.5rem; padding-bottom: calc(2.5rem + env(safe-area-inset-bottom));
}

/* Bausteine */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1.25rem; margin: 1rem 0;
}
.lead { color: var(--muted); margin-top: 0; }
.hint { color: var(--muted); font-size: .875rem; font-weight: normal; }
.meta { color: var(--muted); font-size: .875rem; }
.empty { color: var(--muted); font-style: italic; }
.breadcrumb { margin: 1.25rem 0 0; }
.breadcrumb a { text-decoration: none; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin: 1rem 0; }
.flash-success { background: var(--green-bg); color: var(--green); }
.flash-error { background: var(--error-bg); color: var(--accent-dark); }

/* Formulare */
.stack { display: flex; flex-direction: column; gap: .35rem; }
.stack > label { font-weight: 600; margin-top: .5rem; }
.row { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
.row .stack > label { font-weight: 600; margin-top: .5rem; }

input[type=text], input[type=password], input[type=number], textarea {
    width: 100%; font: inherit; color: inherit; background: #fff;
    border: 1px solid var(--border); border-radius: 8px; padding: .6rem .75rem;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
textarea { resize: vertical; }

.button {
    display: inline-block; font: inherit; font-weight: 600; cursor: pointer;
    background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: .65rem 1.2rem;
}
.button:active { background: var(--accent-dark); }
.button.small { padding: .45rem .9rem; font-size: .9rem; }

.link-button {
    font: inherit; background: none; border: 0; padding: 0; cursor: pointer; color: var(--accent);
}
.danger { color: var(--accent-dark); }

.inline-form { display: inline; margin: 0; }
.form-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; }

/* Login */
.gate { max-width: 420px; margin: 3rem auto; }
.gate h1 { margin-top: 0; }
.gate .button { margin-top: 1rem; }

/* Übersicht */
.person-grid {
    list-style: none; padding: 0; margin: 1.5rem 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem;
}
.person-group { margin: 1.5rem 0; }
.person-group .person-grid { margin-top: .75rem; }
.group-title {
    font-size: 1.1rem; margin: 0; padding-bottom: .4rem;
    border-bottom: 2px solid var(--border); color: var(--muted);
}
.person-card {
    display: flex; flex-direction: column; align-items: center; gap: .35rem; text-align: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1.4rem 1rem; text-decoration: none; color: var(--text);
    transition: transform .12s ease, box-shadow .12s ease;
}
.person-card:active { transform: scale(.98); }
.avatar {
    width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
    background: var(--green-bg); color: var(--green); font-size: 1.5rem; font-weight: 700;
}
.person-name { font-weight: 700; font-size: 1.1rem; }
.person-count { color: var(--muted); font-size: .875rem; }

/* Wunschliste */
.wish-list { list-style: none; padding: 0; margin: 1rem 0; }
.wish.is-editing { outline: 2px solid var(--accent); }
.wish-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.wish-head h2 { margin: 0; font-size: 1.1rem; }
.badge {
    white-space: nowrap; background: var(--green-bg); color: var(--green);
    border-radius: 999px; padding: .15rem .65rem; font-size: .85rem; font-weight: 600;
}
.wish-details { margin: .5rem 0; }
.wish-link { word-break: break-all; }
.wish.is-fulfilling { border-left: 5px solid var(--green); }
.wish.is-fulfilling .wish-head h2 { color: var(--muted); }
.fulfillment-form { margin: .75rem 0 0; }
.fulfillment-toggle {
    display: inline-flex; align-items: center; gap: .55rem; cursor: pointer;
    font: inherit; font-size: .95rem; color: var(--text);
    background: none; border: 0; padding: .25rem 0;
}
.fulfillment-toggle .checkmark {
    width: 1.3rem; height: 1.3rem; flex: 0 0 auto; display: grid; place-items: center;
    border: 2px solid var(--border); border-radius: 5px; background: #fff;
    font-weight: 700; line-height: 1;
}
.fulfillment-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.is-fulfilling .fulfillment-toggle { color: var(--green); font-weight: 600; }
.is-fulfilling .fulfillment-toggle .checkmark { background: var(--green); border-color: var(--green); color: #fff; }
.wish-foot {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem;
    margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--border);
}
.actions { display: flex; gap: 1rem; font-size: .9rem; }

/* Verwaltung */
.title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.admin-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.admin-row input[type=text] { flex: 1 1 180px; width: auto; }
.admin-row .narrow { flex: 0 0 120px; width: 120px; }
.admin-list { display: flex; flex-direction: column; }
.admin-item {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem;
    padding: .75rem 0; border-top: 1px solid var(--border);
}
.admin-item:first-child { border-top: 0; }
.admin-item .admin-row { flex: 1 1 auto; }
.admin-item.is-inactive input[type=text] { color: var(--muted); text-decoration: line-through; }
.checkbox { display: inline-flex; align-items: center; gap: .3rem; font-size: .9rem; }

/* Hover-Effekte nur mit Maus: auf dem iPhone bleiben sie sonst nach dem Tippen «hängen» */
@media (hover: hover) {
    a:hover { color: var(--accent-dark); }
    .brand:hover { color: #fff; }
    .main-nav a:hover, .main-nav .link-button:hover { opacity: 1; text-decoration: underline; color: #fff; }
    .button:hover { background: var(--accent-dark); }
    .link-button:hover { text-decoration: underline; }
    .person-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(60, 40, 20, .12); color: var(--text); }
    .fulfillment-toggle:hover .checkmark { border-color: var(--green); }
}

@media (max-width: 560px) {
    .row { grid-template-columns: 1fr; gap: 0; }
    h1 { font-size: 1.45rem; }
}
