/* =============================================================================
 * Contextual Controls (DialKit Tweaker) — Styles
 * Tweakable live parameter panel for the Popsicle editor preview mode.
 * ============================================================================= */

/* ---------- Toggle Switch (shared for startup + sidebar) ---------- */
.ctx-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0 2px;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  opacity: 0;
  transform: translateY(6px);
  animation: ctxToggleFadeIn 0.35s ease forwards;
}
@keyframes ctxToggleFadeIn {
  to { opacity: 1; transform: translateY(0); }
}

.ctx-toggle-track {
  position: relative;
  width: 30px;
  height: 16px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  border: none;
  transition: background 0.2s ease;
  flex-shrink: 0;
}
.ctx-toggle-wrap.active .ctx-toggle-track {
  background: #4080ff;
}
.ctx-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.45);
  transition: left 0.2s cubic-bezier(0.22, 1, 0.36, 1),
              background 0.2s ease;
}
.ctx-toggle-wrap.active .ctx-toggle-thumb {
  left: 17px;
  background: #ffffff;
}
.ctx-toggle-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, rgba(255,255,255,0.4));
  /* letter-spacing: 0.02em; */
  transition: color 0.2s ease;
}
.ctx-toggle-wrap.active .ctx-toggle-label {
  color: #6ea8fe;
}
.ctx-toggle-wrap:hover .ctx-toggle-label {
  color: rgba(255,255,255,0.6);
}
.ctx-toggle-wrap.active:hover .ctx-toggle-label {
  color: #93bbfc;
}

/* Startup prompt toggle positioning */
#tab-panel-generate .ctx-toggle-wrap {
  justify-content: flex-start;
  margin-top: -4px;
}

/* Sidebar chat toggle positioning (above chat-input-wrapper, outside it) */
.chat-input-area > .ctx-toggle-wrap {
  /* padding: 0 4px 4px; */
  justify-content: flex-start;
  position: relative;
  /* top: 12px; */
}

#sidebar .chat-input-area {
  left: 4px;
  right: -10%;
  padding: 10px 0 1px;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: visible;
  --ctx-shell-bg: rgba(56,58,64,0.4);
  --ctx-shell-bg-active: rgba(54,57,64,0.5);
  --ctx-shell-input-bg: #0c0d14;
  border-radius: 10px;
  backdrop-filter: blur(18px) saturate(118%);
}
#sidebar .chat-input-area::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--ctx-shell-bg);
  box-shadow: 0 8px 28px rgba(0,0,0,0.28);
  pointer-events: none;
  z-index: 1;
  transition: background 0.35s ease,
              box-shadow 0.35s ease,
              opacity 0.35s ease,
              backdrop-filter 0.35s ease,
              -webkit-backdrop-filter 0.35s ease;
}
#sidebar .chat-input-area::after {
  content: '';
  position: absolute;
  inset: -14px -18px -10px;
  border-radius: 22px 22px 18px 18px;
  background: conic-gradient(
    from 0deg,
    rgba(255, 80, 80, 0.42),
    rgba(255, 196, 87, 0.38),
    rgba(101, 214, 161, 0.34),
    rgba(90, 166, 255, 0.36),
    rgba(175, 104, 255, 0.34),
    rgba(255, 108, 194, 0.36),
    rgba(255, 80, 80, 0.42)
  );
  filter: blur(40px) saturate(130%);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  animation: ctxShellRainbowDrift 10s linear infinite;
  transition: opacity 0.35s ease;
}
#sidebar .chat-input-area.ctx-shell-active::before {
  background: var(--ctx-shell-bg-active);
  box-shadow: 0 10px 34px rgba(0,0,0,0.34), inset 0 0 0 1px rgba(255,255,255,0.035);
  backdrop-filter: blur(18px) saturate(118%);
  -webkit-backdrop-filter: blur(18px) saturate(118%);
}
#sidebar .chat-input-area.ctx-shell-active::after {
  opacity: 0.22;
}
#sidebar .chat-input-area > .ctx-toggle-wrap,
#sidebar .chat-input-area > .chat-input-wrapper {
  position: relative;
  z-index: 2;
}
#sidebar .chat-input-area > .ctx-toggle-wrap {
  padding: 0 12px 8px;
  margin: 0;
}
#sidebar .chat-input-area > .sidebar-bottom-blur {
  z-index: 0;
}
#sidebar .chat-input-wrapper {
  width: auto;
  margin: 0 1px 1px;
  top: 0;
  border: none;
  border-radius: 10px;
  background: var(--ctx-shell-input-bg);
  box-shadow: none;
}
#sidebar .chat-input-wrapper:focus-within {
  border-color: transparent;
  box-shadow: 0 8px 22px rgba(0,0,0,0.35);
}

