/* ============================================
   ren-chat.css

   Structure:
   1. CSS custom properties
   2. Global utilities (accessible everywhere)
   3. Non-layout components (buttons, pills,
      skeletons, project selector, drag-drop)
   4. Report page styles (standalone report view)
   5. Misc page components (modals, tabs, etc.)
   6. V2 ANALYSIS CONTAINER — all layout lives
      here, scoped under .ren-chat-container
   7. Mobile overrides (scoped)
   ============================================ */

/* ============================================
   1. CSS CUSTOM PROPERTIES
   ============================================ */

/* ============================================
   2. GLOBAL UTILITIES
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--white);
  color: var(--ink);
}

.hidden {
  display: none !important;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--fuchsia);
  color: white;
  padding: var(--spacing-2) var(--spacing-4);
  z-index: 10000;
  transition: top 0.3s;
}

.skip-link:focus {
  top: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================
   3. NON-LAYOUT COMPONENTS
   ============================================ */

/* Button */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-2);
  padding: var(--spacing-3) var(--spacing-6);
  background: var(--ink);
  color: var(--white);
  border: none;
  border-radius: var(--radius-full);
  font-family: var(--font-family-base);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  background: var(--ink);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn:disabled {
  background: var(--gray-light);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Skeletons */

.project-skeleton {
  padding: 4px 0;
}

.skeleton-label {
  width: 160px;
  height: 12px;
  background: var(--gray-light);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.skeleton-item {
  width: 100%;
  height: 14px;
  background: var(--gray-light);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.skeleton-item.short {
  width: 60%;
}

.project-skeleton .skeleton-label,
.project-skeleton .skeleton-item {
  animation: shimmer 1.5s ease-in-out infinite;
}

/* Project selector card */

.project-selector-card {
  max-width: 520px;
  margin: 0 auto var(--spacing-lg);
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--spacing-5) var(--spacing-5) var(--spacing-4);
  position: relative;
}

.project-selector-card.hidden {
  display: none;
}

.project-selector-card .section-label {
  font-size: var(--caption);
  color: var(--gray-mid);
  text-align: left;
  margin-bottom: var(--spacing-3);
}

.project-selector-card .project-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.project-selector-card .project-item {
  display: flex;
  align-items: center;
  padding: var(--spacing-3) var(--spacing-5);
  margin: 0 calc(-1 * var(--spacing-5));
  border-bottom: 1px solid var(--gray-light);
  cursor: pointer;
  transition: background var(--transition-fast);
  text-align: left;
}

.project-selector-card .project-item:last-child {
  border-bottom: none;
}

.project-selector-card .project-item:hover {
  background: var(--gray-background);
}

.project-selector-card .item-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--ink);
}

.project-selector-card .item-context {
  font-size: var(--text-xs);
  color: var(--gray-mid);
  margin-top: 1px;
}

.project-selector-card .list-divider {
  height: 1px;
  background: var(--gray-light);
  margin: var(--spacing-1) 0;
}

.project-selector-card .something-else-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-2);
  padding: var(--spacing-2) var(--spacing-5);
  margin: 0 calc(-1 * var(--spacing-5));
}

.project-selector-card .else-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: var(--font-size-sm);
  color: var(--ink);
  background: transparent;
  padding: var(--spacing-1) 0;
  font-family: inherit;
}

.project-selector-card .else-input::placeholder {
  color: var(--gray-mid);
}

.project-selector-card .new-project-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  border: 1px solid var(--gray-light);
  background: var(--white);
  color: var(--gray-mid);
  font-size: var(--text-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition-fast), color var(--transition-fast);
  line-height: 1;
  flex-shrink: 0;
}

.project-selector-card .new-project-btn:hover {
  border-color: var(--gray-mid);
  color: var(--ink);
}

.project-selector-card .search-results {
  list-style: none;
  margin: 0;
  padding: 0;
  display: none;
}

.project-selector-card .search-results.visible {
  display: block;
}

