:root {
  --green-950: #042b19;
  --green-900: #063d21;
  --green-800: #07562b;
  --green-700: #0b7138;
  --green-600: #159447;
  --green-100: #e4f2e7;
  --green-50: #f1f8f2;
  --paper: #fffdf8;
  --muted: #6e7b74;
  --line: #d9e4db;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  background: #dceadd;
  color: #173126;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button,
a,
label {
  -webkit-tap-highlight-color: transparent;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.chat-loading {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  background:
    radial-gradient(circle at 50% 35%, rgba(21, 148, 71, 0.18), transparent 22rem),
    var(--paper);
  color: var(--green-900);
}

.chat-loading img {
  object-fit: contain;
}

.chat-app {
  width: 100%;
  height: 100dvh;
  min-height: 560px;
  display: grid;
  grid-template-columns: minmax(265px, 310px) minmax(0, 1fr) minmax(215px, 250px);
  overflow: hidden;
  background: var(--paper);
}

.online-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.98);
}

.online-panel-header {
  min-height: 70px;
  padding: 12px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.online-panel-header strong,
.online-panel-label {
  display: block;
}

.online-panel-header strong {
  margin-top: 3px;
  color: var(--green-900);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
}

.online-panel-label {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.online-panel-hint {
  margin: 0;
  padding: 12px 15px 8px;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.4;
}

.online-user-list {
  min-height: 0;
  margin: 0;
  padding: 4px 8px 16px;
  overflow-y: auto;
  list-style: none;
}

.online-user {
  width: 100%;
  padding: 8px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.online-user:hover,
.online-user:focus-visible {
  outline: none;
  background: var(--green-50);
}

.online-user-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green-100);
  color: var(--green-800);
  font-size: 0.72rem;
  font-weight: 850;
}

.online-user-copy {
  min-width: 0;
}

.online-user-copy strong,
.online-user-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.online-user-copy strong {
  color: var(--green-900);
  font-size: 0.78rem;
}

.online-user-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.64rem;
}

.online-user-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-600);
  box-shadow: 0 0 0 3px rgba(21, 148, 71, 0.12);
}

.online-user-empty {
  padding: 18px 8px;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
}

.online-toggle,
.online-close,
.online-backdrop {
  display: none;
}

@media (max-width: 1100px) and (min-width: 761px) {
  .chat-app {
    grid-template-columns: 235px minmax(0, 1fr) 205px;
  }
}

.chat-sidebar {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.98);
}

.sidebar-header {
  padding: 14px 16px 11px;
  border-bottom: 1px solid var(--line);
}

.sidebar-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--green-900);
  text-decoration: none;
}

.sidebar-brand img {
  width: 64px;
  height: 41px;
  object-fit: contain;
  border-radius: 10px;
  background: white;
}

.sidebar-brand strong,
.sidebar-brand small {
  display: block;
}

.sidebar-brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.16rem;
}

.sidebar-brand small {
  color: var(--muted);
  font-size: 0.7rem;
}

.sidebar-section-title {
  padding: 12px 16px 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.district-heading {
  margin-top: 6px;
  border-top: 1px solid var(--line);
}

.district-heading small {
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--green-100);
  color: var(--green-700);
  font-size: 0.57rem;
  letter-spacing: 0.04em;
}

.chat-list-item {
  width: calc(100% - 14px);
  min-height: 64px;
  margin: 3px 7px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 14px;
  text-align: left;
}

button.chat-list-item {
  cursor: pointer;
}

.chat-list-item-active {
  background: linear-gradient(135deg, var(--green-700), var(--green-600));
  box-shadow: 0 8px 20px rgba(7, 86, 43, 0.18);
  color: white;
}

.chat-avatar,
.district-avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  background: white;
  color: var(--green-800);
  font-size: 0.72rem;
  font-weight: 850;
}

.chat-avatar img {
  width: 38px;
  height: 26px;
  object-fit: contain;
}

.chat-avatar img.general-chat-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.chat-list-copy {
  min-width: 0;
}

.chat-list-copy strong,
.chat-list-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-list-copy strong {
  font-size: 0.84rem;
}

.chat-list-copy small {
  margin-top: 2px;
  color: currentColor;
  font-size: 0.68rem;
  opacity: 0.75;
}

.chat-list-status {
  color: #bff1ca;
  font-size: 0.72rem;
}

.district-list {
  min-height: 0;
  margin: 0;
  padding: 0 0 15px;
  overflow-y: auto;
  list-style: none;
}

.chat-list-item-disabled {
  background: transparent;
  color: #66756d;
  cursor: default;
  opacity: 0.66;
}

.chat-list-item-disabled .district-avatar {
  background: var(--green-100);
}

.conversation {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    linear-gradient(rgba(224, 241, 226, 0.88), rgba(224, 241, 226, 0.88)),
    radial-gradient(circle at 15px 15px, rgba(7, 86, 43, 0.13) 2px, transparent 2.5px);
  background-size: auto, 34px 34px;
}

