/* Family Tree — base styles (Phase 1: login + placeholders) */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    color: #222;
    background: #f5f6f8;
}

/* --- Auth layout ---------------------------------------------------------- */

body.auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-box {
    background: #fff;
    padding: 32px 36px 28px;
    max-width: 380px;
    width: 100%;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
}

.auth-box h1 {
    margin: 0 0 4px;
    font-size: 22px;
}

.auth-box .subtitle {
    margin: 0 0 18px;
    color: #666;
    font-size: 13px;
}

.auth-box label {
    display: block;
    margin-top: 14px;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.auth-box input {
    width: 100%;
    padding: 10px 12px;
    margin-top: 4px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 15px;
    font-family: inherit;
}

.auth-box input:focus {
    outline: none;
    border-color: #2b6cb0;
    box-shadow: 0 0 0 2px rgba(43, 108, 176, .15);
}

.auth-box button {
    margin-top: 22px;
    width: 100%;
    padding: 11px;
    background: #2b6cb0;
    color: #fff;
    border: 0;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.auth-box button:hover {
    background: #1e4e8c;
}

.auth-box .error-box {
    margin-top: 14px;
    padding: 10px 12px;
    background: #fde7e9;
    border: 1px solid #b00020;
    color: #b00020;
    border-radius: 4px;
    font-size: 13px;
}

.auth-box .hint {
    margin: 18px 0 0;
    font-size: 12px;
    color: #888;
    text-align: center;
}

.auth-box .lang-switch {
    margin: 14px 0 0;
    text-align: center;
    font-size: 12px;
}

.auth-box .lang-switch a {
    color: #888;
    text-decoration: none;
    margin: 0 4px;
}

.auth-box .lang-switch a:hover {
    color: #2b6cb0;
}

/* --- Top bar (authenticated pages) ---------------------------------------- */

.topbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 10px 20px;
    background: #fff;
    border-bottom: 1px solid #e4e6eb;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
    position: relative;
    z-index: 100;
}

.topbar-brand {
    font-size: 16px;
    font-weight: 700;
    color: #2b6cb0;
    text-decoration: none;
}
.topbar-brand:hover { color: #1e4e8c; }

/* ── Burger button (mobile only) ──────────────────────────────────── */

.topbar-burger {
    display: none;             /* hidden on desktop */
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    flex-direction: column;
    gap: 4px;
    margin-left: auto;
}
.topbar-burger span {
    display: block;
    width: 20px;
    height: 2px;
    background: #333;
    border-radius: 2px;
    transition: transform .2s, opacity .2s;
}
/* Animate burger → ✕ */
.topbar.is-menu-open .topbar-burger span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}
.topbar.is-menu-open .topbar-burger span:nth-child(2) { opacity: 0; }
.topbar.is-menu-open .topbar-burger span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* ── Main nav (horizontal on desktop) ─────────────────────────────── */

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.topbar-nav-spacer {
    flex: 1;
}

/* ── Nav items (links + buttons) ──────────────────────────────────── */

.topbar-nav-item {
    padding: 6px 12px;
    border: 1px solid #d0d4db;
    color: #2b6cb0;
    text-decoration: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    background: #fff;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.topbar-nav-item:hover {
    background: #eef3fb;
    border-color: #2b6cb0;
}
.topbar-nav-item.is-active {
    background: #eef3fb;
    border-color: #2b6cb0;
    color: #1e4e8c;
    font-weight: 600;
}

/* Primary action (+ Add person) */
.topbar-nav-primary {
    background: #2b6cb0;
    color: #fff;
    border-color: #2b6cb0;
}
.topbar-nav-primary:hover {
    background: #1e4e8c;
    color: #fff;
}

/* ── Language dropdown ────────────────────────────────────────────── */

.lang-dropdown {
    position: relative;
}
.lang-dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #d0d4db;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    font-family: inherit;
}
.lang-dropdown-toggle:hover {
    border-color: #2b6cb0;
    color: #2b6cb0;
}
.lang-dropdown-arrow {
    transition: transform .2s;
}
.lang-dropdown.is-open .lang-dropdown-arrow {
    transform: rotate(180deg);
}
.lang-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 60px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    z-index: 200;
    overflow: hidden;
}
.lang-dropdown-menu[hidden] { display: none; }
.lang-dropdown-item {
    display: block;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    text-decoration: none;
    text-align: center;
}
.lang-dropdown-item:hover { background: #f1f5f9; color: #2b6cb0; }
.lang-dropdown-item.is-active {
    background: #eef3fb;
    color: #2b6cb0;
    font-weight: 600;
}

/* ── Logout ───────────────────────────────────────────────────────── */

.topbar-logout button {
    padding: 6px 12px;
    background: #fff;
    color: #e53e3e;
    border: 1px solid #e53e3e;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.topbar-logout button:hover {
    background: #e53e3e;
    color: #fff;
}

/* --- Tree viewport -------------------------------------------------------- */

.tree-viewport {
    position: fixed;
    left: 0;
    right: 0;
    top: 52px;          /* below topbar */
    bottom: 0;
    overflow: hidden;
    background:
        linear-gradient(#eef1f5, #eef1f5),
        radial-gradient(circle at 20% 30%, rgba(43, 108, 176, .05), transparent 60%);
    cursor: grab;
}

.tree-viewport.is-dragging {
    cursor: grabbing;
}

.tree-viewport canvas {
    display: block;
    /* Canvas sized via JS to devicePixelRatio; never let CSS stretch it. */
    image-rendering: -webkit-optimize-contrast;
}

.tree-controls {
    position: absolute;
    right: 18px;
    bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 5;
}

.tree-controls button {
    width: 36px;
    height: 36px;
    background: #fff;
    border: 1px solid #d0d4db;
    border-radius: 4px;
    font-size: 18px;
    font-weight: 600;
    color: #2b6cb0;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}

.tree-controls button:hover {
    background: #f5f7fb;
}

.tree-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #555;
    padding: 24px;
}

.tree-empty h2 {
    margin: 0 0 10px;
    font-size: 20px;
    color: #2b6cb0;
}

.tree-empty p {
    margin: 0 0 22px;
    max-width: 380px;
    font-size: 14px;
    color: #666;
}

.tree-empty button {
    padding: 10px 18px;
    background: #2b6cb0;
    color: #fff;
    border: 0;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.tree-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 14px;
}

/* --- Modal ---------------------------------------------------------------- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 60px 18px 18px;
    z-index: 50;
    overflow-y: auto;
}

.modal-overlay.is-open {
    display: flex;
}

.modal-card {
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
    max-width: 520px;
    width: 100%;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid #eef0f4;
}

.modal-title {
    margin: 0;
    font-size: 16px;
    color: #2b6cb0;
}

.modal-close {
    background: transparent;
    border: 0;
    font-size: 22px;
    line-height: 1;
    color: #888;
    cursor: pointer;
    padding: 2px 6px;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 16px 20px 20px;
}

.modal-message {
    margin: 0 0 18px;
    color: #444;
    font-size: 14px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn {
    padding: 9px 16px;
    background: #fff;
    color: #2b6cb0;
    border: 1px solid #2b6cb0;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.btn:hover {
    background: #eef3fb;
}

.btn.btn-primary {
    background: #2b6cb0;
    color: #fff;
}

.btn.btn-primary:hover {
    background: #1e4e8c;
}

.btn.btn-danger {
    background: #c53030;
    color: #fff;
    border-color: #c53030;
}

.btn.btn-danger:hover {
    background: #9b1c1c;
}

.btn.btn-sm {
    padding: 6px 10px;
    font-size: 12px;
}

.btn[disabled],
.btn[disabled]:hover {
    opacity: .55;
    cursor: not-allowed;
    background: inherit;
    color: inherit;
}

/* --- Person side panel --------------------------------------------------- */

.person-panel {
    position: fixed;
    top: 52px;          /* below topbar */
    bottom: 0;
    right: 0;
    width: 320px;
    background: #fff;
    border-left: 1px solid #e4e6eb;
    box-shadow: -2px 0 6px rgba(0, 0, 0, .04);
    overflow-y: auto;
    z-index: 20;
    transform: translateX(100%);
    transition: transform .18s ease-out;
}

.person-panel.is-open {
    transform: translateX(0);
}

.person-panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px 12px;
    border-bottom: 1px solid #eef0f4;
}

.person-panel-head h2 {
    margin: 0;
    flex: 1;
    font-size: 15px;
    color: #2b6cb0;
}

.person-panel-head .close {
    background: transparent;
    border: 0;
    font-size: 22px;
    line-height: 1;
    color: #888;
    cursor: pointer;
    padding: 0 4px;
}

.person-panel-head .close:hover { color: #333; }

.person-panel-body { padding: 14px 18px 20px; }

.person-panel-body .person-panel-photo {
    margin: -2px 0 14px;
    border-radius: 6px;
    overflow: hidden;
    background: #f5f6f8;
    max-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.person-panel-body .person-panel-photo img {
    display: block;
    width: 100%;
    max-height: 260px;
    object-fit: contain;
}

.person-panel-body h3 {
    margin: 16px 0 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #8893a5;
}

.person-panel-body h3:first-child { margin-top: 0; }

.person-panel-body .person-title {
    margin: 0 0 4px;
    font-size: 18px;
    color: #1a202c;
}

.person-panel-body .person-title small {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 400;
    margin-left: 6px;
}

.person-panel-body .person-years {
    margin: 0 0 10px;
    color: #64748b;
    font-size: 14px;
}

.person-panel-body .draft-banner {
    background: #fff8e1;
    border: 1px solid #f6c97a;
    color: #8a6417;
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 12px;
    margin: 0 0 12px;
}

.person-panel-body dl {
    margin: 0;
    display: grid;
    grid-template-columns: 110px 1fr;
    row-gap: 6px;
    font-size: 13px;
}

.person-panel-body dt {
    color: #64748b;
    font-weight: 500;
}

.person-panel-body dd {
    margin: 0;
    color: #1a202c;
    word-break: break-word;
}

.person-panel-body dd.muted {
    color: #a0aec0;
    font-style: italic;
}

.person-panel-body .bio {
    margin: 6px 0 0;
    font-size: 13px;
    line-height: 1.55;
    color: #2d3748;
    white-space: pre-wrap;
}

.person-panel-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

.person-panel-actions .btn {
    padding: 8px 10px;
    font-size: 12px;
    text-align: center;
}

.person-panel-actions .btn.wide {
    grid-column: span 2;
}

/* --- Person panel "Photos of this person" (Phase 2 pass #5) -------------- */

.person-panel-photos { margin-top: 4px; }

.person-panel-photos h3 {
    margin: 16px 0 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #8893a5;
}

.person-panel-photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.person-panel-photo-tile {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 4px;
    background: #f5f6f8;
    border: 1px solid #e4e6eb;
    text-decoration: none;
    color: inherit;
    display: block;
    transition: transform .12s ease-out;
}

.person-panel-photo-tile:hover {
    transform: scale(1.03);
    border-color: #2b6cb0;
}

.person-panel-photo-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.person-panel-photo-tile-meta {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 4px 6px;
    background: linear-gradient(transparent, rgba(15, 23, 42, .75));
    color: #fff;
    font-size: 10px;
    line-height: 1.3;
    pointer-events: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transition: opacity .12s ease-out;
}

.person-panel-photo-tile:hover .person-panel-photo-tile-meta {
    opacity: 1;
}

/* --- Person panel attachments (Phase 2 pass #10) ------------------------- */
/* Always-visible section above comments. Lists PDFs and image scans tied to
 * the person; admin/contributor also get the "Attach file" button. */

.person-panel-attachments { margin-top: 4px; }

.person-panel-attachments h3 {
    margin: 16px 0 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #8893a5;
}

.person-panel-attachments-empty {
    margin: 0 0 6px;
    font-size: 12px;
    color: #94a3b8;
}

.person-panel-attachment-list {
    list-style: none;
    margin: 0 0 8px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.person-panel-attachment-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid #e4e6eb;
    border-radius: 4px;
    background: #fafbfc;
}

.person-panel-attachment-icon {
    font-size: 18px;
    line-height: 1;
    flex: 0 0 auto;
}

.person-panel-attachment-main {
    flex: 1 1 auto;
    min-width: 0;
}

.person-panel-attachment-title {
    display: block;
    font-size: 13px;
    color: #1f2937;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.person-panel-attachment-title:hover {
    color: #2b6cb0;
    text-decoration: underline;
}

.person-panel-attachment-meta {
    font-size: 10px;
    color: #8893a5;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.person-panel-attachment-actions {
    flex: 0 0 auto;
}

.person-panel-attachments-toolbar {
    margin-top: 4px;
}

.person-panel-attachment-form .form-field {
    display: block;
    margin-bottom: 10px;
}

.person-panel-attachment-form .form-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #8893a5;
    margin-bottom: 4px;
}

.person-panel-attachment-form .form-hint {
    margin: 4px 0 0;
    font-size: 11px;
    color: #94a3b8;
}

.person-panel-attachment-form textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font: inherit;
    resize: vertical;
}

.person-panel-attachment-form input[type="file"] {
    display: block;
    font-size: 12px;
}

.person-panel-attachment-form .form-error {
    margin: 0 0 8px;
    padding: 6px 8px;
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 4px;
    font-size: 12px;
}

/* --- Comments thread (Phase 2 pass #6) ----------------------------------- */
/* Shared between the person-panel drawer and the album-photo lightbox. Base
 * styles are surface-agnostic; lightbox-specific overrides live in the
 * .lightbox-comments block further down. */

.comments-title {
    margin: 16px 0 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #8893a5;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 6px;
}

.comments-empty {
    margin: 6px 0 10px;
    color: #94a3b8;
    font-size: 12px;
    font-style: italic;
}

.comments-loading {
    margin: 6px 0;
    color: #94a3b8;
    font-size: 12px;
}

.comments-error {
    margin: 6px 0;
    color: #c03333;
    font-size: 12px;
}

.comment-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.comment-avatar {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #2b6cb0;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    user-select: none;
}

.comment-content {
    flex: 1 1 auto;
    min-width: 0;
    position: relative;
    padding: 7px 28px 7px 10px;
    background: #f5f6f8;
    border-radius: 6px;
    border: 1px solid #e4e6eb;
}

.comment-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
    font-size: 11px;
    color: #64748b;
}