.project-selector-card .search-result-item {
  display: flex;
  align-items: center;
  padding: var(--spacing-2) var(--spacing-5);
  margin: 0 calc(-1 * var(--spacing-5));
  cursor: pointer;
  transition: background var(--transition-fast);
  text-align: left;
  border-top: 1px solid var(--gray-light);
}

.project-selector-card .search-result-item:hover {
  background: var(--gray-background);
}

.project-selector-card .result-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--ink);
}

.project-selector-card .result-context {
  font-size: var(--text-xs);
  color: var(--gray-mid);
  margin-top: 1px;
}

.project-selector-card .no-results {
  padding: var(--spacing-3) 0;
  font-size: var(--font-size-sm);
  color: var(--gray-mid);
  text-align: center;
  border-top: 1px solid var(--gray-light);
}

/* Drag-drop overlay */

.drag-drop-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.drag-drop-overlay.active {
  display: flex;
}

.drag-drop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
  color: var(--ink-2);
  font-size: 16px;
  font-weight: 500;
}

.drag-drop-content svg {
  color: var(--fuchsia);
}

/* Company pill */

.company-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-sm);
  background: var(--gray-background);
  border: 1px solid var(--gray-light);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--ink-2);
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
  line-height: 1.6;
}

/* File upload hidden input */

.file-upload-hidden {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

/* Typing dots */

.typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--gray-mid);
  border-radius: 50%;
  animation: loadingBounce 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes loadingBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Loading indicator */

.loading-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--white);
  padding: var(--spacing-6) var(--spacing-8);
  border-radius: var(--spacing-3);
  box-shadow: var(--shadow-lg);
  z-index: 2000;
}

.loading-dots {
  display: flex;
  gap: var(--spacing-2);
}

.loading-dots span {
  width: var(--spacing-3);
  height: var(--spacing-3);
  background: var(--ink);
  border-radius: 50%;
  animation: loadingBounce 1.4s infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Progress bar */

.progress-bar-fill {
  background: var(--fuchsia);
}

/* ============================================
   4. REPORT PAGE STYLES
   Used on standalone report view pages
   ============================================ */

.report-page-wrapper {
  margin-top: 60px;
  min-height: calc(100vh - 60px);
}

.report-cover {
  box-shadow: var(--shadow-lg);
  width: 100%;
  min-height: 100%;
  margin: 0;
  padding: var(--spacing-12) var(--spacing-20) 60px var(--spacing-20);
  position: relative;
  background: var(--white);
}

.report-container {
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: var(--spacing-12);
}

.report-view-body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  background: var(--white);
  margin: 0;
}

.report-view-body .report-page-wrapper {
  margin-top: 0;
  padding: 0;
  padding-top: var(--navbar-height);
  color: var(--ink);
  overflow: auto;
}

.report-view-body.is-embedded .navbar {
  display: none;
}

.report-view-body.is-embedded .report-page-wrapper {
  padding-top: 0;
}

.divider,
hr.divider {
  width: 50px;
  height: 2px;
  background-color: var(--fuchsia);
  border: none;
  margin-left: 0;
}

/* ============================================
   5. MISC PAGE COMPONENTS
   ============================================ */

/* Table modal */

.table-modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.table-modal-overlay.visible .table-modal {
  transform: scale(1);
}

/* History */

.history-dots-btn.visible {
  display: block !important;
}

.history-panel-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.history-panel-overlay.visible .history-panel {
  transform: translateX(0);
}

.history-item.active {
  background: var(--gray-light);
  border-color: var(--fuchsia);
}

/* Version dropdown (My Reports page) */

.version-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-1);
  font-size: var(--font-size-sm);
  color: var(--gray-mid);
  cursor: pointer;
  padding: var(--spacing-1) 0;
}

.version-item:hover { color: var(--ink); }

.version-item.active {
  color: var(--ink);
  font-weight: var(--font-weight-medium);
}

/* Filter tabs */

