#master-chat-root {
  font-family: 'Golos Text', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: #111827;
}

#master-chat-root *,
#master-chat-root *::before,
#master-chat-root *::after {
  box-sizing: border-box;
}

#master-chat-root button {
  font: inherit;
  cursor: pointer;
}

#master-chat-root .master-chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2200;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 24px;
  background: rgba(17, 24, 39, 0.45);
}

#master-chat-root .master-chat {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  max-width: 400px;
  max-height: min(80vh, 600px);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

#master-chat-root .master-chat__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #f3f4f6;
  flex-shrink: 0;
}

#master-chat-root .master-chat__avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: #f3f4f6;
}

#master-chat-root .master-chat__head-text {
  flex: 1;
  min-width: 0;
}

#master-chat-root .master-chat__name {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
}

#master-chat-root .master-chat__status {
  margin: 2px 0 0;
  font-size: 13px;
  color: #6b7280;
  line-height: 1.3;
}

#master-chat-root .master-chat__close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: #6b7280;
  font-size: 26px;
  line-height: 1;
}

#master-chat-root .master-chat__close:hover {
  background: #f3f4f6;
  color: #111827;
}

#master-chat-root .master-chat__messages {
  flex: 1 1 auto;
  min-height: 280px;
  overflow-y: auto;
  padding: 16px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

#master-chat-root .master-chat__bubble {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
}

#master-chat-root .master-chat__bubble--in {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}

#master-chat-root .master-chat__bubble--out {
  align-self: flex-end;
  background: #dbeafe;
  border-bottom-right-radius: 4px;
}

#master-chat-root .master-chat__time {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: #9ca3af;
  line-height: 1.2;
}

#master-chat-root .master-chat__form {
  display: flex;
  gap: 8px;
  padding: 12px 14px 14px;
  border-top: 1px solid #f3f4f6;
  flex-shrink: 0;
  background: #fff;
}

#master-chat-root .master-chat__input {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 11px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
  line-height: 1.35;
  resize: none;
  min-height: 44px;
  max-height: 120px;
}

#master-chat-root .master-chat__input:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

#master-chat-root .master-chat__send {
  flex-shrink: 0;
  align-self: flex-end;
  margin: 0;
  padding: 11px 16px;
  border: none;
  border-radius: 12px;
  background: #2563eb;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

#master-chat-root .master-chat__send:hover:not(:disabled) {
  background: #1d4ed8;
}

#master-chat-root .master-chat__send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#master-chat-root .master-chat__err {
  margin: 0;
  padding: 0 14px 10px;
  font-size: 13px;
  color: #dc2626;
}

#master-chat-root .master-chat__hp {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 480px) {
  #master-chat-root .master-chat-backdrop {
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    align-items: flex-end;
    justify-content: center;
    overflow: hidden;
  }

  #master-chat-root .master-chat {
    max-width: calc(100vw - 24px);
    max-height: 82vh;
    max-height: 82svh;
    border-radius: 16px;
  }

  #master-chat-root .master-chat__messages {
    min-height: 260px;
  }

  /* iOS Safari zooms the page on focus when font-size < 16px */
  #master-chat-root .master-chat__input {
    font-size: 16px;
  }

  #master-chat-root .master-chat__send {
    padding: 11px 14px;
  }
}