.comment-author {
    font-weight: 600;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.comment-date {
    flex: 0 0 auto;
    font-size: 10px;
    white-space: nowrap;
}

.comment-body {
    font-size: 13px;
    line-height: 1.4;
    color: #0f172a;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.comment-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    background: transparent;
    border: 0;
    color: #94a3b8;
    font-size: 16px;
    line-height: 1;
    padding: 2px 6px;
    cursor: pointer;
    border-radius: 3px;
    transition: color .12s ease-out, background .12s ease-out;
}

.comment-delete:hover {
    color: #c03333;
    background: rgba(192, 51, 51, .08);
}

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

.comments-form-text {
    width: 100%;
    padding: 8px 10px;
    font: inherit;
    font-size: 13px;
    line-height: 1.4;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    resize: vertical;
    min-height: 48px;
    box-sizing: border-box;
}

.comments-form-text:focus {
    outline: none;
    border-color: #2b6cb0;
    box-shadow: 0 0 0 2px rgba(43, 108, 176, .18);
}

.comments-form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.comments-form-error {
    margin: 0;
    flex: 1 1 auto;
    color: #c03333;
    font-size: 11px;
}

.comments-form-submit {
    flex: 0 0 auto;
    font-size: 12px;
    padding: 6px 14px;
}

/* --- Form grid inside modal ---------------------------------------------- */

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
}

