/* Modern TikTok Studio Effect Dock & Wide 8-Column Desktop Catalog (r28).
   - Beats codex-studio.css (1,4,0) max-height:280px rule with (1,5,1) -> ZERO vertical clipping!
   - Desktop (>=900px): width: min(760px, 92vw) with 6-8 column grid & scrollable max-height: 240px!
   - Cards: 68x84px rounded rectangles (border-radius: 14px) with vivid category badge + clean 2-line Russian title (NO ugly cartoon faces!).
   - Header horizontal intensity slider: default 40%, smooth 0-100% range. */

/* 1. Unconditionally hide legacy rectangular green rows */
.codex-studio #studioControlsBar > .studio-top-row,
.codex-studio #studioControlsBar > .studio-slider-row,
.codex-studio #studioControlsBar > #beautyFoldersBar,
.codex-studio #studioControlsBar > #beautyMasksCarousel,
.codex-studio #studioControlsBar > #teltvMaskSearch,
.codex-studio #studioControlsBar > #teltvBodyMaskHint,
.codex-studio #studioControlsBar > .teltv-panel-handle,
.codex-studio #studioControlsBar > .teltv-panel-content {
  display: none !important;
}

/* 2. Tuck #bottomBar away while TikTok Studio Dock is open */
body.tt-effects-open #bottomBar,
body.tt-effects-open #expandBottomBarBtn {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: translate3d(-50%, 130%, 0) !important;
  transition: opacity 0.16s ease, transform 0.18s ease !important;
}

/* 3. Main Dock Container — higher specificity than codex-studio.css line 265 so max-height NEVER clips cards! */
body.codex-studio #studioControlsBar,
body.codex-studio #studioControlsBar.tt-studio-ready:not(.hidden):not(.teltv-panel-outside-call):not(.teltv-panel-compact) {
  position: fixed !important;
  left: 50% !important;
  right: auto !important;
  top: auto !important;
  bottom: var(--teltv-tiktok-dock-bottom, max(10px, env(safe-area-inset-bottom, 0px))) !important;
  transform: translateX(-50%) !important;
  width: min(680px, calc(100vw - 12px)) !important;
  max-width: calc(100vw - 12px) !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  z-index: 245 !important;
  padding: 6px 8px 6px !important;
  border-radius: 20px !important;
  background: rgba(10, 12, 20, 0.56) !important;
  border: 1px solid rgba(255, 255, 255, 0.14) !important;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.50) !important;
  backdrop-filter: blur(14px) saturate(135%) !important;
  -webkit-backdrop-filter: blur(14px) saturate(135%) !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 6px !important;
  overflow: visible !important;
  color: #ffffff !important;
  box-sizing: border-box !important;
  pointer-events: auto !important;
}

@media (min-width: 900px) {
  body.codex-studio #studioControlsBar,
  body.codex-studio #studioControlsBar.tt-studio-ready:not(.hidden):not(.teltv-panel-outside-call):not(.teltv-panel-compact) {
    width: min(760px, 92vw) !important;
    max-width: 92vw !important;
  }
}

/* Expanded Full Catalog Mode */
body.codex-studio #studioControlsBar.tt-sheet-expanded,
body.codex-studio #studioControlsBar.tt-studio-ready.tt-sheet-expanded:not(.hidden):not(.teltv-panel-outside-call):not(.teltv-panel-compact) {
  padding: 10px 14px 10px !important;
  border-radius: 22px !important;
  background: rgba(12, 14, 22, 0.92) !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  box-shadow: 0 22px 64px rgba(0, 0, 0, 0.80) !important;
  backdrop-filter: blur(22px) saturate(145%) !important;
  -webkit-backdrop-filter: blur(22px) saturate(145%) !important;
  max-height: calc(100dvh - 64px) !important;
  overflow: visible !important;
}

body.codex-studio #studioControlsBar.hidden,
body.codex-studio #studioControlsBar.teltv-panel-outside-call {
  display: none !important;
}

