:root {
  --bg: #0a0e27;
  --bg-card: #151932;
  --bg-card-hover: #1a1f3a;
  --ink: #e8eaed;
  --muted: #9aa0b4;
  --accent: #00d9ff;
  --accent-hover: #00b8d4;
  --success: #00ff88;
  --warning: #ffd93d;
  --danger: #ff4757;
  --panel: #1e2439;
  --line: #2a3049;
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --gradient-accent: linear-gradient(135deg, #00d9ff 0%, #00b8d4 100%);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 80px;
}

/* Light theme */
body.light-theme {
  --bg: #f5f7fa;
  --bg-card: #ffffff;
  --bg-card-hover: #f8f9fb;
  --ink: #1a202c;
  --muted: #64748b;
  --panel: #f1f5f9;
  --line: #e2e8f0;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

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

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(at 0% 0%, rgba(102, 126, 234, 0.1) 0, transparent 50%),
    radial-gradient(at 100% 100%, rgba(118, 75, 162, 0.1) 0, transparent 50%);
  background-attachment: fixed;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

/* ========== SIDEBAR ========== */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-logo {
  font-size: 20px;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
  transition: opacity 0.3s ease;
}

.sidebar.collapsed .sidebar-logo {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--ink);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.sidebar-toggle:hover {
  background: var(--panel);
}

.sidebar-nav {
  flex: 1;
  padding: 20px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.2s ease;
  position: relative;
  border-left: 3px solid transparent;
}

.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--gradient-accent);
  transform: scaleY(0);
  transition: transform 0.2s ease;
}

.nav-item:hover {
  background: var(--panel);
  color: var(--ink);
}

.nav-item.active {
  color: var(--accent);
  background: var(--panel);
}

.nav-item.active::before {
  transform: scaleY(1);
}

.nav-item svg {
  flex-shrink: 0;
}

.sidebar.collapsed .nav-item span {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--line);
}

.theme-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 600;
}

.theme-toggle:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
}

.theme-toggle .sun-icon {
  display: none;
}

.light-theme .theme-toggle .sun-icon {
  display: block;
}

.light-theme .theme-toggle .moon-icon {
  display: none;
}

.sidebar.collapsed .theme-toggle span {
  display: none;
}

/* ========== MAIN CONTENT ========== */
.page {
  margin-left: var(--sidebar-width);
  padding: 40px 32px 80px;
  width: calc(100vw - var(--sidebar-width));
  box-sizing: border-box;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.page.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed-width);
  width: calc(100vw - var(--sidebar-collapsed-width));
}

/* ========== HERO ========== */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  background: var(--bg-card);
  padding: 40px 48px;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  margin-bottom: 32px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.hero.animated {
  opacity: 1;
  transform: translateY(0);
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-primary);
}

.hero h1 {
  margin: 0 0 12px;
  font-size: 42px;
  font-weight: 800;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.meta {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.meta-item {
  text-align: right;
}

.meta-label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 4px;
}

.meta-value {
  font-weight: 600;
  font-size: 14px;
}

.status-live {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--success);
}

.status-indicator {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(1.2);
  }
}

/* ========== SECTIONS ========== */
.section-container {
  margin-bottom: 48px;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.section-container.animated {
  opacity: 1;
  transform: translateY(0);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--ink);
}

.section-title svg {
  color: var(--accent);
}

/* ========== GRID ========== */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

/* ========== CARDS ========== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  overflow-x: auto;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  border-color: var(--accent);
}

.card h2 {
  margin: 0 0 24px;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ========== STATS ========== */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.stat {
  background: var(--panel);
  padding: 18px 20px;
  border-radius: 14px;
  border: 1px solid var(--line);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: default;
}

.stat:hover {
  border-color: var(--accent);
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 24px rgba(0, 217, 255, 0.15);
}

.stat span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 8px;
}

.stat strong {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  display: block;
}

/* ========== TOOLTIPS ========== */
.tooltip {
  position: fixed;
  background: var(--bg-card);
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  pointer-events: none;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  max-width: 300px;
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* ========== CLUSTER PANEL ========== */
.cluster-panel {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 2fr;
  gap: 24px;
}

.cluster-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 500px;
  overflow-y: auto;
  padding-right: 4px;
}

.cluster-list::-webkit-scrollbar {
  width: 6px;
}

.cluster-list::-webkit-scrollbar-track {
  background: var(--panel);
  border-radius: 3px;
}

.cluster-list::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
  transition: background 0.2s ease;
}

.cluster-list::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.cluster-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.cluster-btn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--gradient-accent);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.cluster-btn:hover {
  transform: translateX(6px);
  border-color: var(--accent);
  background: var(--bg-card-hover);
  box-shadow: 0 4px 16px rgba(0, 217, 255, 0.1);
}

.cluster-btn:hover::before {
  transform: scaleX(1);
}

