@layer components {
/* Control Panel - Premium Designer Style */
.control-panel {
  /* background: var(--panel-card-bg); */
  background:
    linear-gradient(
      90deg,
      transparent 0%,
      rgba(255, 255, 255, 0.35) 25%,
      var(--accent-secondary) 50%,
      rgba(255, 255, 255, 0.35) 75%,
      transparent 100%
    )
      top center / 200% 5px no-repeat,
    var(--surface-glass-strong);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--accent-border-medium);
  border-radius: 24px;
  padding: 0;
  margin-bottom: 28px;
  margin-top: 100px;
  background-repeat: no-repeat, no-repeat;
  background-position: -120% 0, center;
  background-size: 200% 5px, auto;
  animation:
    fadeIn var(--motion-fadeIn-delayed-0-2s),
    shimmerLineBg var(--motion-shimmerLine);
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.4),
    0 0 0 1px var(--accent-glow-soft) inset;
  overflow: visible;
  position: relative;
  z-index: 50;
  transition: all 0.5s var(--ease-smooth);
}

.control-panel::before {
  content: none;
}

.control-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(
      140% 140% at 20% 55%,
      var(--accent-glow-soft) 0%,
      transparent 65%
    ),
    radial-gradient(
      160% 150% at 85% 20%,
      var(--accent-glow-medium) 0%,
      transparent 70%
    );
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
  transition: opacity 0.6s var(--ease-smooth), background 0.6s var(--ease-smooth);
}

.control-panel > * {
  position: relative;
  z-index: 1;
}

.control-panel:hover {
  box-shadow:
    0 14px 48px rgba(0, 0, 0, 0.45),
    0 0 0 1px var(--accent-glow-medium) inset;
}

/* Fallback for browsers without backdrop-filter support */
@supports not (backdrop-filter: blur(8px)) {
  .control-panel {
    background: rgba(15, 23, 42, 0.9);
  }
}

.control-panel-header {
  padding: 24px 32px;
  background: rgba(15, 23, 42, 0.3);
  border-bottom: 1px solid var(--accent-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  position: relative;
  z-index: 1;
  transition: all 0.5s var(--ease-smooth);
}

.control-panel-title {
  font-size: 0.95rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-max);
  background: var(--text-gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0;
}

.control-panel-title::before {
  content: "⚙️";
  font-size: 1.3rem;
  -webkit-text-fill-color: initial;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: var(--letter-spacing-wide);
  color: #6ee7b7;
  padding: 12px 22px;
  background: rgba(16, 185, 129, 0.12);
  backdrop-filter: blur(12px);
  border-radius: 999px;
  border: 1px solid rgba(16, 185, 129, 0.25);
  transition: all 0.4s var(--ease-smooth);
  white-space: nowrap;
}

.status-dot {
  width: 10px;
  height: 10px;
  background: #10b981;
  border-radius: 50%;
  animation: statusPulse var(--motion-statusPulse) !important;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
  flex-shrink: 0;
}

.status-text {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Fetching state */
.status-indicator.fetching {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.25);
}

.status-indicator.fetching .status-dot {
  background: #fbbf24;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.6);
  animation: fetchingPulse var(--motion-fetchingPulse) !important;
}

/* Paused state */
.status-indicator.paused {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.25);
}

.status-indicator.paused .status-dot {
  background: #f59e0b;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
  animation: none !important;
}

.control-panel-body {
  padding: 28px 32px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  transition: all 0.6s var(--ease-standard);
  position: relative;
  overflow: visible;
}

.control-section {
  display: grid;
  gap: 16px;
  transition: all 0.6s var(--ease-standard);
}

.control-section:not(.mode-section):not(.api-key-section):not(.sliders) {
  padding: 22px 24px;
  border-radius: 20px;
  border: 1px solid var(--accent-border-subtle);
  background: var(--surface-glass-soft);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: visible;
  transition:
    transform 0.4s var(--ease-smooth),
    box-shadow 0.4s var(--ease-smooth),
    border-color 0.4s var(--ease-smooth),
    background 0.4s var(--ease-smooth);
}