/* Contextual photo upload & censor gender pills (compact so grid below NEVER clips!) */
.codex-studio #studioControlsBar #faceSwapToolsRow:not(.hidden),
.codex-studio #studioControlsBar #customBgToolsRow:not(.hidden),
.codex-studio #studioControlsBar #censorGenderToolsRow:not(.hidden) {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 2px 0;
  margin: 0 !important;
  flex-wrap: wrap;
  flex-shrink: 0 !important;
}

.codex-studio #studioControlsBar #faceSwapToolsRow button,
.codex-studio #studioControlsBar #customBgToolsRow button,
.codex-studio #studioControlsBar #censorGenderToolsRow button {
  min-height: 28px !important;
  height: 28px !important;
  padding: 3px 13px !important;
  border-radius: 999px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  cursor: pointer;
}

.codex-studio #studioControlsBar #censorGenderToolsRow .tt-gender-label {
  font-size: 11.5px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.78);
}

.codex-studio #studioControlsBar #censorGenderToolsRow .tt-gender-btn {
  background: rgba(255, 255, 255, 0.12) !important;
  color: rgba(255, 255, 255, 0.88) !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
}

.codex-studio #studioControlsBar #censorGenderToolsRow .tt-gender-btn.is-active {
  background: #fe2c55 !important;
  color: #ffffff !important;
  border-color: #ff6b81 !important;
}

/* 4. Header Intensity Slider Pill (Default 40%, Range 0–100%) */
.codex-studio #studioControlsBar .tt-slider-pill {
  align-self: center !important;
  width: min(460px, 100%) !important;
  min-height: 32px !important;
  height: 32px !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 0 14px !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  border-radius: 999px !important;
  background: rgba(18, 21, 32, 0.82) !important;
  border: 1px solid rgba(255, 255, 255, 0.20) !important;
  pointer-events: auto !important;
  flex-shrink: 0 !important;
}

.codex-studio #studioControlsBar.tt-sheet-expanded .tt-slider-pill {
  width: 100% !important;
  background: rgba(255, 255, 255, 0.08) !important;
}

.codex-studio #studioControlsBar .tt-slider-pill.tt-hidden {
  display: none !important;
}

.tt-slider-name {
  flex: 0 1 auto;
  max-width: 165px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.96);
  font-size: 11.5px;
  font-weight: 700;
}

.codex-studio #studioControlsBar input[type="range"].tt-horiz-range {
  -webkit-appearance: none !important;
  appearance: none !important;
  flex: 1 1 140px !important;
  width: auto !important;
  min-width: 110px !important;
  height: 6px !important;
  min-height: 6px !important;
  max-height: 6px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 999px !important;
  outline: none !important;
  transform: none !important;
  background: linear-gradient(
    90deg,
    #fe2c55 0%,
    #fe2c55 var(--tt-pct, 40%),
    rgba(255, 255, 255, 0.26) var(--tt-pct, 40%),
    rgba(255, 255, 255, 0.26) 100%
  ) !important;
  cursor: pointer !important;
}

.codex-studio #studioControlsBar input[type="range"].tt-horiz-range::-webkit-slider-runnable-track {
  height: 6px !important;
  border-radius: 999px !important;
  background: transparent !important;
}

.codex-studio #studioControlsBar input[type="range"].tt-horiz-range::-webkit-slider-thumb {
  -webkit-appearance: none !important;
  appearance: none !important;
  width: 18px !important;
  height: 18px !important;
  margin-top: -6px !important;
  border-radius: 50% !important;
  background: #ffffff !important;
  border: 2.5px solid #fe2c55 !important;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.72) !important;
  cursor: pointer !important;
}

.codex-studio #studioControlsBar input[type="range"].tt-horiz-range::-moz-range-thumb {
  width: 16px !important;
  height: 16px !important;
  border-radius: 50% !important;
  background: #ffffff !important;
  border: 2.5px solid #fe2c55 !important;
  cursor: pointer !important;
}

.tt-slider-pct {
  flex: 0 0 36px;
  text-align: right;
  font-size: 11.5px;
  font-weight: 800;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}

