/* ════════════════════════════════════════════════════════════════════
   Ngiya Family — one stylesheet, no frameworks
   Palette: paper cream, deep leaf green, warm coral, five avatar tones
   ════════════════════════════════════════════════════════════════════ */

:root {
    --paper: #f5f3ea;
    --surface: #fffdf7;
    --surface-2: #fbf9f1;
    --ink: #26332a;
    --ink-soft: #55605a;
    --muted: #7a8074;
    --accent: #7c3aed;
    --accent-deep: #5b21b6;
    --accent-wash: #ede9fe;
    --teal: #0891b2;
    --coral: #f43f5e;
    --line: #8b8b9e;
    --border: #e4e1d2;
    --border-strong: #d3cfba;
    --danger: #dc2626;
    --radius: 18px;
    --radius-small: 12px;
    --shadow: 0 18px 40px -18px rgba(91, 33, 182, 0.28);
    --font-display: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--paper);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: 0.01em; }
h1 { font-size: clamp(1.7rem, 3vw, 2.3rem); margin: 0 0 0.3rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.6rem; }
h3 { font-size: 0.95rem; margin: 0 0 0.5rem; }

a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.small-note { font-size: 0.85rem; }

/* ── Buttons & chips ────────────────────────────────────────────────── */

.btn-primary, .btn-ghost, .chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border-radius: 999px;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    padding: 0.62rem 1.25rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    text-decoration: none;
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 10px 22px -12px rgba(124, 58, 237, 0.65);
}
.btn-primary:hover { background: var(--accent-deep); text-decoration: none; transform: translateY(-1px); }

.btn-ghost {
    background: transparent;
    color: var(--accent-deep);
    border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--accent-wash); text-decoration: none; }

.btn-primary.small, .btn-ghost.small { padding: 0.4rem 0.9rem; font-size: 0.83rem; }

.chip {
    background: var(--surface);
    border-color: var(--border);
    color: var(--ink-soft);
    font-size: 0.82rem;
    padding: 0.45rem 0.85rem;
}
.chip:hover { border-color: var(--accent); color: var(--accent-deep); text-decoration: none; }

.link-danger {
    background: none;
    border: none;
    color: var(--danger);
    font: inherit;
    font-size: 0.83rem;
    cursor: pointer;
    padding: 0;
    text-decoration: underline dotted;
}
.link-danger:hover { color: #8f3f33; }

.code-chip {
    background: var(--accent-wash);
    border-radius: 8px;
    padding: 0.08rem 0.45rem;
    white-space: nowrap;
}
.code-chip:hover { text-decoration: none; background: #ddd6fe; }

/* ════════════════════════════════════════════════════════════════════
   Auth pages (login / register)
   Vivid midnight canvas with floating colour orbs
   ════════════════════════════════════════════════════════════════════ */

.auth-page {
    background: #0a0a1e;
}

.auth-wrap {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    min-height: 100vh;
}

.auth-hero {
    position: relative;
    overflow: hidden;
    color: #e8e0f0;
    padding: clamp(2.5rem, 6vw, 5rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: #0c0a1e;
}
.auth-hero::before {
    content: "";
    position: absolute;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: rgba(124, 58, 237, 0.16);
    top: -10%;
    right: -6%;
    filter: blur(70px);
    pointer-events: none;
}
.auth-hero::after {
    content: "";
    position: absolute;
    width: 340px;
    height: 340px;
    border-radius: 50%;
    background: rgba(236, 72, 153, 0.10);
    bottom: -12%;
    left: -4%;
    filter: blur(60px);
    pointer-events: none;
}

.hero-eyebrow {
    font-size: 0.72rem;
    letter-spacing: 0.38em;
    color: #a78bfa;
    margin: 0 0 1.4rem;
    text-transform: uppercase;
    font-weight: 700;
    position: relative;
    z-index: 1;
}

.auth-hero h1 {
    font-size: clamp(2.2rem, 4.2vw, 3.5rem);
    line-height: 1.08;
    margin: 0 0 1.2rem;
    color: #fff;
    position: relative;
    z-index: 1;
    text-shadow: 0 4px 40px rgba(124, 58, 237, 0.35);
}

.hero-copy {
    color: #b8b0d0;
    max-width: 34rem;
    font-size: 1.05rem;
    line-height: 1.65;
    position: relative;
    z-index: 1;
}

.hero-motif {
    margin-top: 3rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    color: #8b7ab0;
    position: relative;
    z-index: 1;
}
.hero-motif span {
    font-size: 1.8rem;
    color: #06b6d4;
    filter: drop-shadow(0 0 10px rgba(6, 182, 212, 0.5));
}
.hero-motif i {
    width: 50px;
    height: 1px;
    background: rgba(6, 182, 212, 0.45);
}

.auth-card {
    background: #faf8ff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(2rem, 5vw, 4rem);
    border-left: 3px solid #ede9fe;
}

.auth-brand {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    color: #1a1030;
    margin-bottom: 2rem;
    letter-spacing: 0.01em;
}
.auth-brand span {
    color: #7c3aed;
    margin-right: 0.35rem;
    font-size: 1.4rem;
}
.auth-brand:hover { text-decoration: none; }

.auth-card h2 {
    font-size: 1.55rem;
    margin: 0 0 0.35rem;
    color: #1a1030;
}
.auth-sub {
    color: #6b6580;
    margin: 0 0 1.6rem;
    font-size: 0.95rem;
}

.auth-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    border-radius: var(--radius-small);
    padding: 0.75rem 1rem;
    font-size: 0.92rem;
    font-weight: 500;
}

.auth-form { display: flex; flex-direction: column; gap: 1.1rem; }
.auth-form label { display: flex; flex-direction: column; gap: 0.4rem; }
.auth-form label span {
    font-size: 0.78rem;
    font-weight: 700;
    color: #4c1d95;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.auth-form input, .stack-form input, .stack-form select, .stack-form textarea,
.connect-form input {
    font: inherit;
    color: #1a1030;
    background: #fff;
    border: 1.5px solid #e0daf0;
    border-radius: var(--radius-small);
    padding: 0.78rem 1rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.auth-form input:focus, .stack-form input:focus, .stack-form select:focus,
.stack-form textarea:focus, .connect-form input:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12), 0 0 0 1px rgba(124, 58, 237, 0.25);
}
.auth-form input::placeholder {
    color: #a8a0b8;
}

.auth-form .btn-primary {
    margin-top: 0.6rem;
    justify-content: center;
    background: #7c3aed;
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0.85rem 1.4rem;
    border: none;
    border-radius: 14px;
    box-shadow: 0 14px 32px -10px rgba(124, 58, 237, 0.5);
    letter-spacing: 0.02em;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.auth-form .btn-primary:hover {
    background: #8b5cf6;
    transform: translateY(-2px);
    box-shadow: 0 18px 40px -10px rgba(124, 58, 237, 0.65);
}

.auth-alt {
    margin-top: 1.6rem;
    color: #4c4460;
    font-size: 0.93rem;
}
.auth-alt a {
    color: #7c3aed;
    font-weight: 700;
}
.auth-alt a:hover {
    color: #5b21b6;
}
.auth-note {
    margin-top: 1rem;
    font-size: 0.8rem;
    color: #8880a0;
    line-height: 1.5;
}

/* ════════════════════════════════════════════════════════════════════
   Admin panel
   ════════════════════════════════════════════════════════════════════ */

.admin-page { background: var(--paper); }

.admin-bar {
    background: #1a1030;
    border-bottom: 1px solid rgba(124, 58, 237, 0.25);
}
.admin-bar-inner {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem clamp(1rem, 3vw, 1.6rem);
}
.admin-brand {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.12rem;
    color: #e8e0f0;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}
.admin-brand em { font-style: normal; color: #a78bfa; }
.admin-brand:hover { text-decoration: none; color: #fff; }
.admin-brand .brand-mark {
    background: #7c3aed;
    box-shadow: 0 4px 12px -4px rgba(124, 58, 237, 0.5);
}
.admin-bar-end { display: flex; align-items: center; gap: 0.8rem; }
.admin-user { color: #b8b0d0; font-size: 0.88rem; }
.admin-bar .nav-logout { color: #b8b0d0; border-color: rgba(184, 176, 208, 0.3); }
.admin-bar .nav-logout:hover { background: rgba(124, 58, 237, 0.2); color: #e8e0f0; border-color: #7c3aed; }

.admin-tabs {
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 15;
}
.admin-tabs-inner {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    gap: 0.15rem;
    padding: 0 clamp(1rem, 3vw, 1.6rem);
    overflow-x: auto;
}
.admin-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.7rem 1.1rem;
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 2.5px solid transparent;
    white-space: nowrap;
    transition: color 0.15s ease, border-color 0.15s ease;
}
.admin-tab:hover { color: var(--accent); text-decoration: none; }
.admin-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.admin-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #f43f5e;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0 5px;
}

.admin-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.admin-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.3rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.admin-stat-card:first-child {
    border-left: 3px solid var(--accent);
}
.admin-stat-num {
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}
.admin-stat-label {
    font-size: 0.82rem;
    color: var(--muted);
}

.admin-section-head {
    margin-bottom: 1.2rem;
}

.admin-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.admin-table thead th {
    background: var(--surface-2);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: left;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.admin-table tbody td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: var(--surface-2); }
.admin-table small { font-size: 0.78rem; }

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}
.admin-owner-form {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.admin-owner-select {
    font: inherit;
    font-size: 0.82rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-small);
    background: var(--surface);
    max-width: 155px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.admin-danger {
    color: var(--danger) !important;
    border-color: #fecaca !important;
}
.admin-danger:hover {
    background: #fef2f2 !important;
    border-color: var(--danger) !important;
}

.admin-connect-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.3rem 1.4rem;
    margin-bottom: 1rem;
}
.admin-connect-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    align-items: flex-end;
}
.admin-connect-fields label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1;
    min-width: 180px;
}
.admin-connect-fields label span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-soft);
}
.admin-connect-fields select {
    font: inherit;
    font-size: 0.9rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-small);
    padding: 0.55rem 0.8rem;
}
.admin-connect-fields .btn-primary { align-self: flex-end; }

.admin-role-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: #ede9fe;
    color: #5b21b6;
    border-radius: 999px;
    padding: 0.1rem 0.55rem;
    margin-left: 0.3rem;
    vertical-align: middle;
}

