/* File: /assets/css/style.css
   Family OS — visual identity: a private family archive should feel like
   a well-kept ledger, not a SaaS dashboard. Warm paper, brass accents,
   a serif that carries some weight for headings, quiet everywhere else.
*/

:root {
    --ink: #2A2622;
    --ink-soft: #59524A;
    --paper: #F5EFE2;
    --paper-card: #FFFDF8;
    --line: #DED2B6;
    --green: #2F4F3E;
    --green-deep: #223A2D;
    --brass: #B8873D;
    --brass-soft: #E8D9B8;
    --red: #A23E3E;
    --red-soft: #F6E4E1;
    --blue-soft: #E4EDF0;

    --radius: 6px;
    --shadow-card: 0 1px 2px rgba(42, 38, 34, 0.06), 0 1px 1px rgba(42, 38, 34, 0.04);

    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0 0 0.5em; color: var(--ink); }

/* ----------------------------------------------------------------------
   App shell: sidebar + content
   Mobile-first: base rules below are the PHONE layout (off-canvas sidebar,
   hamburger visible, single column). The desktop override lives in the
   min-width media query further down and restores the static sidebar.
   ---------------------------------------------------------------------- */
.shell {
    display: flex;
    min-height: 100vh;
    position: relative;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 18, 15, 0.45);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.shell.sidebar-open .sidebar-overlay {
    display: block;
    opacity: 1;
}

.sidebar {
    width: 260px;
    max-width: 82vw;
    flex-shrink: 0;
    background: var(--green-deep);
    color: #EDE7D6;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
}

