/* NLS Room Visualiser, chat widget (WordPress plugin).
   Self-contained: every rule is scoped under .nlsv so it can drop into the WordPress theme
   without touching Divi. Tokens mirror hub.css (forest / moss / sage / clay / paper / sand). */

.nlsv {
  --v-forest: #26332A; --v-moss: #5E7355; --v-sage: #93A488; --v-clay: #B4714E;
  --v-paper: #FAF7F1; --v-sand: #EBE3D6; --v-ink: #1C1F1A; --v-panel: #FFFDF9;
  --v-body: #4F544B; --v-muted: #6E7369; --v-line: #DDD2C0; --v-error: #A1391F;
  --v-display: 'Fraunces', Georgia, serif;
  --v-sans: 'Karla', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-family: var(--v-sans); color: var(--v-ink); font-size: 16px; line-height: 1.5;
}
.nlsv *, .nlsv *::before, .nlsv *::after { box-sizing: border-box; }
.nlsv button { font: inherit; }

/* ---------- Launcher ---------- */
.nlsv-launcher {
  position: fixed; right: 20px; bottom: 20px; z-index: 99998;
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 56px; padding: 0 22px 0 16px; border: 0; border-radius: 999px;
  background: var(--v-forest); color: var(--v-paper); cursor: pointer;
  font-weight: 600; font-size: 15.5px; letter-spacing: .01em;
  box-shadow: 0 8px 28px rgba(28, 31, 26, .28);
  transition: transform .2s ease, background .2s ease;
}
.nlsv-launcher:hover { filter: brightness(.88); transform: translateY(-2px); }
.nlsv-launcher:focus-visible { outline: 3px solid var(--v-clay); outline-offset: 3px; }
.nlsv-launcher-icon {
  width: 36px; height: 36px; border-radius: 50%; background: #fff; overflow: hidden;
  display: grid; place-items: center; flex: none; color: var(--v-forest);
}
.nlsv-launcher-icon img { width: 100%; height: 100%; object-fit: contain; display: block; }
.nlsv-launcher[hidden] { display: none; }

/* ---------- Panel ---------- */
.nlsv-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 99999;
  width: min(440px, calc(100vw - 32px));
  height: min(760px, calc(100vh - 40px));
  display: flex; flex-direction: column;
  background: var(--v-paper); border: 1px solid var(--v-line); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(28, 31, 26, .30);
  overflow: hidden;
  animation: nlsv-in .28s ease both;
}
.nlsv-panel[hidden] { display: none; }
@keyframes nlsv-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }

.nlsv-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 12px 14px 18px; background: var(--v-forest); color: var(--v-paper);
}
.nlsv-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none; overflow: hidden;
  background: #fff; color: var(--v-forest); display: grid; place-items: center;
  font-family: var(--v-display); font-size: 17px; font-weight: 500;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .25);
}
.nlsv-avatar img { width: 100%; height: 100%; object-fit: contain; display: block; }
.nlsv-head-text { flex: 1; min-width: 0; }
.nlsv-title { margin: 0; font-family: var(--v-display); font-weight: 500; font-size: 18px; line-height: 1.2; }
/* Themes (Divi) color and size headings with their own rules; keep the header title readable on the main color. */
.nlsv .nlsv-panel .nlsv-head h2.nlsv-title { color: #fff; margin: 0; padding: 0; font-size: 18px; line-height: 1.2; font-family: var(--v-display); font-weight: 500; letter-spacing: 0; text-transform: none; }
.nlsv .nlsv-panel .nlsv-head .nlsv-sub { color: rgba(255, 255, 255, .8); padding: 0; }
.nlsv-sub { margin: 2px 0 0; font-size: 13px; opacity: .78; }
.nlsv-icon-btn {
  width: 44px; height: 44px; border: 0; border-radius: 10px; flex: none;
  background: transparent; color: inherit; cursor: pointer; display: grid; place-items: center;
}
.nlsv-icon-btn:hover { background: rgba(255, 255, 255, .1); }
.nlsv-icon-btn:focus-visible { outline: 2px solid var(--v-sand); outline-offset: -2px; }

.nlsv-progress { height: 3px; background: rgba(38, 51, 42, .12); }
.nlsv-progress span { display: block; height: 100%; width: 0; background: var(--v-clay); transition: width .35s ease; }

/* ---------- Log ---------- */
.nlsv-log {
  flex: 1; overflow-y: auto; padding: 18px 16px 8px;
  display: flex; flex-direction: column; gap: 10px;
  overscroll-behavior: contain;
}
.nlsv-log > * { flex-shrink: 0; } /* cards have aspect-ratio heights; don't let the fixed-height log squash them */
.nlsv-msg {
  max-width: 88%; padding: 11px 15px; border-radius: 16px;
  font-size: 15px; line-height: 1.5; animation: nlsv-pop .22s ease both;
}
.nlsv-msg p { margin: 0; }
.nlsv-msg p + p { margin-top: 8px; }
.nlsv-msg a { color: var(--v-forest); font-weight: 600; }
.nlsv-bot { align-self: flex-start; background: var(--v-panel); border: 1px solid var(--v-sand); border-bottom-left-radius: 4px; color: var(--v-body); }
.nlsv-bot strong { color: var(--v-ink); }
.nlsv-user { align-self: flex-end; background: var(--v-moss); color: #fff; border-bottom-right-radius: 4px; }
.nlsv-wide { max-width: 100%; width: 100%; }
@keyframes nlsv-pop { from { opacity: 0; transform: translateY(6px); } }

.nlsv-typing { display: inline-flex; gap: 4px; padding: 14px 16px; }
.nlsv-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--v-sage); animation: nlsv-dot 1s infinite ease-in-out; }
.nlsv-typing i:nth-child(2) { animation-delay: .15s; }
.nlsv-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes nlsv-dot { 0%, 80%, 100% { opacity: .3; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------- Choice chips ---------- */
.nlsv-choices { display: flex; flex-wrap: wrap; gap: 8px; align-self: stretch; }
.nlsv-chip {
  min-height: 44px; padding: 8px 16px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--v-moss); background: var(--v-panel); color: var(--v-forest);
  font-weight: 600; font-size: 14.5px; display: inline-flex; align-items: center; gap: 8px;
  transition: background .15s ease, color .15s ease;
}
.nlsv-chip:hover { background: var(--v-moss); color: #fff; }
.nlsv-chip:focus-visible { outline: 3px solid var(--v-clay); outline-offset: 2px; }
.nlsv-chip:disabled { opacity: .45; cursor: default; background: var(--v-panel); color: var(--v-forest); }

.nlsv-styles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-self: stretch; }
.nlsv-style {
  text-align: left; padding: 12px; border-radius: 12px; cursor: pointer; min-height: 44px;
  border: 1.5px solid var(--v-line); background: var(--v-panel); color: var(--v-ink);
  transition: border-color .15s ease, transform .15s ease;
}
.nlsv-style:hover { border-color: var(--v-moss); transform: translateY(-1px); }
.nlsv-style:focus-visible { outline: 3px solid var(--v-clay); outline-offset: 2px; }
.nlsv-style:disabled { opacity: .45; cursor: default; transform: none; }
.nlsv-style b { display: block; font-family: var(--v-display); font-weight: 500; font-size: 16px; }
.nlsv-style small { display: block; color: var(--v-muted); font-size: 12.5px; line-height: 1.35; margin-top: 3px; }
.nlsv-swatches { display: flex; margin-bottom: 8px; }
.nlsv-swatches span { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--v-panel); margin-right: -6px; }

/* ---------- Upload ---------- */
.nlsv-drop {
  align-self: stretch; display: grid; place-items: center; text-align: center; gap: 6px;
  padding: 22px 16px; border: 2px dashed var(--v-sage); border-radius: 14px;
  background: var(--v-panel); cursor: pointer; color: var(--v-body);
  transition: border-color .15s ease, background .15s ease;
}
.nlsv-drop:hover, .nlsv-drop.is-over { border-color: var(--v-moss); background: #F4F1E8; }
.nlsv-drop:focus-within { outline: 3px solid var(--v-clay); outline-offset: 2px; }
.nlsv-drop b { color: var(--v-forest); font-size: 15.5px; }
.nlsv-drop small { font-size: 13px; color: var(--v-muted); }
.nlsv-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.nlsv-privacy { font-size: 12.5px; color: var(--v-muted); margin: 0; align-self: stretch; }
.nlsv-link {
  background: none; border: 0; padding: 10px 0; min-height: 44px; cursor: pointer;
  color: var(--v-forest); font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}

/* ---------- Result card ---------- */
.nlsv-card {
  align-self: stretch; background: var(--v-panel); border: 1px solid var(--v-sand);
  border-radius: 14px; overflow: hidden; animation: nlsv-pop .3s ease both;
}
.nlsv-card-body { padding: 12px 14px 14px; }
.nlsv-card h4 { margin: 0 0 2px; font-family: var(--v-display); font-weight: 500; font-size: 17px; color: var(--v-ink); }
.nlsv-card p { margin: 0; font-size: 13.5px; color: var(--v-muted); }
.nlsv-palette { display: flex; gap: 6px; margin-top: 10px; }
.nlsv-palette span { flex: 1; height: 28px; border-radius: 6px; position: relative; }

.nlsv-ba { position: relative; aspect-ratio: 4 / 3; background: var(--v-sand); overflow: hidden; --pos: 50%; }
.nlsv-ba img, .nlsv-ba canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.nlsv-ba .nlsv-after { clip-path: inset(0 0 0 var(--pos)); }
.nlsv-ba-line { position: absolute; top: 0; bottom: 0; left: var(--pos); width: 2px; background: #fff; transform: translateX(-1px); pointer-events: none; z-index: 2; }
.nlsv-ba-knob {
  position: absolute; top: 50%; left: var(--pos); transform: translate(-50%, -50%); z-index: 2;
  width: 44px; height: 44px; border-radius: 50%; background: #fff; color: var(--v-ink);
  display: grid; place-items: center; pointer-events: none; box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
}
.nlsv-ba-tag {
  position: absolute; bottom: 10px; z-index: 3; pointer-events: none;
  background: rgba(28, 31, 26, .78); color: var(--v-paper);
  font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; padding: 5px 9px;
}
.nlsv-ba-tag.l { left: 10px; } .nlsv-ba-tag.r { right: 10px; }
.nlsv-ba input[type=range] {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; z-index: 4;
  opacity: 0; cursor: ew-resize; -webkit-appearance: none; appearance: none;
}
.nlsv-ba:has(input:focus-visible) { outline: 3px solid var(--v-clay); outline-offset: 2px; }
.nlsv-badge {
  position: absolute; top: 10px; left: 10px; z-index: 3; pointer-events: none;
  background: var(--v-clay); color: #fff; font-size: 11px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; padding: 5px 9px; border-radius: 4px;
}
.nlsv-rendering {
  position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: rgba(250, 247, 241, .78); backdrop-filter: blur(3px); color: var(--v-forest); font-weight: 600; font-size: 14.5px;
}
.nlsv-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--v-sand); border-top-color: var(--v-clay); animation: nlsv-spin .9s linear infinite; }
@keyframes nlsv-spin { to { transform: rotate(360deg); } }

