.pfw-backdrop {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(5, 10, 18, .72);
    backdrop-filter: blur(4px);
}

.pfw-backdrop[hidden] {
    display: none !important;
}

body.pfw-open {
    overflow: hidden;
}

.pfw-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(940px, 100%);
    height: min(720px, calc(100dvh - 36px));
    min-height: 520px;
    overflow: hidden;
    color: #182235;
    background: #f7f9fc;
    border: 1px solid rgba(255, 152, 0, .8);
    border-radius: 20px;
    box-shadow: 0 28px 90px rgba(0, 0, 0, .45);
    font-family: "Noto Sans", Arial, sans-serif;
}

.pfw-panel button,
.pfw-panel input {
    font: inherit;
}

.pfw-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px 14px;
    background: #fff;
    border-bottom: 1px solid #dfe5ee;
}

.pfw-header h2 {
    margin: 0;
    font-size: clamp(19px, 2.4vw, 26px);
    line-height: 1.15;
}

.pfw-header p {
    margin: 5px 0 0;
    color: #607087;
    font-size: 13px;
}

.pfw-icon-close {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    padding: 0;
    color: #445168;
    background: #eef2f7;
    border: 0;
    border-radius: 50%;
    font-size: 27px !important;
    line-height: 36px;
    cursor: pointer;
}

.pfw-actions {
    display: flex;
    gap: 10px;
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid #dfe5ee;
}

.pfw-actions button,
.pfw-footer button {
    min-height: 40px;
    padding: 8px 14px;
    color: #26344b;
    background: #fff;
    border: 1px solid #c8d2df;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
}

.pfw-actions .pfw-primary {
    color: #4b2d00;
    background: #ffb33b;
    border-color: #ed980e;
}

.pfw-layout {
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr);
    min-height: 0;
    flex: 1;
}

.pfw-sources-column {
    display: flex;
    min-height: 0;
    flex-direction: column;
    padding: 14px;
    background: #eef2f7;
    border-right: 1px solid #d7dee8;
}

.pfw-sources-column h3 {
    margin: 0 0 10px;
    color: #4f5e74;
    font-size: 12px;
    letter-spacing: .055em;
    text-transform: uppercase;
}

.pfw-sources {
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
}

.pfw-source {
    position: relative;
    display: flex;
    width: 100%;
    flex-direction: column;
    gap: 3px;
    margin: 0 0 8px;
    padding: 11px 12px;
    text-align: left;
    color: #26344b;
    background: #fff;
    border: 1px solid #d1d9e4;
    border-radius: 11px;
    cursor: pointer;
}

.pfw-source:hover,
.pfw-source.is-active {
    border-color: #f09a13;
    box-shadow: 0 0 0 2px rgba(255, 166, 28, .16);
}