/* 5. Search Row (Expanded mode) & Clickable Category Tabs (Always clickable in both modes!) */
.tt-search-row {
  display: none;
  align-items: center;
  gap: 6px;
  flex-shrink: 0 !important;
}

#studioControlsBar.tt-sheet-expanded .tt-search-row {
  display: flex !important;
}

.tt-tabs-row {
  display: flex !important;
  align-items: center;
  gap: 4px;
  flex-shrink: 0 !important;
  min-height: 30px !important;
}

.tt-search-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.tt-search-icon {
  position: absolute;
  left: 12px;
  font-size: 13px;
  opacity: 0.7;
  pointer-events: none;
}

.tt-search-field {
  width: 100%;
  min-height: 34px !important;
  height: 34px !important;
  padding: 5px 32px 5px 34px !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.10) !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  color: #ffffff !important;
  font-size: 13.5px !important;
  outline: none !important;
}

.tt-search-field::placeholder {
  color: rgba(255, 255, 255, 0.55) !important;
}

.tt-search-clear {
  position: absolute;
  right: 7px;
  width: 22px !important;
  height: 22px !important;
  min-height: 22px !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.20) !important;
  color: #fff !important;
  font-size: 11px !important;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0 !important;
}

.tt-search-clear.tt-hidden {
  display: none !important;
}

.tt-tabs-strip {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  padding: 2px 2px 4px;
  cursor: grab;
}

.tt-tabs-strip::-webkit-scrollbar {
  display: none;
}

.tt-cat-tab {
  position: relative;
  flex: 0 0 auto;
  min-height: 28px !important;
  height: 28px !important;
  padding: 0 11px !important;
  border: 1px solid rgba(255, 255, 255, 0.10) !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, 0.06) !important;
  color: rgba(255, 255, 255, 0.78) !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  white-space: nowrap !important;
  cursor: pointer;
  display: inline-flex !important;
  align-items: center !important;
}

.tt-cat-tab:hover {
  color: #ffffff !important;
  background: rgba(255, 255, 255, 0.14) !important;
}

.tt-cat-tab.is-active {
  color: #ffffff !important;
  background: rgba(254, 44, 85, 0.28) !important;
  border-color: #fe2c55 !important;
}

/* 6. Single-Row Collapsed Ribbon (Explicit min-height: 94px -> ZERO vertical clipping of 68x84px cards!) */
.tt-wheel-wrap {
  position: relative;
  display: flex !important;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 94px !important;
  flex-shrink: 0 !important;
}

#studioControlsBar.tt-sheet-expanded .tt-wheel-wrap {
  display: none !important;
}

.tt-wheel-nav {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  min-height: 28px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  background: rgba(18, 22, 34, 0.78) !important;
  border: 1px solid rgba(255, 255, 255, 0.22) !important;
  color: #ffffff !important;
  font-size: 18px !important;
  line-height: 1 !important;
  display: grid !important;
  place-items: center !important;
  cursor: pointer;
  flex-shrink: 0;
}

.tt-wheel-nav:hover {
  background: rgba(254, 44, 85, 0.65) !important;
}

@media (max-width: 560px) and (pointer: coarse) {
  .tt-wheel-nav {
    display: none !important;
  }
}

.tt-carousel-viewport {
  flex: 1;
  min-width: 0;
  min-height: 92px !important;
  height: auto !important;
  display: flex !important;
  align-items: stretch;
  gap: 8px;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  padding: 4px 6px !important;
  cursor: grab;
}

.tt-carousel-viewport::-webkit-scrollbar {
  display: none;
}

/* 7. Wide Multi-Column Expanded Catalog Grid (6–9 columns on PC, explicit min-height + scrollable max-height: 240px!) */
.tt-grid-viewport {
  display: none;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 8px 8px;
  min-height: 184px !important;
  max-height: 240px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 4px 4px 6px !important;
  flex: 0 0 auto !important;
  scrollbar-width: thin;
  scrollbar-color: rgba(254, 44, 85, 0.65) rgba(255, 255, 255, 0.08);
}

#studioControlsBar.tt-sheet-expanded .tt-grid-viewport {
  display: grid !important;
}