.admin-forms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.2rem;
    margin-bottom: 1.6rem;
}
.admin-create-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.3rem 1.4rem;
}
.admin-form-title {
    font-size: 1.1rem;
    margin: 0 0 0.3rem;
    color: var(--ink);
}
.admin-stack-form {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 0.4rem;
}
.admin-stack-form label {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.admin-stack-form label > span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-soft);
}
.admin-stack-form input,
.admin-stack-form select {
    font: inherit;
    font-size: 0.9rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-small);
    padding: 0.55rem 0.8rem;
}
.admin-stack-form input:focus,
.admin-stack-form select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
    outline: none;
}
.admin-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.7rem;
}
.admin-checkbox-label {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 0.5rem !important;
    font-size: 0.9rem;
    color: var(--ink-soft);
    cursor: pointer;
}
.admin-checkbox-label input {
    width: auto;
    accent-color: var(--accent);
}

/* Admin action buttons */
.admin-actions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1.6rem;
}
.admin-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--ink);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 2px 8px -4px rgba(91, 33, 182, 0.15);
}
.admin-action-btn:hover {
    background: var(--accent-wash);
    border-color: var(--accent);
    color: var(--accent-deep);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px -6px rgba(91, 33, 182, 0.25);
}
.admin-action-btn:active {
    transform: translateY(0);
}
.admin-action-btn-icon {
    font-size: 1.1rem;
    line-height: 1;
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(38, 51, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: modal-fade-in 0.2s ease;
}
.modal-overlay.active {
    display: flex;
}
@keyframes modal-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes modal-slide-up {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Modal dialog */
.modal {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 25px 60px -20px rgba(38, 51, 42, 0.4);
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modal-slide-up 0.25s ease;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.4rem 1.6rem 1rem;
    border-bottom: 1px solid var(--border);
}
.modal-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--ink);
    margin: 0;
}
.modal-subtitle {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 0.2rem 0 0;
}
.modal-close {
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--muted);
    font-size: 1.3rem;
    line-height: 1;
    transition: all 0.15s ease;
}
.modal-close:hover {
    background: var(--surface-2);
    color: var(--ink);
}
.modal-body {
    padding: 1.4rem 1.6rem;
}
.modal-body .admin-stack-form {
    margin-top: 0;
}
.modal-footer {
    padding: 1rem 1.6rem 1.4rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
}

@media (max-width: 640px) {
    .admin-stat-grid { grid-template-columns: repeat(2, 1fr); }
    .admin-connect-fields { flex-direction: column; }
    .admin-connect-fields label { min-width: 0; }
    .admin-bar-inner { flex-wrap: wrap; }
    .admin-brand { font-size: 0.95rem; }
    .modal { max-width: 100%; margin: 0.5rem; }
    .modal-header { padding: 1.2rem 1.2rem 0.8rem; }
    .modal-body { padding: 1rem 1.2rem; }
    .modal-footer { padding: 0.8rem 1.2rem 1.2rem; }
    .modal-title { font-size: 1rem; }
}

/* ════════════════════════════════════════════════════════════════════
   PWA install banner
   ════════════════════════════════════════════════════════════════════ */

.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 900;
    padding: 0.8rem 1rem;
    padding-bottom: calc(0.8rem + env(safe-area-inset-bottom, 0px));
    background: #2d5a42;
    color: #fff;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}
.pwa-install-banner.visible {
    transform: translateY(0);
}
.pwa-install-inner {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    max-width: 600px;
    margin: 0 auto;
}
.pwa-install-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    flex-shrink: 0;
}
.pwa-install-text {
    flex: 1;
    min-width: 0;
}
.pwa-install-text strong {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
}
.pwa-install-text span {
    display: block;
    font-size: 0.75rem;
    opacity: 0.85;
    line-height: 1.3;
}
.pwa-install-btn {
    flex-shrink: 0;
    padding: 0.5rem 1.2rem;
    background: #fff;
    color: #3e7d5c;
    border: none;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}
.pwa-install-btn:hover {
    background: #f0f0f0;
    transform: scale(1.05);
}
.pwa-install-dismiss {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease;
}
.pwa-install-dismiss:hover {
    background: rgba(255, 255, 255, 0.3);
}

@media (max-width: 480px) {
    .pwa-install-inner { gap: 0.6rem; }
    .pwa-install-icon { width: 32px; height: 32px; }
    .pwa-install-text strong { font-size: 0.82rem; }
    .pwa-install-btn { padding: 0.45rem 1rem; font-size: 0.8rem; }
}

/* ════════════════════════════════════════════════════════════════════
   Family map page (Leaflet + OpenStreetMap)
   ════════════════════════════════════════════════════════════════════ */

.map-page {
    position: relative;
    padding: 0;
    max-width: none;
}
.family-map {
    width: 100%;
    height: calc(100vh - var(--header-h, 60px));
    height: calc(100dvh - var(--header-h, 60px));
    z-index: 0;
}

/* Floating "my location" button for touch users. */
.map-locate-btn {
    position: absolute;
    bottom: 1.4rem;
    left: 0.7rem;
    z-index: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.95rem;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    color: var(--accent-deep);
    font: inherit;
    font-size: 0.83rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow);
}
.map-locate-btn:hover { background: var(--accent-wash); border-color: var(--accent); }

/* Location editor overlay (top-right corner of the map) */
.map-location-form {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 400;
    background: rgba(255, 253, 247, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    box-shadow: var(--shadow);
    width: 280px;
    max-width: calc(100vw - 2rem);
}
.map-form-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    width: 100%;
    background: none;
    border: none;
    padding: 0 0 0.65rem;
    cursor: pointer;
    font: inherit;
    text-align: left;
}
.map-form-toggle:hover .map-form-title { color: var(--accent-deep); }
.map-form-chevron {
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1;
    transition: transform 0.18s ease;
    flex-shrink: 0;
}
.map-location-form.folded .map-form-chevron { transform: rotate(-90deg); }
.map-location-form.folded .map-form,
.map-location-form.folded .map-form-status { display: none; }
.map-location-form.folded .map-form-toggle { padding-bottom: 0; }
.map-form-title {
    font-size: 0.95rem;
    margin: 0;
    color: var(--ink);
    font-weight: 600;
}
.map-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.map-form select,
.map-form input[type="text"] {
    font: inherit;
    font-size: 0.85rem;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-small);
    padding: 0.5rem 0.7rem;
}
.map-form select:focus,
.map-form input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
    outline: none;
}
.map-form-status {
    margin: 0.4rem 0 0;
    font-size: 0.78rem;
    min-height: 1.2em;
}

/* Leaflet popup customisation */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius-small) !important;
    box-shadow: var(--shadow) !important;
}
.leaflet-popup-content {
    margin: 0.8rem 1rem !important;
    font-family: var(--font-body) !important;
    font-size: 0.85rem !important;
    line-height: 1.5 !important;
}
.map-popup {
    min-width: 160px;
}
.map-popup strong {
    font-size: 0.95rem;
    color: var(--ink);
    display: block;
    margin-bottom: 0.15rem;
}
.map-popup .muted {
    display: block;
    font-size: 0.78rem;
    line-height: 1.4;
}
.map-dir-btn {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.4rem 1rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}
.map-dir-btn:hover {
    background: var(--accent-deep);
    transform: translateY(-1px);
}

/* Coordinates display */
.map-coords-display {
    font-size: 0.78rem;
    color: var(--muted);
    margin: 0;
    padding: 0.35rem 0.5rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    font-family: monospace;
    text-align: center;
}

/* Drop pin mode button states */
.map-drop-active {
    background: var(--coral) !important;
    border-color: var(--coral) !important;
    color: #fff !important;
}
.map-drop-active:hover {
    background: #e11d48 !important;
}

