/* ============================================================
   Family Heritage — Main Stylesheet
   Warm, heritage-themed design for a genealogy application
   ============================================================ */

/* ----- Custom Properties ----- */
:root {
    --primary: #5B4A3F;
    --primary-light: #8B7355;
    --primary-dark: #3E3028;
    --accent: #C19A6B;
    --accent-light: #D4B896;
    --bg: #FAF8F5;
    --bg-card: #FFFFFF;
    --bg-input: #FDFCFA;
    --text: #2C2C2C;
    --text-light: #6B6B6B;
    --text-muted: #999999;
    --border: #E5DDD5;
    --border-focus: #C19A6B;
    --success: #4A7C59;
    --success-light: #E8F5E9;
    --danger: #A94442;
    --danger-light: #FDECEC;
    --info: #3B7DD8;
    --info-light: #E3F0FF;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
    --nav-height: 60px;
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-heading: Georgia, 'Times New Roman', serif;

    /* Tree colors */
    --tree-male: #D4E6F1;
    --tree-male-border: #5B9BD5;
    --tree-female: #F5D5E0;
    --tree-female-border: #D4739D;
    --tree-other: #E0E0E0;
    --tree-other-border: #999999;
    --tree-link: #8B7355;
    --tree-spouse-link: #C19A6B;
}

/* ----- Reset ----- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ----- Typography ----- */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    color: var(--text);
    background-color: var(--bg);
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    color: var(--primary);
    line-height: 1.3;
}

h1 { font-size: 2rem; margin-bottom: 0.75rem; }
h2 { font-size: 1.5rem; margin-bottom: 0.5rem; }
h3 { font-size: 1.25rem; margin-bottom: 0.5rem; }
h4 { font-size: 1.1rem; margin-bottom: 0.25rem; }

p { margin-bottom: 0.75rem; }

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--accent);
}

/* ----- Navigation Bar ----- */
.nav-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--primary);
    color: #FFFFFF;
    z-index: 1000;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.nav-inner {
    max-width: 1400px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 2rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #FFFFFF;
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    text-decoration: none;
}

.nav-brand:hover {
    color: var(--accent-light);
}

.nav-brand-icon {
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: rgba(255, 255, 255, 0.85);
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    text-decoration: none;
}

.nav-link:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.12);
}

.nav-link.active {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.18);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
    white-space: nowrap;
}

#nav-user-name {
    font-size: 0.9rem;
    opacity: 0.9;
}

.btn-nav-logout {
    background: rgba(255, 255, 255, 0.15);
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-nav-logout:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ----- Main Content ----- */
#app {
    padding-top: var(--nav-height);
    min-height: 100vh;
}

.page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

/* ----- Buttons ----- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: var(--font-body);
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #FFFFFF;
    border: 1px solid var(--primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg);
    border-color: var(--primary-light);
}

.btn-accent {
    background: var(--accent);
    color: #FFFFFF;
    border: 1px solid var(--accent);
}

.btn-accent:hover:not(:disabled) {
    background: #B08A5B;
    box-shadow: var(--shadow);
}

.btn-danger {
    background: var(--danger);
    color: #FFFFFF;
    border: 1px solid var(--danger);
}

.btn-danger:hover:not(:disabled) {
    background: #8B3836;
}

.btn-ghost {
    background: transparent;
    color: var(--text-light);
    border: 1px solid transparent;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg);
    color: var(--text);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.75rem 1.75rem;
    font-size: 1rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
}

.btn-icon.btn-sm {
    width: 28px;
    height: 28px;
}

/* ----- Cards ----- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    transition: box-shadow var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

.card-flat {
    box-shadow: none;
}

.card-flat:hover {
    box-shadow: none;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

/* ----- Forms ----- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
}

.form-label-optional {
    font-weight: 400;
    color: var(--text-muted);
    margin-left: 0.25rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg-input);
    transition: all var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(193, 154, 107, 0.15);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B6B6B' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
}

.form-checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-error {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

.form-actions .btn-danger {
    margin-left: auto;
}

/* ----- Login / Register Page ----- */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--bg) 0%, #F0EBE3 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 2rem;
    border: 1px solid var(--border);
}

.auth-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-brand-icon {
    display: block;
    margin: 0 auto 0.75rem;
    color: var(--primary);
}

.auth-brand h1 {
    font-family: var(--font-heading);
    color: var(--primary);
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.auth-brand p {
    color: var(--text-light);
    font-size: 0.9rem;
    margin: 0;
}

.auth-error {
    background: var(--danger-light);
    color: var(--danger);
    padding: 0.65rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(169, 68, 66, 0.2);
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
    font-size: 0.875rem;
    color: var(--text-light);
}

.auth-footer a {
    color: var(--primary);
    font-weight: 600;
}

/* ----- Tree View ----- */
.tree-page {
    height: calc(100vh - var(--nav-height));
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tree-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    z-index: 10;
}

.tree-controls .form-select,
.tree-controls .form-input {
    width: auto;
    min-width: 200px;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}

.tree-controls-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tree-controls-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-light);
    white-space: nowrap;
}

