:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1b2430;
  --muted: #5d6b7c;
  --accent: #1f3a5f;
  --accent-ink: #ffffff;
  --border: #d7dde5;
  --danger: #b3261e;
  --ok: #1b6e3a;
  --warn-bg: #fff4d6;
  --warn-ink: #5a4300;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161d;
    --card: #1a222c;
    --ink: #eef2f7;
    --muted: #9aa8b8;
    --accent: #6fa3e0;
    --accent-ink: #0b1118;
    --border: #2b3643;
    --danger: #ff8a80;
    --ok: #7fd49a;
    --warn-bg: #3a2f10;
    --warn-ink: #ffe9a8;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---- Layout ---- */

.landing,
.page {
  max-width: 34rem;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
  display: grid;
  gap: 1.25rem;
}
.page { padding-top: 1rem; }

.brand { text-align: center; }
.brand h1 { margin: 0.5rem 0 0.25rem; font-size: 1.75rem; }
.brand p { margin: 0; color: var(--muted); }

h1, h2, h3 { line-height: 1.25; }
h2 { margin: 0 0 0.75rem; font-size: 1.15rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.muted { color: var(--muted); font-size: 0.9rem; }

/* ---- Top bar ---- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar .who { font-weight: 700; }
.topbar nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.topbar a, .linklike {
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  background: none;
  border: 0;
  padding: 0.5rem 0;
  min-height: 44px;
  cursor: pointer;
}
.topbar a.active { text-decoration: underline; text-underline-offset: 4px; }

/* ---- Forms ---- */

form { display: grid; gap: 0.9rem; }

label { display: grid; gap: 0.35rem; font-weight: 600; font-size: 0.95rem; }

input, select {
  font: inherit;
  min-height: 48px; /* comfortable tap target */
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  width: 100%;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

button {
  font: inherit;
  font-weight: 700;
  min-height: 48px;
  padding: 0 1rem;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
button:disabled { opacity: 0.6; cursor: default; }
button.secondary {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}
button.danger {
  background: transparent;
  color: var(--danger);
  border: 2px solid var(--danger);
}
button.small { min-height: 44px; padding: 0 0.85rem; font-size: 0.9rem; }

.hint { font-weight: 400; color: var(--muted); font-size: 0.85rem; }

/* ---- Messages ---- */

.msg { margin: 0; padding: 0.7rem 0.9rem; border-radius: 10px; font-size: 0.95rem; }
.msg.error { color: var(--danger); border: 1px solid var(--danger); }
.msg.ok { color: var(--ok); border: 1px solid var(--ok); }
.msg.warn { background: var(--warn-bg); color: var(--warn-ink); }
.msg[hidden] { display: none; }

.secret {
  display: block;
  padding: 0.6rem 0.75rem;
  margin: 0.4rem 0;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--bg);
  font: 0.95rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
  user-select: all;
}

/* ---- Lists (admin) ---- */

.list { display: grid; gap: 0.75rem; margin: 0; padding: 0; list-style: none; }
.item {
  display: grid;
  gap: 0.5rem;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}
.item .title { font-weight: 700; }
.item .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  margin-left: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  vertical-align: middle;
}

footer { text-align: center; color: var(--muted); }

/* ---- Phase 2: avatars, events, members ---- */

.topbar .who {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  border: 1px solid var(--border);
}
.avatar-sm { width: 36px; height: 36px; font-size: 0.85rem; }
.avatar-md { width: 56px; height: 56px; font-size: 1.1rem; }
.avatar-lg { width: 120px; height: 120px; font-size: 2.4rem; }

textarea {
  font: inherit;
  min-height: 7rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  width: 100%;
  resize: vertical;
}
textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1rem;
  border: 2px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  background: transparent;
  cursor: pointer;
}
.chip.active { background: var(--accent); color: var(--accent-ink); }

.facts { display: grid; gap: 1rem; margin: 0; }
.fact dt { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.fact dd { margin: 0.15rem 0 0; font-size: 1.1rem; }
.fact dd a { color: var(--accent); font-weight: 600; font-size: 0.95rem; }
.big { font-size: 1.35rem; font-weight: 800; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; }

.members { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); gap: 1rem 0.5rem; margin: 0; padding: 0; list-style: none; }
.member { display: grid; justify-items: center; gap: 0.35rem; text-align: center; font-size: 0.85rem; overflow-wrap: anywhere; }

