/**
 * Krabnet.dk — design system
 * Hand-written, mobile-first CSS3. No framework. Uses custom properties so the
 * whole palette (incl. dark mode) is themeable from one place.
 */

/* ---------------------------------------------------------------- Tokens */
:root {
    --color-bg: #f4f6fb;
    --color-surface: #ffffff;
    --color-surface-2: #f0f3f9;
    --color-border: #e2e8f0;
    --color-text: #16213f;
    --color-text-muted: #64748b;
    --color-primary: #2f7ef0;         /* brand blue — the ".dk" blue in the logo */
    --color-primary-dark: #1f5fca;
    --color-primary-contrast: #ffffff;
    --color-success: #2f9e44;
    --color-danger: #e03131;
    --color-warning: #e8590c;
    --color-focus: #2f7ef0;

    /* Brand identity */
    --color-brand-navy: #16213f;       /* the "krabnet" wordmark navy */
    --color-brand-blue: #2f7ef0;

    /* Module accent colours, straight from the logo tiles */
    --module-calendar: #ee7b0c;        /* orange  */
    --module-images:   #1e88e5;        /* blue    */
    --module-messages: #2f9e44;        /* green   */
    --module-family:   #9c27b0;        /* purple  */

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow: 0 4px 16px rgba(15, 23, 42, .08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, .14);

    --space-1: .25rem;
    --space-2: .5rem;
    --space-3: .75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;

    --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --sidebar-width: 260px;
    --header-height: 60px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #0f1420;
        --color-surface: #1a2130;
        --color-surface-2: #232c3d;
        --color-border: #2d3750;
        --color-text: #e6ebf5;
        --color-text-muted: #94a3b8;
        --color-primary: #5b8def;
        --color-primary-dark: #3d6fd6;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow: 0 4px 16px rgba(0, 0, 0, .45);
        --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
    }
}

/* ---------------------------------------------------------------- Reset */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 var(--space-3); }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 var(--space-4); }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: var(--space-3); top: -60px; z-index: 100;
    background: var(--color-primary); color: var(--color-primary-contrast);
    padding: var(--space-2) var(--space-4); border-radius: var(--radius);
    transition: top .15s ease;
}
.skip-link:focus { top: var(--space-3); text-decoration: none; }

/* ---------------------------------------------------------------- Avatar */
.avatar {
    display: inline-grid; place-items: center; flex: none;
    border-radius: 50%; object-fit: cover; overflow: hidden;
    background: var(--color-surface-2); color: var(--color-text-muted);
    font-weight: 700; line-height: 1;
}
.avatar--initials {
    background: var(--color-primary); color: #fff;
}

.topbar__user {
    display: inline-flex; align-items: center; gap: var(--space-2);
}
.topbar__user:hover { text-decoration: none; }

/* ---------------------------------------------------------------- Logo */
.logo { display: inline-flex; align-items: center; gap: var(--space-3); }
.logo__mark { display: block; border-radius: 22%; }
.logo__word { font-weight: 800; font-size: 1.25rem; letter-spacing: -.01em; color: var(--color-brand-navy); }
.logo__tld { color: var(--color-brand-blue); }
@media (prefers-color-scheme: dark) {
    .logo__word { color: #eaf0fb; }
}

/* ---------------------------------------------------------------- Layout */
.app {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 100vh;
}
.app__main { display: flex; flex-direction: column; min-width: 0; }
.content {
    flex: 1;
    padding: var(--space-5) var(--space-4);
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
}

/* Top bar (mobile + desktop) */
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: var(--space-3);
    height: var(--header-height);
    padding: 0 var(--space-4);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}
.topbar__brand { font-weight: 700; font-size: 1.15rem; color: var(--color-text); }
.topbar__brand:hover { text-decoration: none; }
.topbar__spacer { flex: 1; }
.topbar__user { color: var(--color-text-muted); font-size: .9rem; }

.nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; border: 1px solid var(--color-border);
    background: var(--color-surface); border-radius: var(--radius);
    cursor: pointer; color: var(--color-text);
}
.nav-toggle svg { width: 22px; height: 22px; }

