/* ==========================================================================
   DESIGN TOKENS — the whole app reads from here. Gray page, white surfaces:
   every piece of content sits on a card or a full-bleed white section,
   never on bare gray.
   ========================================================================== */
:root {
    --green: #1F7A3D;
    --green-light: #4CBB6C;
    --ink: #111111;
    --bg: #F0F2F5;
    --surface: #ffffff;
    --border: #E4E6EB;
    --meta: #65676B;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
}

/* The hidden attribute must ALWAYS win. Any class that sets display
   (e.g. .pwa-banner { display: flex }) silently defeats the browser's
   built-in [hidden] rule — this bit us: the push prompt showed from
   page load and its dismiss button "did nothing". Author-origin
   !important keeps every current and future [hidden] element hidden. */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font-family: 'Poppins', system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    /* Sticky footer frame: main grows, the footer sits at the bottom of
       short pages and after the content on long ones. */
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* The landing/login/register run as full-bleed white sections. */
body.logged-out {
    background: var(--surface);
}

main.container {
    flex: 1 0 auto;
    width: 100%;
}

/* Type scale — page title 20/600, card & section titles 17/600, body 15,
   meta 13 gray. Page identity lives in the top bar; h1s stay small. */
h1 {
    font-size: 20px;
    font-weight: 600;
}

h2 {
    font-size: 17px;
    font-weight: 600;
}

h3 {
    font-size: 15px;
    font-weight: 600;
}

.muted {
    color: var(--meta);
}

.meta {
    font-size: 13px;
    color: var(--meta);
}

/* Consistent 56px top bar on every page, always a white surface. */
.top-nav {
    display: flex;
    align-items: center;
    height: 56px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

/* Back arrow: mobile sub-pages only (shown in the mobile block). */
.nav-back {
    display: none;
    border: none;
    background: none;
    padding: 8px;
    margin-left: -8px;
    color: var(--ink);
    cursor: pointer;
    line-height: 0;
}

.brand {
    font-size: 1.4rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--ink);
}

.brand-vine {
    color: var(--green);
}

/* Feed-like 680px column; the nav stays full-width. Settings/admin
   surfaces may widen to 900px via .container-wide / the staff console. */
.container {
    max-width: 680px;
    margin: 0 auto;
    padding: 16px 16px 24px;
}

.container-wide {
    max-width: 900px;
}

a {
    color: var(--green);
}

a:hover {
    color: var(--green-light);
}

.top-nav {
    justify-content: space-between;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Every top-nav item — links AND the Chat button — shares ONE rule set:
   same color, weight, spacing, hover. No chat-specific styling exists. */
.nav-links a,
.nav-links .nav-chat-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    font: inherit;
    font-weight: 500;
    color: var(--ink);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.nav-links a:hover,
.nav-links .nav-chat-btn:hover {
    color: var(--green);
}

.inline-form {
    display: inline;
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-weight: 500;
    color: var(--green);
    cursor: pointer;
}

.link-button:hover {
    color: var(--green-light);
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 28rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Form tokens: 13/600 labels above, 44px+ single-column fields, 16px
   font (no mobile zoom), brand-green focus ring, styled selects. */
.field span {
    font-size: 13px;
    font-weight: 600;
}

.field input,
.field select,
.field textarea,
.inline-form label input,
.inline-form label select {
    font: inherit;
    font-size: 16px;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #ccd0d5;
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
}

.field select,
.inline-form label select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2365676B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.inline-form input:focus,
.inline-form select:focus {
    outline: 2px solid var(--green-light);
    outline-offset: 1px;
    border-color: var(--green);
}

fieldset.stack {
    border: 1px solid #dddddd;
    border-radius: 8px;
    padding: 1rem;
}

legend {
    font-weight: 600;
    padding: 0 0.4rem;
}

/* ==========================================================================
   DESIGN SYSTEM — one button language. Canonical classes: .btn-primary,
   .btn-secondary, .btn-danger, .btn-ghost. Legacy selectors (.button,
   button[type=submit], .danger, .secondary, .link-button, .small) are
   ALIASES sharing the exact same tokens: one radius (8px), one padding
   scale, one font.
   ========================================================================== */
.btn,
.button,
a.button,
button[type="submit"],
button.small,
.call-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    text-decoration: none;
    align-self: flex-start;
}

.btn-primary,
.button,
button[type="submit"] {
    background: var(--green);
    color: #ffffff !important;
}

.btn-primary:hover,
.button:hover,
button[type="submit"]:hover {
    background: var(--green-light);
    color: #ffffff;
}

.btn-secondary,
button.secondary,
.button.secondary,
.btn.secondary {
    background: #ffffff;
    color: var(--ink) !important;
    border-color: var(--ink);
}

.btn-danger,
button.danger,
.button.danger {
    background: #b00020;
    color: #ffffff !important;
}

.btn-danger:hover,
button.danger:hover {
    background: #d32f2f;
}

.btn-ghost {
    background: none;
    border-color: transparent;
    color: var(--green) !important;
    padding: 0.2rem 0.4rem;
}

/* Size modifier — same language, smaller scale. */
.small,
button.small,
.btn.small,
.button.small {
    padding: 0.35rem 0.8rem;
    font-size: 0.875rem;
    font-weight: 500;
}

/* THE form action row. Primary action is always the FIRST child. Side by
   side on desktop; the mobile block stacks it vertically, full width.
   Breathing room is enforced HERE, never per-page: 20px before any
   action row (a .stack's own 16px gap contributes 16 of it). */
.form-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 20px;
}

.stack .form-actions {
    margin-top: 4px;
}

/* Fields outside a .stack still get the minimum 16px rhythm. */
form:not(.stack) .field {
    margin-bottom: 16px;
}

/* Rows composed of sibling one-button forms (approve/decline pairs)
   flatten so every button is a direct row item. */
.form-actions form,
.form-actions .inline-form {
    display: contents;
}

.errors {
    color: #b00020;
    background: #fdecee;
    border: 1px solid #f5c2c7;
    border-radius: 6px;
    padding: 0.75rem 1rem 0.75rem 2rem;
}

.success {
    color: var(--green);
    background: #ecf8f0;
    border: 1px solid #bfe6cc;
    border-radius: 6px;
    padding: 0.75rem 1rem;
}

.page-intro {
    font-size: 13px;
    color: var(--meta);
    margin: 4px 2px 12px;
}

.table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
}

