/* Чат: мессенджер внутри игры. */

.chat-shell {
  width: min(880px, 96vw);
  height: min(880px, 94vh);
  margin: auto;
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #0f141c 0%, #0a0e14 100%);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.025);
}

.chat-back {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line-soft);
  background: transparent;
  color: var(--ink-dim);
  font-size: 17px;
}
.chat-back:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #0b0e12;
  flex: 0 0 auto;
}

.chat-id { display: flex; flex-direction: column; min-width: 0; }
.chat-name { font-size: 15.5px; font-weight: 700; line-height: 1.2; }
.chat-role { font-size: 12.5px; color: var(--ink-mute); }

.chat-status {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--ink-mute);
}
.chat-status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 8px rgba(110, 231, 168, 0.7);
}
.chat-status i.is-off { background: var(--ink-mute); box-shadow: none; }

.chat-finish {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 138, 61, 0.12);
  color: var(--accent-soft);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
}
.chat-finish:hover { background: rgba(255, 138, 61, 0.2); }
.chat-finish[disabled] { opacity: 0.4; pointer-events: none; }

.chat-body {
  overflow-y: auto;
  padding: 20px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.msg { max-width: 82%; }
.msg-body {
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-assistant .msg-body {
  background: #161d27;
  border: 1px solid var(--line-soft);
  border-bottom-left-radius: 5px;
  color: var(--ink);
}
.msg-user { align-self: flex-end; }
.msg-user .msg-body {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #1a0d03;
  font-weight: 500;
  border-bottom-right-radius: 5px;
}
.msg-system {
  max-width: 100%;
  align-self: center;
  padding: 11px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.45;
  border: 1px solid var(--line);
  background: rgba(255, 196, 107, 0.1);
  color: var(--warn);
}
.msg-system.is-bad { background: rgba(255, 122, 122, 0.1); border-color: rgba(255, 122, 122, 0.4); color: #ffb3b3; }
.msg-system.is-info { background: rgba(255, 255, 255, 0.04); color: var(--ink-dim); }

.msg-typing {
  display: inline-flex;
  gap: 4px;
  padding: 14px 16px;
  align-self: flex-start;
}
.msg-typing .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-mute);
  animation: typing 1.1s infinite ease-in-out;
}
.msg-typing .dot:nth-child(2) { animation-delay: 0.15s; }
.msg-typing .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-chips {
  display: flex;
  gap: 8px;
  padding: 10px 16px 0;
  overflow-x: auto;
  scrollbar-width: thin;
}
.chat-chips[hidden] { display: none; }
.chat-chip {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink-dim);
  font-size: 13.5px;
  white-space: nowrap;
  transition: all 0.14s ease;
}
.chat-chip:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.3); }
.chat-chip.is-strong {
  background: rgba(255, 138, 61, 0.16);
  border-color: rgba(255, 138, 61, 0.5);
  color: var(--accent-soft);
  font-weight: 600;
}

.chat-input {
  display: flex;
  gap: 10px;
  padding: 12px 16px 8px;
}
.chat-field {
  flex: 1;
  padding: 12px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.045);
  font-size: 15px;
}
.chat-field:focus { outline: none; border-color: rgba(255, 138, 61, 0.6); }
.chat-send {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  color: #1a0d03;
  font-size: 19px;
  font-weight: 700;
}
.chat-send:hover { filter: brightness(1.08); }

.chat-foot {
  padding: 6px 16px 14px;
  font-size: 11.5px;
  color: var(--ink-mute);
  text-align: center;
}

.chat-summary {
  margin-top: 10px;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 138, 61, 0.4);
  background: linear-gradient(180deg, rgba(255, 138, 61, 0.1), rgba(255, 138, 61, 0.03));
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-summary-title {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-soft);
  font-weight: 700;
}
.chat-summary-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px;
  font-size: 14px;
  align-items: baseline;
}
.chat-summary-row span { color: var(--ink-mute); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.05em; }
.chat-summary-row b { font-weight: 600; }

@media (max-width: 620px) {
  .chat-shell { width: 100vw; height: 100vh; border-radius: 0; border: 0; }
  .chat-summary-row { grid-template-columns: 1fr; gap: 2px; }
  .msg { max-width: 92%; }
}
