/* Halloa design system - calm, warm, accessible. System fonts only (no third-party requests).
   Layout: desktop sidebar (>= 1024px), icon rail (720-1023px), bottom tab bar on phones (< 720px). */
:root {
  --bg: #f7f4ef;
  --surface: #ffffff;
  --surface-2: #f1ece4;
  --surface-3: #e9e2d7;
  --text: #22201c;
  --muted: #6c655b;
  --border: #e5ddd1;
  --accent: #b84e29;
  --accent-hover: #9e3f1d;
  --accent-ink: #ffffff;
  --accent-soft: #f7e4d9;
  --ok-bg: #e6f2ea; --ok-ink: #1f5a36;
  --err-bg: #fbe9e7; --err-ink: #8a1f11;
  --danger: #b42318;
  --focus: #1d5fd1;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(40 30 20 / .05), 0 8px 24px rgb(40 30 20 / .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidenav-w: 236px;
  --tabbar-h: 62px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161412; --surface: #201d1a; --surface-2: #2a2622; --surface-3: #332e29; --text: #f1ece6; --muted: #a79f94;
    --border: #38322c; --accent: #f08a5d; --accent-hover: #f6a27d; --accent-ink: #1b120d; --accent-soft: #3a261c;
    --ok-bg: #18301f; --ok-ink: #a6dcb7; --err-bg: #3a1a15; --err-ink: #f5b5aa; --danger: #f07a6a; --focus: #7fb0ff;
    --shadow: 0 1px 2px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 var(--font); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; }
h1 { font-size: clamp(1.45rem, 1.2rem + 1vw, 1.9rem); line-height: 1.2; margin: .1em 0 .6em; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; margin: 1.5em 0 .6em; }
.h2 { font-size: 1.3rem; margin: .3em 0 .8em; }
.h3 { font-size: 1.05rem; margin: 1.4em 0 .6em; }
.card .h3:first-child, .card h2:first-child { margin-top: 0; }
.h4 { font-size: .95rem; margin: 1.2em 0 .4em; }
code { background: var(--surface-2); padding: .05em .35em; border-radius: 5px; font-size: .9em; }
blockquote { margin: .6em 0; padding: .6em .9em; border-left: 3px solid var(--border); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; white-space: pre-wrap; }
.icon { width: 22px; height: 22px; flex: none; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- App shell ---------- */
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 750; font-size: 1.2rem; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.brand-mark { width: 26px; height: 26px; color: var(--accent); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar-actions { display: flex; gap: 4px; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: var(--muted); }
.icon-btn:hover, .icon-btn.active { background: var(--surface-2); color: var(--text); }
.dot-count { position: absolute; top: 3px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--surface-3); color: var(--text); font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center; border: 1px solid var(--border); }
.count { margin-left: auto; min-width: 1.6em; padding: 0 .45em; border-radius: 999px; background: var(--surface-3); color: var(--text); font-size: .76rem; font-weight: 700; text-align: center; }

.shell { display: grid; grid-template-columns: var(--sidenav-w) minmax(0, 1fr); min-height: 100vh; }
.sidenav { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 8px; padding: 18px 12px; border-right: 1px solid var(--border); background: var(--bg); overflow-y: auto; }
.sidenav-brand { padding: 4px 10px 14px; }
.sidenav nav { display: grid; gap: 2px; }
.sidenav-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }
.sidenav a:not(.brand) { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--muted); text-decoration: none; font-weight: 550; }
.sidenav a:not(.brand):hover { background: var(--surface-2); color: var(--text); }
.sidenav a.active { background: var(--accent-soft); color: var(--accent); }
.page { width: 100%; max-width: 1060px; padding: 26px 28px 40px; margin: 0 auto; min-width: 0; }
.signed-in .topbar { display: none; }
.tabbar { display: none; }