.shell.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 6px 0 24px rgba(0,0,0,0.25);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(237, 231, 214, 0.14);
    margin-bottom: 14px;
}

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brass);
    color: var(--green-deep);
    font-family: var(--font-display);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.brand-name {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.nav { flex: 1; padding: 0 10px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 12px;
    border-radius: var(--radius);
    color: #C9C0A8;
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 2px;
    min-height: 44px;
}

.nav-link:hover { background: rgba(237, 231, 214, 0.08); color: #EDE7D6; text-decoration: none; }

.nav-link.active {
    background: rgba(184, 135, 61, 0.18);
    color: #F3E4C5;
    box-shadow: inset 3px 0 0 var(--brass);
}

.nav-icon { width: 18px; text-align: center; opacity: 0.85; font-size: 14px; }

.nav-section-label {
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: #8C8570;
    padding: 16px 12px 6px;
}

.sidebar-footer {
    padding: 16px 20px 0;
    border-top: 1px solid rgba(237, 231, 214, 0.14);
    margin-top: 16px;
}

.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brass-soft);
    color: var(--green-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 600; color: #EDE7D6; }
.user-role { font-size: 11px; color: #9C9480; text-transform: capitalize; }

.logout-link {
    font-size: 13px;
    color: #9C9480;
    display: inline-flex;
    align-items: center;
    min-height: 32px;
}
.logout-link:hover { color: #EDE7D6; }

.main { flex: 1; min-width: 0; width: 100%; }

.topbar {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    background: var(--paper);
    z-index: 30;
    border-bottom: 1px solid var(--line);
}

.hamburger-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--paper-card);
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
}

.hamburger-btn span {
    display: block;
    width: 18px;
    height: 2px;
    margin: 0 auto;
    background: var(--ink);
    border-radius: 2px;
}

.page-title { font-size: 19px; line-height: 1.2; }

.content { padding: 16px 16px 48px; }

/* ----------------------------------------------------------------------
   Desktop: static sidebar, hamburger hidden, content offset by sidebar width
   ---------------------------------------------------------------------- */
@media (min-width: 861px) {
    .sidebar-overlay { display: none !important; }

    .sidebar {
        position: sticky;
        transform: none;
        max-width: none;
        width: 240px;
    }

    .main { margin-left: 0; }

    .hamburger-btn { display: none; }

    .topbar {
        padding: 28px 40px 0;
        position: static;
        border-bottom: none;
        background: transparent;
    }

    .page-title { font-size: 26px; }

    .content { padding: 20px 40px 60px; }
}

/* ----------------------------------------------------------------------
   Stat cards — styled like index cards, not SaaS KPI tiles
   ---------------------------------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--paper-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-card);
    position: relative;
}

.stat-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--brass);
    border-radius: var(--radius) var(--radius) 0 0;
}

.stat-card-muted { opacity: 0.55; }
.stat-card-muted::before { background: var(--line); }

.stat-card-alert::before { background: var(--red); }

.stat-value {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 600;
    line-height: 1;
    margin-bottom: 6px;
}

.stat-label {
    font-size: 13px;
    color: var(--ink-soft);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.stat-phase {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--brass-soft);
    color: var(--green-deep);
    padding: 2px 6px;
    border-radius: 3px;
}

.stat-action { font-size: 12px; font-weight: 600; }

/* ----------------------------------------------------------------------
   Panels
   ---------------------------------------------------------------------- */
.panel {
    background: var(--paper-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow-card);
}

.panel-header {
    padding: 16px 22px;
    border-bottom: 1px dashed var(--line);
}

.panel-header h2 { font-size: 17px; }

.panel-body { padding: 18px 22px; }

.empty-state { color: var(--ink-soft); font-size: 14px; margin: 0; }

/* ----------------------------------------------------------------------
   Activity feed
   ---------------------------------------------------------------------- */
.activity-list { list-style: none; margin: 0; padding: 0; }

.activity-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    font-size: 13.5px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: baseline;
}

.activity-item:last-child { border-bottom: none; }

.activity-actor { font-weight: 600; }
.activity-action { color: var(--ink-soft); }
.activity-desc { color: var(--ink-soft); }
.activity-time { margin-left: auto; color: #A39B85; font-size: 12px; }

/* ----------------------------------------------------------------------
   Tables
   ---------------------------------------------------------------------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-soft);
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
}
.data-table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.table-actions { white-space: nowrap; }
.inline-form { display: inline-flex; gap: 8px; }

.badge {
    display: inline-block;
    font-size: 11px;
    text-transform: capitalize;
    background: var(--blue-soft);
    color: var(--green-deep);
    padding: 3px 8px;
    border-radius: 10px;
}

/* ----------------------------------------------------------------------
   Buttons / forms
   ---------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-body);
}

.btn-primary { background: var(--green); color: #F5EFE2; }
.btn-primary:hover { background: var(--green-deep); text-decoration: none; }

.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-soft); }
.btn-ghost:hover { background: var(--paper); text-decoration: none; }

.btn-small { padding: 6px 12px; font-size: 12.5px; }
.btn-block { width: 100%; }

.field-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-soft);
    margin: 14px 0 6px;
}

.field-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font-body);
    background: var(--paper-card);
    color: var(--ink);
}

.field-input:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(47, 79, 62, 0.12);
}

/* ----------------------------------------------------------------------
   Forms (add/edit member)
   ---------------------------------------------------------------------- */
.stacked-form { display: flex; flex-direction: column; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--ink-soft);
    margin-top: 8px;
}

.field-hint { font-size: 12px; color: var(--ink-soft); margin: 4px 0 0; }

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 22px;
}

.member-photo-preview {
    display: block;
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 10px;
    margin: 6px 0 8px;
    border: 1px solid var(--line);
}

textarea.field-input { resize: vertical; font-family: var(--font-body); }

@media (min-width: 640px) {
    .form-grid { grid-template-columns: 1fr 1fr; }
}

/* ----------------------------------------------------------------------
   Member list toolbar + card grid
   ---------------------------------------------------------------------- */
.list-toolbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
}

.search-form { display: flex; gap: 8px; }
.search-form .field-input { flex: 1; }

.member-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px;
}

.member-card {
    background: var(--paper-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 12px;
    text-align: center;
    color: var(--ink);
    box-shadow: var(--shadow-card);
}
.member-card:hover { border-color: var(--brass); text-decoration: none; }

.member-card-photo {
    width: 68px;
    height: 68px;
    margin: 0 auto 10px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--brass-soft);
}
.member-card-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.member-photo-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 600;
    color: var(--green-deep);
    background: var(--brass-soft);
}

.member-card-name { font-weight: 600; font-size: 14px; }
.member-card-meta { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.deceased-mark { color: var(--ink-soft); font-size: 12px; }

@media (min-width: 640px) {
    .list-toolbar { flex-direction: row; justify-content: space-between; align-items: center; }
    .search-form { max-width: 320px; }
}

/* ----------------------------------------------------------------------
   Member profile page
   ---------------------------------------------------------------------- */
.member-profile { display: flex; flex-direction: column; gap: 20px; }

.member-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
    padding: 24px 20px;
}