@media (max-width: 600px) {
  .tt-grid-viewport {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    min-height: 176px !important;
    max-height: 220px !important;
  }
}

/* 8. Modern TikTok Studio Rounded-Rectangle Effect Card: 68x84px, border-radius: 14px! */
.tt-fx-item {
  width: 68px !important;
  min-width: 68px !important;
  height: 84px !important;
  min-height: 84px !important;
  flex: 0 0 68px !important;
  padding: 5px 4px 4px !important;
  box-sizing: border-box !important;
  border-radius: 14px !important;
  background: rgba(24, 28, 40, 0.78) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.14) !important;
  color: #ffffff !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 4px !important;
  cursor: pointer;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.tt-grid-viewport .tt-fx-item {
  width: 100% !important;
  min-width: 0 !important;
  flex: initial !important;
}

.tt-fx-item:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.48) !important;
  background: rgba(34, 39, 56, 0.90) !important;
}

.tt-fx-item.is-selected {
  border: 2px solid #fe2c55 !important;
  background: rgba(254, 44, 85, 0.22) !important;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35), 0 6px 16px rgba(254, 44, 85, 0.35) !important;
}

.tt-fx-badge {
  width: 56px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.tt-fx-glyph {
  font-size: 21px;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
}

.tt-fx-tag {
  position: absolute;
  right: 3px;
  top: 3px;
  padding: 1px 3.5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.52);
  color: #fff;
  font-size: 7.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

/* Crisp 2-line Russian title visible in BOTH Collapsed Strip & Expanded Grid! */
.tt-fx-label {
  width: 100%;
  height: 25px;
  font-size: 10px !important;
  font-weight: 600 !important;
  line-height: 12px !important;
  color: rgba(255, 255, 255, 0.95) !important;
  white-space: normal !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  word-break: break-word;
}

/* 9. Bottom Control Pill Row */
.tt-dock-footer {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0;
  flex-shrink: 0 !important;
}

.tt-icon-circle-btn {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  min-height: 34px !important;
  padding: 0 !important;
  border-radius: 50% !important;
  background: rgba(28, 30, 42, 0.88) !important;
  border: 1px solid rgba(255, 255, 255, 0.20) !important;
  color: #ffffff !important;
  font-size: 15px !important;
  display: grid !important;
  place-items: center !important;
  cursor: pointer;
  flex-shrink: 0;
}

.tt-icon-circle-btn.tt-close-white {
  background: #ffffff !important;
  color: #0f172a !important;
  font-weight: 800 !important;
  border: 0 !important;
}

.tt-icon-circle-btn.is-fav {
  color: #facc15 !important;
  border-color: rgba(250, 204, 21, 0.70) !important;
}

.tt-all-effects-pill {
  min-width: 185px;
  max-width: 250px;
  flex: 0 1 225px;
  min-height: 34px !important;
  height: 34px !important;
  padding: 0 16px !important;
  border-radius: 999px !important;
  background: rgba(28, 30, 42, 0.90) !important;
  border: 1px solid rgba(255, 255, 255, 0.20) !important;
  color: #ffffff !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 7px !important;
  cursor: pointer;
  white-space: nowrap;
}

.tt-rec-cluster {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.tt-dock-footer #studioRecordBtn {
  min-height: 34px !important;
  height: 34px !important;
  padding: 0 13px !important;
  border-radius: 999px !important;
  background: rgba(254, 44, 85, 0.92) !important;
  border: 1px solid rgba(255, 255, 255, 0.35) !important;
  color: #ffffff !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 5px !important;
  cursor: pointer;
}

.tt-dock-footer #studioDownloadBtn:not(.hidden),
.tt-dock-footer #studioDeleteProjectBtn:not(.hidden) {
  min-height: 34px !important;
  height: 34px !important;
  padding: 0 12px !important;
  border-radius: 999px !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  display: inline-flex !important;
  align-items: center !important;
}

.tt-empty-msg {
  grid-column: 1 / -1;
  text-align: center;
  padding: 24px 12px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
}
