.panel {
  pointer-events: auto;
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease;
}

.header-panel {
  padding: 14px;
  border-left: 4px solid var(--c-radius);
}

.header-panel h2 {
  margin: 0;
}

.controls-panel {
  padding: 12px;
  overflow-y: auto;
}

.floating-toggle, .floating-config {
  position: fixed;
  z-index: 3000;
  display: none; /* Hidden by default on desktop mostly handled by media queries */
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: var(--bg-panel);
  color: var(--text-main);
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  transition: background 0.25s ease, color 0.25s ease, transform 0.2s ease;
}

.floating-toggle {
  top: 16px;
  left: 16px;
}

.floating-config {
  bottom: 16px;
  right: 16px;
  display: inline-flex; /* Always visible unless configured otherwise */
}

.floating-toggle:hover, .floating-config:hover {
  transform: translateY(-1px);
}

.floating-toggle i, .floating-config i {
  color: var(--c-radius);
}

.floating-toggle .toggle-label {
  font-weight: 700;
  letter-spacing: 0.5px;
}

.floating-toggle.is-closed {
  background: var(--c-radius);
  color: #0f172a;
  border-color: transparent;
}

.floating-toggle.is-closed i {
  color: #0f172a;
}

.action-btn {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  cursor: pointer;
  font-weight: 700;
  transition: background 0.2s ease, transform 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
}

.action-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.08);
}

.action-btn.primary {
  background: var(--c-radius);
  color: #0f172a;
  border-color: transparent;
}

.file-btn {
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
}

.file-btn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.search-box {
  margin-top: 15px;
  position: relative;
}

.search-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-light);
  padding: 8px 35px 8px 12px;
  border-radius: 4px;
  color: white;
  font-family: inherit;
}

.search-input:focus {
  outline: 1px solid var(--c-radius);
}

.search-icon {
  position: absolute;
  right: 10px;
  top: 10px;
  color: var(--text-mute);
  font-size: 0.8rem;
}

.section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 700;
  margin-bottom: 10px;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.section-title:hover {
    color: var(--text-main);
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.panel-content {
    transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
    max-height: 2000px;
    opacity: 1;
    overflow: hidden;
}

.panel-content.collapsed {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
}

.section-title.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

/* Simulation Buttons */
.sim-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #bfdbfe;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.75rem;
  transition: all 0.2s;
}

.sim-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  opacity: 1;
  border-left: 4px solid var(--c-radius);
}

.sim-btn i {
  color: var(--c-radius);
}

/* Filter Grid */
.filter-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.filter-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  color: var(--text-mute);
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.75rem;
  transition: all 0.2s;
}

.filter-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  opacity: 1;
  box-shadow: none;
  border-left: 4px solid var(--c-radius);
}

.filter-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-color: rgba(255, 255, 255, 0.3);
}

.dep-btn {
  background: rgba(34, 197, 94, 0.1);
  border-color: rgba(34, 197, 94, 0.3);
  color: #bbf7d0;
}

.dep-btn.active {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.45);
  color: #dcfce7;
}

.dep-btn:not(.active) {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fecdd3;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

/* Header Elements */
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.logo-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--c-radius);
}

.logo-subtitle {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-mute);
}

.accent {
  color: var(--c-radius);
}

.created-by, .credit-link {
  color: var(--text-mute);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.75rem;
  white-space: nowrap;
}

.created-by:hover, .credit-link:hover {
  color: var(--c-radius);
}

.mini-legend {
  margin-top: 8px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.7rem;
  color: var(--text-mute);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.legend-line {
  display: inline-block;
  width: 20px;
  height: 0;
  border-top: 3px solid var(--text-main);
}

.legend-line.dashed {
  border-top-style: dashed;
  opacity: 0.7;
}

@media (max-width: 1100px) {
  .floating-toggle {
    display: flex !important;
    visibility: visible;
    opacity: 1;
    top: auto;
    bottom: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    left: 16px;
    padding: 10px 14px;
    width: auto;
    height: auto;
    gap: 8px;
    justify-content: center;
    z-index: 4000;
  }

  .floating-config {
    bottom: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    right: 12px;
  }
  
  .panel {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  }

  .controls-panel {
    max-height: 65vh;
  }
}

@media (max-width: 720px) {
  .header-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .logo-title {
    font-size: 1rem;
  }

  .logo-subtitle {
    font-size: 0.8rem;
  }

  .credit-link {
    white-space: normal; /* Allow wrapping on mobile */
  }

  .mini-legend {
    font-size: 0.65rem;
    gap: 8px;
  }

  .legend-item {
    white-space: normal; /* Allow wrapping on mobile */
    font-size: 0.65rem;
  }

  .controls-panel {
    max-height: none;
    padding: 10px;
    overflow: visible;
  }

  .section-title {
    font-size: 0.8rem;
  }

  .sim-btn {
    font-size: 0.7rem;
    padding: 6px 9px;
  }

  .filter-btn {
    font-size: 0.7rem;
    padding: 6px 9px;
  }
}