.tree-controls-sep {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 0.25rem;
}

.tree-container {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: linear-gradient(135deg, #FDFCFA 0%, #F5F0EA 100%);
}

.tree-container svg {
    width: 100%;
    height: 100%;
    cursor: grab;
}

.tree-container svg:active {
    cursor: grabbing;
}

/* Tree nodes */
.tree-node {
    cursor: pointer;
}

.tree-node rect {
    stroke-width: 2;
    transition: filter 0.15s ease;
    rx: 6;
    ry: 6;
}

.tree-node:hover rect {
    filter: brightness(0.95);
}

.tree-node .node-name {
    font-weight: 600;
    font-size: 13px;
    fill: var(--text);
}

.tree-node .node-dates {
    font-size: 11px;
    fill: var(--text-light);
}

.tree-node .node-photo {
    stroke: #FFFFFF;
    stroke-width: 2;
}

/* Tree links */
.tree-link {
    fill: none;
    stroke: var(--tree-link);
    stroke-width: 1.5;
    stroke-opacity: 0.6;
}

.tree-spouse-link {
    fill: none;
    stroke: var(--tree-spouse-link);
    stroke-width: 2;
    stroke-dasharray: 5, 3;
    stroke-opacity: 0.7;
}

/* Tree empty state */
.tree-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
}

.tree-empty-icon {
    color: var(--accent-light);
    margin-bottom: 1.5rem;
    opacity: 0.6;
}

.tree-empty h2 {
    color: var(--primary-light);
    margin-bottom: 0.5rem;
}

.tree-empty p {
    max-width: 400px;
    margin-bottom: 1.5rem;
}

/* ----- Person Profile ----- */
.profile-back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-light);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    transition: color var(--transition);
}

.profile-back:hover {
    color: var(--primary);
}

.profile-header {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    align-items: flex-start;
}

.profile-photo-wrapper {
    flex-shrink: 0;
}

.profile-photo {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--border);
    box-shadow: var(--shadow);
}

.profile-photo-placeholder {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--border) 0%, #D5CEC5 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 4px solid var(--border);
    box-shadow: var(--shadow);
}

.profile-photo-placeholder .initials {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    color: var(--primary-light);
    font-weight: 700;
}

.profile-info {
    flex: 1;
}

.profile-name {
    font-size: 2rem;
    margin-bottom: 0.15rem;
}

.profile-name .maiden-name {
    font-weight: 400;
    color: var(--text-light);
}

.profile-nickname {
    font-style: italic;
    color: var(--text-light);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.profile-dates {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.profile-occupation {
    color: var(--text-light);
    font-size: 0.9rem;
}

.profile-living-badge {
    display: inline-block;
    background: var(--success-light);
    color: var(--success);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.6rem;
    border-radius: 10px;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.profile-section {
    margin-bottom: 2rem;
}

.profile-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.profile-bio {
    line-height: 1.8;
    color: var(--text);
    white-space: pre-line;
}

/* Relationship cards in profile */
.rel-group {
    margin-bottom: 1.25rem;
}

.rel-group-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.rel-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    background: var(--bg);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
}

.rel-card:hover {
    background: var(--bg-card);
    border-color: var(--accent);
}

.rel-card-photo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary-light);
    flex-shrink: 0;
}

.rel-card-info {
    flex: 1;
}

.rel-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

.rel-card-detail {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Photos grid in profile */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

.photo-card {
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    aspect-ratio: 1;
    border: 1px solid var(--border);
    cursor: pointer;
}

.photo-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition);
}

.photo-card:hover img {
    transform: scale(1.05);
}

.photo-card-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: #FFFFFF;
    padding: 1.5rem 0.5rem 0.5rem;
    font-size: 0.8rem;
}

/* Story cards */
.story-card {
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 0.75rem;
}

.story-card-title {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    color: var(--primary);
    margin-bottom: 0.35rem;
}

.story-card-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.story-card-excerpt {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.6;
}

/* ----- People List ----- */
.people-search {
    margin-bottom: 1.5rem;
}

.people-search .form-input {
    max-width: 400px;
}

.people-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.person-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    color: inherit;
}

.person-card:hover {
    box-shadow: var(--shadow-hover);
    border-color: var(--accent);
    color: inherit;
}

.person-card-photo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-light);
    flex-shrink: 0;
    overflow: hidden;
}

.person-card-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.person-card-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.person-card-dates {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ----- Admin Dashboard ----- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem;
    text-align: center;
}

.stat-card-value {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 0.25rem;
}

.stat-card-label {
    font-size: 0.85rem;
    color: var(--text-light);
    font-weight: 500;
}

.admin-section {
    margin-bottom: 2.5rem;
}

.admin-section h2 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