.cluster-id {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.05em;
  display: block;
  width: 100%;
  position: relative;
  z-index: 1;
}

.cluster-label {
  font-weight: 600;
  color: var(--ink);
  font-size: 14px;
  display: block;
  width: 100%;
  overflow: visible;
  text-overflow: unset;
  white-space: normal;
  word-break: break-word;
  line-height: 1.4;
  position: relative;
  z-index: 1;
}

.cluster-meta {
  font-size: 12px;
  color: var(--muted);
  display: block;
  width: 100%;
  line-height: 1.4;
  position: relative;
  z-index: 1;
}

.cluster-detail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  max-height: 600px;
  overflow-y: auto;
}

.cluster-detail::-webkit-scrollbar {
  width: 8px;
}

.cluster-detail::-webkit-scrollbar-track {
  background: var(--bg-card);
  border-radius: 4px;
}

.cluster-detail::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

.cluster-detail::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.cluster-detail h3 {
  color: var(--ink);
  font-size: 22px;
  margin-bottom: 20px;
}

.cluster-detail h4 {
  color: var(--accent);
  font-size: 16px;
  margin: 24px 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cluster-detail ol {
  padding-left: 24px;
  color: var(--muted);
}

.cluster-detail ol li {
  margin-bottom: 10px;
  line-height: 1.6;
}

.cluster-detail ul {
  list-style: none;
  padding: 0;
  margin: 12px 0;
}

.cluster-detail ul li {
  padding: 8px 12px;
  background: var(--bg-card);
  border-radius: 8px;
  margin-bottom: 8px;
  border-left: 3px solid var(--accent);
}

.muted {
  color: var(--muted);
}

/* ========== TABS ========== */
.tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 12px 20px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  font-size: 14px;
}

.tab-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
}

.tab-btn.active {
  background: var(--gradient-accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(0, 217, 255, 0.3);
}

.tab-panel {
  display: none;
  animation: fadeIn 0.4s ease;
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========== TABLE ========== */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
}

.table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  background: var(--panel);
}

.table tbody tr {
  transition: background 0.2s ease;
}

.table tbody tr:hover {
  background: var(--bg-card-hover);
}

/* ========== SEARCH ========== */
.search {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.search input {
  flex: 1;
  padding: 16px 20px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 15px;
  transition: all 0.3s ease;
}

.search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 217, 255, 0.1);
  background: var(--bg-card);
}

.search input::placeholder {
  color: var(--muted);
}

.search button {
  background: var(--gradient-accent);
  color: #fff;
  border: none;
  padding: 16px 28px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 217, 255, 0.2);
}

.search button:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 217, 255, 0.4);
}

.search button:active {
  transform: translateY(-1px);
}

/* ========== RESULTS ========== */
.results {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  min-height: 40px;
}

.result-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 18px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
  font-weight: 500;
}

.result-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 217, 255, 0.15);
}

.loading-spinner,
.error-message,
.empty-message {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  text-align: center;
}

.loading-spinner {
  background: var(--panel);
  color: var(--warning);
  animation: pulse 1.5s ease-in-out infinite;
}

.error-message {
  background: rgba(255, 71, 87, 0.1);
  color: var(--danger);
  border: 1px solid var(--danger);
}

.empty-message {
  background: var(--panel);
  color: var(--muted);
}

/* ========== HORSE DETAIL ========== */
.horse-detail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  max-height: 800px;
  overflow-y: auto;
}

.horse-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.horse-head h3 {
  font-size: 24px;
  margin-bottom: 8px;
}

.horse-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.horse-kpis div {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  transition: all 0.3s ease;
}

.horse-kpis div:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 217, 255, 0.1);
}

.horse-kpis span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  margin-bottom: 6px;
}

.horse-kpis strong {
  font-size: 20px;
  font-weight: 700;
  color: var(--success);
}

.horse-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.horse-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 16px;
}

.horse-charts-grid > div {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.horse-charts-grid h5 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#gradeDistributionChart {
  display: block;
  width: 100%;
  height: 220px;
  max-height: 240px;
}

.mini-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  transition: all 0.3s ease;
}

.mini-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(0, 217, 255, 0.1);
}

.mini-card h4 {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.profile-grid > div {
  padding: 12px;
  background: var(--panel);
  border-radius: 10px;
  border: 1px solid var(--line);
  transition: all 0.2s ease;
}

.profile-grid > div:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.profile-grid span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.profile-grid strong {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

/* Stats grid for cluster details */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.stats-grid > div {
  padding: 14px 16px;
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid var(--line);
  transition: all 0.2s ease;
}

.stats-grid > div:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 217, 255, 0.1);
}

.stats-grid span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  font-weight: 500;
}

.stats-grid strong {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  display: block;
}

/* Race types and finish types lists */
.race-types-list, .finish-types-list {
  list-style: none;
  padding: 0;
  margin: 16px 0;
}

