/* ============================================================
   SIGNAL TUNER & OSCILLOSCOPE DIALOG · 深空调谐台
   ============================================================ */

.signal-tuner-dialog {
  width: min(740px, calc(100vw - 28px));
  max-height: 92vh;
  margin: auto;
  padding: 0;
  background: var(--panel, #0b0f17);
  border: 1px solid var(--line-strong, rgba(160, 210, 255, 0.22));
  color: var(--ink, #e6edf3);
  clip-path: var(--notch, polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px)));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85), 0 0 40px rgba(120, 255, 170, 0.12);
  overflow: hidden;
  cursor: default;
  user-select: none;
}

.signal-tuner-dialog:not([open]) {
  display: none;
}

.tuner-shell {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px 26px 26px;
  gap: 14px;
  overscroll-behavior: contain;
  cursor: default;
}

/* Header */
.tuner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line, rgba(255, 255, 255, 0.08));
  padding-bottom: 12px;
  cursor: default;
}

.tuner-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tuner-beacon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #39d353;
  box-shadow: 0 0 10px #39d353;
  animation: tuner-pulse 2s infinite ease-in-out;
}

@keyframes tuner-pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

.tuner-tag {
  font: 600 var(--fs-micro)/1 var(--font-mono, monospace);
  letter-spacing: 0.2em;
  color: var(--signal-text, #86e1a4);
  text-transform: uppercase;
}

.tuner-title {
  margin: 0;
  font: 600 18px/1.3 var(--font-serif, serif);
  letter-spacing: 0.05em;
  color: var(--ink, #fff);
}

.tuner-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tuner-sound-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line, rgba(255, 255, 255, 0.12));
  color: var(--ink-dim, #99aab5);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tuner-sound-toggle:hover {
  border-color: var(--signal-text, #86e1a4);
  color: var(--signal-text, #86e1a4);
  background: rgba(134, 225, 164, 0.1);
}

.tuner-sound-toggle.is-active {
  color: var(--signal-text, #86e1a4);
  border-color: var(--signal-text, #86e1a4);
}

.tuner-sound-toggle svg,
.tuner-close svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.tuner-close {
  cursor: pointer;
}

/* CRT Oscilloscope Screen */
.tuner-screen-frame {
  position: relative;
  width: 100%;
  height: 190px;
  background: #030806;
  border: 2px solid #1a3324;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.9), 0 0 16px rgba(57, 211, 83, 0.15);
  cursor: crosshair;
}

.tuner-crt-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
              radial-gradient(circle at center, transparent 65%, rgba(0, 0, 0, 0.6) 100%);
  background-size: 100% 4px, 100% 100%;
  z-index: 2;
  opacity: 0.85;
}

.tuner-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.tuner-hud-readout {
  position: absolute;
  inset: 12px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  z-index: 3;
  font-family: var(--font-mono, monospace);
  cursor: default;
}

.tuner-freq-large {
  font-size: 26px;
  font-weight: 700;
  color: #39d353;
  text-shadow: 0 0 10px rgba(57, 211, 83, 0.8);
  letter-spacing: 0.06em;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.tuner-freq-large small {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.75;
}

.tuner-hud-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.tuner-snr-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #7ee787;
  text-shadow: 0 0 6px rgba(126, 231, 135, 0.5);
}

.tuner-snr-meter {
  width: 80px;
  height: 8px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid #1a3324;
  border-radius: 2px;
  overflow: hidden;
  padding: 1px;
  display: flex;
}

.tuner-snr-meter i {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #238636, #39d353, #7ee787);
  box-shadow: 0 0 8px #39d353;
  transition: width 0.08s ease;
}

.tuner-lock-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--ink-dim, #8b949e);
  transition: color 0.2s ease;
}

.tuner-led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #484f58;
  transition: all 0.2s ease;
}

.tuner-lock-indicator.is-near .tuner-led {
  background: #d29922;
  box-shadow: 0 0 8px #d29922;
}

.tuner-lock-indicator.is-near {
  color: #e3b341;
}

.tuner-lock-indicator.is-locked .tuner-led {
  background: #39d353;
  box-shadow: 0 0 12px #39d353;
}

.tuner-lock-indicator.is-locked {
  color: #39d353;
}

/* Slider Controls */
.tuner-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line, rgba(255, 255, 255, 0.06));
  padding: 14px 18px;
  border-radius: 4px;
  cursor: default;
}