/* User management table */
.user-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.user-table th,
.user-table td {
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.user-table th {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-light);
    background: var(--bg);
}

.user-table tr:hover td {
    background: var(--bg);
}

.user-table .form-select {
    width: auto;
    padding: 0.3rem 2rem 0.3rem 0.5rem;
    font-size: 0.85rem;
}

/* ----- Modal Overlay ----- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
    animation: fadeIn 0.15s ease;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.2s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color var(--transition);
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ----- Toast Notifications ----- */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 5000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    animation: toastIn 0.25s ease;
    max-width: 400px;
}

.toast-success {
    background: var(--success);
    color: #FFFFFF;
}

.toast-error {
    background: var(--danger);
    color: #FFFFFF;
}

.toast-info {
    background: var(--info);
    color: #FFFFFF;
}

.toast-exit {
    animation: toastOut 0.2s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ----- Loading Spinner ----- */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-inline {
    display: inline-block;
    vertical-align: middle;
    margin-right: 0.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Full-page loading */
.loading-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    color: var(--text-light);
    gap: 1rem;
}

/* ----- File Upload ----- */
.file-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--bg);
}

.file-upload:hover {
    border-color: var(--accent);
    background: var(--bg-card);
}

.file-upload input[type="file"] {
    display: none;
}

.file-upload-icon {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.file-upload-text {
    font-size: 0.9rem;
    color: var(--text-light);
}

.file-upload-preview {
    margin-top: 1rem;
}

.file-upload-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* ----- Empty State ----- */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-light);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.empty-state h3 {
    color: var(--primary-light);
    margin-bottom: 0.5rem;
}

.empty-state p {
    max-width: 360px;
    margin: 0 auto 1.25rem;
    font-size: 0.9rem;
}

/* ----- Pagination ----- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 2rem;
}

.pagination .btn {
    min-width: 36px;
}

.pagination .btn.active {
    background: var(--primary);
    color: #FFFFFF;
}

/* ----- Utility Classes ----- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-light); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.hidden { display: none !important; }

/* ----- Scrollbar ----- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ----- Responsive ----- */
@media (max-width: 1024px) {
    .profile-header {
        gap: 1.5rem;
    }

    .profile-photo,
    .profile-photo-placeholder {
        width: 120px;
        height: 120px;
    }
}

@media (max-width: 768px) {
    :root {
        --nav-height: 56px;
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }

    .nav-inner {
        padding: 0 1rem;
        gap: 1rem;
    }

    .nav-brand {
        font-size: 1.05rem;
    }

    .nav-link {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }

    .nav-link svg {
        display: none;
    }

    #nav-user-name {
        display: none;
    }

    .page-container {
        padding: 1.25rem 1rem;
    }

    .profile-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .profile-photo,
    .profile-photo-placeholder {
        width: 100px;
        height: 100px;
    }

    .profile-name {
        font-size: 1.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .tree-controls {
        padding: 0.5rem 0.75rem;
    }

    .tree-controls .form-select,
    .tree-controls .form-input {
        min-width: 140px;
        font-size: 0.8rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .card-grid,
    .people-grid {
        grid-template-columns: 1fr;
    }

    .user-table {
        font-size: 0.8rem;
    }

    .user-table th,
    .user-table td {
        padding: 0.5rem 0.65rem;
    }

    .modal {
        max-width: 100%;
        margin: 0.5rem;
    }

    .toast-container {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }

    .toast {
        max-width: 100%;
    }

    .auth-card {
        padding: 2rem 1.5rem;
    }

    .photo-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .layer-toggles {
        flex-wrap: wrap;
    }
}

/* ============================================================
   Phase 2: Advanced Tree Features
   ============================================================ */

/* ----- Layer Toggle Pills ----- */
.layer-toggles {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

.layer-toggle {
    padding: 0.3rem 0.7rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border: 1.5px solid;
    transition: all 0.2s;
    background: transparent;
    font-family: var(--font-body);
    line-height: 1.3;
}

.layer-toggle:hover {
    opacity: 0.85;
}

.layer-toggle.active {
    color: white;
}

.layer-toggle-raised {
    border-color: var(--tree-link);
    color: var(--tree-link);
}

.layer-toggle-raised.active {
    background: var(--tree-link);
}

.layer-toggle-biological {
    border-color: #4A7C59;
    color: #4A7C59;
}

.layer-toggle-biological.active {
    background: #4A7C59;
}

.layer-toggle-whangai {
    border-color: #7B4F9E;
    color: #7B4F9E;
}

.layer-toggle-whangai.active {
    background: #7B4F9E;
}

/* ----- Collapse Indicator & Badge ----- */
.collapse-indicator {
    cursor: pointer;
}

.collapse-indicator:hover circle:first-child {
    fill: #F5F0EA;
}

.collapse-badge {
    pointer-events: none;
}

/* ----- Saved Views ----- */
.saved-views-dropdown {
    position: relative;
    display: inline-block;
}

.saved-views-list {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 100;
    margin-top: 4px;
}

.saved-view-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
}

.saved-view-item:last-child {
    border-bottom: none;
}

.saved-view-item:hover {
    background: var(--bg);
}

.saved-view-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
}