.profile-photo { display: grid; justify-items: center; gap: 0.75rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.file-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 1rem;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  cursor: pointer;
}
.file-label input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-label:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }

/* keep the Sign out button level with the nav links */
.topbar a, .linklike { display: inline-flex; align-items: center; line-height: 1.5; }

/* ---- member card popup + clickable members ---- */

button.member {
  background: none;
  border: 0;
  color: var(--ink);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 400;
  min-height: 44px;
  padding: 0.25rem;
  width: 100%;
  cursor: pointer;
  border-radius: 12px;
}
button.member:hover { background: var(--bg); }

.member-dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  padding: 0;
  width: min(92vw, 24rem);
  max-height: 85vh;
}
.member-dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.member-card { display: grid; justify-items: center; gap: 0.6rem; padding: 1.5rem 1.25rem; text-align: center; }
.member-card h2 { margin: 0; }
.member-card p { margin: 0; }
.member-card .prose { text-align: left; width: 100%; }
.member-card button { width: 100%; margin-top: 0.5rem; }

/* ---- Phase 3: discussion, comments, album, uploads ---- */

.tabs { margin-bottom: 1rem; }
.tabs .chip { flex: 1; justify-content: center; }
.chip.small { min-height: 40px; padding: 0 0.85rem; font-size: 0.9rem; }
a.chip.small { text-decoration: none; }
.sorts { margin: 1rem 0 0.5rem; }
.row.left { justify-content: flex-start; align-items: center; }
.file-label.small { min-height: 44px; font-size: 0.9rem; }

.composer, .inline-form { display: grid; gap: 0.6rem; }
.composer { padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }

.feed { display: grid; gap: 1rem; margin-top: 0.5rem; }
.post {
  display: grid;
  gap: 0.6rem;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}
.post.pinned { border: 2px solid var(--accent); }
.post p, .comment p { margin: 0; }