.tuner-slider-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.tuner-step-btn {
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-strong, rgba(255, 255, 255, 0.15));
  color: var(--ink, #fff);
  padding: 6px 9px;
  font: 600 11px/1 var(--font-mono, monospace);
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tuner-step-btn:hover {
  background: var(--signal-text, #86e1a4);
  color: #0b0f17;
  border-color: var(--signal-text, #86e1a4);
}

.tuner-step-btn:active {
  transform: scale(0.95);
}

.tuner-range-box {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#tunerFreqSlider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: #151b23;
  border: 1px solid var(--line-strong, rgba(255, 255, 255, 0.15));
  border-radius: 4px;
  outline: none;
  cursor: ew-resize;
}

#tunerFreqSlider:focus-visible {
  outline: 2px solid var(--signal-text);
  outline-offset: 4px;
}

#tunerFreqSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #39d353;
  border: 2px solid #ffffff;
  box-shadow: 0 0 10px rgba(57, 211, 83, 0.85);
  cursor: ew-resize;
  transition: transform 0.1s ease;
}

#tunerFreqSlider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

#tunerFreqSlider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #39d353;
  border: 2px solid #ffffff;
  box-shadow: 0 0 10px rgba(57, 211, 83, 0.85);
  cursor: ew-resize;
}

.tuner-ticks {
  display: flex;
  justify-content: space-between;
  font: 500 var(--fs-micro)/1 var(--font-mono, monospace);
  color: var(--ink-faint, #6e7681);
  pointer-events: none;
  margin-top: 2px;
}

/* Quick Jump Frequency Presets */
.tuner-presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.tuner-presets-label {
  font: 600 var(--fs-micro)/1 var(--font-mono, monospace);
  letter-spacing: 0.15em;
  color: var(--ink-dim, #8b949e);
  margin-right: 4px;
}

.tuner-preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04) !important;
  border: 1px solid var(--line-strong, rgba(255, 255, 255, 0.15)) !important;
  padding: 6px 12px;
  border-radius: 3px;
  color: var(--ink, #c9d1d9) !important;
  font: 500 11px/1.2 var(--font-mono, monospace);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tuner-preset-chip:hover {
  background: rgba(134, 225, 164, 0.1) !important;
  border-color: var(--signal-text, #86e1a4) !important;
  color: var(--signal-text, #86e1a4) !important;
  transform: translateY(-1px);
}

.tuner-preset-chip.is-locked-in {
  background: rgba(57, 211, 83, 0.15) !important;
  border-color: #39d353 !important;
  color: #39d353 !important;
  box-shadow: 0 0 10px rgba(57, 211, 83, 0.25);
}

.tuner-preset-chip i {
  font-style: normal;
  font-size: 13px;
}

.tuner-preset-chip b {
  font-weight: 600;
}

.tuner-preset-chip .preset-status {
  font-size: var(--fs-micro);
  opacity: 0.75;
}

/* Signal Output Drawer */
.tuner-output-drawer {
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  border: 1px dashed var(--line-strong, rgba(255, 255, 255, 0.15));
  border-radius: 4px;
  padding: 14px 18px;
  cursor: default;
}

.tuner-empty-signal {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-dim, #8b949e);
  font: 400 12px/1.5 var(--font-sans, sans-serif);
}

.tuner-empty-signal p {
  margin: 0;
}

.tuner-signal-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: tuner-card-in 0.3s ease-out;
}

@keyframes tuner-card-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.tuner-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tuner-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 600 15px/1.3 var(--font-serif, serif);
  color: var(--signal-text, #86e1a4);
}

.tuner-card-badge {
  font: 600 var(--fs-micro)/1 var(--font-mono, monospace);
  padding: 3px 8px;
  background: rgba(57, 211, 83, 0.15);
  border: 1px solid #39d353;
  color: #39d353;
  border-radius: 2px;
}

.tuner-card-body {
  margin: 0;
  font: 400 12.5px/1.6 var(--font-sans, sans-serif);
  color: var(--ink, #e6edf3);
}

.tuner-card-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--line, rgba(255, 255, 255, 0.08));
}

.tuner-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #39d353;
  color: #05060b;
  font: 600 12px/1 var(--font-sans, sans-serif);
  border: 0;
  border-radius: 3px;
  cursor: pointer;
  box-shadow: 0 0 16px rgba(57, 211, 83, 0.4);
  transition: all 0.2s ease;
}

.tuner-action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 24px rgba(57, 211, 83, 0.6);
  background: #4ae966;
}

.tuner-action-note {
  font: 400 11px/1.4 var(--font-mono, monospace);
  color: var(--ink-dim, #8b949e);
}

/* Global Special Effects */
.tuner-global-bubble {
  position: fixed;
  bottom: -40px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.8), rgba(0, 210, 255, 0.3) 60%, rgba(0, 140, 255, 0.5) 100%);
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.6);
  pointer-events: none;
  z-index: 99999;
  animation: bubble-float linear forwards;
}