.form-grid .form-section {
    grid-column: span 2;
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid #eef0f4;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #8893a5;
    font-weight: 600;
}

.form-grid .form-section:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.form-grid .form-field {
    display: flex;
    flex-direction: column;
}

.form-grid .form-field.wide { grid-column: span 2; }

.form-grid label {
    font-size: 11px;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 3px;
    letter-spacing: .02em;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    background: #fff;
    color: #1a202c;
    box-sizing: border-box;
    width: 100%;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
    outline: none;
    border-color: #2b6cb0;
    box-shadow: 0 0 0 2px rgba(43, 108, 176, .15);
}

.form-grid .form-field.has-error input,
.form-grid .form-field.has-error select,
.form-grid .form-field.has-error textarea {
    border-color: #c53030;
}

.form-grid .field-hint {
    margin-top: 3px;
    font-size: 11px;
    color: #94a3b8;
}

.form-grid .field-error {
    margin-top: 3px;
    font-size: 11px;
    color: #c53030;
}

.form-grid textarea { min-height: 70px; resize: vertical; }

.form-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #eef0f4;
}

.form-footer .spacer { flex: 1; }

.form-error-banner {
    margin: 12px 0 0;
    padding: 10px 12px;
    background: #fde7e9;
    border: 1px solid #b00020;
    color: #b00020;
    border-radius: 4px;
    font-size: 12px;
}

.form-duplicates {
    margin: 12px 0 0;
    padding: 10px 12px;
    background: #fff8e1;
    border: 1px solid #f6c97a;
    color: #6b4f0b;
    border-radius: 4px;
    font-size: 12px;
}

.form-duplicates h4 {
    margin: 0 0 4px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.form-duplicates ul {
    margin: 6px 0 0;
    padding: 0 0 0 14px;
}

.form-duplicates li {
    margin: 2px 0;
}

/* --- Photo section in person form ----------------------------------------- */

.form-photo {
    margin-top: 16px;
}

.form-photo .form-section {
    margin: 0 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #eef0f3;
    font-weight: 600;
    color: #475569;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.photo-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.photo-preview-wrap {
    position: relative;
    width: 120px;
    height: 120px;
    flex: 0 0 120px;
    border: 1px solid #d8dde5;
    border-radius: 6px;
    background: #f5f6f8;
    overflow: hidden;
}

.photo-preview-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 12px;
    text-align: center;
    padding: 8px;
}

.photo-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.photo-controls .btn {
    align-self: flex-start;
}

.photo-filename {
    font-size: 12px;
    color: #64748b;
    word-break: break-all;
}

.photo-filename-error {
    color: #c0392b;
}

.form-photo .field-hint {
    margin-top: 8px;
    font-size: 11px;
    color: #94a3b8;
}

/* --- Admin page ----------------------------------------------------------- */

body.admin {
    background: #f5f6f8;
}

.admin-main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 22px 60px;
}

.admin-page-title {
    margin: 0 0 18px;
    font-size: 22px;
    color: #1a202c;
    font-weight: 600;
}

.admin-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #d8dde5;
    margin-bottom: 22px;
}

.admin-tab {
    background: transparent;
    border: 0;
    padding: 10px 18px;
    font: inherit;
    font-size: 14px;
    color: #64748b;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.admin-tab:hover {
    color: #2b6cb0;
}

.admin-tab.is-active {
    color: #2b6cb0;
    border-bottom-color: #2b6cb0;
    font-weight: 600;
}

.admin-tab-badge {
    display: inline-block;
    min-width: 18px;
    padding: 1px 6px;
    font-size: 11px;
    font-weight: 600;
    background: #c53030;
    color: #fff;
    border-radius: 9px;
    text-align: center;
    line-height: 16px;
}

/* `display: inline-block` above wins over the UA `[hidden] { display: none }`
   rule, so re-assert it for badges (and any other element that toggles
   visibility through the `hidden` attribute). */