.my-reports-page .filter-tab.active {
  font-weight: var(--font-weight-bold);
}

.my-reports-page .filter-tab.active::after,
.my-reports-page .filter-tab[data-filter="insights"].active::after,
.my-reports-page .filter-tab[data-filter="courses"].active::after,
.my-reports-page .filter-tab[data-filter="quizzes"].active::after {
  background: var(--fuchsia);
}

.my-reports-page .filter-tab.active .tab-count {
  color: inherit;
}

.my-reports-page .right-panel.open {
  width: 40%;
  display: flex;
  overflow: hidden;
}

/* ============================================
   Mobile bottom sheet (program page · mobile)

   Slide-up panel anchored to the bottom edge.
   Backdrop scrim dims the page; tapping it (or
   the close affordance) slides the sheet back
   down. All chrome driven by global tokens so
   colours / radii / spacing stay in sync with
   the rest of the app shell.
   ============================================ */
.mobile-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 1000;
}
.mobile-sheet-overlay.open {
  opacity: 1;
  visibility: visible;
}

.mobile-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ffffff;
  border-radius: 16px 16px 0 0;
  padding: 8px 20px 24px;
  box-shadow: 0 -8px 30px rgba(15, 23, 42, 0.18);
  transform: translateY(100%);
  transition: transform 0.25s ease;
  z-index: 1001;
  max-height: 85vh;
  overflow-y: auto;
}
.mobile-sheet.open {
  transform: translateY(0);
}

.mobile-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--gray-light);
  border-radius: 999px;
  margin: 0 auto 16px;
}

.mobile-sheet-header {
  text-align: left;
  margin-bottom: 20px;
}
.mobile-sheet-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}
.mobile-sheet-desc {
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  color: var(--gray-mid);
  line-height: 1.45;
}

.mobile-sheet-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.mobile-sheet-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
.mobile-sheet-btn-primary {
  background: var(--btn-pink);
  color: #ffffff;
}
.mobile-sheet-btn-primary:hover {
  opacity: 0.92;
}

/* ============================================
   6. V2 ANALYSIS CONTAINER — LAYOUT

   All layout for the split-screen chat + report
   page lives here. Nothing above this point
   defines layout for these elements.
   ============================================ */

/* Page-level height containment */

.v2-app .main-content:has(.ren-chat-container) {
  height: 100vh;
  min-height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

.v2-app .page-content:has(.ren-chat-container) {
  padding: 0;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

/* Outer container */

.ren-chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  overflow: hidden;
  max-width: var(--content-max-width, 1425px);
  margin: 0 auto;
  padding-top: var(--topbar-height, 72px);
}

/* chat-container: fills remaining height after topbar */

.ren-chat-container .chat-container {
  flex: 1;
  min-height: 0;
  position: relative;
  top: auto;
  left: auto;
  bottom: auto;
  transform: none;
  width: 100%;
  max-width: none;
  padding: 0;
  overflow: hidden;
}

/* Welcome screen */

.ren-chat-container .welcome-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 2rem;
}

.ren-chat-container .welcome-content {
  max-width: 600px;
  width: 100%;
  text-align: center;
}

.ren-chat-container .welcome-title {
  font-size: 36px;
  font-weight: var(--font-weight-bold);
  color: var(--ink);
  margin: 0 0 8px 0;
}

.ren-chat-container .welcome-subtitle {
  font-size: 18px;
  color: var(--gray-mid);
  margin: 0 0 32px 0;
}

.ren-chat-container .centered-input-container {
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
}

/* Welcome screen input */

.ren-chat-container .welcome-screen .input-wrapper {
  display: flex;
  align-items: center;
  background: var(--white);
  border: 1px solid var(--gray-light);
  border-radius: 24px;
  padding: 8px 8px 8px 20px;
  box-shadow: var(--shadow-sm);
  min-height: auto;
  margin-bottom: 0;
}

/* chat-interface: fills chat-container */