.pfw-source b {
    padding-right: 54px;
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pfw-source span {
    color: #748198;
    font-size: 11px;
}

.pfw-source em {
    position: absolute;
    top: 9px;
    right: 9px;
    padding: 2px 6px;
    color: #6a3b00;
    background: #ffe1ad;
    border-radius: 20px;
    font-size: 9px;
    font-style: normal;
    font-weight: 800;
    text-transform: uppercase;
}

.pfw-detail {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    padding: 14px 16px 0;
}

.pfw-detail[hidden] {
    display: none !important;
}

.pfw-detail-empty {
    display: grid;
    place-items: center;
    padding: 30px;
    color: #6a788d;
    text-align: center;
}

.pfw-detail-empty[hidden] {
    display: none !important;
}

.pfw-current {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.pfw-current > div {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.pfw-current-name {
    overflow: hidden;
    font-size: 17px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pfw-current-meta,
.pfw-count {
    color: #6b788d;
    font-size: 11px;
}

.pfw-count {
    flex: 0 0 auto;
    padding: 4px 8px;
    background: #e8edf4;
    border-radius: 20px;
}

.pfw-mode-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.pfw-field-label {
    color: #536176;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.pfw-segmented {
    display: grid;
    min-width: 0;
    flex: 1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 3px;
    background: #e7ecf3;
    border-radius: 11px;
}

.pfw-segmented button {
    min-width: 0;
    min-height: 34px;
    overflow: hidden;
    padding: 5px 8px;
    color: #536176;
    background: transparent;
    border: 0;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.pfw-segmented button.is-active {
    color: #523000;
    background: #fff;
    box-shadow: 0 2px 7px rgba(41, 53, 73, .15), inset 0 -2px 0 #f3a01a;
}

.pfw-search {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 10px;
    padding: 0 11px;
    color: #66748a;
    background: #fff;
    border: 1px solid #cbd4e1;
    border-radius: 10px;
}

.pfw-search:focus-within {
    border-color: #ee9a16;
    box-shadow: 0 0 0 3px rgba(255, 168, 31, .14);
}

.pfw-search input {
    width: 100%;
    height: 40px;
    padding: 0;
    color: #243249;
    background: transparent;
    border: 0;
    outline: 0;
    font-size: 13px;
}

.pfw-people {
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    padding: 0 3px 14px 0;
    scrollbar-width: thin;
}

.pfw-person {
    display: flex;
    width: 100%;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    padding: 9px 10px;
    text-align: left;
    color: #26344b;
    background: #fff;
    border: 1px solid #d6dde7;
    border-radius: 10px;
    cursor: pointer;
}

.pfw-person:hover,
.pfw-person.is-main {
    border-color: #ee9a16;
    background: #fffaf0;
}

.pfw-person-marker {
    flex: 0 0 20px;
    color: #4ba6d1;
    text-align: center;
}

.pfw-person-marker[data-sex="F"] {
    color: #e66a9d;
}

.pfw-person.is-main .pfw-person-marker {
    color: #ec9200;
}

.pfw-person > span:last-child {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.pfw-person b {
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pfw-person small {
    min-height: 15px;
    color: #78859a;
    font-size: 10px;
}

.pfw-empty {
    margin: 12px 4px;
    color: #707e92;
    font-size: 12px;
    line-height: 1.45;
}

.pfw-footer {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    padding: 11px 16px;
    background: #fff;
    border-top: 1px solid #dfe5ee;
}

.pfw-footer .pfw-danger {
    margin-right: auto;
    color: #a62b2b;
    border-color: #edbcbc;
}

.pfw-loading {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    color: #27364e;
    background: rgba(247, 249, 252, .82);
    backdrop-filter: blur(2px);
}

.pfw-loading[hidden] {
    display: none !important;
}

.pfw-loading span {
    width: 28px;
    height: 28px;
    border: 3px solid #d9e0ea;
    border-top-color: #ee9810;
    border-radius: 50%;
    animation: pfw-spin .8s linear infinite;
}

.pfw-loading b {
    font-size: 12px;
}

@keyframes pfw-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 680px) {
    .pfw-backdrop {
        align-items: end;
        padding: 0;
    }

    .pfw-panel {
        width: 100%;
        height: 100dvh;
        min-height: 0;
        border-width: 0;
        border-radius: 0;
    }

    .pfw-header {
        padding: max(12px, env(safe-area-inset-top)) 13px 10px;
    }

    .pfw-header p {
        max-width: 92%;
        font-size: 10px;
    }

    .pfw-actions {
        padding: 8px 10px;
    }

    .pfw-actions button {
        min-width: 0;
        flex: 1;
        padding: 7px 8px;
        font-size: 11px;
    }

    .pfw-layout {
        grid-template-columns: 118px minmax(0, 1fr);
    }

    .pfw-sources-column {
        padding: 9px 7px;
    }

    .pfw-sources-column h3 {
        font-size: 9px;
    }

    .pfw-source {
        padding: 9px 7px;
    }

    .pfw-source b {
        padding-right: 0;
        font-size: 11px;
    }

    .pfw-source span {
        font-size: 9px;
    }

    .pfw-source em {
        position: static;
        align-self: flex-start;
        font-size: 7px;
    }

    .pfw-detail {
        padding: 10px 8px 0;
    }

    .pfw-current {
        margin-bottom: 7px;
    }

    .pfw-current-name {
        font-size: 14px;
    }

    .pfw-current-meta,
    .pfw-count {
        font-size: 9px;
    }

    .pfw-mode-group {
        display: block;
        margin-bottom: 7px;
    }

    .pfw-field-label {
        display: none;
    }

    .pfw-segmented button {
        min-height: 32px;
        padding: 4px;
        font-size: 9px;
    }

    .pfw-search {
        margin-bottom: 7px;
    }

    .pfw-search input {
        height: 36px;
        font-size: 11px;
    }

    .pfw-person {
        gap: 6px;
        margin-bottom: 5px;
        padding: 7px 6px;
    }

    .pfw-person-marker {
        flex-basis: 15px;
    }

    .pfw-person b {
        font-size: 11px;
    }

    .pfw-person small {
        font-size: 8px;
    }

    .pfw-footer {
        padding: 8px 9px max(8px, env(safe-area-inset-bottom));
    }

    .pfw-footer button {
        min-width: 0;
        min-height: 36px;
        padding: 6px 8px;
        font-size: 10px;
    }
}

/* Persistent Poster Designer side workspace. The older dialog rules above are
   intentionally superseded so the poster canvas never leaves the screen. */
#rootSelector {
    display: flex !important;
    min-height: 0;
    flex-direction: column;
}

#posterSideToolbar {
    display: flex;
    flex: 0 0 38px;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    min-width: 0;
    padding: 0 1px 5px;
    border-bottom: 1px solid rgba(255, 152, 0, .35);
}

#rootSelector .pfw-view-switch {
    display: grid;
    min-width: 0;
    flex: 1 1 auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px;
    padding: 3px;
    background: #181818;
    border: 1px solid #494949;
    border-radius: 7px;
}

#rootSelector .pfw-view-switch button {
    min-width: 0;
    height: 27px;
    margin: 0 !important;
    padding: 3px 7px !important;
    overflow: hidden;
    color: #d5d5d5 !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 5px !important;
    box-shadow: none !important;
    font-size: 11px !important;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#rootSelector .pfw-view-switch button.is-active {
    color: #1d1303 !important;
    background: #ff9800 !important;
}

#rootSelector #singleActionBar {
    position: static !important;
    inset: auto !important;
    display: block !important;
    width: auto !important;
    flex: 0 0 auto;
    margin: 0 !important;
    z-index: 6000;
}

#rootSelector #singleActionBar .main-menu-toggle {
    height: 33px;
    min-height: 33px;
    margin: 0 !important;
    padding: 5px 9px !important;
    border-color: #565656;
    border-radius: 7px;
    box-shadow: none;
    font-size: 11px;
}