.table th,
.table td {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #eeeeee;
}

.table th {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #555555;
}

.badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    vertical-align: middle;
}

.badge-active {
    background: #ecf8f0;
    color: var(--green);
}

.badge-archived {
    background: #f2f2f2;
    color: #666666;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    gap: 16px;
    margin: 16px 0;
}

/* THE surface: 12px radius, 1px token border, subtle shadow, 16px pad. */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.cards .card {
    margin-bottom: 0;
}

.card h2,
.card h3 {
    margin-top: 0;
}

.card > :last-child {
    margin-bottom: 0;
}

/* (.button / button.small / button.danger now live in the design-system
   block above — kept out of here so tokens exist exactly once.) */

.inline-form select {
    font: inherit;
    padding: 0.25rem 0.4rem;
    border: 1px solid #cccccc;
    border-radius: 6px;
}

.profile dt {
    font-size: 0.85rem;
    font-weight: 600;
    color: #555555;
    margin-top: 0.9rem;
}

.profile dd {
    margin: 0.15rem 0 0;
}

.badge-managed,
.badge-pending {
    background: #fff4e0;
    color: #9a6200;
}

.badge-accepted {
    background: #ecf8f0;
    color: var(--green);
}

.badge-expired,
.badge-revoked {
    background: #f2f2f2;
    color: #666666;
}

.badge-role {
    background: #eef4fb;
    color: #2b5c8a;
}

.badge-relation {
    background: #eef7f0;
    color: var(--green);
    font-weight: 500;
}

.badge-memorial {
    background: #efe9f7;
    color: #5b4380;
}

.notice {
    border: 1px solid #f0d9a8;
    background: #fffaf0;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
}

.tree-wrap {
    position: relative;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    overflow: hidden;
    background: #fcfdfc;
    touch-action: none;
    user-select: none;
}

.tree-viewport {
    overflow: hidden;
}

.tree-tooltip {
    position: absolute;
    transform: translateX(-50%);
    background: #2b2b2b;
    color: #ffffff;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 30;
}

.tree-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #eeeeee;
}

.tree-wrap svg {
    cursor: grab;
    display: block;
}

.tree-partner-line {
    stroke: var(--green-light);
    stroke-width: 3;
}

.tree-child-line {
    stroke: #bbbbbb;
    stroke-width: 2;
}

.tree-node-circle {
    fill: #eaf5ee;
    stroke: var(--green);
    stroke-width: 2.5;
}

.tree-node-circle.tree-node-managed {
    fill: #fff4e0;
    stroke: #c98a10;
    stroke-dasharray: 5 3;
}

.tree-node-circle.tree-node-memorial {
    fill: #efe9f7;
    stroke: #5b4380;
}

.tree-node-ring {
    stroke: var(--green);
    stroke-width: 2.5;
}

/* Invited arrival: the newcomer's own node pulses so "tap yourself"
   needs no explanation. */
.tree-node-pulse {
    fill: none;
    stroke: var(--green-light);
    animation: tree-pulse 1.6s ease-out infinite;
}

@keyframes tree-pulse {
    0% { stroke-opacity: 0.9; stroke-width: 3; }
    70% { stroke-opacity: 0; stroke-width: 16; }
    100% { stroke-opacity: 0; stroke-width: 3; }
}

.tree-node-initials {
    font-weight: 600;
    font-size: 18px;
    fill: var(--ink);
}

.tree-node-name {
    font-size: 13px;
    fill: var(--ink);
}

.tree-node-badge {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tree-badge-managed {
    fill: #9a6200;
}

.tree-badge-memorial {
    fill: #5b4380;
}

.wizard-steps {
    display: flex;
    gap: 1.5rem;
    list-style: none;
    padding: 0;
    font-weight: 500;
    color: #999999;
}

.wizard-steps .current {
    color: var(--green);
    font-weight: 700;
}

.tributes {
    list-style: none;
    padding: 0;
}

.tributes li {
    border-left: 3px solid var(--green-light);
    padding-left: 1rem;
    margin: 1rem 0;
}

.tributes blockquote {
    margin: 0;
}

.kinship-label {
    color: var(--green);
}

.walkthrough {
    font-style: italic;
    color: #444444;
}

.relationship-tree {
    margin-top: 1.5rem;
}

[x-cloak] {
    display: none !important;
}

.post-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 16px;
    margin: 16px 0;
}

.post-head {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: #eaf5ee;
    color: var(--green);
    font-weight: 700;
    flex-shrink: 0;
}

.post-body {
    white-space: pre-line;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.media-grid img,
.media-grid video {
    width: 100%;
    height: 10rem;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

.media-grid audio {
    width: 100%;
    align-self: center;
}

/* Video pipeline tiles: processing (quiet) and failed (plain-spoken). */
.video-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    height: 10rem;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    padding: 12px;
}

.video-tile-processing {
    background: #f0f2f5;
    color: var(--meta);
    animation: pulse 2.4s ease-in-out infinite;
}

.video-tile-failed {
    background: #fdecee;
    color: #b00020;
}

.video-tile-failed .meta {
    color: #b00020;
    opacity: 0.7;
}

.album-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: 0.5rem;
    margin: 0.75rem 0 1.5rem;
}

.album-grid img,
.album-grid video {
    width: 100%;
    height: 9rem;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

.reaction-bar {
    display: flex;
    gap: 0.35rem;
    margin: 0.5rem 0;
}

.reaction-button {
    font: inherit;
    background: #f5f7f5;
    border: 1px solid #e0e0e0;
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    cursor: pointer;
}

.reaction-button.active {
    background: #eaf5ee;
    border-color: var(--green);
}

.reaction-count {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--green);
}

.comments {
    border-top: 1px solid #f0f0f0;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
}

.comment p {
    margin: 0.15rem 0 0.6rem;
}

.comment-form {
    display: flex;
    gap: 0.5rem;
}

.comment-form input[type="text"] {
    flex: 1;
    font: inherit;
    padding: 0.4rem 0.6rem;
    border: 1px solid #cccccc;
    border-radius: 6px;
}

.composer {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 16px;
}

.tag-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    padding: 0.6rem;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    margin-top: 0.5rem;
}

.tag-option {
    white-space: nowrap;
}

.feed-sentinel {
    text-align: center;
    padding: 1rem;
}

.derived-panel {
    border: 1px solid #d9ecdf;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin: 16px 0;
}