.control-section:not(.mode-section):not(.sliders):not(.api-key-section):hover {
  border-color: var(--accent-glow-soft);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  background: var(--surface-glass-elevated);
  transform: translateY(-3px);
}

.mode-section {
  grid-template-columns: 1fr;
  transition: transform 0.4s var(--ease-smooth);
  overflow: visible;
  position: relative;
  z-index: 5;
}

.mode-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 26px;
  border-radius: 20px;
  border: 1px solid var(--accent-border-subtle);
  background: var(--surface-glass-soft);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  animation: panelCardLift var(--motion-panelCardLift);
  position: relative;
  overflow: visible;
  z-index: 5;
  transition: all 0.4s var(--ease-smooth);
}

.mode-card:hover {
  border-color: var(--accent-glow-soft);
  box-shadow:
    0 10px 26px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  transform: translateY(-3px);
}

.control-section.mode-section:hover .mode-card {
  border-color: var(--accent-glow-soft);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.32),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  background: var(--surface-glass-elevated);
  transform: translateY(-3px);
}

.mode-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
}

.mode-title-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.mode-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-extra-wide);
  background: var(--text-gradient-triple);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 800;
}

.mode-caption {
  font-size: 0.9rem;
  color: rgba(203, 213, 225, 0.9);
  font-weight: 600;
}

.info-badge {
  position: relative;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s var(--ease-standard);
  opacity: 1;
  box-shadow:
    0 3px 10px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  z-index: 2;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 14px;
  background-image: url("../assets/icons/Info.svg");
}

.info-badge svg.info-icon {
  width: 14px;
  height: 14px;
  display: block;
  stroke: currentColor;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.35));
  pointer-events: none;
}

.info-badge:hover,
.info-badge:focus-visible {
  border-color: var(--accent-glow-soft);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.08));
  color: #fff;
  outline: none;
  opacity: 1;
  box-shadow:
    0 5px 14px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.mode-card:hover .info-badge,
.mode-card:focus-within .info-badge {
  opacity: 1;
}

.info-badge .info-tooltip {
  position: absolute;
  left: 50%;
  top: 130%;
  transform: translateX(-50%);
  width: 260px;
  background: var(--surface-glass-elevated);
  border: 1px solid var(--accent-border-subtle);
  border-radius: 12px;
  padding: 12px 14px;
  color: #e5e7eb;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.45;
  box-shadow:
    0 14px 30px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease-standard), transform 0.2s var(--ease-standard);
  transform-origin: top center;
  z-index: 9000;
  background: rgba(10, 12, 20, 0.98);
}

.info-badge:hover .info-tooltip,
.info-badge:focus-visible .info-tooltip {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.control-section.filters-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  align-items: end;
  padding: 22px 24px;
  border: 1px solid var(--accent-border-subtle);
  background: var(--surface-glass-muted);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  border-radius: 20px;
  position: relative;
  overflow: visible;
  z-index: 200;
}