.ren-chat-container .chat-interface {
  display: flex;
  height: 100%;
  width: 100%;
  padding-top: 20px;
  box-sizing: border-box;
}

.ren-chat-container .chat-interface.hidden {
  display: none;
}

/* With report: switch to grid */

.ren-chat-container .chat-interface.with-report {
  display: grid;
  grid-template-columns: 0% 30% 1px 1fr;
  transition: grid-template-columns 0.4s ease-out;
}

.ren-chat-container .chat-interface.with-report .chat-pane {
  grid-column: 2;
  max-width: none;
  margin: 0;
}

.ren-chat-container .chat-interface.with-report .panel-resize-handle {
  grid-column: 3;
  display: block;
}

.ren-chat-container .chat-interface.with-report .report-panel {
  grid-column: 4;
  border-left: none;
}

/* `with-report` is added eagerly by chat-conversation.js (before the
   report HTML actually paints). If we apply the 30%/1fr split before
   .report-panel.visible exists, the chat-pane gets squashed into the
   left column and the welcome screen ends up far off-centre. Detect
   that intermediate state and fall back to the single-pane layout
   until the report panel is genuinely visible. */
.ren-chat-container .chat-interface.with-report:not(:has(.report-panel.visible)) {
  display: flex;
  grid-template-columns: none;
}
.ren-chat-container .chat-interface.with-report:not(:has(.report-panel.visible)) .chat-pane {
  grid-column: auto;
  flex: 1 1 auto;
  max-width: none;
  margin: 0;
}
.ren-chat-container .chat-interface.with-report:not(:has(.report-panel.visible)) .panel-resize-handle,
.ren-chat-container .chat-interface.with-report:not(:has(.report-panel.visible)) .report-panel {
  display: none;
}

/* Resize interaction */

.ren-chat-container .chat-interface.resizing {
  cursor: col-resize;
  user-select: none;
  transition: none;
}

.ren-chat-container .chat-interface.resizing * {
  pointer-events: none;
}

.ren-chat-container .chat-interface.resizing .panel-resize-handle {
  pointer-events: auto;
}

/* Panel resize handle — 6px column in the grid, visible centre line
   plus a wider invisible hit area via ::before so the user can
   actually grab it without pixel-perfect aim. */

.ren-chat-container .panel-resize-handle {
  display: none;
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  cursor: col-resize;
  position: relative;
  z-index: 100;
}

/* Visible 1px divider line down the middle of the 6px column. */
.ren-chat-container .panel-resize-handle::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 1px;
  background: var(--report-ink-15);
  transform: translateX(-50%);
  transition: background 120ms ease, width 120ms ease;
  pointer-events: none;
}

/* Wider invisible hit area so users don't need pixel-perfect aim. */
.ren-chat-container .panel-resize-handle::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -6px;
  right: -6px;
}

/* Hover / drag — beef the line up and tint it so the affordance
   becomes obvious the moment the user moves over it. */
.ren-chat-container .panel-resize-handle:hover::after,
.ren-chat-container .panel-resize-handle.dragging::after {
  background: var(--coral);
  width: 3px;
}

/* chat-pane: flex column, bounded height */

.ren-chat-container .chat-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  max-width: min(1100px, 100%);
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  background: transparent;
}

.ren-chat-container .chat-interface.with-report .chat-pane {
  /* Match the report's evidence-callout tint (--sv-tint-evidence
     transparent) so the chat panel reads as part of the same palette. */
  background: transparent;
}

/* Remove padding when report active */

.ren-chat-container.report-active {
  max-width: 100%;
}

.ren-chat-container.report-active .chat-pane {
  padding: 0;
}

/* Context bar: fixed height, never grows */

.ren-chat-container .ren-context-bar,
.ren-context-bar {
  display: none;
  flex-shrink: 0;
  width: 100%;
  padding: 15px 0;
  background: transparent;
  border-top: 0.5px solid var(--gray-light);
  border-bottom: 0.5px solid var(--gray-light);
  box-sizing: border-box;
}