@keyframes ctxShellRainbowDrift {
  0% {
    transform: translate3d(-2%, 0, 0) rotate(0deg) scale(1.02);
  }
  50% {
    transform: translate3d(2%, 2%, 0) rotate(180deg) scale(1.05);
  }
  100% {
    transform: translate3d(-2%, 0, 0) rotate(360deg) scale(1.02);
  }
}

/* Hide startup toggle when in upload HTML tab or once editor is active */
#tab-panel-paste .ctx-toggle-wrap { display: none; }

/* ---------- Sidenav Button ---------- */
.annotate-cluster #btn-tweaker {
  transition: color 0.15s ease, opacity 0.15s ease;
}
.annotate-cluster #btn-tweaker.tweaker-visible {
  opacity: 1;
  max-height: 42px;
  pointer-events: auto;
  transform: translateX(0);
}
.annotate-cluster #btn-tweaker.tweaker-active {
  color: #4080ff !important;
}
body.preview-active .annotate-cluster #btn-tweaker.tweaker-active {
  color: #4080ff !important;
}

/* Initially hidden, slides in */
#btn-tweaker {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-4px);
  transition: max-height 0.35s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.3s ease,
              transform 0.3s ease,
              color 0.15s ease;
}

/* ---------- Tweaker Floating Panel ---------- */
.twk-panel-host {
  position: fixed;
  top: 0; left: 0;
  width: 0; height: 0;
  z-index: 2147483645;
  pointer-events: none;
}

.twk-panel {
  position: fixed;
  width: 300px;
  background: #0f1117;
  border: 1px solid #1e2030;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4), 0 0 0 1px rgba(30,32,48,0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'SF Mono','Cascadia Code','Fira Code','IBM Plex Mono',monospace;
  color: #858b98;
  pointer-events: auto;
  z-index: 2147483646;
  opacity: 0;
  transform: translateX(40px);
  transition: left 0.25s ease, right 0.25s ease, top 0.25s ease,
              transform 0.25s ease, height 0.25s ease, opacity 0.2s ease;
}
.twk-panel.twk-panel-open {
  opacity: 1;
  transform: translateX(0) !important;
}

/* Panel Header */
.twk-panel-hdr {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: #0c0d14;
  border-bottom: 1px solid #1e2030;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
  flex-shrink: 0;
  border-radius: 4px 4px 0 0;
}
.twk-panel-hdr:hover .twk-drag-handle { opacity: 1; }

.twk-drag-handle {
  font-size: 13px;
  color: #555a6a;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.15s;
  line-height: 1;
  letter-spacing: -1px;
  flex-shrink: 0;
}
.twk-drag-handle:active { cursor: grabbing; }

.twk-panel-title {
  flex: 1;
  font-size: 11px;
  font-weight: 600;
  color: #e1e3ea;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.twk-panel-title i {
  font-size: 10px;
  color: #4080ff;
}

.twk-panel-close {
  background: none;
  border: 1px solid #1e2030;
  color: #555a6a;
  cursor: pointer;
  padding: 3px 7px;
  display: flex;
  align-items: center;
  transition: all 0.12s;
  flex-shrink: 0;
  border-radius: 3px;
}
.twk-panel-close:hover {
  color: #e1e3ea;
  border-color: #2a2e40;
}