/* Public (signed-out) header */
.topbar-public { display: flex; }
.public-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.public-nav > a:not(.btn) { color: var(--muted); text-decoration: none; padding: 7px 10px; border-radius: 10px; font-weight: 550; }
.public-nav > a:not(.btn):hover { background: var(--surface-2); color: var(--text); }
.shell-public { display: block; min-height: auto; }
.lang-menu { position: relative; }
.lang-menu summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted); padding: 7px 10px; border-radius: 10px; font-weight: 550; }
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary:hover { background: var(--surface-2); color: var(--text); }
.lang-list { position: absolute; right: 0; top: calc(100% + 4px); min-width: 150px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 6px; z-index: 30; display: grid; }
.lang-list a { padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.lang-list a:hover, .lang-list a[aria-current] { background: var(--accent-soft); color: var(--accent); }

/* Tablet: icon rail */
@media (max-width: 1023px) {
  .shell { grid-template-columns: 76px minmax(0, 1fr); }
  .sidenav { padding: 14px 10px; align-items: center; }
  .sidenav a:not(.brand) { justify-content: center; padding: 11px; position: relative; }
  .sidenav span:not(.count), .sidenav-brand span { display: none; }
  .sidenav-brand { padding: 4px 0 12px; }
  .sidenav .count { position: absolute; top: 2px; right: 0; font-size: .66rem; }
  .page { padding: 22px 20px 36px; }
}
/* Phone: top bar + bottom tab bar */
@media (max-width: 719px) {
  .signed-in .topbar { display: flex; }
  .shell { display: block; }
  .sidenav { display: none; }
  .page { padding: 16px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); }
  .tabbar { position: fixed; inset: auto 0 0 0; z-index: 25; display: grid; grid-template-columns: repeat(5, 1fr); height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--border); }
  .tabbar a { position: relative; display: grid; place-items: center; align-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 600; }
  .tabbar a.active { color: var(--accent); }
  .tabbar .dot-count { top: 6px; right: calc(50% - 26px); }
  .public-nav { gap: 2px; }
  .public-nav > a:first-child { display: none; }
}

section + section { margin-top: 8px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.col-side { position: sticky; top: 24px; }
@media (max-width: 1180px) { .layout { grid-template-columns: 1fr; } .col-side { position: static; } }
.narrow { max-width: 640px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-weight: 550; margin-bottom: 10px; }
.back-link .icon { width: 18px; height: 18px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.empty { text-align: center; padding: 32px 20px; }
.empty .icon { width: 40px; height: 40px; color: var(--muted); margin-bottom: 6px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
.hint { color: var(--muted); font-size: .85rem; margin: .4em 0 1em; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 200px; }
.list { list-style: none; padding: 0; margin: 0 0 12px; }
.list li { padding: 9px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.inline { display: inline; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 650; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn .icon { width: 18px; height: 18px; }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--border); }
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); }
.btn-sm { padding: 6px 13px; font-size: .88rem; }
.btn-block { display: flex; width: 100%; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(.92); color: #fff; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; font-size: .88rem; }
.linklike:hover { color: var(--text); }
.linklike.danger { color: var(--danger); }
button[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent-soft); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 14px; }
label { display: grid; gap: 5px; font-weight: 550; }
label small, fieldset small { font-weight: 400; color: var(--muted); }
input:not([type=checkbox]):not([type=radio]):not([type=file]), textarea, select {
  font: inherit; color: var(--text); background: var(--surface); width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); outline-offset: 0; }
textarea { resize: vertical; }
select { width: auto; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px 12px; margin: 0; display: grid; gap: 6px; }
legend { font-weight: 650; padding: 0 4px; }
.choice { display: flex; gap: 9px; align-items: flex-start; font-weight: 400; }
.choice input { margin-top: .3em; accent-color: var(--accent); width: 1.05em; height: 1.05em; flex: none; }
.checklist { max-height: 220px; overflow: auto; }
.file-btn { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; cursor: pointer; color: var(--accent); font-weight: 650; padding: 6px 12px; border: 1px dashed var(--border); border-radius: 999px; width: fit-content; }
.file-btn .icon { width: 18px; height: 18px; }
.file-btn:hover { background: var(--accent-soft); }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.preview { max-height: 220px; border-radius: var(--radius-sm); object-fit: cover; }
.search { display: flex; gap: 8px; }
.search input { flex: 1; }

.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; }
.flash ul { margin: 0; padding-left: 1.2em; }
.flash-ok { background: var(--ok-bg); color: var(--ok-ink); }
.flash-error { background: var(--err-bg); color: var(--err-ink); }
.flash-info { background: var(--accent-soft); color: var(--text); }