#rootSelector #gedcomWrap {
    min-height: 0;
    height: auto !important;
    flex: 1 1 auto;
    margin-top: 5px;
    padding: 5px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

#posterPeoplePane.pfw-panel {
    position: relative;
    display: block;
    width: 100%;
    height: auto;
    min-height: 100%;
    overflow: visible;
    color: #f5d98b;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    font-family: "Segoe UI", Arial, sans-serif;
}

#posterPeoplePane[hidden] {
    display: none !important;
}

#posterPeoplePane .pfw-actions {
    position: sticky;
    top: -5px;
    z-index: 4;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding: 4px 2px 6px;
    background: #333;
    border-bottom: 1px solid #4d4d4d;
}

#posterPeoplePane .pfw-actions button {
    width: 100%;
    min-width: 0;
    min-height: 31px;
    margin: 0 !important;
    padding: 5px 6px !important;
    overflow: hidden;
    color: #17100a !important;
    background: #ff9800 !important;
    border: 1px solid #e48a00 !important;
    border-radius: 5px !important;
    font-size: 10px !important;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#posterPeoplePane .pfw-actions .pfw-danger {
    color: #ffdada !important;
    background: #742929 !important;
    border-color: #9a4040 !important;
}

#posterPeoplePane .pfw-sources-column {
    display: block;
    min-height: 0;
    padding: 8px 2px 4px;
    background: transparent;
    border: 0;
}

#posterPeoplePane .pfw-sources-column h3 {
    margin: 0 2px 5px;
    color: #ffb33b;
    font-size: 9px;
    letter-spacing: .06em;
    text-transform: uppercase;
}

#posterPeoplePane .pfw-sources {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    overflow: visible;
}

#posterPeoplePane .pfw-source {
    position: relative;
    display: flex;
    width: 100%;
    min-width: 0;
    min-height: 43px;
    flex-direction: column;
    gap: 1px;
    margin: 0 !important;
    padding: 6px 7px !important;
    overflow: hidden;
    text-align: left;
    color: #e2e2e2 !important;
    background: #202020 !important;
    border: 1px solid #555 !important;
    border-radius: 6px !important;
    box-shadow: none !important;
}

#posterPeoplePane .pfw-source.is-active {
    color: #f5d98b !important;
    border-color: #d4af37 !important;
    background: #171717 !important;
    box-shadow: inset 3px 0 0 #ff9800 !important;
}

#posterPeoplePane .pfw-source b {
    padding-right: 0;
    overflow: hidden;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#posterPeoplePane .pfw-source span,
#posterPeoplePane .pfw-source em {
    color: #aaa;
    font-size: 8px;
    font-style: normal;
}

#posterPeoplePane .pfw-source em {
    position: absolute;
    top: 3px;
    right: 4px;
    padding: 1px 4px;
    color: #2b1b00;
    background: #ffb33b;
    border-radius: 8px;
    font-size: 6px;
    font-weight: 800;
    text-transform: uppercase;
}

#posterPeoplePane .pfw-detail {
    display: block;
    min-width: 0;
    min-height: 0;
    padding: 6px 2px 12px;
}

#posterPeoplePane .pfw-current {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 1px 6px;
    padding: 6px 7px;
    color: #e8e8e8;
    background: #242424;
    border-left: 2px solid #ff9800;
}

#posterPeoplePane .pfw-current > div {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
}