/* Panel Body */
.twk-panel-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 0;
  background:
    radial-gradient(circle at top right, rgba(64,128,255,0.08), transparent 34%),
    linear-gradient(180deg, rgba(12,13,20,0.98) 0%, rgba(10,12,18,0.96) 100%);
}
.twk-panel-body::-webkit-scrollbar { width: 5px; }
.twk-panel-body::-webkit-scrollbar-track { background: transparent; }
.twk-panel-body::-webkit-scrollbar-thumb { background: #1e2030; border-radius: 3px; }
.twk-panel-body::-webkit-scrollbar-thumb:hover { background: #2a2e40; }

/* Panel Footer */
.twk-panel-foot {
  padding: 6px 10px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-top: none;
  background: transparent;
}
.twk-panel-foot::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, #0c0d14 30%, transparent 100%);
  pointer-events: none;
  z-index: -1;
}
.twk-panel-foot .twk-status {
  font-size: 9.5px;
  font-weight: 500;
  color: #555a6a;
  letter-spacing: 0.02em;
}
.twk-panel-foot .twk-status.active {
  color: #4080ff;
}

/* Panel Resize Handle */
.twk-panel-resize-handle {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  cursor: ns-resize;
  z-index: 10;
  background: transparent;
}
.twk-panel-resize-handle:hover {
  background: rgba(64,128,255,0.15);
}

/* ---------- DialKit Theme Override (mounted inside .twk-panel-body) ---------- */
/* Match the app's dark, premium aesthetic */
.twk-panel-body .dialkit-root,
.twk-dialkit-mount .dialkit-root {
  --dial-surface: rgba(255,255,255,0.04);
  --dial-surface-hover: rgba(255,255,255,0.08);
  --dial-surface-active: rgba(64,128,255,0.12);
  --dial-surface-subtle: rgba(255,255,255,0.03);
  --dial-text-root: #e1e3ea;
  --dial-text-section: #858b98;
  --dial-text-label: rgba(255,255,255,0.55);
  --dial-text-focus: #e1e3ea;
  --dial-text-primary: #c8ccd6;
  --dial-text-secondary: #858b98;
  --dial-text-tertiary: #555a6a;
  --dial-border: rgba(255,255,255,0.06);
  --dial-border-hover: rgba(64,128,255,0.4);
  --dial-glass-bg: transparent;
  --dial-dropdown-bg: #13151e;
  --dial-radius: 4px;
  --dial-row-height: 30px;
  --dial-shadow: none;
  --dial-shadow-dropdown: 0 8px 24px rgba(0,0,0,0.6);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  font-size: 11px;
  -webkit-font-smoothing: antialiased;
}
/* Inline Tweaker controls mount into the parent document, so the host needs
   the core DialKit layout rules that would otherwise only exist inside the iframe. */
.twk-panel-body .dialkit-root,
.twk-panel-body .dialkit-root *,
.twk-panel-body .dialkit-root *::before,
.twk-panel-body .dialkit-root *::after {
  box-sizing: border-box;
}
.twk-panel-body .dialkit-stack,
.twk-panel-body .dialkit-folder {
  display: flex;
  flex-direction: column;
}
.twk-panel-body .dialkit-panel {
  position: static !important;
  z-index: auto;
  max-height: none;
}
.twk-panel-body .dialkit-panel-inner {
  width: 100% !important;
  height: auto;
  max-height: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 12px 12px 20px;
  background: transparent;
}
.twk-panel-body .dialkit-panel-inner[data-collapsed=true] {
  border-radius: 0;
}
.twk-panel-body .dialkit-bubble {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border-color: rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.04);
}
.twk-panel-body .dialkit-bubble svg {
  width: 13px;
  height: 13px;
}
/* Slider */
.twk-panel-body .dialkit-slider-wrap {
  position: relative;
  height: 36px;
  margin: 2px 0;
  flex: 0 0 auto;
}
.twk-panel-body .dialkit-slider {
  position: absolute;
  top: 20px;
  left: 0;
  right: 0;
  height: 16px;
  cursor: ew-resize;
  user-select: none;
  overflow: visible;
  touch-action: none;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(10,12,18,0.9);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
  width: 100%;
}
.twk-panel-body .dialkit-slider-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  pointer-events: none;
  transition: width 0.12s ease;
  border-radius: 6px;
  background-color: rgba(64,128,255,0.045);
  background-image: repeating-linear-gradient(
    -55deg,
    rgba(110,168,254,0.18) 0 1px,
    transparent 1px 4px
  );
}
.twk-panel-body .dialkit-slider[data-active=true] .dialkit-slider-fill {
  background-color: rgba(64,128,255,0.07);
  background-image: repeating-linear-gradient(
    -55deg,
    rgba(147,187,252,0.24) 0 1px,
    transparent 1px 3px
  );
}
.twk-panel-body .dialkit-slider-meta {
  position: absolute;
  top: -20px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}