.derived-panel h2 {
    font-size: 1rem;
    margin: 0.25rem 0 0.5rem;
}

.derived-list {
    list-style: none;
    padding: 0;
    margin: 0 0 0.5rem;
}

.derived-list li {
    padding: 0.2rem 0;
}

.rsvp-buttons {
    display: flex;
    gap: 0.5rem;
    margin: 0.5rem 0 1rem;
}

button.rsvp-active {
    background: var(--green);
    color: #ffffff;
    border-color: var(--green);
}

.notif-slot {
    position: relative;
}

.notif-bell {
    position: relative;
    display: inline-block;
}

.bell-button {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    position: relative;
    padding: 0.2rem;
}

.bell-count {
    position: absolute;
    top: -0.35rem;
    right: -0.5rem;
    background: #b00020;
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 0.05rem 0.35rem;
}

.bell-dropdown {
    position: absolute;
    right: 0;
    top: 2.2rem;
    width: 20rem;
    max-height: 24rem;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
    padding: 0.75rem 1rem;
    z-index: 50;
}

.bell-list {
    list-style: none;
    padding: 0;
    margin: 0 0 0.5rem;
}

.bell-list li {
    padding: 0.4rem 0;
    border-bottom: 1px solid #f2f2f2;
}

.bell-list li.unread a {
    font-weight: 700;
}

.bell-list a {
    text-decoration: none;
    color: var(--ink);
}

.chat-layout {
    display: grid;
    grid-template-columns: 16rem 1fr;
    gap: 1.5rem;
    align-items: start;
}

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

.chat-list li {
    border-radius: 8px;
    padding: 0.15rem 0.4rem;
}

.chat-list li.active {
    background: #eaf5ee;
}

.chat-list a {
    text-decoration: none;
    display: block;
    padding: 0.35rem 0.2rem;
}

.badge-unread {
    background: var(--green);
    color: #ffffff;
}

.chat-messages {
    height: 26rem;
    overflow-y: auto;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    background: #fcfdfc;
}

.msg {
    margin: 0.6rem 0;
    max-width: 85%;
}

.msg.mine {
    margin-left: auto;
    background: #eaf5ee;
    border-radius: 10px;
    padding: 0.4rem 0.6rem;
}

.msg-body {
    white-space: pre-wrap;
}

.msg-quote {
    margin: 0.25rem 0;
    padding: 0.25rem 0.6rem;
    border-left: 3px solid var(--green-light);
    background: #f4f8f5;
    font-size: 0.9rem;
    color: #555555;
}

.msg-photo {
    max-width: 16rem;
    border-radius: 8px;
    display: block;
    margin: 0.3rem 0;
}

.msg audio {
    display: block;
    margin: 0.3rem 0;
    max-width: 100%;
}

.msg-reactions {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.2rem;
}

.msg-react {
    background: none;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0 0.3rem;
    cursor: pointer;
    font-size: 0.85rem;
    opacity: 0.55;
}

.msg-react:hover,
.msg-react.active,
.msg-react .reaction-count {
    opacity: 1;
}

.msg-reply-btn {
    font-size: 0.75rem;
}

.chat-composer {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.chat-composer input[type="text"] {
    flex: 1;
    font: inherit;
    padding: 0.5rem 0.75rem;
    border: 1px solid #cccccc;
    border-radius: 999px;
}

.voice-button {
    font-size: 1.3rem;
    background: #eaf5ee;
    border: 2px solid var(--green);
    border-radius: 50%;
    width: 2.8rem;
    height: 2.8rem;
    cursor: pointer;
}

.voice-button.recording {
    background: #b00020;
    border-color: #b00020;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    50% { opacity: 0.6; }
}

.reply-preview {
    margin-top: 0.5rem;
    padding: 0.3rem 0.6rem;
    background: #f4f8f5;
    border-radius: 6px;
    font-size: 0.85rem;
}

@media (max-width: 48rem) {
    .chat-layout { grid-template-columns: 1fr; }
}

.progress-track {
    height: 0.9rem;
    background: #e8efe9;
    border-radius: 999px;
    overflow: hidden;
    margin: 0.5rem 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--green-light));
    border-radius: 999px;
    transition: width 0.4s ease;
}

.phrase-of-day {
    border: 1px solid #d9ecdf;
    background: linear-gradient(135deg, #ffffff, #f4faf6);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin: 16px 0;
}

.phrase-of-day-label {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.phrase-text {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--green);
    margin: 0.25rem 0;
}

.phrase-card {
    max-width: 44rem;
    margin: 1rem 0;
}

.recorder-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.staff-nav {
    background: #111111;
}

.staff-nav .brand,
.staff-nav .nav-links a,
.staff-nav .link-button {
    color: #ffffff;
}

.staff-tag {
    font-size: 0.7rem;
    background: var(--green);
    color: #ffffff;
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    vertical-align: middle;
}

.staff-banner {
    font-size: 0.8rem;
    border-bottom: 1px dashed #dddddd;
    padding-bottom: 0.5rem;
}

.stat-hero {
    border: 2px solid var(--green);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin: 1rem 0;
    max-width: 30rem;
}

.stat-value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--green);
    line-height: 1;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
    height: 9rem;
    padding: 0.5rem 0 1.5rem;
    max-width: 44rem;
}

.bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    height: 100%;
    position: relative;
}

.bar {
    width: 100%;
    background: linear-gradient(180deg, var(--green-light), var(--green));
    border-radius: 4px 4px 0 0;
    min-height: 2px;
}

.bar-label {
    position: absolute;
    bottom: -1.4rem;
    font-size: 0.65rem;
    color: #777777;
}

.totp-qr {
    margin: 1rem 0;
}

.totp-secret {
    font-size: 1.1rem;
    letter-spacing: 0.1em;
}

.seen-by {
    margin: 0.35rem 0 0.1rem;
}

.seen-by-row {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
}

.seen-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.3rem;
    height: 1.3rem;
    border-radius: 50%;
    background: #eaf5ee;
    color: var(--green);
    font-size: 0.7rem;
    font-weight: 700;
    border: 1px solid #ffffff;
    margin-right: -0.5rem;
}

.seen-avatar:last-of-type {
    margin-right: 0.2rem;
}

.seen-text {
    font-size: 0.8rem;
    color: #777777;
}

.seen-full {
    font-size: 0.85rem;
    padding: 0.25rem 0;
}

.album-card {
    text-decoration: none;
    color: var(--ink);
    display: block;
}

