:root {
  --bg: #f3f7f6;
  --surface: #ffffff;
  --surface-soft: #f7faf9;
  --line: #d8e1de;
  --line-strong: #b8c8c3;
  --text: #17201d;
  --muted: #687773;
  --brand: #0f766e;
  --brand-strong: #095c55;
  --brand-soft: #e3f4f1;
  --accent: #f97352;
  --accent-soft: #fff0eb;
  --green: #20a464;
  --yellow: #d59a18;
  --red: #d64f45;
  --shadow: rgba(30, 43, 39, 0.14);
  --radius: 8px;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(243, 247, 246, 0.94)),
    repeating-linear-gradient(90deg, rgba(15, 118, 110, 0.06) 0 1px, transparent 1px 56px),
    repeating-linear-gradient(0deg, rgba(249, 115, 82, 0.045) 0 1px, transparent 1px 56px);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.22);
  outline-offset: 1px;
}

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

.auth-window,
.buddy-window,
.chat-window,
.settings-window {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 44px var(--shadow);
  overflow: hidden;
}

.auth-window {
  width: min(460px, 100%);
}

.window-title {
  min-height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 750;
  font-size: 15px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.window-buttons {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.auth-language-select {
  width: auto;
  min-width: 116px;
  min-height: 32px;
  margin-left: auto;
  padding: 4px 8px;
  color: var(--text);
  background: var(--surface-soft);
}

.window-buttons span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 0;
  background: var(--line-strong);
}

.window-buttons span:nth-child(1) {
  background: #f16d60;
}

.window-buttons span:nth-child(2) {
  background: #e5b949;
}

.window-buttons span:nth-child(3) {
  background: #44b678;
}

.flower {
  display: none;
}

.auth-logo {
  width: 112px;
  height: 112px;
  display: block;
  margin: 24px auto 14px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.18);
}

.auth-tabs {
  width: calc(100% - 32px);
  margin: 0 16px 10px;
  padding: 3px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.auth-tabs button,
.auth-tabs a {
  min-height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  text-decoration: none;
  font-weight: 650;
}

.auth-tabs .active {
  color: var(--brand-strong);
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(21, 30, 28, 0.08);
}

.auth-form {
  display: grid;
  gap: 13px;
  padding: 8px 16px 16px;
}

.auth-form label,
.settings-window label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
}

select,
input {
  min-height: 38px;
  padding: 7px 10px;
}

textarea {
  padding: 10px 12px;
  line-height: 1.45;
}

.auth-form button,
.settings-actions button,
.composer button,
#buzzButton {
  min-height: 38px;
  border: 1px solid var(--brand-strong);
  border-radius: 7px;
  color: #ffffff;
  background: var(--brand);
  font-weight: 750;
}

.auth-form button:hover,
.settings-actions button:hover,
.composer button:hover,
#buzzButton:hover {
  background: var(--brand-strong);
}

.inline-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.inline-field button,
#sendVerificationButton {
  padding: 0 12px;
  color: var(--brand-strong);
  border-color: var(--line-strong);
  background: var(--brand-soft);
}

.inline-field button:hover,
#sendVerificationButton:hover {
  background: #d3ede8;
}

.two-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.auth-message {
  min-height: 22px;
  margin: 0;
  padding: 0 16px 16px;
  color: var(--muted);
}

