#paintChatbot,
#paintChatbot * {
  box-sizing: border-box;
}

#paintChatbot {
  --nce-red: #e10a18;
  --nce-red-dark: #b40612;
  --nce-red-soft: #fff2f3;
  --nce-navy: #16202a;
  --nce-navy-2: #243244;
  --nce-ink: #1f2933;
  --nce-muted: #697586;
  --nce-line: #dfe4ea;
  --nce-page: #f6f7f9;
  --nce-white: #ffffff;
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: calc(max(20px, env(safe-area-inset-bottom)) + 59px);
  z-index: 1200;
  font-family: "Josefin Sans", Arial, Helvetica, sans-serif;
  color: var(--nce-ink);
  letter-spacing: 0;
}

#paintChatbot button,
#paintChatbot input,
#paintChatbot textarea,
#paintChatbot select {
  font: inherit;
  letter-spacing: 0;
}

.nce-launcher {
  width: 58px;
  height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  background: var(--nce-red);
  color: var(--nce-white);
  box-shadow: 0 18px 38px rgba(22, 32, 42, 0.28);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.nce-launcher:hover,
.nce-launcher:focus-visible {
  background: var(--nce-red-dark);
  transform: translateY(-2px);
  box-shadow: 0 22px 46px rgba(22, 32, 42, 0.34);
  outline: none;
}

.nce-launcher i {
  font-size: 29px;
}

.nce-launcher-label {
  position: absolute;
  right: 70px;
  bottom: 10px;
  border-radius: 6px;
  background: var(--nce-navy);
  color: var(--nce-white);
  padding: 8px 11px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 12px 24px rgba(22, 32, 42, 0.18);
}

.nce-panel {
  width: min(400px, calc(100vw - 32px));
  height: min(720px, calc(100dvh - 100px));
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: var(--nce-white);
  border: 1px solid var(--nce-line);
  border-radius: 8px;
  box-shadow: 0 26px 72px rgba(12, 18, 28, 0.3);
}

#paintChatbot.is-open .nce-panel {
  display: flex;
}

#paintChatbot.is-open .nce-launcher,
#paintChatbot.is-open .nce-launcher-label {
  display: none;
}

#paintChatbot.is-minimized .nce-panel {
  height: 72px;
}

#paintChatbot.is-minimized .nce-body,
#paintChatbot.is-minimized .nce-composer,
#paintChatbot.is-minimized .nce-statusbar {
  display: none;
}

.nce-header {
  min-height: 72px;
  background: var(--nce-navy);
  color: var(--nce-white);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
}

.nce-logo {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: var(--nce-white);
  object-fit: contain;
  padding: 4px;
  flex: 0 0 44px;
}

.nce-title {
  flex: 1;
  min-width: 0;
}

.nce-title strong,
.nce-title span {
  display: block;
  line-height: 1.2;
}

.nce-title strong {
  font-size: 15px;
  font-weight: 800;
}

.nce-title span {
  color: #d8dde5;
  font-size: 12px;
  margin-top: 3px;
}

.nce-header-actions,
.nce-row-actions,
.nce-card-actions,
.nce-downloads,
.nce-quick-grid,
.nce-chip-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.nce-header-actions {
  flex-wrap: nowrap;
}

.nce-icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  color: var(--nce-white);
  cursor: pointer;
}

.nce-icon-btn:hover,
.nce-icon-btn:focus-visible {
  background: rgba(255, 255, 255, 0.16);
  outline: none;
}

.nce-body {
  flex: 1;
  min-height: 0;
  background: var(--nce-page);
  display: flex;
}

.nce-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.nce-message {
  max-width: 93%;
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 14px;
  line-height: 1.45;
  box-shadow: 0 7px 18px rgba(16, 24, 40, 0.06);
}

.nce-message.bot {
  align-self: flex-start;
  background: var(--nce-white);
  border: 1px solid var(--nce-line);
}

.nce-message.user {
  align-self: flex-end;
  color: var(--nce-white);
  background: var(--nce-navy-2);
}

.nce-message.system {
  align-self: center;
  max-width: 100%;
  color: var(--nce-muted);
  background: transparent;
  box-shadow: none;
  padding: 3px 8px;
  font-size: 12px;
}

.nce-message p,
.nce-card p,
.nce-welcome p {
  margin: 0;
}

.nce-message strong,
.nce-card strong,
.nce-form-title {
  color: var(--nce-navy);
}

.nce-welcome {
  background: var(--nce-white);
  border: 1px solid var(--nce-line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.06);
}

.nce-welcome h2 {
  margin: 0 0 5px;
  color: var(--nce-navy);
  font-size: 18px;
  line-height: 1.2;
}

.nce-welcome p,
.nce-note,
.nce-meta,
.nce-muted {
  color: var(--nce-muted);
  font-size: 12px;
  line-height: 1.45;
}

