/* Tweaks panel — instant parametric controls over the live spec
   (ui/tweaks-panel.js). Anchored top-right inside #viewport, glass style to
   match the stage dock. */

#ec-tweaks-panel {
  position: absolute;
  top: 64px;
  right: 16px;
  width: 268px;
  max-height: calc(100% - 96px);
  display: flex;
  flex-direction: column;
  z-index: 30;
  font-family: var(--font-ui);
}
/* The unconditional display:flex above would otherwise override the `hidden`
   attribute's UA display:none — without this, the close button is a no-op. */
#ec-tweaks-panel[hidden] {
  display: none;
}

.ec-tweaks-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--line);
}
.ec-tweaks-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}
.ec-tweaks-free {
  font-size: 10.5px;
  color: var(--ok, #7fc98b);
  font-weight: 600;
  flex: 1;
}
.ec-tweaks-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}
.ec-tweaks-close:hover { color: var(--text); }

.ec-tweaks-body {
  overflow-y: auto;
  padding: 6px 14px 10px;
}
.ec-tweaks-empty {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.ec-tweaks-group h3 {
  margin: 10px 0 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.ec-tweak {
  margin-bottom: 10px;
}
.ec-tweak-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.ec-tweak-hint {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
}

/* Segmented options */
.ec-tweak-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.ec-tweak-opt {
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-ui);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(240, 228, 210, 0.12);
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}
.ec-tweak-opt:hover:not(:disabled) { color: var(--text); border-color: rgba(240, 228, 210, 0.28); }
.ec-tweak-opt.on {
  color: #1c1304;
  background: #ec9a3c;
  border-color: #ec9a3c;
}
.ec-tweak-opt:disabled { opacity: 0.4; cursor: not-allowed; }

/* Stepper */
.ec-tweak-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
}
.ec-tweak-step {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid rgba(240, 228, 210, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.ec-tweak-step:hover:not(:disabled) { border-color: rgba(240, 228, 210, 0.28); }
.ec-tweak-step:disabled { opacity: 0.4; cursor: not-allowed; }
.ec-tweak-num {
  width: 58px;
  padding: 4px 6px;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(240, 228, 210, 0.12);
  border-radius: 7px;
  text-align: center;
}
.ec-tweak-unit { font-size: 11px; color: var(--muted); }

/* Toggle */
.ec-tweak-toggle {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  border: 1px solid rgba(240, 228, 210, 0.18);
  background: rgba(255, 255, 255, 0.06);
  position: relative;
  cursor: pointer;
  transition: background 0.14s ease;
  padding: 0;
}
.ec-tweak-toggle .ec-tweak-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.14s ease, background 0.14s ease;
}
.ec-tweak-toggle.on { background: #ec9a3c; border-color: #ec9a3c; }
.ec-tweak-toggle.on .ec-tweak-knob { transform: translateX(16px); background: #1c1304; }
.ec-tweak-toggle:disabled { opacity: 0.4; cursor: not-allowed; }

.ec-tweak-error {
  margin-top: 4px;
  font-size: 10.5px;
  color: #e08a7a;
  line-height: 1.35;
}

/* Deep-link flash from an "Assumed for now" pill */
.ec-tweak-flash {
  animation: ecTweakFlash 1.4s ease;
  border-radius: 8px;
}
@keyframes ecTweakFlash {
  0%, 60% { box-shadow: 0 0 0 2px rgba(236, 154, 60, 0.55); background: rgba(236, 154, 60, 0.08); }
  100% { box-shadow: none; background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .ec-tweak-flash { animation: none; box-shadow: 0 0 0 2px rgba(236, 154, 60, 0.55); }
}

.ec-tweaks-foot {
  padding: 8px 14px 10px;
  border-top: 1px solid var(--line);
  font-size: 10px;
  color: var(--muted);
}

/* Mobile: the rail is a horizontal strip and chat pins to the bottom 44vh —
   float the panel above the chat, full-width-ish, own scroll. */
@media (max-width: 900px) {
  #ec-tweaks-panel {
    position: fixed;
    top: auto;
    right: 8px;
    left: 8px;
    bottom: calc(44vh + 8px);
    width: auto;
    max-height: 42vh;
  }
  /* Chat collapsed: its mobile grid row shrinks to auto (ui/chat-panel.css),
     so the 44vh offset would strand the panel mid-screen. */
  #app.chat-collapsed #ec-tweaks-panel {
    bottom: 64px;
    max-height: 60vh;
  }
}

/* Touch targets — match the app's 44px HIG convention (see chat-panel.css's
   pointer:coarse block). The toggle keeps its slim visual; a pseudo-element
   expands its hit zone instead of inflating the track. */
@media (pointer: coarse) {
  .ec-tweak-step {
    min-width: 44px;
    min-height: 44px;
  }
  .ec-tweak-opt {
    min-height: 44px;
  }
  .ec-tweaks-close {
    min-width: 44px;
    min-height: 44px;
  }
  .ec-tweak-toggle {
    position: relative;
  }
  .ec-tweak-toggle::after {
    content: '';
    position: absolute;
    inset: -14px;
  }
}