/* Map cursor during placement mode */
.map-placing {
    cursor: crosshair !important;
}
.map-placing .leaflet-container {
    cursor: crosshair !important;
}

/* Save button disabled state */
.map-save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.map-save-btn:not(:disabled) {
    background: var(--accent);
    color: #fff;
}

@media (max-width: 640px) {
    /* The location editor floats over the map as a compact card so the
     * map and the form both stay visible and tappable on a phone. */
    .map-location-form {
        position: absolute;
        top: 0.6rem;
        right: 0.6rem;
        left: 0.6rem;
        width: auto;
        max-width: none;
        max-height: 55%;
        overflow-y: auto;
        z-index: 1100;
    }
}

/* ════════════════════════════════════════════════════════════════════
   Welcome dashboard (home page greeting)
   ════════════════════════════════════════════════════════════════════ */

.welcome-dashboard {
    margin-bottom: 1.3rem;
    padding: 0.4rem 0 1rem;
    background: transparent;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
}

.welcome-greeting {
    margin-bottom: 0.7rem;
}
.welcome-greeting h1 {
    font-size: clamp(1.3rem, 2.6vw, 1.65rem);
    margin: 0 0 0.15rem;
    color: var(--ink);
}
.welcome-date {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.welcome-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}
.stat-pill {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.45rem 1rem;
}
.stat-number {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}
.stat-label {
    font-size: 0.82rem;
    color: var(--ink-soft);
}

.welcome-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}
.quick-action {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.1rem;
    background: var(--accent-wash);
    border: 1px solid #ddd6fe;
    border-radius: 999px;
    color: var(--accent-deep);
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.quick-action:hover {
    background: #ddd6fe;
    border-color: var(--accent);
    transform: translateY(-1px);
    text-decoration: none;
}
.quick-action-icon {
    font-size: 1rem;
    opacity: 0.8;
}
.quick-action-label {
    white-space: nowrap;
}

/* ════════════════════════════════════════════════════════════════════
   App shell
   ════════════════════════════════════════════════════════════════════ */

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 253, 247, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.nav-inner {
    max-width: 1240px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem clamp(1rem, 3vw, 1.6rem);
}

.brand {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.12rem;
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}
.brand em { font-style: normal; color: var(--accent-deep); }
.brand:hover { text-decoration: none; color: var(--ink); }
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 11px;
    background: var(--accent);
    color: #fff;
    font-size: 1.02rem;
    box-shadow: 0 6px 14px -6px rgba(91, 33, 182, 0.55);
}
.brand-logo {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    object-fit: contain;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}
.auth-brand .brand-logo { margin-right: 0.45rem; }
.brand-logo-admin {
    background: #fff;
    padding: 3px;
    box-sizing: border-box;
    border-radius: 10px;
    box-shadow: 0 4px 12px -4px rgba(124, 58, 237, 0.5);
}

.family-switch { display: flex; align-items: center; }
.family-switch select {
    font: inherit;
    font-size: 0.88rem;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    border-radius: 999px;
    padding: 0.35rem 0.8rem;
    cursor: pointer;
}

.header-nav {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.22rem;
}
.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
    padding: 0.42rem 1.05rem;
    border-radius: 999px;
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: var(--accent-wash); color: var(--accent-deep); text-decoration: none; }
.nav-link.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 6px 14px -7px rgba(91, 33, 182, 0.6);
}
.nav-ico { font-size: 0.92rem; opacity: 0.9; }

.nav-end { display: flex; align-items: center; gap: 0.55rem; }
.nav-user { display: inline-flex; align-items: center; gap: 0.5rem; }
.nav-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #f6ddd5;
    color: #a34d3d;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.78rem;
}
.nav-user-name { font-size: 0.88rem; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
.nav-logout {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--muted);
    border: 1px solid var(--border-strong);
    padding: 0.38rem 0.85rem;
    border-radius: 999px;
    white-space: nowrap;
}
.nav-logout:hover { background: var(--accent-wash); color: var(--accent-deep); text-decoration: none; }

.app-main { max-width: 1240px; margin: 0 auto; padding: clamp(1.2rem, 3vw, 2.2rem); }

.notice {
    background: var(--accent-wash);
    border: 1px solid #ddd6fe;
    color: var(--accent-deep);
    border-radius: var(--radius-small);
    padding: 0.75rem 1.1rem;
    margin: 0 0 1.2rem;
}

.view-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.6rem;
}
.view-heading p { margin: 0.2rem 0 0; color: var(--ink-soft); }
.eyebrow {
    font-size: 0.72rem;
    letter-spacing: 0.28em;
    color: var(--accent);
    font-weight: 700;
    margin: 0 0 0.4rem;
}

/* ── Empty state ────────────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 3.5rem 1.5rem;
}
.empty-icon { font-size: 2.4rem; color: var(--accent); display: block; margin-bottom: 0.8rem; }
.empty-state p { color: var(--muted); max-width: 30rem; margin: 0.4rem auto 1.4rem; }

/* ════════════════════════════════════════════════════════════════════
   The tree
   ════════════════════════════════════════════════════════════════════ */

.tree-wrap { position: relative; }

.tree-scroll {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

/* Stage carries the diagram's scaled size so the scroll container can pan,
 * and centers the tree when it fits the viewport. */
.tree-stage { position: relative; margin-inline: auto; width: max-content; }

.tree-diagram {
    position: absolute;
    top: 0;
    left: 0;
    width: max-content;
    transform-origin: 0 0;
    padding: 1.6rem 2.2rem 2.6rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20'%3E%3Ccircle cx='1' cy='1' r='1' fill='%23e4e1d2'/%3E%3C/svg%3E");
    background-size: 20px 20px;
}

/* Zoom controls float over the scroll area (extended view only). */
.zoom-toolbar {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    padding: 0.3rem 0.45rem;
    box-shadow: 0 12px 26px -12px rgba(91, 33, 182, 0.5);
}
.zoom-btn {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--ink-soft);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}
.zoom-btn:hover { background: var(--accent-wash); color: var(--accent-deep); }
.zoom-level {
    min-width: 3.4em;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}

.relationship-lines {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
    z-index: 1;
}
.relationship-lines .family-branch {
    fill: none;
    stroke: var(--line);
    stroke-width: 2.4px;
    stroke-linecap: square;
    stroke-linejoin: round;
}

.tree-level { position: relative; z-index: 2; margin-bottom: 2.6rem; }
.tree-level:last-child { margin-bottom: 0; }

.tree-level h2 {
    font-size: 0.72rem;
    font-family: var(--font-body);
    letter-spacing: 0.26em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 0.9rem;
}

.level-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
    gap: 1.3rem 1.8rem;
}