#posterPeoplePane .pfw-current-name {
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#posterPeoplePane .pfw-current-meta,
#posterPeoplePane .pfw-count {
    color: #bcbcbc;
    font-size: 8px;
}

#posterPeoplePane .pfw-count {
    flex: 0 0 auto;
    padding: 3px 6px;
    background: #141414;
    border-radius: 10px;
}

#posterPeoplePane .pfw-mode-group {
    display: block;
    margin: 0 1px 5px;
}

#posterPeoplePane .pfw-field-label {
    display: block;
    margin: 0 0 3px;
    color: #ffb33b;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

#posterPeoplePane .pfw-segmented {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px;
    padding: 2px;
    background: #1b1b1b;
    border-radius: 6px;
}

#posterPeoplePane .pfw-segmented button {
    min-width: 0;
    min-height: 28px;
    margin: 0 !important;
    padding: 4px !important;
    overflow: hidden;
    color: #d7d7d7 !important;
    background: #333 !important;
    border: 1px solid #4b4b4b !important;
    border-radius: 4px !important;
    font-size: 8px !important;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#posterPeoplePane .pfw-segmented button.is-active {
    color: #211300 !important;
    background: #ff9800 !important;
    border-color: #ffb13b !important;
}

#posterPeoplePane .pfw-search {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0 1px 5px;
    padding: 0 7px;
    color: #aaa;
    background: #f6f6f6;
    border: 1px solid #999;
    border-radius: 3px;
}

#posterPeoplePane .pfw-search:focus-within {
    border-color: #ff9800;
    box-shadow: 0 0 0 2px rgba(255, 152, 0, .25);
}

#posterPeoplePane .pfw-search input {
    width: 100%;
    height: 27px;
    padding: 0;
    color: #222;
    background: transparent;
    border: 0;
    outline: 0;
    font-size: 10px;
}

#posterPeoplePane .pfw-people {
    min-height: 0;
    overflow: visible;
    padding: 0;
}

#posterPeoplePane .pfw-person-card {
    position: relative;
    box-sizing: border-box;
    width: 90%;
    margin: 8px auto;
    padding: 9px;
    text-align: left;
    color: #f5d98b;
    background: #1a1a1a;
    border: 1px solid #d4af37;
    border-radius: 12px;
    outline: 0;
    cursor: default;
    transition: border-color .16s, box-shadow .16s, transform .16s;
}

#posterPeoplePane .pfw-person-card.is-main {
    border-color: #ff9800;
    box-shadow: 0 0 0 2px rgba(255, 152, 0, .22);
}

#posterPeoplePane .pfw-person-card.is-main {
    background: #221d13;
}

#posterPeoplePane .pfw-person-card.is-focused {
    border-color: #ff9800;
    box-shadow: 0 0 0 2px rgba(255, 152, 0, .42), inset 4px 0 0 #ff9800;
}

#posterPeoplePane .pfw-root-icon {
    position: absolute;
    top: 5px;
    right: 7px;
    display: grid;
    width: 27px;
    height: 27px;
    min-width: 27px;
    min-height: 27px;
    margin: 0;
    padding: 0;
    place-items: center;
    color: #fff;
    background: #666;
    border: 1px solid #858585;
    border-radius: 3px;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
}

#posterPeoplePane .pfw-root-icon:hover,
#posterPeoplePane .pfw-root-icon:focus-visible {
    border-color: #ffbd55;
    box-shadow: 0 0 0 2px rgba(255, 152, 0, .38);
    outline: 0;
}

#posterPeoplePane .pfw-person-card.is-main .pfw-root-icon {
    background: #ff9800;
}

#posterPeoplePane .pfw-card-head {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding-right: 27px;
    margin-bottom: 4px;
}

#posterPeoplePane .pfw-card-head img,
#posterPeoplePane .pfw-card-avatar {
    width: 32px;
    height: 36px;
    flex: 0 0 32px;
    border-radius: 40%;
    object-fit: cover;
}

#posterPeoplePane .pfw-card-avatar {
    display: grid;
    place-items: center;
    color: #191919;
    background: #d4af37;
    font-size: 13px;
    font-weight: 800;
}

#posterPeoplePane .pfw-card-identity {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
}

#posterPeoplePane .pfw-card-identity small {
    color: #aaa;
    font-size: 7px;
}

#posterPeoplePane .pfw-card-identity b {
    overflow: hidden;
    text-align: center;
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#posterPeoplePane .pfw-sex-dot {
    color: #4fc3f7;
}

#posterPeoplePane .pfw-sex-dot[data-sex="F"] {
    color: #ff6fa5;
}

#posterPeoplePane .pfw-card-body {
    color: #cbd5e1;
    font-size: 9px;
    line-height: 1.4;
}