.control-section.sliders {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  max-height: 500px;
  opacity: 1;
  overflow: visible;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  transition:
    max-height 0.6s var(--ease-standard),
    opacity 0.5s var(--ease-standard),
    margin 0.6s var(--ease-standard),
    padding 0.6s var(--ease-standard);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.control-section.filters-row .control-group {
  height: 100%;
}

.control-section.filters-row .control-group:first-child {
  grid-column: span 2;
}

.control-section.filters-row .control-group .search-input,
.control-section.filters-row .control-group .custom-select {
  width: 100%;
}

.control-section.filters-row .control-group .custom-select,
.control-section.filters-row .control-group .search-input {
  margin-top: 2px;
}

.custom-select {
  position: relative;
  width: 100%;
  z-index: 30;
}

.custom-select.open {
  z-index: 100000;
}

.select-native {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.select-trigger {
  width: 100%;
  padding: 15px 50px 15px 20px;
  background: var(--surface-input-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--accent-border-medium);
  border-radius: 16px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s var(--ease-smooth);
  text-align: left;
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 52px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.select-trigger::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  width: 14px;
  height: 14px;
  border-right: 2px solid rgba(228, 230, 235, 0.7);
  border-bottom: 2px solid rgba(228, 230, 235, 0.7);
  transform: translateY(-70%) rotate(45deg);
  transition:
    transform 0.3s ease,
    opacity 0.3s ease;
  opacity: 0.85;
}

.select-trigger:hover {
  border-color: var(--accent-glow-medium);
}

.custom-select.open .select-trigger,
.select-trigger:focus-visible {
  outline: none;
  border-color: var(--accent-border-strong);
  box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.1);
}

.custom-select.open .select-trigger::after {
  transform: translateY(-30%) rotate(225deg);
  opacity: 1;
}

.select-dropdown {
  position: absolute;
  left: 0;
  top: calc(100% + 10px);
  width: 100%;
  background: var(--panel-card-bg);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--accent-border-medium);
  border-radius: 16px;
  padding: 8px;
  box-shadow:
    0 10px 40px rgba(0, 0, 0, 0.4),
    0 0 0 1px var(--accent-border-subtle) inset;
  opacity: 0;
  transform: translateY(-10px) scale(0.95);
  transform-origin: top;
  pointer-events: none;
  max-height: 260px;
  overflow-y: auto;
  transition:
    opacity 0.2s ease,
    transform 0.3s var(--ease-smooth);
  z-index: 100001;
}

/* Ensure dropdown stays aligned within filters row */
.control-section.filters-row .select-dropdown {
  top: calc(100% + 10px);
  bottom: auto;
  transform: translateY(-10px) scale(0.95);
  transform-origin: top;
}

.custom-select.open .select-dropdown {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  animation: dropdownReveal var(--motion-dropdownReveal);
}

.select-dropdown::-webkit-scrollbar {
  width: 6px;
}

.select-dropdown::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 10px;
}

.select-dropdown::-webkit-scrollbar-thumb {
  background: var(--accent-glow-medium);
  border-radius: 10px;
  border: 1px solid transparent;
  background-clip: padding-box;
  transition: background 0.3s ease;
}

.select-dropdown::-webkit-scrollbar-thumb:hover {
  background: var(--accent-glow-strong);
  background-clip: padding-box;
}

.select-option {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  padding: 13px 16px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition:
    background 0.25s var(--ease-smooth),
    transform 0.2s ease,
    color 0.2s ease;
  gap: 12px;
  text-align: left;
  position: relative;
}

.select-option:hover,
.select-option:focus-visible {
  background: var(--accent-glow-soft);
  color: var(--accent-tertiary);
  outline: none;
}

.select-option.selected {
  background: var(--accent-glow-medium);
  color: var(--accent-tertiary);
}

.select-option.selected::after {
  content: "✓";
  font-size: 0.9rem;
  font-weight: 900;
  color: var(--accent-tertiary);
}

.control-label {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-extra-wide);
  background: var(--text-gradient-triple);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  padding-left: 4px;
}

.control-label .icon {
  font-size: 1.05rem;
  -webkit-text-fill-color: initial;
}

.search-input {
  width: 100%;
  padding: 15px 20px;
  background: var(--surface-input-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--accent-border-medium);
  border-radius: 16px;
  color: var(--text-primary);
  font-size: 0.92rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.3s var(--ease-smooth);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  min-height: 52px;
}

#api-key-input,
#api-key-display {
  letter-spacing: var(--letter-spacing-extra-wide);
  font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
}

.search-input:hover {
  border-color: var(--accent-glow-medium);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-border-strong);
  box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.1);
}

.search-input::placeholder {
  color: var(--text-secondary);
  font-weight: 400;
}