.twk-panel-body .dialkit-slider-label {
  font-size: 12px;
  line-height: 12px;
  font-weight: 500;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}
.twk-panel-body .dialkit-slider-value {
  font-size: 11px;
  line-height: 12px;
  font-weight: 500;
  font-family: 'SF Mono','Cascadia Code','Fira Code',monospace;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 4px;
  background: transparent;
  color: #d7dbe5;
  text-align: right;
  pointer-events: auto;
}
.twk-panel-body .dialkit-slider-value[data-editable=true] {
  background: transparent;
  border-bottom-color: transparent;
  box-shadow: none;
}
.twk-panel-body .dialkit-slider-input {
  font-size: 10px;
  width: 6ch;
  font-family: 'SF Mono','Cascadia Code','Fira Code',monospace;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid rgba(64,128,255,0.45);
  background: transparent;
  color: #f2f5fb;
  z-index: 2;
  pointer-events: auto;
  text-align: right;
}
.twk-panel-body .dialkit-slider-handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: left 0.12s ease;
  width: 2px;
  height: 12px;
  background: #4080ff;
  border-radius: 2px;
}
/* Row */
.twk-panel-body .dialkit-row {
  min-height: calc(var(--dial-row-height) + 4px);
  padding: 6px 8px;
  /* border-radius: 6px; */
  /* border: 1px solid rgba(255,255,255,0.08); */
  /* background: rgba(10,12,18,0.84); */
  /* box-shadow: inset 0 1px 0 rgba(255,255,255,0.03); */
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}
.twk-panel-body .dialkit-row-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: #d3d8e2;
  min-width: 0;
  max-width: none;
  flex: 1 1 auto;
}
.twk-panel-body .dialkit-row:hover,
.twk-panel-body .dialkit-slider:hover,
.twk-panel-body .dialkit-button:hover,
.twk-panel-body .dialkit-select:hover {
  border-color: rgba(64,128,255,0.24);
}
.twk-panel-body .dialkit-row:focus-within,
.twk-panel-body .dialkit-slider:focus-within,
.twk-panel-body .dialkit-button:focus-visible,
.twk-panel-body .dialkit-select:focus-visible,
.twk-panel-body .dialkit-tbtn:focus-visible {
  outline: none;
  border-color: rgba(64,128,255,0.5);
  box-shadow: 0 0 0 1px rgba(64,128,255,0.22), inset 0 1px 0 rgba(255,255,255,0.04);
}
/* Folder */
.twk-panel-body .dialkit-folder-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.twk-panel-body .dialkit-folder-title-root {
  font-size: 12.5px;
  font-weight: 600;
}
.twk-panel-body .dialkit-folder:not(.dialkit-folder-root) {
  /* border: 1px solid rgba(255,255,255,0.08); */
  /* border-radius: 10px; */
  padding: 2px 8px;
  /* margin: 4px 0; */
  /* background: rgba(255,255,255,0.02); */
}
.twk-panel-body .dialkit-folder-root > .dialkit-folder-header {
  border-bottom-color: rgba(255,255,255,0.04);
}
.twk-panel-body .dialkit-folder-body {
  display: flex;
  flex-direction: column;
  /* gap: 6px; */
  /* padding: 4px 0 8px; */
  margin-top: 6px;
  overflow: hidden;
  transition: height 0.2s cubic-bezier(0.2, 0, 0, 1), opacity 0.2s ease;
}
.twk-panel-body .dialkit-folder[data-open=false] > .dialkit-folder-body {
  padding-top: 0;
  padding-bottom: 0;
  gap: 0;
}
/* Toolbar */
.twk-panel-body .dialkit-toolbar {
  min-height: var(--dial-row-height);
  margin-bottom: 10px;
  position: sticky;
  top: 0;
  z-index: 6;
  padding-bottom: 8px;
  background: linear-gradient(180deg, rgba(12,13,20,0.98) 0%, rgba(12,13,20,0.92) 72%, transparent 100%);
  backdrop-filter: blur(10px);
  display:none;
}
.twk-panel-body .dialkit-tbtn {
  width: var(--dial-row-height);
  height: var(--dial-row-height);
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(10,12,18,0.84);
}
.twk-panel-body .dialkit-tbtn:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(64,128,255,0.24);
}
.twk-panel-body .dialkit-tbtn svg {
  width: 12px;
  height: 12px;
}
/* Button */
.twk-panel-body .dialkit-button {
  min-height: calc(var(--dial-row-height) + 4px);
  font-size: 11px;
  border-radius: 6px;
  border: 1px solid rgba(64,128,255,0.28);
  background: rgba(64,128,255,0.12);
  color: #dbe6ff;
}
/* Toggle */
.twk-panel-body .dialkit-toggle-track {
  width: 30px;
  height: 16px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
}
.twk-panel-body .dialkit-toggle[data-checked=true] .dialkit-toggle-track {
  background: #4080ff;
}
.twk-panel-body .dialkit-toggle-thumb {
  width: 12px;
  height: 12px;
  top: 2px;
  left: 2px;
}
.twk-panel-body .dialkit-toggle[data-checked=true] .dialkit-toggle-thumb {
  left: 16px;
}
/* Color */
.twk-panel-body .dialkit-color-swatch {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border-color: rgba(255,255,255,0.1);
}
.twk-panel-body .dialkit-color-right {
  margin-left: auto;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}