.admin-tab-badge[hidden] { display: none; }

.admin-panel {
    background: #fff;
    border: 1px solid #e4e6eb;
    border-radius: 6px;
    padding: 22px 24px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

.admin-panel-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 18px;
}

.admin-panel-head h2 {
    margin: 0;
    flex: 1;
    font-size: 16px;
    color: #2b6cb0;
}

.admin-panel-head-actions {
    display: flex;
    gap: 8px;
}

.admin-loading {
    padding: 18px 4px;
    color: #64748b;
    font-size: 14px;
}

.admin-empty {
    padding: 18px 4px;
    color: #94a3b8;
    font-size: 14px;
}

.muted {
    color: #94a3b8;
}

/* --- Stats grid ----------------------------------------------------------- */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stats-card {
    border: 1px solid #e4e6eb;
    border-radius: 6px;
    padding: 14px 16px;
    background: #fafbfd;
}

.stats-card.is-accent {
    border-color: #f6c97a;
    background: #fffaf0;
}

.stats-card h3 {
    margin: 0 0 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #64748b;
    font-weight: 600;
}

.stats-big {
    font-size: 26px;
    font-weight: 600;
    color: #1a202c;
    line-height: 1.1;
    margin-bottom: 6px;
}

.stats-sub {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    font-size: 11px;
    color: #64748b;
}

.link-like {
    color: #2b6cb0;
    cursor: pointer;
    font-weight: 600;
}

.link-like:hover {
    text-decoration: underline;
}

.stats-activity {
    margin-top: 8px;
    padding-top: 18px;
    border-top: 1px solid #eef0f4;
}

.stats-activity h3 {
    margin: 0 0 10px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #64748b;
    font-weight: 600;
}

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

.activity-list li {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    padding: 6px 0;
    border-bottom: 1px solid #f3f5f8;
    font-size: 12px;
}

.activity-list li:last-child {
    border-bottom: 0;
}

.activity-when {
    color: #94a3b8;
    min-width: 130px;
}

.activity-action {
    color: #2b6cb0;
    font-weight: 600;
    text-transform: capitalize;
}

.activity-entity {
    color: #64748b;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.activity-user {
    color: #1a202c;
    margin-left: auto;
}

.stats-footer {
    margin-top: 16px;
    font-size: 11px;
    color: #94a3b8;
    text-align: right;
}

/* --- Admin tables --------------------------------------------------------- */

.admin-table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.admin-table th,
.admin-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eef0f4;
    vertical-align: top;
}

.admin-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #64748b;
    font-weight: 600;
    background: #fafbfd;
}

.admin-table tbody tr:hover {
    background: #f7f9fc;
}

.admin-table .col-actions {
    text-align: right;
    white-space: nowrap;
}

.admin-table .col-actions .btn {
    margin-left: 6px;
}

.admin-table .col-summary {
    color: #1a202c;
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    background: #eef3fb;
    color: #2b6cb0;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
}

.status-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.status-pill.status-active   { background: #dcfce7; color: #14532d; }
.status-pill.status-used     { background: #e0e7ff; color: #1e3a8a; }
.status-pill.status-expired  { background: #fef3c7; color: #78350f; }
.status-pill.status-revoked  { background: #fee2e2; color: #7f1d1d; }

/* --- Share URL field inside modals --------------------------------------- */

.share-url {
    width: 100%;
    padding: 8px 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    background: #f7f9fc;
    color: #1a202c;
}

.modal-actions.wide {
    grid-column: span 2;
    margin-top: 12px;
}

/* --- Profile page --------------------------------------------------------- */

.profile-main {
    max-width: 720px;
}

.profile-section {
    background: #fff;
    border: 1px solid #e3e6ec;
    border-radius: 6px;
    padding: 20px 22px;
    margin-bottom: 20px;
}

.profile-section h2 {
    margin: 0 0 14px;
    font-size: 15px;
    font-weight: 600;
    color: #1a202c;
}

.profile-hint {
    margin: -6px 0 14px;
    font-size: 12px;
    color: #64748b;
}

.profile-readonly {
    margin: 0 0 16px;
    padding: 10px 14px;
    background: #f5f7fa;
    border: 1px solid #e3e6ec;
    border-radius: 4px;
    display: grid;
    gap: 6px;
}

.profile-readonly-row {
    display: flex;
    gap: 10px;
    font-size: 13px;
    align-items: baseline;
}

.profile-readonly-label {
    width: 80px;
    color: #64748b;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .02em;
    font-weight: 600;
    flex-shrink: 0;
}

.profile-readonly-value {
    color: #1a202c;
    font-weight: 500;
}

.form-success-banner {
    margin: 4px 0 0;
    padding: 10px 12px;
    background: #e6f4ea;
    border: 1px solid #2e7d32;
    color: #1b5e20;
    border-radius: 4px;
    font-size: 12px;
}

.form-success-banner[hidden],
.form-error-banner[hidden] {
    display: none;
}

/* --- Albums page ---------------------------------------------------------- */

.albums-main {
    max-width: 1180px;
}

.albums-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0 0 18px;
}

.albums-header .admin-page-title {
    margin: 0;
    flex: 1;
}

.albums-header-actions {
    display: flex;
    gap: 8px;
}

/* Our own `display: flex` above wins over the UA `[hidden] { display: none }`,
   so re-assert it for the detail-view case that hides the "+ New album" button. */
.albums-header-actions[hidden] { display: none; }

.albums-empty {
    background: #fff;
    border: 1px solid #e4e6eb;
    border-radius: 6px;
    padding: 48px 24px;
    text-align: center;
    color: #64748b;
}

.albums-empty h2 {
    margin: 0 0 8px;
    font-size: 18px;
    color: #1a202c;
}

.albums-empty p {
    margin: 0 0 18px;
    font-size: 14px;
}

.albums-empty-inline {
    padding: 30px 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
    background: #fff;
    border: 1px dashed #d8dde5;
    border-radius: 6px;
}

/* --- Grid of albums ------------------------------------------------------- */

.albums-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.albums-card {
    background: #fff;
    border: 1px solid #e4e6eb;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: transform .12s ease-out, box-shadow .12s ease-out;
    display: flex;
    flex-direction: column;
}

.albums-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(15, 23, 42, .08);
}

.albums-card:focus {
    outline: 2px solid #2b6cb0;
    outline-offset: 2px;
}

.albums-card-thumb {
    position: relative;
    aspect-ratio: 1 / 1;
    background: #f5f6f8;
    overflow: hidden;
}

.albums-card-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.albums-card-cover-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    background:
        repeating-linear-gradient(45deg, #f1f4f8 0 10px, #eaeef5 10px 20px);
}

.albums-card-draft {
    position: absolute;
    top: 10px;
    left: 10px;
    background: #fff8e1;
    border: 1px solid #f6c97a;
    color: #8a6417;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 10px;
    text-transform: lowercase;
    letter-spacing: .02em;
}

.albums-card-body {
    padding: 12px 14px 14px;
}

.albums-card-title {
    margin: 0 0 4px;
    font-size: 14px;
    color: #1a202c;
    font-weight: 600;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.albums-card-meta {
    display: flex;
    gap: 8px;
    font-size: 12px;
    color: #64748b;
    flex-wrap: wrap;
}

.albums-card-date {
    color: #64748b;
}

.albums-card-count {
    color: #94a3b8;
}

.albums-card-count::before {
    content: '· ';
    color: #cbd5e0;
}

.albums-card-meta > .albums-card-count:first-child::before {
    content: '';
}

/* --- Album detail --------------------------------------------------------- */

.albums-detail {
    background: #fff;
    border: 1px solid #e4e6eb;
    border-radius: 6px;
    padding: 22px 24px 28px;
}

.albums-detail-header {
    border-bottom: 1px solid #eef0f4;
    padding-bottom: 16px;
    margin-bottom: 18px;
}

.albums-detail-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.albums-detail-actions {
    display: flex;
    gap: 8px;
}

.albums-detail-titleRow {
    display: flex;
    align-items: center;
    gap: 10px;
}

.albums-detail-title {
    margin: 0;
    font-size: 20px;
    color: #1a202c;
}

.albums-detail-date {
    margin: 4px 0 0;
    font-size: 13px;
    color: #64748b;
}

.albums-detail-desc {
    margin: 10px 0 0;
    font-size: 14px;
    color: #2d3748;
    line-height: 1.55;
    white-space: pre-wrap;
}

.albums-upload-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}

.albums-upload-status {
    font-size: 12px;
    color: #64748b;
}

.albums-upload-status.is-success {
    color: #1b5e20;
}

.albums-upload-status.is-error {
    color: #c53030;
}

.album-photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.album-photo-tile {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 6px;
    background: #f5f6f8;
    border: 1px solid #e4e6eb;
    cursor: pointer;
    transition: transform .12s ease-out;
}

.album-photo-tile:hover {
    transform: scale(1.02);
}

.album-photo-tile:focus {
    outline: 2px solid #2b6cb0;
    outline-offset: 2px;
}

.album-photo-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.album-photo-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 6px 10px;
    background: linear-gradient(transparent, rgba(15, 23, 42, .7));
    color: #fff;
    font-size: 12px;
    line-height: 1.35;
    pointer-events: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.album-photo-actions {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity .12s ease-out;
}

.album-photo-tile:hover .album-photo-actions,
.album-photo-tile:focus-within .album-photo-actions {
    opacity: 1;
}

.album-photo-actions .btn {
    padding: 3px 8px;
    font-size: 11px;
    background: rgba(255, 255, 255, .95);
    border-color: rgba(43, 108, 176, .8);
}

.album-photo-actions .btn.btn-danger {
    background: rgba(197, 48, 48, .95);
    color: #fff;
}

/* --- Lightbox ------------------------------------------------------------- */

.lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 8, 15, .9);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    box-shadow: 0 0 40px rgba(0, 0, 0, .6);
}