.ren-chat-container .ren-context-inner {
  width: 100%;
  margin: 0;
  padding: 0 20px 0 34px;
}

.ren-chat-container.report-active .ren-context-bar {
  display: block;
}

/* messages-container: THE scroll target for chat */

.ren-chat-container .messages-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.ren-chat-container .messages-container::-webkit-scrollbar {
  display: none;
}

/* messages-scroll: grows with content inside messages-container */

.ren-chat-container .messages-scroll {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 20px 24px 34px;
  max-width: min(900px, 100%);
  margin: 0 auto;
  width: 100%;
}

/* input-area: never shrinks, always visible */

.ren-chat-container .input-area {
  flex-shrink: 0;
  padding: 16px 20px 24px;
  background: transparent;
  max-width: min(900px, 100%);
  width: 100%;
  margin: 0 auto;
}

.ren-chat-container .input-area .input-wrapper {
  display: flex;
  align-items: center;
  background: var(--white);
  border: 0.5px solid var(--ink);
  border-radius: 28px;
  padding: 8px;
  box-shadow: none;
  min-height: auto;
  margin-bottom: 0;
  max-width: min(900px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.ren-chat-container .input-area .file-upload-btn {
  width: 32px;
  height: 32px;
  margin-right: 0;
  margin-left: 4px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast);
  flex-shrink: 0;
  color: var(--gray-mid);
}

.ren-chat-container .input-area .file-upload-btn:hover {
  background: var(--gray-background);
  color: var(--ink-2);
}

.ren-chat-container .message-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  background: transparent;
  resize: none;
  font-family: inherit;
  line-height: 1.4;
  padding: 6px 8px;
  color: var(--ink);
  min-height: 24px;
  max-height: 150px;
  overflow-y: hidden;
}

.ren-chat-container .message-input::placeholder {
  color: var(--gray-mid);
}

.ren-chat-container .send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ink);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.ren-chat-container .send-btn:hover {
  background: var(--ink-2);
}

.ren-chat-container .send-btn svg {
  stroke: var(--white);
}

/* report-panel: hidden until visible class added */

.ren-chat-container .report-panel {
  display: none;
  min-width: 0;
  min-height: 0;
  background: var(--white);
}

.ren-chat-container .report-panel.visible {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 1;
  pointer-events: auto;
}

/* report-container: THE scroll target for report */

.ren-chat-container .report-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 0;
}