.twk-panel-body .dialkit-color-hex {
  font-size: 11px;
  width: 9ch;
  font-family: 'SF Mono','Cascadia Code','Fira Code',monospace;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: #edf2ff;
}
/* Select */
.twk-panel-body .dialkit-select-value {
  font-size: 11px;
  color: #edf2ff;
}
.twk-panel-body .dialkit-select {
  padding-right: 10px;
}
.twk-panel-body .dialkit-folder-header {
  /* min-height: calc(var(--dial-row-height) + 2px); */
  position: relative;
  padding: 4px 2px;
  /* border-radius: 6px; */
  /* background: rgba(255,255,255,0.03); */
  cursor: pointer;
  user-select: none;
  display: flex;
  column-gap: 6px;
  align-content: center;
  justify-content: flex-start;
}
.twk-panel-body .dialkit-folder-header::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.06) 16%,
    rgba(255,255,255,0.12) 50%,
    rgba(255,255,255,0.06) 84%,
    transparent 100%
  );
}
.twk-panel-body .dialkit-folder-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: rgba(255,255,255,0.55);
  opacity: 0.7;
  transition: transform 0.18s cubic-bezier(0.2, 0, 0, 1);
}
.twk-panel-body .dialkit-folder[data-open=false] > .dialkit-folder-header .dialkit-folder-icon {
  transform: rotate(-90deg);
}
/* Pill */
.twk-panel-body .dialkit-pill {
  font-size: 8px;
  padding: 1px 5px;
  line-height: 14px;
  border-radius: 3px;
}
.twk-panel-body .dialkit-pill[data-on=true] {
  background: rgba(64,128,255,0.2);
  color: #6ea8fe;
}
/* Spring viz */
.twk-panel-body .dialkit-spring {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  background: rgba(10,12,18,0.8);
}
.twk-panel-body .dialkit-spring-head {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}
.twk-panel-body .dialkit-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: 100%;
  padding: 4px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
}
.twk-panel-body .dialkit-spring-viz {
  width: 100%;
  height: 92px !important;
  border-radius: 8px;
}
.twk-panel-body .dialkit-seg-btn {
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 4px;
  flex: 1 1 96px;
  min-height: 30px;
}
.twk-panel-body .dialkit-seg-btn[data-active=true] {
  background: rgba(64,128,255,0.12);
  color: #6ea8fe;
}
.twk-panel-body .dialkit-text-input {
  font-size: 11px;
  flex: 1 1 180px;
  max-width: 58%;
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  color: #edf2ff;
  text-align: right;
}
.twk-panel-body .dialkit-text-input:focus,
.twk-panel-body .dialkit-color-hex:focus,
.twk-panel-body .dialkit-slider-input:focus {
  outline: none;
  border-color: rgba(64,128,255,0.55);
  box-shadow: 0 0 0 1px rgba(64,128,255,0.18);
  background: rgba(255,255,255,0.06);
}