.viewing-box {
  cursor: default;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  gap: 10px;
  padding: 15px 20px;
  background: var(--surface-input-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--accent-border-medium);
  border-radius: 16px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  transition: all 0.4s var(--ease-smooth);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.viewing-box.filtered {
  background: var(--action-surface);
  border-color: var(--accent-glow-medium);
  color: #fed7aa;
}

.viewing-box .count {
  font-weight: 900;
  font-size: 1.2rem;
  background: var(--text-gradient-reverse);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.slider-control {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 24px;
  background: var(--surface-glass-soft);
  border: 1px solid var(--accent-border-subtle);
  border-radius: 20px;
  transition: all 0.4s var(--ease-smooth);
  box-shadow: none;
  position: relative;
  overflow: hidden;
}

.slider-control:hover {
  border-color: var(--accent-glow-soft);
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.24),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  background: var(--surface-glass-elevated);
  transform: translateY(-3px);
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.slider-label {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-soft-wide);
  background: var(--text-gradient-triple);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  align-items: center;
  gap: 6px;
}

.slider-value {
  font-size: 1.1rem;
  font-weight: 900;
  background: var(--text-gradient-reverse);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-family: "SF Mono", Monaco, monospace;
  min-width: 75px;
  text-align: right;
}

.slider-wrapper {
  position: relative;
  padding: 8px 0;
}

.slider-range {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 600;
  opacity: 0.6;
}

input[type="range"] {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: transparent;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  position: relative;
  --slider-progress: 0%;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -7px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 30% 30%,
    var(--accent-tertiary),
    var(--accent-secondary) 55%,
    var(--accent-primary)
  );
  cursor: grab;
  transition: all 0.3s var(--ease-smooth);
  box-shadow:
    0 0 20px var(--accent-glow-strong),
    0 4px 12px var(--accent-glow-medium),
    0 0 0 5px var(--accent-glow-soft),
    inset 0 -2px 4px rgba(0, 0, 0, 0.45);
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  position: relative;
  z-index: 2;
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  margin-top: -7px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 30% 30%,
    var(--accent-tertiary),
    var(--accent-secondary) 55%,
    var(--accent-primary)
  );
  cursor: grab;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  transition: all 0.3s var(--ease-smooth);
  box-shadow:
    0 0 20px var(--accent-glow-strong),
    0 4px 12px var(--accent-glow-medium),
    0 0 0 5px var(--accent-glow-soft),
    inset 0 -2px 4px rgba(0, 0, 0, 0.45);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.25);
  box-shadow:
    0 0 30px var(--accent-glow-strong),
    0 6px 20px var(--accent-glow-medium),
    0 0 0 8px var(--accent-glow-soft),
    inset 0 -2px 6px rgba(0, 0, 0, 0.55);
  background: radial-gradient(
    circle at 30% 30%,
    var(--accent-tertiary),
    var(--accent-secondary) 45%,
    var(--accent-primary)
  );
  border-color: rgba(255, 255, 255, 0.55);
}

input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.25);
  box-shadow:
    0 0 30px var(--accent-glow-strong),
    0 6px 20px var(--accent-glow-medium),
    0 0 0 8px var(--accent-glow-soft),
    inset 0 -2px 6px rgba(0, 0, 0, 0.55);
  background: radial-gradient(
    circle at 30% 30%,
    var(--accent-tertiary),
    var(--accent-secondary) 45%,
    var(--accent-primary)
  );
  border-color: rgba(255, 255, 255, 0.55);
}

input[type="range"]::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb:active {
  cursor: grabbing;
  transform: scale(1.1);
}

input[type="range"]::-webkit-slider-runnable-track {
  background:
    linear-gradient(90deg, var(--accent-glow-strong), var(--accent-glow-medium)) no-repeat,
    linear-gradient(90deg, rgba(17, 24, 39, 0.82), rgba(15, 23, 42, 0.96)) no-repeat;
  background-size: var(--slider-progress, 0%) 100%, 100% 100%;
  background-position: left center, left center;
  background-color: transparent;
  height: 9px;
  border-radius: 999px;
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.04);
  border: none;
  background-repeat: no-repeat;
}

