/* 🧑‍⚖️ AI Referee POC – reference UI with gradients and hourglass loader */
:root {
  --bg: #0a0a0d;
  --bg-pattern: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(120, 80, 180, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(220, 120, 80, 0.06), transparent);
  --surface: #16161c;
  --surface-upload: #1a1a24;
  --surface-hover: #22222c;
  --border: #2e2e3a;
  --border-dash: #3a3a48;
  --text: #f5f5f7;
  --text-muted: #9ca3af;
  --gradient-welcome: linear-gradient(90deg, #ec4899 0%, #a855f7 50%, #6366f1 100%);
  --gradient-welcome-title: linear-gradient(90deg, #f59e0b 0%, #ec4899 100%);
  --gradient-accent: linear-gradient(90deg, #f59e0b 0%, #eab308 50%, #a855f7 100%);
  --accent-gold: #f59e0b;
  --accent-purple: #a855f7;
  --accent-pink: #ec4899;
  --tab-active-bg: rgba(99, 102, 241, 0.25);
  --success: #22c55e;
  --warning: #eab308;
  --error: #ef4444;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 9999px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  background-image: var(--bg-pattern);
  color: var(--text);
  line-height: 1.5;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header – full width; .header-bar is the long pill (curved left & right) */
.header {
  margin: 0 -1.5rem 2rem;
  padding: 0;
  padding-top: 1.5rem;
  margin-top: 1.25rem;
  width: 100%;
  max-width: calc(1200px + 3rem);
  margin-left: auto;
  margin-right: auto;
}

/* Long horizontal pill bar: stadium shape, subtle glow, shadow */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  width: 100%;
  padding: 0.7rem 2rem 0.7rem 1.75rem;
  min-height: 54px;
  border-radius: 9999px;
  background: linear-gradient(180deg, #252532 0%, #1e1e28 100%);
  border: 1px solid #32324a;
  box-shadow:
    0 6px 24px rgba(0, 0, 0, 0.4),
    0 2px 8px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  box-sizing: border-box;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b 0%, #eab308 40%, #a855f7 70%, #6366f1 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-circle svg {
  width: 20px;
  height: 20px;
  display: block;
  color: rgba(255, 255, 255, 0.95);
}

.logo-emoji {
  font-size: 1.2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.logo {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--text);
}

.header-bar .logo {
  background: var(--gradient-welcome-title);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-tabs {
  display: flex;
  gap: 0.5rem;
  background: transparent;
  padding: 0;
  border-radius: 0;
  border: none;
}

.header-bar .nav-tab {
  padding: 0.5rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #9ca3af;
  text-decoration: none;
  border-radius: 9999px;
  transition: color 0.2s, background 0.2s;
}

.header-bar .nav-tab:hover {
  color: #e5e7eb;
}

.header-bar .nav-tab.active {
  background-image: linear-gradient(90deg, #f59e0b 0%, #a855f7 50%, #6366f1 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 600;
  box-shadow: none;
}

.header-bar .nav-tab.active:hover {
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Main */
.main {
  flex: 1;
}

/* Tab panels */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Welcome – gradient title, AI highlight */
.welcome-section {
  margin-bottom: 2rem;
}

.welcome-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
  text-align: center;
  background: var(--gradient-welcome-title);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-subtitle {
  text-align: center;
  color: var(--text-muted);
  margin: 0 0 2rem;
  font-size: 1rem;
}

.highlight-ai {
  color: var(--accent-gold);
  font-weight: 600;
}

/* Dropzone – dark grey-blue, dashed border, browse link */
.dropzone {
  background: var(--surface-upload);
  border: 2px dashed var(--border-dash);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent-purple);
  background: var(--surface-hover);
  box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.15);
}

.dropzone.disabled {
  opacity: 0.6;
  pointer-events: none;
  cursor: not-allowed;
  filter: saturate(0.7);
}
.dropzone.disabled:hover,
.dropzone.disabled.dragover {
  border-color: var(--border-dash);
  background: var(--surface-upload);
  box-shadow: none;
}

.dropzone-content {
  pointer-events: none;
}

.dropzone-content .browse-link {
  pointer-events: auto;
}

.dropzone-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
  color: var(--text-muted);
}

.dropzone-icon svg {
  width: 48px;
  height: 48px;
}

.dropzone-folder {
  position: relative;
  display: inline-block;
}

.dropzone-folder svg {
  width: 56px;
  height: 56px;
  color: var(--text-muted);
}

.dropzone-sparkle {
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 1.25rem;
  color: var(--accent-gold);
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

.dropzone-text {
  font-size: 1rem;
  font-weight: 500;
  margin: 0 0 1rem;
  color: var(--text);
}

.browse-link {
  color: var(--accent-gold);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
}

.browse-link:hover {
  color: #fbbf24;
}

.dropzone-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem 1.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.dropzone-features .check {
  color: var(--success);
  margin-right: 0.35rem;
}

.upload-status {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.upload-status.success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.upload-status.error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
}

.indexing-loading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
}
.indexing-loading.hidden {
  display: none;
}
.indexing-hourglass {
  display: inline-block;
  animation: hourglass-spin 2s ease-in-out infinite;
}
.index-log {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  max-height: 8rem;
  overflow-y: auto;
  font-size: 0.8rem;
  line-height: 1.4;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}
.index-log.hidden {
  display: none;
}

.analyze-section {
  margin-top: 1.5rem;
  text-align: center;
}

.btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 1.75rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, transform 0.05s;
  background: var(--gradient-accent);
  color: #fff;
}

.btn:active {
  transform: scale(0.98);
}

.btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Progress – hourglass loader + bar + live steps */
.progress-section {
  margin: 2rem 0;
  padding: 1.75rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.progress-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.progress-header-text {
  flex: 1;
  min-width: 0;
}

.hourglass-loader {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  animation: hourglass-spin 2s ease-in-out infinite;
}

.hourglass-loader.state-done {
  animation: hourglass-done 0.5s ease forwards;
}

@keyframes hourglass-spin {
  0%, 100% { transform: rotate(0deg); opacity: 1; }
  50% { transform: rotate(180deg); opacity: 0.9; }
}

@keyframes hourglass-done {
  to { transform: scale(1.15); opacity: 1; }
}

.progress-header h3 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
  font-weight: 600;
  background: var(--gradient-welcome);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.progress-text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: opacity 0.25s ease;
}

.progress-text.progress-text-live {
  color: var(--text);
  font-weight: 500;
  animation: progress-text-pulse 2.5s ease-in-out infinite;
}

@keyframes progress-text-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

.progress-bar {
  position: relative;
  height: 10px;
  background: var(--border);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 1.25rem;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--gradient-accent);
  border-radius: var(--radius-pill);
  transition: width 0.4s ease;
  position: relative;
}

.progress-section:not(.progress-done) .progress-fill {
  animation: progress-glow 2s ease-in-out infinite;
}

@keyframes progress-glow {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.08); }
}