.saved-view-delete {
    color: var(--danger);
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 0 0.25rem;
    margin-left: 0.5rem;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.saved-view-delete:hover {
    opacity: 1;
}

/* ----- Relationship Line Styles ----- */
.tree-link-biological {
    stroke: #4A7C59 !important;
    stroke-dasharray: 3,3;
    stroke-opacity: 0.7;
}

.tree-link-whangai {
    stroke: #7B4F9E !important;
    stroke-dasharray: 6,3;
    stroke-opacity: 0.7;
}

.tree-link-step {
    stroke: #3B7DD8 !important;
    stroke-dasharray: 4,2;
    stroke-opacity: 0.6;
}

.tree-link-foster {
    stroke: #E67E22 !important;
    stroke-dasharray: 2,2;
    stroke-opacity: 0.6;
}

.tree-link-divorced {
    stroke-dasharray: 5,5 !important;
}

.tree-link-widowed {
    stroke-dasharray: 2,4 !important;
}

/* ----- Marriage Status Label ----- */
.marriage-status {
    font-size: 9px;
    fill: var(--text-muted);
    text-anchor: middle;
    pointer-events: none;
}

/* ----- Half-sibling Label ----- */
.half-sibling-label {
    font-size: 8px;
    fill: var(--text-muted);
    font-style: italic;
    pointer-events: none;
}

/* ----- Fan Chart Specific ----- */
.fan-wedge {
    cursor: pointer;
    transition: opacity 0.15s;
}

.fan-wedge:hover {
    opacity: 0.85;
}

/* ----- Hourglass Layout ----- */
.hourglass-divider {
    stroke: var(--border);
    stroke-width: 1;
    stroke-dasharray: 8,4;
    stroke-opacity: 0.4;
}

/* ----- Pedigree Generation Labels ----- */
.pedigree-gen-label {
    font-size: 10px;
    font-weight: 600;
    fill: var(--primary-light);
    opacity: 0.7;
    pointer-events: none;
}

/* ----- Layout selector in controls ----- */
.tree-controls .form-select#tree-layout-select {
    min-width: 140px;
}

/* ----- Responsive adjustments for Phase 2 controls ----- */
@media (max-width: 768px) {
    .layer-toggles {
        gap: 0.25rem;
    }

    .layer-toggle {
        padding: 0.2rem 0.5rem;
        font-size: 0.7rem;
    }

    .saved-views-list {
        min-width: 180px;
        right: 0;
        left: auto;
    }

    .tree-controls .form-select#tree-layout-select {
        min-width: 110px;
    }
}

/* ============================================================
   Phase 3: Photos, Stories & Media
   ============================================================ */

/* ----- Photo Gallery Filters ----- */
.photos-filters {
    margin-bottom: 1.5rem;
}

.photos-filter-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.photos-filter-row .form-select {
    min-width: 160px;
    padding: 0.45rem 2rem 0.45rem 0.75rem;
    font-size: 0.85rem;
}

/* ----- Photo Gallery Masonry Grid ----- */
.photos-masonry {
    columns: 4 240px;
    column-gap: 1rem;
}

.photos-masonry-item {
    break-inside: avoid;
    margin-bottom: 1rem;
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: box-shadow var(--transition), transform var(--transition);
}

.photos-masonry-item:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.photos-masonry-item img {
    width: 100%;
    display: block;
    transition: transform var(--transition);
}

.photos-masonry-item:hover img {
    transform: scale(1.03);
}

.photos-masonry-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
    color: #FFFFFF;
    padding: 2rem 0.75rem 0.75rem;
    opacity: 0;
    transition: opacity var(--transition);
}

.photos-masonry-item:hover .photos-masonry-overlay {
    opacity: 1;
}

.photos-masonry-caption {
    font-size: 0.85rem;
    font-weight: 500;
}

.photos-masonry-date {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-top: 0.15rem;
}

/* ----- Lightbox ----- */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.lightbox-close {
    position: fixed;
    top: 1rem;
    right: 1.25rem;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 2rem;
    cursor: pointer;
    z-index: 3010;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition);
}

.lightbox-close:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.15);
}

.lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    z-index: 3010;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition);
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
}

.lightbox-nav-prev {
    left: 1rem;
}

.lightbox-nav-next {
    right: 1rem;
}

.lightbox-content {
    display: flex;
    max-width: 95vw;
    max-height: 92vh;
    gap: 0;
    animation: slideUp 0.25s ease;
}

.lightbox-image-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-width: 0;
}

.lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.lightbox-res-badge {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    background: rgba(169, 68, 66, 0.9);
    color: #FFFFFF;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.6rem;
    border-radius: 10px;
}