/* Sidebar */
.sidebar {
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: var(--space-4);
    display: flex; flex-direction: column; gap: var(--space-5);
}
.sidebar__brand {
    font-weight: 700; font-size: 1.25rem; color: var(--color-text);
    padding: var(--space-2) var(--space-2) var(--space-4);
}
.sidebar__brand:hover { text-decoration: none; }
.nav-section__label {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--color-text-muted); font-weight: 700;
    margin: 0 var(--space-2) var(--space-2);
}
.nav-list { list-style: none; margin: 0 0 var(--space-2); padding: 0; }
.nav-link {
    display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius);
    color: var(--color-text); font-weight: 500;
}
.nav-link:hover { background: var(--color-surface-2); text-decoration: none; }
.nav-link[aria-current="page"] {
    background: var(--color-primary); color: var(--color-primary-contrast);
}
.nav-link svg { width: 20px; height: 20px; flex: none; }

/* Mobile: sidebar is an off-canvas drawer */
@media (max-width: 900px) {
    .sidebar {
        position: fixed; inset: 0 auto 0 0; z-index: 50;
        width: var(--sidebar-width); max-width: 82vw;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: var(--shadow-lg);
        /* The drawer is full-height and fixed, so long menus must scroll. */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
    }
    body.nav-open .sidebar { transform: translateX(0); }
    .nav-backdrop {
        position: fixed; inset: 0; z-index: 40;
        background: rgba(15, 23, 42, .5);
        opacity: 0; visibility: hidden; transition: opacity .2s ease;
    }
    body.nav-open .nav-backdrop { opacity: 1; visibility: visible; }
}

/* Desktop: fixed two-column layout, no top hamburger */
@media (min-width: 901px) {
    .app { grid-template-columns: var(--sidebar-width) 1fr; }
    .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
    .nav-toggle { display: none; }
    .topbar { background: transparent; border-bottom: 1px solid var(--color-border); }
}

/* ---------------------------------------------------------------- Cards */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: var(--space-4); }
.card__title { margin-bottom: var(--space-4); }
.grid { display: grid; gap: var(--space-4); }
@media (min-width: 700px) { .grid--2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .grid--3 { grid-template-columns: repeat(3, 1fr); } }

.stat { display: flex; flex-direction: column; gap: var(--space-1); }
.stat__value { font-size: 1.8rem; font-weight: 700; }
.stat__label { color: var(--color-text-muted); font-size: .9rem; }

/* ---------------------------------------------------------------- Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    font: inherit; font-weight: 600;
    border: 1px solid transparent; border-radius: var(--radius);
    cursor: pointer; background: var(--color-surface-2); color: var(--color-text);
    min-height: 44px; /* touch target */
}
.btn:hover { text-decoration: none; filter: brightness(.98); }
.btn--primary { background: var(--color-primary); color: var(--color-primary-contrast); }
.btn--primary:hover { background: var(--color-primary-dark); filter: none; }
.btn--danger { background: var(--color-danger); color: #fff; }
.btn--ghost { background: transparent; border-color: var(--color-border); }
.btn--sm { padding: var(--space-2) var(--space-3); min-height: 36px; font-size: .9rem; }
.btn--block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ---------------------------------------------------------------- Forms */
.form-group { margin-bottom: var(--space-4); }
.label { display: block; font-weight: 600; margin-bottom: var(--space-2); }
.input, .select, .textarea {
    width: 100%; padding: var(--space-3);
    font: inherit; color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border); border-radius: var(--radius);
    min-height: 44px;
}
.textarea { min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--color-primary);
    outline: 3px solid color-mix(in srgb, var(--color-primary) 30%, transparent);
    outline-offset: 0;
}
.input--error { border-color: var(--color-danger); }
.field-error { color: var(--color-danger); font-size: .85rem; margin-top: var(--space-1); }
.help { color: var(--color-text-muted); font-size: .85rem; margin-top: var(--space-1); }
.checkbox { display: inline-flex; align-items: center; gap: var(--space-2); }
.checkbox input { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- Alerts */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius); margin-bottom: var(--space-4);
    border: 1px solid transparent;
}
.alert--success { background: color-mix(in srgb, var(--color-success) 14%, var(--color-surface)); border-color: var(--color-success); }
.alert--danger  { background: color-mix(in srgb, var(--color-danger) 14%, var(--color-surface)); border-color: var(--color-danger); }
.alert--info    { background: color-mix(in srgb, var(--color-primary) 12%, var(--color-surface)); border-color: var(--color-primary); }
.alert ul { margin: var(--space-1) 0 0; padding-left: var(--space-5); }

