/* Compact chat thread: support (app + admin) and the offer card.
   Works with both palettes: app variables first, admin variables as fallback. */
.chat {
  --c-bg: var(--bg, #080f18);
  --c-surface: var(--surface-raised, var(--surface, #111a25));
  --c-line: var(--border-soft, var(--line, #1f2e3d));
  --c-text: var(--text, #eaf1fb);
  --c-muted: var(--muted, #8fa1b7);
  --c-subtle: var(--subtle, #6c7f94);
  --c-accent: var(--accent, var(--blue, #2a8cff));
  --c-mine: #1d4f8f;
  --c-mine-text: #f2f7ff;
  --c-danger: var(--danger, var(--red, #f16d76));
  position: relative; display: flex; flex-direction: column; min-width: 0;
}
.chat.is-dropping::after { content: "Отпустите, чтобы прикрепить"; position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; border: 2px dashed var(--c-accent); border-radius: 16px; background: color-mix(in srgb, var(--c-bg) 85%, transparent); color: var(--c-text); font-size: 14px; font-weight: 600; }

.chat-log { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 4px 0 8px; }
.chat--self .chat-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 16px; scrollbar-width: thin; }
.chat-empty { margin: 18px auto; color: var(--c-muted); font-size: 13px; text-align: center; }
.chat-day { align-self: center; margin: 12px 0 6px; padding: 3px 10px; border-radius: 999px; background: var(--c-surface); color: var(--c-muted); font-size: 11.5px; font-weight: 600; }
.chat-system { align-self: center; max-width: 92%; margin: 6px 0; color: var(--c-muted); font-size: 12px; line-height: 1.4; text-align: center; }
.chat-system small { color: var(--c-subtle); font-size: 11px; }

.chat-row { display: flex; margin-top: 8px; }
.chat-row.is-grouped { margin-top: 2px; }
.chat-row.is-mine { justify-content: flex-end; }
.chat-bubble { position: relative; display: grid; gap: 4px; max-width: min(82%, 520px); min-width: 64px; padding: 7px 10px 6px; border-radius: 16px; background: var(--c-surface); color: var(--c-text); overflow-wrap: anywhere; }
.chat-row.is-mine .chat-bubble { background: var(--c-mine); color: var(--c-mine-text); }
.chat-row.is-theirs:not(.is-grouped) .chat-bubble { border-top-left-radius: 6px; }
.chat-row.is-mine:not(.is-grouped) .chat-bubble { border-top-right-radius: 6px; }
.chat-row.is-pending .chat-bubble { opacity: .7; }
.chat-row.is-failed .chat-bubble { outline: 1px solid var(--c-danger); }
.chat-name { color: var(--c-accent); font-size: 12px; font-weight: 650; line-height: 1.2; }
/* The assistant mark rides inside the signature, so a screen reader reads it with the name. */
.chat-name-tag { margin-left: 6px; color: var(--c-muted); font-size: 11px; font-weight: 500; }
.chat-text { margin: 0; font-size: 14.5px; line-height: 1.4; white-space: pre-wrap; }
.chat-meta { display: inline-flex; align-items: center; gap: 3px; justify-self: end; margin-top: -2px; color: color-mix(in srgb, currentColor 55%, transparent); font-size: 11px; line-height: 1; font-variant-numeric: tabular-nums; }
.chat-tick { width: 13px; height: 13px; }
.chat-bubble.is-media-only { padding: 4px; }
.chat-bubble.is-media-only .chat-meta { position: absolute; right: 10px; bottom: 9px; padding: 3px 6px; border-radius: 999px; background: #000a; color: #fff; }

/* Files */
.chat-files { display: grid; gap: 4px; }
.chat-media { display: grid; gap: 3px; overflow: hidden; border-radius: 12px; }
.chat-media--1 { grid-template-columns: minmax(0, 260px); }
.chat-media--2, .chat-media--4 { grid-template-columns: repeat(2, minmax(0, 132px)); }
.chat-media--3 { grid-template-columns: repeat(3, minmax(0, 96px)); }
.chat-media-tile { position: relative; display: grid; place-items: center; min-width: 0; height: 132px; margin: 0; padding: 0; overflow: hidden; border: 0; border-radius: 0; background: color-mix(in srgb, var(--c-bg) 70%, transparent); color: var(--c-muted); cursor: pointer; }
.chat-media--1 .chat-media-tile { height: auto; min-height: 120px; max-height: 300px; }
.chat-media-tile img { width: 100%; height: 100%; object-fit: cover; }
.chat-media--1 .chat-media-tile img { height: auto; max-height: 300px; }
.chat-media-tile .icon { width: 24px; height: 24px; }
.chat-media-play { position: absolute; z-index: 1; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: #000a; color: #fff; }
.chat-media-play .icon { width: 16px; height: 16px; fill: currentColor; }
.chat-file { display: flex; align-items: center; gap: 10px; min-width: 0; width: 100%; margin: 0; padding: 6px 8px 6px 6px; border: 0; border-radius: 12px; background: color-mix(in srgb, var(--c-bg) 35%, transparent); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.chat-file-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 10px; background: color-mix(in srgb, var(--c-accent) 22%, transparent); color: var(--c-accent); }
.chat-row.is-mine .chat-file-icon { background: #ffffff22; color: #fff; }
.chat-file-icon .icon { width: 18px; height: 18px; }
.chat-file-copy { display: grid; min-width: 0; }
.chat-file-copy strong { overflow: hidden; font-size: 13.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.chat-file-copy small { color: color-mix(in srgb, currentColor 60%, transparent); font-size: 11.5px; }

/* "печатает…" */
.chat-typing { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; max-height: 0; margin-top: 0; padding: 0 10px; overflow: hidden; opacity: 0; border-radius: 999px; background: var(--c-surface); color: var(--c-muted); font-size: 12px; transition: max-height .2s, opacity .2s, margin .2s, padding .2s; }
.chat-typing.is-visible { max-height: 28px; margin-top: 8px; padding: 5px 10px; opacity: 1; }
.chat-typing-dots { display: inline-flex; gap: 3px; }
.chat-typing-dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--c-accent); animation: chat-dot 1.1s ease-in-out infinite; }
.chat-typing-dots i:nth-child(2) { animation-delay: .15s; }
.chat-typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-dot { 0%, 70%, 100% { opacity: .35; transform: none; } 35% { opacity: 1; transform: translateY(-3px); } }

/* Composer */
.chat-composer { display: grid; gap: 6px; padding: 8px 0 0; }
.chat--self .chat-composer { padding: 10px 12px 12px; border-top: 1px solid var(--c-line); background: var(--c-bg); }
/* One pill: [clip] [text] [send], everything centred vertically like a Compose Row. */
.chat-compose-row { display: flex; align-items: center; gap: 4px; min-height: 48px; padding: 5px; border: 1px solid var(--c-line); border-radius: 24px; background: var(--c-surface); transition: border-color .15s; }
.chat-compose-row:focus-within { border-color: color-mix(in srgb, var(--c-accent) 60%, var(--c-line)); }
/* The app styles every textarea with its own border, padding and focus ring; the chat field must stay bare. */
.chat .chat-input, .chat .chat-input:focus, .chat .chat-input:focus-visible {
  display: block; flex: 1; align-self: center; width: auto; min-width: 0; min-height: 0 !important; height: 22px; max-height: 132px;
  margin: 0; padding: 0 4px; resize: none; border: 0; border-radius: 0; outline: 0; background: transparent; box-shadow: none;
  color: var(--c-text); font: inherit; font-size: 15px !important; line-height: 22px; }
.chat-input::placeholder { color: var(--c-subtle); }
/* The phone layer forces 48px-tall buttons; these two are exact 36px circles. */
.chat .chat-attach, .chat .chat-send { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px; min-width: 36px; min-height: 36px !important; max-height: 36px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--c-muted); cursor: pointer; aspect-ratio: 1; }
.chat .chat-attach:focus-visible, .chat .chat-send:focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }
.chat .chat-attach .icon { width: 21px; height: 21px; }
.chat .chat-send .icon { width: 18px; height: 18px; margin-left: -2px; }
.chat-attach:hover { color: var(--c-text); }
.chat .chat-send { background: var(--c-accent); color: #fff; transition: opacity .15s, transform .12s; }
.chat-send:disabled { opacity: .35; cursor: default; }
.chat-send:not(:disabled):active { transform: scale(.92); }
.chat-tray { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
.chat-tray-item { display: flex; align-items: center; gap: 6px; flex: none; max-width: 200px; height: 44px; padding: 4px 4px 4px 4px; border: 1px solid var(--c-line); border-radius: 12px; background: var(--c-surface); color: var(--c-text); font-size: 12.5px; }
.chat-tray-item img { width: 36px; height: 36px; flex: none; border-radius: 8px; object-fit: cover; }
.chat-tray-item .chat-file-icon { width: 36px; height: 36px; }
.chat-tray-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat .chat-tray-item .icon-button, .chat .chat-tray-item button { display: grid; place-items: center; width: 28px; height: 28px; min-width: 28px; min-height: 28px !important; flex: none; margin: 0; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--c-muted); }
.chat-tray-item .icon { width: 16px; height: 16px; }
.chat-problem { margin: 0; color: var(--c-danger); font-size: 12.5px; }
.chat-closed { margin: 10px 0 0; padding: 10px 12px; border-radius: 12px; background: var(--c-surface); color: var(--c-muted); font-size: 13px; text-align: center; }
.chat--self .chat-closed { margin: 0; border-radius: 0; border-top: 1px solid var(--c-line); }

@media (prefers-reduced-motion: reduce) {
  .chat-typing, .chat-send { transition: none; }
  .chat-typing-dots i { animation: none; opacity: .8; }
}

/* ---------- App: support list and ticket header ---------- */
.support-rows { display: grid; overflow: hidden; border: 1px solid var(--border-soft, #1f2e3d); border-radius: 16px; background: var(--surface, #0d131a); }
.support-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px; margin: 0; padding: 10px 14px; border: 0; border-radius: 0; background: none; color: var(--text, #eaf1fb); font: inherit; text-align: left; }
.support-row + .support-row { border-top: 1px solid var(--border-soft, #1f2e3d); }
.support-row:active { background: var(--surface-hover, #151e28); }
.support-row-copy { display: grid; gap: 2px; min-width: 0; flex: 1; }
.support-row-copy strong { overflow: hidden; font-size: 14.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.support-row-copy small { color: var(--subtle, #6c7f94); font-size: 12px; }
.support-status { flex: none; padding: 3px 9px; border-radius: 999px; background: var(--surface-raised, #111820); color: var(--muted, #8fa1b7); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.support-status.is-waiting_user { background: color-mix(in srgb, var(--success, #38ce96) 16%, transparent); color: var(--success, #38ce96); }
.support-status.is-new, .support-status.is-waiting_support { background: color-mix(in srgb, var(--accent, #2a8cff) 16%, transparent); color: #8cc2ff; }
.support-row.is-waiting_user .support-row-copy strong::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 7px; border-radius: 50%; background: var(--success, #38ce96); vertical-align: middle; }
.support-head { display: flex; align-items: center; gap: 12px; margin: 14px 0 10px; }
.support-head-copy { display: grid; gap: 2px; min-width: 0; flex: 1; }
.support-head-copy strong { font-size: 18px; font-weight: 650; letter-spacing: -.015em; line-height: 1.25; }
.support-head-copy small { color: var(--subtle, #6c7f94); font-size: 12.5px; }