/* Dropdown override */
.twk-panel-body .dialkit-dropdown,
body > .dialkit-dropdown {
  background: #13151e;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  max-height: min(280px, calc(100vh - 24px));
  overflow-y: auto;
}
.twk-panel-body .dialkit-option,
body > .dialkit-dropdown .dialkit-option {
  font-size: 11px;
  padding: 7px 10px;
  border-radius: 4px;
}
.twk-panel-body .dialkit-option:hover,
body > .dialkit-dropdown .dialkit-option:hover {
  background: rgba(64,128,255,0.08);
}
.twk-panel-body .dialkit-option[data-selected=true],
body > .dialkit-dropdown .dialkit-option[data-selected=true] {
  background: rgba(64,128,255,0.15);
  color: #6ea8fe;
}

/* No controls state */
.twk-no-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 16px;
  text-align: center;
  color: #555a6a;
  gap: 8px;
}
.twk-no-controls i {
  font-size: 20px;
  color: #3a3d4a;
  margin-bottom: 4px;
}
.twk-no-controls span {
  font-size: 11px;
  font-weight: 500;
  color: #555a6a;
}
.twk-no-controls small {
  font-size: 10px;
  color: #3a3d4a;
  line-height: 1.4;
}

/* ── DialKit Mount & Native Overrides ── */
.twk-dialkit-parking {
  position: fixed;
  width: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.twk-dialkit-mount {
  display: flex;
  flex-direction: column;
  width: 100%;
}
.twk-dialkit-mount .dialkit-panel-inner {
  border: none;
  box-shadow: none;
  padding: 0;
  width: 100%;
}

/* ── Save Changes Button (matches inspect panel ins-merge-btn) ── */
.twk-save-btn {
  width: calc(100% - 24px);
  margin: 12px 12px;
  height: 26px;
  border: 1px solid #4080ff;
  background: #4080ff;
  color: #0c0d14;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 3px;
  transition: all 0.12s;
  position: sticky;
  bottom: 0;
  z-index: 5;
}
.twk-save-btn svg {
  flex-shrink: 0;
}
.twk-save-btn:hover {
  background: #5a9ef6;
  border-color: #5a9ef6;
}
.twk-save-btn:active {
  transform: scale(0.98);
}
.twk-save-btn.saving {
  background: rgba(64,128,255,0.16);
  border-color: rgba(64,128,255,0.5);
  color: #dbe6ff;
}
.twk-save-btn.saved {
  background: #34d399 !important;
  border-color: #34d399 !important;
  color: #0c0d14 !important;
}
.twk-save-btn.failed {
  background: rgba(217,48,37,0.14) !important;
  border-color: rgba(217,48,37,0.5) !important;
  color: #ffd7d3 !important;
}

/* ---------- Sidebar Integration (Tweaker Mode Active) ---------- */
#sidebar.twk-sidebar-active .chat-area,
#sidebar.twk-sidebar-active .chat-input-area,
#sidebar.twk-sidebar-active .chat-welcome {
  transition: opacity 0.35s ease, filter 0.35s ease, transform 0.35s ease;
}
#sidebar.twk-sidebar-active .chat-area,
#sidebar.twk-sidebar-active .chat-input-area,
#sidebar.twk-sidebar-active .chat-welcome {
  opacity: 0;
  filter: blur(8px);
  transform: translateX(-20px);
  pointer-events: none;
}
#sidebar.twk-sidebar-active .sidebar-header {
  opacity: 1 !important;
  filter: none !important;
  transform: none !important;
  pointer-events: auto !important;
  z-index: 35;
}

