.mw-demo-page {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172026;
  background: #f6f8fa;
}

.mw-demo-main {
  max-width: 860px;
  margin: 0 auto;
  padding: 48px 20px;
}

.mw-demo-main h1 {
  margin: 0 0 12px;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: 0;
}

.mw-demo-main p {
  max-width: 680px;
  line-height: 1.6;
  color: #526371;
}

.mw-widget {
  position: fixed;
  right: var(--mw-side, 24px);
  bottom: var(--mw-bottom, 24px);
  z-index: var(--mw-z, 99999);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.mw-widget,
.mw-widget * {
  box-sizing: border-box;
}

.mw-bubble {
  width: 68px;
  height: 68px;
  border: 0;
  border-radius: 999px;
  background: var(--mw-primary, #176b50);
  color: #fff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.28);
  cursor: pointer;
  font: 700 14px system-ui, sans-serif;
}

.mw-panel {
  position: absolute;
  right: 0;
  bottom: 82px;
  width: min(360px, calc(100vw - 28px));
  height: min(540px, calc(100vh - 112px));
  overflow: hidden;
  border: 1px solid #d7e0e7;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.24);
}

.mw-panel:not([hidden]) {
  display: flex;
  flex-direction: column;
}

.mw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 14px;
  background: var(--mw-primary, #176b50);
  color: #fff;
}

.mw-header strong,
.mw-header small {
  display: block;
  line-height: 1.25;
}

.mw-header small {
  opacity: 0.86;
  font-size: 12px;
  margin-top: 2px;
}

.mw-close {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
  font: 700 16px system-ui, sans-serif;
}

.mw-visitor {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid #d7e0e7;
  background: #fff;
}

.mw-visitor label {
  color: #526371;
  font: 700 12px system-ui, sans-serif;
}

.mw-name,
.mw-input {
  min-width: 0;
  border: 1px solid #c7d2da;
  border-radius: 8px;
  color: #172026;
  font: 14px system-ui, sans-serif;
}

.mw-name {
  width: 100%;
  padding: 9px 10px;
}

.mw-log {
  flex: 1;
  overflow: auto;
  padding: 12px;
  background: #f5f7f9;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mw-msg {
  max-width: 84%;
  padding: 9px 11px;
  border: 1px solid #d7e0e7;
  border-radius: 8px;
  background: #fff;
  color: #172026;
  font-size: 14px;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.mw-msg.visitor {
  align-self: flex-end;
  background: #dff7ea;
  border-color: #b8e8cc;
}

.mw-msg.operator {
  align-self: flex-start;
}

.mw-msg.system,
.mw-msg.error {
  align-self: center;
  max-width: 94%;
  font-size: 13px;
  background: #eef3f7;
  color: #526371;
}

.mw-msg.error {
  background: #fff5f5;
  border-color: #ffd2d2;
  color: #b42318;
}

.mw-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #d7e0e7;
  background: #fff;
}

.mw-input {
  flex: 1;
  padding: 10px;
}

.mw-send {
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--mw-primary, #176b50);
  color: #fff;
  cursor: pointer;
  font: 700 14px system-ui, sans-serif;
}

.mw-send:disabled,
.mw-input:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

@media (max-width: 480px) {
  .mw-widget {
    right: 14px;
    bottom: 14px;
  }

  .mw-panel {
    right: -6px;
    width: calc(100vw - 16px);
    height: min(560px, calc(100vh - 96px));
  }
}