.album-cover {
    width: 100%;
    height: 9rem;
    object-fit: cover;
    border-radius: 8px;
    display: block;
    margin-bottom: 0.5rem;
}

.msg-read-by {
    font-size: 0.75rem;
    text-align: right;
    margin-top: 0.15rem;
}

.quiz-card {
    border: 2px solid var(--green-light);
    border-radius: 16px;
    padding: 2rem 1.5rem;
    max-width: 30rem;
    margin: 1.5rem auto;
    text-align: center;
    background: #fcfdfc;
}

.quiz-big {
    font-size: 2rem;
    font-weight: 700;
    color: var(--green);
    margin: 1rem 0;
    overflow-wrap: break-word;
}

.quiz-prompt {
    font-weight: 600;
}

.quiz-meaning {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0.75rem 0;
}

.quiz-reveal {
    font: inherit;
    font-weight: 600;
    font-size: 1.1rem;
    padding: 0.9rem 2rem;
    border-radius: 999px;
    border: none;
    background: var(--green);
    color: #ffffff;
    cursor: pointer;
    margin-top: 1rem;
    width: 100%;
    max-width: 20rem;
}

.quiz-grades {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-top: 1.25rem;
}

.quiz-grade {
    font: inherit;
    font-weight: 600;
    padding: 0.8rem 0.25rem;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    color: #ffffff;
}