.lightbox-info {
    width: 320px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.06);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1.25rem;
    overflow-y: auto;
    max-height: 90vh;
    color: rgba(255, 255, 255, 0.9);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.lightbox-counter {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 0.75rem;
}

.lightbox-caption {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    color: #FFFFFF;
    margin-bottom: 0.75rem;
}

.lightbox-meta {
    margin-bottom: 1rem;
}

.lightbox-meta-item {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.25rem;
}

.lightbox-meta-item strong {
    color: rgba(255, 255, 255, 0.9);
}

.lightbox-tags {
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.lightbox-tags strong {
    display: block;
    margin-bottom: 0.35rem;
    color: rgba(255, 255, 255, 0.7);
}

.lightbox-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.lightbox-tag-chip {
    display: inline-block;
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.9);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    text-decoration: none;
    transition: background var(--transition);
}

.lightbox-tag-chip:hover {
    background: rgba(255, 255, 255, 0.22);
    color: #FFFFFF;
}

.lightbox-actions {
    margin-bottom: 1rem;
}

.lightbox-like-btn {
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: rgba(255, 255, 255, 0.85) !important;
}

.lightbox-like-btn:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #FFFFFF !important;
}

.lightbox-comments h4 {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.75rem;
    font-family: var(--font-body);
}

.lightbox-comment {
    padding: 0.6rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.lightbox-comment-author {
    font-weight: 600;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.85);
}

.lightbox-comment-date {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 0.2rem;
}

.lightbox-comment-text {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.5;
}

