/* ============================================================
   PULSE — the AI companion (toggleable from code via PULSE_ENABLED)
   A heartbeat-style waveform widget pinned to the bottom-right.
   ============================================================ */

#pulse-widget {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  width: 340px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 700ms cubic-bezier(.2,.7,.2,1), transform 700ms cubic-bezier(.2,.7,.2,1);
}
#pulse-widget.ready {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
#pulse-widget.collapsed { width: 64px; }
#pulse-widget.collapsed .pulse-card { padding: 0; aspect-ratio: 1; cursor: pointer; }
#pulse-widget.collapsed .pulse-body { display: none; }
#pulse-widget.collapsed .pulse-head .title,
#pulse-widget.collapsed .pulse-head .status,
#pulse-widget.collapsed .pulse-head .toggle { display: none; }
#pulse-widget.collapsed .pulse-head {
  width: 100%; height: 100%;
  padding: 0;
  border-bottom: 0;
  display: grid;
  place-items: center;
}
#pulse-widget.collapsed .pulse-head .glyph {
  grid-area: 1 / 1;
  pointer-events: none;
}
/* Expand button covers the entire collapsed card so a click anywhere opens it. */
#pulse-widget.collapsed .pulse-head .expand {
  display: flex;
  grid-area: 1 / 1;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  margin: 0;
  background: transparent;
  color: transparent; /* hide the + icon so only the dot reads */
  cursor: pointer;
  z-index: 2;
}
#pulse-widget.collapsed .pulse-card:hover .glyph {
  transform: scale(1.08);
  transition: transform var(--t-fast);
}

.pulse-card {
  background: linear-gradient(160deg, rgba(20,16,46,0.92), rgba(11,8,32,0.92));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow:
    var(--glow-violet),
    0 30px 80px -20px rgba(0,0,0,0.7);
  padding: 0;
  position: relative;
}
.pulse-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.pulse-head .glyph {
  width: 28px; height: 28px;
  border-radius: 50%;
  position: relative;
  background: radial-gradient(circle at center, var(--violet) 0%, var(--violet-3) 60%, transparent 100%);
  box-shadow: 0 0 14px rgba(167,139,250,0.6);
  flex-shrink: 0;
}
.pulse-head .glyph::after {
  content: "";
  position: absolute;
  inset: 8px;
  background: var(--mint);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--mint);
  animation: pulse-beat 1.2s ease-in-out infinite;
}
@keyframes pulse-beat {
  0%, 100% { transform: scale(1); opacity: 1; }
  20% { transform: scale(1.5); opacity: 0.7; }
  40% { transform: scale(1); opacity: 1; }
}
.pulse-head .title {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
  font-weight: 600;
}
.pulse-head .status {
  margin-left: auto;
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--mint);
  text-transform: uppercase;
}
.pulse-head .toggle, .pulse-head .expand {
  width: 22px; height: 22px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-dim);
  transition: color var(--t-fast), border-color var(--t-fast);
  margin-left: 6px;
  cursor: pointer;
}
.pulse-head .toggle:hover, .pulse-head .expand:hover {
  color: var(--mint);
  border-color: var(--mint);
}
.pulse-head .expand { display: none; width: 100%; height: 100%; border: 0; }
.pulse-body { padding: 14px; }
.pulse-trace {
  height: 50px;
  background: rgba(5,4,22,0.5);
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  overflow: hidden;
  position: relative;
  margin-bottom: 12px;
}
.pulse-trace svg {
  position: absolute;
  inset: 0;
  width: 220%;
  height: 100%;
  animation: trace-scroll 4s linear infinite;
}
.pulse-trace path {
  stroke: var(--mint);
  stroke-width: 1.5;
  fill: none;
  filter: drop-shadow(0 0 8px var(--mint-glow));
}
.pulse-message {
  font-family: var(--f-body);
  font-size: 13px;
  color: var(--ink-dim);
  line-height: 1.45;
  min-height: 2.6em;
  transition: opacity var(--t-fast);
}
.pulse-message strong { color: var(--violet); font-weight: 600; }
.pulse-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.pulse-actions button {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  background: rgba(167,139,250,0.04);
  transition: all var(--t-fast);
}
.pulse-actions button:hover {
  border-color: var(--mint);
  color: var(--mint);
}