#posterPeoplePane .pfw-card-line {
    overflow-wrap: anywhere;
}

#posterPeoplePane .pfw-card-line small {
    color: #aeb8c7;
}

#posterPeoplePane .pfw-card-line span {
    color: #f1dfad;
}

#posterPeoplePane .pfw-empty,
#posterPeoplePane .pfw-detail-empty {
    margin: 12px 4px;
    padding: 12px;
    color: #ccc;
    background: #222;
    border: 1px dashed #666;
    border-radius: 6px;
    font-size: 10px;
    line-height: 1.4;
    text-align: center;
}

#posterPeoplePane .pfw-detail[hidden],
#posterPeoplePane .pfw-detail-empty[hidden] {
    display: none !important;
}

#posterPeoplePane .pfw-loading {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: flex;
    min-height: 180px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    color: #f5d98b;
    background: rgba(28, 28, 28, .88);
}

#posterPeoplePane .pfw-loading[hidden] {
    display: none !important;
}

#posterPeoplePane .pfw-loading span {
    width: 24px;
    height: 24px;
    border: 3px solid #555;
    border-top-color: #ff9800;
    border-radius: 50%;
    animation: pfw-spin .8s linear infinite;
}

#posterPeoplePane .pfw-loading b {
    font-size: 10px;
}

@media (max-width: 768px) {
    body {
        flex-direction: column !important;
        height: 100dvh !important;
    }

    #container {
        width: 100% !important;
        height: 46vh !important;
        height: 46dvh !important;
        min-height: 0 !important;
        flex: 0 0 46vh !important;
        flex-basis: 46dvh !important;
    }

    #rootSelector {
        width: 100% !important;
        height: 54vh !important;
        height: 54dvh !important;
        min-height: 0 !important;
        flex: 0 0 54vh !important;
        flex-basis: 54dvh !important;
        margin: 0 !important;
        padding: 5px 6px max(5px, env(safe-area-inset-bottom)) !important;
        border-left: 0 !important;
        border-top: 2px solid #ff9800;
        border-radius: 0;
    }

    #posterSideToolbar {
        flex-basis: 36px;
    }

    #rootSelector #gedcomWrap {
        height: auto !important;
        margin-top: 3px !important;
        padding: 4px !important;
    }

    #posterPeoplePane .pfw-actions {
        top: -4px;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        padding-top: 3px;
    }

    #posterPeoplePane .pfw-actions button {
        min-height: 27px;
        padding: 3px 4px !important;
        font-size: 8px !important;
    }

    #posterPeoplePane .pfw-sources {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #posterPeoplePane .pfw-person-card {
        width: calc(100% - 18px);
        margin: 6px 13px 6px 5px;
    }
}

/* Maximum-height saving above the person cards. */
#posterPeoplePane .pfw-sources-column {
    padding: 2px 2px 3px;
}

#posterPeoplePane .pfw-source-select select,
#posterPeoplePane .pfw-delete-source {
    height: 28px;
    min-height: 28px;
}

#posterPeoplePane .pfw-detail {
    padding-top: 2px;
}

#posterPeoplePane .pfw-current {
    min-height: 15px;
    margin: 0 1px 2px;
    padding: 2px 5px;
    background: transparent;
    border-left-width: 1px;
}

#posterPeoplePane .pfw-current-meta {
    overflow: hidden;
    color: #bcbcbc;
    font-size: 7px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#posterPeoplePane .pfw-mode-group {
    margin-bottom: 3px;
}

#posterPeoplePane .pfw-segmented button {
    min-height: 25px;
    padding: 3px !important;
}

@media (max-width: 420px) {
    #rootSelector .pfw-view-switch button span:first-child,
    #rootSelector #mainMenuBtn span:first-child {
        display: none;
    }

    #posterPeoplePane .pfw-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 390px) {
    .pfw-layout {
        grid-template-columns: 96px minmax(0, 1fr);
    }

    .pfw-current-meta {
        max-width: 160px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* Compact family-tree picker: auxiliary actions live in the main Menu. */
#posterPeoplePane .pfw-sources-column {
    position: sticky;
    top: -5px;
    z-index: 4;
    display: flex;
    flex-direction: row;
    align-items: end;
    gap: 5px;
    padding: 4px 2px 7px;
    background: #333;
    border-bottom: 1px solid #4d4d4d;
}

#posterPeoplePane .pfw-source-select {
    display: flex;
    min-width: 0;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 3px;
}

#posterPeoplePane .pfw-source-select > span {
    color: #ffb33b;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: .055em;
    text-transform: uppercase;
}