/* View toggle (nuclear / extended) + heading actions */
.heading-actions { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.view-toggle {
    display: inline-flex;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    padding: 0.25rem;
    box-shadow: 0 8px 18px -12px rgba(91, 33, 182, 0.4);
}
.seg {
    padding: 0.42rem 1rem;
    border-radius: 999px;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--ink-soft);
    white-space: nowrap;
}
.seg:hover { text-decoration: none; color: var(--accent-deep); }
.seg.active { background: var(--accent); color: #fff; }

/* ── Person cards ──────────────────────────────────────────────────── */

.tree-node.single { width: max-content; }

.tree-node.couple {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-start;
    width: max-content;
    gap: 0.55rem;
}

.couple-member { display: block; }

.couple-heart {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    margin-top: 44px;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: var(--surface);
    color: var(--coral);
    font-size: 17px;
    font-style: normal;
    line-height: 1;
    position: relative;
    z-index: 3;
    box-shadow: 0 6px 14px -8px rgba(91, 33, 182, 0.4);
}

.person-card {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 0.24rem;
    width: 132px;
    padding: 0.8rem 0.6rem 0.65rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 24px -16px rgba(91, 33, 182, 0.45);
    text-align: center;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.person-card:hover {
    transform: translateY(-2px);
    border-color: #c4b5fd;
    box-shadow: 0 16px 30px -16px rgba(91, 33, 182, 0.5);
    text-decoration: none;
}
.person-card strong { font-size: 0.84rem; line-height: 1.25; }
.person-card small { color: var(--muted); font-size: 0.71rem; }
.person-card .card-place { color: var(--teal); font-weight: 600; }
.person-card.deceased strong { color: var(--ink-soft); }
.person-card.deceased .avatar { filter: grayscale(0.55); opacity: 0.85; }
.person-card.deceased .card-photo { filter: grayscale(0.6); }
.person-card.deceased strong::after { content: " ✝"; color: var(--muted); font-weight: 400; }

/* Photo cards: the image fills the card, name and location float over a
 * soft dark tint at the bottom. */
.person-card.photo-card { padding: 0; overflow: hidden; }
.card-photo {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: cover;
}
.card-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 0.08rem;
    padding: 1.3rem 0.55rem 0.5rem;
    background: rgba(24, 33, 26, 0.82);
    color: #fff;
}
.card-caption strong { color: #fff; font-size: 0.82rem; }
.card-caption small { color: rgba(255, 255, 255, 0.82); font-size: 0.68rem; }
.card-caption .card-place { color: #ffd9c9; font-weight: 600; }
.person-card.photo-card .network-badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    margin-top: 0;
    background: rgba(226, 241, 244, 0.92);
    backdrop-filter: blur(4px);
}
/* Heart sits level with the middle of a photo card. */
.tree-node.couple:has(.photo-card) .couple-heart { margin-top: 72px; }

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.98rem;
    letter-spacing: 0.02em;
}
.avatar.big { width: 74px; height: 74px; font-size: 1.5rem; }

.avatar.coral { background: #f6ddd5; color: #a34d3d; }
.avatar.sage  { background: #dee9da; color: #4d7245; }
.avatar.gold  { background: #f4e4c3; color: #8a6a25; }
.avatar.blue  { background: #d9e5ee; color: #3c688f; }
.avatar.lilac { background: #e7ddf0; color: #6d5494; }

.network-badge {
    display: inline-block;
    margin-top: 0.2rem;
    font-size: 0.66rem;
    letter-spacing: 0.04em;
    color: var(--teal);
    background: #e2f1f4;
    border: 1px solid #c3dfe6;
    border-radius: 999px;
    padding: 0.12rem 0.55rem;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ════════════════════════════════════════════════════════════════════
   Dialogs / panels
   ════════════════════════════════════════════════════════════════════ */

dialog.overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    border: none;
    padding: clamp(0.8rem, 4vw, 2.5rem);
    background: rgba(29, 40, 34, 0.55);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    z-index: 50;
}

.panel {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.6rem 1.7rem;
    width: min(560px, 100%);
    max-height: 90vh;
    overflow-y: auto;
}

.panel-close {
    position: absolute;
    top: 0.75rem;
    right: 0.9rem;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink-soft);
    font-size: 1.05rem;
}
.panel-close:hover { background: var(--accent-wash); text-decoration: none; color: var(--accent-deep); }

.profile-head { display: flex; gap: 1.1rem; align-items: center; margin-bottom: 1rem; }
.profile-head h2 { margin: 0; font-size: 1.4rem; }
.profile-photo {
    width: 78px;
    height: 78px;
    border-radius: 22px;
    object-fit: cover;
    box-shadow: 0 12px 24px -12px rgba(91, 33, 182, 0.55);
    flex-shrink: 0;
}

/* ── Profile photo lightbox: tap the photo in the details panel to see
 * it full size. Sits above the profile dialog but below the side-nav
 * layers so the drawer still wins when pulled out. ───────────────── */
.profile-photo-btn {
    padding: 0;
    border: none;
    background: none;
    cursor: zoom-in;
    display: block;
    flex-shrink: 0;
    border-radius: 22px;
}
.profile-photo-btn .profile-photo { display: block; }
.profile-photo-btn:hover .profile-photo {
    box-shadow: 0 14px 30px -10px rgba(91, 33, 182, 0.8);
}
.photo-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1140;
    background: rgba(15, 12, 30, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(1rem, 4vw, 2.5rem);
    cursor: zoom-out;
}
.photo-lightbox[hidden] { display: none; }
.photo-lightbox img {
    max-width: min(94vw, 900px);
    max-height: 86vh;
    border-radius: 14px;
    object-fit: contain;
    background: var(--surface);
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.65);
}
.lightbox-close {
    position: absolute;
    top: calc(0.9rem + env(safe-area-inset-top, 0px));
    right: 1rem;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 1.15rem;
    cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.28); }
.profile-life { margin: 0.15rem 0 0.2rem; color: var(--ink-soft); font-size: 0.92rem; }
.profile-family { margin: 0; color: var(--muted); font-size: 0.85rem; }
.profile-contact {
    margin: 0.45rem 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
    font-size: 0.88rem;
    color: var(--ink-soft);
}
.profile-contact a { font-weight: 600; }

.photo-label span { display: block; margin-bottom: 0.45rem; }
.photo-preview {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    object-fit: cover;
    margin-bottom: 0.45rem;
    border: 1px solid var(--border);
}
.cross-hint { margin: 0.1rem 0 0; font-size: 0.82rem; }
.profile-notes {
    background: var(--surface-2);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-small) var(--radius-small) 0;
    padding: 0.7rem 0.95rem;
    font-size: 0.93rem;
    color: var(--ink-soft);
    margin: 0 0 1rem;
}

.profile-section { margin: 0.9rem 0; }
.relation-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.45rem; }
.relation-list li {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    font-size: 0.92rem;
}
.relation-type {
    font-size: 0.68rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent-deep);
    background: var(--accent-wash);
    border-radius: 999px;
    padding: 0.16rem 0.6rem;
    font-weight: 700;
}
.relation-list .inline-form { margin-left: auto; }

.panel-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 1.1rem; padding-top: 1rem; border-top: 1px dashed var(--border-strong); }

/* ── Forms inside panels ───────────────────────────────────────────── */

.form-panel h2 { font-size: 1.3rem; margin-bottom: 0.4rem; }
.form-context { color: var(--ink-soft); font-size: 0.93rem; margin: 0 0 1rem; }

.stack-form { display: flex; flex-direction: column; gap: 1rem; }
.stack-form label { display: flex; flex-direction: column; gap: 0.35rem; }
.stack-form label > span { font-size: 0.83rem; font-weight: 600; color: var(--ink-soft); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem 1rem; }

.checkbox-label { flex-direction: row !important; align-items: center; gap: 0.5rem !important; }
.checkbox-label input { width: auto; }
.checkbox-label span { font-weight: 500 !important; color: var(--ink-soft) !important; }

.form-actions { display: flex; justify-content: flex-end; gap: 0.7rem; margin-top: 0.3rem; }

/* ════════════════════════════════════════════════════════════════════
   Network page
   ════════════════════════════════════════════════════════════════════ */

.connect-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.2rem;
}

.code-card {
    background: var(--surface);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.3rem 1.4rem;
    box-shadow: 0 10px 24px -18px rgba(91, 33, 182, 0.4);
}

.code-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-small);
    padding: 0.85rem 1.1rem;
    margin-top: 0.9rem;
}
.code-value {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 1.5rem;
    letter-spacing: 0.24em;
    color: var(--accent-deep);
    font-weight: 700;
}

.connect-form { display: flex; gap: 0.7rem; margin-top: 0.9rem; }
.connect-form input { flex: 1; min-width: 0; letter-spacing: 0.12em; }

.request-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; }
.request-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    flex-wrap: wrap;
    padding: 0.7rem 0.95rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
}
.request-list li > span:first-child { display: flex; flex-direction: column; }
.request-list small { color: var(--muted); font-size: 0.78rem; }
.request-actions { display: flex; gap: 0.5rem; }
.inline-form { display: inline; }

.status-chip {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-radius: 999px;
    padding: 0.22rem 0.7rem;
}
.status-chip.pending { background: #f7ecd7; color: #8a6a25; }
.status-chip.approved { background: var(--accent-wash); color: var(--accent-deep); }

.section-title {
    font-size: 1.25rem;
    margin: 1.8rem 0 1rem;
}

.family-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.2rem;
}

.family-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.3rem;
    box-shadow: 0 10px 24px -18px rgba(91, 33, 182, 0.4);
}
.family-card-head {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1rem;
}
.family-initial {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: var(--teal);
    color: #fff;
    font-family: var(--font-display);
    font-size: 1.2rem;
    flex-shrink: 0;
}
.family-card-head h3 { margin: 0; font-size: 1.05rem; }
.family-card-head p { margin: 0.1rem 0 0; font-size: 0.8rem; color: var(--muted); }
.family-card-head .status-chip { margin-left: auto; }

/* Member tiles: photo cards with the name and location floating over
 * a dark tint — mirrors the tree's person cards. */