@media (max-width: 640px) {
  #pulse-widget { display: none; }
}

/* ============================================================
   TWEAKS PANEL
   ============================================================ */
#tweaks-panel {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 70;
  width: 280px;
  background: linear-gradient(160deg, rgba(20,16,46,0.95), rgba(11,8,32,0.95));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--glow-violet), 0 30px 80px -20px rgba(0,0,0,0.7);
  display: none;
  font-family: var(--f-body);
}
#tweaks-panel.open { display: block; }
.tweaks-head {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.tweaks-head h4 {
  margin: 0;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
  font-weight: 600;
}
.tweaks-head .close {
  margin-left: auto;
  width: 22px; height: 22px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.tweaks-head .close:hover { color: var(--mint); border-color: var(--mint); }
.tweaks-body { padding: 14px 16px; }
.tweaks-section { margin-bottom: 18px; }
.tweaks-section:last-child { margin-bottom: 0; }
.tweaks-section .label {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 10px;
  display: block;
}
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--t-fast), border-color var(--t-fast);
  position: relative;
  overflow: hidden;
}
.swatch:hover { transform: scale(1.08); }
.swatch.active { border-color: var(--ink); box-shadow: 0 0 0 2px var(--mint); }
.swatch .a { position: absolute; inset: 0; }
.swatch .b { position: absolute; right: 0; bottom: 0; width: 60%; height: 60%; }
.tweaks-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
}
.tweaks-row .name {
  font-size: 13px;
  color: var(--ink);
  flex: 1;
}
.toggle-switch {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  position: relative;
  cursor: pointer;
  transition: background var(--t-fast);
}
.toggle-switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--ink-dim);
  transition: transform var(--t-fast), background var(--t-fast);
}
.toggle-switch.on { background: rgba(94,234,212,0.18); border-color: var(--mint); }
.toggle-switch.on::after { transform: translateX(16px); background: var(--mint); }

/* ---- Tile hover style segmented selector ---- */
.tile-style-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.tile-style-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--ink-dim);
  cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.tile-style-opt:hover { color: var(--ink); border-color: var(--line-strong); transform: translateY(-1px); }
.tile-style-opt.active {
  border-color: var(--mint);
  color: var(--mint);
  background: rgba(94,234,212,0.10);
  box-shadow: 0 0 0 1px var(--mint) inset;
}
.tile-style-opt .sw {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-sm);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
}
.tile-style-opt .sw.cinematic {
  background:
    radial-gradient(60% 80% at 35% 60%, rgba(94,234,212,0.55), transparent 60%),
    linear-gradient(135deg, #14102E, #0B0820);
}
.tile-style-opt .sw.holographic {
  background:
    linear-gradient(115deg,
      #14102E 30%,
      rgba(167,139,250,0.6) 48%,
      rgba(94,234,212,0.6) 50%,
      rgba(167,139,250,0.6) 52%,
      #14102E 70%);
}
.tile-style-opt .sw.terminal {
  background: #0B0820;
  position: relative;
}
.tile-style-opt .sw.terminal::after {
  content: "$_";
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--mint);
  letter-spacing: 0.05em;
}
.tile-style-opt .nm {
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---- Slider ---- */
.tweaks-row .value-out {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--mint);
  letter-spacing: 0.08em;
  padding: 2px 8px;
  background: rgba(94,234,212,0.10);
  border: 1px solid rgba(94,234,212,0.3);
  border-radius: 4px;
}
.tweak-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--surface-2);
  border-radius: 999px;
  outline: none;
  margin-top: 6px;
  cursor: pointer;
}
.tweak-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: linear-gradient(to right, var(--violet), var(--mint));
  border-radius: 999px;
}
.tweak-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--mint);
  border: 2px solid var(--void);
  box-shadow: 0 0 12px rgba(94,234,212,0.6);
  cursor: grab;
  margin-top: -6px;
}
.tweak-slider::-moz-range-track {
  height: 4px;
  background: linear-gradient(to right, var(--violet), var(--mint));
  border-radius: 999px;
}
.tweak-slider::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--mint);
  border: 2px solid var(--void);
  box-shadow: 0 0 12px rgba(94,234,212,0.6);
  cursor: grab;
}