.grade-again { background: #b00020; }
.grade-hard  { background: #c98a10; }
.grade-good  { background: var(--green); }
.grade-easy  { background: #2b7de9; }

.quiz-card audio {
    width: 100%;
    margin: 0.5rem 0;
}

.recipe-story {
    border-left: 4px solid var(--green-light);
    background: #f6fbf7;
    border-radius: 0 10px 10px 0;
    padding: 1rem 1.25rem;
    margin: 1rem 0;
    font-size: 1.05rem;
    max-width: 44rem;
}

.recipe-photo {
    max-width: 100%;
    width: 34rem;
    border-radius: 12px;
    display: block;
}

.recipe-ingredients li,
.recipe-steps li {
    padding: 0.25rem 0;
    max-width: 40rem;
}

.recipe-steps li {
    margin-bottom: 0.5rem;
}

.ingredient-row {
    display: flex;
    gap: 0.5rem;
}

.ingredient-row input:first-child {
    width: 8rem;
}

.ingredient-row input,
.step-row textarea {
    font: inherit;
    padding: 0.45rem 0.6rem;
    border: 1px solid #cccccc;
    border-radius: 6px;
    flex: 1;
}

.step-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.step-number {
    font-weight: 700;
    color: var(--green);
    padding-top: 0.5rem;
}

@media (max-width: 30rem) {
    .quiz-grades { grid-template-columns: repeat(2, 1fr); }
}

.announcement {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    border-radius: 10px;
    padding: 0.6rem 1rem;
    margin-bottom: 1rem;
}

.announcement-info { background: #eef4fb; border: 1px solid #c4d9f2; }
.announcement-warning { background: #fff4e0; border: 1px solid #f0d9a8; }
.announcement-celebration { background: #f6fbf7; border: 1px solid #d9ecdf; }

.post-tombstone {
    background: #fafafa;
    text-align: center;
    border-style: dashed;
}

.report-details summary {
    font-size: 0.8rem;
    cursor: pointer;
    margin-top: 0.4rem;
}

.report-isolation {
    border: 2px dashed #cccccc;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    max-width: 40rem;
    background: #fcfcfc;
}

.cohort-table .cohort-cell {
    text-align: center;
    min-width: 3rem;
}

body.elder-mode {
    font-size: 1.18em;
    line-height: 1.65;
}

.elder-toggle {
    vertical-align: middle;
    font-weight: 700;
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.avatar-round {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: middle;
    flex-shrink: 0;
}

.avatar-initials {
    color: #ffffff;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    letter-spacing: 0.02em;
    user-select: none;
}

.nav-me {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.chat-section {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #888888;
    margin: 1rem 0 0.25rem;
}

/* --- Logged-out landing: one screen, no scrolling ---------------------- */
body.logged-out .container {
    display: flex;
    flex-direction: column;
    padding: 1rem 1.5rem;
}

.landing {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.25rem;
    min-height: 0;
}

.landing-hero-row {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    align-items: center;
    gap: 2.5rem;
}

.landing-headline {
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    line-height: 1.2;
    margin: 0 0 0.75rem;
}

.landing-tagline {
    font-size: 1.05rem;
    line-height: 1.5;
    color: #444444;
    margin: 0 0 1.25rem;
}

.landing-actions {
    display: flex;
    gap: 0.75rem;
    margin: 0;
}

.landing-cta {
    font-size: 1.05rem;
    padding: 0.75rem 2rem;
}

.landing-cta-secondary {
    background: #ffffff;
    color: var(--green) !important;
    border: 2px solid var(--green);
}

.landing-cta-secondary:hover {
    background: #eaf5ee;
}

.landing-hero {
    width: 100%;
    height: auto;
    max-height: min(44vh, 330px);
    display: block;
}

/* Feature row: three compact icon cards. */
.landing-features {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin: 0;
    padding: 16px 0 0;
}

.landing-features li {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 500;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 12px;
}

.landing-features .icon {
    color: var(--green);
}

/* --- Site footer: quiet single row on every page ------------------------ */
.site-footer {
    flex-shrink: 0;
    border-top: 1px solid #eeeeee;
    font-size: 0.8rem;
    color: #777777;
    background: #ffffff;
}

.site-footer-inner {
    max-width: 60rem;
    margin: 0 auto;
    padding: 0.6rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.site-footer-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
}

.site-footer-brand svg {
    height: auto;
}

.site-footer-motto {
    color: #777777;
}

.site-footer-links {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.site-footer-links a {
    color: #777777;
    text-decoration: none;
}

.site-footer-links a:hover {
    color: var(--green);
}

.site-footer-copy {
    margin-left: auto;
    white-space: nowrap;
}

/* --- DM popup chat (docked bottom-right) ------------------------------- */
.dm-dock {
    position: fixed;
    right: 12px;
    bottom: 0;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    z-index: 60;
}

.dm-strip {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    padding-bottom: 10px;
}

.dm-strip-avatar {
    position: relative;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
}

.dm-mute {
    border: none;
    background: #ffffff;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    cursor: pointer;
}

.dm-panels {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.dm-popup {
    width: 300px;
    background: #ffffff;
    border: 1px solid #dddddd;
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
}

.dm-head {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    background: var(--green);
    color: #ffffff;
    border-radius: 10px 10px 0 0;
}

.dm-title {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    min-width: 0;
}

.dm-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dm-badge {
    background: #d64545;
    color: #ffffff;
    border-radius: 10px;
    font-size: 11px;
    padding: 1px 7px;
    font-weight: 700;
}

.dm-strip-avatar .dm-badge {
    position: absolute;
    top: -4px;
    right: -6px;
}

.dm-full,
.dm-close {
    border: none;
    background: none;
    color: #ffffff;
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: none;
    padding: 2px 6px;
}

.dm-body {
    display: flex;
    flex-direction: column;
    height: 320px;
}

.dm-popup.minimized .dm-body {
    display: none;
}

.dm-messages {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    font-size: 0.85rem;
}

.dm-messages .msg {
    margin-bottom: 8px;
}

.dm-composer {
    display: flex;
    gap: 6px;
    padding: 6px;
    border-top: 1px solid #eeeeee;
}

.dm-composer input {
    flex: 1;
    min-width: 0;
}

@media (max-width: 640px) {
    .dm-panels .dm-popup:not(:last-child) {
        display: none; /* one panel at a time on phones */
    }
    .dm-popup {
        width: min(300px, calc(100vw - 70px));
    }
}

/* --- Calls (WebRTC) ------------------------------------------------------ */
#kv-call-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 19, 0.94);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.call-card {
    text-align: center;
    color: #ffffff;
    padding: 24px;
}

.call-card h2 {
    color: #ffffff;
    margin: 16px 0 4px;
}

.call-sub {
    color: #b9ccbf;
    margin-bottom: 28px;
}

.call-actions {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: center;
}

.call-actions button {
    font-size: 1.25rem;
    padding: 16px 36px;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    min-width: 270px;
}

.call-accept {
    background: #1F7A3D;
    color: #ffffff;
}

.call-accept.secondary {
    background: #3c5a46;
    color: #ffffff;
}

.call-decline {
    background: #c0392b;
    color: #ffffff;
}

.call-stage {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    flex-direction: column;
}

.call-tiles {
    flex: 1;
    display: grid;
    gap: 8px;
    padding: 12px;
    grid-template-columns: 1fr;
    align-items: stretch;
}

.call-tiles[data-count="2"] { grid-template-columns: repeat(2, 1fr); }
.call-tiles[data-count="3"],
.call-tiles[data-count="4"] { grid-template-columns: repeat(2, 1fr); }
.call-tiles[data-count="5"],
.call-tiles[data-count="6"] { grid-template-columns: repeat(3, 1fr); }

.call-tile {
    position: relative;
    background: #22301f;
    border-radius: 12px;
    overflow: hidden;
    min-height: 140px;
}

.call-tile video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.call-tile.video-off video {
    opacity: 0.15;
}

.call-tile-name {
    position: absolute;
    left: 10px;
    bottom: 8px;
    color: #ffffff;
    font-size: 0.85rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.call-tile-muted {
    position: absolute;
    right: 10px;
    bottom: 8px;
}

#call-self {
    position: absolute;
    right: 16px;
    bottom: 86px;
    width: 130px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.6);
    transform: scaleX(-1);
    background: #22301f;
}

#call-self.video-off {
    opacity: 0.2;
}

.call-controls {
    display: flex;
    justify-content: center;
    gap: 18px;
    padding: 16px;
}

.call-controls button {
    font-size: 1.4rem;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: #ffffff;
}

.call-controls button.off {
    background: #777777;
}

.call-controls .danger {
    background: #c0392b;
}

.call-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #eaf5ee;
    border: 1px solid var(--green-light);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
}

.badge-call {
    background: #1F7A3D;
    color: #ffffff;
    font-size: 11px;
    border-radius: 10px;
    padding: 1px 8px;
}

.dm-call {
    border: none;
    background: none;
    color: #ffffff;
    cursor: pointer;
    padding: 2px 4px;
}

/* Elder Mode: no outgoing call UI; the incoming card is already giant. */
.elder-mode .call-start {
    display: none;
}

/* --- Person links: names are doors, not blue noise -------------------- */
.person-link {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

a.person-link:hover .person-link-name,
a.person-link:focus .person-link-name {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* --- Presence dots ------------------------------------------------------ */
.presence-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #c9c9c9;
    vertical-align: middle;
}

.presence-dot.online {
    background: #2ecc71;
    box-shadow: 0 0 0 2px #ffffff;
}

/* --- Chat home (roster) + Messages inbox -------------------------------- */
.chat-home {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 24px;
}

@media (max-width: 760px) {
    .chat-home { grid-template-columns: 1fr; }
}

.roster-search {
    width: 100%;
    margin-bottom: 10px;
}

.roster-list {
    list-style: none;
    padding: 0;
    margin: 0 0 14px;
}

.roster-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 6px 8px;
    border: none;
    background: none;
    cursor: pointer;
    font: inherit;
    text-align: left;
    border-radius: 8px;
}

.roster-row:hover {
    background: #eef4ef;
}

.roster-name { flex: 1; }

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

.inbox-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    border-bottom: 1px solid #eeeeee;
    text-decoration: none;
    color: inherit;
}

.inbox-row:hover { background: #f6faf7; }

.inbox-title { min-width: 200px; }

.inbox-unread .inbox-title,
.inbox-unread .inbox-preview { font-weight: 700; color: var(--ink); }

.inbox-preview {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inbox-when { white-space: nowrap; }

.tree-badge-duplicate {
    fill: #b3541e;
    font-weight: 700;
}

/* --- Chat slide-over panel ---------------------------------------------- */
.chat-slideover {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: min(360px, 92vw);
    background: #ffffff;
    border-left: 1px solid #dddddd;
    box-shadow: -4px 0 18px rgba(0, 0, 0, 0.12);
    z-index: 70;
    display: flex;
    flex-direction: column;
}

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

.chat-slideover-body {
    overflow-y: auto;
    padding: 12px 16px;
    flex: 1;
}

.chat-subsection {
    margin: 10px 0 4px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}


/* ==========================================================================
   LIST ROWS — the shared row that replaces tables: 40px avatar/icon left,
   two-line text block, inline chips, right-aligned 40x40 kebab that opens
   a dropdown (desktop) or bottom sheet (mobile).
   ========================================================================== */
.list-card {
    padding: 0;
    overflow: visible;
}

.list-card > h2 {
    padding: 14px 16px 0;
    margin: 0;
}

.list-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    min-height: 56px;
}

.list-row + .list-row {
    border-top: 1px solid #f0f2f5;
}

.list-row-avatar {
    flex-shrink: 0;
    display: inline-flex;
    line-height: 0;
}

/* Icon rows (families, invites…) get a tinted 40px disc. */
.list-row-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eaf5ee;
    color: var(--green);
}

.list-row-main {
    flex: 1;
    min-width: 0;
}

.list-row-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 15px;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.list-row-title a {
    color: inherit;
    text-decoration: none;
}

.list-row-title a:hover {
    color: var(--green);
}

.list-row-meta {
    font-size: 13px;
    color: var(--meta);
    margin-top: 2px;
}

.list-row-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Kebab + its menu: dropdown on desktop, bottom sheet on phones. */
.list-row-menu-wrap {
    position: relative;
    flex-shrink: 0;
    display: inline-flex;
}

.kebab {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: none;
    color: var(--meta);
    cursor: pointer;
}

.kebab:hover {
    background: #f0f2f5;
    color: var(--ink);
}

.icon-button {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: none;
    color: var(--meta);
    cursor: pointer;
}

.icon-button:hover {
    background: #f0f2f5;
    color: var(--green);
}

.icon-button.copied {
    background: #eaf5ee;
    color: var(--green);
}

.row-menu {
    position: absolute;
    right: 0;
    top: 44px;
    z-index: 60;
    min-width: 240px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
    padding: 12px 16px;
}

.row-menu form {
    margin: 0 0 10px;
}

.row-menu form:last-child {
    margin-bottom: 0;
}

.row-menu-title {
    font-weight: 600;
    margin: 2px 0 10px;
}

.row-menu-backdrop {
    display: none;
}

.row-menu-grabber {
    display: none;
}

/* Approval blocks (claims, merges, confirmations): stacked text +
   decision row — the mobile-safe replacement for decision tables. */
.approval p {
    margin: 0 0 6px;
}

.approval .form-actions {
    margin-top: 8px;
}

.approval + .approval {
    border-top: 1px solid #f0f2f5;
    margin-top: 14px;
    padding-top: 14px;
}

/* ==========================================================================
   ONBOARDING — welcome banner, hello nudge, historian checklist. All
   in-context guidance: no modals, no tooltip tours, dismisses forever.
   ========================================================================== */
.welcome-banner,
.nudge-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-color: #bfe6cc;
    background: linear-gradient(135deg, #ffffff, #f2faf4);
}

.welcome-banner-body,
.nudge-banner-body {
    flex: 1;
}

.welcome-banner p,
.nudge-banner p {
    margin: 4px 0 0;
}

.onboarding-checklist .checklist-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.onboarding-checklist .checklist-head h2 {
    flex: 1;
    margin: 0;
}

.checklist-dismiss {
    margin: 0;
}

.checklist-items {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
}

.checklist-items li {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
}

.checklist-items a {
    flex: 1;
    text-decoration: none;
    color: var(--ink);
    font-weight: 500;
}

.checklist-items a:hover {
    color: var(--green);
}

.checklist-done span:last-child {
    color: var(--meta);
    text-decoration: line-through;
}

.checklist-check {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #eaf5ee;
    color: var(--green);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.checklist-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid #ccd0d5;
    flex-shrink: 0;
}

.checklist-go {
    color: var(--meta);
    display: inline-flex;
}

/* ==========================================================================
   EMPTY STATES — centered icon, 17px heading, one line, one primary CTA.
   ========================================================================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 32px 24px;
}

.empty-state-icon {
    color: var(--green);
    background: #eaf5ee;
    border-radius: 50%;
    width: 64px;
    height: 64px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.empty-state h2 {
    margin: 4px 0 0;
}

.empty-state p {
    margin: 0;
    color: var(--meta);
}

.empty-state .btn,
.empty-state .button {
    margin-top: 8px;
    align-self: center;
}

/* ==========================================================================
   PROFILE HEADER + pill action row (person pages).
   ========================================================================== */
.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
}

.profile-header h1 {
    margin: 8px 0 0;
}

.profile-header .profile-meta {
    font-size: 13px;
    color: var(--meta);
}

.profile-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
}

.pill-row {
    display: flex;
    gap: 8px;
    width: 100%;
    margin-top: 12px;
    flex-wrap: wrap;
}

.pill-row > * {
    flex: 1 1 0;
    min-width: 8rem;
    justify-content: center;
    text-align: center;
}

/* Stacked equal-width action buttons under lists (8px gap). */
.button-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 16px 0;
}

.button-stack .btn,
.button-stack .button {
    width: 100%;
    justify-content: center;
}

/* Staff console: one wide white surface for the whole page. */
.staff-body {
    background: var(--bg);
}

.staff-body main.container {
    flex: 0 0 auto;
    max-width: 900px;
    width: calc(100% - 32px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin: 16px auto;
    padding: 16px 20px;
}

/* --- PWA chrome: install card (menu sheet) + floating banners ---------- */
.kv-sheet-install {
    display: none;
    border: 1px solid #d9ecdf;
    background: linear-gradient(135deg, #ffffff, #f2faf4);
    border-radius: var(--radius);
    padding: 12px;
    margin: 12px 0 4px;
}

body.kv-can-install .kv-sheet-install {
    display: block;
}

.kv-sheet-install .form-actions {
    margin-top: 10px;
}

.pwa-banner {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 8px);
    z-index: 75;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16);
    padding: 12px;
    max-width: 480px;
    margin: 0 auto;
}

.pwa-banner-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

@media (min-width: 768px) {
    .pwa-banner {
        bottom: 16px;
    }
}

/* Minimal one-line footer for app pages (desktop); hidden on phones. */
.site-footer-minimal {
    border-top: none;
    background: none;
}

.site-footer-minimal .site-footer-inner {
    justify-content: center;
    gap: 0.75rem;
    font-size: 13px;
    color: var(--meta);
}

/* ==========================================================================
   MOBILE (<768px) — professional responsiveness. Desktop keeps the top nav
   and popup dock untouched; everything below is additive and CSS-only.
   ========================================================================== */

/* Mobile-only chrome stays hidden on desktop. */
.kv-tabbar,
.kv-sheet,
.mobile-page-title,
.mobile-me,
.dm-back {
    display: none;
}

@media (max-width: 767px) {
    /* --- Global guards: nothing may scroll the page sideways ----------- */
    html, body {
        overflow-x: hidden;
    }

    img, video, svg, iframe {
        max-width: 100%;
    }

    code {
        word-break: break-all;
    }

    /* 16px minimum side padding everywhere; the footer (in flow, below)
       provides the tab-bar clearance, so no oversized bottom padding here. */
    .container {
        padding: 12px 16px 24px;
    }

    /* Forms: 16px inputs (no iOS zoom), labels above, full-width submits. */
    input, select, textarea {
        font-size: 16px;
        width: 100%;
        box-sizing: border-box;
    }

    .field {
        display: block;
    }

    .field span {
        display: block;
        margin-bottom: 4px;
    }

    form.stack button[type="submit"],
    .stack > form > button[type="submit"],
    .claim-relationship button[type="submit"],
    .call-actions button {
        width: 100%;
    }

    /* Touch standards: 44px targets, visible press feedback. */
    button, .button, a.button, .roster-row, .kv-tab, .bell-list a,
    .kv-sheet-links a, .inbox-row, .kebab, .icon-button {
        min-height: 44px;
    }

    /* Form action rows stack: full-width buttons, primary on top. */
    .form-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .form-actions button,
    .form-actions .btn,
    .form-actions .button,
    .form-actions a.button {
        width: 100%;
    }

    button:active, .button:active, a:active, .roster-row:active {
        opacity: 0.7;
    }

    .chat-slideover-body, .kv-sheet, .tree-viewport, .dm-messages {
        -webkit-overflow-scrolling: touch;
    }

    /* --- Top bar: back arrow (sub-pages), title, avatar ------------------ */
    .top-nav {
        position: sticky;
        top: 0;
        z-index: 40;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    /* Sub-pages swap the logo for a back arrow; the title carries identity. */
    body.is-subpage .nav-back {
        display: inline-flex;
    }

    body.is-subpage.logged-in .top-nav .brand-lockup {
        display: none;
    }

    .top-nav .nav-links {
        display: none;
    }

    /* Logged-out pages have no tab bar — keep the Log in link visible. */
    .top-nav-public .nav-links {
        display: flex;
        gap: 0.85rem;
    }

    /* --- One-screen landing on phones ----------------------------------
       The vine is too busy as a hero at this size: it becomes a large,
       low-opacity WATERMARK behind the content (bottom/right, clipped,
       non-interactive). Foreground: headline, support line, CTAs and the
       feature list in one compact column. */
    body.logged-out .container {
        padding: 0.75rem 1rem;
    }

    .landing {
        position: relative;
        overflow: hidden;
        gap: 0.75rem;
    }

    .landing-copy,
    .landing-features {
        position: relative;
        z-index: 1;
    }

    .landing-hero {
        position: absolute;
        right: -22%;
        bottom: -4%;
        width: 125%;
        max-width: none;
        max-height: none;
        height: auto;
        margin: 0;
        opacity: 0.08;
        pointer-events: none;
        z-index: 0;
    }

    .landing-hero-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        text-align: center;
    }

    .landing-headline {
        font-size: 1.3rem;
    }

    .landing-tagline {
        font-size: 0.92rem;
        margin-bottom: 0.85rem;
    }

    .landing-actions {
        justify-content: center;
    }

    .landing-cta {
        padding: 0.6rem 1.5rem;
        font-size: 1rem;
    }

    .landing-features {
        grid-template-columns: 1fr;
        gap: 8px;
        padding-top: 8px;
    }

    /* Compact single-column rows: icon left, label beside it. */
    .landing-features li {
        flex-direction: row;
        justify-content: center;
        text-align: left;
        gap: 10px;
        padding: 10px 12px;
        font-size: 14px;
    }

    /* --- Footer (Facebook concept): app pages show NO footer on phones —
       the tab bar is the navigation. The full footer exists only on the
       landing page (in flow, never fixed) and inside the menu sheet. */
    .site-footer-minimal {
        display: none;
    }

    .site-footer-inner {
        flex-direction: column;
        justify-content: center;
        gap: 0.35rem;
        padding: 0.75rem 16px;
        text-align: center;
    }

    .site-footer-links {
        justify-content: center;
        gap: 0.75rem 1rem;
    }

    .site-footer-copy {
        margin-left: 0;
    }

    .top-nav .brand-logo, .top-nav svg {
        max-width: 96px;
        height: auto;
    }

    .mobile-page-title {
        display: block;
        flex: 1;
        min-width: 0;
        text-align: center;
        font-weight: 600;
        font-size: 17px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-me {
        display: block;
        line-height: 0;
    }

    /* --- Bottom tab bar (safe-area aware) -------------------------------- */
    .kv-tabbar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 80;
        background: #ffffff;
        border-top: 1px solid #e2e2e2;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .kv-tab {
        position: relative;
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 8px 0 6px;
        border: none;
        background: none;
        color: var(--ink);
        text-decoration: none;
        font: inherit;
        cursor: pointer;
    }

    .kv-tab-icon { font-size: 1.25rem; line-height: 1; }

    .kv-tab-label { font-size: 0.65rem; }

    .kv-tab-badge .badge-unread {
        position: absolute;
        top: 4px;
        right: calc(50% - 22px);
    }

    /* --- Slide-up sheets (menu, notifications) --------------------------- */
    .kv-sheet {
        display: block;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 85;
        background: #ffffff;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.2);
        max-height: 75dvh;
        overflow-y: auto;
        padding: 4px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    }

    .kv-sheet-grabber {
        width: 44px;
        height: 5px;
        border-radius: 3px;
        background: #d5d5d5;
        margin: 8px auto 12px;
    }

    .kv-sheet-links a,
    .kv-sheet-links .link-button {
        display: flex;
        align-items: center;
        padding: 12px 4px;
        border-bottom: 1px solid #f0f0f0;
        color: inherit;
        text-decoration: none;
        font-size: 1rem;
        width: 100%;
        text-align: left;
    }

    /* The menu sheet carries the small footer links + © on mobile. */
    .kv-sheet-footer {
        padding: 14px 4px calc(4px + env(safe-area-inset-bottom, 0px));
        font-size: 13px;
        color: var(--meta);
        text-align: center;
    }

    .kv-sheet-footer a {
        color: var(--meta);
        text-decoration: none;
        margin: 0 6px;
    }

    /* Notifications sheet: the bell partial renders inline, always open. */
    .kv-notif-sheet .bell-button { display: none; }
    .kv-notif-sheet .bell-dropdown { display: block !important; position: static; box-shadow: none; width: 100%; }

    /* --- Chat: full-screen panel + full-screen conversation -------------- */
    .chat-slideover {
        width: 100vw;
        border-left: none;
    }

    .dm-dock {
        right: 0;
        left: 0;
        bottom: 0;
        z-index: 90;
    }

    .dm-strip { display: none; }              /* badges on the tab instead */
    .dm-popup.minimized { display: none; }    /* no minimized bars on mobile */

    .dm-popup {
        position: fixed;
        inset: 0;
        width: 100vw;
        border-radius: 0;
        border: none;
    }

    .dm-head {
        border-radius: 0;
        padding: 10px 12px;
        padding-top: calc(10px + env(safe-area-inset-top, 0px));
    }

    .dm-back {
        display: block;
        border: none;
        background: none;
        color: #ffffff;
        font-size: 1.6rem;
        line-height: 1;
        padding: 0 10px 4px 2px;
        cursor: pointer;
    }

    .dm-body {
        height: auto;
        flex: 1;
    }

    .dm-composer {
        padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    }

    /* --- Tree: full-viewport canvas minus the bars ------------------------ */
    .tree-viewport svg {
        height: calc(100dvh - 220px) !important;
    }

    /* --- Tables: stacked ledger cards; everything else scrolls contained. */
    .table {
        display: block;
        overflow-x: auto;
        max-width: 100%;
        -webkit-overflow-scrolling: touch;
        /* fade hint on the trailing edge */
        background:
            linear-gradient(to left, rgba(255,255,255,0), #ffffff 24px) left/24px 100% no-repeat local,
            linear-gradient(to left, #ffffff 0, rgba(255,255,255,0) 24px) right/24px 100% no-repeat local,
            radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.18), transparent) right/14px 100% no-repeat scroll;
    }

    .ledger-table, .ledger-table tbody, .ledger-table tr, .ledger-table td {
        display: block;
        width: 100%;
        background: none;
    }

    .ledger-table thead { display: none; }

    .ledger-table tr {
        border: 1px solid #e5e5e5;
        border-radius: 10px;
        margin-bottom: 10px;
        padding: 8px 12px;
    }

    .ledger-table td {
        border: none;
        padding: 4px 0;
    }

    .ledger-table td[data-label]::before {
        content: attr(data-label) ': ';
        font-weight: 600;
        color: #666666;
    }

    /* --- List-row kebab menus open as bottom sheets ---------------------- */
    .row-menu-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 84;
        background: rgba(0, 0, 0, 0.35);
    }

    .row-menu {
        position: fixed;
        left: 0;
        right: 0;
        top: auto;
        bottom: 0;
        z-index: 85;
        min-width: 0;
        border: none;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.2);
        max-height: 75dvh;
        overflow-y: auto;
        padding: 4px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    }

    .row-menu-grabber {
        display: block;
    }

    .row-menu form {
        max-width: none;
    }

    /* --- Cards: 8px rhythm on phones -------------------------------------- */
    .card, .composer { margin-bottom: 8px; }

    .post-card, .derived-panel, .phrase-of-day { margin: 8px 0; }

    .cards { margin: 8px 0; }

    .media-grid { grid-template-columns: repeat(2, 1fr); }

    .albums-grid, .cards { grid-template-columns: repeat(2, 1fr) !important; gap: 8px; }

    /* Button groups that sit in a row must wrap, never overflow. */
    .rsvp-buttons, .tree-controls, .recorder-row { flex-wrap: wrap; }

    /* Tag-people picker becomes a bottom sheet. */
    .tag-options {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 85;
        background: #ffffff;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.2);
        max-height: 60dvh;
        overflow-y: auto;
        padding: 16px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    }

    .tag-option { display: flex; align-items: center; gap: 10px; min-height: 44px; }

    .tag-option input[type="checkbox"] { width: auto; }

    /* --- Layout stacking ---------------------------------------------------- */
    .chat-home, .chat-layout { grid-template-columns: 1fr; display: block; }

    .profile-tabs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

    /* Call screen already fills the viewport; keep controls above the tab bar. */
    .call-controls { padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }

    #kv-call-overlay { z-index: 120; }
}