.progress-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

.progress-step {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: color 0.2s, background 0.2s;
}

.progress-step .step-icon {
  flex-shrink: 0;
  width: 1.25rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.progress-step.processing {
  color: var(--text);
  background: rgba(99, 102, 241, 0.1);
}

.progress-step.processing .step-icon {
  color: var(--accent-purple);
}

.step-icon-spinner {
  animation: step-icon-spin 1.2s linear infinite;
}

.progress-step.done {
  color: var(--success);
}

.progress-step.done .step-icon {
  color: var(--success);
}

@keyframes step-icon-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Results */
.results-section {
  margin-top: 2rem;
}

.results-title {
  font-size: 1.35rem;
  margin: 0 0 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--gradient-welcome);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.results-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--border);
}

.card h4 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: var(--text-muted);
}

.card .value {
  font-size: 1.1rem;
  font-weight: 500;
}

.card-description,
.phase-timings {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Three equal columns that fill the full width of the card */
.summary-grid.summary-grid-three {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  width: 100%;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.metric {
  background: var(--surface-hover);
  padding: 0.85rem 0.5rem;
  border-radius: var(--radius-sm);
  text-align: center;
  min-height: 0;
}

.summary-grid-three .metric {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.metric-value {
  font-weight: 600;
  font-size: 1rem;
}

/* Card accent colors – professional and attractive */
.card-match-result {
  border-left: 4px solid #22c55e;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.06) 0%, var(--surface) 50%);
}

.card-match-result .metric {
  background: rgba(34, 197, 94, 0.12);
}

.card-match-result .metric-value {
  color: #22c55e;
}

.card-summary {
  border-left: 4px solid #a855f7;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.06) 0%, var(--surface) 50%);
}

.card-summary .value {
  color: var(--text);
}

.card-processing {
  border-left: 4px solid #3b82f6;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.06) 0%, var(--surface) 50%);
}

.card-processing .metric {
  background: rgba(59, 130, 246, 0.12);
}

.card-processing .metric-value {
  color: #60a5fa;
}

.metric-caption {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.card-cost-summary {
  border-left: 4px solid #10b981;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.06) 0%, var(--surface) 50%);
}

.card-cost-summary h4 {
  color: #10b981;
}

.card-cost-summary .metric-value {
  color: #34d399;
}

.cost-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(16, 185, 129, 0.2);
}

.cost-breakdown-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.cost-breakdown-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
}

.cost-breakdown-list li {
  display: block;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(16, 185, 129, 0.08);
}

.cost-breakdown-list li:last-child {
  border-bottom: none;
}

.cost-breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.cost-breakdown-label {
  color: var(--text-secondary);
}

.cost-breakdown-value {
  color: #34d399;
  font-variant-numeric: tabular-nums;
}

.cost-breakdown-tokens {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  padding-left: 0.25rem;
}

.cost-breakdown-empty {
  color: var(--text-muted);
  font-style: italic;
}

@media (max-width: 640px) {
  .cost-breakdown {
    grid-template-columns: 1fr;
  }
}

/* Marengo tab: cost block above search results */
.marengo-cost-block {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: rgba(139, 92, 246, 0.12);
  border-radius: var(--radius-sm);
  border-left: 3px solid #8b5cf6;
}

.marengo-cost-block strong {
  color: var(--text);
}

.marengo-cost-breakdown {
  color: var(--text-muted);
  font-weight: normal;
}

.card-clips {
  border-left: 4px solid #f59e0b;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.05) 0%, var(--surface) 50%);
}

.card-clips h4 {
  color: #f59e0b;
}

.card-compilation {
  border-left: 4px solid #ec4899;
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.06) 0%, var(--surface) 50%);
}

