.modal-trim-crop {
  position: fixed;
  inset: 0;
  height: 100%;
  min-height: -webkit-fill-available;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  justify-content: center;
  align-items: flex-end;
  z-index: 1000;
  overflow: hidden;
  opacity: 0;
  transition: transform 0.28s ease-out, opacity 0.25s;
}

.modal-trim-crop.show {
  opacity: 1;
}

.modal-content {
  background: #ffffff;
  width: 100%;
  max-width: 100%;
  height: calc(100% - 100px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  border-radius: 12px 12px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.3);
  transform: translateY(100%);
  transition: transform 0.28s ease-out, opacity 0.25s;
  padding: 0px 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-sizing: border-box;
  backface-visibility: hidden;
  will-change: transform, opacity;
}

.modal-trim-crop.show .modal-content {
  transform: translateY(0) !important;
}

html.modal-open, body.modal-open {
  height: 100dvh !important;
  overflow: hidden !important;
  position: fixed;
  width: 100%;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  border-bottom: 1px solid #F2F0F0;
}

.modal-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: rgba(0, 0, 0, 1);
  margin: 0;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #999;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.15s ease-out;
}

.btn-close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #666;
}

.crop-info-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-radius: 0.3rem;
}

.crop-dimensions {
  display: flex;
  gap: 16px;
}

.dimension-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.dimension-item label {
  font-size: 0.6rem;
  font-weight: 600;
  color: rgba(147, 147, 147, 1);
}

.dimension-value {
  font-size: 0.6rem;
  font-weight: 600;
  color: rgba(147, 147, 147, 1);
  text-align: center;
}

.btn-done {
  background: #667eea;
  color: white;
  border: none;
  border-radius: 0.3rem;
  padding: 7px 11px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease-out;
}

.btn-done:hover {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  transform: translateY(-1px);
}

.video-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: rgba(147, 147, 147, 1);
  height: 200px;
  max-height: 200px;
  z-index: 1;
}

.video-element {
  width: 100%;
  height: 100%;
  display: block;
  max-height: 200px;
  object-fit: contain;
  position: relative;
  z-index: 1;
}

.crop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.3s ease-out;
  display: none;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.crop-overlay.visible {
  opacity: 1 !important;
  display: block !important;
}

.crop-overlay-top,
.crop-overlay-bottom,
.crop-overlay-left,
.crop-overlay-right {
  position: absolute;
  background: rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 49;
}

.crop-overlay-top {
  top: 0;
  left: 0;
  right: 0;
}

.crop-overlay-bottom {
  bottom: 0;
  left: 0;
  right: 0;
}

.crop-overlay-left {
  top: 0;
  bottom: 0;
  left: 0;
}

.crop-overlay-right {
  top: 0;
  bottom: 0;
  right: 0;
}

.crop-selection {
  position: absolute;
  cursor: move;
  pointer-events: auto;
  border: 3px solid #667eea;
  box-shadow: none;
  will-change: transform;
  transform: translate3d(0, 0, 0);
  background: transparent;
  z-index: 51;
  min-width: 30px;
  min-height: 30px;
  touch-action: none;
  user-select: none;
  transition: transform 0.08s linear;
  left: 0;
  top: 0;
  width: 100px;
  height: 100px;
}

.crop-selection::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border: 2px solid #667eea;
  pointer-events: none;
}

.crop-selection.fixed-ratio {
  cursor: move;
}

.crop-selection.fixed-ratio .crop-handle[data-corner="nw"],
.crop-selection.fixed-ratio .crop-handle[data-corner="se"] {
  cursor: nwse-resize;
}

.crop-selection.fixed-ratio .crop-handle[data-corner="ne"],
.crop-selection.fixed-ratio .crop-handle[data-corner="sw"] {
  cursor: nesw-resize;
}

.crop-selection[data-ratio="1:1"] {
  cursor: move;
}

.crop-selection[data-ratio="1:1"] .crop-handle {
  cursor: nwse-resize;
}