.lightbox-comment-form {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.lightbox-comment-form .form-textarea {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: #FFFFFF;
    font-size: 0.85rem;
    min-height: 60px;
}

.lightbox-comment-form .form-textarea::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.lightbox-comment-form .form-textarea:focus {
    border-color: rgba(255, 255, 255, 0.35);
    box-shadow: none;
}

/* ----- Photo Upload Modal Enhancements ----- */
.photo-upload-dropzone {
    min-height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.photo-upload-dragover {
    border-color: var(--accent) !important;
    background: var(--bg-card) !important;
    box-shadow: 0 0 0 3px rgba(193, 154, 107, 0.2);
}

.file-upload-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.photo-upload-previews {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.photo-upload-preview-item {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    aspect-ratio: 1;
    border: 1px solid var(--border);
}

.photo-upload-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-upload-preview-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    color: #FFFFFF;
    font-size: 0.65rem;
    padding: 0.15rem 0.3rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.photo-upload-preview-remove {
    position: absolute;
    top: 0.15rem;
    right: 0.15rem;
    width: 22px;
    height: 22px;
    background: rgba(0, 0, 0, 0.6);
    color: #FFFFFF;
    border: none;
    border-radius: 50%;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.photo-upload-preview-remove:hover {
    background: var(--danger);
}

.photo-upload-progress {
    margin-top: 1rem;
    background: var(--bg);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    height: 28px;
}

.photo-upload-progress-bar {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s ease;
    width: 0%;
    border-radius: var(--radius);
}

.photo-upload-progress-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
}

/* ----- Albums Grid ----- */
.albums-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
}

.album-card {
    display: block;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    color: inherit;
}

.album-card:hover {
    box-shadow: var(--shadow-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
    color: inherit;
}

.album-card-cover {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.album-card-cover-placeholder {
    width: 100%;
    height: 180px;
    background: linear-gradient(135deg, var(--bg) 0%, var(--border) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.album-card-info {
    padding: 1rem 1.25rem;
}

.album-card-name {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.2rem;
}

.album-card-meta {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 0.35rem;
}

.album-card-category {
    display: inline-block;
    background: var(--accent-light);
    color: var(--primary-dark);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    text-transform: capitalize;
}

/* ----- Stories Page ----- */
.stories-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.stories-controls .form-input {
    font-size: 0.9rem;
}

.stories-controls .form-select {
    font-size: 0.85rem;
    padding: 0.45rem 2rem 0.45rem 0.75rem;
}

.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.25rem;
}

.stories-card {
    display: block;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    color: inherit;
}

.stories-card:hover {
    box-shadow: var(--shadow-hover);
    border-color: var(--accent);
    color: inherit;
}

.stories-card-header {
    margin-bottom: 0.75rem;
}

.stories-card-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    color: var(--primary);
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.stories-card-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stories-card-excerpt {
    font-size: 0.9rem;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

.stories-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8rem;
}

.stories-card-person-link {
    color: var(--accent);
    font-weight: 500;
}

.stories-card-read {
    color: var(--primary-light);
    font-weight: 600;
}

/* ----- Story Detail Page ----- */
.story-detail-page {
    max-width: 860px;
}

.story-detail {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 2.5rem;
    margin-bottom: 2rem;
}

.story-detail-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}

.story-detail-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.story-detail-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.story-detail-date {
    font-size: 0.9rem;
    color: var(--text-light);
}

.story-detail-person {
    font-size: 0.9rem;
    color: var(--text-light);
}

.story-detail-person a {
    color: var(--accent);
    font-weight: 600;
}

.story-detail-content {
    max-width: 720px;
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text);
}

.story-detail-content h2 {
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    font-size: 1.5rem;
}

.story-detail-content h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

.story-detail-content h4 {
    margin-top: 1.25rem;
    margin-bottom: 0.35rem;
}

.story-detail-content blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 1.25rem;
    margin: 1.25rem 0;
    color: var(--text-light);
    font-style: italic;
}

.story-detail-content strong {
    color: var(--primary);
}

.story-detail-content a {
    color: var(--accent);
    text-decoration: underline;
}

.story-detail-actions {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* ----- Story Comments ----- */
.story-comments {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.story-comments h3 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.story-comment {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.story-comment:last-child {
    border-bottom: none;
}

.story-comment-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.3rem;
}

.story-comment-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.story-comment-text {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text);
}

.story-comment-form {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-end;
}

.story-comment-form .form-textarea {
    width: 100%;
}

/* ----- Story Editor ----- */
.story-editor-title-input {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    padding: 0.75rem 1rem;
}

.story-toolbar {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
}

.story-toolbar-btn {
    min-width: 32px;
    height: 32px;
    padding: 0 0.5rem !important;
    font-size: 0.85rem !important;
}

.story-toolbar-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 0.25rem;
}

.story-editor-wrap {
    position: relative;
}

.story-editor-textarea {
    border-radius: 0 0 var(--radius) var(--radius) !important;
    font-size: 1rem;
    line-height: 1.7;
    min-height: 350px;
}

.story-editor-preview {
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    min-height: 350px;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text);
}

.story-editor-preview h2 {
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.story-editor-preview h3 {
    margin-top: 1rem;
    margin-bottom: 0.35rem;
}

.story-editor-preview blockquote {
    border-left: 4px solid var(--accent);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-light);
    font-style: italic;
}

.story-draft-notice {
    background: var(--info-light);
    color: var(--info);
    padding: 0.6rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid rgba(59, 125, 216, 0.2);
}

.story-autosave-status {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    text-align: right;
}

/* ----- Phase 3 Responsive ----- */
@media (max-width: 1024px) {
    .lightbox-content {
        flex-direction: column;
        max-height: 95vh;
    }

    .lightbox-info {
        width: 100%;
        max-height: 40vh;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 0 0 var(--radius) var(--radius);
    }

    .lightbox-image {
        max-height: 55vh;
    }

    .lightbox-nav-prev {
        left: 0.5rem;
    }

    .lightbox-nav-next {
        right: 0.5rem;
    }
}

@media (max-width: 768px) {
    .photos-masonry {
        columns: 2 140px;
        column-gap: 0.5rem;
    }

    .photos-masonry-item {
        margin-bottom: 0.5rem;
    }

    .photos-filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .photos-filter-row .form-select {
        min-width: 100%;
    }

    .albums-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .album-card-cover,
    .album-card-cover-placeholder {
        height: 140px;
    }

    .stories-grid {
        grid-template-columns: 1fr;
    }

    .story-detail {
        padding: 1.5rem;
    }

    .story-detail-header h1 {
        font-size: 1.5rem;
    }

    .story-detail-content {
        font-size: 1rem;
    }

    .story-toolbar {
        flex-wrap: wrap;
    }

    .lightbox-nav {
        width: 36px;
        height: 36px;
    }

    .lightbox-nav svg {
        width: 24px;
        height: 24px;
    }

    .lightbox-info {
        padding: 1rem;
        max-height: 45vh;
    }
}

/* ============================================================
   Phase 4: Personal Experience — Homepage, Onboarding, Access
   ============================================================ */

/* ----- User Homepage ----- */
.user-homepage {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.homepage-banner {
    width: 100%;
    height: 240px;
    border-radius: 12px;
    object-fit: cover;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    position: relative;
    overflow: hidden;
}

.banner-upload-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    color: rgba(255, 255, 255, 0.85);
    opacity: 0;
    cursor: pointer;
    transition: opacity 0.2s;
    font-size: 0.85rem;
    font-weight: 500;
}

.banner-upload-overlay:hover {
    opacity: 1;
}

.homepage-header {
    text-align: center;
    margin-bottom: 2rem;
}

.homepage-heading {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--primary);
}

.homepage-subtitle {
    color: var(--text-light);
    font-size: 1.1rem;
}

.homepage-bio {
    max-width: 600px;
    margin: 1rem auto;
    line-height: 1.7;
}

