/* Explainability section – mobile transcript demo */
.mira-explainability-demo {
  background: var(--bg-soft);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 14px 14px 10px;
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  min-height: 210px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
}

.mira-explainability-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.mira-explainability-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mira-explainability-header .hint {
  font-size: 0.78rem;
  color: var(--muted);
}

.mira-explainability-transcript {
  font-size: 0.95rem;
  line-height: 1.6;
  position: relative;
}

.mira-explainability-transcript p {
  margin: 0;
}

.mira-explainability-transcript [data-hama-chunk] {
  padding: 1px 3px;
  border-radius: 6px;
  transition:
    background-color 0.25s ease,
    box-shadow 0.25s ease,
    color 0.25s ease;
}

.mira-explainability-transcript [data-hama-chunk].is-active {
  background-color: rgba(0, 0, 0, 0.05);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18);
  color: var(--text);
  animation: mira-pulse 1.6s ease-out infinite;
}

@keyframes mira-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.18);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(0, 0, 0, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
  }
}

.mira-explainability-footer {
  display: flex;
  justify-content: flex-start;
  margin-top: 10px;
}

.mira-explainability-tag {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg);
  max-width: 100%;
}

.mira-explainability-tag .tag-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.mira-explainability-tag .tag-main {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

.mira-explainability-tag .tag-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

/* Chat-style explainability for desktop right panel */
.mira-chat-demo {
  padding: 10px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 260px;
}

@media (min-width: 880px) {
  .wwd-explainability-desktop .mira-chat-demo {
    min-height: 280px;
  }
}

.mira-chat-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

.mira-chat-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mira-chat-header .hint {
  font-size: 0.78rem;
  color: var(--muted);
}

.mira-chat-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

/* Each row = chat on left, explanation on right, vertically aligned (desktop) */
.mira-chat-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.mira-chat-left {
  flex: 1.4;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mira-chat-right {
  flex: 1;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Chat bubbles – softer, WhatsApp-ish */
.chat-bubble {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  border-radius: 16px;
  padding: 5px 9px 4px;
  font-size: 0.78rem;
  line-height: 1.35;
  max-width: 80%;
  box-sizing: border-box;
}

.chat-bubble-rater {
  align-self: flex-start;
  margin-right: 40px;
  background: #ffffff;
  /* border: 1px solid #dde1e7; */
  color: #555b65;
}

.chat-bubble-subject {
  align-self: flex-end;
  margin-left: 40px;
  background: #5eb4fb;
  /* border: 1px solid #c3ddff; */
  color: #ffffff;
}

/* Tiny timestamp in bottom-right of each bubble */
.chat-meta {
  align-self: flex-end;
  font-size: 0.65rem;
  opacity: 0.6;
  margin-top: 2px;
}

/* Bubble tails */
/* .chat-bubble-rater::after {
  content: "";
  position: absolute;
  left: -6px;
  bottom: 6px;
  width: 0;
  height: 0;
  border-width: 6px 6px 6px 0;
  border-style: solid;
  border-color: transparent #f2f4f7 transparent transparent;
}

.chat-bubble-subject::after {
  content: "";
  position: absolute;
  right: -6px;
  bottom: 6px;
  width: 0;
  height: 0;
  border-width: 6px 0 6px 6px;
  border-style: solid;
  border-color: transparent transparent transparent #e3f2ff;
} */

/* Explanation tag on the right side (desktop) */
.mira-chat-explain {
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--bg);
  padding: 6px 8px;
  font-size: 0.76rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mira-chat-explain-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.mira-chat-explain-main {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
}

.mira-chat-explain-sub {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Default: before focus starts, everything is clear and neutral */
.mira-chat-row .chat-bubble {
  opacity: 1;
  filter: none;
}

/* Blur / dim non-active rows only once focus mode is on */
.mira-chat-demo.has-focus .mira-chat-row:not(.is-active) .chat-bubble {
  opacity: 0.35;
  filter: blur(0.6px);
}

/* Explanations: hidden by default, shown only for active row in focus mode */
.mira-chat-row .mira-chat-right {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.mira-chat-demo.has-focus .mira-chat-row.is-active .mira-chat-right {
  opacity: 1;
  transform: translateY(0);
}

/* --- Compact chat UI (~40% smaller) baseline --- */
.mira-chat-body .chat-bubble {
  font-size: 0.55rem;        /* smaller text (desktop baseline) */
  padding: 5px 10px 3px;      /* tighter padding */
  max-width: 70%;            /* slightly narrower bubbles */
}

.mira-chat-body .chat-meta {
  font-size: 0.46rem;        /* tiny timestamp */
  margin-top: 1px;
}

/* keep tails but adapt to smaller bubbles */
.mira-chat-body .chat-bubble-rater::after {
  bottom: 4px;
}

.mira-chat-body .chat-bubble-subject::after {
  bottom: 4px;
}

/* ============================================
   MOBILE CHAT – STACKED + BIGGER TEXT
   ============================================ */
@media (max-width: 768px) {
  /* Slightly tighter padding on small screens */
  .mira-chat-demo {
    padding: 10px 9px 9px;
  }

  .mira-chat-header-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .mira-chat-demo-mobile {
    width: 100%;
  }

  .mira-chat-demo-mobile .mira-chat-header {
    font-size: 0.8rem;
  }

  .mira-chat-demo-mobile .mira-chat-header-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  /* Rows stack vertically: explanation under the bubbles */
  .mira-chat-demo-mobile .mira-chat-row {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  .mira-chat-demo-mobile .mira-chat-left,
  .mira-chat-demo-mobile .mira-chat-right {
    width: 100%;
  }

  .mira-chat-demo-mobile .mira-chat-right {
    margin-top: 2px;
  }

  /* Bigger chat text on mobile vs desktop baseline */
  .mira-chat-demo-mobile .chat-bubble {
    font-size: 0.75rem;              /* override 0.55rem */
    padding: 6px 10px 5px;
    max-width: 100%;
  }

  .mira-chat-demo-mobile .chat-meta {
    font-size: 0.6rem;
  }

  /* Explanation block readable but compact */
  .mira-chat-demo-mobile .mira-chat-explain {
    font-size: 0.75rem;
    padding: 8px 10px;
  }

  .mira-chat-demo-mobile .mira-chat-explain-main {
    font-size: 0.82rem;
  }

  /* COLLAPSE EXPLANATION SPACE:
     when there's no explanation, there is no extra gap */
  .mira-chat-demo-mobile .mira-chat-right {
    display: none;      /* no empty slot between bubbles */
    margin-top: 0;
  }

  .mira-chat-demo-mobile .mira-chat-row.is-active .mira-chat-right {
    display: block;     /* only active row shows explanation */
    margin-top: 6px;
  }
}

/* Score pill – make "Severe" bubble orange and pinned to the right (desktop + mobile) */
.mira-chat-header .score-pill,
.mira-explainability-header .score-pill {
  background: #ffa77e;
  /* border-color: #ea580c; */
  color: #000000;
}

/* Push the severe pill to the right in header rows */
.mira-chat-header-top .score-pill,
.mira-explainability-topline .score-pill {
  margin-left: auto;
}

/* Mobile: keep it right-aligned even when header stacks */
@media (max-width: 768px) {
  .mira-chat-demo-mobile .mira-chat-header-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .mira-chat-demo-mobile .mira-chat-header-top .score-pill {
    align-self: flex-end;
    margin-left: 0;  /* override the desktop auto-margin */
  }
}

/* -----------------------------------------------------------
   UNIFIED HEADER LAYOUT FOR INSOMNIA + SEVERE TAGS
   ----------------------------------------------------------- */

/* Put pill + severe bubble in one row, aligned center-left */
.mira-chat-header-top,
.mira-explainability-topline {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 10px !important;
  width: 100%;
}

/* Ensure pills stay on one line */
.mira-chat-header-top .pill,
.mira-chat-header-top .score-pill,
.mira-explainability-topline .pill,
.mira-explainability-topline .score-pill {
  white-space: nowrap;
}

/* Add clean spacing between header row and intro text */
.mira-chat-header .hint,
.mira-explainability-header .hint {
  margin-top: 6px !important;
  margin-bottom: 6px !important;
  display: block;
}

/* Add spacing below intro text before chat begins */
.mira-chat-body {
  margin-top: 8px !important;
}

/* MOBILE — keep exactly the same layout */
@media (max-width: 768px) {
  .mira-chat-header-top,
  .mira-explainability-topline {
    flex-direction: row !important;   /* force single-line pills */
    align-items: center !important;
    justify-content: flex-start !important;
  }

  /* ensure no wrapping even on small screens */
  .mira-chat-header-top .pill,
  .mira-chat-header-top .score-pill,
  .mira-explainability-topline .pill,
  .mira-explainability-topline .score-pill {
    font-size: 0.7rem;                /* slightly smaller to prevent wrapping */
  }
}

/* -----------------------------------------------------------
   MOBILE: stabilize chat box height so explanation never expands container
   ----------------------------------------------------------- */

@media (max-width: 768px) {
  /* Give chat box a predictable vertical space */
  .mira-chat-demo-mobile {
    min-height: 720px;       /* adjust as needed */
    max-height: 720px;       /* prevents expansion / jumping */
    overflow-y: hidden;      /* hide overflow but keep clean look */
    position: relative;
  }

  /* When explanation shows, shift interior layout but not container size */
  .mira-chat-demo-mobile .mira-chat-body {
    padding-bottom: 40px;    /* breathing room for explanation */
  }

  /* Explanation should overlay inside the fixed height, not push height */
  .mira-chat-demo-mobile .mira-chat-right {
    position: relative;
    z-index: 2;
  }
}
