.cne-cs {
  --cne-paper: var(--ne-cream-100, #fbf6ee);
  --cne-ink: var(--ne-brown-900, #35241d);
  --cne-gold: var(--ne-gold-400, #c5a46a);
  --cne-edge: #dfd1bc;
  --cne-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  --cne-panel-bottom: calc(var(--cne-bottom) + 58px);
  position: fixed;
  z-index: 9997;
  left: max(22px, env(safe-area-inset-left, 0px));
  bottom: var(--cne-bottom);
  color: var(--cne-ink);
  font-family: inherit;
  line-height: 1.5;
}

body.nav-open .cne-cs {
  visibility: hidden;
  pointer-events: none;
}

.cne-cs button, .cne-cs textarea, .cne-cs a {
  font: inherit;
  font-size: 17px;
}

.cne-cs button, .cne-cs a {
  -webkit-tap-highlight-color: transparent;
}

.cne-cs button:focus-visible, .cne-cs a:focus-visible,
.cne-cs textarea:focus-visible, .cne-cs-log:focus-visible {
  outline: 2px solid #80591c;
  outline-offset: 2px;
}

.cne-cs-launch, .cne-cs-form button {
  min-height: 46px;
  background: var(--cne-ink);
  color: var(--cne-paper);
  border: 1px solid var(--cne-gold);
  font-weight: 700;
  cursor: pointer;
}

.cne-cs .cne-cs-launch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 999px;
  box-shadow: 0 6px 20px #35241d28;
}

.cne-cs-launch svg {
  color: var(--cne-gold);
}

.cne-cs-panel {
  position: fixed;
  left: inherit;
  bottom: var(--cne-panel-bottom);
  width: min(366px, calc(100vw - 44px));
  height: min(560px, calc(100vh - var(--cne-panel-bottom) - 80px));
  height: min(560px, calc(100dvh - var(--cne-panel-bottom) - 80px));
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
  border: 1px solid var(--cne-edge);
  border-radius: 16px;
  background: var(--cne-paper);
  box-shadow: 0 12px 38px #35241d2b;
}

.cne-cs [hidden] {
  display: none;
}

.cne-cs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  padding: 4px 8px 4px 14px;
  border-bottom: 1px solid var(--cne-edge);
}

.cne-cs .cne-cs-header h2 {
  margin: 0;
  color: var(--cne-ink);
  font: inherit;
  font-size: 17px;
  font-weight: 750;
}

.cne-cs .cne-cs-close {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--cne-ink);
  font-size: 25px;
  cursor: pointer;
}

.cne-cs-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 12px 14px;
  font-size: 17px;
}

.cne-cs .cne-cs-message {
  margin: 0 0 9px;
  padding: 9px 11px;
  background: #fff;
  border: 1px solid var(--cne-edge);
  border-radius: 10px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.cne-cs .cne-cs-user {
  margin-left: 24px;
  background: #eee2d0;
}

.cne-cs-wa {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--cne-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cne-cs-form {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-end;
  gap: 8px;
  margin: 0;
  padding: 8px 10px;
  border-top: 1px solid var(--cne-edge);
}

.cne-cs .cne-cs-form textarea {
  box-sizing: border-box;
  flex: 1;
  min-width: 0;
  width: 100%;
  min-height: 44px;
  padding: 7px 9px;
  border: 1px solid #ad9275;
  border-radius: 8px;
  background: #fff;
  color: var(--cne-ink);
  font-size: 17px;
  line-height: 1.45;
  resize: none;
  max-height: 108px;
}

.cne-cs .cne-cs-form button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 8px;
}

.cne-cs button:disabled {
  opacity: .6;
  cursor: wait;
}

.cne-cs-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.cne-cs-privacy {
  flex: 0 0 auto;
  margin: 0;
  padding: 7px 12px;
  background: #f2e8da;
  border-bottom: 1px solid var(--cne-edge);
}

.cne-cs .cne-cs-privacy a {
  color: #503b2a;
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cne-cs-header { flex: 0 0 auto; }

.cne-cs-options {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0 0 10px;
}

.cne-cs-options button,
.cne-cs .cne-cs-wa {
  min-height: 46px;
  padding: 7px 11px;
  border: 1px solid #aa8656;
  border-radius: 8px;
  background: #f6ebd8;
  color: #38271d;
  font-weight: 700;
  cursor: pointer;
}

.cne-cs .cne-cs-wa {
  margin-top: 8px;
  background: #35241d;
  color: #fff6e9;
  text-decoration: none;
}

.cne-cs-review {
  padding: 11px;
  margin-bottom: 10px;
  border: 1px solid #ad9275;
  border-radius: 10px;
  background: #fff;
}

.cne-cs-review p { margin: 0 0 12px; white-space: pre-line; overflow-wrap: anywhere; }
.cne-cs-review .cne-cs-options { margin-bottom: 0; }
.cne-cs-fields label { display: block; margin-bottom: 9px; font-weight: 700; }

.cne-cs-fields textarea {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 48px;
  margin-top: 2px;
  padding: 3px 7px;
  color: var(--cne-ink);
  background: #fff;
  border: 1px solid #ad9275;
  border-radius: 5px;
}

@media (max-width: 640px) {
  body.cne-cs-mobile-open { overflow: hidden; }

  .cne-cs {
    --cne-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    left: max(14px, env(safe-area-inset-left, 0px));
  }

  .cne-cs.cne-cs-open { z-index: 10010; }
  .cne-cs-open .cne-cs-launch { visibility: hidden; }

  .cne-cs-panel {
    left: max(8px, env(safe-area-inset-left, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
    top: calc(var(--cne-visible-top, 0px) + max(8px, env(safe-area-inset-top, 0px)));
    bottom: auto;
    width: auto;
    height: calc(var(--cne-visible-height, 100dvh) - max(8px, env(safe-area-inset-top, 0px)) - max(8px, env(safe-area-inset-bottom, 0px)));
  }

  .cne-cs-compact .cne-cs-log > .cne-cs-options {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 2px 2px 4px;
    margin-bottom: 2px;
  }

  .cne-cs-compact .cne-cs-log > .cne-cs-options button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .cne-cs-log { padding: 10px; }
  .cne-cs .cne-cs-message { margin-bottom: 7px; padding: 7px 9px; }
}