.twk-sidebar-content {
  position: absolute;
  top: 48px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  z-index: 20;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  opacity: 0;
  transform: translateX(30px);
  filter: blur(6px);
  transition: opacity 0.35s ease, filter 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}
.twk-sidebar-content.twk-sidebar-visible {
  opacity: 1;
  transform: translateX(0);
  filter: blur(0);
  pointer-events: auto;
}
/* Opaque gradient moving upward from bottom */
.twk-sidebar-content::before {
  content: '';
  position: absolute;
  inset: 0;
  background: none;
  pointer-events: none;
  z-index: -1;
}
.twk-sidebar-content .twk-panel-body,
.twk-sidebar-content .twk-panel-foot,
.twk-sidebar-content .twk-panel-foot::before {
  background: transparent;
}

/* Sidebar docked header — transparent, compact */
.twk-sidebar-content .twk-panel-hdr {
  background: transparent;
  padding: 8px 6px;
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(to right, transparent, #1e2030 15%, #1e2030 85%, transparent) 1;
  border-radius: 0;
}
.twk-sidebar-content .twk-panel-close {
  background: none;
  border: 1px solid #1e2030;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
}
.twk-sidebar-content .twk-panel-close:hover {
  background: rgba(255,255,255,0.06);
}
.twk-sidebar-content .twk-drag-handle {
  opacity: 0;
  cursor: grab;
  transition: opacity 0.15s;
}
.twk-sidebar-content .twk-panel-hdr:hover .twk-drag-handle {
  opacity: 1;
}
.twk-sidebar-content .twk-drag-handle:active {
  cursor: grabbing;
}
.twk-sidebar-content .twk-panel-foot {
  padding: 6px 10px;
  border-top: none;
  background: transparent;
  position: relative;
}
.twk-sidebar-content .twk-panel-foot::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(12,13,20,0.95) 30%, transparent 100%);
  pointer-events: none;
  z-index: -1;
}

/* Side-tabs texture when tweaker docked */
.side-tabs.twk-texture-active::after {
  content: '';
  display: block;
  flex: 1;
  min-height: 0;
  width: 30px;
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 4px,
    rgba(64,128,255,0.08) 4px,
    rgba(64,128,255,0.08) 5px
  );
  opacity: 1;
  margin-top: 4px;
  transition: opacity 0.35s ease;
}

/* ---------- Vertical Chat Tab (when tweaker docked) ---------- */
.twk-chat-tab {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%) translateX(-100%);
  z-index: 2147483647;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-sidebar, #000);
  border: 1px solid #1A1A1A;
  border-left: none;
  border-radius: 0 6px 6px 0;
  cursor: pointer;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: #858b98;
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.25s ease,
              color 0.15s ease,
              background 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
}
.twk-chat-tab.twk-chat-tab-visible {
  transform: translateY(-50%) translateX(0);
  opacity: 1;
  pointer-events: auto;
}
.twk-chat-tab:hover {
  color: #e1e3ea;
  background: rgb(32, 32, 32);
}
.twk-chat-tab i {
  font-size: 12px;
  writing-mode: horizontal-tb;
}
