/* SPDX-License-Identifier: LicenseRef-Apache-2.0-with-Commons-Clause */
/* Copyright (c) 2026 Griffith Software — https://griffith.software */

/* Navy, red and white. Wide screens get a navy sidebar; phones get a tab bar. */
:root {
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #edf0f6;
  --text: #0f1b33;
  --heading: #0b2a5b;
  --muted: #5b667a;
  --line: #dfe4ec;
  --navy: #0b2a5b;
  --navy-text: #ffffff;
  --btn-bg: #0b2a5b;
  --btn-fg: #ffffff;
  --red: #d7192a;
  --red-dark: #b3121f;
  --red-text: #ffffff;
  --accent: #1f56c8;
  --accent-text: #ffffff;
  --accent-soft: #e3ecfb;
  --mine: #1f56c8;
  --mine-text: #ffffff;
  --theirs: #ffffff;
  --warn: #b3121f;
  --warn-soft: #fdecee;
  --tint-0-bg: #dfe9fb;
  --tint-0-fg: #1f56c8;
  --tint-1-bg: #fde2e4;
  --tint-1-fg: #d7192a;
  --tint-2-bg: #e6e9f0;
  --tint-2-fg: #33415c;
  --card-glow: linear-gradient(105deg, #ffffff 0%, #f4f7fd 55%, #fdeef0 100%);
  --radius: 14px;
  --shadow: 0 1px 2px rgb(11 42 91 / 0.06), 0 6px 18px rgb(11 42 91 / 0.06);
  --header-h: 68px;
  --tabs-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1222;
    --surface: #121c30;
    --surface-2: #1a2640;
    --text: #e8edf6;
    --heading: #e8edf6;
    --muted: #9aa7bd;
    --line: #26334d;
    --navy: #0b1a36;
    --btn-bg: #7fa6ff;
    --btn-fg: #0a1222;
    --red: #ef3b47;
    --red-dark: #d7192a;
    --accent: #7fa6ff;
    --accent-text: #0a1222;
    --accent-soft: #1a2b4d;
    --mine: #2a5bd0;
    --theirs: #1a2640;
    --warn: #ff7a83;
    --warn-soft: #3a1820;
    --tint-0-bg: #1c2f57;
    --tint-0-fg: #9dbbff;
    --tint-1-bg: #44161d;
    --tint-1-fg: #ff8a93;
    --tint-2-bg: #232f47;
    --tint-2-fg: #c3cde0;
    --card-glow: linear-gradient(105deg, #121c30 0%, #15223c 55%, #2a1626 100%);
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0a1222;
  --surface: #121c30;
  --surface-2: #1a2640;
  --text: #e8edf6;
  --heading: #e8edf6;
  --muted: #9aa7bd;
  --line: #26334d;
  --navy: #0b1a36;
  --btn-bg: #7fa6ff;
  --btn-fg: #0a1222;
  --red: #ef3b47;
  --red-dark: #d7192a;
  --accent: #7fa6ff;
  --accent-text: #0a1222;
  --accent-soft: #1a2b4d;
  --mine: #2a5bd0;
  --theirs: #1a2640;
  --warn: #ff7a83;
  --warn-soft: #3a1820;
  --tint-0-bg: #1c2f57;
  --tint-0-fg: #9dbbff;
  --tint-1-bg: #44161d;
  --tint-1-fg: #ff8a93;
  --tint-2-bg: #232f47;
  --tint-2-fg: #c3cde0;
  --card-glow: linear-gradient(105deg, #121c30 0%, #15223c 55%, #2a1626 100%);
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

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

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

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; color: var(--heading); }
h1 { font-size: 1.7rem; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; }
p { margin: 0 0 0.9em; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }

#app, .view { min-height: 100%; display: flex; flex-direction: column; }
.view { flex: 1; }

.page {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}
.page.narrow { max-width: 520px; }
.page.page-top { padding-bottom: 0; }
.page-icon { display: block; width: 72px; height: 72px; margin: 8px 0 16px; border-radius: 16px; }

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand img { width: 56px; height: 56px; border-radius: 14px; }
.brand-name { font-weight: 800; font-size: 1.35rem; line-height: 1.1; color: var(--heading); }
.tagline { font-size: 1.45rem; text-transform: uppercase; letter-spacing: 0.02em; }
.tagline-red { color: var(--red); }
.tagline-small { font-weight: 700; text-transform: uppercase; font-size: 0.9rem; letter-spacing: 0.03em; }
.brand-by { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

.stack { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.row.heading { margin: 4px 0 16px; gap: 12px; }
.row.heading h1 { margin: 0; }

label { display: block; font-weight: 600; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 0.88rem; margin-top: 4px; }
.note {
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.92rem;
}
.note.warn { background: var(--warn-soft); }
.note.tip { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 16px; }
.note.tip p { margin: 0; }
.error { color: var(--warn); font-size: 0.92rem; margin: 6px 0 0; min-height: 1.2em; }

input[type="text"], input[type="email"], input[type="number"], input[type="url"], input[type="search"], textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
}
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}
.code-input { letter-spacing: 0.3em; font-size: 1.3rem; text-align: center; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 10px;
  padding: 11px 18px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
}
button.red, .button.red { background: var(--red); color: var(--red-text); box-shadow: 0 2px 8px rgb(215 25 42 / 0.25); }
button.red:hover, .button.red:hover { background: var(--red-dark); }
button.secondary, .button.secondary { background: var(--surface-2); color: var(--text); }
button.ghost { background: transparent; color: var(--text); padding: 8px 10px; }
button.danger { background: var(--warn); color: #fff; }
.danger-text { color: var(--warn) !important; }
button:disabled, .button.off { opacity: 0.5; cursor: default; }
.full { width: 100%; }
.small-button { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }
.link-back {
  background: transparent;
  color: var(--accent);
  padding: 0;
  min-height: 36px;
  font-weight: 600;
  gap: 4px;
  margin-bottom: 4px;
}
.icon { width: 22px; height: 22px; flex: none; }
.small-icon { width: 16px; height: 16px; }

.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { width: 22px; height: 22px; margin-top: 1px; flex: none; accent-color: var(--red); }

.agreement ol { padding-left: 1.3em; margin: 0 0 1em; }
.agreement li { margin-bottom: 0.6em; }
.terms {
  max-height: 46vh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px 16px 4px;
  margin-bottom: 14px;
  font-size: 0.95rem;
}

/* App frame */
.app-shell { min-height: 100dvh; display: flex; flex-direction: column; }
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.app-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-right: auto; }
.app-brand img { width: 44px; height: 44px; border-radius: 11px; }
.app-brand-text { display: flex; flex-direction: column; font-weight: 800; font-size: 1.15rem; line-height: 1.05; color: var(--heading); }
.brand-tail { color: var(--red); }
.header-search { display: none; }
.popover-anchor { position: relative; }
.icon-button {
  position: relative;
  background: transparent;
  color: var(--text);
  padding: 0;
  width: 44px;
  min-height: 44px;
  border-radius: 12px;
}
.icon-button:hover { background: var(--surface-2); }
.badge {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1;
}
.bell .badge { position: absolute; top: 5px; right: 4px; box-shadow: 0 0 0 2px var(--surface); }
.badge.inline { min-width: 22px; height: 22px; border-radius: 11px; font-size: 0.75rem; }
.account-button { background: transparent; color: var(--text); padding: 4px 6px; gap: 8px; min-height: 44px; }
.account-button:hover { background: var(--surface-2); }
.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-weight: 800;
}
.account-name, .account-button .small-icon { display: none; }
.popover {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 12px 32px rgb(11 42 91 / 0.18);
  padding: 8px;
}
.bell-panel { width: min(340px, calc(100vw - 24px)); right: -52px; }
.bell-panel h2 { font-size: 1rem; margin: 6px 8px 8px; }
.popover-list { display: flex; flex-direction: column; max-height: 60vh; overflow-y: auto; }
.popover-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  font-weight: 400;
  padding: 10px;
}
.popover-item:hover, .menu-panel button:hover { background: var(--surface-2); }
.popover-item strong { display: block; }
.popover-item .muted { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-note { margin: 4px 10px 10px; }
.menu-panel { display: flex; flex-direction: column; min-width: 200px; }
.menu-panel button { background: transparent; color: var(--text); justify-content: flex-start; font-weight: 600; }

.app-body { flex: 1; display: flex; min-height: 0; }
.app-sidebar { display: none; }
.app-main { flex: 1; min-width: 0; padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); }
.tab-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.74rem;
  font-weight: 600;
}
.tab.active { color: var(--red); }

