/* Messenger UI — палитра сайта */
:root {
  --accent: #c0392b;
  --accent-hover: #a93226;
  --bg: #f7f7f7;
  --surface: #fff;
  --border: #ddd;
  --border-light: #eee;
  --text: #111;
  --text-body: #222;
  --text-secondary: #555;
  --text-muted: #777;
  --text-faint: #888;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06);
  --dark: #2c3e50;
  --dark-hover: #1a252f;
  --out-bg: #fff;
  --out-accent: #fdecea;
}

body.chat-page {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, sans-serif;
  line-height: 1.5;
}

.chat-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
}

.chat-header .back {
  color: #fff;
  text-decoration: none;
  font-size: 1.375rem;
  line-height: 1;
  padding: 4px 6px 4px 0;
}

.chat-header .back:hover { opacity: .85; }

.chat-header-main { min-width: 0; flex: 1; }

.chat-contact {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.2;
}

.chat-topic {
  font-size: .8125rem;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255, 255, 255, .92);
}

.chat-topic .bi { font-weight: 600; color: #fff; }
.chat-topic .ru { font-weight: 400; color: rgba(255, 255, 255, .82); }
.chat-topic .sep { margin: 0 .25em; color: rgba(255, 255, 255, .55); }

.chat {
  flex: 1;
  padding: 16px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  display: flex;
  max-width: 90%;
}

.msg-out { align-self: flex-end; }
.msg-in { align-self: flex-start; }

.bubble {
  padding: 10px 12px 8px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  line-height: 1.45;
  border: 1px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: box-shadow 0.28s ease, border-color 0.28s ease;
}

.bubble.is-open {
  cursor: default;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .09);
}

.msg-out .bubble {
  border-color: #f0c4bf;
  border-top-right-radius: 4px;
  background: linear-gradient(135deg, #fff 0%, var(--out-accent) 100%);
}

.msg-in .bubble {
  background: var(--surface);
  border-top-left-radius: 4px;
}

.sender {
  font-size: .75rem;
  font-weight: 700;
  margin-bottom: 5px;
  letter-spacing: .02em;
}

.msg-out .sender { color: var(--accent); }
.msg-in .sender { color: var(--dark); }

.bubble-hint {
  font-size: .6875rem;
  color: var(--text-faint);
  margin-top: 6px;
  font-weight: 400;
  max-height: 2.5em;
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.22s ease, max-height 0.28s ease, margin-top 0.28s ease;
}

.bubble.is-open .bubble-hint {
  opacity: 0;
  max-height: 0;
  margin-top: 0;
}

.bubble-detail {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  margin-top: 0;
  padding-top: 0;
  border-top: 1px solid transparent;
  transition:
    max-height 0.38s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.28s ease 0.04s,
    margin-top 0.28s ease,
    padding-top 0.28s ease,
    border-color 0.28s ease;
}

.bubble.is-open .bubble-detail {
  opacity: 1;
  margin-top: 8px;
  padding-top: 8px;
  border-top-color: var(--border-light);
}

@media (prefers-reduced-motion: reduce) {
  .bubble,
  .bubble-hint,
  .bubble-detail {
    transition: none;
  }
}

.detail-block + .detail-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-light);
}

.detail-label {
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.detail-grammar {
  font-size: .8125rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.55;
}

.detail-grammar p {
  margin: 0 0 6px;
}

.detail-grammar p:last-child {
  margin-bottom: 0;
}

.detail-grammar strong {
  color: var(--text-body);
  font-weight: 600;
}

.vocab-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: .8125rem;
  line-height: 1.4;
}

.vocab-list li {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
}

.vocab-list li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.vocab-list .vocab-tr {
  font-weight: 600;
  color: var(--text-body);
}

.vocab-list .vocab-ru {
  text-align: right;
}

.text-tr {
  font-size: 1rem;
  color: var(--text-body);
  font-weight: 600;
}

.bubble-detail .text-ru {
  font-size: .875rem;
  font-weight: 400;
  color: var(--text-body);
  margin: 0;
  padding: 0;
  border: none;
}

.chat-footer {
  padding: 12px 16px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}

.chat-footer a,
.chat-footer .nav-disabled {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-body);
  font-size: .875rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  text-align: center;
  line-height: 1.35;
}

.chat-footer a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.chat-footer a.next {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.chat-footer a.next:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.chat-footer a.prev {
  background: var(--dark);
  color: #fff;
  border-color: var(--dark);
}

.chat-footer a.prev:hover {
  background: var(--dark-hover);
  border-color: var(--dark-hover);
  color: #fff;
}

.chat-footer .nav-disabled {
  background: var(--surface);
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.load-error {
  margin: 12px;
  padding: 14px 16px;
  background: #fff3f3;
  border: 1px solid #f0c4bf;
  border-radius: 10px;
  color: #8e2e24;
  font-size: .875rem;
  line-height: 1.5;
}