.member-hero-photo {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 0 0 4px var(--paper-card), 0 0 0 5px var(--line);
}
.member-hero-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.member-hero-info h2 { font-size: 22px; margin-bottom: 4px; }

.member-relation-to-you {
    display: inline-block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--green-deep);
    background: var(--brass-soft);
    padding: 3px 10px;
    border-radius: 10px;
    margin-bottom: 10px;
}

.member-fact-list {
    list-style: none;
    margin: 0 0 6px;
    padding: 0;
    font-size: 13.5px;
    color: var(--ink-soft);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.member-hero .form-actions { justify-content: center; }

@media (min-width: 640px) {
    .member-hero { flex-direction: row; text-align: left; align-items: flex-start; }
    .member-hero .form-actions { justify-content: flex-start; }
}

/* ----------------------------------------------------------------------
   Relationships
   ---------------------------------------------------------------------- */
.relationship-group { margin-bottom: 18px; }
.relationship-group:last-child { margin-bottom: 0; }

.relationship-group-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-soft);
    margin-bottom: 8px;
}

.relationship-list { list-style: none; margin: 0; padding: 0; }

.relationship-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}
.relationship-item:last-child { border-bottom: none; }

.btn-link-danger {
    background: none;
    border: none;
    color: var(--red);
    font-size: 12.5px;
    cursor: pointer;
    padding: 6px 4px;
    text-decoration: underline;
}

.add-relationship-form {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed var(--line);
}

.inline-form-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.inline-form-wrap .field-input { width: 100%; }

@media (min-width: 640px) {
    .inline-form-wrap { flex-direction: row; align-items: center; }
    .inline-form-wrap .field-input { width: auto; flex: 1; }
}

