:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #64748b;
  --line: #dbe2ef;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --sent: #2563eb;
  --received: #eef2f7;
  --success: #16a34a;
  --danger: #dc2626;
  --shadow: 0 20px 45px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.2);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.app {
  min-height: 100vh;
}

.notification-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 20;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
}

.notification {
  padding: 13px 14px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 700;
  animation: slideIn 180ms ease;
}

.notification.success {
  border-left-color: var(--success);
}

.notification.error {
  border-left-color: var(--danger);
}

.notification.leaving {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 180ms ease, transform 180ms ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

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

.brand-mark,
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #ffffff;
  background: var(--primary);
  font-weight: 800;
  overflow: hidden;
}

.brand h1,
.brand p,
.conversation-header h2,
.conversation-header p,
.sidebar-header h2,
.eyebrow {
  margin: 0;
}

.brand h1 {
  font-size: 26px;
}

.brand p,
.conversation-header p,
.eyebrow {
  color: var(--muted);
}

.auth-highlights {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.auth-highlights span {
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 0 8px;
  color: #334155;
  background: #eef6ff;
  border: 1px solid #cfe4ff;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  margin-bottom: 20px;
  background: var(--panel-soft);
  border-radius: 8px;
}

.tab {
  padding: 10px;
  color: var(--muted);
  background: transparent;
  border-radius: 6px;
}

.tab.active {
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: #ffffff;
  outline: none;
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.password-control {
  position: relative;
  display: block;
}

.password-control input {
  padding-right: 76px;
}

.password-toggle {
  position: absolute;
  top: 7px;
  right: 7px;
  min-width: 58px;
  min-height: 30px;
  padding: 0 10px;
  color: var(--primary);
  background: #eff6ff;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.password-toggle:hover {
  background: #dbeafe;
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.check-label input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--primary);
}

.link-button {
  padding: 0;
  color: var(--primary);
  background: transparent;
  font-size: 13px;
  font-weight: 800;
}

.link-button:hover {
  color: var(--primary-dark);
}

.avatar-preview-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.preview-avatar {
  width: 38px;
  height: 38px;
  font-size: 14px;
}

.password-meter {
  height: 7px;
  overflow: hidden;
  background: #e2e8f0;
  border-radius: 999px;
}

.password-meter span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--danger);
  border-radius: inherit;
  transition: width 180ms ease, background-color 180ms ease;
}

.password-meter span.weak {
  width: 33%;
  background: var(--danger);
}

.password-meter span.good {
  width: 66%;
  background: #ca8a04;
}

.password-meter span.strong {
  width: 100%;
  background: var(--success);
}

.field-note {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.recovery-form h2,
.recovery-form p {
  margin: 0;
}

.recovery-form h2 {
  color: var(--text);
  font-size: 20px;
}

.recovery-form p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.secondary-auth-button {
  min-height: 42px;
  color: var(--text);
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
}

.secondary-auth-button:hover {
  background: #eef2f7;
}

.auth-form > button,
.message-form button[type="submit"] {
  min-height: 44px;
  padding: 0 18px;
  color: #ffffff;
  background: var(--primary);
  border-radius: 8px;
  font-weight: 700;
}

.auth-form > button:hover,
.message-form button[type="submit"]:hover {
  background: var(--primary-dark);
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.message {
  min-height: 22px;
  margin: 16px 0 0;
  color: var(--danger);
  font-weight: 600;
}

.message.success {
  color: var(--success);
}

.chat-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 340px 1fr;
}

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

.sidebar-header,
.conversation-header {
  min-height: 84px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.sidebar-header h2 {
  font-size: 18px;
}

.eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
}

.secondary-button {
  min-height: 38px;
  padding: 0 12px;
  color: var(--text);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 700;
}

.list-message {
  padding: 18px;
  color: var(--muted);
}

.user-list {
  display: grid;
  gap: 4px;
  padding: 10px;
  overflow-y: auto;
}

.user-card {
  width: 100%;
  min-height: 68px;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
  color: inherit;
  background: transparent;
  border-radius: 8px;
  text-align: left;
}

.user-card:hover,
.user-card.active {
  background: var(--panel-soft);
}

.user-card h3,
.user-card p {
  margin: 0;
}

.user-card h3 {
  font-size: 15px;
}

.user-card p,
.status {
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #94a3b8;
}

.status-dot.online {
  background: var(--success);
}

.conversation {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #edf1f7;
}

.active-chat {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.message-area {
  padding: 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  margin: auto;
  color: var(--muted);
  text-align: center;
}

.bubble {
  max-width: min(620px, 76%);
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.45;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
  word-break: break-word;
}

.message-attachment {
  display: grid;
  gap: 6px;
  margin-top: 8px;
  color: inherit;
  text-decoration: none;
}

.message-attachment img {
  display: block;
  width: min(280px, 100%);
  max-height: 260px;
  object-fit: cover;
  border-radius: 8px;
}

.message-attachment span {
  font-weight: 800;
}

.message-attachment small {
  opacity: 0.78;
}

.bubble.sent {
  align-self: flex-end;
  color: #ffffff;
  background: var(--sent);
}

.bubble.received {
  align-self: flex-start;
  color: var(--text);
  background: var(--received);
}

.bubble-time {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.75;
}

.message-form {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  padding: 16px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.icon-button {
  width: 44px;
  min-height: 44px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: #eff6ff;
  border: 1px solid #cfe4ff;
  border-radius: 8px;
  font-size: 24px;
  font-weight: 800;
}

.icon-button:hover {
  background: #dbeafe;
}

.attachment-preview {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
}

.attachment-preview button {
  color: var(--danger);
  background: transparent;
  font-weight: 800;
}

@media (max-width: 760px) {
  .chat-view {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

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

  .conversation {
    min-height: 58vh;
  }

  .bubble {
    max-width: 88%;
  }

  .message-form {
    grid-template-columns: auto 1fr;
  }

  .message-form button[type="submit"] {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .notification-stack {
    top: 12px;
    right: 12px;
    width: calc(100vw - 24px);
  }

  .auth-view {
    padding: 16px;
  }

  .auth-panel {
    padding: 22px;
  }

  .brand {
    align-items: flex-start;
  }

  .auth-highlights {
    grid-template-columns: 1fr;
  }

  .form-row {
    align-items: flex-start;
    flex-direction: column;
  }
}