#posterPeoplePane .pfw-source-select select {
    width: 100%;
    height: 32px;
    min-width: 0;
    padding: 4px 26px 4px 7px;
    overflow: hidden;
    color: #f5d98b;
    background: #1a1a1a;
    border: 1px solid #d4af37;
    border-radius: 5px;
    outline: 0;
    font-size: 10px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#posterPeoplePane .pfw-source-select select:focus {
    border-color: #ff9800;
    box-shadow: 0 0 0 2px rgba(255, 152, 0, .22);
}

#posterPeoplePane .pfw-delete-source {
    display: grid;
    width: 34px;
    height: 32px;
    min-width: 34px;
    min-height: 32px;
    place-items: center;
    margin: 0 !important;
    padding: 0 !important;
    color: #ffe7e7 !important;
    background: #742929 !important;
    border: 1px solid #9a4040 !important;
    border-radius: 5px !important;
    font-size: 14px !important;
}

#posterPeoplePane .pfw-delete-source:disabled,
#menuDropdown #pfwMenuExport:disabled,
#menuDropdown #pfwMenuImport:disabled {
    opacity: .42;
    cursor: not-allowed;
    filter: grayscale(.6);
}

@media (max-width: 768px) {
    #posterPeoplePane .pfw-sources-column {
        top: -4px;
        padding-top: 3px;
    }

    #posterPeoplePane .pfw-source-select select,
    #posterPeoplePane .pfw-delete-source {
        height: 30px;
        min-height: 30px;
    }
}

/* Final compact overrides must follow the picker rules above. */
#posterPeoplePane .pfw-sources-column {
    padding: 2px 2px 3px;
}

#posterPeoplePane .pfw-source-select {
    gap: 0;
}

#posterPeoplePane .pfw-source-select select,
#posterPeoplePane .pfw-delete-source {
    height: 28px;
    min-height: 28px;
}

/* Existing GEDCOM AI conversation, hosted inside Poster Designer. */
.gedcom-ai-backdrop[hidden],
.gedcom-ai-panel[hidden] {
    display: none !important;
}

.gedcom-ai-backdrop {
    position: fixed;
    inset: 0;
    z-index: 120000;
    background: rgba(15, 23, 42, .52);
    backdrop-filter: blur(2px);
}

.gedcom-ai-panel {
    position: fixed;
    z-index: 120010;
    top: calc(var(--gedcom-ai-visible-top, 0px) + 12px);
    left: 12px;
    display: grid;
    width: min(520px, calc(100vw - 24px));
    height: calc(var(--gedcom-ai-visible-height, 100vh) - 24px);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    padding: 0;
    overflow: hidden;
    color: #172033;
    background: #f8fafc;
    border: 1px solid #f0a11a;
    border-radius: 16px;
    box-shadow: 0 22px 60px rgba(15, 23, 42, .34);
    font-family: "Noto Sans", Arial, sans-serif;
}

.gedcom-ai-panel button,
.gedcom-ai-panel textarea,
.gedcom-ai-panel select {
    box-sizing: border-box;
    font: inherit;
}

.gedcom-ai-panel-head,
.gedcom-ai-history-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.gedcom-ai-panel-head {
    min-width: 0;
    padding: 7px 9px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}

.gedcom-ai-heading-copy {
    min-width: 0;
    flex: 1 1 auto;
}

.gedcom-ai-panel-head h2 {
    margin: 1px 0 0;
    color: #172033;
    font-size: 15px;
    line-height: 1.15;
}