/* ----------------------------------------------------------------------
   Flash messages
   ---------------------------------------------------------------------- */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.flash-error { background: var(--red-soft); color: #7A2E2E; border-color: #E3BDBD; }
.flash-success { background: #E6EEE3; color: var(--green-deep); border-color: #C7D9C1; }
.flash-info { background: var(--blue-soft); color: #2C4A54; border-color: #C7DBE1; word-break: break-all; }
.flash-standalone { max-width: 420px; margin: 20px auto 0; }

/* ----------------------------------------------------------------------
   Auth pages (login / register / password reset)
   ---------------------------------------------------------------------- */
.auth-body {
    background: var(--green-deep);
    background-image:
        radial-gradient(circle at 20% 20%, rgba(184, 135, 61, 0.10), transparent 45%),
        radial-gradient(circle at 80% 85%, rgba(184, 135, 61, 0.08), transparent 45%);
}

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--paper-card);
    border-radius: 10px;
    padding: 36px 32px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.auth-brand .brand-mark { background: var(--green); color: #F5EFE2; }
.auth-brand .brand-name { color: var(--ink); }

.auth-tagline { color: var(--ink-soft); font-size: 13.5px; margin: 0 0 20px; }

.auth-form { display: flex; flex-direction: column; }
.auth-form .btn { margin-top: 20px; }

.auth-links {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
    text-align: center;
}

/* ----------------------------------------------------------------------
   Locked/private member cards (list + tree list view)
   ---------------------------------------------------------------------- */
.member-card-locked {
    opacity: 0.6;
    cursor: default;
}
.member-card-locked .member-photo-placeholder { background: var(--line); color: var(--ink-soft); }

/* ----------------------------------------------------------------------
   Visual family tree
   ---------------------------------------------------------------------- */
.tree-visual-toolbar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.tree-visual-zoom-controls { display: flex; gap: 8px; }

.tree-visual-wrap {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--paper-card);
    height: 60vh;
    min-height: 360px;
    overflow: hidden;
    position: relative;
}

.ftree-host { width: 100%; height: 100%; position: relative; touch-action: none; }
.ftree-svg { display: block; background: var(--paper); cursor: grab; }
.ftree-svg:active { cursor: grabbing; }

.ftree-status {
    position: absolute;
    top: 12px;
    left: 12px;
    font-size: 13px;
    color: var(--ink-soft);
    background: var(--paper-card);
    padding: 4px 10px;
    border-radius: 6px;
    pointer-events: none;
}
.ftree-status:empty { display: none; }

.ftree-node-box {
    fill: var(--paper-card);
    stroke: var(--line);
    stroke-width: 1.5;
}
.ftree-node:hover .ftree-node-box { stroke: var(--brass); }
.ftree-node-private .ftree-node-box { fill: var(--paper); stroke-dasharray: 4 3; }

.ftree-avatar-text {
    font-size: 16px;
    fill: var(--green-deep);
    font-family: var(--font-display);
    font-weight: 600;
    text-anchor: middle;
}
.ftree-name-text {
    font-size: 13px;
    font-family: var(--font-body);
    font-weight: 600;
    fill: var(--ink);
}
.ftree-meta-text {
    font-size: 11px;
    font-family: var(--font-body);
    fill: var(--ink-soft);
}

.ftree-edge, .ftree-spouse-link {
    stroke: var(--line);
    stroke-width: 2;
    fill: none;
}
.ftree-spouse-link { stroke: var(--brass); }

.ftree-expand-circle {
    fill: var(--green);
    stroke: var(--paper-card);
    stroke-width: 2;
}
.ftree-expand-btn:hover .ftree-expand-circle { fill: var(--green-deep); }
.ftree-expand-btn { cursor: pointer; }
.ftree-expand-label {
    font-size: 14px;
    font-weight: 700;
    fill: var(--paper);
    text-anchor: middle;
}

.tree-visual-help { margin-top: 10px; }

@media (min-width: 640px) {
    .tree-visual-toolbar { flex-direction: row; justify-content: space-between; align-items: center; }
    .tree-visual-wrap { height: 68vh; }
}

/* ----------------------------------------------------------------------
   Certificates
   ---------------------------------------------------------------------- */
.cert-upload-block {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px dashed var(--line);
}

.cert-on-file {
    font-size: 13px;
    color: var(--green-deep);
    margin: 4px 0 8px;
}

.cert-status-list {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 14px;
}

.cert-label { font-weight: 600; margin-right: 6px; }
.cert-ok { color: var(--green-deep); margin-right: 8px; }
.cert-missing { color: var(--red); margin-right: 8px; }

/* ----------------------------------------------------------------------
   AI-inferred relationships
   ---------------------------------------------------------------------- */
.ai-tag {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--blue-soft);
    color: #2C4A54;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 6px;
    font-weight: 600;
}

.badge-confirmed { background: #E6EEE3; color: var(--green-deep); }
.badge-pending { background: var(--brass-soft); color: #6B4E1E; }

.panel-divider {
    border-top: 1px solid var(--line);
    margin: 22px 0;
}

/* ----------------------------------------------------------------------
   Document library
   ---------------------------------------------------------------------- */
.doc-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.doc-card {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: var(--paper-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    color: var(--ink);
    box-shadow: var(--shadow-card);
}
.doc-card:hover { border-color: var(--brass); text-decoration: none; }

.doc-card-icon { font-size: 28px; line-height: 1; flex-shrink: 0; }

.doc-card-title { font-weight: 600; font-size: 14.5px; margin-bottom: 4px; }
.doc-card-meta {
    font-size: 12.5px;
    color: var(--ink-soft);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.doc-card-date { color: #A39B85; }

.doc-preview-image {
    max-width: 100%;
    max-height: 420px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    display: block;
    margin-bottom: 4px;
}
.doc-preview-pdf {
    width: 100%;
    height: 60vh;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 4px;
}

@media (min-width: 640px) {
    .doc-grid { grid-template-columns: 1fr 1fr; }
}

/* ----------------------------------------------------------------------
   Photo gallery
   ---------------------------------------------------------------------- */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.photo-card {
    display: block;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--paper-card);
    border: 1px solid var(--line);
    color: var(--ink);
}
.photo-card:hover { border-color: var(--brass); text-decoration: none; }
.photo-card img { width: 100%; height: 140px; object-fit: cover; display: block; }
.photo-card-caption { font-size: 12px; padding: 6px 8px; color: var(--ink-soft); }

/* ----------------------------------------------------------------------
   Voice memories
   ---------------------------------------------------------------------- */
.audio-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.audio-row-title { font-weight: 600; font-size: 15px; }
.audio-row audio { width: 100%; }

@media (min-width: 640px) {
    .audio-row { flex-direction: row; align-items: center; justify-content: space-between; }
    .audio-row audio { width: 280px; }
}

/* ----------------------------------------------------------------------
   Family stories
   ---------------------------------------------------------------------- */
.story-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.story-card {
    display: block;
    background: var(--paper-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    color: var(--ink);
    box-shadow: var(--shadow-card);
}
.story-card:hover { border-color: var(--brass); text-decoration: none; }
.story-card-cover { height: 140px; overflow: hidden; }
.story-card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.story-card-body { padding: 14px 16px; }
.story-card-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; margin-bottom: 4px; }

.story-cover-hero {
    width: 100%;
    max-height: 320px;
    object-fit: cover;
    display: block;
}

.story-toolbar { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }

.story-body { font-size: 15px; line-height: 1.7; }
.story-body h3 { font-size: 19px; margin: 20px 0 8px; }
.story-body p { margin: 0 0 14px; }
.story-body ul { margin: 0 0 14px; padding-left: 22px; }
.story-body blockquote {
    margin: 0 0 14px;
    padding: 8px 16px;
    border-left: 3px solid var(--brass);
    background: var(--paper);
    color: var(--ink-soft);
    font-style: italic;
}

@media (min-width: 640px) {
    .story-grid { grid-template-columns: 1fr 1fr; }
}

/* ----------------------------------------------------------------------
   Settings — theme swatches
   ---------------------------------------------------------------------- */
.theme-swatch-row {
    display: flex;
    gap: 12px;
    margin: 10px 0 4px;
    flex-wrap: wrap;
}

.theme-swatch {
    width: 64px;
    height: 44px;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid var(--line);
    background: var(--paper);
    position: relative;
    overflow: hidden;
}
.theme-swatch::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 16px;
    background: var(--green);
}
.theme-swatch::after {
    content: "";
    position: absolute;
    bottom: 6px; right: 6px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--brass);
}
.theme-swatch:hover { border-color: var(--brass); }

/* ----------------------------------------------------------------------
   Theme variants (Settings > Appearance)
   Each theme overrides the same CSS custom properties the whole
   stylesheet already reads from, so no other rule needs to change.
   ---------------------------------------------------------------------- */
[data-theme="midnight-navy"] {
    --ink: #232733;
    --ink-soft: #5B6376;
    --paper: #EDEFF4;
    --paper-card: #FFFFFF;
    --line: #D6DAE4;
    --green: #1F3A5F;
    --green-deep: #16283F;
    --brass: #7C93B8;
    --brass-soft: #DCE4EF;
    --red: #A23E3E;
    --red-soft: #F6E4E1;
    --blue-soft: #E4EDF0;
}

[data-theme="terracotta"] {
    --ink: #3A2A20;
    --ink-soft: #7A6353;
    --paper: #FBF1E7;
    --paper-card: #FFFDF9;
    --line: #E8D3BC;
    --green: #B5502E;
    --green-deep: #8A3A20;
    --brass: #D98F4E;
    --brass-soft: #F3DCC0;
    --red: #A23E3E;
    --red-soft: #F6E4E1;
    --blue-soft: #EFE6DC;
}

[data-theme="slate-blue"] {
    --ink: #26303B;
    --ink-soft: #5E6C7A;
    --paper: #EEF2F5;
    --paper-card: #FFFFFF;
    --line: #D3DCE3;
    --green: #3E5C76;
    --green-deep: #2C4457;
    --brass: #8FA6B8;
    --brass-soft: #DCE6EC;
    --red: #A23E3E;
    --red-soft: #F6E4E1;
    --blue-soft: #E1EAF0;
}

/* ----------------------------------------------------------------------
   Forum
   ---------------------------------------------------------------------- */
.forum-list { display: flex; flex-direction: column; gap: 10px; }

.forum-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: var(--paper-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px 16px;
    color: var(--ink);
    box-shadow: var(--shadow-card);
}
.forum-card:hover { border-color: var(--brass); text-decoration: none; }
.forum-card-title { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.forum-card-stats { text-align: right; font-size: 12.5px; color: var(--ink-soft); flex-shrink: 0; }

.forum-post { padding: 4px 0; }
.forum-post-reply {
    margin-top: 10px;
    padding: 10px 0 0 16px;
    border-top: 1px dashed var(--line);
}

.forum-post-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}
.forum-post-author { font-weight: 600; font-size: 14px; }
.forum-post-time { font-size: 12px; color: #A39B85; }
.forum-post-body { font-size: 14.5px; line-height: 1.6; }

.forum-attachment {
    display: inline-block;
    margin-top: 6px;
    font-size: 13px;
}

.forum-post-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.forum-like-btn {
    background: none;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 12.5px;
    cursor: pointer;
    color: var(--ink-soft);
}
.forum-like-btn-active {
    background: var(--brass-soft);
    border-color: var(--brass);
    color: var(--green-deep);
}

.forum-replies { margin-top: 4px; }

.forum-reply-form {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ----------------------------------------------------------------------
   Chat
   ---------------------------------------------------------------------- */
.chat-wrap {
    display: flex;
    flex-direction: column;
    height: 65vh;
    min-height: 360px;
    background: var(--paper-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message {
    max-width: 80%;
    background: var(--paper);
    border-radius: 10px;
    padding: 8px 12px;
    align-self: flex-start;
}
.chat-message-mine {
    align-self: flex-end;
    background: var(--brass-soft);
}

.chat-message-meta {
    display: flex;
    gap: 8px;
    font-size: 11.5px;
    color: var(--ink-soft);
    margin-bottom: 2px;
}
.chat-message-author { font-weight: 600; }
.chat-message-body { font-size: 14px; line-height: 1.5; word-break: break-word; }

.chat-form {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--line);
    background: var(--paper-card);
}
.chat-form textarea {
    flex: 1;
    resize: none;
    min-height: 42px;
    max-height: 120px;
}

@media (min-width: 640px) {
    .chat-message { max-width: 60%; }
}

/* ----------------------------------------------------------------------
   Calendar
   ---------------------------------------------------------------------- */
.calendar-nav { display: flex; align-items: center; gap: 12px; }

.calendar-list { display: flex; flex-direction: column; gap: 8px; }

.calendar-day-row {
    display: flex;
    gap: 14px;
    background: var(--paper-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 16px;
}

.calendar-day-num {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    color: var(--green-deep);
    width: 32px;
    flex-shrink: 0;
    text-align: center;
}

.calendar-day-items { flex: 1; display: flex; flex-direction: column; gap: 8px; }

.calendar-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--ink);
    flex-wrap: wrap;
}
.calendar-item:hover { text-decoration: underline; }

/* ----------------------------------------------------------------------
   Timeline
   ---------------------------------------------------------------------- */
.timeline-list { list-style: none; margin: 0; padding: 0; }

.timeline-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}
.timeline-item:last-child { border-bottom: none; }

.timeline-icon { font-size: 18px; flex-shrink: 0; width: 24px; text-align: center; }

/* ----------------------------------------------------------------------
   Family map — combined Leaflet pin map
   ---------------------------------------------------------------------- */
.family-map-host {
    height: 60vh;
    min-height: 360px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    overflow: hidden;
    margin-bottom: 16px;
}
.family-map-host .leaflet-popup-content a { font-weight: 600; }

@media (min-width: 640px) {
    .family-map-host { height: 68vh; }
}

/* ----------------------------------------------------------------------
   Sidebar logo (Settings > Appearance upload) and notification bell
   ---------------------------------------------------------------------- */
.brand-logo { height: 32px; width: auto; max-width: 150px; object-fit: contain; border-radius: 4px; flex-shrink: 0; }

.topbar-spacer { flex: 1; }

.notif-bell {
    position: relative;
    font-size: 20px;
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
}
.notif-bell:hover { background: var(--paper); text-decoration: none; }

.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}

/* ----------------------------------------------------------------------
   Landing page
   ---------------------------------------------------------------------- */
.landing-body { background: var(--paper); }

.landing-hero {
    background: linear-gradient(160deg, var(--green-deep), var(--green));
    color: #F5EFE2;
    padding: 64px 20px 56px;
    text-align: center;
}
.landing-hero-inner { max-width: 640px; margin: 0 auto; }

.landing-logo { height: 72px; width: auto; max-width: 260px; object-fit: contain; border-radius: 8px; margin: 0 auto 18px; display: block; }
.landing-logo-mark {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--brass);
    color: var(--green-deep);
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
}

.landing-hero h1 { font-size: 32px; color: #F5EFE2; margin-bottom: 10px; }
.landing-tagline { font-size: 16px; color: #D8CFB6; margin-bottom: 28px; }

.landing-cta { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.landing-cta-ghost { background: rgba(245, 239, 226, 0.1); border-color: rgba(245, 239, 226, 0.3); color: #F5EFE2; }
.landing-cta-ghost:hover { background: rgba(245, 239, 226, 0.18); }

.landing-features { padding: 48px 20px; }
.landing-features-inner { max-width: 1000px; margin: 0 auto; }

.feature-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.feature-card {
    background: var(--paper-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px 20px;
    box-shadow: var(--shadow-card);
}
.feature-icon { font-size: 28px; margin-bottom: 10px; }
.feature-card h3 { font-size: 17px; margin-bottom: 6px; }
.feature-card p { font-size: 13.5px; color: var(--ink-soft); margin: 0; line-height: 1.6; }

.landing-footer {
    text-align: center;
    padding: 24px 20px 40px;
    color: var(--ink-soft);
    font-size: 12.5px;
}

@media (min-width: 640px) {
    .landing-hero { padding: 90px 20px 72px; }
    .landing-cta { flex-direction: row; justify-content: center; }
    .feature-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 960px) {
    .feature-grid { grid-template-columns: repeat(3, 1fr); }
}

.rich-text-content { font-size: 14.5px; line-height: 1.65; }
.rich-text-content p { margin: 0 0 10px; }
.rich-text-content p:last-child { margin-bottom: 0; }
.rich-text-content ul, .rich-text-content ol { margin: 0 0 10px; padding-left: 22px; }
.rich-text-content a { text-decoration: underline; }

/* ----------------------------------------------------------------------
   Fundraising
   ---------------------------------------------------------------------- */
.fundraiser-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.fundraiser-card {
    display: block;
    background: var(--paper-card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    color: var(--ink);
    box-shadow: var(--shadow-card);
}
.fundraiser-card:hover { border-color: var(--brass); text-decoration: none; }
.fundraiser-card-cover { height: 130px; overflow: hidden; }
.fundraiser-card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fundraiser-card-body { padding: 14px 16px; }
.fundraiser-card-title {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.fundraiser-progress-track {
    height: 8px;
    background: var(--line);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}
.fundraiser-progress-track-lg { height: 12px; margin: 4px 0 10px; }
.fundraiser-progress-fill { height: 100%; background: var(--brass); border-radius: 4px; }

.fundraiser-stats-row {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 13.5px;
    color: var(--ink-soft);
}

.gateway-choice-row { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 14px; }
.gateway-choice {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
}
.gateway-choice:has(input:checked) { border-color: var(--brass); background: var(--brass-soft); }

@media (min-width: 640px) {
    .fundraiser-grid { grid-template-columns: 1fr 1fr; }
    .gateway-choice-row { flex-direction: row; flex-wrap: wrap; }
    .gateway-choice { flex: 1; min-width: 160px; }
}

/* ----------------------------------------------------------------------
   Direct messages
   ---------------------------------------------------------------------- */
.conversation-list { list-style: none; margin: 0; padding: 0; }

.conversation-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 8px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
}
.conversation-row:last-child { border-bottom: none; }
.conversation-row:hover { background: var(--paper); text-decoration: none; }
.conversation-row-unread .conversation-name { font-weight: 700; }

.conversation-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--brass);
    color: var(--green-deep);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.conversation-meta { flex: 1; min-width: 0; }
.conversation-name { font-size: 14.5px; margin-bottom: 2px; }
.conversation-preview {
    font-size: 13px;
    color: var(--ink-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

/* ----------------------------------------------------------------------
   Responsive refinements
   ---------------------------------------------------------------------- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -22px;
    padding: 0 22px;
}

.btn { min-height: 42px; }
.btn-small { min-height: 34px; }

@media (max-width: 420px) {
    .auth-card { padding: 28px 20px; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
    .sidebar { transition: none; }
}