.crop-selection.dragging {
  transition: none !important;
  animation: none !important;
}

.crop-handle {
  position: absolute;
  background: #ffffff;
  border: 2px solid #667eea;
  width: 8px;
  height: 8px;
  z-index: 52;
  pointer-events: auto;
  transition: all 0.15s ease-out;
  transform: translate3d(0, 0, 0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  touch-action: none;
  user-select: none;
}

.crop-handle:hover {
  transform: scale(1.2);
  background: #667eea;
  border-color: #ffffff;
  box-shadow: 0 4px 8px rgba(102, 126, 234, 0.6);
}

.crop-handle.dragging {
  transition: none;
  transform: scale(1.4);
  background: #667eea;
  border-color: #ffffff;
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.8);
}

.crop-handle[data-corner="nw"] {
  top: -4px;
  left: -4px;
  cursor: nw-resize;
}

.crop-handle[data-corner="ne"] {
  top: -4px;
  right: -4px;
  cursor: ne-resize;
}

.crop-handle[data-corner="sw"] {
  bottom: -4px;
  left: -4px;
  cursor: sw-resize;
}

.crop-handle[data-corner="se"] {
  bottom: -4px;
  right: -4px;
  cursor: se-resize;
}

.play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.15s ease-out;
}

.play-overlay:hover {
  opacity: 1;
}

.video-timeline {
  position: relative;
  width: 100%;
  font-family: sans-serif;
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
}

.timeline-playpause {
  width: 20px;
  height: 20px;
  border: 2px solid #BFBCBC;
  border-radius: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  margin-top: 5px;
}

.timeline-track {
  position: relative;
}

.timeline-segment {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 3px;
  border-radius: 2px;
}

.timeline-segment-left {
  left: 0;
  background: #C0C0C0;
  width: 10%;
}

.timeline-segment-active {
  background: rgba(56, 200, 104, 1);
  left: 10%;
  width: 80%;
}

.timeline-segment-right {
  right: 0;
  background: #C0C0C0;
  width: 10%;
}

.timeline-handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  max-width: 20px;
  max-height: 20px;
  cursor: ew-resize;
  z-index: 10;
  user-select: none;
  touch-action: none;
  border-radius: 50%;
}

.timeline-handle-left {
  left: 10%;
}

.timeline-handle-right {
  left: 90%;
}

.handle-circle {
  width: 20px !important;
  height: 20px !important;
  border: 2px solid #BFBCBC;
  background-color: #FFFFFF;
  padding: 0 !important;
  margin: 0 !important;
  box-sizing: border-box !important;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.time-start,
.time-end {
  position: absolute;
  top: 22px;
  font-size: 12px;
  color: #bbb;
  font-weight: 500;
  pointer-events: none;
  white-space: nowrap;
  transition: left 0.1s;
  z-index: 20;
  display: block;
}

.timeline-playhead {
  position: absolute;
  top: 1px;
  z-index: 50;
}

.playhead-icon {
  width: 12px;
  height: 12px;
}

.playhead-icon.play polygon {
  fill: #444;
}

.playhead-icon.pause rect {
  fill: #444;
}

.crop-ratios {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border: 1px solid #F2F2F2;
  border-right: none;
  border-left: none;
}

.ratio-btn {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: #FFF;
  border: 1px solid #D0CFCF;
  border-radius: 0.3rem;
  cursor: pointer;
  transition: all 0.15s ease-out;
}

.ratio-btn:hover {
  background: rgba(248, 245, 245, 1);
  transform: translateY(-2px);
}

.ratio-btn.active {
  background: #E7F0FF;
  color: #838181;
  border-color: #D2E2FE;
}

.ratio-btn img {
  width: 15px;
  height: 15px;
}

.ratio-btn span {
  font-size: 0.6rem;
  color: #838181;
}

.flip-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 9px;
}