.gedcom-ai-read-only {
    display: block;
    overflow: hidden;
    color: #9a4d09;
    font-size: 7px;
    font-weight: 800;
    letter-spacing: .04em;
    line-height: 1.2;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.gedcom-ai-head-actions,
.gedcom-ai-quota,
.gedcom-ai-quota-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.gedcom-ai-head-actions {
    flex: 0 0 auto;
}

.gedcom-ai-close {
    width: auto;
    min-width: 28px;
    height: 28px;
    padding: 0 9px;
    color: #64748b;
    background: #f1f5f9;
    border: 0;
    border-radius: 999px;
    font-size: 11px !important;
    font-weight: 800;
    line-height: 28px;
    cursor: pointer;
}

.gedcom-ai-quota {
    min-height: 28px;
    max-width: 185px;
    justify-content: center;
    padding: 4px 7px;
    color: #166534;
    background: #ecfdf3;
    border: 1px solid #bbf7d0;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.15;
    text-align: center;
}

.gedcom-ai-quota.is-checking {
    color: #475569;
    background: #f1f5f9;
    border-color: #dbe3ed;
    font-weight: 700;
}

.gedcom-ai-quota.is-unavailable {
    color: #9a3412;
    background: #fff7ed;
    border-color: #fed7aa;
    font-size: 8px;
}

.gedcom-ai-quota-actions button {
    padding: 2px 4px;
    font-size: 8px;
}

.gedcom-ai-context {
    min-width: 0;
    padding: 4px 7px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}

.gedcom-ai-intro {
    display: none;
}

.gedcom-ai-root-context {
    box-sizing: border-box;
    margin: 0;
    padding: 4px 6px;
    color: #5b35a5;
    background: #f0ebff;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.25;
}

.gedcom-ai-root-context::before {
    content: "●";
    margin-right: 4px;
    color: #8b5cf6;
}

.gedcom-ai-history-section {
    display: flex;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
    background: #f1f5f9;
}

.gedcom-ai-history-title-row {
    min-height: 27px;
    flex: 0 0 auto;
    padding: 3px 8px;
    background: rgba(255,255,255,.72);
    border-bottom: 1px solid #e2e8f0;
}

.gedcom-ai-history-title-row h3,
.gedcom-ai-evidence h3 {
    margin: 0;
    color: #475569;
    font-size: 9px;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.gedcom-ai-history-title-row button {
    padding: 3px 5px;
    color: #64748b;
    background: transparent;
    border: 0;
    font-size: 8px;
    cursor: pointer;
}

.gedcom-ai-history-scroll {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.gedcom-ai-history-empty {
    margin: auto;
    padding: 20px;
    color: #94a3b8;
    font-size: 12px;
}

.gedcom-ai-history-list {
    min-height: 0;
    flex: 0 0 auto;
    padding: 10px 11px 6px;
}

.myfamily-ai-history-entry {
    box-sizing: border-box;
    width: fit-content;
    max-width: 88%;
    margin: 0 0 10px;
    padding: 8px 10px;
    border: 0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(15,23,42,.08);
}

.myfamily-ai-history-entry.is-user {
    margin-left: auto;
    color: #3b2500;
    background: #f59e0b;
    border-bottom-right-radius: 4px;
}

.myfamily-ai-history-entry.is-assistant {
    margin-right: auto;
    color: #1e293b;
    background: #fff;
    border-bottom-left-radius: 4px;
}

.myfamily-ai-history-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.myfamily-ai-history-head strong {
    color: inherit;
    font-size: 9px;
    opacity: .7;
}

.myfamily-ai-history-content {
    margin: 4px 0 0;
    color: inherit;
    font-size: 12px;
    line-height: 1.48;
}

.gedcom-ai-panel .myfamily-ai-repeat-question {
    min-height: 23px;
    padding: 3px 7px;
    color: #3b2500;
    background: #f59e0b;
    border: 0;
    border-radius: 8px;
    font-size: 8px;
    font-weight: 800;
    cursor: pointer;
}

.gedcom-ai-evidence {
    margin: 0 10px 9px;
    padding: 7px 9px;
    color: #3f6212;
    background: #f7fee7;
    border: 1px solid #d9f99d;
    border-radius: 8px;
}

.gedcom-ai-evidence[hidden] {
    display: none !important;
}

.gedcom-ai-evidence ul {
    margin: 4px 0 0;
}

.gedcom-ai-evidence li {
    margin-bottom: 3px;
    font-size: 10px;
}

.gedcom-ai-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px 7px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
}

.gedcom-ai-preset-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 7px;
}

.gedcom-ai-preset-row label {
    color: #64748b;
    font-size: 9px;
    font-weight: 700;
}

.gedcom-ai-preset-row select {
    width: 100%;
    height: 29px;
    padding: 3px 25px 3px 7px;
    color: #334155;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 9px;
}

.gedcom-ai-compose-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 8px;
}

.gedcom-ai-form textarea {
    min-width: 0;
    min-height: 44px;
    max-height: 84px;
    resize: vertical;
    padding: 7px 8px;
    color: #172033;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 11px;
}

.gedcom-ai-form #gedcomAiSubmit {
    min-height: 38px;
    padding: 7px 10px;
    color: #3b2500;
    background: #f59e0b;
    border: 0;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 800;
    cursor: pointer;
}

.gedcom-ai-form #gedcomAiSubmit:disabled {
    opacity: .55;
    cursor: wait;
}

.gedcom-ai-status {
    box-sizing: border-box;
    width: 100%;
    color: #475569;
    font-size: 10px;
}

.gedcom-ai-status.is-error {
    padding: 6px 8px;
    color: #b91c1c;
    background: #fef2f2;
    border-radius: 7px;
}

.gedcom-ai-status.is-loading {
    min-height: 29px;
    padding: 5px 8px;
}