.lightbox-chrome {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 16px 24px 22px;
    background: linear-gradient(transparent, rgba(0, 0, 0, .6));
    color: #fff;
    font-size: 13px;
    text-align: center;
}

.lightbox-counter {
    opacity: .75;
    font-size: 12px;
    margin-bottom: 6px;
    letter-spacing: .05em;
}

.lightbox-caption {
    font-size: 14px;
    line-height: 1.5;
    max-width: 820px;
    margin: 0 auto;
}

.lightbox-btn {
    position: absolute;
    background: rgba(255, 255, 255, .08);
    border: 0;
    color: #fff;
    font-size: 34px;
    line-height: 1;
    padding: 10px 16px;
    cursor: pointer;
    border-radius: 4px;
    transition: background .12s ease-out;
}

.lightbox-btn:hover {
    background: rgba(255, 255, 255, .18);
}

.lightbox-close {
    top: 16px;
    right: 20px;
    font-size: 28px;
    padding: 4px 14px;
}

.lightbox-prev {
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.lightbox-next {
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

/* --- Lightbox photo tag overlay (Phase 2 pass #4) ------------------------ */

/* The figure wraps the <img> so tag dots can be absolute-positioned against
 * the image's rendered box rather than the full-viewport overlay. */
.lightbox-figure {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 100%;
    line-height: 0;
}

.lightbox-figure .lightbox-img {
    max-width: 100%;
    max-height: calc(100vh - 80px);
}

.lightbox-overlay.is-tagging .lightbox-img {
    cursor: crosshair;
}

.lightbox-add-tag {
    top: 16px;
    left: 20px;
    right: auto;
    font-size: 13px;
    line-height: 1.2;
    padding: 8px 14px;
}

.lightbox-tag-hint {
    position: absolute;
    top: 62px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(8, 12, 20, .88);
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
    pointer-events: none;
    z-index: 5;
}

.lightbox-tag-hint[hidden] { display: none; }

.lightbox-counter-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    align-items: baseline;
}

.lightbox-tag-count {
    opacity: .85;
    font-size: 12px;
    letter-spacing: .03em;
}

.lightbox-tag-dot {
    position: absolute;
    width: 22px;
    height: 22px;
    margin-left: -11px;
    margin-top: -11px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .15);
    border: 2px solid rgba(255, 255, 255, .9);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .35);
    cursor: pointer;
    padding: 0;
    z-index: 3;
    transition: transform .1s ease-out, background .12s;
}

.lightbox-tag-dot:hover,
.lightbox-tag-dot:focus {
    background: rgba(96, 165, 250, .45);
    transform: scale(1.15);
    outline: none;
}

.lightbox-tag-label {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%);
    background: rgba(8, 12, 20, .94);
    color: #fff;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity .12s ease-out;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lightbox-tag-dot:hover .lightbox-tag-label,
.lightbox-tag-dot:focus .lightbox-tag-label {
    opacity: 1;
    pointer-events: auto;
}

.lightbox-tag-label::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(8, 12, 20, .94);
}