input[type="range"]::-moz-range-track {
  background:
    linear-gradient(90deg, var(--accent-glow-strong), var(--accent-glow-medium)) no-repeat,
    linear-gradient(90deg, rgba(17, 24, 39, 0.82), rgba(15, 23, 42, 0.96)) no-repeat;
  background-size: var(--slider-progress, 0%) 100%, 100% 100%;
  background-position: left center, left center;
  background-color: transparent;
  background-repeat: no-repeat;
  height: 9px;
  border-radius: 999px;
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.04);
  border: none;
}

input[type="range"]::-moz-range-progress {
  background: transparent;
  border: none;
  box-shadow: none;
}

/* Responsive */
@media (max-width: 1024px) {
  .control-section.sliders {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .control-section.filters-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .control-panel-body {
    padding: 16px 18px;
  }

  .control-panel-header {
    padding: 14px 18px;
  }
}

/* Data feed toggle */
.mode-switch {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Pause fetch button */
.pause-fetch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--accent-border-medium);
  background: var(--surface-input-bg);
  cursor: pointer;
  transition: all 0.3s var(--ease-smooth);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}

.pause-fetch-btn:hover {
  border-color: var(--accent-border-strong);
  background: var(--surface-glass-elevated);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

.pause-fetch-btn .pause-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  position: relative;
  transition: all 0.3s ease;
}

/* Pause icon (two vertical bars) */
.pause-fetch-btn .pause-icon::before,
.pause-fetch-btn .pause-icon::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 18px;
  background: var(--accent-secondary);
  border-radius: 2px;
  transition: all 0.3s ease;
  opacity: 0.85;
}

.pause-fetch-btn .pause-icon::before {
  left: 0;
}

.pause-fetch-btn .pause-icon::after {
  right: 0;
}

.pause-fetch-btn:hover .pause-icon::before,
.pause-fetch-btn:hover .pause-icon::after {
  opacity: 1;
  background: var(--accent-tertiary);
}

/* Play icon (triangle) when paused */
.pause-fetch-btn.paused .pause-icon::before {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 9px 0 9px 16px;
  border-color: transparent transparent transparent var(--accent-secondary);
  background: transparent;
  border-radius: 0;
  left: 2px;
  opacity: 1;
}

.pause-fetch-btn.paused .pause-icon::after {
  display: none;
}

.pause-fetch-btn.paused:hover .pause-icon::before {
  border-color: transparent transparent transparent var(--accent-tertiary);
}

.mode-switch .switch {
  position: relative;
  display: inline-block;
  width: 58px;
  height: 28px;
}

.mode-switch .switch input {
  display: none;
}

.mode-switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--surface-input-bg);
  transition: all 0.35s var(--ease-smooth);
  border-radius: 999px;
  border: 1px solid var(--accent-border-medium);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.35);
}

.mode-switch .slider:hover {
  border-color: var(--accent-border-strong);
}

.mode-switch .slider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 22px;
  height: 22px;
  transform: translateY(-50%);
  background: var(--accent-gradient-secondary-primary);
  border-radius: 50%;
  transition: all 0.35s var(--ease-smooth);
  box-shadow:
    0 2px 6px var(--accent-glow-medium),
    0 0 0 4px rgba(255, 255, 255, 0.12);
}

.mode-switch .slider:hover::before {
  box-shadow:
    0 3px 8px var(--accent-glow-strong),
    0 0 0 4px rgba(255, 255, 255, 0.16);
}

.mode-switch input:checked + .slider {
  background: var(--surface-input-strong);
  border-color: var(--accent-border-strong);
  box-shadow:
    inset 0 0 0 1px var(--accent-glow-soft),
    inset 0 8px 20px rgba(0, 0, 0, 0.4);
}

.mode-switch input:checked + .slider:hover {
  border-color: var(--accent-glow-medium);
}

.mode-switch input:checked + .slider::before {
  left: calc(100% - 25px);
  background: var(--accent-gradient-tertiary-secondary);
  box-shadow:
    0 2px 6px var(--accent-glow-medium),
    0 0 0 4px rgba(255, 255, 255, 0.12);
}

