.family-feature-shell,
.family-member-dialog,
.family-chat-popup {
    --family-panel: #191625;
    --family-inset: #13111e;
    --family-border: #3d354b;
    --family-ink: #faf5ff;
    --family-muted: #c0b7cd;
    --family-accent: #ffcb69;
    color: var(--family-ink);
}

.family-feature-shell [hidden],
.family-member-dialog [hidden],
.family-chat-popup [hidden] {
    display: none !important;
}

.family-feature-shell {
    width: min(70rem, 100% - 2rem);
    margin-inline: auto;
    padding-block: clamp(1.5rem, 5vw, 5rem);
}

.family-feature-panel,
.family-member-dialog {
    background: var(--family-panel);
    border: 1px solid var(--family-border);
    border-radius: 1.25rem;
    overflow: hidden;
}

.family-feature-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
}

.family-feature-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 2.75rem;
    padding: .65rem 1rem;
    border: 1px solid transparent;
    border-radius: .65rem;
    background: var(--family-accent);
    color: #24190b;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.family-feature-button:hover,
.family-feature-button:focus-visible {
    background: #ffe2a8;
    color: #24190b;
}

.family-feature-button:disabled { opacity: .6; cursor: wait; }
.family-feature-secondary { background: var(--family-inset); border-color: var(--family-border); color: var(--family-ink); }
.family-feature-back { display: inline-flex; gap: .65rem; margin-bottom: 1rem; color: var(--family-accent); }

.family-welcome {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.family-welcome-logo { width: 7rem; height: auto; margin-bottom: 1.5rem; }
.family-welcome-card { display: grid; grid-template-columns: 1fr 1fr; }
.family-welcome-copy { align-self: center; padding: clamp(1.5rem, 4vw, 3.5rem); }
.family-welcome-copy h1 { color: var(--family-ink); font-size: clamp(2rem, 4.4vw, 4rem); line-height: 1.06; }
.family-welcome-copy p { margin-block: 1rem 1.75rem; color: var(--family-muted); }
.family-welcome-copy h1 + .family-feature-actions { margin-top: 1.4rem; }
.family-welcome-media { display: grid; min-width: 0; background: var(--family-inset); }
.family-welcome-media > * { width: 100%; height: 100%; min-height: 18rem; object-fit: cover; border: 0; }
.family-welcome-media video { object-fit: contain; }

.family-member-profile {
    padding: 0;
    border: 0;
    background: transparent;
    color: #ffcb69;
    text-align: start;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: .18em;
}

.family-member-registrant { color: #e2bc81; }
.family-member-dialog .modal-header,
.family-member-dialog .modal-footer { border-color: var(--family-border); }
.family-member-dialog .modal-title { color: var(--family-ink); }
.family-profile-photo { width: 6rem; height: 6rem; object-fit: cover; border-radius: .75rem; margin-bottom: 1rem; }
.family-profile-fields > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: .75rem; padding-block: .65rem; border-bottom: 1px solid var(--family-border); }
.family-profile-fields > div:last-child { border-bottom: 0; }
.family-profile-fields dt { color: var(--family-muted); }
.family-profile-fields dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.family-chat { max-width: 55rem; }
.family-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid var(--family-border);
}
.family-chat-header > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.family-chat-header :is(h1, h2) { margin: 0; color: var(--family-ink); font-size: clamp(1.5rem, 4vw, 2rem); }
.family-chat-header p { margin: .25rem 0 0; color: var(--family-muted); }
.family-chat-scroll { height: clamp(16rem, 55dvh, 36rem); overflow-y: auto; padding: 1rem 1.5rem; background: var(--family-inset); overflow-anchor: none; }
.family-chat-empty { margin-top: 2rem; color: var(--family-muted); text-align: center; }
.family-chat-messages { display: grid; gap: .85rem; list-style: none; padding: 0; margin: .75rem 0 0; }
.family-chat-messages li { justify-self: start; max-width: min(90%, 40rem); padding: .7rem 1rem; border: 1px solid var(--family-border); border-radius: .85rem; background: var(--family-panel); }
.family-chat-messages li.is-mine { justify-self: end; background: #2e2434; border-color: #5b4556; }
.family-chat-messages p { margin: .3rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.family-chat-attachment { display: grid; gap: .35rem; margin-top: .45rem; }
.family-chat-attachment :is(img, video) {
    display: block;
    width: 100%;
    max-width: 24rem;
    max-height: 17rem;
    border-radius: .55rem;
    background: var(--family-inset);
    object-fit: contain;
}
.family-chat-attachment video { aspect-ratio: 16 / 9; }
.family-chat-attachment a { color: var(--family-accent); font-size: .82rem; text-decoration: underline; text-underline-offset: .16em; }
.family-chat-meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: .25rem .8rem; color: var(--family-accent); }
.family-chat-meta time { color: var(--family-muted); font-size: .8rem; }
.family-chat-form { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .55rem; padding: 1rem 1.5rem; border-top: 1px solid var(--family-border); }
.family-chat-form textarea { min-width: 0; resize: vertical; background: var(--family-inset); border: 1px solid var(--family-border); border-radius: .65rem; color: var(--family-ink); padding: .6rem .85rem; }
.family-chat-form textarea::placeholder { color: var(--family-muted); }
.family-chat-form p { grid-column: 1 / -1; margin: 0; color: var(--family-accent); }
.family-chat-form p:empty { display: none; }
.family-chat-form .family-chat-quota { color: var(--family-muted); font-size: .78rem; line-height: 1.35; }
.family-chat-file {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .45rem;
    padding: .2rem .3rem .2rem .6rem;
    border: 1px solid var(--family-border);
    border-radius: .6rem;
    background: var(--family-inset);
    color: var(--family-muted);
}
.family-chat-file span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.family-chat-attach { margin: 0; cursor: pointer; }
.family-chat-form input:disabled + .family-chat-attach { opacity: .6; cursor: not-allowed; }

.family-chat-launcher {
    position: fixed;
    z-index: 1030;
    inset-inline-end: max(1rem, env(safe-area-inset-right));
    inset-block-end: max(1rem, env(safe-area-inset-bottom));
    display: grid;
    place-items: center;
    width: 3.5rem;
    height: 3.5rem;
    border: 1px solid #ffcc66;
    border-radius: 50%;
    background: #ffcb69;
    box-shadow: 0 6px 22px #0a0811a6;
    color: #24190b;
    font-size: 1.65rem;
}

.family-chat-launcher:hover,
.family-chat-launcher:focus-visible {
    background: #ffe2a8;
    color: #24190b;
}

.family-chat-launcher[hidden] { display: none; }

.has-family-chat .progress-wrap {
    inset-block-end: calc(max(1rem, env(safe-area-inset-bottom)) + 4.1rem);
}

.family-chat-popup {
    position: fixed;
    inset: auto max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) auto;
    width: min(27rem, calc(100% - 2rem));
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 1.25rem;
    background: var(--family-panel);
    box-shadow: 0 14px 52px #07060dbb;
}

