/* Minimal ChatGPT-like shell — /chat.html */

.chat-page {
  height: 100vh;
  overflow: hidden;
}

.chat-page .site-header {
  flex-shrink: 0;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border, #2a3548);
}

.chat-page .site-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  max-width: 1100px;
}

.chat-toolbar {
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.65rem 1.25rem;
  border-bottom: 1px solid var(--border, #2a3548);
  background: var(--surface, #151b26);
}

.chat-compare-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.75rem;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text, #e8edf5);
}

.chat-compare-switch input {
  width: 2.75rem;
  height: 1.5rem;
  accent-color: var(--accent, #4d9fff);
}

.chat-compare-switch:focus-within {
  outline: 2px solid var(--accent, #4d9fff);
  outline-offset: 2px;
  border-radius: 6px;
}

.chat-compare-hint {
  font-size: 0.78rem;
  color: var(--muted, #8b9cb3);
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-msg {
  max-width: 85%;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg.user {
  align-self: flex-end;
  background: rgba(77, 159, 255, 0.14);
  border: 1px solid rgba(77, 159, 255, 0.28);
}

.chat-msg.assistant {
  align-self: flex-start;
  background: var(--surface, #151b26);
  border: 1px solid var(--border, #2a3548);
}

.chat-msg-error {
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: #f87171;
}

/* Per-turn cost/usage footer under an assistant message (rendered only when usage exists) */
.chat-msg-cost {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--muted, #8b9cb3);
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

.chat-empty {
  color: var(--muted, #8b9cb3);
  text-align: center;
  margin: auto;
  font-size: 0.9rem;
}

.chat-composer {
  flex-shrink: 0;
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  padding: 0.75rem 1.25rem 1.25rem;
  border-top: 1px solid var(--border, #2a3548);
  background: var(--bg, #0c0f14);
}

.chat-composer textarea {
  flex: 1;
  resize: none;
  min-height: 2.75rem;
  max-height: 8rem;
  padding: 0.65rem 0.85rem;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--text, #e8edf5);
  background: var(--surface, #151b26);
  border: 1px solid var(--border, #2a3548);
  border-radius: var(--radius, 10px);
  line-height: 1.4;
}

.chat-composer textarea:focus,
.chat-composer textarea:focus-visible {
  outline: 2px solid var(--accent, #4d9fff);
  outline-offset: 0;
  border-color: var(--accent, #4d9fff);
}

.chat-composer textarea:disabled {
  opacity: 0.55;
}

.chat-composer button {
  flex-shrink: 0;
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  border-radius: var(--radius, 10px);
  background: var(--accent, #4d9fff);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}

.chat-composer button:hover:not(:disabled) {
  filter: brightness(1.08);
}

.chat-composer button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.chat-stream-hint {
  align-self: flex-start;
  font-size: 0.75rem;
  color: var(--muted, #8b9cb3);
}

.chat-compare-turn {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.chat-compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.chat-compare-pane {
  --chat-pane-bg: var(--surface, #151b26);
  --chat-pane-border: var(--border, #2a3548);
  --chat-compare-plain: rgba(77, 159, 255, 0.12);
  --chat-compare-deep: rgba(167, 139, 250, 0.12);
  background: var(--chat-pane-bg);
  border: 1px solid var(--chat-pane-border);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  min-width: 0;
}

.chat-compare-pane--plain {
  background: var(--chat-compare-plain);
}

.chat-compare-pane--deep {
  background: var(--chat-compare-deep);
}

.chat-pane-title {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted, #8b9cb3);
}

.chat-pane-text {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.5;
  font-size: 0.9rem;
}

.chat-pane-loading,
.chat-pane-error {
  font-size: 0.85rem;
}

.chat-pane-loading {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted, #8b9cb3);
}

.chat-pane-error {
  color: #f87171;
}

.chat-pane-scores {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border, #2a3548);
}

.chat-score-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.2rem 0.5rem;
  align-items: center;
  font-size: 0.78rem;
}

.chat-score-label {
  color: var(--muted, #8b9cb3);
}

.chat-score-value {
  font-variant-numeric: tabular-nums;
  color: var(--text, #e8edf5);
}

.chat-score-bar {
  grid-column: 1 / -1;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.chat-score-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent, #4d9fff);
  transition: width 0.35s var(--ease, cubic-bezier(.2,.7,.2,1));
}

@media (prefers-reduced-motion: no-preference) {
  .chat-compare-pane {
    animation: chat-pane-rise 0.35s var(--ease, cubic-bezier(.2,.7,.2,1)) both;
  }
}

@keyframes chat-pane-rise {
  from { transform: translateY(8px); }
  to { transform: none; }
}

@media (max-width: 768px) {
  .chat-compare-grid {
    grid-template-columns: 1fr;
  }
}

/* VeriThink generation progress row */
.chat-progress {
  align-self: flex-start;
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  max-width: 90%;
  padding: 0.55rem 0.75rem;
  background: var(--surface, #151b26);
  border: 1px solid var(--border, #2a3548);
  border-radius: 12px;
}

.chat-progress-avatar {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--accent, #4d9fff);
  background: var(--bg, #0c0f14);
}

.chat-progress-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-progress-body {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  min-width: 0;
  font-size: 0.85rem;
  line-height: 1.4;
}

.chat-progress-name {
  font-weight: 600;
  color: var(--text, #e8edf5);
}

.chat-progress-stage {
  color: var(--muted, #8b9cb3);
}

.chat-progress-elapsed {
  font-variant-numeric: tabular-nums;
  color: var(--muted, #8b9cb3);
  font-size: 0.8rem;
}

.chat-progress--stall {
  border-color: #c9a227;
}

.chat-progress-stall {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: #c9a227;
}

.chat-progress-dots {
  display: inline-flex;
  gap: 0.2rem;
  margin-left: 0.15rem;
  vertical-align: middle;
}

.chat-progress-dots span {
  display: inline-block;
  width: 0.3rem;
  height: 0.3rem;
  border-radius: 50%;
  background: var(--accent, #4d9fff);
  opacity: 0.35;
  animation: chat-dot-pulse 1.2s ease-in-out infinite;
}

.chat-progress-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.chat-progress-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes chat-dot-pulse {
  0%, 80%, 100% {
    opacity: 0.35;
    transform: scale(1);
  }
  40% {
    opacity: 1;
    transform: scale(1.15);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-progress-dots span {
    animation: none;
    opacity: 0.7;
  }
}

/* Deep-answer spinner (progress row). Static ring under reduced motion. */
.chat-spinner {
  flex: none;
  align-self: center;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 2px solid var(--border, #2a3548);
  border-top-color: var(--accent, #4d9fff);
}

@media (prefers-reduced-motion: no-preference) {
  .chat-spinner {
    animation: chat-spin 0.7s linear infinite;
  }
}

@keyframes chat-spin {
  to { transform: rotate(360deg); }
}

/* ── Clarification panel (needs_clarification), above the composer ── */
.chat-clarify {
  flex-shrink: 0;
  margin: 0 1.25rem 0.5rem;
  padding: 0.85rem 1rem;
  background: var(--surface, #151b26);
  border: 1px solid var(--border, #2a3548);
  border-left: 3px solid var(--accent, #4d9fff);
  border-radius: var(--radius, 10px);
  color: var(--text, #e8edf5);
  font-size: 0.9rem;
  max-height: 45vh;
  overflow-y: auto;
}

.chat-clarify[hidden] {
  display: none;
}

.chat-clarify-hint {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  color: var(--muted, #8b9cb3);
}

.chat-clarify .clarify-q {
  margin: 0.6rem 0;
  padding: 0.6rem 0.7rem;
  background: var(--bg, #0c0f14);
  border: 1px solid var(--border, #2a3548);
  border-radius: var(--radius, 10px);
}

.chat-clarify .clarify-q strong {
  display: block;
  line-height: 1.35;
}

.chat-clarify .clarify-opts {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.chat-clarify .clarify-opt {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  min-height: 2.75rem;
  font-size: 0.88rem;
  cursor: pointer;
  line-height: 1.35;
}

.chat-clarify .clarify-opt input[type="radio"] {
  margin-top: 0.65rem;
  min-width: 1rem;
  accent-color: var(--accent, #4d9fff);
}

.chat-clarify .clarify-opt span {
  flex: 1;
  min-width: 0;
  align-self: center;
  overflow-wrap: anywhere;
}
.chat-clarify .clarify-opt-recommended {
  outline: 1px dashed var(--accent);
}
.chat-clarify .clarify-rec-badge {
  font-size: 0.7rem;
  color: var(--accent);
}
.chat-clarify .clarify-other-text {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 0.35rem;
  background: var(--bg, #0c0f14);
  color: var(--text);
  border: 1px solid var(--border, #2a3548);
  border-radius: var(--radius, 10px);
}
.chat-clarify .clarify-actions button,
.chat-clarify .clarify-opt {
  min-height: 44px;
}
.chat-clarify .clarify-opt:focus-visible,
.chat-clarify button:focus-visible,
.chat-clarify .clarify-other-text:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.chat-clarify fieldset.clarify-q {
  border: 0;
  margin: 0.6rem 0;
  padding: 0;
}

.chat-clarify .clarify-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin-top: 0.75rem;
}

.chat-clarify .clarify-actions button {
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius, 10px);
  border: 1px solid transparent;
  font-size: 0.88rem;
  cursor: pointer;
}

.chat-clarify .clarify-submit {
  background: var(--accent, #4d9fff);
  color: #fff;
}

.chat-clarify .clarify-submit:hover:not(:disabled) {
  filter: brightness(1.08);
}

.chat-clarify .clarify-skip {
  background: transparent;
  border-color: var(--border, #2a3548);
  color: var(--muted, #8b9cb3);
}

.chat-clarify .clarify-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-clarify :focus-visible,
.chat-chip:focus-visible {
  outline: 2px solid var(--accent, #4d9fff);
  outline-offset: 2px;
}

/* ── Follow-up chips ("### Продолжим?") ── */
.chat-followups {
  align-self: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-width: 100%;
  margin-top: -0.25rem;
}

.chat-chip {
  min-height: 2.75rem;
  max-width: 100%;
  padding: 0.5rem 0.85rem;
  background: var(--surface, #151b26);
  border: 1px solid var(--border, #2a3548);
  border-radius: 999px;
  color: var(--text, #e8edf5);
  font-size: 0.85rem;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;
  transition: border-color 0.2s var(--ease, cubic-bezier(.2,.7,.2,1)),
              background 0.2s var(--ease, cubic-bezier(.2,.7,.2,1));
}

.chat-chip:hover:not(:disabled) {
  border-color: var(--accent, #4d9fff);
  background: rgba(77, 159, 255, 0.12);
}

.chat-chip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (prefers-reduced-motion: no-preference) {
  .chat-followups {
    animation: chat-pane-rise 0.35s var(--ease, cubic-bezier(.2,.7,.2,1)) both;
  }
}

@media (max-width: 768px) {
  .chat-clarify {
    margin: 0 1rem 0.5rem;
  }
  .chat-clarify .clarify-actions button {
    flex: 1 1 auto;
  }
}

@media (max-width: 360px) {
  .chat-clarify {
    margin: 0 0.75rem 0.5rem;
    padding: 0.7rem 0.75rem;
  }
  .chat-clarify .clarify-actions {
    flex-direction: column;
  }
  .chat-clarify .clarify-actions button {
    width: 100%;
  }
  .chat-chip {
    width: 100%;
    border-radius: var(--radius, 10px);
  }
}

.chat-multi-task {
  margin: 0 1rem 0.65rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border, #2a3548);
  border-radius: var(--radius, 10px);
  background: var(--surface2, #0b1018);
  font-size: 0.85rem;
}
.chat-multi-task .mt-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.chat-multi-task .mt-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.chat-multi-task .mt-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.45rem;
  align-items: center;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  background: var(--surface, #111822);
}
.chat-multi-task .mt-item-active {
  outline: 1px solid var(--accent, #4d9fff);
}
.chat-multi-task .mt-item-status {
  font-size: 0.75rem;
  text-transform: lowercase;
}
.chat-multi-task .mt-status-done { color: var(--ok, #3ecf8e); }
.chat-multi-task .mt-status-fail { color: var(--danger, #ff6b6b); }
.chat-multi-task .mt-status-wait { color: var(--warn, #f0c040); }
.chat-multi-task .mt-status-run { color: var(--accent, #4d9fff); }
.chat-multi-task .mt-hint {
  margin: 0.5rem 0 0;
  color: var(--muted, #8b9cb3);
  font-size: 0.78rem;
}
.chat-multi-task .mt-merged {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--border, #2a3548);
}
.chat-multi-task .mt-merged-body {
  margin-top: 0.35rem;
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: 0.84rem;
}

/* PR06 D3: answer readiness honesty badges */
.chat-readiness {
  margin: 0.45rem 0 0;
  padding: 0.35rem 0.55rem;
  border-radius: 6px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--muted, #8b9cb3);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border, #2a3548);
}
.chat-readiness--pipeline_verified {
  color: var(--ok, #3ecf8e);
  border-color: rgba(62, 207, 142, 0.35);
}
.chat-readiness--transport_ready,
.chat-readiness--unverified {
  color: var(--warn, #f0c040);
  border-color: rgba(240, 192, 64, 0.25);
}
.chat-readiness--needs_clarification,
.chat-readiness--requires_confirm {
  color: var(--accent, #4d9fff);
  border-color: rgba(77, 159, 255, 0.35);
}
.chat-compare-disclaimer {
  margin: 0.5rem 0 0.25rem;
  font-size: 0.78rem;
  color: var(--muted, #8b9cb3);
  line-height: 1.4;
}
