/* =========================================================================
   WG — Aufgaben & Einkauf
   Aesthetic: warm "editorial-minimal", domestic and calm.
   Fraunces (display serif) + Nunito Sans (humanist sans).
   ========================================================================= */

:root {
    --paper:      #f3efe6;
    --paper-2:    #fbf9f3;
    --paper-3:    #efe9dc;
    --ink:        #2b2822;
    --ink-soft:   #6d675b;
    --ink-faint:  #9a9385;
    --line:       #e5dfd0;
    --line-soft:  #eee9dc;

    --accent:       #4e7a5b;
    --accent-strong:#3c6448;
    --accent-ink:   #2f4d38;
    --accent-soft:  #e6ede2;

    --rust:       #b0542c;
    --rust-ink:   #8f4322;
    --rust-soft:  #f3e2d6;

    --gold:       #b3852f;
    --gold-soft:  #f2e8d2;

    --danger:     #b23b3b;
    --danger-soft:#f4dede;

    --shadow-sm: 0 1px 2px rgba(43, 40, 34, 0.05);
    --shadow-md: 0 6px 20px -8px rgba(43, 40, 34, 0.18);
    --shadow-lg: 0 22px 50px -20px rgba(43, 40, 34, 0.30);

    --radius:    16px;
    --radius-sm: 10px;
    --radius-pill: 999px;

    --font-display: "Fraunces", Georgia, "Times New Roman", serif;
    --font-body: "Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    --maxw: 760px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper:      #16150f;
        --paper-2:    #201d15;
        --paper-3:    #2a2619;
        --ink:        #ece7da;
        --ink-soft:   #a8a08e;
        --ink-faint:  #776f5f;
        --line:       #322d21;
        --line-soft:  #2a2619;

        --accent:       #82b18e;
        --accent-strong:#9ac2a4;
        --accent-ink:   #bfd8c5;
        --accent-soft:  #23301f;

        --rust:       #d8794f;
        --rust-ink:   #e8a688;
        --rust-soft:  #372015;

        --gold:       #d3a955;
        --gold-soft:  #322815;

        --danger:     #e07373;
        --danger-soft:#37201f;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 6px 20px -8px rgba(0, 0, 0, 0.5);
        --shadow-lg: 0 22px 50px -20px rgba(0, 0, 0, 0.7);
    }
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    color: var(--ink);
    background-color: var(--paper);
    background-image:
        radial-gradient(1100px 620px at 88% -6%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%),
        radial-gradient(900px 620px at 4% 108%, color-mix(in srgb, var(--gold) 12%, transparent), transparent 60%);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select, button { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; }
a { color: var(--accent-ink); }

/* ---------- app shell ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px clamp(16px, 5vw, 36px);
    background: color-mix(in srgb, var(--paper) 82%, transparent);
    backdrop-filter: saturate(1.4) blur(12px);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--line);
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 22px;
    letter-spacing: -0.02em;
    color: var(--ink);
}
.brand .brand-mark {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 11px;
    background: linear-gradient(150deg, var(--accent), var(--accent-strong));
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.brand .brand-mark svg { width: 19px; height: 19px; }
.brand small {
    display: block;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-top: -2px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-chip .who {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.15;
}
.user-chip .who b { font-weight: 700; font-size: 14px; }
.user-chip .who span { font-size: 11px; color: var(--ink-faint); }

/* ---------- layout ---------- */
.shell { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(16px, 5vw, 24px) 96px; }

.tabs {
    position: sticky;
    top: 63px;
    z-index: 20;
    display: flex;
    gap: 4px;
    margin: 22px auto 26px;
    padding: 5px;
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-sm);
}
.tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 12px;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--ink-soft);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.01em;
    transition: color .2s, background .2s, box-shadow .2s;
}
.tab svg { width: 17px; height: 17px; opacity: .85; }
.tab:hover { color: var(--ink); }
.tab.is-active {
    background: linear-gradient(150deg, var(--accent), var(--accent-strong));
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.tab .tab-count {
    min-width: 18px;
    padding: 0 5px;
    border-radius: var(--radius-pill);
    background: color-mix(in srgb, currentColor 16%, transparent);
    font-size: 11px;
    line-height: 18px;
}

/* ---------- section header ---------- */
.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.section-head h2 { font-size: clamp(24px, 6vw, 30px); }
.section-head p { margin: 2px 0 0; color: var(--ink-soft); font-size: 14px; }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 14px;
    line-height: 1;
    transition: transform .12s, background .2s, border-color .2s, color .2s, box-shadow .2s;
    white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }
.btn-primary {
    background: linear-gradient(150deg, var(--accent), var(--accent-strong));
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover { box-shadow: var(--shadow-md); filter: brightness(1.03); }
.btn-ghost {
    background: var(--paper-2);
    border-color: var(--line);
    color: var(--ink);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn-quiet {
    background: transparent;
    color: var(--ink-soft);
    padding: 8px 12px;
}
.btn-quiet:hover { background: var(--paper-3); color: var(--ink); }
.btn-danger-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--danger);
}
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--ink-faint);
    transition: background .18s, color .18s, border-color .18s;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { background: var(--paper-3); color: var(--ink); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- cards / lists ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }

.card {
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
    transition: transform .16s ease, box-shadow .2s ease, border-color .2s ease;
}
.card.reveal { animation: rise .5s cubic-bezier(.2,.8,.2,1) backwards; }

.task-card { position: relative; overflow: hidden; }
.task-card::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--accent);
    opacity: .0;
    transition: opacity .2s;
}
.task-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.task-card:hover::before { opacity: .5; }
.task-card.is-overdue::before { background: var(--rust); opacity: .8; }
.task-card.is-done::before { background: var(--accent); opacity: .55; }

.task-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.task-title { font-family: var(--font-display); font-size: 20px; font-weight: 500; }
.task-desc { margin: 6px 0 0; color: var(--ink-soft); font-size: 14.5px; }
.task-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--line);
    font-size: 13.5px;
    color: var(--ink-soft);
}
.task-meta .who-line { display: flex; align-items: center; gap: 9px; }
.task-meta .who-line b { color: var(--ink); font-weight: 700; }
.task-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.chip-info {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-faint);
    font-size: 12.5px;
}
.chip-info svg { width: 14px; height: 14px; }

/* ---------- status pills ---------- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px 5px 9px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .02em;
    white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-open   { background: var(--gold-soft);   color: var(--gold); }
.pill-done   { background: var(--accent-soft); color: var(--accent-ink); }
.pill-overdue{ background: var(--rust-soft);   color: var(--rust-ink); }

/* ---------- avatars ---------- */
.avatar {
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    font-weight: 800;
    font-family: var(--font-body);
    letter-spacing: .01em;
    flex: none;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.18), var(--shadow-sm);
    user-select: none;
}
.avatar.sz-sm { width: 28px; height: 28px; font-size: 12px; }
.avatar.sz-md { width: 36px; height: 36px; font-size: 14px; }
.avatar.sz-lg { width: 44px; height: 44px; font-size: 16px; }
.avatar.ghost {
    background: var(--paper-3) !important;
    color: var(--ink-faint);
    box-shadow: inset 0 0 0 1px var(--line);
}

/* ---------- shopping list ---------- */
.shop-list { display: flex; flex-direction: column; }
.shop-item {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 13px 6px 13px 4px;
    border-bottom: 1px solid var(--line-soft);
    animation: rise .45s cubic-bezier(.2,.8,.2,1) backwards;
}
.shop-item:last-child { border-bottom: 0; }
.shop-item .body { min-width: 0; flex: 1; }
.shop-item .name { font-weight: 700; font-size: 15.5px; transition: color .2s; }
.shop-item .sub { font-size: 12px; color: var(--ink-faint); margin-top: 1px; }
.shop-item .row-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .18s; }
.shop-item:hover .row-actions, .shop-item:focus-within .row-actions { opacity: 1; }
.shop-item.checked .name { color: var(--ink-faint); text-decoration: line-through; text-decoration-color: var(--ink-faint); }

