:root {
  --bg: #d9ebdf;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --line: rgba(31, 58, 44, 0.12);
  --ink: #173127;
  --muted: #5c7768;
  --accent: #1f8f65;
  --accent-dark: #156c4b;
  --incoming: #ffffff;
  --outgoing: #d8f5d1;
  --danger: #b94242;
  --shadow: 0 18px 50px rgba(29, 68, 47, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Trebuchet MS", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.85), transparent 28%),
    linear-gradient(180deg, #e9f6ee 0%, var(--bg) 100%);
}

body {
  -webkit-font-smoothing: antialiased;
}

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

.login-body {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  min-height: 100vh;
  padding: 24px;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
}

.login-shell {
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}

.login-badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(31, 143, 101, 0.12);
  color: var(--accent-dark);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-title {
  margin: 16px 0 8px;
  font-size: 30px;
  line-height: 1.05;
}

.login-text {
  margin: 0 0 20px;
  color: var(--muted);
  line-height: 1.45;
}

.login-form input {
  width: 100%;
  border: 1px solid rgba(31, 58, 44, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.95);
  padding: 14px 16px;
  font-size: 16px;
  color: var(--ink);
  outline: none;
}

.login-form input:focus,
.composer-textarea:focus {
  border-color: rgba(31, 143, 101, 0.5);
  box-shadow: 0 0 0 4px rgba(31, 143, 101, 0.11);
}

.field-label {
  display: block;
  margin: 12px 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.form-error {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(185, 66, 66, 0.1);
  color: var(--danger);
  font-size: 14px;
}

.primary-button {
  border: 0;
  background: linear-gradient(135deg, var(--accent), #2fb882);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 14px 24px rgba(31, 143, 101, 0.24);
}

.primary-button-full {
  width: 100%;
  margin-top: 18px;
  padding: 14px 18px;
}

.chat-body {
  min-height: 100vh;
  padding: 0;
}

.chat-app {
  position: relative;
  min-height: 100vh;
  max-width: 820px;
  margin: 0 auto;
}

.chat-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  max-width: 820px;
  margin: 0 auto;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  padding: 16px 18px 14px;
  background: rgba(238, 247, 242, 0.92);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.header-avatar-shell,
.avatar {
  display: inline-flex;
  border-radius: 50%;
  overflow: hidden;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
}

.header-avatar-shell {
  width: 48px;
  height: 48px;
  -ms-flex-negative: 0;
  flex-shrink: 0;
}

.header-avatar-image,
.avatar img,
.avatar-small,
.media-photo-preview,
.media-video-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-copy {
  min-width: 0;
  padding: 2px 0 0 12px;
}

.group-title {
  display: block;
  font-size: 18px;
  line-height: 1.15;
}

.group-subtitle {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.header-actions {
  margin-left: auto;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  -webkit-box-align: end;
  -ms-flex-align: end;
  align-items: flex-end;
  gap: 6px;
}

.current-user-pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(31, 143, 101, 0.12);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.header-link {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.chat-stage {
  padding: 88px 12px 132px;
}

.chat-loader {
  padding: 18px 12px;
  text-align: center;
  color: var(--muted);
}

.chat-messages {
  min-height: calc(100vh - 220px);
  overflow-y: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.message-row {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  gap: 10px;
  margin: 0 0 14px;
}

.message-row.is-outgoing {
  -webkit-box-orient: horizontal;
  -webkit-box-direction: reverse;
  -ms-flex-direction: row-reverse;
  flex-direction: row-reverse;
}

.message-avatar-slot {
  width: 38px;
  -ms-flex-negative: 0;
  flex-shrink: 0;
}

.avatar-small,
.avatar-fallback {
  width: 38px;
  height: 38px;
  font-size: 15px;
}

.message-body {
  max-width: calc(100% - 48px);
}

.message-row.is-outgoing .message-body {
  text-align: right;
}

.message-meta {
  margin-bottom: 4px;
  padding: 0 4px;
  font-size: 12px;
  color: var(--muted);
}

.message-author {
  font-weight: 700;
  color: #22513d;
}

.message-status {
  display: inline-block;
  margin-left: 8px;
}

.message-status-error {
  color: var(--danger);
}

.message-bubble {
  display: inline-block;
  max-width: 100%;
  padding: 12px 14px;
  background: var(--incoming);
  border-radius: 18px 18px 18px 6px;
  box-shadow: 0 8px 18px rgba(26, 57, 41, 0.08);
  text-align: left;
}

.message-row.is-outgoing .message-bubble {
  background: var(--outgoing);
  border-radius: 18px 18px 6px 18px;
}

.message-bubble-media {
  padding: 8px;
}

.message-text {
  white-space: normal;
  word-break: break-word;
  line-height: 1.42;
  font-size: 15px;
}

.message-bubble-media .message-text {
  padding: 8px 6px 2px;
}

.message-footer {
  margin-top: 4px;
  padding: 0 4px;
  font-size: 11px;
  color: var(--muted);
}

.media-button {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.media-button-photo {
  width: 220px;
  max-width: 100%;
}

.media-photo-preview {
  display: block;
  width: 100%;
  max-width: 220px;
  max-height: 240px;
  border-radius: 16px;
}

.media-button-video,
.media-button-audio {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 12px;
  min-width: 220px;
  padding: 6px 4px;
}

.media-card-thumb {
  display: inline-flex;
  width: 88px;
  height: 66px;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(23, 49, 39, 0.12);
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
}

.media-card-icon {
  display: inline-flex;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(31, 143, 101, 0.15);
  color: var(--accent-dark);
  font-weight: 700;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  font-size: 20px;
}

.media-card-copy {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -ms-flex-direction: column;
  flex-direction: column;
  gap: 4px;
  color: var(--ink);
}

.media-card-copy strong {
  font-size: 14px;
  line-height: 1.2;
}

.media-card-copy span {
  font-size: 12px;
  color: var(--muted);
}

.composer-notice {
  position: fixed;
  left: 50%;
  bottom: 104px;
  z-index: 22;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(23, 49, 39, 0.88);
  color: #fff;
  font-size: 13px;
  text-align: center;
}

.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  max-width: 820px;
  margin: 0 auto;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  gap: 10px;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  background: rgba(238, 247, 242, 0.96);
  border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.composer-icon-button,
.send-button {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  -ms-flex-negative: 0;
  flex-shrink: 0;
  cursor: pointer;
}

.composer-icon-button {
  background: rgba(31, 143, 101, 0.12);
  color: var(--accent-dark);
  font-size: 28px;
  line-height: 48px;
}

.composer-fields {
  -webkit-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(31, 58, 44, 0.15);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.95);
  padding: 8px 12px;
}

.composer-textarea {
  width: 100%;
  min-height: 32px;
  max-height: 120px;
  border: 0;
  padding: 6px 0;
  resize: none;
  background: transparent;
  font-size: 15px;
  line-height: 1.4;
  outline: none;
  color: var(--ink);
}

.file-chip {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(31, 143, 101, 0.09);
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  gap: 10px;
}

.file-chip-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--accent-dark);
}

.file-chip-remove {
  margin-left: auto;
  border: 0;
  background: transparent;
  font-size: 20px;
  color: var(--accent-dark);
  cursor: pointer;
}

.send-button {
  background: linear-gradient(135deg, var(--accent), #2fb882);
  box-shadow: 0 14px 24px rgba(31, 143, 101, 0.24);
}

.send-plane {
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 4px;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 16px solid #fff;
}

.new-messages-button {
  position: fixed;
  left: 50%;
  bottom: 98px;
  z-index: 18;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(31, 143, 101, 0.95);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 14px 24px rgba(31, 143, 101, 0.24);
  cursor: pointer;
}

.media-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.92);
  padding: 18px;
}

.media-overlay-panel {
  position: relative;
  height: 100%;
}

.overlay-close {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 28px;
  cursor: pointer;
}

.overlay-loader {
  padding: 18px 52px 18px 8px;
  color: rgba(255, 255, 255, 0.82);
  text-align: center;
}

.overlay-content {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  height: calc(100% - 54px);
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.overlay-media,
.overlay-content img,
.overlay-content video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.overlay-photo.is-zoomed {
  -webkit-transform: scale(2);
  transform: scale(2);
  -webkit-transform-origin: center center;
  transform-origin: center center;
}

.overlay-card {
  max-width: 360px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  text-align: center;
  line-height: 1.45;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 640px) {
  .chat-header {
    padding: 12px 12px 10px;
  }

  .chat-stage {
    padding: 78px 8px 126px;
  }

  .message-body {
    max-width: calc(100% - 44px);
  }

  .header-actions {
    gap: 4px;
  }

  .current-user-pill {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