.lightbox-tag-del {
    background: rgba(255, 255, 255, .16);
    border: 0;
    color: #fff;
    font-size: 14px;
    line-height: 1;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    padding: 0;
    cursor: pointer;
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.lightbox-tag-del:hover {
    background: rgba(239, 68, 68, .75);
}

/* --- Lightbox comments panel (Phase 2 pass #6) --------------------------- */
/* Docked on the right side of the overlay on desktop; hidden on narrow
 * viewports so the photo still owns the whole screen. Users on mobile can
 * still read/write comments through the person-panel surface. */

.lightbox-comments {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 340px;
    background: rgba(12, 18, 28, .92);
    color: #e5e7eb;
    border-left: 1px solid rgba(255, 255, 255, .08);
    overflow-y: auto;
    padding: 60px 20px 24px;
    z-index: 4;
    box-sizing: border-box;
}

/* Reserve room for the side panel so the image doesn't hide under it. */
@media (min-width: 900px) {
    .lightbox-overlay {
        padding-right: 380px;
    }
    /* Close button must clear the comment panel edge. */
    .lightbox-overlay .lightbox-close {
        right: 360px;
    }
}

/* On narrow viewports the comments panel would eat the whole screen, so we
 * fold it out of the lightbox. Person-panel comments still work there. */
@media (max-width: 899.98px) {
    .lightbox-comments { display: none; }
}

.lightbox-comments .comments-title {
    color: #94a3b8;
    margin-top: 0;
}

.lightbox-comments .comments-empty,
.lightbox-comments .comments-loading {
    color: #64748b;
}

.lightbox-comments .comment-content {
    background: rgba(255, 255, 255, .06);
    border-color: rgba(255, 255, 255, .1);
}

.lightbox-comments .comment-author { color: #f1f5f9; }
.lightbox-comments .comment-date   { color: #94a3b8; }
.lightbox-comments .comment-body   { color: #e2e8f0; }

.lightbox-comments .comment-delete {
    color: #94a3b8;
}
.lightbox-comments .comment-delete:hover {
    color: #f87171;
    background: rgba(248, 113, 113, .15);
}

.lightbox-comments .comments-form-text {
    background: rgba(255, 255, 255, .08);
    color: #f1f5f9;
    border-color: rgba(255, 255, 255, .18);
}

.lightbox-comments .comments-form-text::placeholder {
    color: #94a3b8;
}

.lightbox-comments .comments-form-text:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 2px rgba(96, 165, 250, .25);
}

.lightbox-comments .comments-form-submit {
    background: #2b6cb0;
    color: #fff;
    border-color: #2b6cb0;
}
.lightbox-comments .comments-form-submit:hover {
    background: #1e4d80;
}

/* --- Person picker modal (used by lightbox tagging) ---------------------- */

.person-picker {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(440px, 82vw);
}

.person-picker-search {
    width: 100%;
    padding: 9px 12px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
}

.person-picker-search:focus {
    outline: none;
    border-color: #2b6cb0;
    box-shadow: 0 0 0 2px rgba(43, 108, 176, .15);
}

.person-picker-list {
    max-height: 360px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: #fff;
}

.person-picker-item {
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, .05);
}

.person-picker-item:hover,
.person-picker-item:focus {
    background: rgba(43, 108, 176, .08);
    outline: none;
}

.person-picker-item:last-child {
    border-bottom: 0;
}

.person-picker-item-name {
    flex: 1 1 auto;
    font-size: 14px;
    color: #222;
}

.person-picker-item-meta {
    font-size: 12px;
    color: #94a3b8;
    flex: 0 0 auto;
}

.person-picker-empty {
    padding: 28px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

/* --- Advanced search panel ------------------------------------------------ */

.ft-search-panel {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 320px;
    max-height: calc(100% - 32px);
    background: #fff;
    border: 1px solid #d0d4db;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .18);
    z-index: 6;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ft-search-panel[hidden] {
    display: none;
}

.ft-search-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 10px;
    border-bottom: 1px solid #eef0f4;
}

.ft-search-title {
    margin: 0;
    font-size: 14px;
    color: #2b6cb0;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .02em;
}

.ft-search-close {
    background: transparent;
    border: 0;
    font-size: 22px;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    padding: 2px 6px;
}

.ft-search-close:hover {
    color: #1a202c;
}

.ft-search-form {
    padding: 12px 14px 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ft-search-row {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ft-search-label {
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.ft-search-field {
    padding: 7px 10px;
    border: 1px solid #d0d4db;
    border-radius: 4px;
    font-size: 13px;
    font-family: inherit;
    color: #1a202c;
    background: #fff;
    box-sizing: border-box;
    width: 100%;
}

.ft-search-field:focus {
    outline: none;
    border-color: #2b6cb0;
    box-shadow: 0 0 0 2px rgba(43, 108, 176, .15);
}

.ft-search-year-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ft-search-year {
    flex: 1;
    min-width: 0;
}

.ft-search-year-sep {
    color: #94a3b8;
    font-size: 13px;
}

.ft-search-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 2px;
}

.ft-search-reset {
    padding: 6px 12px;
    background: transparent;
    color: #64748b;
    border: 1px solid #d0d4db;
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
}

.ft-search-reset:hover {
    background: #f5f7fb;
    color: #1a202c;
    border-color: #94a3b8;
}

.ft-search-count {
    padding: 6px 14px 8px;
    font-size: 12px;
    color: #64748b;
    border-top: 1px solid #eef0f4;
    background: #f9fafc;
}

.ft-search-results {
    flex: 1 1 auto;
    overflow-y: auto;
    border-top: 1px solid #eef0f4;
    max-height: 340px;
}

.ft-search-results:empty {
    display: none;
}

.ft-search-empty {
    padding: 18px 14px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

.ft-search-result {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 14px;
    background: transparent;
    border: 0;
    border-top: 1px solid #f1f3f6;
    text-align: left;
    font-family: inherit;
    cursor: pointer;
    color: inherit;
}

.ft-search-result:first-child {
    border-top: 0;
}

.ft-search-result:hover {
    background: #eef3fb;
}

.ft-search-result:focus {
    outline: none;
    background: #eef3fb;
    box-shadow: inset 3px 0 0 #2b6cb0;
}

.ft-search-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #2b6cb0;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.ft-search-result-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}

.ft-search-result-name {
    font-size: 13px;
    color: #1a202c;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ft-search-result-meta {
    font-size: 11px;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Narrow viewports: let the panel take a little less room so it doesn't
   cover the entire tree. Full-width on true mobile is fine — the canvas is
   still there underneath when the panel is closed. */
@media (max-width: 640px) {
    .ft-search-panel {
        width: calc(100% - 24px);
        left: 12px;
        top: 12px;
        max-height: calc(100% - 24px);
    }
}

/* --- Topbar live-search -------------------------------------------------- */

.topbar-livesearch {
    position: relative;
    flex: 0 1 260px;
    min-width: 140px;
}

#ft-livesearch-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-family: inherit;
    font-size: 13px;
    color: #1a202c;
    background: #f8fafc;
    outline: none;
    box-sizing: border-box;
}

#ft-livesearch-input:focus {
    border-color: #2b6cb0;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(43, 108, 176, .15);
}

#ft-livesearch-input::placeholder {
    color: #94a3b8;
}

.ft-livesearch-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    min-width: 280px;
    max-height: 360px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .18);
    z-index: 50;
}

.ft-livesearch-dropdown[hidden] {
    display: none;
}

.ft-livesearch-dropdown .ft-search-result.is-active {
    background: #eef3fb;
    box-shadow: inset 3px 0 0 #2b6cb0;
}

.ft-livesearch-empty {
    padding: 14px 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
}

/* --- Audit log (admin → Audit tab) --------------------------------------- */

/* Filter row sits above the results table and stays flush with the panel
   edges. Flex-wrap so narrow viewports let fields fall onto a second row
   instead of truncating. */
.audit-filters {
    margin-bottom: 12px;
}

.audit-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
    align-items: flex-end;
}

.audit-filter-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
}