.homepage-widgets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.homepage-widget {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.homepage-widget-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.widget-empty {
    text-align: center;
    padding: 1rem 0;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Homepage Edit */
.homepage-edit-bar {
    text-align: center;
    margin-bottom: 1.5rem;
}

.homepage-edit-form {
    max-width: 600px;
    margin: 1.5rem auto 0;
    text-align: left;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

/* Homepage Pinned Post */
.homepage-pinned {
    max-width: 600px;
    margin: 0 auto 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--accent-light);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
}

.homepage-pinned-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.homepage-pinned p {
    color: var(--text);
    line-height: 1.7;
    margin: 0;
}

/* Birthday Widget */
.birthday-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.birthday-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.4rem 0;
}

.birthday-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.birthday-info {
    flex: 1;
    min-width: 0;
}

.birthday-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
    text-decoration: none;
}

.birthday-name:hover {
    color: var(--accent);
}

.birthday-detail {
    font-size: 0.8rem;
    color: var(--text-light);
}

.birthday-today {
    font-weight: 700;
    color: var(--accent);
}

/* Activity Widget */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.35rem 0;
}

.activity-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--bg);
}

.activity-icon-person { color: var(--primary-light); }
.activity-icon-photo { color: var(--accent); }
.activity-icon-story { color: var(--success); }

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-text {
    font-size: 0.85rem;
    color: var(--text);
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
}

a.activity-text:hover {
    color: var(--accent);
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Leaderboard Widget */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.45rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.leaderboard-item:hover {
    background: var(--bg);
}

.leaderboard-rank {
    width: 24px;
    text-align: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.leaderboard-rank-num {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-light);
}

.leaderboard-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-points {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
}

/* Events Widget */
.events-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.event-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.event-date-badge {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--accent-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.event-date-month {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--primary);
    line-height: 1;
}

.event-date-day {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.event-info {
    flex: 1;
    min-width: 0;
}

.event-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

.event-detail {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ----- Family Landing Page ----- */
.family-home {
    min-height: calc(100vh - var(--nav-height));
}

.family-hero {
    text-align: center;
    padding: 4rem 2rem;
    background: linear-gradient(135deg, var(--bg) 0%, #F0EBE3 50%, #E8DFD4 100%);
}

.family-hero h1 {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.family-hero-subtitle {
    font-size: 1.15rem;
    color: var(--text-light);
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.6;
}

.family-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    padding: 2rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.family-stat {
    text-align: center;
}

.family-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    font-family: var(--font-heading);
}

.family-stat-label {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 0.15rem;
}

.family-home-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.family-home-greeting {
    text-align: center;
    margin-bottom: 2rem;
}

.family-home-greeting h2 {
    margin-bottom: 1rem;
}

.family-home-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.family-home-widgets {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1.5rem 2rem;
}

.family-featured-story {
    max-width: 700px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    text-align: center;
}

.family-featured-story h3 {
    margin-bottom: 1rem;
}

.family-featured-story-content {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-light);
    font-style: italic;
}

/* ----- Access Request Form (public page) ----- */
.access-request-form {
    max-width: 500px;
    margin: 2rem auto;
}

.access-request-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    border: 1px solid var(--border);
}

.access-request-card h2 {
    text-align: center;
    margin-bottom: 0.5rem;
}

.access-request-success {
    background: var(--success-light);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(74, 124, 89, 0.2);
}

/* ----- Access Requests Admin Panel ----- */
.access-requests-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.access-request-item {
    padding: 1.25rem;
}

.access-request-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.access-request-person {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.access-request-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.access-request-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.access-request-email {
    font-size: 0.8rem;
    color: var(--text-light);
}

.access-request-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.access-request-field {
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 0.5rem;
    padding: 0.35rem 0;
}

.access-request-field strong {
    color: var(--text-light);
    font-size: 0.8rem;
}

.access-request-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.admin-badge {
    display: inline-block;
    background: var(--accent);
    color: #FFFFFF;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.15rem 0.55rem;
    border-radius: 10px;
    vertical-align: middle;
    margin-left: 0.35rem;
    font-family: var(--font-body);
}

/* ----- Invite System ----- */
.invite-create-form h4 {
    margin-bottom: 0.25rem;
}

.invite-generated {
    background: var(--success-light);
    border-radius: var(--radius);
    padding: 1rem;
    border: 1px solid rgba(74, 124, 89, 0.2);
}

.invite-generated-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--success);
    margin-bottom: 0.5rem;
}

.invite-generated-url {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.invite-generated-url code {
    flex: 1;
    background: var(--bg-card);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    word-break: break-all;
    border: 1px solid var(--border);
    min-width: 0;
}

.invite-generated-qr {
    text-align: center;
}

.invite-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.invite-item {
    padding: 0.75rem;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.invite-item-url {
    margin-bottom: 0.35rem;
}

.invite-url-text {
    font-size: 0.75rem;
    color: var(--text-light);
    word-break: break-all;
    display: block;
    background: var(--bg-card);
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.invite-item-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.invite-item-message {
    font-size: 0.8rem;
    color: var(--text);
    font-style: italic;
}

.invite-item-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.invite-item-actions {
    display: flex;
    gap: 0.35rem;
}

/* ----- Onboarding Overlay ----- */
.onboarding-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.onboarding-progress {
    display: flex;
    gap: 0.5rem;
    padding: 1.5rem 1rem 0.5rem;
    justify-content: center;
}

.onboarding-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    transition: all 0.3s;
}

.onboarding-dot.active {
    background: var(--accent);
    transform: scale(1.25);
}

.onboarding-dot.completed {
    background: var(--success);
}

.onboarding-step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
    width: 100%;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.onboarding-step-enter {
    animation: onboardingSlideIn 0.3s ease;
}

.onboarding-step-exit {
    opacity: 0;
    transform: translateX(-20px);
}

@keyframes onboardingSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.onboarding-icon {
    margin-bottom: 1.5rem;
}

.onboarding-done-icon {
    animation: onboardingCheckmark 0.5s ease 0.1s both;
}

@keyframes onboardingCheckmark {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.onboarding-title {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    color: var(--primary);
    margin-bottom: 0.75rem;
}

.onboarding-desc {
    color: var(--text-light);
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 0.5rem;
    max-width: 480px;
}

.onboarding-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    align-items: center;
}

.onboarding-done-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
    align-items: center;
}

/* Onboarding Search */
.onboarding-search {
    width: 100%;
    max-width: 400px;
    margin-top: 1rem;
    text-align: left;
}

.onboarding-search-results {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 0.5rem;
    border-radius: var(--radius);
}

.onboarding-search-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.onboarding-search-result {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.35rem;
    cursor: pointer;
    transition: all 0.15s;
}

.onboarding-search-result:hover {
    border-color: var(--accent);
    background: var(--bg);
}

.onboarding-search-result.selected {
    border-color: var(--success);
    background: var(--success-light);
}

.onboarding-search-result-photo {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--primary-light);
    flex-shrink: 0;
    font-size: 0.9rem;
}

.onboarding-search-result-info {
    flex: 1;
    min-width: 0;
}

.onboarding-search-result-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}