.nce-upload-zone {
  margin: 12px 0;
  border: 1px dashed #f0a3a9;
  border-radius: 8px;
  background: var(--nce-red-soft);
  padding: 12px;
}

.nce-upload-zone button {
  width: 100%;
}

.nce-quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.nce-quick {
  border: 1px solid var(--nce-line);
  border-radius: 8px;
  min-height: 68px;
  padding: 10px;
  background: var(--nce-white);
  color: var(--nce-navy);
  text-align: left;
  cursor: pointer;
  display: flex;
  gap: 9px;
  align-items: center;
}

.nce-quick i {
  color: var(--nce-red);
  font-size: 21px;
  flex: 0 0 22px;
}

.nce-quick span {
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

.nce-quick:hover,
.nce-quick:focus-visible {
  border-color: var(--nce-red);
  box-shadow: 0 8px 18px rgba(225, 10, 24, 0.12);
  outline: none;
}

.nce-card,
.nce-form,
.nce-product,
.nce-calc-result,
.nce-upload-preview {
  border: 1px solid var(--nce-line);
  border-radius: 8px;
  background: var(--nce-white);
  padding: 12px;
  margin-top: 9px;
}

.nce-card + .nce-card,
.nce-product + .nce-product {
  margin-top: 8px;
}

.nce-product {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
}

.nce-product-image {
  width: 72px;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 6px;
  background: #eef1f5;
}

.nce-product img,
.nce-preview-img {
  width: 100%;
  border-radius: 6px;
  object-fit: cover;
  background: #eef1f5;
}

.nce-product img {
  aspect-ratio: 1 / 1;
}

.nce-product-image img {
  height: 100%;
  display: block;
}

.nce-variant {
  display: grid;
  gap: 4px;
  margin: 8px 0;
  color: var(--nce-navy);
  font-size: 11px;
  font-weight: 800;
}

.nce-variant select {
  width: 100%;
  min-height: 35px;
  border: 1px solid #cfd6df;
  border-radius: 6px;
  background: #fff;
  color: var(--nce-ink);
  padding: 6px 8px;
}

.nce-shop-link {
  margin-top: 12px !important;
}

.nce-ai-notice {
  margin-top: 7px !important;
  padding: 7px 8px;
  border-left: 3px solid #98a2b3;
  background: #f7f8fa;
}

.nce-quote-line {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding: 9px 0;
  border-top: 1px solid var(--nce-line);
}

.nce-quote-line img {
  width: 50px;
  height: 50px;
  border-radius: 6px;
  object-fit: cover;
  background: #eef1f5;
}

.nce-quote-line small,
.nce-quote-line b {
  display: block;
  margin-top: 2px;
  color: var(--nce-muted);
  font-size: 11px;
  line-height: 1.3;
}

.nce-quote-line b {
  color: var(--nce-navy);
  font-size: 12px;
}

.nce-quote-totals {
  display: grid;
  gap: 5px;
  padding-top: 10px;
  border-top: 1px solid var(--nce-line);
}

.nce-quote-totals span,
.nce-quote-totals strong {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.nce-quote-totals strong {
  margin-top: 3px;
  padding: 10px;
  border-radius: 6px;
  background: var(--nce-navy);
  color: #fff;
  font-size: 15px;
}

.nce-quote-totals strong b {
  color: #fff;
}

.nce-product h3,
.nce-card h3 {
  margin: 0 0 4px;
  color: var(--nce-navy);
  font-size: 14px;
  line-height: 1.25;
}

.nce-product p {
  color: var(--nce-muted);
  font-size: 12px;
  line-height: 1.35;
}

.nce-price {
  color: var(--nce-red);
  font-weight: 800;
}

.nce-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 8px 0;
}

.nce-meta-pill {
  border-radius: 6px;
  background: #f1f3f6;
  color: var(--nce-navy);
  padding: 6px 7px;
  font-size: 11px;
  line-height: 1.25;
}

.nce-palette {
  display: grid;
  grid-template-columns: repeat(5, minmax(42px, 1fr));
  gap: 7px;
  margin-top: 9px;
}

.nce-swatch {
  min-width: 0;
}

.nce-swatch-color {
  height: 38px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.nce-swatch span,
.nce-swatch small {
  display: block;
  overflow-wrap: anywhere;
}

.nce-swatch span {
  margin-top: 4px;
  color: var(--nce-navy);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
}

.nce-swatch small {
  color: var(--nce-muted);
  font-size: 10px;
  line-height: 1.2;
}

.nce-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.nce-autocomplete {
  position: relative;
}

.nce-suggestions {
  position: absolute;
  z-index: 12;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 230px;
  overflow-y: auto;
  border: 1px solid #d8dee8;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(16, 24, 40, 0.16);
}

.nce-suggestion {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  border-bottom: 1px solid #eef1f5;
  background: #fff;
  color: var(--nce-navy);
  text-align: left;
  cursor: pointer;
}

.nce-suggestion:hover,
.nce-suggestion:focus {
  background: #fff5f5;
  outline: none;
}

.nce-suggestion span,
.nce-suggestion small {
  display: block;
}

.nce-suggestion small,
.nce-suggestion-empty {
  color: var(--nce-muted);
  font-size: 11px;
}

.nce-suggestion-empty {
  padding: 10px;
}

.nce-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nce-field.full {
  grid-column: 1 / -1;
}

.nce-field span {
  color: var(--nce-navy);
  font-size: 11px;
  font-weight: 800;
}

.nce-field input,
.nce-field textarea,
.nce-field select,
.nce-composer textarea {
  width: 100%;
  border: 1px solid var(--nce-line);
  border-radius: 6px;
  background: var(--nce-white);
  color: var(--nce-ink);
  padding: 9px 10px;
  font-size: 13px;
  line-height: 1.35;
}

.nce-field textarea {
  resize: vertical;
  min-height: 70px;
}

.nce-field input:focus,
.nce-field textarea:focus,
.nce-field select:focus,
.nce-composer textarea:focus {
  border-color: var(--nce-red);
  box-shadow: 0 0 0 3px rgba(225, 10, 24, 0.12);
  outline: none;
}

.nce-primary,
.nce-secondary,
.nce-link-btn,
.nce-danger {
  min-height: 34px;
  border-radius: 6px;
  padding: 8px 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}

.nce-primary {
  border: 1px solid var(--nce-red);
  background: var(--nce-red);
  color: var(--nce-white);
}

.nce-primary:hover,
.nce-primary:focus-visible {
  background: var(--nce-red-dark);
  border-color: var(--nce-red-dark);
  color: var(--nce-white);
  outline: none;
}

.nce-secondary,
.nce-link-btn {
  border: 1px solid var(--nce-line);
  background: var(--nce-white);
  color: var(--nce-navy);
}

.nce-secondary:hover,
.nce-link-btn:hover,
.nce-secondary:focus-visible,
.nce-link-btn:focus-visible {
  border-color: var(--nce-red);
  color: var(--nce-red);
  outline: none;
}

.nce-danger {
  border: 1px solid #f3c7cb;
  background: #fff7f8;
  color: var(--nce-red-dark);
}

.nce-action-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.nce-statusbar {
  min-height: 28px;
  background: #f9fafb;
  border-top: 1px solid var(--nce-line);
  color: var(--nce-muted);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  font-size: 11px;
}

.nce-composer {
  border-top: 1px solid var(--nce-line);
  background: var(--nce-white);
  padding: 10px;
  display: grid;
  grid-template-columns: 36px 1fr 38px;
  gap: 8px;
  align-items: end;
}

.nce-composer .nce-icon-btn {
  width: 36px;
  height: 36px;
  border-color: var(--nce-line);
  background: #f6f7f9;
  color: var(--nce-navy);
}

.nce-composer textarea {
  resize: none;
  min-height: 38px;
  max-height: 112px;
}

.nce-send {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--nce-red);
  color: var(--nce-white);
  cursor: pointer;
}

.nce-send:hover,
.nce-send:focus-visible {
  background: var(--nce-red-dark);
  outline: none;
}

.nce-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.nce-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--nce-red);
  opacity: 0.35;
  animation: nceTyping 1s infinite ease-in-out;
}