.member-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
    gap: 0.7rem;
}
.member-tile {
    position: relative;
    border-radius: var(--radius-small);
    overflow: hidden;
    aspect-ratio: 1 / 1.15;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.member-tile img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.member-initial {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
    font-family: var(--font-display);
    font-size: 1.6rem;
    color: var(--accent);
}
.member-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    padding: 1.3rem 0.5rem 0.45rem;
    background: rgba(24, 33, 26, 0.8);
    color: #fff;
}
.member-caption strong { font-size: 0.78rem; line-height: 1.2; }
.member-caption small {
    font-size: 0.64rem;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.member-tile:not(.photo) .member-caption { text-align: center; }
.member-tile:not(.photo) .member-caption strong { color: var(--ink); }
.member-tile:not(.photo) .member-caption small { color: var(--muted); }

.empty-connect {
    margin-top: 1.4rem;
    text-align: center;
    padding: 2.4rem 1rem;
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
}
.empty-connect .empty-icon { font-size: 2.4rem; color: var(--accent); display: block; margin-bottom: 0.8rem; }
.empty-connect h2 { margin: 0 0 0.3rem; }
.empty-connect p { color: var(--muted); margin: 0; }

/* ═══ Tree browsing modes, connection notes, member menu, tracing ═══ */

.tree-controls { display: flex; flex-direction: column; gap: 0.65rem; margin: 0 0 1.2rem; }
.mode-tabs {
    display: inline-flex;
    align-self: flex-start;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    padding: 0.25rem;
    gap: 0.15rem;
    box-shadow: 0 8px 18px -12px rgba(91, 33, 182, 0.4);
}
.mode-tab {
    padding: 0.4rem 0.95rem;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--ink-soft);
    white-space: nowrap;
}
.mode-tab:hover { text-decoration: none; color: var(--accent-deep); }
.mode-tab.active { background: var(--accent); color: #fff; }

.gen-strip { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.gen-chip {
    padding: 0.34rem 0.8rem;
    border: 1px dashed var(--border-strong);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-soft);
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}
.gen-chip:hover { text-decoration: none; border-style: solid; border-color: var(--accent); color: var(--accent-deep); }
.gen-chip.active {
    background: var(--accent-wash);
    border-style: solid;
    border-color: var(--accent);
    color: var(--accent-deep);
}
.mode-hint { margin: 0; color: var(--muted); font-size: 0.85rem; }

/* Connection notes: how the trees connect beyond what is in view. */
.connection-notes {
    margin-top: 1.4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 1.1rem 1.3rem;
}
.connection-notes h3 {
    font-size: 0.78rem;
    font-family: var(--font-body);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 0.8rem;
}
.connection-notes ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.45rem; }
.connection-notes li { font-size: 0.88rem; color: var(--ink-soft); line-height: 1.45; }
.connection-notes .note-rel { color: var(--accent-deep); font-weight: 600; padding: 0 0.15rem; }
.connection-notes .note-ctx { color: var(--muted); font-size: 0.78rem; white-space: nowrap; }
.connection-notes .note-ctx::before { content: " · "; }