/* ---------------------------------------------------------------- Badges */
.badge {
    display: inline-block; padding: 2px var(--space-2);
    font-size: .75rem; font-weight: 700; border-radius: 999px;
    background: var(--color-surface-2); color: var(--color-text-muted);
}
.badge--success { background: color-mix(in srgb, var(--color-success) 20%, transparent); color: var(--color-success); }
.badge--danger  { background: color-mix(in srgb, var(--color-danger) 20%, transparent); color: var(--color-danger); }
.badge--primary { background: color-mix(in srgb, var(--color-primary) 20%, transparent); color: var(--color-primary); }

/* ---------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; min-width: 560px; }
.table th, .table td { padding: var(--space-3) var(--space-4); text-align: left; border-bottom: 1px solid var(--color-border); }
.table th { background: var(--color-surface-2); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--color-text-muted); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover, .table tbody tr:hover { background: var(--color-surface-2); }

/* ---------------------------------------------------------------- Auth pages */
.auth {
    min-height: 100vh; display: grid; place-items: center;
    padding: var(--space-5) var(--space-4);
}
.auth__card { width: 100%; max-width: 420px; }
.auth__title { text-align: center; }
.auth__logo { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); margin-bottom: var(--space-5); }
.auth__tagline { text-transform: uppercase; letter-spacing: .18em; font-size: .72rem; font-weight: 700; color: var(--color-text-muted); margin: 0; }
.auth__alt { text-align: center; margin-top: var(--space-4); color: var(--color-text-muted); }

/* ---------------------------------------------------------------- Page head */
.page-head {
    display: flex; align-items: center; gap: var(--space-4);
    flex-wrap: wrap; margin-bottom: var(--space-5);
}
.page-head h1 { margin: 0; }
.page-head__actions { margin-left: auto; display: flex; gap: var(--space-2); flex-wrap: wrap; }

.list-reset { list-style: none; margin: 0; padding: 0; }
.muted { color: var(--color-text-muted); }
.mt-4 { margin-top: var(--space-4); }
.stack > * + * { margin-top: var(--space-4); }