/* Error state — centered vertically and horizontally in the report panel */
.ren-chat-container .report-container .report-error {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 40px;
  gap: 20px;
  min-height: 100%;
}
.ren-chat-container .report-container .report-error .report-error-icon {
  color: var(--theme, #FF00AA);
  opacity: 0.35;
}
.ren-chat-container .report-container .report-error .report-error-body {
  font-size: 0.9rem;
  color: var(--ink-2, #888);
  max-width: 340px;
  line-height: 1.65;
  margin: 0;
}

/* Scope guard — product suggestion buttons */
.suggest-product-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.suggest-product-btn {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--theme, #FF00AA);
  color: var(--theme, #FF00AA);
  background: transparent;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.suggest-product-btn:hover {
  background: var(--theme, #FF00AA);
  color: #fff;
  text-decoration: none;
}

.ren-chat-container .report-container::-webkit-scrollbar {
  width: var(--spacing-2);
}

.ren-chat-container .report-container::-webkit-scrollbar-track {
  background: transparent;
}

.ren-chat-container .report-container::-webkit-scrollbar-thumb {
  background: var(--gray-light);
  border-radius: var(--spacing-1);
}

.ren-chat-container .report-container::-webkit-scrollbar-thumb:hover {
  background: var(--ink-2);
}

/* Progress state inside report panel */

.ren-chat-container .report-container .progress-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 48px;
}

.ren-chat-container .report-container .progress-bar-container {
  width: 100%;
  max-width: 400px;
  height: 8px;
  background: var(--gray-light);
  border-radius: 8px;
  overflow: hidden;
}

.ren-chat-container .report-container .progress-bar-fill {
  height: 100%;
  background: var(--fuchsia);
  border-radius: 8px;
  transition: width 0.3s ease-out;
}

.ren-chat-container .report-container #reportProgressText {
  margin-top: 16px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--gray-mid);
}

/* report-cover inside panel: no extra shadow */

.ren-chat-container .report-cover {
  box-shadow: none;
  margin-top: 0;
}

/* Loading indicator inside container */

.ren-chat-container .loading-indicator {
  display: none;
  position: static;
  transform: none;
}

.ren-chat-container .loading-indicator.visible {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* Message bubbles */

.ren-chat-container .message {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.ren-chat-container .message.user-message {
  align-items: flex-end;
  margin-left: auto;
  background: transparent;
  padding: 0;
}

.ren-chat-container .message.user-message .message-content {
  background: var(--surface-cool-strong);
  color: var(--ink);
  padding: 12px 20px;
  border-radius: 20px;
  border: none;
  font-size: 15px;
  line-height: 1.5;
  max-width: 90%;
  width: fit-content;
  min-width: 0;
  text-align: left;
  white-space: normal;
  grid-column: auto;
  margin-left: auto;
}

.ren-chat-container .message.ai-message,
.ren-chat-container .message.assistant-message {
  align-items: flex-start;
}

.ren-chat-container .message.ai-message .message-content,
.ren-chat-container .message.assistant-message .message-content {
  background: transparent;
  color: var(--ink);
  padding: 8px 0;
  font-size: 15px;
  line-height: 1.6;
  max-width: 90%;
}

.ren-chat-container .message.ai-message .message-content p,
.ren-chat-container .message.assistant-message .message-content p {
  margin: 0 0 12px 0;
}

.ren-chat-container .message.ai-message .message-content p:last-child,
.ren-chat-container .message.assistant-message .message-content p:last-child {
  margin-bottom: 0;
}

/* Markdown links inside Ren replies — Ren now emits free-report
   references as [Title](/report/N) so users can click straight
   through. Style them in brand pink with a persistent underline so
   they're visually distinct from surrounding prose. */
.ren-chat-container .message.ai-message .message-content a,
.ren-chat-container .message.assistant-message .message-content a {
  color: var(--pink);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  font-weight: 500;
  transition: opacity 120ms ease;
}
.ren-chat-container .message.ai-message .message-content a:hover,
.ren-chat-container .message.assistant-message .message-content a:hover {
  opacity: 0.75;
  text-decoration-thickness: 2px;
}
.ren-chat-container .message.ai-message .message-content a:visited,
.ren-chat-container .message.assistant-message .message-content a:visited {
  color: var(--pink);
}

.ren-chat-container .chat-interface.with-report .message.user-message .message-content,
.ren-chat-container .chat-interface.with-report .message.ai-message .message-content,
.ren-chat-container .chat-interface.with-report .message.assistant-message .message-content {
  max-width: 90%;
}

.ren-chat-container .typing-indicator {
  padding: 8px 0;
}

/* ── Ren context bar inner elements ── */

.ren-context-inner {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ren-context-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
  min-width: 0;
  line-height: 1.2;
}

.ren-context-product {
  font-weight: var(--font-weight-medium);
}

.ren-context-sep {
  color: var(--gray-light);
}

.ren-context-date {
  color: var(--ink);
}

.ren-context-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  line-height: 1.2;
}

.ren-context-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.ren-context-version {
  flex-shrink: 0;
  position: relative;
}

.ren-version-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color 150ms ease;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
}

.ren-version-trigger:hover {
  color: var(--ink);
}

.ren-version-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fuchsia);
  flex-shrink: 0;
}

.ren-version-dot-empty {
  width: 6px;
  height: 6px;
  flex-shrink: 0;
}