.audit-filter-field label {
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 600;
}

.audit-filter-field select,
.audit-filter-field input[type="date"] {
    padding: 6px 8px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
    color: #1a202c;
    min-width: 140px;
}

.audit-filter-field.is-reset {
    min-width: auto;
    align-self: flex-end;
}

.audit-filter-field.is-reset label {
    visibility: hidden;
}

/* Table tweaks — the audit table reuses .admin-table but needs a tighter
   timestamp column and a mono font so 50 rows scan vertically. */
.admin-table td.audit-when {
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    color: #4a5568;
}

.audit-entity {
    display: inline-flex;
    gap: 4px;
    align-items: baseline;
}

.audit-entity-type {
    color: #1a202c;
    font-weight: 500;
}

.audit-entity-id {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    color: #64748b;
}

/* Action tags — colored per-category so delete/reject stand out without
   forcing the user to read the label. Unknown actions fall through to the
   default .tag pill from the invites section. */
.audit-action-tag[data-action="delete"],
.audit-action-tag[data-action="reject"] {
    background: #fee2e2;
    color: #7f1d1d;
}

.audit-action-tag[data-action="approve"],
.audit-action-tag[data-action="create"] {
    background: #dcfce7;
    color: #14532d;
}

.audit-action-tag[data-action="update"],
.audit-action-tag[data-action="upload"] {
    background: #fef3c7;
    color: #78350f;
}

.audit-action-tag[data-action="login"],
.audit-action-tag[data-action="logout"],
.audit-action-tag[data-action="password_change"] {
    background: #e0e7ff;
    color: #1e3a8a;
}

/* Details cell — width capped so the <pre> block doesn't push the row
   horizontally. Pre wraps long lines with break-all to keep table width. */
.admin-table td.audit-details-cell {
    max-width: 380px;
}

.audit-details-wrap {
    display: inline-block;
    max-width: 100%;
}

.audit-details-inline {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    color: #4a5568;
}

.audit-details-toggle {
    padding: 2px 8px;
    font-size: 11px;
    border: 1px solid #cbd5e0;
    background: #f7fafc;
    color: #2d3748;
    border-radius: 6px;
    cursor: pointer;
}

.audit-details-toggle:hover {
    background: #edf2f7;
}

.audit-details-json {
    display: block;
    margin: 0;
    padding: 8px 10px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    color: #1a202c;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 240px;
    overflow: auto;
    cursor: pointer;
}

.audit-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 8px 0;
}

/* Compact "xs" button size used only by the details toggle. .btn-sm is
   still a bit chunky for a one-char affordance inside a table cell. */
.btn.btn-xs {
    padding: 3px 8px;
    font-size: 11px;
}

/* --- Trash (admin → Trash tab) ------------------------------------------
   Reuses .audit-filters / .audit-filter-row / .audit-filter-field for the
   filter bar, .admin-table for the grid, and audit.entity.* tags for the
   entity column. Only the summary cell and the inline action-button row
   need their own styling. */

.trash-summary-cell {
    max-width: 360px;
}

.trash-summary {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 360px;
}

.trash-actions {
    white-space: nowrap;
}

.trash-actions .btn {
    margin-right: 6px;
}

.trash-actions .btn:last-child {
    margin-right: 0;
}

/* ── PDF export ────────────────────────────────────────────────────────── */

.pdf-export-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 280px;
}

.pdf-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pdf-label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.pdf-radios {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}