.race-types-list li, .finish-types-list li {
  padding: 12px 16px;
  background: var(--bg-card);
  border-left: 4px solid var(--accent);
  margin-bottom: 10px;
  border-radius: 8px;
  transition: all 0.2s ease;
  color: var(--ink);
  font-size: 14px;
}

.race-types-list li:hover, .finish-types-list li:hover {
  background: var(--bg-card-hover);
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0, 217, 255, 0.15);
}

.race-types-list li strong, .finish-types-list li strong {
  color: var(--accent);
  font-weight: 600;
}

/* Custom scrollbar for horse-detail */
.horse-detail::-webkit-scrollbar {
  width: 8px;
}

.horse-detail::-webkit-scrollbar-track {
  background: var(--bg-card);
  border-radius: 4px;
}

.horse-detail::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

.horse-detail::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ========== CARD STATUS ========== */
.card-status {
  margin-top: 16px;
  padding: 14px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.card-status .loading {
  color: var(--warning);
  font-weight: 600;
}

.card-status .success {
  color: var(--success);
  font-weight: 600;
}

.card-status .error {
  color: var(--danger);
  font-weight: 600;
}

/* ========== MARKDOWN PREVIEW ========== */
.markdown-preview {
  margin-top: 24px;
}

.markdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--line);
  flex-wrap: wrap;
  gap: 12px;
}

.markdown-header h3 {
  margin: 0;
  color: var(--accent);
  font-size: 20px;
}

.markdown-header > div {
  display: flex;
  gap: 10px;
}

.copy-btn,
.download-btn {
  background: var(--gradient-accent);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  display: inline-block;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 217, 255, 0.2);
}

.copy-btn:hover,
.download-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 217, 255, 0.4);
}

.markdown-content {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  overflow-x: auto;
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink);
  max-height: 600px;
  overflow-y: auto;
}

.markdown-content::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.markdown-content::-webkit-scrollbar-track {
  background: var(--bg-card);
  border-radius: 4px;
}

.markdown-content::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 4px;
}

.markdown-content::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.token-usage {
  font-size: 12px;
  color: var(--muted);
  opacity: 0.9;
}

.markdown-footer {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
  .sidebar {
    width: var(--sidebar-collapsed-width);
  }

  .sidebar-logo,
  .nav-item span,
  .theme-toggle span {
    opacity: 0;
    width: 0;
    overflow: hidden;
  }

  .page {
    margin-left: var(--sidebar-collapsed-width);
  }

  .cluster-panel {
    grid-template-columns: 1fr;
  }

  .hero {
    padding: 32px 28px;
  }

  .hero h1 {
    font-size: 32px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .page {
    margin-left: 0;
    padding: 24px 16px 60px;
  }

  .hero {
    flex-direction: column;
    align-items: flex-start;
    padding: 24px 20px;
  }

  .hero h1 {
    font-size: 28px;
  }

  .meta {
    width: 100%;
    justify-content: space-between;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .markdown-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .markdown-header > div {
    width: 100%;
  }

  .copy-btn,
  .download-btn {
    flex: 1;
  }

  #gradeDistributionChart {
    height: 180px;
    max-height: 200px;
  }
}

@media (max-width: 480px) {
  .stats {
    grid-template-columns: 1fr;
  }

  .section-title {
    font-size: 22px;
  }

  .card h2 {
    font-size: 18px;
  }

  #gradeDistributionChart {
    height: 160px;
    max-height: 180px;
  }
}

/* ========== CLUSTER VERTICAL LAYOUT ========== */
.cluster-vertical {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.cluster-vertical .card {
  width: 100%;
}

/* ========== METHODOLOGY SECTION ========== */
.methodology-section {
  margin-bottom: 24px;
  padding: 20px;
  background: var(--panel);
  border-radius: 12px;
  border-left: 4px solid var(--accent);
}

.methodology-section h4 {
  color: var(--accent);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.methodology-section h5 {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  margin: 16px 0 8px 0;
}

.methodology-section p {
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.7;
}

.methodology-section ul {
  margin-left: 20px;
  color: var(--muted);
  line-height: 1.8;
}

.methodology-section ul ul {
  margin-top: 8px;
  margin-bottom: 8px;
}

.methodology-section li {
  margin-bottom: 8px;
}

.methodology-section code {
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: 4px;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  color: var(--accent);
  border: 1px solid var(--line);
}

.methodology-section strong {
  color: var(--ink);
  font-weight: 600;
}

/* Theme Selector Buttons */
.theme-btn {
  transition: all 0.2s ease;
}

.theme-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
  border-color: #667eea !important;
}

.theme-btn.active {
  background: rgba(102, 126, 234, 0.2) !important;
  border-color: #667eea !important;
}

.theme-btn:active {
  transform: translateY(0);
}