/* ---------- Avatars, tags ---------- */
.avatar { border-radius: 50%; object-fit: cover; flex: none; display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #f2a65a, #c2562f); color: #fff; font-weight: 700; }
.avatar-xs { width: 28px; height: 28px; font-size: .7rem; }
.avatar-sm { width: 40px; height: 40px; font-size: .9rem; }
.avatar-md { width: 52px; height: 52px; font-size: 1.05rem; }
.avatar-lg { width: 96px; height: 96px; font-size: 1.8rem; }
.tag { display: inline-block; font-size: .76rem; font-weight: 650; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); width: fit-content; }
.tag-public { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.rsvp-going, .tag-ok { background: var(--ok-bg); color: var(--ok-ink); border-color: transparent; }
.role-admin { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.role-moderator { background: var(--surface-3); color: var(--text); }

/* ---------- Posts ---------- */
.compose textarea { border: 0; padding: 4px 0; font-size: 1.05rem; background: transparent; }
.compose textarea:focus { outline: none; }
.compose-row { display: flex; gap: 10px; align-items: center; justify-content: flex-end; border-top: 1px solid var(--border); padding-top: 12px; margin-top: 6px; flex-wrap: wrap; }
.compose-row .file-btn { margin-right: auto; }
.compose .hint { margin-bottom: 0; }
.post-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.post-head a { text-decoration: none; }
.post-head .name { font-weight: 650; color: var(--text); }
.post-context { font-size: .82rem; color: var(--muted); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.post-context .icon { width: 16px; height: 16px; }
.post-context a { color: var(--muted); font-weight: 600; }
.meta { font-size: .84rem; color: var(--muted); }
.meta a { color: var(--muted); }
.post-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 10px; }
.post-img { display: block; width: 100%; border-radius: var(--radius-sm); margin: 4px 0 8px; background: var(--surface-2); }
/* ⋮ action menu (posts, chat messages): quiet until opened */
.more-menu { position: relative; margin-left: auto; }
.more-menu summary { list-style: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; color: var(--muted); cursor: pointer; }
.more-menu summary::-webkit-details-marker { display: none; }
.more-menu summary:hover, .more-menu[open] summary { background: var(--surface-2); color: var(--text); }
.more-menu summary .icon { width: 20px; height: 20px; }
.more-list { position: absolute; right: 0; top: calc(100% + 4px); min-width: 170px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 6px; z-index: 30; display: grid; gap: 2px; font-size: .92rem; }
.more-list a, .more-list button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 8px; background: none; font: inherit; color: var(--text); text-decoration: none; cursor: pointer; }
.more-list a:hover, .more-list button:hover { background: var(--surface-2); }
.more-list .danger { color: var(--danger); }
.more-form { display: grid; gap: 4px; padding-top: 4px; border-top: 1px solid var(--border); margin-top: 4px; }
.more-form .input-sm { max-width: none; margin: 0 4px; width: calc(100% - 8px); }
.more-menu-sm { margin-left: 0; }
.more-menu-sm summary { width: 22px; height: 22px; }
.more-menu-sm summary .icon { width: 15px; height: 15px; }
.more-menu-sm .more-list { top: auto; bottom: calc(100% + 4px); font-size: .88rem; }
.msg:not(.msg-own) .more-menu-sm .more-list { right: auto; left: 0; }
.more-menu-sm.more-down .more-list { bottom: auto; top: calc(100% + 4px); }
.msg-meta { align-items: center; }
.caught-up { display: flex; gap: 14px; align-items: center; justify-content: center; text-align: left; padding: 28px 16px; color: var(--muted); }
.caught-up svg { width: 40px; height: 40px; color: var(--ok-ink); flex: none; }
.caught-up p { margin: 0; }

/* ---------- People ---------- */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.person { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; }
.people-grid .person { margin: 0; }
.person-link { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; min-width: 0; }
.person-link strong { overflow-wrap: anywhere; }
.profile-head { display: flex; gap: 20px; align-items: flex-start; }
.profile-head h1 { margin: 0; }
.profile-info { min-width: 0; flex: 1; }
.profile-info p { margin: .3em 0; }
.bio { white-space: pre-wrap; }
@media (max-width: 480px) { .profile-head { flex-direction: column; align-items: center; text-align: center; } .profile-head .row { justify-content: center; } }

/* ---------- Events & communities (shared card grid) ---------- */
.event-grid, .comm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.event-card, .comm-card { display: grid; align-content: start; color: var(--text); text-decoration: none; margin: 0; transition: border-color .15s, transform .15s; padding: 0; overflow: hidden; }
.event-card:hover, .comm-card:hover { border-color: var(--accent); color: var(--text); }
.event-thumb, .comm-thumb { display: block; width: 100%; aspect-ratio: 5 / 2; object-fit: cover; background: var(--surface-2); }
.event-card-body, .comm-card-body { display: grid; gap: 4px; padding: 14px 16px 16px; }
.event-date { color: var(--accent); font-weight: 650; font-size: .86rem; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.cat-option { position: relative; display: grid; gap: 4px; font-weight: 550; font-size: .86rem; cursor: pointer; border: 2px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.cat-option img { display: block; width: 100%; aspect-ratio: 5 / 2; object-fit: cover; }
.cat-option span { padding: 2px 8px 8px; }
.cat-option input { position: absolute; opacity: 0; }
.cat-option:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.cat-option:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.event-detail { padding: 0; overflow: hidden; }
.event-cover { display: block; width: 100%; aspect-ratio: 5 / 2; max-height: 320px; object-fit: cover; }
.event-body { padding: 20px; }
.event-body h1 { margin-top: .4em; }
.event-when { font-weight: 650; }
.rsvp { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 14px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 16px 0; }

.comm-header { padding: 0; overflow: hidden; }
.comm-cover { display: block; width: 100%; aspect-ratio: 4 / 1; object-fit: cover; }
.comm-header-body { padding: 16px 20px 6px; }
.comm-header-body h1 { margin: 0 0 4px; }
.comm-tabs { display: flex; gap: 4px; padding: 0 12px; border-top: 1px solid var(--border); overflow-x: auto; }
.comm-tabs a { padding: 12px 12px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.comm-tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.member-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

/* ---------- Chat ---------- */
.chat-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.chat-list { padding: 6px; }
.chat-item { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; color: var(--text); text-decoration: none; }
.chat-item:hover { background: var(--surface-2); }
.chat-item.active { background: var(--accent-soft); }
.chat-item-main { min-width: 0; flex: 1; }
.chat-item-title { display: flex; justify-content: space-between; gap: 8px; font-weight: 650; }
.chat-item-title span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-preview { color: var(--muted); font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item.unread .chat-item-preview { color: var(--text); font-weight: 600; }
.chat-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); flex: none; }
.chat-thread { display: flex; flex-direction: column; padding: 0; overflow: hidden; min-height: 60vh; }
.chat-thread-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.chat-thread-head h1 { font-size: 1.1rem; margin: 0; }
.chat-messages { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 16px; max-height: 62vh; overflow-y: auto; }
.msg { max-width: min(78%, 560px); align-self: flex-start; }
.msg-bubble { background: var(--surface-2); padding: 8px 12px; border-radius: 16px 16px 16px 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-own { align-self: flex-end; }
.msg-own .msg-bubble { background: var(--accent-soft); border-radius: 16px 16px 4px 16px; }
.msg-meta { font-size: .74rem; color: var(--muted); margin: 2px 6px; display: flex; gap: 8px; }
.msg-own .msg-meta { justify-content: flex-end; }
.msg-removed .msg-bubble { font-style: italic; color: var(--muted); background: transparent; border: 1px dashed var(--border); }
.msg-sender { font-size: .78rem; font-weight: 650; margin: 0 6px 2px; color: var(--muted); }
.chat-compose { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-compose textarea { min-height: 44px; max-height: 160px; }
.chat-day { align-self: center; font-size: .76rem; color: var(--muted); margin: 8px 0; }
.chat-calm { text-align: center; color: var(--muted); font-size: .8rem; padding: 6px 12px 10px; }
@media (max-width: 899px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-layout.in-thread .chat-list-wrap { display: none; }
  .chat-messages { max-height: none; min-height: 50vh; }
}

/* ---------- Me menu (phones) ---------- */
.me-menu { padding: 6px; }
.me-menu a, .me-menu button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 12px; border-radius: 12px; color: var(--text); text-decoration: none; font: inherit; font-weight: 550; background: none; border: 0; cursor: pointer; text-align: left; }
.me-menu a:hover, .me-menu button:hover { background: var(--surface-2); }
.me-menu .count { margin-left: auto; }

/* ---------- Settings ---------- */
.subnav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.subnav a { padding: 5px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--muted); font-size: .88rem; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
section[id] { scroll-margin-top: 80px; }
.qr { width: 200px; max-width: 100%; margin: 12px 0; padding: 8px; background: #fff; border-radius: var(--radius-sm); }
.qr svg { display: block; width: 100%; height: auto; }
.secret { word-break: break-all; font-size: .95rem; }
.steps li { margin-bottom: 12px; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.codes code { font-size: 1rem; letter-spacing: .05em; }
.mail-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .85rem; background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm); }

/* ---------- Landing & static pages ---------- */
.hero { text-align: center; padding: 40px 0 32px; max-width: 720px; margin: 0 auto; }
.hero-mark { width: 96px; height: 96px; }
.hero h1 { font-size: clamp(1.9rem, 1.3rem + 2.6vw, 3rem); margin: .4em 0 .4em; }
.lead { font-size: 1.15rem; color: var(--muted); }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-top: 16px; }
.feature h2 { margin-top: 0; font-size: 1.1rem; }
.feature .icon { width: 30px; height: 30px; color: var(--accent); }
.stat { font-size: 2rem; font-weight: 750; color: var(--accent); line-height: 1.1; }
.rules dt { font-weight: 650; margin-top: .8em; }
.rules dd { margin: .2em 0 0; color: var(--muted); }
.prose table { width: 100%; border-collapse: collapse; font-size: .9rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px; text-align: left; vertical-align: top; }
.prose li { margin-bottom: .5em; }

.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 28px 8px 8px; margin-top: 24px; border-top: 1px solid var(--border); }
.footer p { margin: .3em 0; }
.footer a { color: var(--muted); }

/* ---------- Additions: layout helpers & chat details ---------- */
.row.center-row { justify-content: center; }
.chat-back { display: none; }
.chat-options { min-width: 240px; padding: 12px; gap: 10px; }
@media (max-width: 899px) {
  .chat-back { display: inline-grid; }
  .chat-layout:not(.in-thread) .chat-placeholder { display: none; }
}

/* ---------- Explore events ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 6px; }
.chip { display: inline-block; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: .86rem; font-weight: 550; text-decoration: none; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.explore-filters { margin-bottom: 18px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.filter-grid select { width: 100%; }
.near-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.near-row .locate { margin-bottom: 4px; }
.locate-hint, .locate-status { margin: -6px 0 0; }
.locate-status:empty { display: none; }
.postcode-field { flex: 0 1 9rem; }
.event-card .tags { gap: 6px; margin-top: 2px; }
.end-state { padding: 18px 0; }

/* ---------- Organisers ---------- */
.steps { padding-left: 1.3em; display: grid; gap: 6px; margin: 0 0 18px; }
.org-list { display: grid; gap: 10px; }
.org-row { display: grid; gap: 6px; color: var(--text); text-decoration: none; }
.org-row:hover { border-color: var(--accent); color: var(--text); }
.org-head { display: grid; gap: 4px; margin-bottom: 18px; }
.org-head h1 { margin: .2em 0 0; }
.org-status { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; margin: 8px 0; }
.org-status p { margin: .2em 0; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 8px 0; font-size: .9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.admin-org { margin-bottom: 14px; }
.narrow-card { max-width: 760px; margin: 0 auto; }

/* ---------- Change email ---------- */
.change-email { margin-top: 10px; }
.change-email summary { cursor: pointer; color: var(--accent); font-weight: 600; width: fit-content; }
.change-email .form { margin-top: 10px; }

/* ---------- Sign-up bot protection (D34) ---------- */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Photo descriptions ---------- */
.alt-field { margin-top: 8px; }
[hidden] { display: none !important; } /* the hidden attribute wins over display rules (.avatar, .row, ...) */

.input-sm { width: auto; max-width: 14rem; padding: 4px 8px; font-size: .85rem; }

/* ---------- Edited chat messages (D38) ---------- */
.msg-edited { font-style: italic; color: var(--muted); font-size: .78rem; }