/* Member menu, opened by clicking a card. */
.card-popover {
    position: fixed;
    z-index: 60;
    min-width: 176px;
    padding: 0.45rem;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    box-shadow: 0 18px 40px -14px rgba(91, 33, 182, 0.55);
    display: grid;
    gap: 0.25rem;
}
.pop-name {
    font-weight: 700;
    font-size: 0.86rem;
    padding: 0.3rem 0.55rem 0.45rem;
    color: var(--ink);
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.15rem;
}
.pop-action {
    border: none;
    background: transparent;
    text-align: left;
    padding: 0.5rem 0.6rem;
    border-radius: 9px;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--ink-soft);
    cursor: pointer;
}
.pop-action:hover { background: var(--accent-wash); color: var(--accent-deep); }
.pop-action.pop-trace { color: var(--coral); }
.pop-action.pop-trace:hover { background: #fbe9e4; }

/* Traced connections: relatives stand out, the rest recede, and the
 * lines joining them turn red. */
.person-card.dimmed { opacity: 0.28; filter: grayscale(0.7); }
.person-card.trace-linked { border-color: var(--coral); box-shadow: 0 0 0 3px #f6ddd5; }
.person-card.trace-source { border-color: var(--coral); box-shadow: 0 0 0 4px #f2c9bd; }
.relationship-lines .family-branch.hot {
    stroke: #d23b2e;
    stroke-width: 3.2px;
}
.couple-heart.hot { color: #d23b2e; border-color: #d23b2e; }
.trace-chip {
    position: fixed;
    right: 1.1rem;
    bottom: 1.1rem;
    z-index: 60;
    border: 1px solid #d23b2e;
    background: var(--surface);
    color: #b4271c;
    border-radius: 999px;
    padding: 0.5rem 1rem;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 14px 30px -12px rgba(120, 22, 14, 0.5);
}
.trace-chip:hover { background: #fbe9e4; }

/* ════════════════════════════════════════════════════════════════════
   Responsive
   ════════════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-hero { min-height: 34vh; }
    .nav-user-name { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .member-tiles { grid-template-columns: repeat(auto-fill, minmax(94px, 1fr)); }
}

@media (max-width: 640px) {
    .nav-inner { flex-wrap: wrap; gap: 0.55rem; }
    .brand { font-size: 0.95rem; }
    .auth-brand { font-size: 1rem; }
    .header-nav { order: 3; width: 100%; justify-content: center; margin-left: 0; }
    .nav-logout { padding: 0.32rem 0.6rem; font-size: 0.8rem; }
    .family-switch { order: 2; margin-left: auto; }
    .level-row { gap: 1rem 1.2rem; }
    .person-card { width: 116px; }
    .tree-diagram { padding: 1.2rem 1.2rem 2rem; }
    .couple-heart { margin-top: 40px; width: 36px; height: 36px; font-size: 15px; }
    .tree-node.couple:has(.photo-card) .couple-heart { margin-top: 62px; }
    .view-heading { align-items: flex-start; flex-direction: column; }
    .zoom-toolbar { right: 0.6rem; bottom: 0.6rem; }
    .mode-tabs { align-self: stretch; }
    .mode-tab { flex: 1; text-align: center; }
}

/* ════════════════════════════════════════════════════════════════════
   Quick-fill prompts and the tiny inline picker
   ════════════════════════════════════════════════════════════════════ */

/* "+ Add birth year" — a dashed-underline invitation instead of dead
 * grey text. Clicking opens a small picker right there, no reload. */
.quickfill {
    border-bottom: 1px dashed #c4b5fd;
    color: var(--accent-deep);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.12s ease, border-color 0.12s ease;
}
.quickfill:hover,
.quickfill:focus-visible {
    color: var(--accent);
    border-bottom-style: solid;
    outline: none;
}
.person-card .quickfill { font-size: 0.71rem; }
/* Inside a photo card the prompt floats over the dark tint. */
.card-caption .quickfill { border-bottom-color: rgba(255, 255, 255, 0.7); color: #cfe8d8; }
.card-caption .quickfill:hover { color: #fff; }

.quickfill.qf-photo {
    display: inline-block;
    border: 1px dashed #c4b5fd;
    border-radius: 999px;
    padding: 0.16rem 0.6rem;
    font-size: 0.71rem;
    background: var(--accent-wash);
}
.quickfill.qf-photo:hover { border-style: solid; background: #dcefe2; }

/* The little popover with a guessed year, a date field and Confirm. */
.quickfill-pop {
    position: fixed;
    z-index: 70;
    display: grid;
    gap: 0.4rem;
    width: 224px;
    padding: 0.7rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    box-shadow: 0 20px 44px -16px rgba(91, 33, 182, 0.55);
    font-size: 0.84rem;
}
.quickfill-pop .qf-title { font-weight: 700; font-size: 0.8rem; color: var(--ink); }
.quickfill-pop .qf-row { display: flex; gap: 0.45rem; }
.quickfill-pop input[type="number"],
.quickfill-pop input[type="date"] {
    flex: 1;
    min-width: 0;
    font: inherit;
    font-size: 0.86rem;
}
.quickfill-pop .qf-hint { color: var(--accent-deep); font-size: 0.72rem; margin: 0; font-weight: 600; }
.quickfill-pop .qf-error { color: #b4271c; font-size: 0.74rem; margin: 0; }
.quickfill-pop .qf-actions { display: flex; justify-content: flex-end; gap: 0.4rem; }

/* ════════════════════════════════════════════════════════════════
   Reminder bell in the header
   ════════════════════════════════════════════════════════════════ */

.notif-bell { position: relative; }
.notif-bell summary {
    list-style: none;
    cursor: pointer;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: var(--surface);
    font-size: 1rem;
    position: relative;
}
.notif-bell summary::-webkit-details-marker { display: none; }
.notif-bell[open] summary { background: var(--accent-wash); border-color: var(--accent); }
.notif-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 17px;
    height: 17px;
    border-radius: 999px;
    background: #d23b2e;
    color: #fff;
    font-size: 0.64rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}
.notif-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.55rem);
    width: min(330px, calc(100vw - 2rem));
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: 0 24px 50px -18px rgba(91, 33, 182, 0.6);
    padding: 0.9rem 1rem;
    z-index: 60;
}
.notif-panel h3 { margin: 0 0 0.6rem; font-size: 0.95rem; }
.notif-panel ul {
    list-style: none;
    margin: 0 0 0.7rem;
    padding: 0;
    display: grid;
    gap: 0.45rem;
    max-height: 260px;
    overflow-y: auto;
}
.notif-panel li {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-left-width: 3px;
    border-radius: 10px;
    background: var(--surface-2);
}
.notif-panel li small { color: var(--muted); font-size: 0.72rem; }
.notif-panel li.notif-birthday { border-left-color: var(--accent); }
.notif-panel li.notif-anniversary { border-left-color: var(--coral); }
.notif-text { font-size: 0.84rem; color: var(--ink-soft); line-height: 1.4; }

/* ════════════════════════════════════════════════════════════════
   Ancestor of the day and profile completion
   ════════════════════════════════════════════════════════════════ */

/* A daily prompt that highlights one elder and challenges the family
 * to find something new about them. */
.ancestor-day {
    margin-top: 1.4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 1.1rem 1.3rem;
}
.ancestor-day h3 {
    font-size: 0.78rem;
    font-family: var(--font-body);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 0.8rem;
}
.ancestor-body { display: flex; gap: 1.1rem; align-items: center; flex-wrap: wrap; }
.ancestor-body > img {
    width: 74px;
    height: 74px;
    border-radius: 22px;
    object-fit: cover;
    box-shadow: 0 12px 24px -12px rgba(91, 33, 182, 0.55);
}
.ancestor-copy { flex: 1; min-width: 240px; }
.ancestor-copy p { margin: 0.15rem 0; font-size: 0.9rem; color: var(--ink-soft); }
.ancestor-copy strong { color: var(--ink); }
.ancestor-copy .muted { color: var(--muted); }
.ancestor-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.55rem; }

/* "This profile is 60% complete. Missing: …" */
.completion-meter {
    margin: 0.2rem 0 1rem;
    padding: 0.8rem 0.95rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
}
.meter-row { display: flex; align-items: center; gap: 0.7rem; }
.meter-row strong { font-size: 0.9rem; color: var(--accent-deep); font-variant-numeric: tabular-nums; }
.meter-bar {
    flex: 1;
    height: 10px;
    border-radius: 999px;
    background: #e4ebe4;
    overflow: hidden;
}
.meter-bar span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
    min-width: 6px;
}
.completion-meter p { margin: 0.45rem 0 0.4rem; font-size: 0.84rem; color: var(--ink-soft); }

/* ════════════════════════════════════════════════════════════════
   Form pieces: required markers, smart-guess hint, vital status
   ════════════════════════════════════════════════════════════════ */

.req {
    color: #b4271c;
    font-style: normal;
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-left: 0.3rem;
}
.guess-hint { color: var(--accent-deep); font-size: 0.76rem; font-weight: 600; margin-top: 0.25rem; }

.vital-status {
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-small);
    padding: 0.8rem 1rem;
    display: grid;
    gap: 0.5rem;
}
.vital-status legend { font-size: 0.83rem; font-weight: 600; color: var(--ink-soft); padding: 0 0.35rem; }
.radio-label {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.88rem;
    color: var(--ink-soft);
    cursor: pointer;
}
.radio-label input { width: auto; accent-color: var(--accent); }

/* ════════════════════════════════════════════════════════════════
   Stories
   ════════════════════════════════════════════════════════════════ */

.story-composer h2 { font-size: 1.15rem; margin: 0 0 0.9rem; }
.story-feed { display: grid; gap: 1.2rem; margin-top: 1.2rem; }
.story-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.35rem;
    box-shadow: 0 10px 24px -18px rgba(91, 33, 182, 0.4);
}
.story-head h3 { margin: 0 0 0.25rem; font-size: 1.12rem; }
.story-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.55rem;
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted);
}
.story-meta a { color: var(--accent-deep); font-weight: 600; }
.story-family-chip {
    background: #e2f1f4;
    border: 1px solid #c3dfe6;
    color: var(--teal);
    border-radius: 999px;
    padding: 0.08rem 0.55rem;
    font-size: 0.72rem;
}
.story-body { margin-top: 0.7rem; font-size: 0.95rem; line-height: 1.65; color: var(--ink-soft); }
.story-photos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.6rem;
    margin-top: 0.9rem;
}
.story-photos img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--border);
}
.story-delete { margin-top: 0.8rem; }
.photos-hint { display: block; margin-top: 0.3rem; color: var(--accent-deep); font-size: 0.78rem; font-weight: 600; }
.link-danger {
    border: none;
    background: none;
    color: #b4271c;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}
.link-danger:hover { text-decoration: underline; }

/* ════════════════════════════════════════════════════════════════
   Charts page
   ════════════════════════════════════════════════════════════════ */

.chart-tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.chart-tab {
    padding: 0.45rem 1.1rem;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 0.88rem;
}
.chart-tab:hover { text-decoration: none; color: var(--accent-deep); border-color: var(--accent); }
.chart-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.chart-controls {
    display: flex;
    align-items: flex-end;
    gap: 1.1rem;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1.1rem;
    margin-bottom: 1.1rem;
}
.chart-person { display: flex; flex-direction: column; }
.chart-person > span {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 0.3rem;
}
.chart-person select { min-width: 230px; }
.chart-stat { margin: 0 0 0.15rem; color: var(--muted); font-size: 0.82rem; }

.chart-stage { padding: 1rem; overflow-x: auto; }
.chart-stage svg.chart-svg { display: block; width: 100%; height: auto; }
.chart-empty-note { text-align: center; color: var(--muted); padding: 2rem 1rem; margin: 0; }
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.2rem;
    margin: 0.8rem 0 0;
    font-size: 0.8rem;
    color: var(--ink-soft);
    align-items: center;
}
.swatch {
    display: inline-block;
    width: 13px;
    height: 13px;
    border-radius: 4px;
    margin-right: 0.35rem;
    vertical-align: -2px;
}
.swatch-male { background: #dfe9f3; border: 1px solid #5c87ac; }
.swatch-female { background: #f6e3ea; border: 1px solid #b4798f; }
.swatch-other { background: #e5ede5; border: 1px solid #6d9678; }
.legend-hint { color: var(--muted); margin-left: auto; }

/* ════════════════════════════════════════════════════════════════
   Poster page
   ════════════════════════════════════════════════════════════════ */

.poster-page { background: #ecefe9; }
.poster-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    align-items: center;
    max-width: 1240px;
    margin: 0 auto;
    padding: 0.9rem clamp(1rem, 3vw, 1.6rem) 0;
}
.poster-controls { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: flex-end; flex: 1; }
.poster-controls label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--ink-soft);
}
.poster-controls select,
.poster-controls input[type="text"] { min-width: 130px; }
.poster-title-field input { min-width: 220px; }

.poster-sheet { max-width: 1240px; margin: 0 auto; padding: clamp(0.9rem, 2.5vw, 1.8rem); }
.poster-inner {
    background: var(--poster-bg, #fbfaf6);
    color: var(--poster-ink, #20362b);
    font-family: var(--poster-font, Georgia, serif);
    border: 3px solid var(--poster-accent, #3e7d5c);
    border-radius: 18px;
    padding: clamp(1.4rem, 4vw, 3.2rem) clamp(1.2rem, 4vw, 3.4rem);
    box-shadow: 0 30px 60px -30px rgba(91, 33, 182, 0.45);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}
.poster-head { text-align: center; margin-bottom: 1.2rem; }
.poster-kicker {
    margin: 0;
    letter-spacing: 0.4em;
    font-size: 0.8rem;
    color: var(--poster-accent, #3e7d5c);
    font-weight: 700;
}
.poster-title {
    margin: 0.35rem 0 0.5rem;
    font-size: clamp(1.8rem, 4.5vw, 3rem);
    line-height: 1.1;
    font-family: inherit;
}
.poster-sub { margin: 0; color: var(--poster-sub, #5c6f60); font-size: 0.95rem; }
.poster-chart { margin-top: 0.6rem; }
.poster-chart svg { width: 100%; height: auto; display: block; }
.poster-foot {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 0.8rem;
    border-top: 2px solid var(--poster-accent, #3e7d5c);
    color: var(--poster-sub, #5c6f60);
    font-size: 0.85rem;
}

/* ════════════════════════════════════════════════════════════════
   Mobile refinements (the phone version of the app)
   ════════════════════════════════════════════════════════════════ */

@media (max-width: 640px) {
    .app-main {
        padding: 1rem 0.9rem calc(1.4rem + env(safe-area-inset-bottom, 0px));
    }
    .header-nav {
        justify-content: flex-start;
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .header-nav::-webkit-scrollbar { display: none; }
    .notif-panel { right: -0.3rem; }
    .chart-controls { align-items: stretch; flex-direction: column; gap: 0.7rem; }
    .chart-person select { min-width: 0; width: 100%; }
    .chart-stage { padding: 0.7rem; }
    .story-photos { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
    .story-card { padding: 1rem 1rem; }
    .poster-toolbar { padding-top: 0.8rem; }
    .poster-controls label { flex: 1 1 45%; }
    .poster-controls select,
    .poster-controls input[type="text"] { min-width: 0; width: 100%; }
    .poster-title-field { flex: 1 1 100%; }
    .ancestor-body { flex-direction: column; align-items: flex-start; }
    .meter-row strong { font-size: 1rem; }
    .quickfill-pop { width: min(224px, calc(100vw - 1.6rem)); }
}

/* ════════════════════════════════════════════════════════════════
   Printing
   ════════════════════════════════════════════════════════════════ */

@media print {
    .app-header,
    .heading-actions,
    .tree-controls,
    .zoom-toolbar,
    .trace-chip,
    .card-popover,
    .quickfill-pop,
    .chart-tabs,
    .chart-controls,
    .chart-legend,
    .poster-toolbar,
    .notice,
    .no-print { display: none !important; }

    body { background: #fff; }
    .app-main { max-width: none; padding: 0; }
    .tree-scroll { border: none; overflow: visible; }
    .tree-diagram { background-image: none; }
    .person-card, .story-card { box-shadow: none; break-inside: avoid; }
    .chart-stage { border: none; box-shadow: none; padding: 0; }
    a { color: inherit; text-decoration: none; }
}

/* The poster prints as one A2 landscape sheet — the SVG is vector, so it
 * stays razor sharp at any size. Named pages work in current browsers;
 * older ones simply fall back to the default paper. */
@page poster { size: A2 landscape; margin: 8mm; }
.poster-sheet { page: poster; }
@media print {
    .poster-page { background: none; }
    .poster-sheet { max-width: none; padding: 0; }
    .poster-inner { box-shadow: none; border-radius: 0; }
}

/* ── Activity feed ──────────────────────────────────────────────────── */

.act-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.2rem;
    height: 1.2rem;
    padding: 0 0.35rem;
    font-size: 0.68rem;
    font-weight: 700;
    color: #fff;
    background: var(--coral);
    border-radius: 999px;
    margin-left: 0.3rem;
}

.activity-page {
    max-width: 680px;
    margin: 0 auto;
    padding: 1.2rem 1rem 3rem;
}

.activity-section-head {
    margin-bottom: 1.4rem;
}

.activity-timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.activity-item {
    display: flex;
    gap: 0.8rem;
    align-items: flex-start;
    padding: 0.85rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.activity-item:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px -6px rgba(124, 58, 237, 0.15);
}

.activity-icon {
    flex-shrink: 0;
    font-size: 1.3rem;
    width: 2rem;
    text-align: center;
    line-height: 1;
    padding-top: 0.1rem;
}

.activity-body {
    flex: 1;
    min-width: 0;
    font-size: 0.92rem;
    line-height: 1.45;
}
.activity-body strong {
    color: var(--accent-deep);
}

.activity-time {
    display: block;
    font-size: 0.76rem;
    margin-top: 0.25rem;
}

/* ── Story comments ─────────────────────────────────────────────────── */

.story-comments {
    margin-top: 1rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--border);
}

.story-comments-list {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin-bottom: 0.8rem;
}

.story-comment {
    padding: 0.65rem 0.85rem;
    background: var(--surface-2);
    border-radius: var(--radius-small);
    border: 1px solid var(--border);
}

.comment-head {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}
.comment-head strong {
    font-size: 0.85rem;
    color: var(--accent-deep);
}
.comment-head small {
    font-size: 0.72rem;
}

.comment-body {
    font-size: 0.88rem;
    line-height: 1.5;
    margin: 0;
}

.story-comment-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.story-comment-form textarea {
    width: 100%;
    resize: vertical;
    min-height: 2.5rem;
    font: inherit;
    font-size: 0.88rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    background: var(--surface);
    transition: border-color 0.15s ease;
}
.story-comment-form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-wash);
}

.btn-sm {
    padding: 0.4rem 0.9rem;
    font-size: 0.82rem;
    align-self: flex-end;
}

/* ── Side navigation drawer ─────────────────────────────────────────── */

.nav-burger {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 0 9px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.nav-burger span {
    display: block;
    height: 2px;
    width: 100%;
    border-radius: 2px;
    background: var(--ink-soft);
    transition: background 0.15s ease;
}
.nav-burger:hover { background: var(--accent-wash); border-color: var(--accent); }
.nav-burger:hover span { background: var(--accent-deep); }

.nav-end { margin-left: auto; }

.side-nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 12, 30, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    /* Above every floating card (map editor 1100, modals 1000) so the
     * dim covers them, but below the drawer itself. */
    z-index: 1150;
}
body.side-nav-open .side-nav-overlay { opacity: 1; pointer-events: auto; }

.side-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 272px;
    max-width: 84vw;
    background: var(--surface);
    border-right: 1px solid var(--border);
    transform: translateX(-102%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    /* The drawer is on top of everything when pulled out: floating map
     * editor, modals, prompts and banners included. */
    z-index: 1200;
    overflow-y: auto;
    padding: 0.9rem 0.9rem calc(1.2rem + env(safe-area-inset-bottom, 0px));
}
body.side-nav-open .side-nav { transform: translateX(0); }

.side-nav-head {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.2rem 0.3rem 0.9rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.7rem;
}
.side-nav-head strong {
    font-family: var(--font-display);
    font-size: 0.98rem;
    color: var(--ink);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.side-nav-close {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--ink-soft);
    font-size: 0.95rem;
    cursor: pointer;
    flex-shrink: 0;
}
.side-nav-close:hover { background: var(--accent-wash); color: var(--accent-deep); }

.side-group { border-bottom: 1px solid var(--border); padding: 0.25rem 0; }
.side-group summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    list-style: none;
    cursor: pointer;
    padding: 0.45rem 0.4rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    user-select: none;
}
.side-group summary::-webkit-details-marker { display: none; }
.side-group summary::after {
    content: "▾";
    font-size: 0.8rem;
    transition: transform 0.18s ease;
}
.side-group:not([open]) summary::after { transform: rotate(-90deg); }
.side-group summary:hover { color: var(--accent-deep); }

.side-links { display: flex; flex-direction: column; gap: 0.12rem; padding: 0.15rem 0 0.55rem; }
.side-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.52rem 0.6rem;
    border-radius: var(--radius-small);
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 0.92rem;
}
.side-link:hover { background: var(--accent-wash); color: var(--accent-deep); text-decoration: none; }
.side-link.active { background: var(--accent); color: #fff; }
.side-ico { width: 1.25rem; text-align: center; opacity: 0.9; flex-shrink: 0; }
.side-badge {
    margin-left: auto;
    min-width: 1.3rem;
    height: 1.3rem;
    padding: 0 0.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--coral);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.side-link.active .side-badge { background: rgba(255, 255, 255, 0.25); }

.side-note {
    margin: 0.8rem 0.3rem 0;
    font-size: 0.76rem;
    color: var(--muted);
    line-height: 1.45;
}

@media (max-width: 640px) {
    .nav-burger { width: 36px; height: 36px; padding: 0 8px; }
}

/* Wide screens: the drawer docks beside the content instead of floating
 * over it. It stays open unless the user collapses it with the burger;
 * the choice is remembered across pages. */
@media (min-width: 921px) {
    body.side-nav-open .side-nav {
        transform: translateX(0);
        box-shadow: none;
        top: var(--header-h, 60px);
    }
    body.side-nav-open .side-nav-overlay { opacity: 0; pointer-events: none; }
    body.side-nav-open .nav-inner,
    body.side-nav-open .app-main,
    body.side-nav-open .chat-page,
    body.side-nav-open .map-page { margin-left: 272px; }
    .nav-inner, .app-main, .chat-page, .map-page {
        transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

/* ── Chat ───────────────────────────────────────────────────────────── */

.chat-page {
    display: flex;
    height: calc(100vh - var(--header-h, 60px));
    height: calc(100dvh - var(--header-h, 60px));
    max-width: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.chat-list-pane {
    width: 320px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    flex-direction: column;
}
.chat-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border);
}
.chat-list-head h1 { font-size: 1.25rem; margin: 0; }

.chat-conversations {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}
.chat-loading { padding: 0.6rem 0.5rem; }

.chat-conv {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.65rem 0.7rem;
    border-radius: var(--radius-small);
    color: var(--ink);
}
.chat-conv:hover { background: var(--accent-wash); text-decoration: none; }
.chat-conv.active { background: var(--accent-wash); }
.chat-conv-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.chat-conv-main strong { font-size: 0.92rem; }
.chat-conv-preview {
    font-size: 0.8rem;
    color: var(--ink-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 0.25rem; flex-shrink: 0; }

.chat-thread-pane {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--paper);
}

.chat-thread-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    color: var(--muted);
}
.chat-empty-ico { font-size: 2.2rem; }

.chat-thread {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.chat-thread-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.chat-back-btn {
    display: none;
    width: 34px;
    height: 34px;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--ink-soft);
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
}
.chat-thread-title { display: flex; flex-direction: column; min-width: 0; }
.chat-thread-title strong { font-size: 1rem; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}
.chat-msg { display: flex; flex-direction: column; align-items: flex-start; max-width: 72%; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-msg-sender { color: var(--muted); font-size: 0.72rem; margin: 0 0 0.15rem 0.4rem; }
.chat-bubble {
    padding: 0.55rem 0.85rem;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 0.92rem;
    line-height: 1.45;
    word-wrap: break-word;
}
.chat-msg.mine .chat-bubble {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.chat-msg-time { color: var(--muted); font-size: 0.68rem; margin-top: 0.15rem; }

.chat-composer {
    display: flex;
    align-items: flex-end;
    gap: 0.6rem;
    padding: 0.7rem 1rem;
    padding-bottom: calc(0.7rem + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-top: 1px solid var(--border);
}
.chat-composer textarea {
    flex: 1;
    resize: none;
    font: inherit;
    font-size: 0.92rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-small);
    background: var(--surface-2);
    max-height: 120px;
}
.chat-composer textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-wash);
}
.chat-send-btn { flex-shrink: 0; }

.chat-send-error {
    margin: 0;
    padding: 0.4rem 1rem;
    background: #fef2f2;
    border-top: 1px solid #fecaca;
    color: #b91c1c;
    font-size: 0.8rem;
    font-weight: 600;
}
.chat-send-error[hidden] { display: none; }

/* New chat dialog */
.chat-user-filter {
    width: 100%;
    font: inherit;
    font-size: 0.9rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-small);
    background: var(--surface);
    margin-bottom: 0.6rem;
}
.chat-user-filter:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.chat-user-list {
    max-height: 260px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.chat-user-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.55rem;
    border-radius: var(--radius-small);
    cursor: pointer;
    font-size: 0.92rem;
}
.chat-user-row:hover { background: var(--accent-wash); }
.chat-user-row input { accent-color: var(--accent); width: 16px; height: 16px; }
.chat-group-name-row { margin-top: 0.7rem; }
.chat-group-name-row input {
    width: 100%;
    font: inherit;
    font-size: 0.9rem;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-small);
    background: var(--surface);
}

@media (max-width: 800px) {
    .chat-list-pane { width: 100%; border-right: none; }
    .chat-thread-pane { display: none; }
    body.chat-thread-open .chat-list-pane { display: none; }
    body.chat-thread-open .chat-thread-pane { display: flex; }
    .chat-back-btn { display: inline-flex; }
    .chat-msg { max-width: 85%; }
}

/* ── Contextual push-notification prompt ────────────────────────────── */
.push-prompt {
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: calc(0.9rem + env(safe-area-inset-bottom, 0px));
    z-index: 950;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 18px 44px -16px rgba(38, 51, 42, 0.45);
    padding: 0.8rem 0.95rem;
}
.push-prompt[hidden] { display: none; }
.push-prompt-ico { font-size: 1.3rem; flex-shrink: 0; }
.push-prompt-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.push-prompt-text strong { font-size: 0.92rem; color: var(--ink); }
.push-prompt-text span { font-size: 0.78rem; color: var(--muted); line-height: 1.4; }
.push-prompt-enable {
    flex-shrink: 0;
    padding: 0.45rem 1rem;
    border: none;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
}
.push-prompt-enable:hover { background: var(--accent-deep); }
.push-prompt-dismiss {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--muted);
    font-size: 0.85rem;
    cursor: pointer;
}
.push-prompt-dismiss:hover { background: var(--accent-wash); color: var(--accent-deep); }
@media (min-width: 640px) {
    .push-prompt { left: auto; width: 380px; right: 1.2rem; bottom: 1.2rem; }
}

/* ── Foreground push toast (in-app notification while the app is open) ── */
.fgn-toast {
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: calc(0.9rem + env(safe-area-inset-bottom, 0px));
    z-index: 960;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: 0 18px 44px -16px rgba(38, 51, 42, 0.45);
    padding: 0.8rem 0.95rem;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}
.fgn-toast:hover { text-decoration: none; }
.fgn-toast-ico { font-size: 1.2rem; flex-shrink: 0; }
.fgn-toast-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.fgn-toast-text strong { font-size: 0.9rem; color: var(--ink); }
.fgn-toast-text span { font-size: 0.8rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 640px) {
    .fgn-toast { left: auto; width: 380px; right: 1.2rem; bottom: 1.2rem; }
}

/* ════════════════════════════════════════════════════════════════════
   Landing page (home.php) — informative front door for guests
   Deep leaf green hero, paper sections, solid colours only
   ════════════════════════════════════════════════════════════════════ */

.landing-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem clamp(1.2rem, 4vw, 3rem);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.landing-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ink);
}
.landing-brand:hover { text-decoration: none; }

.landing-nav-actions { display: flex; align-items: center; gap: 0.6rem; }

.landing-hero {
    position: relative;
    overflow: hidden;
    background: #1f3d2b;
    color: #f0ede2;
    padding: clamp(3.5rem, 9vw, 7rem) clamp(1.2rem, 4vw, 3rem) clamp(3rem, 7vw, 5.5rem);
}
.landing-hero::before {
    content: "";
    position: absolute;
    width: 460px;
    height: 460px;
    border-radius: 50%;
    background: rgba(62, 125, 92, 0.35);
    top: -18%;
    right: -8%;
    filter: blur(80px);
    pointer-events: none;
}
.landing-hero::after {
    content: "";
    position: absolute;
    width: 340px;
    height: 340px;
    border-radius: 50%;
    background: rgba(244, 63, 94, 0.12);
    bottom: -16%;
    left: -6%;
    filter: blur(70px);
    pointer-events: none;
}

.landing-hero-inner {
    position: relative;
    z-index: 1;
    max-width: 46rem;
    margin: 0 auto;
    text-align: center;
}

.landing-eyebrow {
    font-size: 0.72rem;
    letter-spacing: 0.38em;
    color: #9fc7ae;
    margin: 0 0 1.3rem;
    text-transform: uppercase;
    font-weight: 700;
}

.landing-hero h1 {
    font-size: clamp(2.3rem, 5.5vw, 3.8rem);
    line-height: 1.08;
    margin: 0 0 1.2rem;
    color: #fff;
}

.landing-copy {
    color: #cfe0d4;
    font-size: 1.06rem;
    line-height: 1.7;
    max-width: 38rem;
    margin: 0 auto 1.8rem;
}

.landing-cta-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.landing-cta { padding: 0.8rem 1.7rem; font-size: 1rem; }

.landing-cta-light {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.4);
}
.landing-cta-light:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }

.landing-fine {
    color: #9db8a6;
    font-size: 0.85rem;
    margin: 1.4rem 0 0;
}

.landing-section {
    padding: clamp(2.8rem, 6vw, 4.5rem) clamp(1.2rem, 4vw, 3rem);
    max-width: 68rem;
    margin: 0 auto;
}

.landing-section-alt {
    max-width: none;
    background: var(--surface-2);
}
.landing-section-alt > .landing-section-head,
.landing-section-alt > .landing-grid {
    max-width: 68rem;
    margin-left: auto;
    margin-right: auto;
}

.landing-section-head {
    text-align: center;
    max-width: 40rem;
    margin: 0 auto 2.2rem;
}
.landing-section-head h2 {
    font-size: clamp(1.5rem, 3vw, 2.1rem);
    margin: 0 0 0.5rem;
}
.landing-section-head p { color: var(--ink-soft); margin: 0; }

.landing-steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.2rem;
    counter-reset: none;
}
.landing-steps li {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem 1.5rem;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.4rem 1rem;
    align-items: start;
}
.landing-steps h3 { margin: 0.2rem 0 0.3rem; grid-column: 2; }
.landing-steps p { margin: 0; color: var(--ink-soft); grid-column: 2; }

.landing-step-num {
    grid-row: 1;
    grid-column: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 50%;
    background: #3e7d5c;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
}

