.chat-panel-open {
  overflow: hidden;
}

.chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  width: 100%;
  height: 100%;
  padding: 0;
  background: rgba(17, 17, 15, 0.5);
  border: 0;
  cursor: default;
}

.chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 41;
  display: grid;
  grid-template-rows: auto auto minmax(120px, 1fr) auto;
  width: min(520px, calc(100vw - 24px));
  height: 100dvh;
  padding: 22px;
  color: var(--ink);
  background: var(--soft);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 32px rgba(17, 17, 15, 0.18);
}

.chat-backdrop[hidden],
.chat-panel[hidden] {
  display: none;
}

.chat-panel-head,
.chat-form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-panel-head {
  margin-bottom: 14px;
}

.chat-panel h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.chat-close,
.chat-submit {
  padding: 8px 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.chat-submit {
  flex: 0 0 auto;
  min-width: 70px;
  color: #fff;
  background: var(--teal);
  border-color: var(--teal);
}

.chat-submit:disabled {
  cursor: wait;
  opacity: 0.55;
}

.chat-boundary {
  margin: 0 0 12px;
  padding: 10px 12px;
  color: var(--muted);
  background: var(--mint-pale);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
  line-height: 1.45;
}

.chat-messages {
  min-height: 0;
  padding-right: 4px;
  overflow-y: auto;
}

.chat-exchange {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.chat-role,
.chat-copy,
.chat-error,
.chat-proposal-label,
.chat-proposal-meta,
.chat-proposal-note {
  margin: 0;
}

.chat-role {
  margin-top: 10px;
  color: var(--teal);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chat-copy {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.chat-proposals {
  display: grid;
  gap: 8px;
  margin-top: 7px;
}

.chat-proposal {
  padding: 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--mint);
  border-radius: 6px;
}

.chat-proposal-label {
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
}

.chat-proposal-meta,
.chat-proposal-note {
  margin-top: 4px;
  color: var(--muted-light);
  font-size: 10px;
}

.chat-proposal-payload {
  display: grid;
  grid-template-columns: minmax(90px, 0.4fr) 1fr;
  margin: 8px 0 0;
  font-size: 11px;
}

.chat-proposal-payload dt,
.chat-proposal-payload dd {
  min-width: 0;
  padding: 4px 0;
  margin: 0;
  overflow-wrap: anywhere;
  border-bottom: 1px solid var(--line);
}

.chat-proposal-payload dt {
  color: var(--muted);
  font-weight: 700;
}

.chat-form {
  padding-top: 14px;
}

.chat-input {
  display: block;
  width: 100%;
  padding: 10px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  resize: vertical;
}

.chat-form-row {
  margin-top: 8px;
}

.chat-error {
  color: var(--red);
  font-size: 11px;
}

@media (max-width: 720px) {
  .chat-panel {
    width: 100%;
    padding: 18px;
  }
}
