* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: #0a0a0f; color: #e0e0e0; font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 14px; }
.container { max-width: 900px; margin: 0 auto; padding: 20px; }
h1 { color: #00ff88; font-size: 24px; margin-bottom: 5px; }
.subtitle { color: #666; margin-bottom: 20px; font-size: 12px; }

.panel { background: #12121a; border: 1px solid #222; border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.panel h2 { color: #00aaff; font-size: 15px; margin-bottom: 12px; }
.panel-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.panel-header h2 { margin-bottom: 0; }
.refresh-btn { background: none; border: 1px solid #333; color: #888; font-size: 16px; cursor: pointer; padding: 2px 6px; border-radius: 4px; line-height: 1; }
.refresh-btn:hover { color: #00aaff; border-color: #00aaff; }

.audio-grid {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0 16px;
  align-items: center;
}
.audio-prompt { color: #555; font-size: 13px; padding: 8px 0; }
.audio-status { display: flex; align-items: center; gap: 6px; }
.audio-controls { display: flex; gap: 6px; }
.audio-track { display: flex; flex-direction: column; gap: 4px; justify-self: end; }
.audio-track select { min-width: 150px; }
.audio-volume { display: flex; flex-direction: column; gap: 4px; }
.audio-sensitivity { display: flex; flex-direction: column; gap: 4px; }

.row { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }

button {
  background: #1a1a2e; color: #00ff88; border: 1px solid #00ff88;
  padding: 8px 16px; border-radius: 4px; cursor: pointer;
  font-family: inherit; font-size: 13px; transition: all 0.15s;
}
button:hover { background: #00ff88; color: #0a0a0f; }
button.ready { background: #00ff88; color: #0a0a0f; font-weight: bold; }
button.ready:hover { background: #00cc66; }
button.danger { border-color: #ff4444; color: #ff4444; }
button.danger:hover { background: #ff4444; color: #0a0a0f; }
button.active { background: #00ff88; color: #0a0a0f; font-weight: bold; }
button:disabled { opacity: 0.3; cursor: default; }

select {
  background: #1a1a2e; color: #e0e0e0; border: 1px solid #333;
  padding: 8px 12px; border-radius: 4px; font-family: inherit; font-size: 13px;
}

/* Custom range slider */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; background: #1a1a2e; border: 1px solid #333; border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: #00aaff; border: 1px solid #00aaff;
  margin-top: -6px; box-shadow: 0 0 6px #00aaff44;
}
input[type="range"]::-moz-range-track {
  height: 4px; background: #1a1a2e; border: 1px solid #333; border-radius: 2px;
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%;
  background: #00aaff; border: 1px solid #00aaff;
  box-shadow: 0 0 6px #00aaff44;
}

.dot { width: 10px; height: 10px; aspect-ratio: 1; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot-on { background: #00ff88; box-shadow: 0 0 8px #00ff88; }
.dot-sync { background: #ffaa00; box-shadow: 0 0 8px #ffaa00; }
.dot-off { background: #333; }

.now-playing {
  background: #081a0e; border: 1px solid #00ff88; border-radius: 8px;
  padding: 16px; margin-bottom: 16px;
}
.np-header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.np-question { font-size: 16px; color: #00ff88; flex: 1; }
.np-link { color: #00aaff; text-decoration: none; font-size: 14px; padding: 4px 10px; border: 1px solid #00aaff44; border-radius: 4px; white-space: nowrap; transition: all 0.15s; }
.np-link:hover { background: #00aaff22; border-color: #00aaff; color: #fff; }
.np-mood { font-size: 22px; font-weight: bold; margin: 8px 0; }
.np-mood.bullish { color: #00ff88; }
.np-mood.bearish { color: #ff6644; }

/* Signal strips — visual state of the six data signals + price/tone */
.signal-strips { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.signal-strip {
  display: grid;
  grid-template-columns: 86px 1fr 96px;
  align-items: center;
  gap: 10px;
  padding: 3px 4px;
  border-radius: 3px;
}
.signal-strip.no-window { grid-template-columns: 86px 1fr; }
.signal-label {
  font-size: 10px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
}
.signal-bar {
  position: relative;
  height: 10px;
  background: #0a0a12;
  border: 1px solid #1a1a2e;
  border-radius: 2px;
  overflow: visible;
}
.signal-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: #00aaff;
  width: 0%;
  transition: width 0.5s ease;
  border-radius: 1px 0 0 1px;
}
/* Signed bar: zero line at 50%, fill grows left or right */
.signal-bar-signed::before {
  content: '';
  position: absolute;
  left: 50%; top: -2px; bottom: -2px;
  width: 1px;
  background: #333;
}
.signal-fill-signed {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 0%;
  background: #00ff88;
  transition: left 0.5s ease, width 0.5s ease, background 0.2s ease;
}
.signal-fill-signed.negative { background: #ff6644; }
/* Raw-value tick — ghost marker showing where the bar would land at neutral sensitivity.
   The gap between tick and bar end is the power-curve effect made visible. */
.signal-raw-tick {
  position: absolute;
  top: -2px; bottom: -2px;
  width: 1px;
  background: #ff9900;
  opacity: 0.55;
  transition: left 0.5s ease;
  pointer-events: none;
}
/* Window indicator — target window length + filled portion from buffer */
.signal-window {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}
.signal-window-bar {
  position: relative;
  flex: 1;
  max-width: 48px;
  height: 4px;
  background: transparent;
  border: 1px solid #333;
  border-radius: 1px;
}
.signal-window-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: #ff9900;
  width: 0%;
  transition: width 1.0s linear;
}
.signal-window-label {
  font-size: 9px;
  color: #888;
  font-variant-numeric: tabular-nums;
  min-width: 38px;
  text-align: right;
  letter-spacing: 0.3px;
}
/* Price strip: needle marker on a tone-tinted gradient track */
.signal-price-track {
  position: relative;
  height: 10px;
  background: #0a0a12;
  border: 1px solid #1a1a2e;
  border-radius: 2px;
  overflow: visible;
}
.signal-price-needle {
  position: absolute;
  top: -3px; bottom: -3px;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 4px rgba(255,255,255,0.5);
  transition: left 0.5s ease;
}
.signal-price-label {
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.signal-price-label.bullish { color: #00ff88; }
.signal-price-label.bearish { color: #ff6644; }
/* Event flash — brief amber illumination */
@keyframes signal-flash {
  0%   { background: rgba(255,153,0,0.30); }
  100% { background: transparent; }
}
.signal-strip.flash { animation: signal-flash 0.7s ease-out; }
/* Group divider */
.signal-divider { border-top: 1px solid #1a1a2e; margin: 2px 2px; }

/* ── Price bar + voice rack + warmup banner ──────────────── */
.np-signals { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.np-price {
  display: grid;
  grid-template-columns: 60px 1fr 46px;
  align-items: center;
  gap: 10px;
  padding: 2px 4px;
}
.np-price-label {
  font-size: 10px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.np-price-track {
  position: relative;
  height: 10px;
  background: #0a0a12;
  border: 1px solid #1a1a2e;
  border-radius: 2px;
}
.np-price-needle {
  position: absolute;
  top: -3px; bottom: -3px;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 4px rgba(255,255,255,0.5);
  transition: left 0.5s ease;
}
.np-price-value {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: #aaa;
}
.np-price-value.bullish { color: #00ff88; }
.np-price-value.bearish { color: #ff6644; }
.np-section {
  border-top: 1px solid #1a1a2e;
  padding-top: 10px;
  margin-top: 2px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.np-section-heading {
  font-size: 10px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 0 4px;
}
.np-warmup {
  font-size: 11px;
  color: #ff9900;
  background: rgba(255,153,0,0.08);
  border: 1px solid rgba(255,153,0,0.25);
  border-radius: 3px;
  padding: 6px 10px;
  letter-spacing: 0.3px;
  font-variant-numeric: tabular-nums;
  transition: color 0.4s, background 0.4s, border-color 0.4s;
}
.np-warmup.tuned {
  color: #00ff88;
  background: rgba(0,255,136,0.06);
  border-color: rgba(0,255,136,0.25);
}
.voice-rack { display: flex; flex-direction: column; gap: 4px; }
.voice-rack-empty { color: #555; font-size: 12px; padding: 6px 4px; }
.voice-row-np {
  display: grid;
  grid-template-columns: 110px 1fr 38px;
  align-items: center;
  gap: 10px;
  padding: 2px 4px;
  border-radius: 3px;
  transition: opacity 0.2s;
}
.voice-row-np.voice-row-muted { opacity: 0.3; }
.voice-row-label {
  font-size: 11px;
  color: #cccccc;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.voice-row-meter {
  position: relative;
  height: 8px;
  background: #0a0a12;
  border: 1px solid #1a1a2e;
  border-radius: 2px;
  overflow: hidden;
}
.voice-row-meter-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, #00aaff 0%, #00ff88 70%, #ffcc00 100%);
  width: 0%;
  transition: width 0.4s ease;
}
.voice-row-state {
  font-size: 10px;
  color: #666;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Horizontal stepped delta gauge — used for melody-style voices that
   represent a signed magnitude with discrete bands (silence / 3-note /
   5-note / 8-note up or down). Driven by the server-decided
   `price_delta_band` so the lit cell always matches what the audio
   does, at every sensitivity setting. Each cell self-labels with
   arrow + note count (▼8 ▼5 ▼3 · ▲3 ▲5 ▲8) so the band structure is
   readable without knowing the colour code. Active cell fills brightly
   with bold text. When the per-tick gate is closed (price_moving=false)
   the whole gauge fades. */
.delta-gauge {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  height: 26px;
  padding: 2px;
  background: #0a0a12;
  border: 1px solid #1a1a2e;
  border-radius: 3px;
  transition: opacity 0.2s;
}
.delta-gauge.delta-gauge-flat { opacity: 0.4; }
.delta-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
  background: #15151f;
  border-radius: 2px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.delta-cell-down { color: #5a2530; }
.delta-cell-zero { color: #444; font-size: 14px; background: #10101a; }
.delta-cell-up   { color: #1f5a3a; }
/* Active cell — much brighter than baseline so the current band reads
   instantly. Text inverts to maximize contrast. */
.delta-cell-down.active {
  background: #ff4466;
  color: #fff;
  box-shadow: 0 0 8px rgba(255, 68, 102, 0.7);
}
.delta-cell-up.active {
  background: #00ff88;
  color: #000;
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.7);
}
.delta-cell-zero.active {
  background: #444;
  color: #ccc;
}
.voice-row-delta .voice-row-state { color: #aaa; }

.url-row { display: flex; gap: 8px; margin-bottom: 12px; }
.url-row input {
  flex: 1; background: #1a1a2e; color: #e0e0e0; border: 1px solid #333;
  padding: 8px 12px; border-radius: 4px; font-family: inherit; font-size: 13px;
}
.url-row input::placeholder { color: #444; }
.url-row input:focus { outline: none; border-color: #00aaff; }
.url-status { font-size: 11px; color: #555; margin-bottom: 8px; min-height: 16px; }

.browse-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.browse-tab {
  background: #1a1a2e; color: #888; border: 1px solid #222; border-radius: 4px;
  padding: 5px 12px; cursor: pointer; font-family: inherit; font-size: 12px; transition: all 0.15s;
}
.browse-tab:hover { border-color: #00aaff; color: #ccc; }
.browse-tab.active { background: #00aaff22; border-color: #00aaff; color: #00aaff; }
.browse-loading { color: #444; font-size: 12px; padding: 10px 0; }

.browse-card {
  background: #0d0d15; border: 1px solid #1a1a2e; border-radius: 6px;
  padding: 10px 14px; margin-bottom: 5px; display: flex; align-items: center; gap: 10px;
  transition: all 0.15s; cursor: pointer;
}
.browse-card:hover { border-color: #333; }
.browse-card.playing { border-color: #00ff88; background: #081a0e; }
.browse-body { flex: 1; min-width: 0; }
.browse-question { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #ccc; }
.browse-meta { font-size: 11px; color: #555; margin-top: 2px; }
.browse-price { color: #00aaff; font-size: 14px; font-weight: bold; min-width: 45px; text-align: right; }

.browse-play-btn {
  background: #00aaff22; color: #00aaff; border: 1px solid #00aaff44; border-radius: 4px;
  padding: 4px 14px; font-family: inherit; font-size: 11px; font-weight: bold; cursor: pointer;
  text-transform: uppercase; letter-spacing: 0.5px; transition: all 0.15s; white-space: nowrap;
}
.browse-play-btn:hover { background: #00aaff44; border-color: #00aaff; color: #fff; }
.browse-play-btn.is-playing {
  background: #00ff8822; color: #00ff88; border-color: #00ff8844; cursor: default;
}

.market-link { color: #00aaff; text-decoration: none; font-size: 16px; padding: 6px 10px; border: 1px solid #1a1a2e; border-radius: 4px; transition: all 0.15s; white-space: nowrap; }
.market-link:hover { color: #fff; background: #00aaff22; border-color: #00aaff; }

.nav-links { display: flex; gap: 12px; margin-bottom: 16px; }
.nav-links a { color: #00aaff; text-decoration: none; font-size: 12px; padding: 4px 10px; border: 1px solid #00aaff44; border-radius: 4px; }
.nav-links a:hover { background: #00aaff22; }
.nav-links a.active { background: #00aaff22; border-color: #00aaff; }
.donate-footer { text-align: center; margin-top: 24px; padding: 12px; color: #444; font-size: 11px; }
.donate-footer a { color: #00aaff; text-decoration: none; }
.donate-footer a:hover { text-decoration: underline; }

/* ── Mobile Responsive ── */
@media (max-width: 600px) {
  .container { padding: 12px; }
  h1 { font-size: 20px; }

  /* Nav: wrap links and allow scrolling gracefully */
  .nav-links { flex-wrap: wrap; gap: 8px; }

  /* Audio grid: stack vertically */
  .audio-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .audio-track { justify-self: stretch; }
  .audio-track select { width: 100%; }

  /* Volume/sensitivity sliders: full width */
  .audio-volume input[type="range"],
  .audio-sensitivity input[type="range"] {
    width: 100% !important;
    min-width: 0;
  }
  .audio-volume > div,
  .audio-sensitivity > div {
    width: 100%;
  }

  /* Signal strips: tighter columns on mobile */
  .signal-strip { grid-template-columns: 70px 1fr 78px; gap: 8px; }
  .signal-strip.no-window { grid-template-columns: 70px 1fr; }
  .voice-row-np { grid-template-columns: 90px 1fr 32px; gap: 8px; }
  .np-price { grid-template-columns: 48px 1fr 40px; gap: 8px; }
  .signal-window-bar { max-width: 36px; }
  .signal-window-label { min-width: 32px; font-size: 9px; }

  /* URL row: stack on very small screens */
  .url-row { flex-direction: column; }
  .url-row input { width: 100%; }
  .url-row button { width: 100%; }

  /* Now playing header */
  .np-header { flex-direction: column; gap: 6px; }
  .np-link { align-self: flex-start; }

  /* Browse cards: wrap to two rows — question on top, actions below */
  .browse-card { flex-wrap: wrap; }
  .browse-body { flex-basis: 100%; }
  .browse-question { white-space: normal; }
  .browse-price { margin-left: auto; }

  /* Buttons: ensure touch-friendly sizing */
  button { min-height: 40px; }
  select { min-height: 40px; }
}

#log {
  background: #08080c; border: 1px solid #1a1a2e; border-radius: 4px;
  padding: 10px; height: 100px; overflow-y: auto; font-size: 11px; color: #444; margin-top: 10px;
}