.mode-switch input:checked + .slider:hover::before {
  box-shadow:
    0 3px 8px var(--accent-glow-strong),
    0 0 0 4px rgba(255, 255, 255, 0.16);
}

#mode-toggle-label {
  display: inline-block;
  min-width: 120px;
  text-align: left;
  white-space: nowrap;
  font-size: 0.88rem;
  color: var(--text-primary);
  transition: color 0.3s ease;
}

/* API key management */
.real-only {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  transition:
    max-height 0.6s var(--ease-standard),
    opacity 0.5s var(--ease-standard),
    margin 0.6s var(--ease-standard),
    padding 0.6s var(--ease-standard);
}

.api-key-section {
  grid-template-columns: 1fr;
  transition: transform 0.4s var(--ease-smooth);
  overflow: visible;
}

.api-settings {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid var(--accent-border-subtle);
  background: var(--surface-glass-soft);
  isolation: isolate;
  transition:
    border-color 0.4s var(--ease-smooth),
    box-shadow 0.4s var(--ease-smooth),
    background 0.4s var(--ease-smooth),
    transform 0.4s var(--ease-smooth);
  box-shadow:
    0 4px 8px -2px rgba(0, 0, 0, 0.2),
    0 2px 4px -2px rgba(0, 0, 0, 0.12);
}

.api-settings:hover {
  border-color: var(--accent-glow-soft);
  box-shadow:
    0 12px 20px -6px rgba(0, 0, 0, 0.35),
    0 4px 8px -4px rgba(0, 0, 0, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  background: linear-gradient(135deg, rgba(31, 41, 55, 0.95) 0%, rgba(20, 26, 36, 0.95) 100%);
  transform: translateY(-3px);
  z-index: 10;
}

.api-settings-label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px;
  cursor: pointer;
  list-style: none;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: var(--letter-spacing-extra-wide);
  background: var(--text-gradient-triple);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-transform: uppercase;
  user-select: none;
  position: relative;
  z-index: 1;
  transition: opacity 0.3s ease;
  min-height: 52px;
}

.api-settings summary::-webkit-details-marker {
  display: none;
}

.api-settings-label .icon {
  -webkit-text-fill-color: initial;
}

.api-settings-label::before {
  content: "";
  width: 12px;
  height: 12px;
  border-right: 2px solid var(--accent-secondary);
  border-bottom: 2px solid var(--accent-secondary);
  border-radius: 1px;
  transform: rotate(-45deg);
  transition:
    transform 0.35s var(--ease-standard),
    opacity 0.3s ease,
    border-color 0.3s ease;
  opacity: 0.85;
}

.api-settings-label::after {
  content: "";
  flex-grow: 1;
  height: 1px;
  margin-left: 12px;
  background: linear-gradient(90deg, var(--accent-glow-soft), transparent);
  opacity: 0.4;
  transition: opacity 0.3s ease;
}

.api-settings-label:hover::after {
  opacity: 0.6;
}

.api-settings[open] {
  border-color: var(--accent-border-medium);
  box-shadow:
    0 4px 8px -2px rgba(0, 0, 0, 0.2),
    0 2px 4px -2px rgba(0, 0, 0, 0.12);
}

.api-settings[open] .api-settings-label::before {
  transform: rotate(45deg);
  opacity: 1;
}

.api-settings[open] .api-settings-label::after {
  opacity: 0.65;
}

.api-settings-content {
  display: grid;
  gap: 24px;
  padding: 0 24px;
  padding-top: 16px;
  padding-bottom: 24px;
  animation: accordionReveal 0.45s var(--ease-smooth);
  transform-origin: top;
  overflow: hidden;
}

.api-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  align-items: start;
}

.api-field-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.api-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(148, 163, 184, 0.85);
  letter-spacing: var(--letter-spacing-midwide);
  text-transform: uppercase;
  padding-left: 4px;
}