.family-chat-popup::backdrop { background: #08061245; }

.family-chat-popup .family-feature-panel {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 2rem);
}

.family-chat-popup .family-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    padding: .7rem .95rem;
}

.family-chat-popup .family-chat-header h2 { font-size: 1.25rem; }
.family-chat-popup .family-chat-scroll { height: min(23rem, 50dvh); min-height: 0; padding-inline: .85rem; }
.family-chat-popup .family-chat-form { padding: .7rem .85rem; }
.family-chat-popup .family-chat-form textarea { resize: none; }

.family-chat-control {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    min-width: 44px;
    min-height: 44px;
    border: 1px solid var(--family-border);
    border-radius: .65rem;
    background: var(--family-inset);
    color: var(--family-ink);
    text-decoration: none;
}

.family-chat-control:hover { color: var(--family-accent); }
.family-chat-launcher:focus-visible,
.family-chat-control:focus-visible,
.family-chat-form input:focus-visible + .family-chat-attach { outline: 2px solid #ffcc66; outline-offset: 3px; }

@media (max-width: 700px) {
    .family-welcome-card { grid-template-columns: 1fr; }
    .family-welcome-media > * { min-height: 0; aspect-ratio: 16 / 9; }
    .family-chat-header, .family-chat-scroll, .family-chat-form { padding-inline: .85rem; }
}

@media (max-width: 400px) {
    .family-profile-fields > div { grid-template-columns: 1fr; gap: .25rem; }
    .family-chat-form > .family-feature-button { padding-inline: .65rem; }
}