/* ---------- Summary ---------- */
.nlsv-summary { margin: 8px 0 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.nlsv-summary dt { color: var(--v-muted); }
.nlsv-summary dd { margin: 0; color: var(--v-ink); word-break: break-word; }

.nlsv-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--v-clay); color: #fff; font-weight: 700; font-size: 15px; text-decoration: none;
}
.nlsv-btn:hover { filter: brightness(.9); }
.nlsv-btn:focus-visible { outline: 3px solid var(--v-forest); outline-offset: 2px; }
.nlsv-btn[disabled] { opacity: .6; cursor: default; }
.nlsv-btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-self: stretch; }
.nlsv-btn-row .nlsv-btn { flex: 1 1 auto; }

/* ---------- Composer ---------- */
.nlsv-composer { border-top: 1px solid var(--v-sand); background: var(--v-panel); padding: 10px 12px 12px; }
.nlsv-composer[hidden] { display: none; }
.nlsv-form { display: flex; gap: 8px; align-items: center; }
.nlsv-input {
  flex: 1; min-width: 0; min-height: 48px; padding: 0 14px; font: inherit; font-size: 16px;
  border: 1.5px solid var(--v-line); border-radius: 12px; background: #fff; color: var(--v-ink);
}
.nlsv-input:focus { outline: none; border-color: var(--v-moss); box-shadow: 0 0 0 3px rgba(94, 115, 85, .2); }
.nlsv-input[aria-invalid=true] { border-color: var(--v-error); }
.nlsv-send {
  width: 48px; height: 48px; border-radius: 12px; border: 0; flex: none; cursor: pointer;
  background: var(--v-forest); color: #fff; display: grid; place-items: center;
}
.nlsv-send:hover { background: var(--v-moss); }
.nlsv-send:focus-visible { outline: 3px solid var(--v-clay); outline-offset: 2px; }
.nlsv-error { margin: 6px 2px 0; font-size: 13px; color: var(--v-error); min-height: 0; }
.nlsv-error:empty { display: none; }
.nlsv-foot { margin: 8px 2px 0; font-size: 11.5px; color: var(--v-muted); }
.nlsv-foot a { color: inherit; }

.nlsv-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Left-hand placement */
.nlsv--left .nlsv-launcher, .nlsv--left .nlsv-panel { right: auto; left: 20px; }

/* Shown to administrators in Test mode only */
.nlsv-testpill {
  display: inline-block; vertical-align: middle; margin-left: 6px; padding: 2px 8px; border-radius: 999px;
  background: #F2C94C; color: #3A2E00; font-family: var(--v-sans); font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
}

/* [nls_visualiser] shortcode button, lives in page content, outside .nlsv */
.nlsv-open-btn {
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 24px; border: 0; border-radius: 999px;
  background: var(--nlsv-accent, #B4714E); color: #fff; font: 700 16px/1 'Karla', system-ui, sans-serif; cursor: pointer;
}
.nlsv-open-btn:hover { filter: brightness(.9); }
.nlsv-open-btn:focus-visible { outline: 3px solid var(--nlsv-primary, #26332A); outline-offset: 3px; }

@media (max-width: 560px) {
  .nlsv-panel { right: 0; bottom: 0; width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .nlsv-launcher { right: 16px; bottom: 16px; }
  .nlsv--left .nlsv-panel { left: 0; }
  .nlsv--left .nlsv-launcher { left: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .nlsv *, .nlsv *::before, .nlsv *::after { animation: none !important; transition: none !important; }
}
