body {
  font-family:
    "Source Sans Pro", "Lucida Grande", "Lucida Sans Unicode", "Geneva",
    "Verdana", sans-serif;
  margin: 0;
  padding: 0;
  background: #ffffff;
  color: #2e3338;
  line-height: 1.6;
}

.header {
  background: linear-gradient(135deg, #3776ab 0%, #4584bb 100%);
  color: white;
  padding: 32px 0;
  box-shadow: 0 2px 10px rgba(55, 118, 171, 0.2);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 20px;
}

.python-logo {
  width: auto;
  height: 72px;
  margin-bottom: 12px; /* tighter spacing to avoid visual gap */
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.python-logo img {
  height: 72px;
  width: auto;
  display: block; /* avoid baseline alignment issues */
  vertical-align: middle;
  /* subtle shadow that does not affect layout */
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.1));
}

.header-text h1 {
  margin: 0;
  font-size: 2.5em;
  font-weight: 600;
  color: white;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-text .subtitle {
  margin: 8px 0 0 0;
  font-size: 1.1em;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 300;
}

.header-search {
  width: 100%;
  max-width: 500px;
}

.header-search #search-input {
  width: 100%;
  padding: 12px 20px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 25px;
  font-size: 16px;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.95);
  color: #2e3338;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
}

.header-search #search-input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

.header-search #search-input::placeholder {
  color: #6c757d;
}

.stats-section {
  background: #ffffff;
  padding: 24px 0;
  border-bottom: 1px solid #e9ecef;
}

.stats-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.stat-card {
  background: #ffffff;
  border: 1px solid #e9ecef;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: all 0.2s ease;
  min-height: 120px;
}

.stat-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.stat-icon {
  font-size: 32px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #3776ab 0%, #4584bb 100%);
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(55, 118, 171, 0.3);
}

.stat-content {
  flex: 1;
}

.stat-label {
  font-size: 14px;
  color: #5a6c7d;
  font-weight: 500;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 16px;
  font-weight: 700;
  color: #2e3338;
  line-height: 1.3;
  margin-bottom: 4px;
  word-break: break-word;
  overflow-wrap: break-word;
}

.stat-file {
  font-size: 12px;
  color: #8b949e;
  font-weight: 400;
  margin-bottom: 2px;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  word-break: break-word;
  overflow-wrap: break-word;
}

.stat-detail {
  font-size: 12px;
  color: #5a6c7d;
  font-weight: 400;
  line-height: 1.4;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  word-break: break-word;
  overflow-wrap: break-word;
}

.controls {
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  padding: 20px 0;
  text-align: center;
}

.controls-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  text-align: center;
}


.controls button {
  background: #3776ab;
  color: white;
  border: none;
  padding: 12px 24px;
  margin: 0 8px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(55, 118, 171, 0.2);
}

.controls button:hover {
  background: #2d5aa0;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(55, 118, 171, 0.3);
}

.controls button.secondary {
  background: #ffd43b;
  color: #2e3338;
}

.controls button.secondary:hover {
  background: #ffcd02;
}

.thread-filter-wrapper {
  display: none;
  align-items: center;
  margin-left: 16px;
  background: white;
  border-radius: 6px;
  padding: 4px 8px 4px 12px;
  border: 2px solid #3776ab;
  transition: all 0.2s ease;
}

.thread-filter-wrapper:hover {
  border-color: #2d5aa0;
  box-shadow: 0 2px 6px rgba(55, 118, 171, 0.2);
}

.thread-filter-label {
  color: #3776ab;
  font-size: 14px;
  font-weight: 600;
  margin-right: 8px;
  display: flex;
  align-items: center;
}

.thread-filter-select {
  background: transparent;
  color: #2e3338;
  border: none;
  padding: 4px 24px 4px 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-width: 120px;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233776ab' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 4px center;
  background-size: 16px;
}

.thread-filter-select:focus {
  outline: none;
}

.thread-filter-select:hover {
  color: #3776ab;
}

.thread-filter-select option {
  padding: 8px;
  background: white;
  color: #2e3338;
  font-weight: normal;
}

#chart {
  width: 100%;
  height: calc(100vh - 160px);
  overflow: hidden;
  background: #ffffff;
  padding: 0 40px;
}

.d3-flame-graph rect {
  /* Prefer selector specificity instead of !important */
  stroke: rgba(55, 118, 171, 0.3);
  stroke-width: 1px;
  cursor: pointer;
  transition: all 0.1s ease;
}

.d3-flame-graph rect:hover {
  stroke: #3776ab;
  stroke-width: 2px;
  filter: brightness(1.05);
}

.d3-flame-graph text {
  /* Ensure labels use our font without !important */
  font-family: "Source Sans Pro", sans-serif;
  font-size: 12px;
  font-weight: 500;
  fill: #2e3338;
  pointer-events: none;
}

.info-panel {
  position: fixed;
  bottom: 24px;
  left: 84px; /* Leave space for the button */
  background: white;
  padding: 24px;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  font-size: 14px;
  max-width: 280px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: none;
}

.info-panel h3 {
  margin: 0 0 16px 0;
  color: #3776ab;
  font-weight: 600;
  font-size: 16px;
  border-bottom: 2px solid #ffd43b;
  padding-bottom: 8px;
}

.info-panel p {
  margin: 12px 0;
  color: #5a6c7d;
  line-height: 1.5;
}

.info-panel strong {
  color: #3776ab;
}

#show-info-btn {
  position: fixed;
  bottom: 32px;
  left: 32px;
  z-index: 1100;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #3776ab;
  color: white;
  border: none;
  font-size: 24px;
  box-shadow: 0 2px 8px rgba(55, 118, 171, 0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

#show-info-btn:hover {
  background: #2d5aa0;
}

#close-info-btn {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #3776ab;
}

@media (max-width: 600px) {
  .python-logo { height: 48px; }
  .python-logo img { height: 48px; }
  #show-info-btn {
    left: 8px;
    bottom: 8px;
  }
  .info-panel {
    left: 60px; /* Still leave space for button */
    bottom: 8px;
    max-width: 90vw;
  }
}

.legend-panel {
  position: fixed;
  top: 24px;
  left: 24px;
  background: white;
  padding: 24px;
  border-radius: 8px;
  border: 1px solid #e9ecef;
  font-size: 14px;
  max-width: 320px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  display: none;
  z-index: 1001;
}

.legend-panel h3 {
  margin: 0 0 20px 0;
  color: #3776ab;
  font-weight: 600;
  font-size: 18px;
  text-align: center;
  border-bottom: 2px solid #ffd43b;
  padding-bottom: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  margin: 12px 0;
  padding: 10px;
  border-radius: 6px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
}

.legend-color {
  width: 28px;
  height: 18px;
  border-radius: 4px;
  margin-right: 16px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.legend-label {
  color: #2e3338;
  font-weight: 600;
  flex: 1;
}

.legend-description {
  color: #5a6c7d;
  font-size: 12px;
  margin-top: 2px;
  font-weight: 400;
}

.chart-container {
  background: #ffffff;
  margin: 0;
  padding: 12px 0;
}

/* Tooltip overflow fixes */
.python-tooltip {
  max-width: 500px !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
  box-sizing: border-box !important;
}

/* Responsive tooltip adjustments */
@media (max-width: 768px) {
  .python-tooltip {
    max-width: calc(100vw - 40px) !important;
    max-height: calc(100vh - 80px) !important;
    overflow-y: auto !important;
  }
}

@media (max-width: 480px) {
  .python-tooltip {
    max-width: calc(100vw - 20px) !important;
    font-size: 12px !important;
  }
}
