:root {
  --bg: #f4f4f1;
  --panel: #ffffff;
  --text: #121212;
  --muted: #6b6b6b;
  --line: #ddddda;
  --dark: #151515;
  --soft: #ecece8;
  --danger: #8b1e1e;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Arial, Helvetica, sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; border: 1px solid var(--dark); background: var(--panel); padding: 10px 14px; border-radius: 5px; }
button:hover { background: var(--soft); }
input, textarea, select { width: 100%; border: 1px solid var(--line); background: #fff; padding: 11px 12px; border-radius: 5px; }
textarea { resize: vertical; }
label { display: grid; gap: 7px; font-size: 14px; font-weight: 700; }
hr { border: 0; border-top: 1px solid var(--line); margin: 25px 0; }

.site-header, .app-header { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 5vw; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { text-decoration: none; font-size: 24px; letter-spacing: 4px; font-weight: 900; }
.tagline { color: var(--muted); font-size: 14px; }
.app-header nav { display: flex; align-items: center; gap: 18px; }
.app-header nav a, .link-button { text-decoration: none; font-size: 14px; }
.link-button { border: 0; padding: 0; background: transparent; }

.home-grid { width: min(1180px, 92vw); margin: 55px auto; display: grid; grid-template-columns: 1fr 390px; gap: 60px; align-items: start; }
.welcome-panel h1 { font-size: clamp(42px, 7vw, 82px); line-height: .95; max-width: 800px; margin: 10px 0 22px; letter-spacing: -4px; }
.welcome-panel > p { max-width: 680px; color: var(--muted); font-size: 18px; line-height: 1.6; }
.eyebrow { font-size: 12px; letter-spacing: 2px; font-weight: 900; color: var(--muted); }
.auth-card, .settings-card, .admin-card, .profile-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 26px; }
.stack-form { display: grid; gap: 16px; }
.stack-form.compact { gap: 10px; }
.primary-button { background: var(--dark); color: #fff; }
.primary-button:hover { background: #333; }
.alert { padding: 10px 12px; background: var(--soft); border-radius: 5px; margin-bottom: 14px; }
.alert.error { border-left: 4px solid var(--danger); }
.announcement-list { margin-top: 55px; max-width: 760px; }
.announcement-card { border-top: 1px solid var(--line); padding: 22px 0; }
.announcement-card h3 { margin: 0 0 8px; }
.announcement-card p { white-space: pre-wrap; line-height: 1.55; }
.announcement-card small { color: var(--muted); }

.chat-layout { min-height: calc(100vh - 68px); display: grid; grid-template-columns: 270px 1fr; }
.room-sidebar { border-right: 1px solid var(--line); background: #eeeeda; padding: 22px 14px; }
.sidebar-title { padding: 0 10px 18px; font-weight: 900; }
.room-category { margin-bottom: 26px; }
.room-category h3 { margin: 0 10px 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }
.room-link { display: flex; justify-content: space-between; gap: 10px; padding: 10px; border-radius: 5px; text-decoration: none; font-size: 14px; }
.room-link:hover, .room-link.active { background: var(--panel); }
.room-link.restricted { color: var(--muted); opacity: .62; cursor: not-allowed; user-select: none; }
.room-link.restricted:hover { background: transparent; }
.room-badges { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.room-badges small { font-size: 10px; color: var(--muted); white-space: nowrap; }
.chat-access-alert { margin: 14px 24px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 5px; background: #fff; font-size: 13px; }
.chat-panel { display: grid; grid-template-rows: auto 1fr auto auto; min-width: 0; background: var(--panel); }
.chat-room-header { padding: 18px 25px; border-bottom: 1px solid var(--line); }
.chat-room-header h1 { margin: 0; font-size: 19px; }
.chat-room-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.messages { overflow-y: auto; padding: 20px 25px; }
.message-item { display: grid; grid-template-columns: 40px 1fr; gap: 12px; padding: 10px 0; }
.message-item p { margin: 5px 0 0; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-meta { display: flex; gap: 10px; align-items: baseline; }
.message-meta a { font-weight: 800; text-decoration: none; }
.message-meta time { font-size: 11px; color: var(--muted); }
.profile-avatar { width: 38px; height: 38px; display: grid; place-items: center; overflow: hidden; border-radius: 50%; background: var(--dark); color: #fff; font-weight: 900; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.message-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 16px 25px 22px; border-top: 1px solid var(--line); }
.chat-error { margin: 0 25px; background: #fff2f2; color: var(--danger); padding: 10px; border-radius: 5px; }
.empty-state, .empty-page { padding: 50px; }

.profile-wrap, .admin-wrap { width: min(1100px, 92vw); margin: 45px auto; }
.profile-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.profile-card { display: flex; align-items: center; gap: 24px; }
.profile-avatar.large { width: 110px; height: 110px; font-size: 38px; flex: 0 0 auto; }
.profile-card h1 { margin: 4px 0 12px; }
.profile-bio { color: var(--muted); line-height: 1.55; white-space: pre-wrap; }
.page-heading { margin-bottom: 25px; }
.page-heading h1 { margin: 5px 0; font-size: 42px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.wide-card { grid-column: 1 / -1; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; }
.admin-row, .user-admin-row, .announcement-admin-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; border-top: 1px solid var(--line); padding: 14px 0; }
.user-admin-row small { display: block; color: var(--muted); margin-top: 4px; }
.row-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.small-form input { width: 74px; }
.danger-button { border-color: #caa; color: var(--danger); }
.announcement-admin-row p { margin: 5px 0 0; color: var(--muted); max-width: 680px; white-space: pre-wrap; }

@media (max-width: 820px) {
  .home-grid, .profile-wrap, .admin-grid { grid-template-columns: 1fr; }
  .welcome-panel h1 { letter-spacing: -2px; }
  .chat-layout { grid-template-columns: 1fr; }
  .room-sidebar { border-right: 0; border-bottom: 1px solid var(--line); max-height: 220px; overflow-y: auto; }
  .wide-card { grid-column: auto; }
  .user-admin-row, .announcement-admin-row { align-items: flex-start; flex-direction: column; }
  .row-actions { justify-content: flex-start; }
  .site-header, .app-header { padding: 0 20px; }
}

/* Community tools: keep the original simple layout. */
[hidden] { display: none !important; }
:root { --bg: #fff; }
.room-sidebar { background: #f7f7f7; }
.chat-layout { height: calc(100dvh - 68px); min-height: 500px; }
.chat-panel { display: flex; flex-direction: column; overflow: hidden; }
.chat-room-header, .pinned-section, .connection-status, .reply-preview, .message-form { flex-shrink: 0; }
.messages { flex: 1; min-height: 100px; }
.message-body { min-width: 0; }
.message-meta { flex-wrap: wrap; }
.message-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 8px; }
.message-actions button { font-size: 12px; padding: 4px 9px; border-color: var(--line); }
.message-item:focus { outline: 2px solid #56748e; outline-offset: 2px; }
.mentioned-message { background: #fff8df; border-left: 3px solid #bb8b11; padding-left: 10px; }
.mention { color: #174c80; background: #eaf2fa; font-weight: 700; border-radius: 3px; padding: 1px 3px; }
.mention-self { background: #ffe6a0; color: #513d08; }
.reply-quote { display: block; text-align: left; font-size: 12px; color: #555; border: 0; border-left: 3px solid #aaa; border-radius: 0; background: #f6f6f6; padding: 7px 10px; margin-top: 8px; max-width: 100%; overflow-wrap: anywhere; }
.reply-preview { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #f6f6f6; padding: 10px 25px; font-size: 13px; }
.reply-preview span { overflow-wrap: anywhere; min-width: 0; }
.reply-preview button { flex-shrink: 0; font-size: 12px; }
.pinned-section { padding: 10px 25px; border-bottom: 1px solid var(--line); max-height: 200px; overflow-y: auto; background: #fafafa; }
summary { cursor: pointer; font-weight: 700; }
.pinned-item { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.pinned-link { text-align: left; flex: 1; font-size: 13px; border-color: var(--line); overflow-wrap: anywhere; min-width: 0; }
.pin-label { font-size: 11px; color: #66530c; background: #fff2bc; padding: 2px 5px; }
.deleted-message, .muted { color: var(--muted); }
.deleted-message { font-style: italic; }
.connection-status { font-size: 11px; color: var(--muted); margin: 8px 25px 0; }
.chat-notice { padding: 10px 25px; background: #edf5ec; font-size: 13px; }
.preserve-lines, .report-card blockquote, .report-preview { white-space: pre-wrap; overflow-wrap: anywhere; }
.admin-nav { display: flex; flex-wrap: wrap; gap: 15px; margin-bottom: 25px; }
.report-card, .edit-card { border-top: 1px solid var(--line); padding: 18px 0; margin-top: 14px; overflow-wrap: anywhere; }
.report-card h3 { font-size: 16px; margin-top: 0; }
.report-card blockquote { background: #f7f7f7; padding: 12px; border-left: 3px solid #aaa; margin: 10px 0; }
.edit-card > form + form, .edit-card > .row-actions { margin-top: 10px; }
.admin-message-list { max-height: 500px; overflow-y: auto; }
dialog { width: min(520px, 92vw); max-height: 85dvh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 25px; }
dialog::backdrop { background: rgb(0 0 0 / 35%); }
.form-error { color: var(--danger); }
button:disabled { opacity: .5; cursor: not-allowed; }
#room-description { white-space: pre-wrap; max-height: 90px; overflow-y: auto; font-size: 13px; }
@media (max-width: 820px) {
  .chat-layout { grid-template-rows: auto minmax(0, 1fr); }
  .room-sidebar { max-height: 160px; }
  .messages { padding: 12px; }
  .message-form, .reply-preview { padding: 12px; }
  .chat-room-header, .pinned-section { padding: 12px; }
  .chat-room-header h1 { overflow-wrap: anywhere; }
  .app-header nav { gap: 10px; }
  .inline-form { flex-wrap: wrap; }
}

.account-action-wrap { width: min(520px, 92vw); margin: 50px auto; }
.account-action-wrap h1 { font-size: 26px; line-height: 1.2; }
.account-action-wrap p, .recovery-settings p { line-height: 1.5; overflow-wrap: anywhere; }
.account-links { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 24px; font-size: 14px; }
.form-help { color: var(--muted); font-size: 13px; margin: 0; font-weight: normal; }
.optional-label { font-size: 12px; font-weight: normal; color: var(--muted); }
.recovery-settings { grid-column: 1 / -1; }
.recovery-settings > form { max-width: 520px; }
.remove-email { margin-top: 25px; max-width: 520px; }

.kudos-panel { margin: 15px 0; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.kudos-summary { margin: 0 0 7px; display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.kudos-label { font-size: 12px; color: #555; background: #f1f1f1; border-radius: 4px; padding: 3px 6px; }
.kudos-help { font-size: 12px; line-height: 1.5; color: #666; margin: 7px 0; }
.kudos-actions { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0; }
.kudos-actions button { padding: 8px 10px; font-size: 13px; }
.kudos-vote[value="1"][aria-pressed="true"] { background: #18743b; border-color: #18743b; color: #fff; }
.kudos-vote[value="-1"][aria-pressed="true"] { background: #b4232c; border-color: #b4232c; color: #fff; }
.kudos-vote:focus-visible { outline: 2px solid #174c80; outline-offset: 3px; }
.message-author { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; max-width: 100%; }
.message-author > a { overflow-wrap: anywhere; min-width: 0; }
.message-item { grid-template-columns: 40px minmax(0, 1fr) auto; }
.chat-kudos { display: inline-flex; gap: 4px; flex-shrink: 0; align-self: start; justify-self: end; }
.chat-kudos button { width: 28px; height: 28px; padding: 0; border-radius: 50%; font-size: 17px; font-weight: 700; line-height: 1; border-color: #aaa; }
.chat-kudos.has-voted button { opacity: 0; }
.chat-kudos.has-voted:hover button,
.chat-kudos.has-voted:has(:focus-visible) button { opacity: 1; }
.message-menu-trigger { width: 26px; height: 26px; flex-shrink: 0; border-radius: 50%; padding: 0; border-color: var(--line); font-size: 20px; line-height: 1; }
.message-menu-trigger:focus-visible { outline: 2px solid #174c80; outline-offset: 2px; }
.message-actions.message-menu { position: fixed; z-index: 100; display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 5px; min-width: 130px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: 0 4px 16px rgb(0 0 0 / 12%); }
.message-menu button { text-align: left; padding: 8px 10px; border: 0; font-size: 13px; }
.message-menu button:focus-visible { outline: 2px solid #174c80; outline-offset: -2px; }
.chat-kudos-status { flex-shrink: 0; font-size: 13px; margin: 8px 25px 0; }
@media (hover: none) {
  .chat-kudos.has-voted:focus-within button,
  .chat-kudos.has-voted.touch-revealed button { opacity: 1; }
}
@media (max-width: 480px) {
  .message-item { column-gap: 8px; }
  .chat-kudos { flex-direction: column; }
}

.sidebar-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 18px; }
.sidebar-tabs a { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px; border-radius: 5px; font-size: 13px; text-decoration: none; text-align: center; }
.sidebar-tabs a:hover { background: var(--soft); }
.sidebar-tabs a[aria-current="page"] { background: var(--dark); color: #fff; }
.leaderboard-layout { height: auto; min-height: calc(100dvh - 68px); align-items: start; }
.leaderboard-layout .room-sidebar { align-self: stretch; }
.leaderboard-panel { min-width: 0; padding: 26px; max-width: 1050px; width: 100%; }
.leaderboard-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.leaderboard-heading h1 { margin: 0 0 8px; font-size: 26px; }
.leaderboard-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.refresh-rankings { padding: 10px 12px; border: 1px solid var(--line); border-radius: 5px; font-size: 13px; }
.leaderboard-help { color: #666; font-size: 13px; line-height: 1.5; }
.leaderboard-table { width: 100%; border-collapse: collapse; margin: 24px 0; table-layout: fixed; }
.leaderboard-table caption { text-align: left; font-size: 13px; color: #555; padding-bottom: 12px; }
.leaderboard-table th, .leaderboard-table td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; }
.leaderboard-table th { font-size: 12px; color: #555; background: #f7f7f7; }
.leaderboard-table th:first-child { width: 64px; }
.leaderboard-table th:last-child { width: 82px; text-align: right; }
.leaderboard-table td:last-child { text-align: right; }
.leaderboard-user { display: flex; align-items: center; gap: 12px; font-weight: 700; text-decoration: none; }
.leaderboard-user:hover .leaderboard-username { text-decoration: underline; }
.leaderboard-user .profile-avatar { flex-shrink: 0; }
.leaderboard-username { min-width: 0; overflow-wrap: anywhere; }
.leaderboard-you { font-size: 12px; font-weight: normal; color: #555; }
.leaderboard-self { background: #f0f5fa; }
.leaderboard-rank, .leaderboard-score { font-variant-numeric: tabular-nums; }
.leaderboard-score { font-weight: 700; }
.leaderboard-score.positive { color: #18743b; }
.leaderboard-score.negative { color: #b4232c; }
.leaderboard-pagination { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.leaderboard-pagination a, .leaderboard-pagination > span { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 38px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 5px; font-size: 13px; text-decoration: none; }
.leaderboard-pagination a:hover { background: var(--soft); }
.leaderboard-pagination a[aria-current="page"] { background: var(--dark); color: #fff; border-color: var(--dark); }
.leaderboard-pagination > span { color: #777; background: #f7f7f7; }
@media (max-width: 820px) {
  .room-sidebar { max-height: 220px; }
  .leaderboard-layout { grid-template-rows: auto auto; }
  .leaderboard-panel { padding: 20px 12px; }
}
@media (max-width: 520px) {
  .leaderboard-table th, .leaderboard-table td { padding: 10px 6px; }
  .leaderboard-table th:first-child { width: 46px; }
  .leaderboard-table th:last-child { width: 60px; }
  .leaderboard-user { gap: 8px; font-size: 14px; }
  .leaderboard-user .profile-avatar { width: 30px; height: 30px; }
}
#kudos-status { font-size: 13px; line-height: 1.4; }
.kudos-tooltip { position: fixed; z-index: 10000; pointer-events: none; background: #222; color: #fff; font-size: 13px; line-height: 1.4; border-radius: 5px; padding: 9px 12px; max-width: calc(100vw - 16px); box-shadow: 0 3px 12px #0002; }
.profile-card > div:last-child { min-width: 0; }
@media (max-width: 520px) {
  .profile-card { align-items: flex-start; flex-direction: column; gap: 14px; }
  .profile-card h1 { overflow-wrap: anywhere; }
}

.admin-tabs { display: flex; gap: 8px; margin: 20px 0; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.admin-tabs a { padding: 12px 18px; text-decoration: none; border-radius: 5px; }
.admin-tabs a[aria-current="page"] { background: #151515; color: white; }
.analytics-wrap { width: min(1280px, 94vw); }
.analytics-filters { display: flex; align-items: end; flex-wrap: wrap; gap: 14px; background: #f7f7f7; padding: 18px; border: 1px solid var(--line); border-radius: 6px; }
.analytics-filters input { max-width: 210px; }
.analytics-presets, .analytics-jumps { display: flex; flex-wrap: wrap; gap: 14px; font-size: 14px; padding: 10px 0; }
.analytics-note { font-size: 13px; line-height: 1.6; color: #626262; overflow-wrap: anywhere; }
.analytics-metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; margin-top: 20px; }
.analytics-metric { border: 1px solid var(--line); border-radius: 6px; padding: 20px; min-width: 0; }
.analytics-metric h2 { font-size: 14px; margin: 0 0 12px; color: #555; }
.analytics-metric > strong { font-size: 36px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.analytics-metric p { font-size: 12px; color: #666; line-height: 1.5; margin-bottom: 0; }
.analytics-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 20px; margin-top: 22px; }
.analytics-grid > section { min-width: 0; scroll-margin-top: 16px; }
.analytics-grid h2 { font-size: 20px; margin-top: 0; }
.analytics-wide { grid-column: 1/-1; }
.analytics-bars { padding: 0; list-style: none; margin: 20px 0; }
.analytics-bars li { margin-bottom: 13px; }
.analytics-bars li > div:first-child { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; margin-bottom: 6px; }
.analytics-bars span { overflow-wrap: anywhere; }
.analytics-bar-track { height: 7px; background: #eee; border-radius: 3px; overflow: hidden; }
.analytics-bar-track > span { display: block; height: 100%; background: #175b88; }
.analytics-line-chart { display: block; width: 100%; max-height: 260px; margin-top: 20px; }
.analytics-line-chart text { font-size: 12px; fill: #555; }
.analytics-legend { display: flex; flex-wrap: wrap; gap: 24px; font-size: 13px; }
.analytics-legend span:first-child { color: #175b88; }
.analytics-legend span:last-child { color: #8d4a00; }
.analytics-table-wrap { max-height: 430px; overflow: auto; margin: 15px 0; }
.analytics-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.analytics-table td, .analytics-table th { padding: 12px 9px; text-align: left; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.analytics-table th { background: #f6f6f6; position: sticky; top: 0; }
.analytics-facts { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 13px; font-size: 14px; }
.analytics-facts dt { line-height: 1.5; }
.analytics-facts dd { margin: 0; font-weight: 700; text-align: right; max-width: 220px; }
.analytics-hours { display: grid; grid-template-columns: repeat(24,minmax(20px,1fr)); overflow-x: auto; gap: 5px; padding-bottom: 12px; }
.analytics-hours > div { display: flex; flex-direction: column; align-items: center; gap: 5px; font-size: 11px; }
.hour-track { display: flex; align-items: end; height: 110px; width: 100%; background: #f4f4f4; }
.hour-track i { display: block; width: 100%; background: #175b88; }
.analytics-insights { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.analytics-insights article { background: #f7f9fb; border-left: 3px solid #175b88; padding: 16px; }
.analytics-insights h3 { margin: 0; font-size: 16px; }
.analytics-insights p { font-size: 14px; line-height: 1.6; }
.analytics-public-note { max-width: 1100px; margin: 30px auto; padding: 0 20px; font-size: 13px; color: #666; }
@media (max-width: 820px) {
  .analytics-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .analytics-grid, .analytics-insights { grid-template-columns: 1fr; }
  .analytics-wrap .page-heading h1 { font-size: 30px; }
}
@media (max-width: 420px) {
  .analytics-metric { padding: 12px; }
  .analytics-grid .admin-card { padding: 16px; }
  .analytics-facts { grid-template-columns: 1fr; gap: 8px; }
  .analytics-facts dd { text-align: left; margin-bottom: 10px; }
}

/* Admin moderation and drill-downs */
.moderation-filters { display:grid; grid-template-columns:repeat(auto-fit,minmax(210px,1fr)); gap:14px; align-items:end; margin:18px 0; }
.moderation-filters label { display:grid; gap:6px; font-size:.9rem; }
.check-label { display:flex !important; align-items:center; gap:8px; font-size:.9rem; }
.check-label input[type=checkbox] { width:18px; height:18px; flex:0 0 18px; margin:0; }
.bulk-toolbar { display:flex; align-items:center; gap:14px; flex-wrap:wrap; padding:14px; border:1px solid #ddd; border-radius:8px; background:#fafafa; }
.pagination { display:flex; gap:20px; align-items:center; margin-top:16px; }
.admin-notice { padding:14px; border:1px solid #b7d4c0; background:#f1faf4; border-radius:8px; }
.user-admin-row { flex-wrap:wrap; gap:18px; }
.user-admin-row .stack-form { max-width:320px; }
.analytics-metric a { color:inherit; text-underline-offset:4px; }
.analytics-table td { vertical-align:top; }
.analytics-table td small { display:block; color:#666; }
.analytics-table .message-text { min-width:230px; white-space:pre-wrap; overflow-wrap:anywhere; }
button:disabled { opacity:.5; cursor:not-allowed; }
@media(max-width:650px) { .moderation-filters { grid-template-columns:1fr; } .bulk-toolbar { align-items:flex-start; flex-direction:column; } }
.moderation-filters label { min-width:0; }
.moderation-filters input, .moderation-filters select { min-width:0; max-width:100%; }
@media(min-width:651px) { .moderation-filters { grid-template-columns:repeat(auto-fit,minmax(280px,1fr)); } }

/* v2.7: shared navigation, room polls and member feedback. */
.app-header { position: sticky; top: 0; z-index: 20; }
.app-header nav { flex-wrap: wrap; justify-content: flex-end; padding: 12px 0; }
.brand { overflow-wrap: anywhere; max-width: 45%; letter-spacing: 2px; }
.home-tagline { width: min(1180px,92vw); margin: 20px auto 0; color: var(--muted); }
.button-link { display: inline-block; border: 1px solid var(--dark); padding: 10px 14px; border-radius: 5px; text-decoration: none; }
.room-sidebar { display: flex; flex-direction: column; overflow-y: auto; min-height: 0; }
.room-category summary { padding: 8px 10px; font-size: 13px; letter-spacing: 1px; overflow-wrap: anywhere; }
.room-category { margin-bottom: 12px; }
.suggestion-box { margin-top: auto; border-top: 1px solid var(--line); padding: 18px 8px 0; }
.suggestion-box summary { font-size: 15px; margin: 0; }
.suggestion-box p { font-size: 12px; line-height: 1.5; }
.suggestion-box label { font-size: 12px; }
.suggestion-box .stack-form { gap: 8px; }
#suggestion-status:empty, #poll-status:empty { display: none; }
.room-polls { flex-shrink: 0; max-height: 38vh; overflow-y: auto; padding: 12px 25px; border-bottom: 1px solid var(--line); background: #fafafa; }
.poll-card { border-top: 1px solid var(--line); padding: 10px 0; }
.poll-card h3 { font-size: 16px; margin: 4px 0; overflow-wrap: anywhere; }
.poll-card p { font-size: 13px; }
.poll-card fieldset { border: 0; padding: 0; margin: 10px 0; }
.poll-card legend { font-size: 12px; margin-bottom: 8px; }
.poll-option { display: flex; gap: 8px; align-items: start; margin-bottom: 8px; font-weight: normal; overflow-wrap: anywhere; }
.poll-option input, .check-label input[type="radio"] { width: auto; flex-shrink: 0; margin-top: 2px; }
.poll-admin-list { margin-top: 24px; }
#poll-room-choices { margin-top: 14px; display: grid; gap: 10px; }
:focus-visible { outline: 2px solid #174c80; outline-offset: 3px; }
@media(max-width: 820px) {
  .app-header { gap: 10px; padding: 8px 12px; min-height: 68px; }
  .app-header nav { gap: 12px; }
  .brand { font-size: 18px; }
  .room-sidebar { max-height: 240px; }
  .suggestion-box { margin-top: 16px; }
  .room-polls { padding: 12px; max-height: 30vh; }
}

/* Ignoring changes only the current member's view, without hiding messages. */
.message-item.ignored-message { background: transparent; border-color: var(--line); }
.ignored-message .message-body > p,
.ignored-message .message-body > p a,
.ignored-message .message-meta a,
.ignored-message .message-meta time,
.ignored-message .reply-quote,
.reply-quote.ignored-message,
.ignored-message .pinned-link { color: #a3a3a3; font-style: italic; }
.ignored-message .mention { background: transparent; }
.ignored-message .profile-avatar { opacity: .45; }
.download-link { display: inline-block; border: 1px solid var(--line); border-radius: 5px; padding: 10px 14px; text-decoration: none; }

/* Collapsible profile settings and keyboard focus. */
#ignored-users { align-self: start; }
#ignored-users > summary { font-size: 1.25rem; }
.suggestion-box > summary:focus-visible, #ignored-users > summary:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; border-radius: 2px; }
.admin-tabs { flex-wrap: wrap; }

/* Security event details remain readable inside their horizontal scroll container. */
#events .analytics-table, #ip-bans .analytics-table { min-width: 760px; }
#events .analytics-table td:first-child, #ip-bans .analytics-table td:first-child { white-space: nowrap; }

.security-page .admin-card { min-width: 0; }

/* v2.15: explicit Safari control colours and responsive community layout. */
button { color: var(--text); -webkit-text-fill-color: currentColor; }
input, textarea, select { color: var(--text); -webkit-text-fill-color: currentColor; min-width: 0; }
input::placeholder, textarea::placeholder { -webkit-text-fill-color: #777; }
.primary-button, .kudos-vote[aria-pressed="true"] { -webkit-text-fill-color: currentColor; }
button:disabled { opacity: 1; color: #666; background: #f1f1f1; border-color: #aaa; }
input:disabled { -webkit-text-fill-color: #666; }
.app-header { gap: 16px; }
.app-header nav { min-width: 0; }
.app-header nav a, .link-button { white-space: nowrap; }
.home-grid .welcome-panel { grid-column: 1; grid-row: 1; }
.home-grid .auth-card { grid-column: 2; grid-row: 1; }
.sidebar-toggle { display: inline-grid; place-items: center; width: 44px; height: 44px; min-height: 44px; padding: 0; margin: 0; border: 0; border-radius: 50%; color: #111; background: transparent; flex: 0 0 44px; }
.sidebar-toggle:hover { background: var(--soft); }
.sidebar-toggle svg { display: block; }
.sidebar-chevron { transform-origin: 16px 16px; }
.sidebar-toggle[aria-expanded="false"] .sidebar-chevron { transform: rotate(180deg); }
.chat-room-header { display: flex; align-items: center; gap: 12px; }
.room-title-content, .leaderboard-title-content { min-width: 0; }
.leaderboard-title-content { flex: 1; }
.chat-layout { position: relative; }
.sidebar-content { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sidebar-scroll { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sidebar-tabs a { border: 1px solid var(--dark); flex: 1; }
.sidebar-tabs a[aria-current="page"] { border-color: var(--dark); }
.chat-layout { height: calc(100dvh - var(--header-height, 68px)); min-height: 0; grid-template-columns: 270px minmax(0,1fr); }
.chat-layout.sidebar-collapsed { grid-template-columns: minmax(0,1fr); }
.chat-layout.sidebar-collapsed .room-sidebar { padding: 12px 8px; }
.leaderboard-layout { height: auto; min-height: calc(100dvh - var(--header-height, 68px)); }
.room-sidebar { max-height: none; }
.message-form { grid-template-columns: minmax(0,1fr) auto; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.profile-card { align-items: flex-start; }
.profile-bio { margin: 16px 0; overflow-wrap: anywhere; }
.kudos-actions button { min-height: 44px; }
.account-editor { width: 100%; border-top: 1px solid var(--line); padding-top: 12px; }
.user-admin-row .account-editor .stack-form { max-width: 600px; margin: 14px 0; }
.account-meta { overflow-wrap: anywhere; }
@media (max-width: 820px) {
  .app-header { padding: 10px 12px; flex-wrap: wrap; }
  .brand { max-width: 100%; font-size: 20px; }
  .app-header nav { flex: 1 1 220px; gap: 8px 14px; padding: 0; }
  .app-header nav a, .link-button { min-height: 36px; display: inline-flex; align-items: center; }
  .home-grid { gap: 28px; margin: 24px auto; }
  .home-grid .auth-card { grid-column: 1; grid-row: 1; }
  .home-grid .welcome-panel { grid-column: 1; grid-row: 2; }
  .chat-layout, .chat-layout.sidebar-collapsed { grid-template-columns: minmax(0,1fr); grid-template-rows: auto minmax(0,1fr); }
  .room-sidebar, .chat-layout.sidebar-collapsed .room-sidebar { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .sidebar-toggle { margin: 0; align-self: center; }
  .sidebar-content { margin: 0; max-height: none; overflow-y: auto; flex: 1; }
  .leaderboard-layout { grid-template-rows: auto auto; }
  .messages { min-height: 0; }
  input, textarea, select { font-size: 16px; }
  .message-meta { gap: 5px 8px; }
  .message-meta time { flex-basis: 100%; }
  .auth-card, .profile-card, .settings-card { padding: 20px; min-width: 0; }
}

/* v2.15.1: title-bar arrow and right-hand homepage login. */
.home-grid { grid-template-columns: minmax(0, 1fr) minmax(320px, 390px); grid-template-areas: "welcome login"; }
.home-grid .welcome-panel { grid-area: welcome; }
.home-grid .auth-card { grid-area: login; width: 100%; justify-self: end; }
@media (max-width: 820px) {
  .home-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "login" "welcome"; }
  .chat-layout, .chat-layout.sidebar-collapsed { grid-template-rows: minmax(0,1fr); }
  .room-sidebar { position: absolute; z-index: 25; top: var(--sidebar-top, 80px); bottom: 0; left: 0; width: min(320px, 92vw); max-height: none; padding: 16px; border-right: 1px solid var(--line); border-bottom: 0; box-shadow: 4px 0 14px #0002; }
  .leaderboard-layout .room-sidebar { bottom: auto; height: min(65dvh, 600px); }
  .leaderboard-layout { grid-template-rows: auto; }
}

/* Mobile chat directory unfolds below the title and makes space in the chat. */
@media (max-width: 820px) {
  .chat-panel { min-height: 0; }
  :is(.chat-panel, .leaderboard-panel) > .room-sidebar,
  .sidebar-collapsed :is(.chat-panel, .leaderboard-panel) > .room-sidebar {
    position: static; z-index: auto; width: 100%; height: auto; max-height: none;
    padding: 0; border: 0; box-shadow: none; overflow: hidden; flex-shrink: 0;
    display: grid; grid-template-rows: 1fr; visibility: visible;
    transition: grid-template-rows 200ms ease, visibility 0s;
  }
  .sidebar-collapsed :is(.chat-panel, .leaderboard-panel) > .room-sidebar {
    grid-template-rows: 0fr; visibility: hidden;
    transition: grid-template-rows 200ms ease, visibility 0s 200ms;
  }
  :is(.chat-panel, .leaderboard-panel) > .room-sidebar .sidebar-content { overflow: hidden; min-height: 0; }
  :is(.chat-panel, .leaderboard-panel) > .room-sidebar .sidebar-scroll {
    max-height: min(40dvh, 320px); overflow-y: auto; overscroll-behavior-y: contain;
    padding: 14px 12px; border-bottom: 1px solid var(--line);
  }
}
@media (max-width: 820px) and (prefers-reduced-motion: reduce) {
  :is(.chat-panel, .leaderboard-panel) > .room-sidebar,
  .sidebar-collapsed :is(.chat-panel, .leaderboard-panel) > .room-sidebar { transition: none; }
}

/* v2.15.2: compact title-row control, with no native rectangular button. */
.chat-room-header { display: block; }
.room-title-row { display: flex; align-items: center; flex-wrap: nowrap; gap: 8px; min-width: 0; }
.room-title-row h1 { margin: 0; min-width: 0; }
.chat-room-header .room-title-row h1 { line-height: 24px; }
#room-description:empty { display: none; }
.room-title-content { width: 100%; }
.chat-room-header .sidebar-toggle, .leaderboard-heading .sidebar-toggle {
  -webkit-appearance: none; appearance: none; display: inline-flex; align-items: center; justify-content: center;
  position: relative; width: 24px; height: 24px; min-height: 0; flex: 0 0 24px;
  margin: 0; padding: 0; border: 0 !important; border-radius: 50%;
  background: transparent !important; box-shadow: none !important; color: #000; -webkit-text-fill-color: #000;
  outline: none; line-height: 1;
}
.sidebar-toggle::before { content: ''; position: absolute; inset: -10px; border-radius: 50%; }
.sidebar-toggle svg { display: block; width: 24px; height: 24px; pointer-events: none; }
.sidebar-toggle:focus-visible svg circle { stroke: #174c80; stroke-width: 3; }
.sidebar-chevron { transform-origin: 16px 16px; transform: none; }
.sidebar-toggle[aria-expanded="false"] .sidebar-chevron { transform: rotate(180deg); }
@media (max-width: 820px) {
  .sidebar-toggle[aria-expanded="true"] .sidebar-chevron { transform: rotate(90deg); }
  .sidebar-toggle[aria-expanded="false"] .sidebar-chevron { transform: rotate(270deg); }
  .app-header form[action="/logout"] button,
  #message-form button,
  #kudos-form button,
  .chat-kudos button {
    -webkit-appearance: none; appearance: none;
    color: #000 !important; -webkit-text-fill-color: #000 !important; opacity: 1 !important;
  }
  #kudos-form .kudos-vote[value="1"][aria-pressed="true"], .chat-kudos .kudos-vote[value="1"][aria-pressed="true"] { background: #e8f5eb; }
  #kudos-form .kudos-vote[value="-1"][aria-pressed="true"], .chat-kudos .kudos-vote[value="-1"][aria-pressed="true"] { background: #fbeaec; }
}

/* Priority 2 controls */
.member-results { max-height: min(70dvh, 760px); overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.member-results:focus-visible { outline: 2px solid #175b88; outline-offset: 3px; }
.visitor-tile { display: block; color: inherit; text-decoration: none; }
.visitor-tile:hover, .visitor-tile:focus-visible { border-color: #175b88; box-shadow: 0 0 0 2px #175b8822; }
.profile-avatar { overflow: hidden; flex-shrink: 0; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-editor { border: 1px solid var(--line); border-radius: 8px; padding: 16px; min-width: 0; }
.avatar-editor input[type=range] { width: 100%; min-height: 36px; padding: 0; }
.avatar-preview { width: 180px; height: 180px; margin: 12px auto; touch-action: none; cursor: grab; }
.avatar-preview:active { cursor: grabbing; }
.message-reactions { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
.reaction-button { background: #f5f5f5; color: #333; border: 1px solid #ddd; border-radius: 20px; min-width: 36px; min-height: 32px; padding: 4px 8px; font-size: 14px; }
.reaction-button[aria-pressed=true] { border-color: #175b88; background: #e7f1fa; color: #124568; }
.chat-link { overflow-wrap: anywhere; }
.settings-card > summary { font-weight: 700; cursor: pointer; }
@media (max-width: 820px) {
  .leaderboard-panel > .room-sidebar { margin: 12px 0; }
  .sidebar-collapsed .leaderboard-panel > .room-sidebar { margin: 0; }
  .reaction-button { min-height: 40px; min-width: 40px; }
  .member-results { max-height: 65dvh; }
}

.visitor-details > .admin-card { margin: 16px 0; }