/* ---------------------------------------------------------------- Calendar */
.calendar-head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); flex-wrap: wrap; }
.calendar-head h2 { margin: 0; text-transform: capitalize; }
.calendar {
    display: grid; grid-template-columns: repeat(7, 1fr);
    gap: 1px; background: var(--color-border);
    border: 1px solid var(--color-border); border-radius: var(--radius);
    overflow: hidden;
}
.calendar__dow {
    background: var(--color-surface-2); padding: var(--space-2);
    text-align: center; font-size: .78rem; font-weight: 700; color: var(--color-text-muted);
}
.calendar__cell {
    background: var(--color-surface); min-height: 96px;
    padding: var(--space-2); display: flex; flex-direction: column; gap: var(--space-1);
}
.calendar__cell--muted { background: var(--color-surface-2); }
.calendar__cell--today .calendar__date { background: var(--color-primary); color: #fff; }
.calendar__date {
    align-self: flex-start; font-size: .8rem; font-weight: 700;
    width: 26px; height: 26px; display: grid; place-items: center; border-radius: 999px;
}
.event-pill {
    display: block; font-size: .74rem; padding: 2px var(--space-2);
    border-radius: var(--radius-sm); color: #fff; overflow: hidden;
    white-space: nowrap; text-overflow: ellipsis;
}
.event-pill:hover { text-decoration: none; filter: brightness(1.05); }
.event-pill--marker { cursor: default; font-style: italic; }
.event-pill--household { border-left: 3px solid rgba(255, 255, 255, .85); }

@media (max-width: 620px) {
    .calendar__cell { min-height: 64px; }
    .calendar__dow { font-size: .66rem; }
    .event-pill { font-size: .66rem; }
}

/* ---------------------------------------------------------------- Family tree */
.person-avatar {
    display: inline-grid; place-items: center; flex: none;
    border-radius: 50%; object-fit: cover;
    background: var(--color-surface-2); color: var(--color-text-muted);
    font-weight: 700; overflow: hidden;
}
.person-avatar--initials { color: #fff; }
.person-avatar--female { background: #d6336c; }
.person-avatar--male { background: #1c7ed6; }
.person-avatar--other { background: #7048e8; }
.person-avatar--unknown { background: #868e96; }

.person-card {
    display: flex; gap: var(--space-3); align-items: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
    color: var(--color-text);
}
.person-card:hover { text-decoration: none; box-shadow: var(--shadow); }
.person-card__body { min-width: 0; }
.person-card__body strong { display: block; }
.person-card__body .muted { font-size: .85rem; display: flex; align-items: center; gap: .25rem; }

.relation-group { margin-bottom: var(--space-4); }
.relation-group__label {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--color-text-muted); font-weight: 700; margin: 0 0 var(--space-2);
}
.person-chip {
    display: flex; align-items: center; gap: var(--space-2);
    padding: var(--space-2); border-radius: var(--radius);
    color: var(--color-text);
}
.person-chip:hover { background: var(--color-surface-2); text-decoration: none; }

/* ---- Graphical descendant tree (pure CSS connectors) ---- */
.tree-scroll { overflow-x: auto; padding: var(--space-3) var(--space-2); }
.tree { display: inline-block; min-width: 100%; text-align: center; }
.tree ul {
    display: flex; justify-content: center;
    padding-top: 22px; margin: 0; position: relative; list-style: none;
}
.tree li {
    list-style: none; text-align: center; position: relative;
    padding: 22px var(--space-2) 0; display: flex; flex-direction: column; align-items: center;
}
/* connectors up from each node to the horizontal sibling bar */
.tree li::before, .tree li::after {
    content: ''; position: absolute; top: 0; right: 50%;
    border-top: 2px solid var(--color-border); width: 50%; height: 22px;
}
.tree li::after {
    right: auto; left: 50%; border-left: 2px solid var(--color-border);
}
.tree li::before { border-right: 2px solid var(--color-border); }
/* single child: one straight vertical line (no sibling bar), continuing the
   line drawn above by the parent ul so parent and child stay connected. */
.tree li:only-child::after { display: none; }
.tree li:only-child::before {
    display: block; right: auto; left: 50%;
    width: 0; height: 22px;
    border: 0; border-left: 2px solid var(--color-border); border-radius: 0;
}
.tree li:only-child { padding-top: 22px; }
/* trim the outer edges of the sibling bar */
.tree li:first-child::before, .tree li:last-child::after { border: 0 none; }
.tree li:last-child::before { border-right: 2px solid var(--color-border); border-radius: 0 6px 0 0; }
.tree li:first-child::after { border-radius: 6px 0 0 0; }
/* vertical line down from a parent to its children row */
.tree ul ul::before {
    content: ''; position: absolute; top: 0; left: 50%;
    border-left: 2px solid var(--color-border); width: 0; height: 22px;
}
/* top-level roots have no incoming connector (also when a root is an only-child) */
.tree > ul { padding-top: 0; }
.tree > ul > li::before, .tree > ul > li::after,
.tree > ul > li:only-child::before { display: none; }
.tree > ul > li { padding-top: 0; }

.tree-node {
    display: inline-flex; align-items: stretch; gap: var(--space-1);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-2); box-shadow: var(--shadow-sm);
}
.tree-person {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: var(--space-2); border-radius: var(--radius-sm);
    color: var(--color-text); width: 96px;
}
.tree-person:hover { background: var(--color-surface-2); text-decoration: none; }
.tree-person__name { font-weight: 600; font-size: .82rem; line-height: 1.2; }
.tree-person__years { font-size: .72rem; color: var(--color-text-muted); }
.tree-amp { display: flex; align-items: center; color: var(--color-text-muted); font-weight: 700; }

/* ---------------------------------------------------------------- History */
.timeline { position: relative; }
.timeline-item {
    display: grid; grid-template-columns: 90px 1fr; gap: var(--space-3);
    color: var(--color-text); align-items: start;
}
.timeline-item + .timeline-item { margin-top: var(--space-3); }
.timeline-item:hover { text-decoration: none; }
.timeline-item__year {
    position: relative; text-align: right; font-weight: 700; color: var(--color-text-muted);
    padding-right: var(--space-4); padding-top: var(--space-3);
}
/* vertical line + dot */
.timeline-item__year::after {
    content: ''; position: absolute; right: -1px; top: 0; bottom: -20px;
    border-right: 2px solid var(--color-border);
}
.timeline-item:last-child .timeline-item__year::after { bottom: 50%; }
.timeline-item__dot {
    position: absolute; right: -6px; top: var(--space-4); width: 12px; height: 12px;
    border-radius: 50%; border: 2px solid var(--color-surface); z-index: 1;
}
.timeline-item__card {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); padding: var(--space-4); box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: var(--space-1); align-items: flex-start;
}
.timeline-item:hover .timeline-item__card { box-shadow: var(--shadow); }
.timeline-item__title { font-size: 1.05rem; }
.timeline-item__img {
    width: 100%; max-height: 220px; object-fit: cover; border-radius: var(--radius);
    margin-top: var(--space-2);
}

@media (max-width: 560px) {
    .timeline-item { grid-template-columns: 56px 1fr; }
    .timeline-item__year { font-size: .85rem; padding-right: var(--space-3); }
}

/* ---------------------------------------------------------------- Map */
.map {
    height: 65vh; min-height: 380px; width: 100%;
    border-radius: var(--radius); border: 1px solid var(--color-border);
    background: var(--color-surface-2); z-index: 0;
}

/* Avatar pins (Leaflet divIcon) */
.map-pin__inner {
    width: 40px; height: 40px; border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    background: var(--color-primary); border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, .4);
    display: grid; place-items: center; overflow: hidden;
}
.map-pin__inner.is-me { background: var(--module-messages); }
.map-pin__inner img, .map-pin__inner span {
    transform: rotate(45deg);
    width: 30px; height: 30px; border-radius: 50%; object-fit: cover;
    display: grid; place-items: center;
    color: #fff; font-weight: 700; font-size: 13px;
}
.map-pin__inner img { border: 0; }

/* Household pins: a rounded square (a "home"), not a person teardrop. */
.map-pin__inner.is-household {
    border-radius: 10px; transform: none;
    background: var(--module-family);
}
.map-pin__inner.is-household img, .map-pin__inner.is-household span {
    transform: none; border-radius: 7px;
}

/* ---------------------------------------------------------------- Finance */
.budget__track {
    height: 10px; border-radius: 999px; overflow: hidden;
    background: var(--color-surface-2); border: 1px solid var(--color-border);
}
.budget__fill { height: 100%; background: var(--color-success); border-radius: 999px; transition: width .3s ease; }
.budget__fill--over { background: var(--color-danger); }
.budget__labels { display: flex; justify-content: space-between; margin-top: var(--space-2); font-size: .82rem; }
.budget__over { color: var(--color-danger); font-weight: 600; }

.settle {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
    padding: var(--space-3) 0; border-bottom: 1px solid var(--color-border);
}
.settle:last-child { border-bottom: 0; }
.settle__arrow { display: inline-flex; align-items: center; gap: var(--space-1); color: var(--color-text-muted); font-size: .85rem; white-space: nowrap; }

/* ---------------------------------------------------------------- Wishlists */
.wishlist-card {
    display: flex; gap: var(--space-3); align-items: center;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); padding: var(--space-4);
    box-shadow: var(--shadow-sm); color: var(--color-text);
}
.wishlist-card:hover { text-decoration: none; box-shadow: var(--shadow); }
.wishlist-card__badge {
    flex: none; width: 44px; height: 44px; border-radius: var(--radius);
    display: grid; place-items: center; font-size: 1.4rem;
}

.wish {
    display: flex; gap: var(--space-3); align-items: flex-start;
    padding: var(--space-3) 0; border-bottom: 1px solid var(--color-border);
}
.wish:last-child { border-bottom: 0; }
.wish--reserved { opacity: .6; }
.wish__main { flex: 1; min-width: 0; }
.wish__meta { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; margin-top: 2px; }
.wish__link { display: inline-flex; align-items: center; gap: 4px; font-size: .85rem; }
.wish__actions { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }

/* ---------------------------------------------------------------- Loans */
.loan-card {
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); color: var(--color-text);
}
.loan-card:hover { text-decoration: none; box-shadow: var(--shadow); }
.loan-card__media {
    aspect-ratio: 16 / 9; display: grid; place-items: center; overflow: hidden;
    background: var(--color-surface-2);
}
.loan-card__media img { width: 100%; height: 100%; object-fit: cover; }
.loan-card__emoji { font-size: 2.6rem; }
.loan-card__body { padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-1); align-items: flex-start; }