.conversation-header {
  min-height: 70px;
  padding: 10px 17px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid rgba(7, 86, 43, 0.13);
  background: rgba(255, 253, 248, 0.94);
  backdrop-filter: blur(12px);
}

.conversation-avatar {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green-50);
}

.conversation-avatar img {
  width: 42px;
  height: 29px;
  object-fit: contain;
}

.conversation-avatar img.general-chat-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.conversation-title {
  min-width: 0;
}

.conversation-title strong,
.conversation-title span {
  display: block;
}

.conversation-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-title span {
  color: var(--green-600);
  font-size: 0.72rem;
}

.conversation-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.signed-in-user {
  max-width: 190px;
  margin-right: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-button {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--green-800);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 750;
  text-decoration: none;
}

.message-list {
  min-height: 0;
  padding: 24px clamp(14px, 4vw, 56px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  max-width: min(72%, 620px);
  padding: 9px 12px;
  align-self: flex-start;
  border-radius: 6px 17px 17px 17px;
  background: white;
  box-shadow: 0 5px 14px rgba(6, 61, 33, 0.09);
  transition:
    box-shadow 180ms ease,
    background-color 180ms ease;
}

.message.mine {
  align-self: flex-end;
  border-radius: 17px 6px 17px 17px;
  background: #d5f0da;
}

.message.system {
  max-width: 90%;
  align-self: center;
  border-radius: 12px;
  background: rgba(255, 253, 248, 0.86);
}

.message.mentions-me {
  box-shadow:
    0 0 0 2px rgba(225, 154, 37, 0.52),
    0 5px 14px rgba(6, 61, 33, 0.09);
}

.message.is-targeted {
  box-shadow:
    0 0 0 3px rgba(20, 148, 71, 0.42),
    0 8px 20px rgba(6, 61, 33, 0.16);
}

.message-meta {
  margin-bottom: 3px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.message-author {
  color: var(--green-700);
  font-size: 0.76rem;
  font-weight: 800;
}

.message-time {
  color: var(--muted);
  font-size: 0.62rem;
}

.message-reply-reference {
  width: 100%;
  margin: 3px 0 7px;
  padding: 7px 9px;
  display: block;
  overflow: hidden;
  border: 0;
  border-left: 3px solid var(--green-500);
  border-radius: 4px 9px 9px 4px;
  background: rgba(7, 86, 43, 0.07);
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.message-reply-reference:hover {
  background: rgba(7, 86, 43, 0.12);
}

.message-reply-reference strong,
.message-reply-reference small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-reply-reference strong {
  color: var(--green-700);
  font-size: 0.72rem;
}

.message-reply-reference small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.68rem;
}

.message-text {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
  line-height: 1.42;
  white-space: pre-wrap;
}

.mention {
  padding: 1px 3px;
  border-radius: 5px;
  background: rgba(21, 148, 71, 0.11);
  color: var(--green-700);
  font-weight: 800;
}

.message-actions {
  margin: 6px -3px -3px;
  display: flex;
  justify-content: flex-end;
  gap: 3px;
}

.message-actions button {
  padding: 3px 6px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.64rem;
  font-weight: 750;
}

.message-actions button:hover,
.message-actions button:focus-visible {
  background: rgba(7, 86, 43, 0.09);
  color: var(--green-800);
  outline: none;
}

.message-attachment {
  margin: 6px -3px 7px;
  overflow: hidden;
  border-radius: 12px;
  background: #dce8df;
}

.message-attachment img,
.message-attachment video {
  width: 100%;
  max-width: 520px;
  max-height: 480px;
  display: block;
  object-fit: contain;
  background: #102218;
}

.message-form {
  padding: 10px 14px 9px;
  border-top: 1px solid rgba(7, 86, 43, 0.14);
  background: rgba(255, 253, 248, 0.96);
}

.reply-preview {
  max-width: 620px;
  margin: 0 0 8px 56px;
  padding: 8px 9px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(21, 148, 71, 0.24);
  border-left: 4px solid var(--green-500);
  border-radius: 12px;
  background: var(--green-50);
}

.reply-preview-icon {
  color: var(--green-700);
  font-size: 1.2rem;
  text-align: center;
}

.reply-preview-copy {
  min-width: 0;
}

.reply-preview-copy span,
.reply-preview-copy small {
  display: block;
}

.reply-preview-copy span {
  color: var(--green-800);
  font-size: 0.75rem;
}

.reply-preview-copy small {
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-compose-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 8px;
}

.message-compose-row textarea {
  min-height: 46px;
  max-height: 120px;
  padding: 11px 13px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: white;
  color: #173126;
}

.message-compose-row textarea:focus {
  border-color: rgba(21, 148, 71, 0.5);
  box-shadow: 0 0 0 3px rgba(21, 148, 71, 0.1);
}

.attachment-button,
.send-button {
  min-height: 46px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 14px;
  cursor: pointer;
  font-size: 0.77rem;
  font-weight: 800;
}

.attachment-button {
  border: 1px solid var(--line);
  background: var(--green-50);
  color: var(--green-800);
}

.send-button {
  border: 0;
  background: var(--green-700);
  color: white;
}

.send-button:hover {
  background: var(--green-800);
}

.attachment-preview {
  max-width: 620px;
  margin: 0 0 8px 56px;
  padding: 7px 9px 7px 7px;
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--green-50);
}

.attachment-preview-media {
  width: 50px;
  height: 50px;
  overflow: hidden;
  border-radius: 9px;
  background: #dbe8de;
}

.attachment-preview-object {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.attachment-preview-copy {
  min-width: 0;
}

.attachment-preview-copy strong,
.attachment-preview-copy span {
  display: block;
}

.attachment-preview-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
}

.attachment-preview-copy span,
.composer-foot {
  color: var(--muted);
  font-size: 0.65rem;
}

.attachment-remove,
.reply-remove {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: white;
  color: var(--green-900);
  cursor: pointer;
  font-size: 1.15rem;
}

.composer-foot {
  min-height: 19px;
  padding: 4px 2px 0 56px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

#chat-message {
  color: #ac3b32;
  text-align: right;
}

.send-button:disabled,
.attachment-button:has(input:disabled) {
  cursor: wait;
  opacity: 0.58;
}

@media (max-width: 760px) {
  .chat-app {
    grid-template-columns: 112px minmax(0, 1fr);
  }

  .online-panel {
    width: min(320px, 88vw);
    height: 100dvh;
    position: fixed;
    z-index: 30;
    top: 0;
    right: 0;
    transform: translateX(102%);
    box-shadow: -18px 0 50px rgba(4, 43, 25, 0.2);
    transition: transform 220ms ease;
  }

  .online-panel.is-open {
    transform: translateX(0);
  }

  .online-toggle,
  .online-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .online-close {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--green-50);
    color: var(--green-900);
    cursor: pointer;
    font-size: 1.25rem;
  }

  .online-backdrop.is-open {
    display: block;
    position: fixed;
    z-index: 29;
    inset: 0;
    border: 0;
    background: rgba(4, 43, 25, 0.28);
  }

  .sidebar-header {
    padding: 10px 7px;
  }

  .sidebar-brand {
    width: 100%;
    justify-content: center;
  }

  .sidebar-brand img {
    width: 58px;
    height: 38px;
  }

  .sidebar-brand span,
  .sidebar-section-title span,
  .district-heading small,
  .chat-list-copy small {
    display: none;
  }

  .sidebar-section-title {
    justify-content: center;
    padding-inline: 6px;
  }

  .chat-list-item {
    min-height: 57px;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 6px;
    padding: 7px;
    border-radius: 11px;
  }

  .chat-avatar,
  .district-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.61rem;
  }

  .chat-avatar img {
    width: 32px;
    height: 22px;
  }

  .chat-avatar img.general-chat-avatar {
    width: 100%;
    height: 100%;
  }

  .chat-list-copy strong {
    font-size: 0.68rem;
  }

  .chat-list-status {
    display: none;
  }

  .conversation-header {
    min-height: 61px;
    padding: 7px 9px;
  }

  .conversation-avatar {
    width: 40px;
    height: 40px;
  }

  .conversation-avatar img {
    width: 34px;
    height: 24px;
  }

  .conversation-avatar img.general-chat-avatar {
    width: 100%;
    height: 100%;
  }

  .conversation-title strong {
    font-size: 0.82rem;
  }

  .conversation-title span {
    font-size: 0.62rem;
  }

  .signed-in-user,
  .conversation-actions .header-button:first-of-type {
    display: none;
  }

  .header-button {
    min-height: 31px;
    padding: 6px 8px;
    font-size: 0.65rem;
  }

  .message-list {
    padding: 14px 9px;
  }

  .message {
    max-width: 88%;
  }

  .message-form {
    padding: 8px;
  }

  .message-compose-row {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .attachment-button {
    padding: 0;
  }

  .attachment-button-label {
    display: none;
  }

  .send-button {
    grid-column: 1 / -1;
    min-height: 38px;
  }

  .attachment-preview {
    margin-left: 0;
  }

  .reply-preview {
    margin-left: 0;
  }

  .composer-foot {
    padding-left: 2px;
    display: block;
  }

  #chat-message {
    display: block;
    text-align: left;
  }
}

@media (max-width: 470px) {
  .chat-app {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .chat-list-item {
    width: calc(100% - 8px);
    margin-inline: 4px;
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .chat-list-copy strong {
    max-width: 64px;
    text-align: center;
  }

  .conversation-avatar {
    display: none;
  }

  .message-text {
    font-size: 0.86rem;
  }
}