.ren-version-item-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.ren-version-current-tag {
  font-size: 10px;
  color: var(--fuchsia);
  font-weight: var(--font-weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ren-version-list {
  display: none;
  position: absolute;
  top: calc(100% + var(--space-1));
  right: 0;
  background: var(--white);
  border: 1px solid var(--gray-light);
  border-top: 2px solid var(--fuchsia);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  padding: var(--space-2);
  z-index: 300;
}

.ren-version-list.open {
  display: block;
}

.ren-version-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3);
  gap: var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: background 150ms ease;
  color: var(--ink);
}

.ren-version-item:hover {
  background: var(--gray-background);
}

.ren-version-item.current {
  font-weight: var(--font-weight-semibold);
}

.ren-version-item-date {
  font-size: var(--font-size-xs);
  color: var(--gray-mid);
}

/* ── Report actions hamburger ── */

.report-actions-menu {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 100;
}

.report-actions-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  color: white;
  opacity: 0.85;
  transition: opacity 150ms ease;
  padding: 0;
}

.report-actions-btn:hover {
  opacity: 1;
}

.report-panel.report-visible .report-actions-btn {
  display: flex;
}

.report-actions-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  background: var(--white);
  border: 1px solid var(--gray-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  padding: var(--space-2);
  z-index: 200;
}

.report-actions-dropdown.open {
  display: block;
}

.report-actions-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  color: var(--ink);
  cursor: pointer;
  transition: background 150ms ease;
}

.report-actions-option:hover {
  background: var(--gray-background);
}

.report-cover {
  position: relative;
}

.file-card {
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--gray-light);
  border-radius: 10px;
  background: var(--gray-lightest);
}

.file-card-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  color: var(--ink-2);
}

.file-card-icon svg {
  width: 100%;
  height: 100%;
}

.file-card-info {
  flex: 1;
  min-width: 0;
}

.file-card-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-card-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 2px;
}

.file-card-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--gray-light);
  border-top-color: var(--ink-2);
  border-radius: 50%;
  animation: fc-spin 0.8s linear infinite;
}

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

.file-card-check {
  color: #22c55e;
  font-weight: 600;
}

.file-card-error {
  color: #ef4444;
  font-weight: 600;
}

/* ============================================
   7. MOBILE OVERRIDES
   All scoped under .ren-chat-container
   ============================================ */

@media (min-width: 769px) and (max-width: 1024px) {
  .ren-chat-container .chat-interface.with-report {
    grid-template-columns: 0% 40% 6px 1fr;
  }

  .welcome-title { font-size: 2rem; }
  .welcome-subtitle { font-size: 1.4rem; }
  .desktop-title { display: none; }
  .mobile-title { display: inline; }
}