@keyframes bubble-float {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  10% { opacity: 0.85; }
  90% { opacity: 0.85; }
  100% { transform: translateY(-110vh) scale(1.3); opacity: 0; }
}

.tuner-global-feather {
  position: fixed;
  top: -40px;
  font-size: 24px;
  pointer-events: none;
  z-index: 99999;
  animation: feather-fall linear forwards;
}

@keyframes feather-fall {
  0% { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  10% { opacity: 0.9; }
  90% { opacity: 0.9; }
  100% { transform: translate(var(--fx, 80px), 110vh) rotate(360deg); opacity: 0; }
}

.cosmic-beacon-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  pointer-events: none;
  overflow: hidden;
  animation: beacon-fade 3.5s forwards ease-out;
}

@keyframes beacon-fade {
  0% { opacity: 0; }
  10% { opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

.cosmic-beacon-beam {
  position: absolute;
  top: 50%;
  left: -20%;
  width: 140%;
  height: 6px;
  background: linear-gradient(90deg, transparent 0%, #39d353 20%, #ffffff 50%, #68a8ff 80%, transparent 100%);
  box-shadow: 0 0 40px #39d353, 0 0 80px #68a8ff, 0 0 120px #ffffff;
  transform: translateY(-50%) rotate(-18deg);
  animation: beam-sweep 1.6s forwards cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes beam-sweep {
  0% { transform: translateY(-50%) rotate(-18deg) scaleX(0.1); opacity: 0; }
  30% { transform: translateY(-50%) rotate(-18deg) scaleX(1); opacity: 1; height: 16px; }
  100% { transform: translateY(-50%) rotate(-18deg) scaleX(1.2); opacity: 0; height: 1px; }
}

.cosmic-star-burst {
  position: absolute;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 12px #39d353, 0 0 20px #ffffff;
  animation: star-burst-anim 2.5s forwards ease-out;
}

@keyframes star-burst-anim {
  0% { transform: translate(0, 0) scale(0.2); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(1.5); opacity: 0; }
}

/* Nebula Mode Smooth Transition Wave & Ambient Background */
.nebula-transition-ripple {
  position: fixed;
  inset: 0;
  z-index: 99998;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(138, 43, 226, 0.45), rgba(0, 210, 255, 0.3) 45%, transparent 75%);
  animation: nebula-ripple-anim 1.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes nebula-ripple-anim {
  0% { transform: scale(0.5); opacity: 0; filter: blur(8px); }
  25% { transform: scale(1); opacity: 0.9; filter: blur(0px); }
  100% { transform: scale(1.35); opacity: 0; filter: blur(16px); }
}

.ambient {
  transition: background 1.2s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

body.series-nebula-mode .ambient {
  background:
    radial-gradient(60% 50% at 20% 15%, rgba(138, 43, 226, 0.18), transparent 70%),
    radial-gradient(55% 45% at 85% 25%, rgba(0, 210, 255, 0.16), transparent 70%),
    radial-gradient(70% 50% at 50% 80%, rgba(255, 20, 147, 0.12), transparent 75%),
    radial-gradient(40% 35% at 75% 70%, rgba(57, 211, 83, 0.10), transparent 60%) !important;
}

html[data-theme="light"] body.series-nebula-mode .ambient {
  background:
    radial-gradient(60% 50% at 20% 15%, rgba(185, 160, 250, 0.22), transparent 70%),
    radial-gradient(55% 45% at 85% 25%, rgba(130, 215, 255, 0.20), transparent 70%),
    radial-gradient(70% 50% at 50% 80%, rgba(255, 185, 205, 0.18), transparent 75%),
    radial-gradient(40% 35% at 75% 70%, rgba(160, 235, 160, 0.15), transparent 60%) !important;
}

body.series-nebula-mode .site-header,
body.series-nebula-mode .archive-header,
body.series-nebula-mode .lab-header {
  background: rgba(5, 6, 12, 0.55) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

html[data-theme="light"] body.series-nebula-mode .site-header,
html[data-theme="light"] body.series-nebula-mode .archive-header,
html[data-theme="light"] body.series-nebula-mode .lab-header {
  background: rgba(246, 242, 233, 0.72) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px) !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06) !important;
}

@media (max-width: 640px) {
  .tuner-shell {
    padding: 16px;
    gap: 12px;
  }
  .tuner-screen-frame {
    height: 160px;
  }
  .tuner-freq-large {
    font-size: 20px;
  }
  .tuner-step-btn {
    padding: 4px 6px;
    font-size: var(--fs-micro);
  }
}