.api-field {
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  padding-left: 20px;
  border-radius: 16px;
  border: 1px solid var(--accent-border-medium);
  background: var(--surface-input-bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition:
    border-color 0.3s var(--ease-smooth),
    box-shadow 0.3s var(--ease-smooth);
  position: relative;
  z-index: 1;
  min-height: 52px;
  overflow: hidden;
  isolation: isolate;
}

.api-field:focus-within {
  border-color: var(--accent-border-strong);
  box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.1);
}

.api-field .api-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.92rem;
  font-family: inherit;
  letter-spacing: var(--letter-spacing-slight);
  padding: 15px 20px 15px 0;
  align-self: center;
}

.api-field .api-input::placeholder {
  color: rgba(148, 163, 184, 0.68);
}

.api-field .api-input:focus {
  outline: none;
}

.api-field-actions {
  display: flex;
  flex-shrink: 0;
}

.api-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 0 20px;
  margin: 0;
  border-radius: 0;
  border: none;
  border-left: 1px solid rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease;
  background: color-mix(in srgb, var(--accent-secondary) 6%, transparent);
  color: color-mix(in srgb, var(--accent-tertiary) 85%, transparent);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  font-family: inherit;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  text-transform: none;
  white-space: nowrap;
  vertical-align: middle;
  flex-shrink: 0;
  align-self: stretch;
  box-sizing: border-box;
}

.api-action-btn:hover {
  background: color-mix(in srgb, var(--accent-secondary) 12%, transparent);
  color: var(--accent-tertiary);
}

.api-action-btn:active {
  background: color-mix(in srgb, var(--accent-secondary) 18%, transparent);
  color: var(--accent-tertiary);
}

.api-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: color-mix(in srgb, var(--accent-secondary) 6%, transparent);
}

.api-save-btn {
  min-width: 90px;
}

.api-copy-btn,
.api-visibility-btn {
  min-width: 70px;
}

.api-field:has(.api-input.invalid) {
  border-color: rgba(239, 68, 68, 0.75);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.45);
  animation: invalidPulse var(--motion-invalidPulse);
}

.api-field:has(.api-input.invalid) .api-input {
  color: #fecaca;
}

.api-info-text {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.6;
  color: rgba(191, 219, 254, 0.8);
}

.api-info-text a {
  color: #fed7aa;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s ease;
}

.api-info-text a:hover {
  color: #fef3c7;
}

#api-key-display[readonly] {
  cursor: default;
}

.last-api {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(31, 41, 55, 0.95);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: var(--letter-spacing-compact);
  backdrop-filter: blur(15px);
}

.fetching-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #f59e0b;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
  animation: pulse-orange var(--motion-pulse);
}

.fetching-indicator.complete {
  background-color: #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
  animation: pulse-green var(--motion-pulse);
}

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fb923c;
  border-radius: 50%;
  animation: spin var(--motion-spin);
}

.cp-fade-in {
  animation: cpFade var(--motion-cpFade);
}

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

  .api-field {
    flex-direction: column;
    align-items: stretch;
  }

  .api-action-btn,
  .api-field-actions,
  .api-field-actions .api-action-btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .control-panel-title {
    font-size: 0.75rem;
    letter-spacing: var(--letter-spacing-wide);
  }

  .search-input,
  .select-trigger {
    padding-right: 36px;
  }

  .slider-control {
    padding: 12px;
  }

  .control-label {
    font-size: 0.7rem;
  }
}

/* Accessibility: Consistent focus-visible for control panel elements */
.select-trigger:focus-visible,
.api-action-btn:focus-visible,
.slider-control:focus-visible {
  outline: none;
  box-shadow: var(--panel-focus-ring);
  border-color: var(--accent-border-strong);
}
}

@keyframes shimmerLine {
  0% {
    opacity: 0.6;
    background-position: -100% 0;
  }

  50% {
    opacity: 1;
    background-position: 0% 0;
  }

  100% {
    opacity: 0.6;
    background-position: 100% 0;
  }
}

@keyframes shimmerLineBg {
  0% {
    background-position: -120% 0, center;
  }

  50% {
    background-position: 0% 0, center;
  }

  100% {
    background-position: 120% 0, center;
  }
}