@media (max-width: 768px) {
  body {
    overflow: auto !important;
  }

  .report-content {
    overflow: visible !important;
  }

  /* Report page mobile */

  .report-container iframe {
    width: 100%;
    height: 100%;
    min-height: calc(100vh - 50px);
    border: none;
    display: block;
  }

  .report-container:has(iframe) {
    padding: 0;
    overflow: hidden;
  }

  .report-nav-footer {
    padding: var(--spacing-3) var(--spacing-4);
    flex-direction: column;
    gap: var(--spacing-3);
  }

  .report-nav-btn {
    width: 100%;
    justify-content: center;
  }

  .report-cover {
    padding: var(--spacing-6) var(--spacing-5) var(--spacing-10) var(--spacing-5) !important;
    margin-left: calc(-1 * var(--spacing-5));
    margin-right: calc(-1 * var(--spacing-5));
    width: calc(100% + (2 * var(--spacing-5)));
  }

  .report-hero-image {
    height: 180px !important;
  }

  .report-type {
    padding: 20px 0 0 0 !important;
    font-size: 0.625rem;
  }

  .report-title {
    font-size: 0.8125rem;
    max-width: 95%;
    line-height: var(--line-height-snug) !important;
  }

  .report-prepared {
    margin-top: var(--spacing-4);
  }

  .report-cta {
    text-align: left;
  }

  .executive-headline,
  h2.executive-headline,
  .report-content h2.executive-headline {
    font-size: var(--font-size-sm) !important;
    line-height: var(--line-height-snug) !important;
  }

  .report-logo-full { display: none; }
  .report-logo-symbol { display: block; }

  .report-logo img,
  .report-logo-full,
  .report-logo-symbol {
    height: var(--spacing-6);
  }

  .report-type {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
  }

  .report-content table {
    cursor: pointer;
    position: relative;
  }

  .report-content table::after {
    content: 'Tap to expand';
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6875rem;
    color: var(--ink-2);
    opacity: 0.7;
  }

  .report-content table:active {
    opacity: 0.8;
  }

  .report-header-mobile {
    display: flex;
  }

  /* Chat page mobile */

  .desktop-title { display: none; }
  .mobile-title { display: inline; }

  .ren-chat-container .welcome-screen {
    padding: 0.4rem 0.3rem;
  }

  .ren-chat-container .welcome-content {
    padding: 0 0.2rem;
  }

  .ren-chat-container .centered-input-container {
    max-width: 100%;
    padding: 0 var(--spacing-4);
  }

  .ren-chat-container .welcome-title {
    font-size: 2rem;
  }

  .ren-chat-container .welcome-subtitle {
    font-size: 1.2rem;
    margin-bottom: 2rem;
  }

  .ren-chat-container .send-btn {
    width: 44px;
    height: 44px;
  }

  /* Collapsible report sections */

  .collapsible-section {
    margin-top: 0 !important;
    border-bottom: 1px solid var(--gray-light);
    padding-bottom: 0;
  }

  .collapsible-section:last-child {
    border-bottom: none;
  }

  .collapsible-section .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-4) 0;
    margin: 0;
    border-bottom: none;
  }

  .collapsible-section .framework-header {
    margin-bottom: 0;
    font-size: 1.1rem;
    border-top: none;
    margin-top: 0;
    padding-top: 0;
  }

  .collapsible-section .framework-subtitle {
    font-size: 0.85rem;
    margin-top: var(--spacing-1);
  }

  /* Chat interface: absolute positioned pane */

  .ren-chat-container .chat-interface {
    height: calc(100dvh - 50px);
  }

  .ren-chat-container .chat-pane {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    max-width: none;
    margin: 0;
    padding: 0;
    height: auto;
  }

  .ren-chat-container .messages-container {
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 20px));
  }

  /* Fixed input at bottom */

  .ren-chat-container .input-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px var(--spacing-3);
    padding-bottom: max(4px, env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--gray-light);
    max-width: none;
    margin: 0;
    z-index: 1000;
  }

  body.keyboard-open .ren-chat-container .input-area {
    position: absolute;
  }

  .ren-chat-container .input-area .input-wrapper {
    min-height: 44px;
    padding: var(--spacing-2) var(--spacing-3);
    border-radius: 22px;
  }

  .ren-chat-container .input-area .message-input {
    font-size: 1rem;
  }

  /* Mobile report: full screen overlay */

  .ren-chat-container .chat-interface.with-report {
    display: block;
  }

  .ren-chat-container .chat-interface.with-report .chat-pane {
    display: none;
  }

  .ren-chat-container .chat-interface.with-report .report-panel {
    display: block;
    position: fixed;
    top: 50px;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(100dvh - 50px);
    z-index: 100;
    border-left: none;
    padding: 0;
    overflow-y: auto;
  }

  .ren-chat-container .chat-interface.with-report .report-panel.visible {
    opacity: 1;
  }

  /* History dots */

  .history-dots-btn.visible {
    display: block !important;
    top: calc(50px + 12px);
    right: var(--spacing-4);
    padding: 6px 10px;
    font-size: 1.125rem;
  }

  .company-pill {
    max-width: 120px;
    font-size: 11px;
  }

}