.tree-badge-removedlink {
    fill: #777777;
    font-style: italic;
}

/* --- Icon system: currentColor, aligned to text ------------------------- */
.icon {
    vertical-align: -0.18em;
    flex-shrink: 0;
}

/* --- Monochrome call controls: black on white, inverted when off, red
       ONLY for ending a call (universal convention). ------------------- */
.call-controls button {
    background: #ffffff;
    color: #111111;
}

.call-controls button.off {
    background: #111111;
    color: #ffffff;
}

.call-controls .call-end {
    background: #c0392b;
    color: #ffffff;
}

.dm-call, .dm-close, .dm-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dm-composer button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* --- Twin start cards: identical size, icon top, one-line copy ---------- */
.start-cards {
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
    align-items: stretch;
}

.start-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
}

.start-card-icon {
    color: var(--green);
    margin-top: 0.25rem;
}

.start-card p {
    flex: 1;
    margin: 0;
    color: #555555;
}

.start-card .btn {
    align-self: center;
    width: 100%;
    justify-content: center;
}

/* --- Family sub-navigation: same header on every family page ------------ */
.family-header h1 {
    margin-bottom: 0.25rem;
}

.family-nav {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #e5e5e5;
    margin-bottom: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* fade hint when it scrolls (mobile) */
    background:
        linear-gradient(to left, rgba(255,255,255,0), #ffffff 24px) left/24px 100% no-repeat local,
        linear-gradient(to left, #ffffff 0, rgba(255,255,255,0) 24px) right/24px 100% no-repeat local,
        radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.14), transparent) right/12px 100% no-repeat scroll;
}

.family-nav a {
    padding: 0.55rem 0.9rem;
    text-decoration: none;
    color: var(--ink);
    font-weight: 500;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
}

.family-nav a.active {
    color: var(--green);
    border-bottom-color: var(--green);
    font-weight: 600;
}

.family-nav a:hover {
    color: var(--green);
}