/* ---------------------------------------------------------------- Recipes */
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.chip {
    display: inline-flex; align-items: center; gap: var(--space-1);
    padding: var(--space-2) var(--space-3); border-radius: 999px;
    border: 1px solid var(--color-border); background: var(--color-surface);
    color: var(--color-text); font-size: .85rem; font-weight: 600;
}
.chip:hover { background: var(--color-surface-2); text-decoration: none; }
.chip.is-active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.recipe-card {
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); color: var(--color-text);
}
.recipe-card:hover { text-decoration: none; box-shadow: var(--shadow); }
.recipe-card__media {
    aspect-ratio: 16 / 9; display: grid; place-items: center; overflow: hidden;
}
.recipe-card__media img { width: 100%; height: 100%; object-fit: cover; }
.recipe-card__emoji { font-size: 2.4rem; }
.recipe-card__body { padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-1); align-items: flex-start; }
.recipe-card__title { font-size: 1rem; }

.recipe-steps { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: var(--space-3); }
.recipe-steps li { padding-left: var(--space-1); }

/* Star display */
.stars { display: inline-flex; align-items: center; gap: 1px; }
.stars__star { color: var(--color-border); line-height: 0; }
.stars__star.is-on { color: #f59f00; }
.stars__star svg { fill: currentColor; stroke: none; }
.stars__meta { margin-left: var(--space-2); color: var(--color-text-muted); font-size: .8rem; }

/* Interactive rating */
.rate { display: inline-flex; gap: var(--space-1); }
.rate__star {
    background: none; border: 0; cursor: pointer; padding: var(--space-1);
    color: var(--color-border); line-height: 0;
}
.rate__star svg { fill: currentColor; stroke: none; }
.rate__star.is-on { color: #f59f00; }
.rate:hover .rate__star { color: #f59f00; }        /* hover fills up to the hovered star */
.rate__star:hover ~ .rate__star { color: var(--color-border); }

/* ---------------------------------------------------------------- Gallery */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-2);
}
.gallery-item {
    display: block; aspect-ratio: 1 / 1; overflow: hidden;
    border-radius: var(--radius); border: 1px solid var(--color-border);
    background: var(--color-surface-2);
}
.gallery-item img {
    width: 100%; height: 100%; object-fit: cover; display: block;
    transition: transform .2s ease;
}
.gallery-item:hover img { transform: scale(1.05); }

.gallery-full {
    display: flex; justify-content: center;
    background: var(--color-surface-2); border-radius: var(--radius);
    overflow: hidden;
}
.gallery-full img { max-width: 100%; height: auto; display: block; }

/* ---------------------------------------------------------------- Messages */
.msg {
    display: flex; gap: var(--space-3);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
}
.msg__avatar {
    flex: none; width: 42px; height: 42px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--module-messages); color: #fff; font-weight: 700;
}
.msg__body { min-width: 0; flex: 1; }
.msg__meta { display: flex; gap: var(--space-2); align-items: baseline; flex-wrap: wrap; }
.msg__meta .muted { font-size: .85rem; }
.msg__text { margin: var(--space-2) 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg__actions { display: flex; gap: var(--space-2); margin-top: var(--space-3); flex-wrap: wrap; }

/* Private messaging: folder tabs + message rows */
.msg-folders {
    display: flex; gap: var(--space-1); flex-wrap: wrap;
    border-bottom: 1px solid var(--color-border); padding-bottom: var(--space-2);
}
.msg-folder {
    display: inline-flex; align-items: center; gap: var(--space-2);
    padding: var(--space-2) var(--space-3); border-radius: var(--radius);
    color: var(--color-text-muted); text-decoration: none; font-weight: 600;
}
.msg-folder:hover { background: var(--color-surface-2); color: var(--color-text); }
.msg-folder.is-active { background: var(--color-surface-2); color: var(--color-text); }
.msg-row {
    display: block; padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border); color: var(--color-text); text-decoration: none;
}
.msg-row:last-child { border-bottom: 0; }
.msg-row:hover { background: var(--color-surface-2); }
.msg-row.is-unread { background: color-mix(in srgb, var(--color-primary) 6%, transparent); }
.msg-row.is-unread .msg-row__subject { font-weight: 700; }
.msg-row__top { display: flex; justify-content: space-between; gap: var(--space-3); align-items: baseline; }
.msg-row__people { font-weight: 600; overflow-wrap: anywhere; }
.msg-row__date { font-size: .8rem; flex: none; }
.msg-row__subject { margin-top: var(--space-1); overflow-wrap: anywhere; display: flex; align-items: center; gap: var(--space-2); }
.msg-row__star { color: var(--color-warning, #e0a800); flex: none; }
.msg-row__snippet { margin-top: var(--space-1); font-size: .9rem; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.msg-head__meta { display: grid; gap: var(--space-1); }
.msg-content { margin-top: var(--space-4); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }

/* Mine filer: upload area + file rows */
.filedrop {
    display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
    text-align: center; padding: var(--space-5); cursor: pointer;
    border: 2px dashed var(--color-border); border-radius: var(--radius);
    color: var(--color-text-muted); transition: border-color .15s, background .15s;
}
.filedrop:hover, .filedrop.is-drag { border-color: var(--color-primary); background: var(--color-surface-2); }
.filedrop strong { color: var(--color-text); }
.upload-list { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: grid; gap: var(--space-2); }
.upload-item { display: grid; grid-template-columns: 1fr 120px 46px; align-items: center; gap: var(--space-2); font-size: .9rem; }
.upload-item__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item__bar { height: 8px; border-radius: 4px; background: var(--color-surface-2); overflow: hidden; }
.upload-item__bar i { display: block; height: 100%; width: 0; background: var(--color-primary); transition: width .2s; }
.upload-item__pct { text-align: right; color: var(--color-text-muted); }
.upload-item.is-done .upload-item__bar i { background: var(--color-success); }
.upload-item.is-error .upload-item__pct { color: var(--color-danger); }
.file-row {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
    padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border);
}
.file-row:last-child { border-bottom: 0; }
.file-row__main { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.file-row__actions { display: flex; gap: var(--space-2); flex: none; flex-wrap: wrap; }
.share-copy { display: flex; gap: var(--space-2); align-items: center; }
.share-copy .input { flex: 1; min-width: 0; font-size: .85rem; }

/* Message attachments (compose + read) */
.attach-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.attach-chips:empty { display: none; }
.attach-chip {
    display: inline-flex; align-items: center; gap: var(--space-2);
    padding: .3rem .6rem; border-radius: 999px; font-size: .85rem;
    background: var(--color-surface-2); border: 1px solid var(--color-border); max-width: 100%;
}
.attach-chip__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 16rem; }
.attach-chip__x {
    border: 0; background: none; cursor: pointer; color: var(--color-text-muted);
    font-size: 1.1rem; line-height: 1; padding: 0;
}
.attach-chip__x:hover { color: var(--color-danger); }
.attach-chip--link { text-decoration: none; color: var(--color-text); }
.attach-chip--link:hover { border-color: var(--color-primary); }
.attach-controls { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: flex-start; margin-top: var(--space-3); }
.attach-controls .btn { cursor: pointer; }
.attach-progress-list { display: grid; gap: var(--space-1); margin-top: var(--space-2); font-size: .85rem; color: var(--color-text-muted); }
.attach-archive { position: relative; }
.attach-archive__list {
    margin-top: var(--space-2); display: grid; gap: var(--space-1);
    max-height: 220px; overflow: auto; padding: var(--space-2);
    border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface);
}
.attach-archive__item {
    text-align: left; border: 0; background: none; cursor: pointer; padding: .35rem .5rem;
    border-radius: var(--radius); color: var(--color-text); font-size: .9rem;
}
.attach-archive__item:hover { background: var(--color-surface-2); }
.attach-archive__item:disabled { opacity: .5; cursor: default; }
.msg-attachments { margin-top: var(--space-4); display: grid; gap: var(--space-2); }
.msg-attachments__list { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* Køb og salg (marketplace) */
.market-filters { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.market-filters .select { max-width: 16rem; }
.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-3); }
.market-card {
    display: flex; flex-direction: column; text-decoration: none; color: var(--color-text);
    border: 1px solid var(--color-border); border-radius: var(--radius); overflow: hidden; background: var(--color-surface);
}
.market-card:hover { border-color: var(--color-primary); }
.market-card__photo {
    position: relative; aspect-ratio: 1 / 1; display: grid; place-items: center;
    background: var(--color-surface-2); color: var(--color-text-muted); overflow: hidden;
}
.market-card__photo img { width: 100%; height: 100%; object-fit: cover; }
.market-card__flag {
    position: absolute; top: .4rem; left: .4rem; font-size: .72rem; font-weight: 700;
    padding: .15rem .5rem; border-radius: 999px; background: var(--color-text); color: var(--color-surface);
}
.market-card__flag--auction { background: var(--color-primary); color: var(--color-primary-contrast); }
.market-card__flag--sold { background: var(--color-success); color: #fff; }
.market-card__body { padding: var(--space-2) var(--space-3) var(--space-3); display: grid; gap: .15rem; }
.market-card__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.market-card__price { font-weight: 700; }
.market-card__meta { font-size: .8rem; }
.market-detail { display: grid; gap: var(--space-4); }
@media (min-width: 800px) { .market-detail { grid-template-columns: 1fr 320px; align-items: start; } }
.market-price { font-size: 1.6rem; font-weight: 800; margin: .25rem 0 var(--space-3); }
.market-photos { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.market-photos img { width: 120px; height: 120px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--color-border); }
.market-photos--empty { aspect-ratio: 16/9; width: 100%; display: grid; place-items: center; background: var(--color-surface-2); color: var(--color-text-muted); border-radius: var(--radius); }
.market-meta { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.market-type { display: flex; gap: var(--space-3); }
.market-type__opt { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; }
.market-photo-remove { display: inline-grid; gap: .25rem; justify-items: center; font-size: .8rem; }
.market-photo-remove img { width: 90px; height: 90px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--color-border); }

/* Household member rows (title per member) */
.household-member-row { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.select--sm { width: auto; min-width: 8rem; padding: .3rem .5rem; font-size: .85rem; }

/* Event list (mobile-friendly agenda) */
.agenda { list-style: none; margin: 0; padding: 0; }
.agenda__item { display: flex; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--color-border); }
.agenda__swatch { width: 6px; border-radius: 3px; flex: none; }
.agenda__time { color: var(--color-text-muted); font-size: .85rem; }