.byline { display: flex; align-items: center; flex-wrap: wrap; gap: 0.25rem 0.6rem; }
.byline .badge { margin-left: 0; }
.byline-person {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

.social-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }
.social-bar button {
  min-height: 40px;
  padding: 0 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.9rem;
}
.social-bar button.on { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.social-bar button.add { color: var(--muted); font-weight: 400; }
.picker { display: flex; flex-wrap: wrap; gap: 0.4rem; width: 100%; }
.picker button { font-size: 1.2rem; }

.actions-line { gap: 0.9rem; }
.small-link { font-size: 0.9rem; font-weight: 600; padding: 0; min-height: 44px; }
.danger-text { color: var(--danger); }

.comments { display: grid; gap: 0.75rem; padding-top: 0.5rem; border-top: 1px solid var(--border); }
.comment { display: grid; gap: 0.3rem; margin-top: 0.5rem; }
.replies { margin-left: 0.6rem; padding-left: 0.6rem; border-left: 2px solid var(--border); }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.grid.single { grid-template-columns: 1fr; }
.grid.attached { grid-template-columns: repeat(4, 1fr); }
.grid:empty { display: none; }
.tile {
  position: relative;
  display: block;
  aspect-ratio: 1;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #222b36;
  width: 100%;
}
.grid.single .tile { aspect-ratio: 4 / 3; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.6rem;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}
.attached-item { position: relative; }
.attached-item .remove {
  position: absolute;
  top: 2px;
  right: 2px;
  min-height: 28px;
  width: 28px;
  padding: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  line-height: 1;
}

.tab-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.uploads { display: grid; gap: 0.25rem; }
.upload-line { margin: 0; font-size: 0.9rem; color: var(--muted); overflow-wrap: anywhere; }
.upload-line.bad { color: var(--danger); }

.lightbox {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  background: #000;
  color: #fff;
}
.lightbox::backdrop { background: #000; }
.lightbox[open] { display: flex; flex-direction: column; }
.lb-stage { flex: 1; min-height: 0; display: grid; place-items: center; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem calc(0.6rem + env(safe-area-inset-bottom));
  background: #111;
}
.lb-info { flex: 1 1 100%; font-size: 0.9rem; color: #cbd5e1; }
.lb-bar .secondary { color: #fff; border-color: #fff; }
.lb-bar .chip { color: #fff; border-color: #fff; }

/* ---- Group chat ---- */
.chat-page { display: flex; flex-direction: column; height: calc(100dvh - 4.5rem); padding-bottom: 0.75rem; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 0.6rem; padding: 0.25rem 0; }
.msg-row { display: flex; gap: 0.5rem; align-items: flex-end; max-width: 88%; }
.msg-row.mine { align-self: flex-end; flex-direction: row-reverse; }
.bubble { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 0.45rem 0.8rem; }
.mine .bubble { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.bubble .who { font-size: 0.75rem; font-weight: 700; opacity: 0.8; }
.bubble p { margin: 0; }
.bubble .when { font-size: 0.7rem; opacity: 0.7; }
.bubble .del { background: none; border: 0; color: inherit; opacity: 0.7; min-height: 32px; padding: 0 0.3rem; font-size: 0.75rem; font-weight: 600; }
.chat-form { display: flex; gap: 0.5rem; align-items: flex-end; }
.chat-form textarea { min-height: 48px; height: 48px; resize: none; flex: 1; }
.chat-form button { flex: none; }

/* ---- event edit dialog + calendar buttons ---- */
.edit-dialog { width: min(94vw, 30rem); }
.edit-dialog .dialog-body { padding: 1.25rem; overflow-y: auto; max-height: 85vh; }
.event-actions { margin-top: 1rem; gap: 0.5rem; }
.event-actions .chip { text-decoration: none; }

/* ---- notification settings ---- */
.push-root { display: grid; gap: 0.75rem; }
.push-root .prefs { display: grid; gap: 0.25rem; }
label.check { display: flex; align-items: center; gap: 0.75rem; min-height: 44px; font-weight: 600; }
label.check input { width: 1.4rem; height: 1.4rem; min-height: 0; flex: none; }
.push-root .small { justify-self: start; }

/* ---- sign-in banner ---- */
.brand .banner { display: block; width: calc(100% + 2rem); max-width: none; height: auto; margin: -2rem -1rem 0.75rem; }
.brand .tagline { font-size: 1.05rem; font-weight: 600; letter-spacing: 0.02em; }
@media (min-width: 40rem) { .brand .banner { width: 100%; margin: 0 0 0.75rem; border-radius: var(--radius); } }

/* ---- calmer buttons in the discussion area: only "Post" is a filled button ---- */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tab {
  flex: 1;
  min-height: 48px;
  background: none;
  color: var(--muted);
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  margin-bottom: -1px;
  font-weight: 700;
}
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.sorts { display: flex; align-items: center; gap: 0.25rem; margin: 1rem 0 0.5rem; }
.sort-label { margin-right: 0.35rem; }
.sort-btn {
  min-height: 40px;
  padding: 0 0.7rem;
  background: none;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 600;
}
.sort-btn.active { color: var(--accent); border-color: var(--accent); font-weight: 800; }
.social-bar button.on { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); border-color: var(--accent); }
.file-label.secondary { background: transparent; color: var(--accent); border: 2px solid var(--accent); }
#event-delete { margin-top: 0.75rem; width: 100%; }

/* ---- attendance strip: tinted and slim so it reads as separate from the content ---- */
.rsvp {
  display: grid;
  gap: 0.25rem;
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  border: 1px dashed var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--bg));
}
.rsvp[hidden] { display: none; }
.rsvp-main { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.rsvp-main p { margin: 0; }
.seg { display: inline-flex; gap: 0.4rem; }
.seg button {
  min-height: 44px;
  padding: 0 1rem;
  background: var(--card);
  color: var(--ink);
  border: 2px solid var(--border);
  border-radius: 999px;
  font-weight: 700;
}
.seg button.on-in { border-color: var(--ok); color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--card)); }
.seg button.on-out { border-color: var(--danger); color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--card)); }
.rsvp #rsvp-who { justify-self: start; }
.who-list { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 0.4rem; }
.who-list li { display: flex; align-items: center; gap: 0.6rem; }
.seg[hidden], .rsvp [hidden] { display: none; }

/* taller invitation banner on the join page */
.brand .banner-tall { margin-bottom: 1rem; }

/* "See who" dialog */
.member-dialog .dialog-body { padding: 1.25rem; overflow-y: auto; max-height: 80vh; display: grid; gap: 0.25rem; }
.member-dialog .dialog-body h2 { margin: 0.75rem 0 0.5rem; font-size: 1rem; }
.member-dialog .dialog-body h2:first-child { margin-top: 0; }
.member-dialog .dialog-body .who-list { margin: 0 0 0.5rem; }
.member-dialog .dialog-body > button { margin-top: 0.75rem; width: 100%; }