.check {
    position: relative;
    width: 26px; height: 26px;
    flex: none;
    border: 2px solid var(--line);
    border-radius: 8px;
    background: var(--paper);
    transition: background .2s, border-color .2s, transform .1s;
}
.check:hover { border-color: var(--accent); }
.check:active { transform: scale(.92); }
.check svg { position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; color: #fff; stroke-dasharray: 26; stroke-dashoffset: 26; }
.check.on { background: var(--accent); border-color: var(--accent); }
.check.on svg { animation: draw .3s ease forwards; }

/* ---------- members ---------- */
.member-row {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 13px 6px;
    border-bottom: 1px solid var(--line-soft);
    animation: rise .45s cubic-bezier(.2,.8,.2,1) backwards;
}
.member-row:last-child { border-bottom: 0; }
.member-row .body { flex: 1; min-width: 0; }
.member-row .name { font-weight: 700; font-size: 15.5px; }
.member-row .sub { font-size: 12px; color: var(--ink-faint); }
.tag-you {
    margin-left: 8px;
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    background: var(--accent-soft);
    color: var(--accent-ink);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .03em;
}

/* ---------- empty state ---------- */
.empty {
    text-align: center;
    padding: 46px 20px;
    color: var(--ink-soft);
}
.empty .emoji { font-size: 34px; }
.empty h3 { font-size: 20px; margin: 12px 0 4px; color: var(--ink); }
.empty p { margin: 0 auto 18px; max-width: 34ch; font-size: 14.5px; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }
.field > label { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.field .hint { font-size: 12px; color: var(--ink-faint); }
.input, .textarea, .select {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--paper);
    color: var(--ink);
    transition: border-color .18s, box-shadow .18s, background .18s;
}
.input:focus, .textarea:focus, .select:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--paper-2);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.textarea { min-height: 78px; resize: vertical; }
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }
.inline-input { display: flex; gap: 10px; align-items: center; }
/* The number input grows to fill; the unit select keeps its natural width so it
   can't starve the number field of space (which made the value unreadable). */
.inline-input .input { flex: 1 1 auto; width: auto; min-width: 0; }
.inline-input .select { flex: 0 0 auto; width: auto; }

/* ---------- modal ---------- */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 18px;
    background: color-mix(in srgb, #1a1712 55%, transparent);
    backdrop-filter: blur(3px);
    animation: fade .18s ease;
}
.modal {
    width: min(480px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 22px 22px 20px;
    animation: pop .22s cubic-bezier(.2,.9,.25,1.1);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { font-size: 22px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.modal .lead { color: var(--ink-soft); font-size: 14px; margin: -6px 0 16px; }

/* ---------- toast ---------- */
.toast-host {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 70;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    border-radius: var(--radius-pill);
    background: var(--ink);
    color: var(--paper);
    font-weight: 700;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    animation: toastIn .28s cubic-bezier(.2,.9,.25,1.1);
}
.toast.err { background: var(--danger); color: #fff; }
.toast.ok { background: var(--accent-strong); color: #fff; }
.toast svg { width: 16px; height: 16px; }

/* ---------- auth screen ---------- */
.auth-wrap {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.auth-card {
    width: min(420px, 100%);
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow-lg);
    padding: 30px 28px 26px;
    animation: rise .5s cubic-bezier(.2,.8,.2,1);
}
.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    margin-bottom: 22px;
}
.auth-brand .brand-mark { width: 52px; height: 52px; border-radius: 16px; }
.auth-brand .brand-mark svg { width: 28px; height: 28px; }
.auth-brand h1 { font-size: 30px; font-weight: 600; }
.auth-brand p { margin: 0; color: var(--ink-soft); font-size: 14.5px; max-width: 30ch; }
.auth-error {
    margin: 4px 0 14px;
    padding: 9px 13px;
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 13.5px;
    font-weight: 600;
}

/* ---------- loading ---------- */
.boot {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    color: var(--ink-faint);
}
.spinner {
    width: 34px; height: 34px;
    border-radius: 50%;
    border: 3px solid var(--line);
    border-top-color: var(--accent);
    animation: spin .8s linear infinite;
}

/* ---------- utilities ---------- */
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1; min-width: 0; }

/* ---------- animations ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes draw { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 560px) {
    .topbar { padding: 12px 16px; }
    .brand { font-size: 19px; }
    .user-chip .who { display: none; }
    .tab span.label { display: none; }
    .tab { padding: 10px; }
    .task-actions .label { display: none; }
    .field-row { flex-direction: column; gap: 0; }
}
