.lg-chat {
  --chat-ink: var(--ink, #263f36);
  --chat-accent: var(--accent, #35594a);
  --chat-paper: var(--paper, #faf7f0);
  --chat-line: var(--line, #deddd2);
  --chat-muted: var(--muted, #65736a);
  width: min(540px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100dvh - 40px);
  padding: 0;
  border: 1px solid var(--chat-line);
  border-radius: 20px;
  background: var(--chat-paper);
  color: var(--chat-ink);
  font: inherit;
  box-shadow: 0 30px 100px #13281e3b;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.lg-chat[open] {
  display: flex;
  flex-direction: column;
  animation: lg-chat-reveal 160ms ease-out;
}

.lg-chat::backdrop {
  background: #152b2459;
  backdrop-filter: blur(5px);
}

.lg-chat *,
.lg-chat *::before,
.lg-chat *::after {
  box-sizing: border-box;
}

.lg-chat button,
.lg-chat textarea {
  font: inherit;
}

.lg-chat button {
  cursor: pointer;
}

.lg-chat button:focus-visible,
.lg-chat textarea:focus-visible,
.lg-chat__transcript:focus-visible {
  outline: 3px solid var(--chat-accent);
  outline-offset: 3px;
}

.lg-chat__header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  justify-content: space-between;
  padding: 25px 26px 20px;
  flex: 0 0 auto;
}

.lg-chat__eyebrow {
  margin: 0 0 10px;
  color: var(--chat-muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .19em;
}

.lg-chat__title {
  margin: 0;
  color: var(--chat-ink);
  font-size: clamp(21px, 4.3vw, 27px);
  font-weight: 500;
  letter-spacing: -.04em;
  line-height: 1.15;
}

.lg-chat__subtitle {
  margin: 8px 0 0;
  color: var(--chat-muted);
  font-size: 13px;
  line-height: 1.45;
}

.lg-chat__close {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  margin: -4px -7px 0 0;
  padding: 0;
  border: 1px solid var(--chat-line);
  border-radius: 50%;
  background: transparent;
  color: var(--chat-ink);
  font-size: 28px !important;
  font-weight: 300;
  line-height: 1;
}

.lg-chat__close:hover {
  background: #e6eadf;
}

.lg-chat__notice {
  flex: 0 0 auto;
  margin: 0 26px;
  padding: 11px 13px;
  border: 1px solid #d9dfd1;
  border-radius: 8px;
  background: #ecf0e5;
  color: #354b3d;
  font-size: 12px;
  line-height: 1.5;
}

.lg-chat__transcript {
  flex: 1 1 260px;
  min-height: 115px;
  margin: 0;
  padding: 24px 26px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  scrollbar-width: thin;
  scrollbar-color: #b7c2b7 transparent;
}

.lg-chat__message {
  max-width: 92%;
  margin: 0 0 20px;
}

.lg-chat__message:last-child {
  margin-bottom: 0;
}

.lg-chat__sender {
  display: block;
  margin-bottom: 7px;
  color: var(--chat-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
}

.lg-chat__bubble {
  margin: 0;
  padding: 13px 15px;
  border: 1px solid var(--chat-line);
  border-radius: 2px 13px 13px;
  background: #fffdf8;
  color: var(--chat-ink);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.lg-chat__message--user {
  margin-left: auto;
}

.lg-chat__message--user .lg-chat__sender {
  text-align: right;
}

.lg-chat__message--user .lg-chat__bubble {
  border-color: var(--chat-accent);
  border-radius: 13px 2px 13px 13px;
  background: var(--chat-accent);
  color: #fffdf8;
}

.lg-chat__quick {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 26px 18px;
}

.lg-chat__quick-label {
  width: 100%;
  margin: 0 0 3px;
  color: var(--chat-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .06em;
}

.lg-chat__question {
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid #cfd6c9;
  border-radius: 8px;
  background: transparent;
  color: var(--chat-ink);
  font-size: 11px !important;
  line-height: 1.4;
  text-align: left;
  transition: background 120ms ease;
}

.lg-chat__question:hover {
  background: #e9eee3;
}

.lg-chat__form {
  flex: 0 0 auto;
  padding: 18px 26px 13px;
  border-top: 1px solid var(--chat-line);
  background: #f3f1e9;
}

.lg-chat__input-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
}

.lg-chat__input {
  display: block;
  width: 100%;
  min-height: 73px;
  max-height: 130px;
  padding: 11px 13px;
  border: 1px solid #bdc7b8;
  border-radius: 8px;
  background: #fffdf8;
  color: var(--chat-ink);
  font-size: 14px !important;
  line-height: 1.5;
  resize: vertical;
}

.lg-chat__input::placeholder {
  color: var(--chat-muted);
  opacity: 1;
}

.lg-chat__input-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 7px 0 12px;
  color: var(--chat-muted);
  font-size: 10px;
  line-height: 1.4;
}

.lg-chat__counter {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.lg-chat__send {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 12px 16px;
  border: 1px solid var(--chat-accent);
  border-radius: 8px;
  background: var(--chat-accent);
  color: #fffdf8;
  font-size: 12px !important;
  font-weight: 600;
}

.lg-chat__send:hover:not(:disabled) {
  filter: brightness(1.12);
}

.lg-chat__send:disabled {
  border-color: #d5d9ce;
  background: #d5d9ce;
  color: #677261;
  cursor: default;
}

.lg-chat__footer {
  margin: 11px 0 0;
  color: var(--chat-muted);
  font-size: 10px;
  line-height: 1.4;
  text-align: center;
}

@keyframes lg-chat-reveal {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 580px) {
  .lg-chat {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
    border-radius: 15px;
  }

  .lg-chat__header { padding: 20px 18px 16px; }
  .lg-chat__notice { margin-inline: 18px; }
  .lg-chat__transcript { padding-inline: 18px; }
  .lg-chat__quick { padding-inline: 18px; }
  .lg-chat__form { padding: 15px 18px 12px; }
  .lg-chat__question { min-height: 44px; }
  .lg-chat__input { font-size: 16px !important; }
}

@media (max-height: 620px) {
  .lg-chat { overflow-y: auto; }
  .lg-chat__transcript { flex-basis: 160px; min-height: 100px; }
  .lg-chat__header { padding-block: 15px 12px; }
  .lg-chat__quick { padding-bottom: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .lg-chat[open] { animation: none; }
  .lg-chat__question { transition: none; }
}