.landing-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.1rem;
}

.landing-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem 1.5rem;
}
.landing-card-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 12px;
    background: #e7efe9;
    color: #2c5a41;
    font-size: 1.15rem;
    margin-bottom: 0.7rem;
}
.landing-card h3 { margin: 0 0 0.4rem; }
.landing-card p { margin: 0; color: var(--ink-soft); font-size: 0.93rem; line-height: 1.6; }

.landing-assure {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.1rem;
    margin-bottom: 2.8rem;
}
.landing-assure-item {
    border-left: 3px solid #3e7d5c;
    background: var(--surface);
    border-radius: var(--radius-small);
    padding: 1.1rem 1.3rem;
}
.landing-assure-item strong { display: block; margin-bottom: 0.3rem; }
.landing-assure-item p { margin: 0; color: var(--ink-soft); font-size: 0.92rem; }

.landing-final {
    text-align: center;
    background: #1f3d2b;
    color: #f0ede2;
    border-radius: var(--radius);
    padding: clamp(2rem, 5vw, 3.2rem) 1.5rem;
}
.landing-final h2 {
    color: #fff;
    font-size: clamp(1.4rem, 3vw, 2rem);
    margin: 0 0 1.4rem;
}

.landing-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.2rem;
    flex-wrap: wrap;
    background: #1f3d2b;
    color: #cfe0d4;
    padding: 1.6rem clamp(1.2rem, 4vw, 3rem);
}
.landing-footer-logo { width: 40px; height: 40px; }
.landing-footer strong {
    font-family: var(--font-display);
    font-size: 1.15rem;
    color: #fff;
}
.landing-footer p { margin: 0.15rem 0 0; font-size: 0.85rem; }
.landing-footer nav { display: flex; gap: 1.1rem; }
.landing-footer a { color: #f0ede2; font-weight: 600; font-size: 0.9rem; }
.landing-footer a:hover { color: #fff; }

@media (min-width: 640px) {
    .landing-steps { grid-template-columns: repeat(3, 1fr); }
    .landing-steps li { grid-template-columns: 1fr; }
    .landing-steps h3, .landing-steps p { grid-column: 1; }
    .landing-grid { grid-template-columns: repeat(2, 1fr); }
    .landing-assure { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 960px) {
    .landing-grid { grid-template-columns: repeat(3, 1fr); }
}
