.scb-chat-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}

.scb-chat-toggle {
  width: 64px;
  height: 64px;
  border: 1px solid var(--border, #2a2d31);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, .18), transparent 35%),
    linear-gradient(180deg, #22262d, #101216);
  color: #ffffff;
  box-shadow: var(--shadow, 0 10px 30px rgba(0, 0, 0, .45));
  cursor: pointer;
  font-weight: 800;
  display: grid;
  place-items: center;
  transition: transform .18s ease, background .18s ease;
}

.scb-chat-toggle-icon {
  width: 34px;
  height: 34px;
  display: block;
  color: #ffffff;
  fill: currentColor;
  filter: drop-shadow(0 2px 8px rgba(92, 199, 216, .38));
}

.scb-chat-toggle:hover {
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, .22), transparent 35%),
    linear-gradient(180deg, #303640, #15181d);
  transform: translateY(-1px);
}

.scb-chat-panel {
  position: absolute;
  right: 0;
  bottom: 78px;
  width: min(380px, calc(100vw - 40px));
  height: min(620px, calc(100vh - 118px));
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid var(--border, #2a2d31);
  border-radius: 16px;
  background: rgba(18, 20, 22, .95);
  color: var(--text, #e7e7e7);
  box-shadow: var(--shadow, 0 10px 30px rgba(0, 0, 0, .45));
  backdrop-filter: blur(10px);
}

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

.scb-chat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border, #2a2d31);
}

.scb-chat-title {
  font-weight: 850;
  letter-spacing: 0;
}

.scb-chat-subtitle {
  color: var(--muted, #b6b6b6);
  font-size: 12px;
  margin-top: 1px;
}

.scb-chat-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border, #2a2d31);
  background: rgba(28, 31, 35, .8);
  color: #f3f3f3;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.scb-chat-body {
  min-height: 0;
  display: grid;
}

.scb-chat-start,
.scb-chat-active {
  min-height: 0;
  display: grid;
  gap: 14px;
  padding: 16px;
}

.scb-chat-start {
  align-content: start;
  overflow-y: auto;
}

.scb-chat-lead {
  margin: 0;
  color: #d7d7d7;
}

.scb-chat-button {
  appearance: none;
  border: 1px solid var(--border, #2a2d31);
  border-radius: 12px;
  background: var(--btn, #1c1f23);
  color: #f3f3f3;
  padding: 11px 13px;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  transition: background .18s ease, transform .18s ease;
}

.scb-chat-button:hover {
  background: var(--btn-hover, #23262b);
  transform: translateY(-1px);
}

.scb-chat-button.is-secondary {
  background: rgba(10, 12, 14, .68);
}

.scb-chat-code-list {
  display: grid;
  gap: 8px;
}

.scb-chat-code-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border, #2a2d31);
  border-radius: 12px;
  background: rgba(10, 12, 14, .62);
  color: #efefef;
  padding: 11px 12px;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.scb-chat-code-item:hover {
  border-color: #748293;
  background: rgba(34, 38, 43, .88);
}

.scb-chat-code-pill {
  display: block;
  font-weight: 850;
  letter-spacing: .08em;
}

.scb-chat-small {
  color: var(--muted, #b6b6b6);
  font-size: 12px;
}

.scb-chat-manual {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.scb-chat-manual input,
.scb-chat-composer .scb-chat-message-input {
  min-width: 0;
  border: 1px solid var(--border, #2a2d31);
  border-radius: 10px;
  background: rgba(8, 10, 12, .78);
  color: #f2f2f2;
  padding: 11px 12px;
  font: inherit;
  outline: none;
}

.scb-chat-manual input:focus,
.scb-chat-composer .scb-chat-message-input:focus {
  border-color: #6b798a;
  box-shadow: 0 0 0 3px rgba(120, 150, 180, .18);
}

.scb-chat-status {
  min-height: 20px;
  color: var(--muted, #b6b6b6);
  font-size: 13px;
}

.scb-chat-active > .scb-chat-status {
  padding: 0 12px 10px;
}

.scb-chat-status.is-error {
  color: #ffd4d4;
}

.scb-chat-active {
  grid-template-rows: auto 1fr auto;
  padding: 0;
}

.scb-chat-codebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #2a2d31);
  background: rgba(10, 12, 14, .42);
}

.scb-chat-codebar strong {
  letter-spacing: .08em;
}

.scb-chat-back {
  border: 0;
  background: transparent;
  color: #e2e2e2;
  cursor: pointer;
  padding: 7px 0;
  font: inherit;
}

.scb-chat-messages {
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
}

.scb-chat-empty {
  height: 100%;
  display: grid;
  place-items: center;
  min-height: 220px;
  text-align: center;
  color: var(--muted, #b6b6b6);
}

.scb-chat-message {
  max-width: 86%;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border, #2a2d31);
  background: rgba(9, 11, 13, .74);
}

.scb-chat-message.is-admin {
  background: rgba(52, 61, 72, .86);
}

.scb-chat-message.is-visitor {
  margin-left: auto;
}

.scb-chat-message.is-ai-message {
  border-color: rgba(210, 220, 235, .3);
}

.scb-chat-message-meta {
  color: #c7c7c7;
  font-size: 11px;
  margin-bottom: 4px;
}

.scb-chat-message-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.scb-chat-ai-notice {
  margin-top: 8px;
  color: var(--muted, #b6b6b6);
  font-size: 11px;
  line-height: 1.35;
}

.scb-chat-composer {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border, #2a2d31);
}

.scb-chat-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

@media (max-width: 520px) {
  .scb-chat-widget {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  .scb-chat-toggle {
    width: 58px;
    height: 58px;
  }

  .scb-chat-toggle-icon {
    width: 31px;
    height: 31px;
  }

  .scb-chat-panel {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    width: auto;
    height: min(590px, calc(100vh - 104px));
    height: min(590px, calc(100dvh - 104px));
    max-height: calc(100vh - 104px);
    max-height: calc(100dvh - 104px);
    border-radius: 12px;
  }

  .scb-chat-manual,
  .scb-chat-input-row {
    grid-template-columns: 1fr;
  }

  .scb-chat-start,
  .scb-chat-messages {
    padding: 14px;
  }

  .scb-chat-codebar,
  .scb-chat-top {
    padding: 12px 14px;
  }

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

  .scb-chat-button {
    width: 100%;
  }
}
