:root {
  --ctw-bg: #ffffff;
  --ctw-border: rgba(0,0,0,0.12);
  --ctw-shadow: 0 10px 30px rgba(0,0,0,0.16);
  --ctw-accent: #2b6cff;
  --ctw-muted: rgba(0,0,0,0.55);
}

.ctw-launcher {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 54px;
  height: 54px;
  border-radius: 999px;
  border: 1px solid var(--ctw-border);
  background: var(--ctw-accent);
  box-shadow: var(--ctw-shadow);
  cursor: pointer;
  z-index: 2147483000;
  display: grid;
  place-items: center;
}

.ctw-launcher svg { width: 26px; height: 26px; fill: #fff; }

.ctw-panel {
  position: fixed;
  right: 18px;
  bottom: 84px;
  width: min(360px, calc(100vw - 24px));
  height: min(520px, calc(100vh - 120px));
  background: var(--ctw-bg);
  border: 1px solid var(--ctw-border);
  border-radius: 14px;
  box-shadow: var(--ctw-shadow);
  z-index: 2147483000;
  overflow: hidden;
  display: none;
}

.ctw-panel.ctw-open { display: flex; flex-direction: column; }

.ctw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px;
  background: #fff;
  border-bottom: 1px solid var(--ctw-border);
}

.ctw-header-left { display: flex; flex-direction: column; gap: 2px; }
.ctw-title { font-weight: 650; font-size: 14px; }
.ctw-subtitle { font-size: 12px; color: var(--ctw-muted); }
.ctw-close {
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 20px;
  cursor: pointer;
  color: var(--ctw-muted);
}

.ctw-messages {
  flex: 1;
  padding: 14px 12px;
  overflow: auto;
  background: #f7f8fb;
}

.ctw-msg { display: flex; gap: 8px; margin: 10px 0; align-items: flex-end; }
.ctw-msg.ctw-user { justify-content: flex-end; }
.ctw-msg.ctw-admin { justify-content: flex-start; }

.ctw-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(0,0,0,0.08);
  overflow: hidden;
  flex: 0 0 28px;
  border: 1px solid var(--ctw-border);
}
.ctw-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.ctw-admin-block { display: flex; flex-direction: column; gap: 4px; }
.ctw-name { font-size: 12px; color: var(--ctw-muted); margin-left: 4px; }

.ctw-bubble {
  max-width: 84%;
  padding: 10px 12px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
}

.ctw-bubble.ctw-user {
  background: var(--ctw-accent);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.ctw-bubble.ctw-admin {
  background: #fff;
  border: 1px solid var(--ctw-border);
  color: #111;
  border-bottom-left-radius: 6px;
}

.ctw-status {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
  color: rgba(255,255,255,0.85);
}
.ctw-msg.ctw-user .ctw-status { color: rgba(255,255,255,0.85); }
.ctw-msg.ctw-user .ctw-time { opacity: 0.85; }
.ctw-ticks { font-weight: 700; letter-spacing: -1px; opacity: 0.85; }
.ctw-ticks.ctw-read { color: #8bd3ff; opacity: 1; }

.ctw-meta {
  font-size: 12px;
  color: var(--ctw-muted);
  margin: 0 0 10px 0;
}

.ctw-onboard {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.92);
  display: none;
  padding: 18px;
}
.ctw-onboard.ctw-show { display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.ctw-onboard h3 { margin: 0; font-size: 16px; }
.ctw-onboard p { margin: 0; color: var(--ctw-muted); font-size: 13px; }
.ctw-onboard input {
  border: 1px solid var(--ctw-border);
  border-radius: 10px;
  padding: 10px 10px;
  font-size: 14px;
  outline: none;
}
.ctw-onboard button {
  border: none;
  background: var(--ctw-accent);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 650;
}

.ctw-inputbar {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--ctw-border);
  background: #fff;
}

.ctw-inputbar input {
  flex: 1;
  border: 1px solid var(--ctw-border);
  border-radius: 10px;
  padding: 10px 10px;
  font-size: 14px;
  outline: none;
}

.ctw-inputbar button {
  border: none;
  background: var(--ctw-accent);
  color: #fff;
  padding: 0 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 650;
}

.ctw-inputbar button:disabled { opacity: 0.6; cursor: default; }