.nce-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.nce-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

.nce-hidden {
  display: none !important;
}

@keyframes nceTyping {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }
  40% {
    transform: translateY(-3px);
    opacity: 1;
  }
}

@media (max-width: 640px) {
  #paintChatbot {
    right: max(20px, env(safe-area-inset-right));
    bottom: calc(max(20px, env(safe-area-inset-bottom)) + 57px);
  }

  #paintChatbot.is-open {
    inset: auto max(12px, env(safe-area-inset-right)) calc(max(20px, env(safe-area-inset-bottom)) + 57px) max(12px, env(safe-area-inset-left));
  }

  #paintChatbot.is-open .nce-panel {
    width: 100%;
    height: min(86dvh, 720px);
    border-radius: 10px;
  }

  .nce-launcher {
    width: 54px;
    height: 54px;
  }

  .nce-launcher-label {
    display: none;
  }

  .nce-quick-grid,
  .nce-form-grid,
  .nce-meta-grid {
    grid-template-columns: 1fr;
  }

  .nce-product {
    grid-template-columns: 60px minmax(0, 1fr);
  }

  .nce-product-image {
    width: 60px;
  }

  .nce-statusbar {
    flex-direction: column;
  }

  body.nce-dialog-open {
    overflow: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  #paintChatbot *,
  #paintChatbot *::before,
  #paintChatbot *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