.gedcom-ai-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 600px) {
    .gedcom-ai-panel {
        top: calc(var(--gedcom-ai-visible-top, 0px) + 3px);
        right: 4px;
        left: 4px;
        width: auto;
        height: calc(var(--gedcom-ai-visible-height, 100vh) - 6px);
        border-radius: 12px;
    }

    .gedcom-ai-panel-head {
        padding: 6px 7px;
    }

    .gedcom-ai-read-only {
        max-width: 145px;
    }

    .gedcom-ai-quota {
        max-width: 140px;
        font-size: 9px;
    }

    .gedcom-ai-context {
        padding: 3px 6px;
    }

    .gedcom-ai-history-list {
        padding: 8px 8px 4px;
    }

    .myfamily-ai-history-entry {
        max-width: 92%;
        margin-bottom: 8px;
    }

    .gedcom-ai-form {
        padding: 5px 6px;
    }

    .gedcom-ai-form textarea {
        min-height: 42px;
        max-height: 62px;
        resize: none;
    }
}

@media (max-height: 590px) {
    .gedcom-ai-panel-head {
        padding-top: 5px;
        padding-bottom: 5px;
    }

    .gedcom-ai-context {
        padding-top: 2px;
        padding-bottom: 2px;
    }

    .gedcom-ai-history-title-row {
        min-height: 24px;
    }

    .gedcom-ai-form textarea {
        min-height: 40px;
    }
}

/* In People mode only the person-card list scrolls; all controls stay visible. */
#rootSelector #gedcomWrap.pfw-show-people {
    display: flex !important;
    height: 0 !important;
    min-height: 0 !important;
    flex: 1 1 0 !important;
    flex-direction: column;
    overflow: hidden !important;
}

#rootSelector #gedcomWrap.pfw-show-people #templateMenu {
    display: none !important;
}

#posterPeoplePane.pfw-panel {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: column;
    overflow: hidden;
}

#posterPeoplePane .pfw-sources-column {
    position: static;
    flex: 0 0 auto;
}

#posterPeoplePane .pfw-detail {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: column;
    overflow: hidden;
}

#posterPeoplePane .pfw-current,
#posterPeoplePane .pfw-mode-group,
#posterPeoplePane .pfw-search {
    flex: 0 0 auto;
}

#posterPeoplePane .pfw-people {
    min-height: 0;
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.pfw-confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100002;
    display: grid;
    padding: 14px;
    place-items: center;
    background: rgba(12, 10, 8, .68);
    opacity: 0;
    backdrop-filter: blur(6px);
    transition: opacity .16s ease;
}

.pfw-confirm-backdrop.is-visible {
    opacity: 1;
}

.pfw-confirm-dialog {
    width: min(370px, calc(100vw - 28px));
    box-sizing: border-box;
    padding: 20px;
    color: #2b2118;
    background: linear-gradient(145deg, #fffdf8, #f5eddf);
    border: 1px solid rgba(151, 98, 43, .25);
    border-radius: 20px;
    box-shadow: 0 26px 70px rgba(0, 0, 0, .42), inset 0 1px 0 rgba(255, 255, 255, .9);
    text-align: center;
    transform: translateY(8px) scale(.98);
    transition: transform .16s ease;
}

.pfw-confirm-backdrop.is-visible .pfw-confirm-dialog {
    transform: translateY(0) scale(1);
}

.pfw-confirm-icon {
    display: grid;
    width: 48px;
    height: 48px;
    margin: 0 auto 10px;
    place-items: center;
    color: #a62e24;
    background: #ffe7e2;
    border: 1px solid rgba(178, 54, 42, .18);
    border-radius: 50%;
    font-size: 22px;
}

.pfw-confirm-dialog h2 {
    margin: 0;
    color: #2b2118;
    font-size: 20px;
    line-height: 1.2;
}

.pfw-confirm-tree-name {
    display: block;
    margin: 9px 0 5px;
    overflow: hidden;
    color: #8a4b16;
    font-size: 14px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pfw-confirm-dialog p {
    margin: 0;
    color: #6d6259;
    font-size: 12px;
    line-height: 1.45;
}

.pfw-confirm-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    margin-top: 18px;
}

.pfw-confirm-actions button {
    min-height: 42px;
    padding: 9px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 850;
}

.pfw-confirm-cancel {
    color: #463c34;
    background: #fff;
    border: 1px solid rgba(70, 60, 52, .2);
}

.pfw-confirm-delete {
    color: #fff;
    background: linear-gradient(135deg, #c23e31, #9f291f);
    border: 1px solid #92261d;
    box-shadow: 0 8px 18px rgba(159, 41, 31, .22);
}

.pfw-confirm-actions button:focus-visible {
    outline: 3px solid rgba(255, 152, 0, .32);
    outline-offset: 2px;
}

@media (max-width: 420px) {
    .pfw-confirm-dialog {
        padding: 17px;
        border-radius: 17px;
    }

    .pfw-confirm-actions button {
        min-height: 44px;
    }
}