.card-compilation h4 {
  color: #ec4899;
}

.compilation-video {
  width: 100%;
  max-height: 360px;
  border-radius: var(--radius-sm);
  background: #0a0a0f;
}

.card-evidence {
  border-left: 4px solid #64748b;
  background: linear-gradient(135deg, rgba(100, 116, 139, 0.06) 0%, var(--surface) 50%);
}

.card-evidence h4 {
  color: #94a3b8;
}

.card-evidence-qwen {
  border-left-color: #8b5cf6;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.06) 0%, var(--surface) 50%);
}

.card-evidence-qwen h4 {
  color: #a78bfa;
}

.evidence-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0.5rem 0 0;
}

/* Evidence grid: all boxes fill the outer container (equal columns) */
.evidence-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 0.75rem;
  width: 100%;
}

.evidence-item {
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.evidence-item img,
.evidence-item video {
  width: 100%;
  display: block;
  flex: 1;
  min-height: 160px;
  max-height: 280px;
  object-fit: contain;
  background: #0c0c12;
}

.evidence-item img {
  cursor: pointer;
}

.evidence-item img:hover {
  opacity: 0.92;
}

.evidence-item .caption {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .evidence-grid {
    grid-auto-flow: row;
    grid-auto-columns: unset;
  }
}

/* Image modal (dialog) – only visible when [open]; close button inside content */
.image-modal:not([open]) {
  display: none !important;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
  border: none;
  background: transparent;
  max-width: none;
  max-height: none;
}

.image-modal::backdrop {
  background: rgba(0, 0, 0, 0.85);
  cursor: pointer;
}

.image-modal-backdrop {
  position: absolute;
  inset: 0;
  cursor: pointer;
}

.image-modal-content {
  position: relative;
  z-index: 1;
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.image-modal-content img {
  max-width: 100%;
  max-height: 85vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.image-modal-caption {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
}

.image-modal-close {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  z-index: 2;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.2s;
}

.image-modal-close:hover {
  background: rgba(0, 0, 0, 0.9);
}

/* Two clips per row on main AI Referee results */
.highlights-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (max-width: 640px) {
  .summary-grid.summary-grid-three {
    grid-template-columns: 1fr;
  }
  .highlights-list {
    grid-template-columns: 1fr;
  }
}

.highlight-clip {
  background: var(--surface-hover);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.highlight-clip video {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
}

.highlight-clip .caption {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

.hidden {
  display: none !important;
}

/* RAG Search tab – Video Search UI (no implementation) */
.rag-page-title {
  font-size: 1.35rem;
  margin: 0 0 1.25rem;
  background: var(--gradient-welcome);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.rag-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: stretch;
}

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

.rag-upload-panel {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.5rem;
}

.rag-dropzone {
  border: 2px dashed var(--border-dash);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--surface-upload);
}

.rag-dropzone:hover {
  border-color: var(--accent-purple);
  background: var(--surface-hover);
}

.rag-dropzone-icon {
  display: block;
  font-size: 2rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1;
}

.rag-dropzone-text {
  font-size: 0.95rem;
  color: var(--text);
  margin: 0 0 0.5rem;
}

.rag-dropzone .browse-link {
  color: #6366f1;
  text-decoration: underline;
  cursor: pointer;
}

.rag-no-file {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

.rag-chat-panel {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 320px;
}

.rag-chat-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.rag-chat-title {
  font-weight: 600;
  font-size: 1rem;
  background: var(--gradient-welcome);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.rag-chat-messages {
  flex: 1;
  padding: 1rem 1.25rem;
  overflow-y: auto;
}

.rag-msg {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
}

.rag-msg-bot {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  align-self: flex-start;
}

.rag-msg-user {
  align-self: flex-end;
  background: var(--accent-purple);
  color: white;
  border: none;
}

.rag-msg-user p {
  color: inherit;
}

.rag-msg p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text);
}

.search-results-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.search-result-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.search-result-card:last-child {
  border-bottom: none;
}

.search-result-thumb {
  width: 120px;
  height: auto;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.search-result-body {
  flex: 1;
  min-width: 0;
}

.search-result-time {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent-purple);
  margin-right: 0.5rem;
  display: block;
  margin-bottom: 0.35rem;
}

.search-result-video {
  width: 100%;
  max-width: 320px;
  max-height: 200px;
  border-radius: var(--radius-sm);
  background: var(--surface-upload);
  margin: 0.25rem 0;
}

.search-result-clip-link {
  font-size: 0.85rem;
  color: var(--accent-purple);
  text-decoration: none;
  display: inline-block;
  margin-top: 0.25rem;
}

.search-result-clip-link:hover {
  text-decoration: underline;
}

.search-result-details {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

.search-result-details summary {
  cursor: pointer;
  color: var(--accent-purple);
  font-weight: 500;
  user-select: none;
}

.search-result-details summary:hover {
  text-decoration: underline;
}

.search-result-desc {
  margin-top: 0.35rem;
  padding: 0.5rem 0;
  color: var(--text);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.search-result-desc br {
  display: block;
  content: "";
  margin-top: 0.25rem;
}

.search-result-body p {
  margin: 0.35rem 0 0.5rem;
  font-size: 0.9rem;
}

.rag-msg .error {
  color: var(--error, #c00);
}

.rag-chat-input-wrap {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.rag-chat-input {
  flex: 1;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-upload);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.rag-chat-input::placeholder {
  color: var(--text-muted);
}

.rag-chat-input:focus {
  outline: none;
  border-color: var(--accent-purple);
}

.rag-chat-send {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--accent-purple);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.rag-chat-send:hover:not(:disabled) {
  filter: brightness(1.1);
}

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

/* Footer – copyright left, links right */
.footer {
  margin-top: auto;
  padding: 1.25rem 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.footer-copy {
  margin: 0;
}

.footer-links {
  display: flex;
  gap: 1rem;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--text);
}