.onboarding-search-result-dates {
    font-size: 0.8rem;
    color: var(--text-light);
}

.onboarding-search-result-check {
    flex-shrink: 0;
}

/* Onboarding Photo Upload */
.onboarding-photo-upload {
    width: 100%;
    max-width: 300px;
    margin-top: 1rem;
}

/* Onboarding Family Grid */
.onboarding-family-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
    width: 100%;
    max-width: 500px;
}

.onboarding-family-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    transition: all 0.15s;
}

.onboarding-family-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.onboarding-family-photo {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    margin-bottom: 0.5rem;
}

.onboarding-family-initials {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.5rem;
    font-weight: 700;
    color: var(--primary-light);
    font-size: 1rem;
}

.onboarding-family-name {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text);
    margin-bottom: 0.15rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.onboarding-family-rel {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Onboarding Contribution Grid */
.onboarding-contribution-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1rem;
    width: 100%;
    max-width: 480px;
}

.onboarding-contribution-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text);
}

.onboarding-contribution-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow);
    color: var(--primary);
}

.onboarding-contribution-card span {
    font-size: 0.8rem;
    font-weight: 500;
}

/* Onboarding Carousel */
.onboarding-carousel {
    width: 100%;
    max-width: 480px;
    position: relative;
    min-height: 200px;
}

.onboarding-slide {
    display: none;
    animation: onboardingSlideIn 0.3s ease;
}

.onboarding-slide.active {
    display: block;
}

.onboarding-slide-icon {
    margin-bottom: 1rem;
}

.onboarding-carousel-nav {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.onboarding-carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.onboarding-carousel-dot.active {
    background: var(--accent);
    transform: scale(1.3);
}

.onboarding-carousel-controls {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* ----- Phase 4 Responsive ----- */
@media (max-width: 768px) {
    .user-homepage {
        padding: 1.25rem 1rem;
    }

    .homepage-banner {
        height: 160px;
        border-radius: 8px;
    }

    .homepage-heading {
        font-size: 1.5rem;
    }

    .homepage-widgets {
        grid-template-columns: 1fr;
    }

    .family-hero {
        padding: 2.5rem 1.5rem;
    }

    .family-hero h1 {
        font-size: 2rem;
    }

    .family-stats {
        gap: 1.5rem;
        padding: 1.5rem 1rem;
    }

    .family-stat-value {
        font-size: 1.5rem;
    }

    .family-home-content {
        padding: 1.5rem 1rem;
    }

    .access-request-form {
        margin: 1.5rem auto;
    }

    .access-request-card {
        padding: 1.5rem;
    }

    .access-request-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .access-request-actions {
        flex-wrap: wrap;
    }

    .invite-generated-url {
        flex-direction: column;
        align-items: stretch;
    }

    .onboarding-step {
        padding: 1.5rem 1rem;
    }

    .onboarding-title {
        font-size: 1.35rem;
    }

    .onboarding-family-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.75rem;
    }

    .onboarding-contribution-grid {
        grid-template-columns: 1fr;
        max-width: 300px;
    }
}
