:root {
  color-scheme: dark;
  --bg: #101113;
  --panel: #181a1f;
  --panel-2: #20232a;
  --text: #f4f7fb;
  --muted: #9aa3af;
  --line: #30343d;
  --accent: #27c08a;
  --accent-2: #188760;
  --danger: #ff6b6b;
  --bubble-own: #1d6f55;
  --bubble-other: #292d36;
}

body.light {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #edf1f4;
  --text: #17191d;
  --muted: #657080;
  --line: #d8dee6;
  --accent: #12825c;
  --accent-2: #0e6548;
  --danger: #b42318;
  --bubble-own: #d8f5e9;
  --bubble-other: #eef1f5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
}

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.brand h1,
.chat-header h2 {
  margin: 0;
  font-size: 22px;
}

.brand p,
.chat-header p,
.account-meta span {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.tab,
.icon-button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
}

.tab {
  padding: 10px;
}

.tab.active {
  border-color: var(--accent);
  color: var(--accent);
}

.auth-form {
  display: grid;
  gap: 14px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 11px 12px;
  outline: none;
}

input:focus {
  border-color: var(--accent);
}

.primary-button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.error-text {
  color: var(--danger);
  min-height: 20px;
}

.messenger {
  height: 100vh;
  display: grid;
  grid-template-columns: 340px 1fr 260px;
}

.sidebar {
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
}

.account-row {
  display: grid;
  grid-template-columns: 42px 1fr 38px 38px 38px;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.nav-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 12px 14px 0;
}

.members-panel {
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow: auto;
  padding-bottom: 14px;
}

.mini-chart {
  display: flex;
  align-items: end;
  gap: 4px;
  min-height: 80px;
  padding: 10px 14px;
}

.mini-chart span {
  flex: 1;
  min-height: 4px;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
}

.account-meta {
  min-width: 0;
}

.account-meta strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-button {
  width: 38px;
  height: 38px;
}

.search-box {
  position: relative;
  padding: 14px;
}

.search-results {
  position: absolute;
  z-index: 4;
  left: 14px;
  right: 14px;
  top: 58px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.search-result,
.chat-item {
  display: flex;
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 12px 14px;
  cursor: pointer;
}

.chat-item.active,
.search-result:hover,
.chat-item:hover {
  background: var(--panel-2);
}

.panel-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  padding: 0 14px 8px;
  text-transform: uppercase;
}

.chat-list {
  overflow: auto;
}

.list-panel {
  overflow: auto;
  padding-bottom: 14px;
}

.section-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 12px 14px 6px;
  text-transform: uppercase;
}

.row-action {
  margin-left: auto;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 9px;
  cursor: pointer;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #777;
}

.status-dot.online { background: #27c08a; }
.status-dot.idle { background: #e3a008; }
.status-dot.do_not_disturb { background: #e5484d; }
.status-dot.offline { background: #6b7280; }

.chat-main {
  min-width: 0;
}

.chat-panel {
  min-width: 0;
  background: var(--bg);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

.chat-header {
  min-height: 70px;
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

/*.state-banner {
  margin: 12px 18px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--muted);
  background: var(--panel);
}*/

.messages {
  overflow: auto;
  padding: 18px;
  max-height: 500px;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: min(680px, 82%);
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bubble-other);
}

.message.own {
  margin-left: auto;
  background: var(--bubble-own);
}

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

.message span {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.attachment-preview {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.attachment-preview img,
.attachment-preview video {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
}

.attachment-card {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--panel-2);
}

.message-attachments {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.message-attachments img,
.message-attachments video {
  max-width: min(420px, 100%);
  border-radius: 8px;
}

.video-circle {
  width: 180px;
  height: 180px;
  object-fit: cover;
  border-radius: 50%;
}

.message-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.message-actions button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 7px;
  font-size: 12px;
}

button,
input,
textarea {
  font: inherit;
}

.composer {
  display: grid;
  grid-template-columns: 38px 38px 38px minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.composer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 120px;
  height: 42px;
  resize: none;
  overflow-y: auto;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  line-height: 20px;
}

.composer textarea:focus {
  border-color: var(--accent);
}

.composer .primary-button,
.composer .icon-button {
  height: 42px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 18px;
}

.modal-panel {
  width: min(460px, 100%);
  display: grid;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-head h2 {
  margin: 0;
  font-size: 20px;
}

.profile-grid {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 12px;
  align-items: center;
}

.profile-avatar {
  width: 76px;
  height: 76px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--panel-2);
}

.file-button {
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  min-height: 42px;
  cursor: pointer;
}

.file-button input {
  display: none;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 11px 12px;
}

.profile-meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}
.chat-panel > .state-banner {
  display: none !important;
}

@media (max-width: 760px) {
  .messenger {
    grid-template-columns: 1fr;
    grid-template-rows: 38vh 62vh;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .composer {
  grid-template-columns: 38px 38px 38px 1fr auto;
  padding: 10px;
  gap: 6px;
  }

  .members-panel {
    display: none;
  }
}

#stateBanner {
  display: none !important;
}

.chat-panel > .state-banner {
  display: none !important;
}