/* On phones a conversation fills the screen above the tab bar (Messages is a tab). */
.app-shell.is-chat .app-header { display: none; }
.app-shell.is-chat .app-main {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--tabs-h) - env(safe-area-inset-bottom));
  padding-bottom: 0;
}
.app-shell.is-chat .composer { padding-bottom: 8px; }

@media (min-width: 900px) {
  .header-search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 520px;
    margin: 0 auto 0 32px;
    padding: 0 14px;
    background: var(--surface-2);
    border-radius: 12px;
    color: var(--muted);
    font-weight: 400;
  }
  .header-search input { border: 0; background: transparent; padding: 12px 0; }
  .header-search input:focus-visible { outline: none; }
  .header-search:focus-within { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); }
  .app-brand { margin-right: 0; }
  .app-brand img { width: 52px; height: 52px; border-radius: 13px; }
  .app-brand-text { font-size: 1.35rem; }
  .account-name { display: inline; font-weight: 700; }
  .account-button .small-icon { display: inline; }
  .bell-panel { right: 0; }
  .app-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 250px;
    flex: none;
    position: sticky;
    top: var(--header-h);
    height: calc(100dvh - var(--header-h));
    padding: 20px 14px;
    background: var(--navy);
    color: var(--navy-text);
  }
  .side-nav { display: flex; flex-direction: column; gap: 6px; }
  .side-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: 12px;
    color: rgb(255 255 255 / 0.88);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.02rem;
  }
  .side-link:hover { background: rgb(255 255 255 / 0.08); }
  .side-link.active { background: var(--red); color: #fff; }
  .side-badge {
    margin-top: auto;
    text-align: center;
    padding: 18px 12px 14px;
    border-top: 1px solid rgb(255 255 255 / 0.18);
  }
  .side-badge p { margin: 0; }
  .badge-name { font-weight: 800; font-size: 1.3rem; margin-bottom: 10px !important; }
  .badge-tagline { color: #ff4d5a; text-transform: uppercase; font-weight: 600; font-size: 0.86rem; white-space: nowrap; }
  .badge-tagline-end { text-transform: uppercase; font-weight: 800; margin-top: 8px !important; }
  .badge-description { margin-top: 14px !important; padding-top: 14px; border-top: 1px solid rgb(255 255 255 / 0.25); font-size: 0.92rem; }
  .badge-by { margin-top: 8px !important; font-size: 0.8rem; color: rgb(255 255 255 / 0.65); }
  .app-main { padding-bottom: 0; }
  .tab-bar { display: none; }
  .page-search { display: none !important; }
  .app-shell.is-chat .app-header { display: flex; }
  .app-shell.is-chat .app-main { height: calc(100dvh - var(--header-h)); }
  .group-switcher { padding: 10px 16px; }
  .page { padding: 28px 28px 48px; }
}

/* Sponsor */
.sponsor {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
}
.sponsor img { flex: none; border-radius: 8px; object-fit: cover; }
.sponsor-label {
  flex: none;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
}
.sponsor-strip { height: 44px; padding: 0 12px; border-width: 0 0 1px; background: var(--surface-2); }
.sponsor-strip img { width: 28px; height: 28px; }
.sponsor-strip .sponsor-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.92rem; }
.sponsor-card {
  flex-wrap: wrap;
  gap: 14px 16px;
  border-radius: 16px;
  padding: 16px 18px;
  margin-bottom: 22px;
  min-height: 96px;
  background: var(--card-glow);
  box-shadow: var(--shadow);
}
.sponsor-card img { width: 56px; height: 56px; border-radius: 13px; }
/* The support message's megaphone keeps its own shape (no tile, no rounding). */
.sponsor.is-support img { border-radius: 0; object-fit: contain; }
.sponsor-strip.is-support img { width: 38px; height: 28px; }
.sponsor-card.is-support img { width: 90px; height: 66px; }
.sponsor-body { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 2px; }
.sponsor-card .sponsor-label { align-self: flex-start; border: 0; padding: 0; }
.sponsor-title { color: var(--heading); font-size: 1.15rem; line-height: 1.2; }
.sponsor-card .sponsor-text { color: var(--muted); font-size: 0.95rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sponsor-cta {
  flex: 1 1 100%;
  text-align: center;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  border-radius: 10px;
  padding: 11px 16px;
  white-space: nowrap;
}
@media (min-width: 640px) {
  .sponsor-card { flex-wrap: nowrap; padding: 20px 24px; }
  .sponsor-cta { flex: none; }
}

/* Group list and Messages */
.page-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  font-weight: 400;
}
.page-search input { border: 0; padding: 11px 0; background: transparent; }
.page-search input:focus-visible { outline: none; }
.group-list, .message-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.group-card, .message-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 14px 16px;
  font-weight: 400;
  box-shadow: var(--shadow);
}
.group-card:hover, .message-row:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.group-avatar {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.4rem;
}
.group-avatar.small { width: 42px; height: 42px; font-size: 1.1rem; }
.tint-0 { background: var(--tint-0-bg); color: var(--tint-0-fg); }
.tint-1 { background: var(--tint-1-bg); color: var(--tint-1-fg); }
.tint-2 { background: var(--tint-2-bg); color: var(--tint-2-fg); }
.group-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.group-name { font-weight: 800; font-size: 1.05rem; color: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-sub { color: var(--muted); font-size: 0.85rem; }
.group-preview { color: var(--text); font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.has-unread .group-preview { font-weight: 700; }
.group-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.group-time { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.chevron { color: var(--muted); width: 20px; height: 20px; }
.avatar img, .msg-avatar img, .profile-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.avatar { overflow: hidden; }
.group-card.compact { padding: 10px 14px; }
.group-card.compact .group-avatar { width: 42px; height: 42px; font-size: 1.1rem; }
.row-top { display: flex; align-items: baseline; gap: 8px; }
.message-row .from { color: var(--muted); }
.message-row.unread { border-left: 4px solid var(--red); padding-left: 12px; }
.message-row.unread .group-preview { font-weight: 700; }
.empty { text-align: center; padding: 32px 8px; color: var(--muted); }

/* Chat */
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; height: 100dvh; }
.app-shell.is-chat .chat { height: 100%; }
.group-switcher {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  scrollbar-width: thin;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.switch-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 230px;
  min-height: 40px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
}
.switch-chip:hover { background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); }
.switch-chip.active { background: var(--red); color: #fff; }
.chip-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.85rem;
}
.switch-chip.active .chip-avatar { background: #fff; color: var(--red); }
.chip-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.chat-title { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 0 4px; }
.chat-name { font-weight: 800; color: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { color: var(--muted); font-size: 0.8rem; }
.status-bar { font-size: 0.85rem; text-align: center; padding: 6px; background: var(--surface-2); color: var(--muted); }
.messages { flex: 1; overflow-y: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 82%; display: flex; flex-direction: column; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg-from { font-size: 0.78rem; color: var(--muted); margin: 6px 4px 2px; font-weight: 600; }
/* Other members' messages: their photo (or letter) beside the name and bubble. */
.msg:not(.mine) { display: grid; grid-template-columns: 32px minmax(0, auto); column-gap: 8px; justify-items: start; }
.msg:not(.mine) > :not(.msg-avatar) { grid-column: 2; }
.msg-avatar {
  grid-column: 1;
  grid-row: 1 / span 3;
  align-self: start;
  margin-top: 22px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.85rem;
  overflow: hidden;
}
.bubble {
  background: var(--theirs);
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 4px;
  padding: 8px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.mine .bubble { background: var(--mine); color: var(--mine-text); border-color: transparent; border-radius: 16px 16px 4px 16px; }
.msg-link { color: inherit; text-decoration: underline; text-underline-offset: 2px; font-weight: 600; }
.msg-meta { font-size: 0.72rem; color: var(--muted); margin: 2px 4px 0; display: flex; align-items: center; gap: 6px; }
.msg-action {
  min-height: 28px;
  min-width: 32px;
  padding: 0 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}
.msg-action:hover { background: var(--surface-2); }
.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.composer button[type="submit"] { background: var(--red); color: #fff; }
.composer textarea { resize: none; max-height: 160px; min-height: 44px; }
.counter { font-size: 0.75rem; color: var(--muted); text-align: right; padding: 0 12px; }
.counter.over { color: var(--warn); }
.bubble.with-photo { padding: 4px; display: flex; flex-direction: column; gap: 4px; }
.bubble.with-photo > span { padding: 2px 8px 4px; }
.photo {
  display: block;
  width: min(280px, 64vw);
  max-height: 360px;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
  min-height: 0;
}
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo.loading { animation: pulse 1.2s ease-in-out infinite; }
.photo.missing { display: grid; place-items: center; color: var(--muted); font-weight: 400; font-size: 0.85rem; min-height: 80px; }
@keyframes pulse { 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .photo.loading { animation: none; } }
.photo-preview { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface); border-top: 1px solid var(--line); }
.photo-preview img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.viewer {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgb(0 0 0 / 0.92);
  display: grid;
  place-items: center;
  padding: 16px;
}
/* Sized against the screen: a percentage max-height doesn't resolve inside the auto-sized grid,
   which let tall phone photos run off the bottom. */
.viewer img { max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); object-fit: contain; }
.viewer-close { position: absolute; top: 12px; right: 12px; background: rgb(255 255 255 / 0.15); color: #fff; }
.ended { padding: 16px; text-align: center; background: var(--surface); border-top: 1px solid var(--line); }

/* Invite */
.qr { background: #fff; padding: 12px; border-radius: var(--radius); width: min(280px, 100%); margin: 8px auto 16px; box-shadow: var(--shadow); }
.qr svg { display: block; width: 100%; height: auto; }
.link-box { font-family: ui-monospace, Consolas, monospace; font-size: 0.8rem; word-break: break-all; background: var(--surface-2); border-radius: 10px; padding: 10px; }

/* Menu and dialogs */
.menu { position: relative; }
.menu-list {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 20;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
  padding: 6px;
  display: flex;
  flex-direction: column;
}
.menu-list button { background: transparent; color: var(--text); justify-content: flex-start; font-weight: 500; }
.menu-list button:hover { background: var(--surface-2); }

dialog {
  border: 0;
  border-radius: 18px;
  padding: 20px;
  width: min(440px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 16px 48px rgb(0 0 0 / 0.3);
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.resources { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }
.resources li { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.resources strong { display: block; }

/* Operator page */
.page.wide { max-width: 920px; }
.op-tabs { gap: 16px; margin: 0 0 12px; }
.op-tabs a[aria-current="page"] { font-weight: 700; text-decoration: none; color: var(--text); }
.review-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.review-item.threat { border-left-color: var(--warn); }
.review-facts { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; font-size: 0.9rem; margin: 10px 0; }
.review-facts dt { color: var(--muted); }
.review-facts dd { margin: 0; overflow-wrap: anywhere; }
.review-facts .pre { white-space: pre-wrap; }
.review-text { margin: 8px 0; padding: 10px 12px; background: var(--warn-soft); border-radius: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.review-thread { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.review-thread li { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.review-thread li.reported { background: var(--warn-soft); outline: 2px solid var(--warn); }
.review-photo { display: block; max-width: min(360px, 100%); border-radius: 10px; margin: 8px 0; }
.op-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.op-action { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.op-action textarea, .op-action input[type="text"] { width: min(320px, 70vw); }
.op-action input[type="date"] { font: inherit; padding: 9px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 50;
}

/* Sponsor pages and previews */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 16px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.notice { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.notice.error { border-color: var(--warn); }
.sponsor-previews { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 20px; max-width: 460px; }
.sponsor-previews p { margin: 6px 0 0; }
.sponsor.preview.sponsor-strip { border-width: 1px; border-radius: 10px; }
.sponsor.preview.sponsor-card { margin-bottom: 0; }
input[type="file"] { width: 100%; }
table.stats { width: 100%; border-collapse: collapse; margin: 12px 0; font-variant-numeric: tabular-nums; }
table.stats th, table.stats td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.stats td + td, table.stats th + th { text-align: right; }
.op-sections { gap: 20px; margin: 0 0 16px; font-size: 1.05rem; }
.op-sections a[aria-current="page"] { font-weight: 700; text-decoration: none; color: var(--text); }
.op-section { margin: 0 0 28px; }
.op-rules { margin: 8px 0; font-size: 0.9rem; }

/* Settings and About */
fieldset.choices { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px 4px; margin: 0 0 16px; }
fieldset.choices legend { font-weight: 700; padding: 0 6px; }
fieldset.choices .check { margin-bottom: 10px; }
.about .stack .button { text-align: center; }

/* Settings: profile photo, name, Delete My Data */
.profile-row { display: flex; align-items: center; gap: 16px; margin: 4px 0 8px; }
.profile-photo {
  flex: none;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--red);
  color: #fff;
  font-weight: 800;
  font-size: 2rem;
  overflow: hidden;
}
.stack.tight { margin: 0; gap: 8px; }
.name-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
button.danger-outline { background: transparent; color: var(--warn); border: 2px solid var(--warn); }
button.danger-outline:hover { background: var(--warn-soft); }

/* Info: the Section 7 link under the taglines, and the phone popup */
.badge-law { margin-top: 10px !important; font-size: 0.82rem; }
.badge-law a { color: inherit; text-decoration: underline; text-underline-offset: 2px; opacity: 0.92; }
.tab-button { background: transparent; border-radius: 0; padding: 0; min-height: 0; font-weight: 600; }
.info-panel {
  text-align: center;
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius);
  padding: 18px 14px 14px;
  margin-bottom: 14px;
}
.info-panel p { margin: 0; }
.info-panel .badge-name { font-weight: 800; font-size: 1.3rem; margin-bottom: 10px; }
.info-panel .badge-tagline { color: #ff4d5a; text-transform: uppercase; font-weight: 600; font-size: 0.9rem; }
.info-panel .badge-tagline-end { text-transform: uppercase; font-weight: 800; margin-top: 8px; }
.info-panel .badge-law { margin-top: 10px; }
.info-panel .badge-description { margin-top: 14px; padding-top: 14px; border-top: 1px solid rgb(255 255 255 / 0.25); font-size: 0.92rem; }
.info-panel .badge-by { margin-top: 8px; font-size: 0.8rem; color: rgb(255 255 255 / 0.65); }
.fixed-support { margin-bottom: 0; }

/* Sign-in footer and the privacy page (site/privacy.html) */
.signin-footer { margin-top: 20px; text-align: center; }
.privacy { line-height: 1.55; }
.privacy table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.privacy th, .privacy td { text-align: left; vertical-align: top; padding: 6px 8px; border-bottom: 1px solid var(--line); }

/* Welcome (the sign-in screen). Phones: the picture whole, the words on navy below it.
   Wide screens: the words over the picture, the sign-in card beside the rest. */
.welcome { max-width: 1180px; margin: 0 auto; padding: 0 0 40px; }
.welcome-hero { position: relative; overflow: hidden; background: #0a1222; border-radius: 0 0 22px 22px; }
.welcome-art { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; object-position: 50% 40%; }
.welcome-hero-text { position: relative; z-index: 1; padding: 20px 20px 24px; color: #fff; max-width: 640px; }
.welcome-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.welcome-brand img { width: 44px; height: 44px; border-radius: 12px; }
.welcome-brand .brand-name { color: #fff; font-size: 1.15rem; }
.welcome-brand .brand-tail { color: #ff4d5a; }
.welcome-hero .welcome-kicker {
  margin: 0 0 8px; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: #ffd166;
}
.welcome-hero h1 { font-size: clamp(1.9rem, 6vw, 3rem); line-height: 1.05; text-transform: uppercase; margin: 0 0 12px; color: #fff; }
.welcome-hero h1 .tagline-red { color: #ff4d5a; }
.welcome-hero .welcome-lead { font-size: 1.08rem; line-height: 1.5; margin: 0; color: rgb(255 255 255 / 0.9); }

.welcome-main { display: grid; gap: 22px; padding: 22px 16px 0; }
.welcome-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); }
.welcome-card h2 { margin: 0 0 6px; font-size: 1.3rem; color: var(--heading); }
.welcome-intro { font-size: 1.05rem; line-height: 1.6; margin: 0; }
.welcome-intro strong { color: var(--heading); }
.welcome-crews { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
.welcome-crews li {
  font-size: 0.86rem; font-weight: 700; padding: 6px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
}
.welcome-points { display: grid; gap: 14px; }
.welcome-point { border-left: 4px solid var(--red); padding-left: 14px; }
.welcome-point h3 { margin: 2px 0 4px; font-size: 1.05rem; color: var(--heading); }
.welcome-point p { margin: 0; color: var(--muted); line-height: 1.5; }
.welcome-steps { counter-reset: step; display: grid; gap: 10px; margin: 10px 0 0; padding: 0; list-style: none; }
.welcome-steps li { counter-increment: step; display: flex; gap: 12px; align-items: baseline; line-height: 1.5; }
.welcome-steps li::before {
  content: counter(step); flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--red); color: #fff; font-weight: 800; font-size: 0.9rem;
}
.welcome-safe { border-left: 4px solid var(--red); }
.welcome .signin-footer { margin-bottom: 0; }

@media (min-width: 900px) {
  .welcome-hero { min-height: 540px; display: flex; align-items: flex-end; border-radius: 0 0 28px 28px; }
  .welcome-art { position: absolute; inset: 0; height: 100%; aspect-ratio: auto; object-position: 60% 45%; }
  .welcome-hero::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(90deg, rgb(10 18 34 / 0.94) 0%, rgb(10 18 34 / 0.78) 38%, rgb(10 18 34 / 0.1) 70%), linear-gradient(0deg, rgb(10 18 34 / 0.6) 0%, transparent 40%);
  }
  .welcome-hero-text { padding: 40px 44px; text-shadow: 0 2px 12px rgb(0 0 0 / 0.5); }
  .welcome-main { grid-template-columns: 1.15fr 1fr; align-items: start; padding: 28px 24px 0; gap: 26px; }
  .welcome-signin { grid-column: 2; grid-row: 1 / span 4; position: sticky; top: 20px; }
  .welcome-main > :not(.welcome-signin) { grid-column: 1; }
}

/* A heading that takes focus when a step opens (for screen readers) shows no outline. */
h1[tabindex="-1"]:focus { outline: none; }