.flip-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: #FFFF;
  border: 1px solid #D0CFCF;
  border-radius: 0.3rem;
  cursor: pointer;
  transition: all 0.15s ease-out;
  flex: 1;
  max-width: 90px;
  justify-content: center;
}

.flip-btn:hover {
  background: rgba(248, 245, 245, 1);
}

.flip-btn.active {
  background: #E7F0FF;
  color: #838181;
  border-color: #D2E2FE;
}

.flip-btn img {
  width: 16px;
  height: 16px;
}

.flip-btn span {
  font-size: 0.6rem;
  font-weight: 500;
  color: #939393;
}

@media (max-width: 768px) {
  .modal-content {
    height: calc(100% - 90px);
    padding: 0 8px;
  }
  .timeline-playhead {
    left: var(--playhead-position, 6.6%);
  }
  
  .crop-dimensions {
    gap: 8px;
  }
  
  .dimension-item {
    gap: 2px;
  }
  
  .dimension-value {
    min-width: 30px;
    font-size: 0.7rem;
  }

  .time-end {
    left: -17px;
  }
  
  .ratio-btn {
    min-width: 50px;
    padding: 4px;
  }
  
  .video-timeline {
    margin-bottom: 40px;
    margin-top: 10px;
  }
  
  .handle-circle {
    width: 16px !important;
    height: 16px !important;
  }
  
  .timeline-playhead {
    width: 16px;
    height: 16px;
  }
  
  .playhead-icon {
    width: 10px;
    height: 10px;
  }
  
  .time-start,
  .time-end {
    font-size: 10px;
    top: 20px;
  }
}

@media (max-width: 480px) {
  .time-end {
    left: -17px;
  }

  .timeline-playhead {
    left: var(--playhead-position, 6.6%);
  }
  
  .crop-handle {
    width: 10px;
    height: 10px;
  }
  
  .crop-handle[data-corner="nw"] {
    top: -5px;
    left: -5px;
  }
  
  .crop-handle[data-corner="ne"] {
    top: -5px;
    right: -5px;
  }
  
  .crop-handle[data-corner="sw"] {
    bottom: -5px;
    left: -5px;
  }
  
  .crop-handle[data-corner="se"] {
    bottom: -5px;
    right: -5px;
  }
  
  .video-timeline {
    margin-bottom: 10px;
  }
  
  .handle-circle {
    width: 14px !important;
    height: 14px !important;
  }
  
  .timeline-playhead {
    width: 14px;
    height: 14px;
  }
  
  .playhead-icon {
    width: 8px;
    height: 8px;
  }
  
  .time-start,
  .time-end {
    font-size: 9px;
    top: 18px;
  }
}

@keyframes cropOverlayFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.crop-overlay.visible {
  animation: cropOverlayFadeIn 0.3s ease-out;
}

@keyframes modalSlideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.modal-trim-crop.show .modal-content {
  animation: modalSlideUp 0.3s ease-out;
}

.crop-handle-hidden {
  opacity: 0;
  pointer-events: none;
}

.crop-handle-visible {
  opacity: 1;
  pointer-events: auto;
}

.crop-selection-moving {
  transition: none;
}

.crop-handle-dragging {
  transition: none;
}

.crop-selection-dragging {
  transition: none;
}

.advanced-btn {
  display: flex;
  align-items: center;
  gap: 8px;
}

.about-icon {
  background-color: transparent;
  border: none;
  cursor: pointer;
  border-radius: 0.3rem;
  transition: all 0.3s ease;
  width: auto;
  height: 20px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  color: #333;
  text-overflow: ellipsis;
  max-width: 100px;
}

.about-icon span,
.about-icon svg {
  color: #939393;
}

.control-group-advanced {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}

.timeline-track {
  position: relative;
  margin-bottom: 15px;
  height: 30px;
  width: calc(100% - 25px);
}

.time-end {
  left: -22px;
}

@keyframes cropSelectionAppear {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes handlePulse {
  0%, 100% {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  }
  50% {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 0 0 4px rgba(102, 126, 234, 0.3);
  }
}