.pdf-radios label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.pdf-pages-opts {
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pdf-pages-opts .pdf-radios {
    flex-direction: row;
    gap: 0;
}

.pdf-checkbox {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.pdf-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
}

.pdf-status {
    font-size: 12px;
    color: #64748b;
}

/* ── Mobile card navigation ────────────────────────────────────────────── */

/* Person-panel nav buttons — hidden on desktop, visible on mobile */
.person-panel-nav { display: none; }

/* Mobile person list — hidden on desktop */
.mobile-person-list { display: none; }

@media (max-width: 767.98px) {
    /* Hide canvas and desktop-only controls */
    #ft-tree-canvas { display: none; }
    .tree-controls { display: none; }
    #ft-search-mount { display: none; }

    /* ── Topbar: mobile layout ──────────────────────────────────────── */
    .topbar {
        flex-wrap: wrap;
        padding: 8px 12px;
        gap: 6px;
    }
    .topbar-brand { font-size: 14px; }

    /* Show burger */
    .topbar-burger {
        display: flex;
    }

    /* Livesearch goes full-width below brand row */
    .topbar-livesearch {
        flex: 1 1 100%;
        order: 10;
        margin-top: 4px;
    }

    /* Nav: hidden by default, vertical dropdown when open */
    .topbar-nav {
        display: none;
        flex-direction: column;
        gap: 2px;
        width: 100%;
        order: 20;
        padding-top: 8px;
        border-top: 1px solid #e2e8f0;
        margin-top: 4px;
    }
    .topbar.is-menu-open .topbar-nav {
        display: flex;
    }

    /* Nav items: full-width in mobile menu */
    .topbar-nav-item {
        width: 100%;
        text-align: left;
        padding: 10px 12px;
        border: none;
        border-radius: 6px;
        font-size: 14px;
    }
    .topbar-nav-item:hover { background: #f1f5f9; }
    .topbar-nav-item.is-active {
        background: #eef3fb;
        border: none;
    }
    .topbar-nav-primary {
        border: none;
    }

    /* Spacer becomes a horizontal divider */
    .topbar-nav-spacer {
        flex: 0;
        height: 1px;
        background: #e2e8f0;
        margin: 4px 0;
    }

    /* Language dropdown: full-width in mobile */
    .lang-dropdown { width: 100%; }
    .lang-dropdown-toggle {
        width: 100%;
        justify-content: space-between;
        padding: 10px 12px;
        border: none;
        border-radius: 6px;
        font-size: 14px;
    }
    .lang-dropdown-menu {
        position: static;
        box-shadow: none;
        border: none;
        background: #f8fafc;
        border-radius: 6px;
        margin-top: 2px;
    }
    .lang-dropdown-item {
        text-align: left;
        padding: 8px 24px;
    }

    /* Logout: full-width */
    .topbar-logout { width: 100%; }
    .topbar-logout button {
        width: 100%;
        text-align: left;
        padding: 10px 12px;
        font-size: 14px;
        border: none;
        border-radius: 6px;
        color: #e53e3e;
    }
    .topbar-logout button:hover {
        background: #fef2f2;
        color: #e53e3e;
    }

    /* Person panel → full-screen card */
    .person-panel {
        width: 100vw;
        left: 0;
        right: 0;
    }

    /* Show nav buttons row inside panel */
    .person-panel-nav {
        display: block;
        padding: 8px 16px;
        border-bottom: 1px solid #e2e8f0;
        background: #f8fafc;
    }

    /* Mobile person list — scrollable grid */
    .mobile-person-list {
        display: block;
        padding: 12px 16px;
        overflow-y: auto;
        max-height: calc(100vh - 90px);
    }
}

/* Mobile nav button row */
.mobile-nav-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.mobile-nav-btn {
    padding: 6px 10px;
    font-size: 12px;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    color: #2b6cb0;
    font-weight: 500;
}
.mobile-nav-btn:disabled {
    color: #a0aec0;
    background: #f7fafc;
    cursor: default;
}
.mobile-nav-btn.mobile-nav-back {
    color: #4a5568;
    border-color: #a0aec0;
}

/* Mobile picker (multi-person selection) */
.mobile-picker {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mobile-picker-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    text-align: left;
    width: 100%;
    font-size: 13px;
}
.mobile-picker-row:active { background: #edf2f7; }
.mobile-picker-initial {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: #e5e9f0;
    color: #7a8297;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
}
.mobile-picker-name { font-weight: 600; color: #1a202c; }
.mobile-picker-years { color: #64748b; font-size: 12px; margin-left: auto; }

/* Mobile person list styles */
.mobile-list-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 12px 0;
    color: #1a202c;
}

.mobile-gen-header {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 12px 0 6px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid #e2e8f0;
}

.mobile-list-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    font-size: 14px;
}
.mobile-list-row:active { background: #edf2f7; }

.mobile-list-photo {
    width: 36px; height: 36px;
    flex-shrink: 0;
    position: relative;
}
.mobile-list-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
}
.mobile-list-initial {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: #e5e9f0;
    color: #7a8297;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}
.mobile-list-initial-hidden { display: none; }

.mobile-list-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.mobile-list-name { font-weight: 600; color: #1a202c; }
.mobile-list-years { font-size: 12px; color: #64748b; }

.mobile-empty {
    text-align: center;
    color: #94a3b8;
    padding: 40px 20px;
    font-size: 14px;
}

/* ── Profile invite section ────────────────────────────────────────────── */

.invite-create-row {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 10px;
}
.invite-create-row select {
    padding: 7px 10px;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    font-size: 13px;
}
.invite-result {
    margin-top: 14px;
}
.invite-result label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    display: block;
    margin-bottom: 4px;
}
.invite-link-row {
    display: flex;
    gap: 6px;
}
.invite-link-row input {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
    background: #f8fafc;
}
.invite-copied {
    font-size: 12px;
    color: #38a169;
    margin-top: 4px;
}

/* --- Geo autocomplete dropdown --------------------------------------------- */

.geo-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 60;
    background: #fff;
    border: 1px solid #cbd5e0;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
    max-height: 220px;
    overflow-y: auto;
}
.geo-dropdown[hidden] {
    display: none !important;
}
.geo-dropdown-item {
    display: block;
    width: 100%;
    padding: 7px 10px;
    border: none;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    line-height: 1.4;
    color: #2d3748;
}
.geo-dropdown-item:hover,
.geo-dropdown-item.is-active {
    background: #ebf4ff;
}
.geo-dropdown-city {
    font-weight: 500;
}
.geo-dropdown-country {
    color: #718096;
}
.geo-dropdown-empty {
    padding: 8px 10px;
    font-size: 13px;
    color: #a0aec0;
    text-align: center;
}

/* --- Map page -------------------------------------------------------------- */

.map-body {
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}
.map-body .topbar {
    flex-shrink: 0;
}
.map-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.map-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 16px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
    flex-wrap: wrap;
}
.map-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
}
.map-filters {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
}
.map-filter-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}
.map-filter-item input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}
.map-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.map-status[hidden] {
    display: none !important;
}
.map-status {
    padding: 6px 16px;
    font-size: 13px;
    color: #4a5568;
    background: #edf2f7;
    text-align: center;
    flex-shrink: 0;
}
.map-status-error {
    color: #c53030;
    background: #fff5f5;
}
.map-container {
    flex: 1;
    min-height: 300px;
}
.map-empty[hidden] {
    display: none !important;
}
.map-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    color: #718096;
}
.map-empty h2 {
    font-size: 20px;
    margin: 0 0 8px;
    color: #4a5568;
}
.map-empty p {
    font-size: 14px;
    margin: 0;
    max-width: 400px;
}

/* Leaflet popup overrides */
.map-popup { font-size: 13px; }
.map-popup-location {
    display: block;
    font-size: 14px;
    margin-bottom: 2px;
}
.map-popup-type {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 6px;
}
.map-popup-list {
    margin: 0;
    padding: 0 0 0 16px;
    list-style: disc;
}
.map-popup-list li {
    margin: 2px 0;
}
.map-popup-list a {
    color: #2b6cb0;
    text-decoration: none;
}
.map-popup-list a:hover {
    text-decoration: underline;
}

@media (max-width: 640px) {
    .map-toolbar {
        padding: 6px 10px;
        gap: 8px;
    }
    .map-title {
        font-size: 15px;
    }
    .map-filters {
        gap: 8px;
    }
    .map-filter-item {
        font-size: 12px;
    }
}