.auth-note {
  margin: 0;
  padding: 0 16px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.auth-note a {
  color: var(--brand-strong);
  font-weight: 750;
}

.challenge-panel {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.challenge-panel button {
  width: fit-content;
  padding: 0 12px;
  color: var(--brand-strong);
  border-color: var(--line-strong);
  background: var(--brand-soft);
}

.challenge-panel output {
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface);
  overflow-wrap: anywhere;
}

.captcha-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.captcha-panel span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.captcha-panel strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.captcha-panel button {
  min-height: 38px;
  padding: 0 12px;
  color: var(--brand-strong);
  border-color: var(--line-strong);
  background: var(--brand-soft);
}

.captcha-panel label {
  grid-column: 1 / -1;
}

.auth-message.error {
  color: var(--red);
}

.desktop {
  min-height: 100vh;
  padding: clamp(16px, 3vw, 34px);
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(420px, 760px);
  align-items: start;
  justify-content: center;
  gap: clamp(14px, 2vw, 22px);
}

.buddy-window {
  min-height: min(720px, calc(100vh - 68px));
  display: grid;
  grid-template-rows: auto auto auto auto auto 1fr auto;
}

.chat-window {
  min-height: min(720px, calc(100vh - 68px));
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
}

.profile {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  padding: 16px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.avatar {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  color: var(--brand-strong);
  font-weight: 800;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--brand-soft);
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.profile label {
  display: block;
  margin: 1px 0 7px;
  font-weight: 800;
}

.search-row {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.tabs button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tabs .active {
  color: var(--brand-strong);
  border-color: var(--line);
  background: var(--brand-soft);
}

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

.contact-list {
  list-style: none;
  margin: 0;
  padding: 0 8px 8px;
  overflow: auto;
}

.contact {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: default;
}

.contact:hover,
.contact.active {
  border-color: var(--line);
  background: var(--surface-soft);
}

.presence {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.online {
  background: var(--green);
}

.away {
  background: var(--yellow);
}

.dnd {
  background: var(--red);
}

.offline {
  background: #a9b5b1;
}

.contact-name {
  min-width: 0;
  font-weight: 780;
  font-size: 14px;
}

.contact-note {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-badge {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 18px;
  margin-left: 7px;
  padding: 0 6px;
  border: 1px solid #cf5b3d;
  border-radius: 999px;
  color: #9a341f;
  background: var(--accent-soft);
  font-size: 11px;
  font-weight: 850;
  vertical-align: 1px;
}

.uin {
  color: var(--muted);
  font-size: 12px;
}

.toolbar,
.composer-tools {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.toolbar button,
.composer-tools button,
.title-button {
  min-width: 34px;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--brand-strong);
  background: var(--surface);
  font-weight: 800;
}

.toolbar button:hover,
.composer-tools button:hover,
.title-button:hover {
  background: var(--brand-soft);
}

.chat-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: var(--muted);
  font-size: 13px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

#buzzButton {
  margin-left: auto;
  min-height: 34px;
  padding: 0 14px;
  border-color: #c34f35;
  background: var(--accent);
}

#buzzButton:hover {
  background: #dc5f3f;
}

.connection-status {
  min-width: 104px;
  padding: 5px 8px;
  color: var(--brand-strong);
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.messages {
  margin: 0;
  padding: 18px;
  list-style: none;
  overflow: auto;
  background: #fbfcfc;
}

.message {
  width: fit-content;
  max-width: min(76%, 560px);
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 5px 14px rgba(30, 43, 39, 0.06);
  font-size: 14px;
  line-height: 1.42;
}

.message.me {
  margin-left: auto;
  background: var(--brand-soft);
  border-color: #b7dcd5;
}

.message.system {
  margin-left: auto;
  margin-right: auto;
  color: #66522a;
  background: #fff6df;
  border-color: #ead696;
  font-size: 13px;
}

.message-head {
  display: flex;
  gap: 8px;
  margin-bottom: 5px;
  color: var(--brand-strong);
  font-weight: 800;
}

.time {
  margin-left: auto;
  color: var(--muted);
  font-weight: 500;
}

.file-link {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-top: 8px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--brand-strong);
  text-align: left;
}

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

.attachment audio,
.attachment video {
  width: min(100%, 360px);
}

.attachment video {
  max-height: 260px;
  background: #101716;
}

.composer-tools button.recording {
  width: auto;
  padding: 0 10px;
  color: #ffffff;
  background: var(--red);
  border-color: #a83d35;
}

.composer {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 10px;
  padding: 0 16px 16px;
  background: var(--surface-soft);
}

.composer textarea {
  min-height: 78px;
  resize: vertical;
}

.composer button {
  align-self: stretch;
}

.settings-panel {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(23, 32, 29, 0.34);
}

.settings-panel[hidden] {
  display: none;
}

.settings-window {
  width: min(440px, 100%);
}

.admin-window {
  width: min(920px, 100%);
  max-height: min(860px, calc(100vh - 32px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 44px var(--shadow);
  overflow: auto;
}

.admin-login-inline {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.admin-login-inline label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.admin-login-inline button,
.admin-card button {
  min-height: 38px;
  align-self: end;
  padding: 0 14px;
  border: 1px solid var(--brand-strong);
  border-radius: 7px;
  color: #ffffff;
  background: var(--brand);
  font-weight: 750;
}

.admin-login-inline .auth-message {
  grid-column: 1 / -1;
  padding: 0;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
}

.admin-stats article,
.admin-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.admin-stats article {
  padding: 12px;
}

.admin-stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.admin-stats strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 0 16px 16px;
}

.admin-card {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.admin-card h3 {
  margin: 0;
}

.admin-card p {
  margin: 0;
  color: var(--muted);
}

.app-drop-zone {
  min-height: 118px;
  display: grid;
  place-items: center;
  padding: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface);
  text-align: center;
}

.app-drop-zone.dragging {
  border-color: var(--brand);
  color: var(--brand-strong);
  background: var(--brand-soft);
}

.app-drop-zone input {
  display: none;
}

.release-list {
  display: grid;
  gap: 8px;
}

.release-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.release-item a,
.release-item .badge {
  color: var(--brand-strong);
  font-weight: 750;
}

.agent-request-list {
  display: grid;
  gap: 8px;
}

.agent-request-item {
  display: grid;
  grid-template-columns: 1fr 150px auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}

.agent-request-item p {
  margin: 4px 0;
  color: var(--text);
}

.agent-request-item small {
  color: var(--muted);
}

.settings-window label {
  padding: 12px 16px 0;
}

.settings-window .check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
}

.auth-check-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface-soft);
}

.auth-check-row input {
  width: auto;
  min-height: auto;
  margin-top: 2px;
}

.settings-window .check-row input {
  width: auto;
  min-height: auto;
  margin: 0;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px;
}

.settings-actions button {
  padding: 0 14px;
}

.title-button {
  margin-left: auto;
}

@media (max-width: 820px) {
  .desktop {
    grid-template-columns: 1fr;
  }

  .buddy-window,
  .chat-window {
    min-height: auto;
  }

  .chat-window {
    min-height: 620px;
  }
}

@media (max-width: 540px) {
  .auth-screen,
  .desktop {
    padding: 10px;
  }

  .two-fields,
  .inline-field,
  .admin-login-inline,
  .admin-grid,
  .composer {
    grid-template-columns: 1fr;
  }

  .admin-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .message {
    max-width: 92%;
  }
}
