/* Readable LINE-inspired conversation layout, retaining the KKL AI identity. */
#kklcb-root {
  --kklcb-ink: #141b23;
  --kklcb-muted: #435361;
  --kklcb-green: #086b39;
  --kklcb-chat: #dce6ef;
  --kklcb-user: #b6f392;
  --kklcb-border: #b5c3ce;
  font-family: Tahoma, "Noto Sans Thai", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  color: var(--kklcb-ink);
  position: relative;
  z-index: 99990;
}
#kklcb-root * { box-sizing: border-box; }
#kklcb-root [hidden] { display: none !important; }
#kklcb-root button, #kklcb-root textarea { font: inherit; }
#kklcb-root button { cursor: pointer; text-transform: none; letter-spacing: normal; margin: 0; }
#kklcb-root button:focus-visible, #kklcb-root a:focus-visible, #kklcb-root textarea:focus-visible { outline: 3px solid #a76300; outline-offset: 3px; }
#kklcb-root .kklcb-avatar { display: block; object-fit: contain; flex-shrink: 0; }
#kklcb-root .kklcb-launch {
  position: fixed; right: 24px; bottom: calc(24px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 10px 20px 10px 12px;
  background: #151718; color: #ffe019; border: 1px solid #151718; border-radius: 40px;
  box-shadow: 0 6px 24px #15242f30; font-size: 16px; font-weight: 700;
}
#kklcb-root .kklcb-launch-avatar { width: 36px; height: 36px; }
#kklcb-root .kklcb-panel {
  position: fixed; right: 24px; bottom: calc(94px + env(safe-area-inset-bottom));
  width: 440px; max-width: calc(100% - 32px); height: 710px; max-height: calc(100dvh - 126px);
  display: flex; flex-direction: column; background: #fff; border: 1px solid #94a7b6; border-radius: 20px;
  box-shadow: 0 16px 65px #15242f33; overflow: hidden; touch-action: pan-y pinch-zoom; overscroll-behavior-x: none;
}
#kklcb-root .kklcb-panel > * { min-width: 0; max-width: 100%; }
#kklcb-root .kklcb-head {
  display: flex; align-items: center; gap: 12px; flex-shrink: 0; padding: 15px 16px;
  background: #263f50; color: #fff; border-bottom: 1px solid #152d3d;
}
#kklcb-root .kklcb-head > div:nth-child(2) { min-width: 0; }
#kklcb-root .kklcb-head strong { display: block; font-size: 18px; line-height: 1.5; color: #fff; }
#kklcb-root .kklcb-head small { display: block; margin-top: 3px; font-size: 14px; line-height: 1.5; color: #e1edf5; }
#kklcb-root .kklcb-mark { display: grid; place-items: center; width: 52px; height: 52px; flex-shrink: 0; background: #fff4bb; border: 1px solid #e4c85b; border-radius: 16px; }
#kklcb-root .kklcb-mark img { width: 46px; height: 46px; }
#kklcb-root .kklcb-close { width: 44px; height: 44px; flex-shrink: 0; margin-left: auto; padding: 0; color: #fff; background: transparent; border: 0; border-radius: 10px; font-size: 30px; line-height: 1; }
#kklcb-root .kklcb-close:hover { background: #ffffff1a; }
#kklcb-root .kklcb-messages {
  flex: 1; min-height: 80px; min-width: 0; overflow-x: hidden; overflow-y: auto; scrollbar-gutter: stable;
  padding: 18px 14px 8px; background: var(--kklcb-chat); overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom; scrollbar-color: #728797 transparent;
}
#kklcb-root .kklcb-message { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; max-width: 100%; margin: 0 0 22px; }
#kklcb-root .kklcb-message > small { display: flex; align-items: center; gap: 6px; margin-bottom: 7px; color: #344755; font-size: 13px; font-weight: 600; line-height: 1.5; }
#kklcb-root .kklcb-message-avatar { width: 24px; height: 24px; object-fit: contain; }
#kklcb-root .kklcb-copy {
  min-width: 0; max-width: 100%; padding: 13px 15px; color: var(--kklcb-ink); background: #fff;
  border: 1px solid #c4d0d9; border-radius: 4px 18px 18px 18px; box-shadow: 0 1px 2px #1c34451a;
  font-size: 17px; font-weight: 400; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
}
#kklcb-root .kklcb-user { align-items: flex-end; width: calc(100% - 40px); max-width: calc(100% - 40px); margin-left: 40px; }
#kklcb-root .kklcb-user .kklcb-copy { color: #122414; background: var(--kklcb-user); border-color: #8dca6b; border-radius: 18px 4px 18px 18px; }
#kklcb-root .kklcb-sources-label { margin: 12px 0 6px; color: #253e4f; font-size: 14px; font-weight: 700; }
#kklcb-root .kklcb-sources { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; width: 100%; min-width: 0; max-width: 100%; }
#kklcb-root .kklcb-sources a {
  display: block; min-width: 0; max-width: 100%; padding: 11px 13px; color: #075b36; background: #fff;
  border: 1px solid #7eaa94; border-radius: 12px; font-size: 16px; font-weight: 600; line-height: 1.6;
  white-space: normal; overflow-wrap: anywhere; word-break: break-word; text-decoration: underline; text-underline-offset: 3px;
}
#kklcb-root .kklcb-sources a:hover { background: #edf9ec; }
#kklcb-root .kklcb-chips {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; flex-shrink: 0;
  padding: 12px 14px 8px; overflow: hidden; background: #fff; touch-action: pan-y pinch-zoom;
}
#kklcb-root .kklcb-chips button {
  min-width: 0; max-width: 100%; min-height: 44px; padding: 8px 6px; color: #243947; background: #edf3f7;
  border: 1px solid #9bafbd; border-radius: 12px; font-size: 14px; font-weight: 600; line-height: 1.5; white-space: normal;
}
#kklcb-root .kklcb-chips button:hover { background: #dfeaf2; }
#kklcb-root .kklcb-status { flex-shrink: 0; min-height: 8px; margin: 0; padding: 2px 16px; color: #744900; font-size: 14px; line-height: 1.5; }
#kklcb-root .kklcb-turnstile { flex-shrink: 0; margin: 0 14px; }
#kklcb-root .kklcb-form { display: flex; align-items: flex-end; gap: 8px; flex-shrink: 0; margin: 6px 14px 10px; padding: 8px; background: #fff; border: 2px solid #7e929f; border-radius: 16px; }
#kklcb-root .kklcb-form:focus-within { border-color: var(--kklcb-green); }
#kklcb-root textarea {
  flex: 1; min-width: 0; min-height: 52px; max-height: 120px; padding: 4px 6px; border: 0 !important;
  background: #fff !important; color: var(--kklcb-ink) !important; box-shadow: none !important; outline: none !important; resize: none;
  overflow-x: hidden; overflow-y: auto; overflow-wrap: anywhere; font-size: 17px; line-height: 1.6; touch-action: pan-y pinch-zoom;
}
#kklcb-root textarea::placeholder { color: #526270; opacity: 1; }
/* The surrounding green form border provides the focus indicator. */
#kklcb-root textarea:focus-visible { outline: none; }
#kklcb-root .kklcb-send { min-width: 58px; min-height: 46px; flex-shrink: 0; padding: 9px 12px; color: #fff; background: var(--kklcb-green); border: 1px solid #075b31; border-radius: 12px; font-size: 16px; font-weight: 700; }
#kklcb-root .kklcb-send:hover { background: #075b31; }
#kklcb-root button:disabled { cursor: default; opacity: .65; }
#kklcb-root .kklcb-foot { flex-shrink: 0; padding: 0 14px 12px; color: #435361; background: #fff; font-size: 12px; line-height: 1.6; text-align: center; }
#kklcb-root .kklcb-foot a, #kklcb-root .kklcb-clear { color: #253e4f; font-size: 13px; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
#kklcb-root .kklcb-clear { padding: 3px 6px; background: transparent; border: 0; }
#kklcb-root .kklcb-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 480px) {
  #kklcb-root .kklcb-launch { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); font-size: 16px; }
  #kklcb-root .kklcb-panel { right: 10px; bottom: calc(84px + env(safe-area-inset-bottom)); width: 440px; max-width: calc(100% - 20px); max-height: calc(100dvh - 108px); border-radius: 16px; }
  #kklcb-root .kklcb-head { gap: 9px; padding: 12px; }
  #kklcb-root .kklcb-head strong { font-size: 17px; }
  #kklcb-root .kklcb-head small { font-size: 13px; }
  #kklcb-root .kklcb-mark { width: 46px; height: 46px; }
  #kklcb-root .kklcb-mark img { width: 42px; height: 42px; }
  #kklcb-root .kklcb-messages { padding: 16px 10px 6px; }
  #kklcb-root .kklcb-copy { padding: 12px 13px; }
  #kklcb-root .kklcb-chips { gap: 6px; padding: 10px 10px 6px; }
  #kklcb-root .kklcb-form { margin-right: 10px; margin-left: 10px; }
}
@media (max-height: 550px) {
  #kklcb-root .kklcb-panel { bottom: 10px; max-height: calc(100dvh - 20px); }
  #kklcb-root .kklcb-head { padding: 9px 12px; }
  #kklcb-root .kklcb-chips { display: none; }
  #kklcb-root .kklcb-foot { padding-bottom: 6px; }
}
