:root {
    /* --brand-accent is set per board (admin Settings) in the layout. */
    --brand-accent: #1b74e4;
    --bg: #f0f2f5;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --text: #1c1e21;
    --muted: #65676b;
    --border: #dadde1;
    --accent: var(--brand-accent);
    --accent-text: #ffffff;
    --danger: #c62828;
    --radius: 10px;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.12);
    color-scheme: light;
}

/* Dark palette: when the board's theme is Dark, or Auto and the visitor prefers dark. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #18191a;
        --surface: #242526;
        --surface-2: #3a3b3c;
        --text: #e4e6eb;
        --muted: #b0b3b8;
        --border: #3e4042;
        --accent: color-mix(in srgb, var(--brand-accent) 75%, white);
        --danger: #ef5350;
        --shadow: none;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #18191a;
    --surface: #242526;
    --surface-2: #3a3b3c;
    --text: #e4e6eb;
    --muted: #b0b3b8;
    --border: #3e4042;
    --accent: color-mix(in srgb, var(--brand-accent) 75%, white);
    --danger: #ef5350;
    --shadow: none;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; color: var(--muted); }
h4 { margin: .75rem 0 .25rem; font-size: .9rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

/* Layout */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: .45rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.brand { display: flex; align-items: center; gap: .75rem; color: var(--text); min-width: 0; flex-shrink: 1; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 56px; width: auto; max-width: 96px; object-fit: contain; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-name { font-weight: 800; font-size: 1.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-tagline { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { display: flex; gap: .2rem; margin-left: auto; }
.topbar-signin { margin-left: auto; flex: none; white-space: nowrap; }
.nav a { padding: .45rem .85rem; border-radius: 8px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

.account-menu > summary { display: flex; align-items: center; gap: .5rem; padding: .3rem .5rem; border-radius: 999px; }
.account-menu > summary:hover { background: var(--surface-2); }
.account-menu .avatar { width: 34px; height: 34px; font-size: .9rem; }
.account-name { font-weight: 600; white-space: nowrap; }
details.menu li[role="separator"] { border-top: 1px solid var(--border); margin: .3rem 0; }
details.menu .menu-button {
    display: block; width: 100%; text-align: left; background: none; font-weight: 400;
    padding: .5rem .7rem; border-radius: 6px; color: var(--text);
}
details.menu .menu-button:hover { background: var(--surface-2); }
details.menu form { margin: 0; }

.container { max-width: 760px; margin: 0 auto; padding: 1.25rem 1rem; }
.container.wide { max-width: 1200px; padding-left: 1.25rem; padding-right: 1.25rem; }
.narrow { max-width: 420px; margin: 2rem auto; }

/* Feed: posts at a readable width, with a sidebar when there's room. */
.feed-layout { display: grid; grid-template-columns: minmax(0, 680px) 320px; gap: 2rem; justify-content: center; align-items: start; }
.feed-sidebar { position: sticky; top: 88px; display: grid; gap: 1rem; }
.feed-sidebar h2 { margin: 0 0 .6rem; font-size: 1rem; color: var(--text); }
.sidebar-events { list-style: none; padding: 0; margin: 0; display: grid; gap: .7rem; }
.sidebar-events li { display: flex; gap: .7rem; align-items: center; }
.sidebar-events .date-badge { width: 44px; }
.sidebar-events .date-badge .day { font-size: 1.1rem; }
.sidebar-events a.event-title { font-size: .95rem; }
.sidebar-albums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sidebar-albums a { display: block; aspect-ratio: 1; overflow: hidden; border-radius: 6px; background: var(--surface-2); }
.sidebar-albums img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sidebar-more { display: inline-block; margin-top: .6rem; font-size: .85rem; }

@media (max-width: 1000px) {
    .feed-layout { grid-template-columns: minmax(0, 680px); }
    .feed-sidebar { display: none; }
}

@media (max-width: 760px) {
    .topbar-inner { flex-wrap: wrap; gap: .4rem .75rem; padding: .4rem .75rem; }
    .brand-logo { height: 44px; }
    .brand-tagline { display: none; }
    .brand-name { font-size: 1rem; }
    .brand { flex: 1 1 0; }
    .account-menu { margin-left: 0; }
    .account-name { display: none; }
    .nav { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
    .nav a { padding: .4rem .7rem; }
}

.page-head { display: flex; justify-content: space-between; align-items: center; }

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

.card.past { opacity: .7; }

/* Forms */
input, textarea, select {
    font: inherit;
    color: inherit;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .5rem .7rem;
    width: 100%;
}

textarea { resize: vertical; }

label { display: block; font-weight: 500; }
label > input, label > textarea { margin-top: .25rem; font-weight: normal; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: normal; }
label.check input { width: auto; }

.stack > * + * { margin-top: .9rem; }
.row { display: flex; gap: 1rem; align-items: end; flex-wrap: wrap; }
.row > label { flex: 1; min-width: 10rem; }
.actions { display: flex; justify-content: flex-end; align-items: center; gap: 1rem; }

button, .button {
    font: inherit;
    font-weight: 600;
    border: 0;
    border-radius: 8px;
    padding: .5rem 1rem;
    cursor: pointer;
    background: var(--surface-2);
    color: var(--text);
    display: inline-block;
}

button.primary, .button.primary { background: var(--accent); color: var(--accent-text); }
.button:hover { text-decoration: none; }
button.link { background: none; padding: 0; color: var(--accent); font-weight: 500; }
button.link:hover { text-decoration: underline; }
button.link.muted { color: var(--muted); }
button.danger { color: var(--danger); }

.errors {
    color: var(--danger);
    margin: .5rem 0 0;
    padding-left: 1.2rem;
}

.htmx-request button[type=submit], button.htmx-request { opacity: .6; pointer-events: none; }

/* Composer */
.composer textarea { border: 0; background: transparent; padding: .25rem 0; font-size: 1.05rem; }
.composer-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: .6rem;
    margin-top: .4rem;
}
.composer-actions .primary { margin-left: auto; }
.file { font-weight: 500; color: var(--muted); cursor: pointer; }
.file input { width: auto; padding: 0; border: 0; background: none; font-size: .85rem; }

/* Posts */
.post-head { display: flex; gap: .6rem; align-items: center; margin-bottom: .6rem; }
.author { font-weight: 600; }
.post-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: .5rem 0; }
.post-foot { border-top: 1px solid var(--border); margin-top: .6rem; padding-top: .5rem; }
.post-foot .link { color: var(--muted); font-weight: 500; }

.avatar {
    --hue: 210;
    flex: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    font-weight: 700;
    color: #fff;
    background: hsl(var(--hue) 55% 45%);
}

.gallery { display: grid; gap: 4px; margin: .5rem -1rem; }
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; max-height: 520px; }
.gallery-2, .gallery-4 { grid-template-columns: 1fr 1fr; }
.gallery-3 { grid-template-columns: 2fr 1fr; grid-auto-rows: 180px; }
.gallery-3 a:first-child { grid-row: span 2; }
.gallery-2 img, .gallery-4 img { aspect-ratio: 1; }

.more { display: block; text-align: center; padding: 1rem; color: var(--muted); }

/* Comments */
.comments { margin-top: .5rem; }
.comment { display: flex; gap: .5rem; margin: .5rem 0; }
.comment .avatar { width: 32px; height: 32px; font-size: .85rem; }
.bubble { background: var(--surface-2); border-radius: 14px; padding: .4rem .8rem; max-width: 100%; }
.comment-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.comment-form textarea { flex: 1 1 0; min-width: 0; }
.comment-form textarea { border-radius: 18px; min-height: 2.4rem; }

/* Events */
.event-panel {
    display: flex;
    gap: .9rem;
    align-items: center;
    color: inherit;
    padding: .25rem 0;
}
a.event-title { display: block; font-weight: 700; font-size: 1.1rem; color: var(--text); }
a.date-badge { color: var(--text); }
a.date-badge:hover { text-decoration: none; border-color: var(--accent); }
.event-location { overflow-wrap: anywhere; }
.post-body a, .comment-body a { overflow-wrap: anywhere; }
.date-badge {
    flex: none;
    width: 52px;
    border-radius: 8px;
    overflow: hidden;
    text-align: center;
    border: 1px solid var(--border);
    background: var(--surface);
}
.date-badge .month { display: block; background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; text-transform: uppercase; padding: 2px 0; }
.date-badge .day { display: block; font-size: 1.3rem; font-weight: 700; padding: 2px 0; }

.rsvp { margin: .6rem 0; }
.rsvp form { display: flex; gap: .4rem; margin-bottom: .3rem; }
.pill { border-radius: 999px; padding: .35rem .9rem; font-size: .9rem; }
.pill.selected { background: var(--accent); color: var(--accent-text); }

/* People */
.people { list-style: none; padding: 0; margin: 0; }
.people li { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; }
.people a.person { display: inline-flex; align-items: center; gap: .5rem; color: var(--text); }
.people a.person:hover { color: var(--accent); }
.people:not(.big) .avatar { width: 28px; height: 28px; font-size: .8rem; }
.people.big li { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.people.big li:last-child { border-bottom: 0; }
.tag { font-size: .7rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border-radius: 4px; padding: 1px 6px; margin-left: .3rem; vertical-align: middle; }

/* Tables */
.table { width: 100%; border-collapse: collapse; padding: 0; }
.table th, .table td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: 0; }
.table input.copy { font-family: ui-monospace, monospace; font-size: .8rem; }
.table form { margin: 0; }

/* Roles & admin */
.chip {
    --chip: #607d8b;
    display: inline-block;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.6;
    padding: 0 .55rem;
    border-radius: 999px;
    color: var(--chip);
    background: color-mix(in srgb, var(--chip) 14%, transparent);
    border: 1px solid color-mix(in srgb, var(--chip) 40%, transparent);
    margin: 0 .15rem;
    vertical-align: middle;
}

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.tile { display: flex; flex-direction: column; gap: .3rem; color: inherit; margin: 0; }
.tile:hover { text-decoration: none; border-color: var(--accent); }

.notice {
    background: color-mix(in srgb, var(--accent) 10%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
    border-radius: 8px;
    padding: .6rem .9rem;
}

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.checks { display: grid; gap: .45rem; }
fieldset.checks legend { font-weight: 600; margin-bottom: .4rem; }
label.check { align-items: flex-start; }
label.check input { margin-top: .25rem; flex: none; }

form.inline { display: inline; margin: 0; }
.nowrap { white-space: nowrap; }

.profile-head { display: flex; gap: 1rem; align-items: center; }
.profile-head h1 { margin: 0; }
.filters { align-items: end; }
label.color { flex: 0 0 auto; min-width: 0; }
label.color input { width: 3.5rem; height: 2.4rem; padding: .2rem; }
input.copy { font-family: ui-monospace, monospace; font-size: .85rem; }
button.danger:not(.link) { background: color-mix(in srgb, var(--danger) 15%, var(--surface-2)); color: var(--danger); }
button:disabled { opacity: .4; cursor: default; }

.audit { list-style: none; margin: 0; padding: 0; }
.audit li { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.audit li:last-child { border-bottom: 0; }

/* Profiles */
img.avatar { object-fit: cover; background: var(--surface-2); }
.avatar.large { width: 112px; height: 112px; font-size: 2.6rem; border: 4px solid var(--surface); }
a.author { color: var(--text); font-weight: 600; }

.profile { padding: 0; overflow: hidden; }
.profile .cover { display: block; width: 100%; aspect-ratio: 3 / 1; object-fit: cover; }
.cover.placeholder, .cover-preview.placeholder {
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 45%, var(--surface)), color-mix(in srgb, var(--accent) 15%, var(--surface)));
}
.cover.placeholder { aspect-ratio: 5 / 1; }
.profile-body { display: flex; align-items: flex-end; gap: 1rem; padding: 0 1rem; margin-top: -48px; flex-wrap: wrap; }
.profile-title { flex: 1; min-width: 12rem; padding-bottom: .3rem; }
.profile-title h1 { margin: 0; }
.profile-member-title { color: var(--muted); font-weight: 600; margin: .1rem 0 .3rem; }
.profile-actions { padding-bottom: .5rem; }
.profile .tabs { margin: .75rem 0 0; padding: 0 1rem; border-bottom: 0; border-top: 1px solid var(--border); }
.profile .tabs a { margin: -1px 0 0; border-bottom: 0; border-top: 2px solid transparent; }
.profile .tabs a.active { border-top-color: var(--accent); }
.profile-about .post-body { margin-bottom: .5rem; }
.profile-about .post-body > :first-child { margin-top: 0; }
.profile-about .facts { padding: 0; }
.facts { list-style: none; padding: .5rem 1rem 1rem; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }

.photos { display: grid; gap: 1rem; }
.photo-row { display: flex; gap: 1rem; align-items: center; }
.photo-row .stack > * + * { margin-top: .3rem; }
.cover-preview { width: 168px; aspect-ratio: 3 / 1; object-fit: cover; border-radius: 8px; flex: none; }
.file-button { cursor: pointer; }
.link-row input:first-child { flex: 0 0 9rem; }
.link-row input:last-child { flex: 1; }
.post-head a.author, .bubble a.author { display: block; }

/* Feed ordering & pins */
.sort-toggle { display: flex; align-items: center; gap: .4rem; margin: 0; }
.post.pinned { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.pin-label { color: var(--accent); font-weight: 600; margin: -.2rem 0 .4rem; }
.post-menu { margin: 0 0 0 auto; display: flex; gap: .6rem; align-items: baseline; }
.post-menu .link, .bubble .link { line-height: 1.4; }

[hidden] { display: none !important; }

/* Events: form, tabs, calendar */
.event-form fieldset.when { display: grid; gap: .6rem; }
.event-form legend { font-weight: 600; margin-bottom: .3rem; }
.event-form .options { gap: 1.5rem; }
.event-form .options label.check { flex: 0 0 auto; min-width: 0; }
select { appearance: auto; }

.tabs { display: flex; gap: .25rem; margin: 0 0 1rem; border-bottom: 1px solid var(--border); }
.tabs a { padding: .4rem .9rem; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }

.calendar { padding: .75rem; }
.calendar-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.calendar-head h2 { margin: 0; color: var(--text); font-size: 1.15rem; min-width: 10rem; text-align: center; }
.calendar-head .button { padding: .2rem .7rem; font-size: 1.1rem; }
.today-link { margin-left: auto; }

table.month { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.month th { font-size: .75rem; color: var(--muted); font-weight: 600; padding: .3rem 0; text-transform: uppercase; }
table.month td { vertical-align: top; height: 6.5rem; border: 1px solid var(--border); padding: .2rem; overflow: hidden; }
table.month td.outside { background: var(--surface-2); }
table.month td.outside .day-number { color: var(--muted); opacity: .6; }
table.month td.today .day-number { background: var(--accent); color: var(--accent-text); border-radius: 999px; width: 1.6rem; text-align: center; }
.day-number { font-size: .8rem; font-weight: 600; margin-bottom: .15rem; line-height: 1.6rem; padding-left: .2rem; }
.chip-event {
    display: block;
    font-size: .75rem;
    line-height: 1.35;
    padding: .05rem .3rem;
    margin-bottom: .15rem;
    border-radius: 4px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chip-event:hover { background: var(--surface-2); text-decoration: none; }
.chip-event.allday { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.chip-event .time { color: var(--muted); margin-right: .2rem; }
.rsvp-dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; margin-right: .25rem; vertical-align: middle; border: 1.5px solid #2e7d32; }
.rsvp-dot.going { background: #2e7d32; }
.rsvp-dot.maybe { background: transparent; }

.agenda { display: none; list-style: none; padding: 0; margin: 0; }
.agenda > li { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.agenda > li.today .agenda-date { color: var(--accent); }
.agenda-date { font-weight: 600; font-size: .9rem; }
.agenda ul { list-style: none; padding: 0; margin: .2rem 0 0; }
.agenda .time { color: var(--muted); display: inline-block; min-width: 4.5rem; font-size: .85rem; }

@media (max-width: 560px) {
    table.month { display: none; }
    .agenda { display: block; }
}

/* Branding */
.welcome { text-align: center; margin-bottom: 1.2rem; }
.welcome-logo { width: 96px; height: 96px; object-fit: contain; }
.welcome-name { font-size: 1.6rem; font-weight: 700; }
.welcome-about { white-space: pre-wrap; margin-top: .6rem; text-align: left; }
.logo-preview { width: 96px; height: 96px; object-fit: contain; background: var(--surface-2); border-radius: 8px; }
.wizard-steps { display: flex; gap: .5rem; list-style: none; padding: 0; margin: 0 0 1rem; }
.wizard-steps li { flex: 1; padding: .4rem; border-bottom: 3px solid var(--border); color: var(--muted); font-size: .9rem; }
.wizard-steps li.current { border-color: var(--accent); color: var(--text); font-weight: 600; }
.wizard-steps li.done { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
textarea.code { font-family: ui-monospace, monospace; font-size: .85rem; }
.tile .count { font-size: 1.4rem; font-weight: 700; color: var(--accent); }

/* Albums */
.album-card { margin: .4rem 0; }
.album-title { display: block; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.album-preview { display: grid; gap: 4px; margin: .6rem -1rem 0; grid-template-columns: repeat(var(--cols, 3), 1fr); }
.album-preview-1 { --cols: 1; }
.album-preview-2 { --cols: 2; }
.album-preview-4 { --cols: 2; }
.album-preview-5 { grid-template-columns: repeat(6, 1fr); }
.album-preview-5 .album-thumb:nth-child(-n+2) { grid-column: span 3; }
.album-preview-5 .album-thumb:nth-child(n+3) { grid-column: span 2; }
.album-thumb { position: relative; display: block; aspect-ratio: 1; overflow: hidden; background: var(--surface-2); }
.album-preview-1 .album-thumb { aspect-ratio: 16 / 9; }
.album-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-more {
    position: absolute; inset: 0; display: grid; place-items: center;
    background: rgb(0 0 0 / .45); color: #fff; font-size: 1.6rem; font-weight: 700;
}

.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.album-tile { display: flex; flex-direction: column; gap: .2rem; padding: 0 0 .6rem; overflow: hidden; color: var(--text); margin: 0; }
.album-tile:hover { text-decoration: none; border-color: var(--accent); }
.album-tile img, .album-empty { width: 100%; aspect-ratio: 1; object-fit: cover; display: grid; place-items: center; font-size: 2.5rem; background: var(--surface-2); }
.album-tile-title, .album-tile .muted { padding: 0 .7rem; }
.album-tile-title { font-weight: 600; }
.album-head h1 { margin-bottom: .2rem; }

.uploader { padding: .75rem; }
.dropzone {
    display: flex; flex-direction: column; align-items: center; gap: .2rem; cursor: pointer;
    padding: 1.2rem; border: 2px dashed var(--border); border-radius: var(--radius); text-align: center;
}
.dropzone.dragging, .dropzone:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.dropzone { position: relative; }
/* The real file input covers the whole drop zone (so clicking anywhere opens the picker) but is invisible. */
.dropzone input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.dropzone .button { pointer-events: none; margin-top: .3rem; }
.upload-status { margin-top: .6rem; }
.progress { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-bottom: .3rem; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .15s; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .8rem; margin-top: 1rem; }
.photo-tile { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.photo-tile.cover { border-color: var(--accent); }
.photo-tile > a img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; }
.photo-tile figcaption, .caption-form { padding: .45rem .6rem; display: flex; flex-direction: column; gap: .2rem; }
.photo-tile .caption { overflow-wrap: anywhere; }
.tile-actions { display: flex; flex-wrap: wrap; gap: .2rem .7rem; }
.tile-actions .link { font-size: inherit; }
.event-photos { margin-top: 1.5rem; }
.event-photos h2 { margin: 0; color: var(--text); }

/* Full-screen viewer */
html.viewer-open { overflow: hidden; }
.viewer { position: fixed; inset: 0; z-index: 100; background: rgb(0 0 0 / .92); display: grid; place-items: center; }
.viewer img { max-width: 94vw; max-height: 82vh; object-fit: contain; }
.viewer-caption { position: absolute; bottom: 2.6rem; left: 1rem; right: 1rem; text-align: center; color: #eee; }
.viewer-counter { position: absolute; bottom: 1rem; left: 0; right: 0; text-align: center; color: #aaa; font-size: .85rem; }
.viewer button {
    position: absolute; background: rgb(255 255 255 / .12); color: #fff; font-size: 2rem; line-height: 1;
    width: 3rem; height: 3rem; border-radius: 50%; padding: 0;
}
.viewer button:hover { background: rgb(255 255 255 / .25); }
.viewer-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.viewer-next { right: 1rem; top: 50%; transform: translateY(-50%); }
.viewer-close { right: 1rem; top: 1rem; }
.viewer.single .viewer-prev, .viewer.single .viewer-next { display: none; }

/* New menu and composer */
.feed-head { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .8rem; }
.feed-head .new-menu { margin-left: auto; }
details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; user-select: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu > ul {
    position: absolute; right: 0; top: calc(100% + .3rem); z-index: 20; min-width: 12rem;
    list-style: none; margin: 0; padding: .3rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 6px 20px rgb(0 0 0 / .18);
}
details.menu > ul a { display: block; padding: .5rem .7rem; border-radius: 6px; color: var(--text); }
details.menu > ul a:hover, details.menu > ul a:focus-visible { background: var(--surface-2); text-decoration: none; }
.composer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem; }
.file-pick { display: block; margin-bottom: .5rem; }
.file-pick input { padding: .4rem; }
.composer textarea { border: 1px solid var(--border); background: var(--surface-2); padding: .5rem .7rem; font-size: 1rem; }
.composer-actions { justify-content: flex-end; }

/* Event types */
.date-badge .month { background: var(--badge, var(--danger)); }
.type-filter { display: flex; flex-wrap: wrap; gap: .4rem; margin: -.4rem 0 1rem; }
.type-filter .pill { display: inline-flex; align-items: center; gap: .35rem; color: var(--text); background: var(--surface-2); }
.type-filter .pill:hover { text-decoration: none; }
.type-filter .pill.selected { background: var(--accent); color: var(--accent-text); }
.type-dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--type); }
.chip-event { border-left: 3px solid var(--type, transparent); }
.chip-event.allday { background: color-mix(in srgb, var(--type, var(--accent)) 20%, transparent); }
.event-panel .chip { margin: 0 0 .15rem; }
.type-row { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.type-edit { flex: 1; align-items: center; margin: 0; }
.type-edit .grow { flex: 1; }
.type-edit.add { border-top: 1px solid var(--border); padding-top: .9rem; }
.type-actions { display: flex; gap: .6rem; align-items: center; }

/* Event images */
.event-image { margin: .5rem -1rem .6rem; background: var(--surface-2); }
.event-image img { display: block; width: 100%; height: auto; max-height: 560px; object-fit: contain; }
.event-panel > div:not(.date-badge) { flex: 1; min-width: 0; }
.event-thumb { flex: none; width: 96px; height: 72px; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.event-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.event-image-field { display: grid; gap: .4rem; }
.event-image-field legend { font-weight: 600; margin-bottom: .2rem; }
.current-image img { width: 120px; height: 80px; object-fit: cover; border-radius: 8px; }
@media (max-width: 560px) { .event-thumb { width: 64px; height: 64px; } }
.post-menu .link { color: var(--muted); font-weight: 500; }
.post-menu .link:hover { color: var(--accent); }

/* The Ends field carries a duration note underneath; align the When row's fields by their tops
   so that note hangs below instead of pushing the Ends box up. */
.event-form .when .row:first-of-type { align-items: start; }
.event-form [data-summary]:empty { display: none; }
.event-form [data-summary] { margin: 0; }
.member-title { color: var(--muted); font-weight: 600; }

/* Member directory */
.member-search { margin: 0 0 1rem; position: sticky; top: 80px; z-index: 5; }
.member-search input { font-size: 1.05rem; padding: .65rem .9rem; background: var(--surface); box-shadow: var(--shadow); }
.member-list { list-style: none; padding: .3rem 0; margin: 0; }
.member-list li + li { border-top: 1px solid var(--border); }
.member-row { display: flex; align-items: center; gap: .8rem; padding: .6rem 1rem; color: var(--text); }
.member-row:hover { background: var(--surface-2); text-decoration: none; }
.member-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.member-main .author, .member-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .2rem; }
.member-joined { white-space: nowrap; min-width: 6.5rem; text-align: right; }
@media (max-width: 560px) {
    .member-joined { display: none; }
    .member-search { top: 110px; }
}

/* Showing what roles grant */
.role-permissions.everything { font-weight: 600; }
.role-option { display: flex; flex-direction: column; gap: .15rem; align-items: flex-start; }
.effective-group { display: grid; grid-template-columns: 9rem 1fr; gap: .8rem; padding: .25rem 0; }
@media (max-width: 560px) { .effective-group { grid-template-columns: 1fr; gap: 0; } }
/* Headings at the top of a card (or of a form filling one) don't need the section spacing. */
.card > h2:first-child, .card > form:first-child > h2:first-child, .card > fieldset > h2:first-child { margin-top: 0; }

/* Content roles */
.audience-badge {
    display: inline-block; font-size: .75rem; font-weight: 600; padding: 0 .5rem; border-radius: 999px; margin-left: .3rem;
    color: var(--text); background: color-mix(in srgb, var(--accent) 15%, var(--surface-2)); vertical-align: middle;
}
.audience-select { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.audience-select select { width: auto; }
.composer-actions .audience-select { margin-left: auto; }
.composer-actions .audience-select + .primary { margin-left: 0; }
.role-summary { display: inline-flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.role-summary .flag { font-size: .7rem; padding: 0 .4rem; border-radius: 4px; background: var(--surface-2); color: var(--muted); }

/* Member since */
.member-since-edit { gap: .4rem; align-items: center; flex-wrap: wrap; }
.member-since-edit select, .member-since-edit input { width: auto; }
.member-since-edit input[type=number] { width: 6rem; }

/* Documents */
.documents-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.documents-main > h2 { margin: 1rem 0 .6rem; }
.documents-search input[type=search] { flex: 1; }
.doc-folders { padding: .6rem; }
.folder-nav { display: grid; gap: 2px; }
.folder-nav a { display: flex; justify-content: space-between; gap: .5rem; padding: .35rem .6rem; border-radius: 6px; color: var(--text); }
.folder-nav a:hover { background: var(--surface-2); text-decoration: none; }
.folder-nav a.active { background: color-mix(in srgb, var(--accent) 15%, var(--surface-2)); font-weight: 600; }
.folder-manage { margin-top: .8rem; border-top: 1px solid var(--border); padding-top: .6rem; }
.folder-manage summary { cursor: pointer; }
.folder-edit-list { list-style: none; padding: 0; margin: .6rem 0; display: grid; gap: .6rem; }
.folder-edit-list li { display: grid; gap: .3rem; }
.folder-manage .row { gap: .3rem; align-items: center; }
.folder-manage input { flex: 1; min-width: 0; }
.document-list { list-style: none; margin: 0; padding: 0; }
.document-list li { display: flex; align-items: center; gap: .8rem; padding: .7rem 1rem; border-top: 1px solid var(--border); }
.document-list li:first-child { border-top: none; }
.doc-main { flex: 1; min-width: 0; }
.doc-title { font-weight: 600; }
.doc-flags { display: flex; gap: .3rem; flex-wrap: wrap; }
.doc-icon {
    flex: none; display: inline-grid; place-items: center; width: 44px; height: 52px; border-radius: 6px;
    font-size: .65rem; font-weight: 700; letter-spacing: .03em; color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); border: 1px solid var(--border);
}
.doc-icon.large { width: 60px; height: 72px; font-size: .8rem; }
.document-head { display: flex; gap: 1rem; align-items: flex-start; }
.document-head h1 { margin: 0 0 .2rem; }
.public-badge {
    display: inline-block; font-size: .75rem; font-weight: 600; padding: 0 .5rem; border-radius: 999px;
    background: color-mix(in srgb, #2e7d32 18%, var(--surface-2)); color: var(--text);
}
.button.small, button.small:not(.link) { padding: .25rem .7rem; font-size: .85rem; }
@media (max-width: 760px) {
    .documents-layout { grid-template-columns: 1fr; }
    .document-list li { flex-wrap: wrap; }
}

/* Public calendar and home page */
.public-event-image { width: 100%; max-height: 420px; object-fit: cover; border-radius: 8px; display: block; }
.public-event h1.event-title { font-size: 1.5rem; margin: .2rem 0; }
.home { max-width: 960px; margin: 0 auto; display: grid; gap: 1.2rem; }
.home-content { display: grid; gap: 1rem; }
.home-content > h1, .home-content > h2, .home-content > h3 { margin: .6rem 0 0; }
.home-content > p, .home-content > ul, .home-content > ol, .home-content > blockquote { margin: 0; line-height: 1.6; }
.home-content img { max-width: 100%; border-radius: 8px; }
.home-content blockquote { border-left: 3px solid var(--accent); padding-left: 1rem; color: var(--muted); }
.home-content .document-list li { padding: .6rem 0; }
.home-documents h3 { margin: 1rem 0 .2rem; font-size: 1rem; }
.markdown-preview { border: 1px dashed var(--border); border-radius: var(--radius); padding: 1rem; background: var(--bg); }
.home-editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.2rem; align-items: start; }
.home-editor textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem; }
.cheatsheet { border-collapse: collapse; width: 100%; }
.cheatsheet td { padding: .25rem .3rem; vertical-align: top; border-top: 1px solid var(--border); }
.cheatsheet tr:first-child td { border-top: none; }
.home-images { list-style: none; padding: 0; margin: 0; display: grid; gap: .6rem; }
.home-images li { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: .5rem; align-items: center; }
.home-images img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; }
.widget-placeholder { border: 2px dashed var(--border); border-radius: var(--radius); padding: 1.2rem; text-align: center; color: var(--muted); }
@media (max-width: 1000px) { .home-editor { grid-template-columns: 1fr; } }
.doc-flags .audience-badge { margin-left: 0; }
.admin-version { margin-top: 2rem; text-align: center; }

/* Formatted text (MiniMarkdown) in posts, comments, descriptions and bios */
.md { white-space: normal; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .6em; }
.md ul, .md ol { margin: 0 0 .6em; padding-left: 1.4em; }
.md li { margin: .1em 0; }
.md blockquote { margin: 0 0 .6em; padding: .1em 0 .1em .8em; border-left: 3px solid var(--border); color: var(--muted); }
.md blockquote p { margin: 0; }
.md code, .home-content code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; padding: .05em .3em; border-radius: 4px; background: var(--surface-2); }
.md del, .home-content del { color: var(--muted); }
.md .md-heading { font-size: 1.05rem; font-weight: 650; margin: .8em 0 .3em; line-height: 1.3; }
.md > .md-heading:first-child { margin-top: 0; }

/* Editing posts and comments */
.edit-form { gap: .5rem; margin: .5rem 0; }
.edit-form textarea { width: 100%; }
.comment .edit-form { flex: 1; margin: 0; }
.edited { white-space: nowrap; }

/* Add member: the details to pass on */
.credentials { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .5rem 1rem; align-items: center; margin: 0; }
.credentials dt { font-weight: 600; }
.credentials dd { margin: 0; }

/* Photo editor (js/photo-editor.js) */
.photo-editor { width: min(560px, calc(100vw - 2rem)); border: 0; border-radius: var(--radius); padding: 1.2rem; background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgb(0 0 0 / .35); }
.photo-editor::backdrop { background: rgb(0 0 0 / .55); }
.photo-editor h2 { margin: 0 0 .2rem; }
.photo-editor-frame { position: relative; width: 100%; margin: .8rem 0; border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.photo-editor-view { display: block; width: 100%; cursor: grab; touch-action: none; }
.photo-editor-view:active { cursor: grabbing; }
.photo-editor-view:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
/* The profile picture shows as a circle: dim the corners outside it. */
.photo-editor-frame.round::after {
    content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
    box-shadow: 0 0 0 999px rgb(0 0 0 / .45); outline: 2px solid rgb(255 255 255 / .8); outline-offset: -2px;
}
.photo-editor-controls { display: flex; align-items: center; gap: .6rem; }
.photo-editor-zoom { flex: 1; display: flex; align-items: center; gap: .5rem; }
.photo-editor-zoom input { flex: 1; width: auto; padding: 0; }
.photo-editor-previews { display: flex; align-items: center; gap: .8rem; margin: .8rem 0; }
.photo-editor-preview { background: var(--surface-2); }
.photo-editor-preview.round { border-radius: 50%; width: 96px; height: 96px; }
.photo-editor-preview.round.small { width: 40px; height: 40px; }
.photo-editor-preview.banner { border-radius: 6px; width: 300px; max-width: 100%; height: auto; aspect-ratio: 3; }
.photo-editor-status { margin: .3rem 0; }
.photo-editor-controls button.small { font-size: 1.15rem; line-height: 1; padding: .3rem .6rem; }

/* Notifications */
.bell { position: relative; display: inline-grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%; color: var(--muted); font-size: 1.15rem; }
.bell:hover { background: var(--surface-2); text-decoration: none; }
.bell-count {
    position: absolute; top: -.1rem; right: -.2rem; min-width: 1.1rem; height: 1.1rem; padding: 0 .3rem; border-radius: 999px;
    background: var(--danger); color: #fff; font-size: .7rem; font-weight: 700; line-height: 1.1rem; text-align: center;
}
.notifications-head { justify-content: space-between; align-items: baseline; margin-bottom: .5rem; }
.notifications-head h2 { margin: 0; }
.notification-section + .notification-section { margin-top: 1.5rem; }
.notification-list { list-style: none; margin: 0; padding: 0; }
.notification-list li { display: flex; align-items: flex-start; gap: .7rem; padding: .8rem 1rem; border-top: 1px solid var(--border); }
.notification-list li:first-child { border-top: none; }
.notification-list li.unread { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.notification-list li.unread .notification-text { font-weight: 600; }
.notification-icon { width: 1.4rem; text-align: center; font-weight: 700; color: var(--accent); padding-top: .4rem; }
.notification-main { flex: 1; min-width: 0; display: grid; gap: .1rem; }
.notification-text { color: var(--text); }
.notification-excerpt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notification-list form { align-self: center; }
.muted-posts { margin-top: 2rem; }
.new-pill { display: inline-block; font-size: .7rem; font-weight: 700; padding: 0 .45rem; border-radius: 999px; background: var(--accent); color: var(--accent-text); vertical-align: middle; }
.new-count { color: var(--accent); font-weight: 600; font-size: .9rem; }
.comment.is-new .bubble { box-shadow: inset 3px 0 0 var(--accent); }

/* @mentions */
a.mention { font-weight: 600; }
.mention-list {
    z-index: 50; list-style: none; margin: 0; padding: .3rem; border-radius: 8px; background: var(--surface);
    border: 1px solid var(--border); box-shadow: 0 6px 20px rgb(0 0 0 / .18); max-width: 320px;
}
.mention-list li { display: flex; align-items: center; gap: .5rem; padding: .35rem .5rem; border-radius: 6px; cursor: pointer; }
.mention-list li[aria-selected="true"], .mention-list li:hover { background: color-mix(in srgb, var(--accent) 14%, var(--surface-2)); }
.mention-list .avatar { width: 24px; height: 24px; font-size: .7rem; }

/* iPhone Safari zooms into any field whose text is under 16px when it's tapped. On touch screens,
   keep form fields at 16px so the page stays put (pinch-to-zoom still works). */
@media (hover: none) and (pointer: coarse) {
    input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), textarea, select {
        font-size: 16px !important;
    }
}

/* Warning before sharing a document with people who can't open it */
.share-warning {
    flex-basis: 100%; display: grid; gap: .4rem; margin-top: .5rem; padding: .7rem .9rem; border-radius: 8px;
    background: color-mix(in srgb, #f9a825 18%, var(--surface)); border: 1px solid color-mix(in srgb, #f9a825 45%, var(--border));
}
.share-warning ul { margin: 0; padding-left: 1.2rem; }
.share-warning .row { align-items: center; gap: .6rem; }

/* Cancelled events: still listed, plainly marked. */
.cancelled-header {
    background: var(--danger);
    color: #fff;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    text-align: center;
    padding: .5rem .8rem;
    border-radius: 8px;
    margin: .5rem 0 .7rem;
}
.card > .cancelled-header:first-child { margin-top: 0; }
.public-event .cancelled-header { font-size: 1.1rem; margin-bottom: 0; }
.cancelled .event-title, .chip-event.cancelled, .agenda .cancelled { text-decoration: line-through; }
.cancelled .date-badge, .chip-event.cancelled, .agenda .cancelled { opacity: .55; }
.cancelled-note { margin: .2rem 0 .3rem; }
.cancelled-banner { color: var(--danger); font-weight: 700; }
