/* ═══════════════════════════════════════════════════════
   Responsive — All @media queries consolidated
   ═══════════════════════════════════════════════════════ */

/* ── Mobile topbar (hidden by default) ── */
.mobile-topbar {
  display: none;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  gap: 10px;
  flex-shrink: 0;
}

.mobile-menu-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  flex: 1;
}

.mobile-title span {
  color: var(--accent);
}

/* ── Sidebar overlay (hidden by default) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 150;
}

.sidebar.open ~ .sidebar-overlay {
  display: block;
}

/* ── Tablet (1024px) ── */
@media (max-width: 1024px) {
  .chat-setup-hero {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .chat-field-key {
    width: 100%;
  }
  .lb-plot-label {
    width: 160px;
  }
  .pipeline-desc {
    font-size: 0.65rem;
  }
}

/* ── Mobile (768px) ── */
@media (max-width: 768px) {
  /* App layout becomes column on mobile */
  .app-layout {
    flex-direction: column;
  }

  /* Mobile topbar */
  .mobile-topbar {
    display: flex;
  }

  /* Sidebar becomes fixed overlay */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px !important;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 0 0 30px rgba(0,0,0,0.3);
    z-index: 200;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar.collapsed {
    width: 260px !important;
    transform: translateX(-100%);
  }
  .sidebar.collapsed.open {
    transform: translateX(0);
  }
  /* On mobile, undo all collapsed styles — sidebar is full-width overlay */
  .sidebar.collapsed .sidebar-header h1,
  .sidebar.collapsed .sidebar-label {
    opacity: 1 !important;
    width: auto !important;
    overflow: visible !important;
    padding: initial !important;
    margin: initial !important;
    border: none !important;
  }
  .sidebar.collapsed .sidebar-footer a {
    display: inline-flex !important;
    opacity: 1 !important;
    width: auto !important;
    padding: 3px 8px !important;
  }
  .sidebar.collapsed .sidebar-item {
    justify-content: flex-start !important;
    padding: 10px 14px !important;
    gap: 10px !important;
  }
  .sidebar.collapsed .sidebar-logo-icon {
    display: block !important;
  }
  .sidebar.collapsed .sidebar-footer {
    justify-content: flex-start !important;
    padding: 12px 14px !important;
    gap: 6px !important;
  }
  .sidebar-resize {
    display: none;
  }

  /* Main content fills remaining space */
  .main-content {
    flex: 1;
    min-height: 0;
  }
  .main-body {
    padding: 16px;
  }

  /* Layout */
  .container { padding: 16px; }
  .header { padding: 0 16px; height: 48px; }
  .header h1 { font-size: 1.1rem; }

  /* Hero */
  .hero-inner { grid-template-columns: 1fr; gap: 20px; padding: 24px 16px; }
  .hero-text h2 { font-size: 1.2rem; }
  .hero-text p { font-size: 0.82rem; }
  .hero-pipeline { display: none; }

  /* Filters */
  .filter-bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .filter-search { width: 100%; }
  .filter-search:focus { width: 100%; }
  .filter-range { justify-content: flex-start; }
  .filter-count { margin-left: 0; text-align: right; }

  /* Table */
  .table-wrap { border-radius: var(--radius); overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .runs-table td, .runs-table th { padding: 7px 8px; }
  .runs-table td { font-size: 0.74rem; }
  .runs-table th { font-size: 0.6rem; }
  .date-time { display: none; }
  .scenario-range { display: none; }
  .note-cell { max-width: 100px; font-size: 0.7rem; }
  .git-hash { font-size: 0.64rem; padding: 1px 5px; }
  .models-badge { font-size: 0.7rem; }
  .group-count { font-size: 0.6rem; padding: 1px 6px; }
  .group-name { font-size: 0.78rem; }

  /* Detail page */
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .spec-grid { grid-template-columns: 1fr; }
  .gallery { grid-template-columns: 1fr; }
  .run-meta { flex-direction: column; gap: 4px; }
  .card { padding: 14px; }
  .run-header h2 { font-size: 1.25rem; }
  .models-table { font-size: 0.74rem; }
  .models-table th, .models-table td { padding: 6px 8px; }

  /* Lightbox */
  .lightbox img { max-width: 96vw; max-height: 85vh; border-radius: 4px; }

  /* Chat */
  .chat-responses {
    grid-template-columns: 1fr;
  }
  .chat-user-bubble {
    max-width: 90%;
  }
  .chat-setup-screen {
    min-height: auto;
    padding: 20px 14px;
  }
  .chat-setup-hero {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 16px;
    overflow: visible;
  }
  .chat-setup-hero .hero-text h2 {
    font-size: 1.1rem;
  }
  .battle-models {
    flex-direction: column;
    gap: 8px;
  }
  .battle-vs {
    display: none;
  }
  .battle-fighter {
    width: 100%;
  }
  .battle-key-section {
    width: 100%;
  }
  .custom-select {
    width: 100%;
  }
  .custom-select-trigger {
    width: 100%;
  }
  .chat-topbar {
    flex-wrap: wrap;
    font-size: 0.76rem;
    padding: 8px 12px;
    gap: 6px;
  }
  .chat-input-wrap {
    padding: 8px 12px;
  }
  .vote-buttons {
    flex-direction: column;
    gap: 6px;
  }
  .vote-btn {
    font-size: 0.78rem;
    padding: 10px 14px;
  }

  /* Leaderboard */
  .const-pills {
    gap: 4px;
  }
  .const-pill {
    font-size: 0.68rem;
    padding: 4px 10px;
  }
  .lb-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .lb-view-tabs, .lb-group-tabs {
    width: 100%;
  }
  .lb-view-tab, .lb-group-tab {
    flex: 1;
    justify-content: center;
    font-size: 0.72rem;
  }
  .lb-plot-label {
    width: 100px;
    font-size: 0.68rem;
  }
  .lb-plot-value {
    width: 36px;
    font-size: 0.68rem;
  }
  .lb-pareto-table th.lb-pareto-col {
    max-width: 50px;
    font-size: 0.55rem;
  }
  .lb-plot-tooltip {
    display: none;
  }
  .const-section-header {
    font-size: 0.78rem;
  }
  .const-criterion {
    padding: 8px 10px;
  }
  .const-criterion-text {
    font-size: 0.78rem;
  }
}

/* ── Small mobile (480px) ── */
@media (max-width: 480px) {
  .header-right a { display: none; }
  .hero-text h2 { font-size: 1.05rem; }
  .hero-text p { font-size: 0.78rem; }
  .hero-inner { padding: 16px 12px; }
  .hero-btn { font-size: 0.72rem; padding: 6px 12px; }
  .container { padding: 12px; }
  .main-body { padding: 12px; }
  .section-title { font-size: 0.95rem; }
  .filter-select { font-size: 0.7rem; padding: 5px 24px 5px 8px; }
  .filter-search { font-size: 0.72rem; }
  .filter-input { width: 44px; font-size: 0.68rem; }
  .runs-table td, .runs-table th { padding: 6px 6px; }
  .note-cell { max-width: 80px; }
  .card { padding: 12px; }
  .card h2 { font-size: 0.95rem; }
  .metric-item { padding: 10px; }
  .metric-value { font-size: 1rem; }
  .spec-section { padding: 10px 12px; }

  .chat-setup-hero .hero-text h2 {
    font-size: 0.95rem;
  }
  .chat-setup-hero .hero-text p {
    font-size: 0.78rem;
  }
  .battle-title {
    font-size: 1.15rem;
  }
  .battle-config {
    padding: 16px;
  }
  .lb-plot-label {
    width: 80px;
    font-size: 0.62rem;
  }
  .const-pills {
    gap: 3px;
  }
  .const-pill {
    font-size: 0.62rem;
    padding: 3px 8px;
  }
}
